Changeset 69
- Timestamp:
- Jan 14, 2006, 6:36:36 PM (20 years ago)
- Location:
- GPL/trunk/alsa-kernel/pci/hda
- Files:
-
- 1 added
- 12 edited
-
hda_codec.c (modified) (72 diffs)
-
hda_codec.h (modified) (16 diffs)
-
hda_generic.c (modified) (31 diffs)
-
hda_intel.c (modified) (77 diffs)
-
hda_local.h (modified) (7 diffs)
-
hda_patch.h (modified) (1 diff)
-
hda_proc.c (modified) (13 diffs)
-
makefile.os2 (modified) (1 diff)
-
patch_analog.c (modified) (23 diffs)
-
patch_cmedia.c (modified) (34 diffs)
-
patch_realtek.c (modified) (18 diffs)
-
patch_si3054.c (added)
-
patch_sigmatel.c (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk/alsa-kernel/pci/hda/hda_codec.c
r32 r69 49 49 /* codec vendor labels */ 50 50 static struct hda_vendor_id hda_vendor_ids[] = { 51 { 0x10ec, "Realtek" },52 { 0x11d4, "Analog Devices" },53 { 0x13f6, "C-Media" },54 { 0x434d, "C-Media" },55 { 0x8384, "SigmaTel" },56 {0} /* terminator */51 { 0x10ec, "Realtek" }, 52 { 0x11d4, "Analog Devices" }, 53 { 0x13f6, "C-Media" }, 54 { 0x434d, "C-Media" }, 55 { 0x8384, "SigmaTel" }, 56 {0} /* terminator */ 57 57 }; 58 58 … … 156 156 { 157 157 unsigned int parm; 158 int i, j, conn_len, num_tupples, conns;158 int i, conn_len, conns; 159 159 unsigned int shift, num_elems, mask; 160 hda_nid_t prev_nid; 160 161 161 162 snd_assert(conn_list && max_conns > 0, return -EINVAL); … … 172 173 } 173 174 conn_len = parm & AC_CLIST_LENGTH; 174 num_tupples = num_elems / 2;175 175 mask = (1 << (shift-1)) - 1; 176 176 … … 187 187 /* multi connection */ 188 188 conns = 0; 189 for (i = 0; i < conn_len; i += num_elems) { 190 parm = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_LIST, i); 191 for (j = 0; j < num_tupples; j++) { 192 int range_val; 193 hda_nid_t val1, val2, n; 194 range_val = parm & (1 << (shift-1)); /* ranges */ 195 val1 = parm & mask; 196 parm >>= shift; 197 val2 = parm & mask; 198 parm >>= shift; 199 if (range_val) { 200 /* ranges between val1 and val2 */ 201 if (val1 > val2) { 202 snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", val1, val2); 203 continue; 189 prev_nid = 0; 190 for (i = 0; i < conn_len; i++) { 191 int range_val; 192 hda_nid_t val, n; 193 194 if (i % num_elems == 0) 195 parm = snd_hda_codec_read(codec, nid, 0, 196 AC_VERB_GET_CONNECT_LIST, i); 197 range_val = !! (parm & (1 << (shift-1))); /* ranges */ 198 val = parm & mask; 199 parm >>= shift; 200 if (range_val) { 201 /* ranges between the previous and this one */ 202 if (! prev_nid || prev_nid >= val) { 203 snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", prev_nid, val); 204 continue; 205 } 206 for (n = prev_nid + 1; n <= val; n++) { 207 if (conns >= max_conns) { 208 snd_printk(KERN_ERR "Too many connections\n"); 209 return -EINVAL; 204 210 } 205 for (n = val1; n <= val2; n++) { 206 if (conns >= max_conns) 207 return -EINVAL; 208 conn_list[conns++] = n; 209 } 210 } else { 211 if (! val1) 212 break; 213 if (conns >= max_conns) 214 return -EINVAL; 215 conn_list[conns++] = val1; 216 if (! val2) 217 break; 218 if (conns >= max_conns) 219 return -EINVAL; 220 conn_list[conns++] = val2; 211 conn_list[conns++] = n; 221 212 } 213 } else { 214 if (conns >= max_conns) { 215 snd_printk(KERN_ERR "Too many connections\n"); 216 return -EINVAL; 217 } 218 conn_list[conns++] = val; 222 219 } 220 prev_nid = val; 223 221 } 224 222 return conns; … … 240 238 int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex) 241 239 { 242 #if 0243 240 struct hda_bus_unsolicited *unsol; 244 241 unsigned int wp; … … 255 252 256 253 queue_work(unsol->workq, &unsol->work); 257 #endif 254 258 255 return 0; 259 256 } … … 288 285 static int init_unsol_queue(struct hda_bus *bus) 289 286 { 290 #if 0291 287 struct hda_bus_unsolicited *unsol; 292 288 293 unsol = kcalloc(1, sizeof(*unsol), GFP_KERNEL); 289 if (bus->unsol) /* already initialized */ 290 return 0; 291 292 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); 294 293 if (! unsol) { 295 294 snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); … … 303 302 } 304 303 INIT_WORK(&unsol->work, process_unsol_events, bus); 305 bus->unsol = unsol; 306 #endif 304 bus->unsol = unsol; 307 305 return 0; 308 306 } … … 319 317 if (! bus) 320 318 return 0; 321 if (bus->unsol) { 322 #if 0 323 destroy_workqueue(bus->unsol->workq); 324 #endif 319 if (bus->unsol) { 320 destroy_workqueue(bus->unsol->workq); 325 321 kfree(bus->unsol); 326 322 } … … 335 331 } 336 332 337 static int snd_hda_bus_dev_free(s nd_device_t*device)333 static int snd_hda_bus_dev_free(struct snd_device *device) 338 334 { 339 335 struct hda_bus *bus = device->device_data; … … 349 345 * Returns 0 if successful, or a negative error code. 350 346 */ 351 int snd_hda_bus_new(s nd_card_t*card, const struct hda_bus_template *temp,347 int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, 352 348 struct hda_bus **busp) 353 349 { 354 350 struct hda_bus *bus; 355 351 int err; 356 static s nd_device_ops_tdev_ops = {357 /*.dev_free = */snd_hda_bus_dev_free,0,0,0352 static struct snd_device_ops dev_ops = { 353 .dev_free = snd_hda_bus_dev_free, 358 354 }; 359 355 … … 364 360 *busp = NULL; 365 361 366 bus = k calloc(1,sizeof(*bus), GFP_KERNEL);362 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 367 363 if (bus == NULL) { 368 364 snd_printk(KERN_ERR "can't allocate struct hda_bus\n"); … … 378 374 init_MUTEX(&bus->cmd_mutex); 379 375 INIT_LIST_HEAD(&bus->codec_list); 380 381 init_unsol_queue(bus);382 376 383 377 if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { … … 438 432 439 433 /* 440 * look for an AFG node 441 * 442 * return 0 if not found 443 */ 444 static int look_for_afg_node(struct hda_codec *codec) 434 * look for an AFG and MFG nodes 435 */ 436 static void setup_fg_nodes(struct hda_codec *codec) 445 437 { 446 438 int i, total_nodes; … … 448 440 449 441 total_nodes = snd_hda_get_sub_nodes(codec, AC_NODE_ROOT, &nid); 450 for (i = 0; i < total_nodes; i++, nid++) { 451 if ((snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE) & 0xff) == 452 AC_GRP_AUDIO_FUNCTION) 453 return nid; 454 } 455 return 0; 456 } 442 for (i = 0; i < total_nodes; i++, nid++) { 443 switch((snd_hda_param_read(codec, nid, AC_PAR_FUNCTION_TYPE) & 0xff)) { 444 case AC_GRP_AUDIO_FUNCTION: 445 codec->afg = nid; 446 break; 447 case AC_GRP_MODEM_FUNCTION: 448 codec->mfg = nid; 449 break; 450 default: 451 break; 452 } 453 } 454 } 455 456 /* 457 * read widget caps for each widget and store in cache 458 */ 459 static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) 460 { 461 int i; 462 hda_nid_t nid; 463 464 codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node, 465 &codec->start_nid); 466 codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL); 467 if (! codec->wcaps) 468 return -ENOMEM; 469 nid = codec->start_nid; 470 for (i = 0; i < codec->num_nodes; i++, nid++) 471 codec->wcaps[i] = snd_hda_param_read(codec, nid, 472 AC_PAR_AUDIO_WIDGET_CAP); 473 return 0; 474 } 475 457 476 458 477 /* … … 467 486 if (codec->patch_ops.free) 468 487 codec->patch_ops.free(codec); 488 kfree(codec->amp_info); 489 kfree(codec->wcaps); 469 490 kfree(codec); 470 491 } … … 495 516 } 496 517 497 codec = k calloc(1,sizeof(*codec), GFP_KERNEL);518 codec = kzalloc(sizeof(*codec), GFP_KERNEL); 498 519 if (codec == NULL) { 499 520 snd_printk(KERN_ERR "can't allocate struct hda_codec\n"); … … 513 534 codec->revision_id = snd_hda_param_read(codec, AC_NODE_ROOT, AC_PAR_REV_ID); 514 535 515 /* FIXME: support for multiple AFGs? */ 516 codec->afg = look_for_afg_node(codec); 517 if (! codec->afg) { 518 snd_printk(KERN_ERR "hda_codec: no AFG node found\n"); 536 setup_fg_nodes(codec); 537 if (! codec->afg && ! codec->mfg) { 538 snd_printdd("hda_codec: no AFG or MFG node found\n"); 519 539 snd_hda_codec_free(codec); 520 540 return -ENODEV; 541 } 542 543 if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) { 544 snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); 545 snd_hda_codec_free(codec); 546 return -ENOMEM; 547 } 548 549 if (! codec->subsystem_id) { 550 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; 551 codec->subsystem_id = snd_hda_codec_read(codec, nid, 0, 552 AC_VERB_GET_SUBSYSTEM_ID, 553 0); 521 554 } 522 555 … … 535 568 } 536 569 570 if (codec->patch_ops.unsol_event) 571 init_unsol_queue(bus); 572 537 573 snd_hda_codec_proc_new(codec); 538 574 … … 554 590 */ 555 591 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, u32 stream_tag, 556 int channel_id, int format) 557 { 558 if (! nid) 559 return; 560 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 561 nid, stream_tag, channel_id, format); 562 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 563 (stream_tag << 4) | channel_id); 564 msleep(1); 565 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 592 int channel_id, int format) 593 { 594 if (! nid) 595 return; 596 597 snd_printdd("hda_codec_setup_stream: NID=0x%x, stream=0x%x, channel=%d, format=0x%x\n", 598 nid, stream_tag, channel_id, format); 599 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CHANNEL_STREAMID, 600 (stream_tag << 4) | channel_id); 601 msleep(1); 602 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_STREAM_FORMAT, format); 566 603 } 567 604 … … 574 611 #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) 575 612 #define INFO_AMP_CAPS (1<<0) 576 #define INFO_AMP_VOL(ch) (1 << (1 + (ch)))613 #define INFO_AMP_VOL(ch) (1 << (1 + (ch))) 577 614 578 615 /* initialize the hash table */ … … 581 618 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); 582 619 codec->num_amp_entries = 0; 620 codec->amp_info_size = 0; 621 codec->amp_info = NULL; 583 622 } 584 623 … … 598 637 599 638 /* add a new hash entry */ 600 if (codec->num_amp_entries >= ARRAY_SIZE(codec->amp_info)) { 601 snd_printk(KERN_ERR "hda_codec: Tooooo many amps!\n"); 602 return NULL; 639 if (codec->num_amp_entries >= codec->amp_info_size) { 640 /* reallocate the array */ 641 int new_size = codec->amp_info_size + 64; 642 struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info), 643 GFP_KERNEL); 644 if (! new_info) { 645 snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n"); 646 return NULL; 647 } 648 if (codec->amp_info) { 649 memcpy(new_info, codec->amp_info, 650 codec->amp_info_size * sizeof(struct hda_amp_info)); 651 kfree(codec->amp_info); 652 } 653 codec->amp_info_size = new_size; 654 codec->amp_info = new_info; 603 655 } 604 656 cur = codec->num_amp_entries++; … … 621 673 if (! info) 622 674 return 0; 623 if (! (info->status & INFO_AMP_CAPS)) {624 if (!(snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) & AC_WCAP_AMP_OVRD))625 nid = codec->afg;626 info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ?627 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP);628 info->status |= INFO_AMP_CAPS;675 if (! (info->status & INFO_AMP_CAPS)) { 676 if (! (get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) 677 nid = codec->afg; 678 info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ? 679 AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); 680 info->status |= INFO_AMP_CAPS; 629 681 } 630 682 return info->amp_caps; … … 636 688 */ 637 689 static unsigned int get_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 638 hda_nid_t nid, int ch, int direction, int index)639 { 640 u32 val, parm;641 642 if (info->status & INFO_AMP_VOL(ch))643 return info->vol[ch];644 645 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT;646 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT;647 parm |= index;648 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm);649 info->vol[ch] = val & 0xff;650 info->status |= INFO_AMP_VOL(ch);651 return info->vol[ch];690 hda_nid_t nid, int ch, int direction, int index) 691 { 692 u32 val, parm; 693 694 if (info->status & INFO_AMP_VOL(ch)) 695 return info->vol[ch]; 696 697 parm = ch ? AC_AMP_GET_RIGHT : AC_AMP_GET_LEFT; 698 parm |= direction == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : AC_AMP_GET_INPUT; 699 parm |= index; 700 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, parm); 701 info->vol[ch] = val & 0xff; 702 info->status |= INFO_AMP_VOL(ch); 703 return info->vol[ch]; 652 704 } 653 705 … … 656 708 */ 657 709 static void put_vol_mute(struct hda_codec *codec, struct hda_amp_info *info, 658 hda_nid_t nid, int ch, int direction, int index, int val)659 { 660 u32 parm;661 662 parm = ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT;663 parm |= direction == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT;664 parm |= index << AC_AMP_SET_INDEX_SHIFT;665 parm |= val;666 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm);667 info->vol[ch] = val;710 hda_nid_t nid, int ch, int direction, int index, int val) 711 { 712 u32 parm; 713 714 parm = ch ? AC_AMP_SET_RIGHT : AC_AMP_SET_LEFT; 715 parm |= direction == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT; 716 parm |= index << AC_AMP_SET_INDEX_SHIFT; 717 parm |= val; 718 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, parm); 719 info->vol[ch] = val; 668 720 } 669 721 … … 673 725 static int snd_hda_codec_amp_read(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int index) 674 726 { 675 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index));676 if (! info)677 return 0;678 return get_vol_mute(codec, info, nid, ch, direction, index);727 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, index)); 728 if (! info) 729 return 0; 730 return get_vol_mute(codec, info, nid, ch, direction, index); 679 731 } 680 732 … … 684 736 static int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch, int direction, int idx, int mask, int val) 685 737 { 686 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));687 688 if (! info)689 return 0;690 val &= mask;691 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;692 if (info->vol[ch] == val && ! codec->in_resume)693 return 0;694 put_vol_mute(codec, info, nid, ch, direction, idx, val);695 return 1;738 struct hda_amp_info *info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 739 740 if (! info) 741 return 0; 742 val &= mask; 743 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 744 if (info->vol[ch] == val && ! codec->in_resume) 745 return 0; 746 put_vol_mute(codec, info, nid, ch, direction, idx, val); 747 return 1; 696 748 } 697 749 … … 707 759 708 760 /* volume */ 709 int snd_hda_mixer_amp_volume_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)761 int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 710 762 { 711 763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 728 780 } 729 781 730 int snd_hda_mixer_amp_volume_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)782 int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 731 783 { 732 784 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 744 796 } 745 797 746 int snd_hda_mixer_amp_volume_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)798 int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 747 799 { 748 800 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 754 806 int change = 0; 755 807 756 if (chs & 1) 757 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, 758 0x7f, *valp); 759 if (chs & 2) 760 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 761 0x7f, valp[1]); 808 if (chs & 1) { 809 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, 810 0x7f, *valp); 811 valp++; 812 } 813 if (chs & 2) 814 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 815 0x7f, *valp); 762 816 return change; 763 817 } 764 818 765 819 /* switch */ 766 int snd_hda_mixer_amp_switch_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)820 int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 767 821 { 768 822 int chs = get_amp_channels(kcontrol); … … 775 829 } 776 830 777 int snd_hda_mixer_amp_switch_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)831 int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 778 832 { 779 833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 791 845 } 792 846 793 int snd_hda_mixer_amp_switch_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)847 int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 794 848 { 795 849 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 801 855 int change = 0; 802 856 803 if (chs & 1) 804 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, 805 0x80, *valp ? 0 : 0x80); 806 if (chs & 2) 807 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 808 0x80, valp[1] ? 0 : 0x80); 857 if (chs & 1) { 858 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, 859 0x80, *valp ? 0 : 0x80); 860 valp++; 861 } 862 if (chs & 2) 863 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 864 0x80, *valp ? 0 : 0x80); 865 809 866 return change; 810 867 } 811 868 812 869 /* 870 * bound volume controls 871 * 872 * bind multiple volumes (# indices, from 0) 873 */ 874 875 #define AMP_VAL_IDX_SHIFT 19 876 #define AMP_VAL_IDX_MASK (0x0f<<19) 877 878 int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 879 { 880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 881 unsigned long pval; 882 int err; 883 884 down(&codec->spdif_mutex); /* reuse spdif_mutex */ 885 pval = kcontrol->private_value; 886 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ 887 err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); 888 kcontrol->private_value = pval; 889 up(&codec->spdif_mutex); 890 return err; 891 } 892 893 int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 894 { 895 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 896 unsigned long pval; 897 int i, indices, err = 0, change = 0; 898 899 down(&codec->spdif_mutex); /* reuse spdif_mutex */ 900 pval = kcontrol->private_value; 901 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 902 for (i = 0; i < indices; i++) { 903 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); 904 err = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol); 905 if (err < 0) 906 break; 907 change |= err; 908 } 909 kcontrol->private_value = pval; 910 up(&codec->spdif_mutex); 911 return err < 0 ? err : change; 912 } 913 914 /* 813 915 * SPDIF out controls 814 916 */ 815 917 816 static int snd_hda_spdif_mask_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)918 static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 817 919 { 818 920 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; … … 821 923 } 822 924 823 static int snd_hda_spdif_cmask_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)925 static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 824 926 { 825 927 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | … … 832 934 } 833 935 834 static int snd_hda_spdif_pmask_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)936 static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 835 937 { 836 938 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | … … 840 942 } 841 943 842 static int snd_hda_spdif_default_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)944 static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 843 945 { 844 946 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 857 959 static unsigned short convert_from_spdif_status(unsigned int sbits) 858 960 { 859 unsigned short val = 0;860 861 if (sbits & IEC958_AES0_PROFESSIONAL)862 val |= 1 << 6;863 if (sbits & IEC958_AES0_NONAUDIO)864 val |= 1 << 5;865 if (sbits & IEC958_AES0_PROFESSIONAL) {866 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015)867 val |= 1 << 3;868 } else {869 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015)870 val |= 1 << 3;871 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT))872 val |= 1 << 4;873 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8))874 val |= 1 << 7;875 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8);876 }877 return val;961 unsigned short val = 0; 962 963 if (sbits & IEC958_AES0_PROFESSIONAL) 964 val |= 1 << 6; 965 if (sbits & IEC958_AES0_NONAUDIO) 966 val |= 1 << 5; 967 if (sbits & IEC958_AES0_PROFESSIONAL) { 968 if ((sbits & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015) 969 val |= 1 << 3; 970 } else { 971 if ((sbits & IEC958_AES0_CON_EMPHASIS) == IEC958_AES0_CON_EMPHASIS_5015) 972 val |= 1 << 3; 973 if (! (sbits & IEC958_AES0_CON_NOT_COPYRIGHT)) 974 val |= 1 << 4; 975 if (sbits & (IEC958_AES1_CON_ORIGINAL << 8)) 976 val |= 1 << 7; 977 val |= sbits & (IEC958_AES1_CON_CATEGORY << 8); 978 } 979 return val; 878 980 } 879 981 … … 882 984 static unsigned int convert_to_spdif_status(unsigned short val) 883 985 { 884 unsigned int sbits = 0; 885 886 if (val & (1 << 5)) 887 sbits |= IEC958_AES0_NONAUDIO; 888 if (val & (1 << 6)) 889 sbits |= IEC958_AES0_PROFESSIONAL; 890 if (sbits & IEC958_AES0_PROFESSIONAL) { 891 if (sbits & (1 << 3)) 892 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 893 } else { 894 if (val & (1 << 3)) 895 sbits |= IEC958_AES0_CON_EMPHASIS_5015; 896 if (! (val & (1 << 4))) 897 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT; 898 if (val & (1 << 7)) 899 sbits |= (IEC958_AES1_CON_ORIGINAL << 8); 900 sbits |= val & (0x7f << 8); 901 } 902 return sbits; 903 } 904 905 static int snd_hda_spdif_default_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 906 { 907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 908 hda_nid_t nid = kcontrol->private_value; 909 unsigned short val; 910 int change; 911 912 down(&codec->spdif_mutex); 913 codec->spdif_status = ucontrol->value.iec958.status[0] | 914 ((unsigned int)ucontrol->value.iec958.status[1] << 8) | 915 ((unsigned int)ucontrol->value.iec958.status[2] << 16) | 916 ((unsigned int)ucontrol->value.iec958.status[3] << 24); 917 val = convert_from_spdif_status(codec->spdif_status); 918 val |= codec->spdif_ctls & 1; 919 change = codec->spdif_ctls != val; 920 codec->spdif_ctls = val; 921 922 if (change || codec->in_resume) { 923 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 924 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8); 925 } 926 927 up(&codec->spdif_mutex); 928 return change; 929 } 930 931 static int snd_hda_spdif_out_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 932 { 933 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 934 uinfo->count = 1; 935 uinfo->value.integer.min = 0; 936 uinfo->value.integer.max = 1; 937 return 0; 938 } 939 940 static int snd_hda_spdif_out_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 941 { 942 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 943 944 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1; 945 return 0; 946 } 947 948 static int snd_hda_spdif_out_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 986 unsigned int sbits = 0; 987 988 if (val & (1 << 5)) 989 sbits |= IEC958_AES0_NONAUDIO; 990 if (val & (1 << 6)) 991 sbits |= IEC958_AES0_PROFESSIONAL; 992 if (sbits & IEC958_AES0_PROFESSIONAL) { 993 if (sbits & (1 << 3)) 994 sbits |= IEC958_AES0_PRO_EMPHASIS_5015; 995 } else { 996 if (val & (1 << 3)) 997 sbits |= IEC958_AES0_CON_EMPHASIS_5015; 998 if (! (val & (1 << 4))) 999 sbits |= IEC958_AES0_CON_NOT_COPYRIGHT; 1000 if (val & (1 << 7)) 1001 sbits |= (IEC958_AES1_CON_ORIGINAL << 8); 1002 sbits |= val & (0x7f << 8); 1003 } 1004 return sbits; 1005 } 1006 1007 static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 949 1008 { 950 1009 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 951 hda_nid_t nid = kcontrol->private_value;952 unsigned short val;1010 hda_nid_t nid = kcontrol->private_value; 1011 unsigned short val; 953 1012 int change; 954 1013 955 down(&codec->spdif_mutex); 956 val = codec->spdif_ctls & ~1; 957 if (ucontrol->value.integer.value[0]) 958 val |= 1; 959 change = codec->spdif_ctls != val; 960 if (change || codec->in_resume) { 961 codec->spdif_ctls = val; 962 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 963 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 964 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 965 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 966 } 1014 down(&codec->spdif_mutex); 1015 codec->spdif_status = ucontrol->value.iec958.status[0] | 1016 ((unsigned int)ucontrol->value.iec958.status[1] << 8) | 1017 ((unsigned int)ucontrol->value.iec958.status[2] << 16) | 1018 ((unsigned int)ucontrol->value.iec958.status[3] << 24); 1019 val = convert_from_spdif_status(codec->spdif_status); 1020 val |= codec->spdif_ctls & 1; 1021 change = codec->spdif_ctls != val; 1022 codec->spdif_ctls = val; 1023 1024 if (change || codec->in_resume) { 1025 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1026 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_2, val >> 8); 1027 } 1028 967 1029 up(&codec->spdif_mutex); 968 1030 return change; 969 1031 } 970 1032 971 static snd_kcontrol_new_t dig_mixes[] = { 1033 static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1034 { 1035 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1036 uinfo->count = 1; 1037 uinfo->value.integer.min = 0; 1038 uinfo->value.integer.max = 1; 1039 return 0; 1040 } 1041 1042 static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1043 { 1044 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1045 1046 ucontrol->value.integer.value[0] = codec->spdif_ctls & 1; 1047 return 0; 1048 } 1049 1050 static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1051 { 1052 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1053 hda_nid_t nid = kcontrol->private_value; 1054 unsigned short val; 1055 int change; 1056 1057 down(&codec->spdif_mutex); 1058 val = codec->spdif_ctls & ~1; 1059 if (ucontrol->value.integer.value[0]) 1060 val |= 1; 1061 change = codec->spdif_ctls != val; 1062 if (change || codec->in_resume) { 1063 codec->spdif_ctls = val; 1064 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val & 0xff); 1065 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1066 AC_AMP_SET_RIGHT | AC_AMP_SET_LEFT | 1067 AC_AMP_SET_OUTPUT | ((val & 1) ? 0 : 0x80)); 1068 } 1069 up(&codec->spdif_mutex); 1070 return change; 1071 } 1072 1073 static struct snd_kcontrol_new dig_mixes[] = { 972 1074 { 973 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,974 /*.name = */SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK),0,975 /*.access = */SNDRV_CTL_ELEM_ACCESS_READ,0,976 /*.info = */snd_hda_spdif_mask_info,977 /*.get = */snd_hda_spdif_cmask_get,0,01075 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1076 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1077 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), 1078 .info = snd_hda_spdif_mask_info, 1079 .get = snd_hda_spdif_cmask_get, 978 1080 }, 979 1081 { 980 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,981 /*.name = */SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK),0,982 /*.access = */SNDRV_CTL_ELEM_ACCESS_READ,0,983 /*.info = */snd_hda_spdif_mask_info,984 /*.get = */snd_hda_spdif_pmask_get,0,01082 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1084 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), 1085 .info = snd_hda_spdif_mask_info, 1086 .get = snd_hda_spdif_pmask_get, 985 1087 }, 986 1088 { 987 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,988 /*.name = */SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),0,0,0,989 /*.info = */snd_hda_spdif_mask_info,990 /*.get = */snd_hda_spdif_default_get,991 /*.put = */snd_hda_spdif_default_put,01089 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1090 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 1091 .info = snd_hda_spdif_mask_info, 1092 .get = snd_hda_spdif_default_get, 1093 .put = snd_hda_spdif_default_put, 992 1094 }, 993 1095 { 994 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,995 /*.name = */SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH),0,0,0,996 /*.info = */snd_hda_spdif_out_switch_info,997 /*.get = */snd_hda_spdif_out_switch_get,998 /*.put = */snd_hda_spdif_out_switch_put,01096 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1097 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 1098 .info = snd_hda_spdif_out_switch_info, 1099 .get = snd_hda_spdif_out_switch_get, 1100 .put = snd_hda_spdif_out_switch_put, 999 1101 }, 1000 1102 {0} /* end */ … … 1014 1116 { 1015 1117 int err; 1016 s nd_kcontrol_t*kctl;1017 s nd_kcontrol_new_t*dig_mix;1118 struct snd_kcontrol *kctl; 1119 struct snd_kcontrol_new *dig_mix; 1018 1120 1019 1121 for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { … … 1022 1124 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1023 1125 return err; 1024 }1025 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);1026 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls);1126 } 1127 codec->spdif_ctls = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1128 codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); 1027 1129 return 0; 1028 1130 } … … 1032 1134 */ 1033 1135 1034 #define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info1035 1036 static int snd_hda_spdif_in_switch_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)1037 { 1038 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1039 1040 ucontrol->value.integer.value[0] = codec->spdif_in_enable;1041 return 0;1042 } 1043 1044 static int snd_hda_spdif_in_switch_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)1045 { 1046 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1047 hda_nid_t nid = kcontrol->private_value;1048 unsigned int val = !!ucontrol->value.integer.value[0];1049 int change;1050 1051 down(&codec->spdif_mutex);1052 change = codec->spdif_in_enable != val;1053 if (change || codec->in_resume) {1054 codec->spdif_in_enable = val;1055 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val);1056 }1057 up(&codec->spdif_mutex);1058 return change;1059 } 1060 1061 static int snd_hda_spdif_in_status_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)1062 { 1063 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);1064 hda_nid_t nid = kcontrol->private_value;1065 unsigned short val;1066 unsigned int sbits;1067 1068 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0);1069 sbits = convert_to_spdif_status(val);1070 ucontrol->value.iec958.status[0] = sbits;1071 ucontrol->value.iec958.status[1] = sbits >> 8;1072 ucontrol->value.iec958.status[2] = sbits >> 16;1073 ucontrol->value.iec958.status[3] = sbits >> 24;1074 return 0;1075 } 1076 1077 static s nd_kcontrol_new_tdig_in_ctls[] = {1078 {1079 SNDRV_CTL_ELEM_IFACE_MIXER,0,0,1080 SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH),0,0,0,1081 snd_hda_spdif_in_switch_info,1082 snd_hda_spdif_in_switch_get,1083 snd_hda_spdif_in_switch_put,0 1084 },1085 {1086 SNDRV_CTL_ELEM_IFACE_MIXER,0,0,1087 SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT),0,1088 SNDRV_CTL_ELEM_ACCESS_READ,0,1089 snd_hda_spdif_mask_info,1090 snd_hda_spdif_in_status_get,0,0 1091 },1092 {0} /* end */1136 #define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info 1137 1138 static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1139 { 1140 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1141 1142 ucontrol->value.integer.value[0] = codec->spdif_in_enable; 1143 return 0; 1144 } 1145 1146 static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1147 { 1148 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1149 hda_nid_t nid = kcontrol->private_value; 1150 unsigned int val = !!ucontrol->value.integer.value[0]; 1151 int change; 1152 1153 down(&codec->spdif_mutex); 1154 change = codec->spdif_in_enable != val; 1155 if (change || codec->in_resume) { 1156 codec->spdif_in_enable = val; 1157 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1, val); 1158 } 1159 up(&codec->spdif_mutex); 1160 return change; 1161 } 1162 1163 static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1164 { 1165 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1166 hda_nid_t nid = kcontrol->private_value; 1167 unsigned short val; 1168 unsigned int sbits; 1169 1170 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0); 1171 sbits = convert_to_spdif_status(val); 1172 ucontrol->value.iec958.status[0] = sbits; 1173 ucontrol->value.iec958.status[1] = sbits >> 8; 1174 ucontrol->value.iec958.status[2] = sbits >> 16; 1175 ucontrol->value.iec958.status[3] = sbits >> 24; 1176 return 0; 1177 } 1178 1179 static struct snd_kcontrol_new dig_in_ctls[] = { 1180 { 1181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1182 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 1183 .info = snd_hda_spdif_in_switch_info, 1184 .get = snd_hda_spdif_in_switch_get, 1185 .put = snd_hda_spdif_in_switch_put, 1186 }, 1187 { 1188 .access = SNDRV_CTL_ELEM_ACCESS_READ, 1189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1190 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT), 1191 .info = snd_hda_spdif_mask_info, 1192 .get = snd_hda_spdif_in_status_get, 1193 }, 1194 {0} /* end */ 1093 1195 }; 1094 1196 … … 1105 1207 int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) 1106 1208 { 1107 int err; 1108 snd_kcontrol_t *kctl; 1109 snd_kcontrol_new_t *dig_mix; 1110 1111 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1112 kctl = snd_ctl_new1(dig_mix, codec); 1113 kctl->private_value = nid; 1114 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1115 return err; 1116 } 1117 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1; 1118 return 0; 1119 } 1209 int err; 1210 struct snd_kcontrol *kctl; 1211 struct snd_kcontrol_new *dig_mix; 1212 1213 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 1214 kctl = snd_ctl_new1(dig_mix, codec); 1215 kctl->private_value = nid; 1216 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1217 return err; 1218 } 1219 codec->spdif_in_enable = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DIGI_CONVERT, 0) & 1; 1220 return 0; 1221 } 1222 1223 1224 /* 1225 * set power state of the codec 1226 */ 1227 static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, 1228 unsigned int power_state) 1229 { 1230 hda_nid_t nid, nid_start; 1231 int nodes; 1232 1233 snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE, 1234 power_state); 1235 1236 nodes = snd_hda_get_sub_nodes(codec, fg, &nid_start); 1237 for (nid = nid_start; nid < nodes + nid_start; nid++) { 1238 if (get_wcaps(codec, nid) & AC_WCAP_POWER) 1239 snd_hda_codec_write(codec, nid, 0, 1240 AC_VERB_SET_POWER_STATE, 1241 power_state); 1242 } 1243 1244 if (power_state == AC_PWRST_D0) 1245 msleep(10); 1246 } 1247 1120 1248 1121 1249 /** … … 1146 1274 struct hda_codec *codec = list_entry(p, struct hda_codec, list); 1147 1275 int err; 1276 hda_set_power_state(codec, 1277 codec->afg ? codec->afg : codec->mfg, 1278 AC_PWRST_D0); 1148 1279 if (! codec->patch_ops.init) 1149 1280 continue; … … 1159 1290 * stream formats 1160 1291 */ 1161 static unsigned int rate_bits[][3] = { 1292 struct hda_rate_tbl { 1293 unsigned int hz; 1294 unsigned int alsa_bits; 1295 unsigned int hda_fmt; 1296 }; 1297 1298 static struct hda_rate_tbl rate_bits[] = { 1162 1299 /* rate in Hz, ALSA rate bitmask, HDA format value */ 1300 1301 /* autodetected value used in snd_hda_query_supported_pcm */ 1163 1302 { 8000, SNDRV_PCM_RATE_8000, 0x0500 }, /* 1/6 x 48 */ 1164 1303 { 11025, SNDRV_PCM_RATE_11025, 0x4300 }, /* 1/4 x 44 */ … … 1172 1311 { 176400, SNDRV_PCM_RATE_176400, 0x5800 },/* 4 x 44 */ 1173 1312 { 192000, SNDRV_PCM_RATE_192000, 0x1800 }, /* 4 x 48 */ 1174 { 0 } 1313 1314 /* not autodetected value */ 1315 { 9600, SNDRV_PCM_RATE_KNOT, 0x0400 }, /* 1/5 x 48 */ 1316 1317 { 0 } /* terminator */ 1175 1318 }; 1176 1319 … … 1194 1337 unsigned int val = 0; 1195 1338 1196 for (i = 0; rate_bits[i] [0]; i++)1197 if (rate_bits[i] [0]== rate) {1198 val = rate_bits[i] [2];1339 for (i = 0; rate_bits[i].hz; i++) 1340 if (rate_bits[i].hz == rate) { 1341 val = rate_bits[i].hda_fmt; 1199 1342 break; 1200 1343 } 1201 if (! rate_bits[i] [0]) {1344 if (! rate_bits[i].hz) { 1202 1345 snd_printdd("invalid rate %d\n", rate); 1203 1346 return 0; … … 1252 1395 val = 0; 1253 1396 if (nid != codec->afg && 1254 snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) & AC_WCAP_FORMAT_OVRD) {1397 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { 1255 1398 val = snd_hda_param_read(codec, nid, AC_PAR_PCM); 1256 1399 if (val == -1) … … 1262 1405 if (ratesp) { 1263 1406 u32 rates = 0; 1264 for (i = 0; rate_bits[i] [0]; i++) {1407 for (i = 0; rate_bits[i].hz; i++) { 1265 1408 if (val & (1 << i)) 1266 rates |= rate_bits[i] [1];1409 rates |= rate_bits[i].alsa_bits; 1267 1410 } 1268 1411 *ratesp = rates; … … 1274 1417 unsigned int wcaps; 1275 1418 1276 wcaps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);1419 wcaps = get_wcaps(codec, nid); 1277 1420 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1278 1421 if (streams == -1) … … 1341 1484 { 1342 1485 int i; 1343 unsigned int val = 0, rate, stream;1486 unsigned int val = 0, rate, stream; 1344 1487 1345 1488 if (nid != codec->afg && 1346 snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) & AC_WCAP_FORMAT_OVRD) {1489 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { 1347 1490 val = snd_hda_param_read(codec, nid, AC_PAR_PCM); 1348 1491 if (val == -1) … … 1355 1498 } 1356 1499 1357 rate = format & 0xff00;1358 for (i = 0; rate_bits[i] [0]; i++)1359 if (rate_bits[i] [2]== rate) {1500 rate = format & 0xff00; 1501 for (i = 0; rate_bits[i].hz; i++) 1502 if (rate_bits[i].hda_fmt == rate) { 1360 1503 if (val & (1 << i)) 1361 1504 break; 1362 1505 return 0; 1363 1506 } 1364 if (! rate_bits[i] [0])1507 if (! rate_bits[i].hz) 1365 1508 return 0; 1366 1509 1367 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM);1368 if (stream == -1)1369 return 0;1370 if (! stream && nid != codec->afg)1371 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM);1372 if (! stream || stream == -1)1373 return 0;1374 1375 if (stream & AC_SUPFMT_PCM) {1510 stream = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 1511 if (stream == -1) 1512 return 0; 1513 if (! stream && nid != codec->afg) 1514 stream = snd_hda_param_read(codec, codec->afg, AC_PAR_STREAM); 1515 if (! stream || stream == -1) 1516 return 0; 1517 1518 if (stream & AC_SUPFMT_PCM) { 1376 1519 switch (format & 0xf0) { 1377 1520 case 0x00: … … 1410 1553 static int hda_pcm_default_open_close(struct hda_pcm_stream *hinfo, 1411 1554 struct hda_codec *codec, 1412 s nd_pcm_substream_t*substream)1555 struct snd_pcm_substream *substream) 1413 1556 { 1414 1557 return 0; … … 1419 1562 unsigned int stream_tag, 1420 1563 unsigned int format, 1421 s nd_pcm_substream_t*substream)1564 struct snd_pcm_substream *substream) 1422 1565 { 1423 1566 snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); … … 1427 1570 static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo, 1428 1571 struct hda_codec *codec, 1429 s nd_pcm_substream_t*substream)1572 struct snd_pcm_substream *substream) 1430 1573 { 1431 1574 snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); … … 1524 1667 * If no entries are matching, the function returns a negative value. 1525 1668 */ 1526 int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config *tbl)1527 { 1528 struct hda_board_config *c;1669 int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl) 1670 { 1671 const struct hda_board_config *c; 1529 1672 1530 1673 if (codec->bus->modelname) { 1531 for (c = tbl; c->modelname || c->pci_ vendor; c++) {1674 for (c = tbl; c->modelname || c->pci_subvendor; c++) { 1532 1675 if (c->modelname && 1533 1676 ! strcmp(codec->bus->modelname, c->modelname)) { … … 1542 1685 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); 1543 1686 pci_read_config_word(codec->bus->pci, PCI_SUBSYSTEM_ID, &subsystem_device); 1544 for (c = tbl; c->modelname || c->pci_vendor; c++) { 1545 if (c->pci_vendor == subsystem_vendor && 1546 c->pci_device == subsystem_device) 1687 for (c = tbl; c->modelname || c->pci_subvendor; c++) { 1688 if (c->pci_subvendor == subsystem_vendor && 1689 (! c->pci_subdevice /* all match */|| 1690 (c->pci_subdevice == subsystem_device))) { 1691 snd_printdd(KERN_INFO "hda_codec: PCI %x:%x, codec config %d is selected\n", 1692 subsystem_vendor, subsystem_device, c->config); 1547 1693 return c->config; 1694 } 1548 1695 } 1549 1696 } … … 1554 1701 * snd_hda_add_new_ctls - create controls from the array 1555 1702 * @codec: the HDA codec 1556 * @knew: the array of s nd_kcontrol_new_t1703 * @knew: the array of struct snd_kcontrol_new 1557 1704 * 1558 1705 * This helper function creates and add new controls in the given array. … … 1561 1708 * Returns 0 if successful, or a negative error code. 1562 1709 */ 1563 int snd_hda_add_new_ctls(struct hda_codec *codec, s nd_kcontrol_new_t*knew)1710 int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) 1564 1711 { 1565 1712 int err; 1566 1713 1567 1714 for (; knew->name; knew++) { 1568 err = snd_ctl_add(codec->bus->card, snd_ctl_new1(knew, codec)); 1569 if (err < 0) 1570 return err; 1571 } 1572 return 0; 1573 } 1574 1715 struct snd_kcontrol *kctl; 1716 kctl = snd_ctl_new1(knew, codec); 1717 if (! kctl) 1718 return -ENOMEM; 1719 err = snd_ctl_add(codec->bus->card, kctl); 1720 if (err < 0) { 1721 if (! codec->addr) 1722 return err; 1723 kctl = snd_ctl_new1(knew, codec); 1724 if (! kctl) 1725 return -ENOMEM; 1726 kctl->id.device = codec->addr; 1727 if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) 1728 return err; 1729 } 1730 } 1731 return 0; 1732 } 1733 1734 1735 /* 1736 * Channel mode helper 1737 */ 1738 int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 1739 const struct hda_channel_mode *chmode, int num_chmodes) 1740 { 1741 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1742 uinfo->count = 1; 1743 uinfo->value.enumerated.items = num_chmodes; 1744 if (uinfo->value.enumerated.item >= num_chmodes) 1745 uinfo->value.enumerated.item = num_chmodes - 1; 1746 sprintf(uinfo->value.enumerated.name, "%dch", 1747 chmode[uinfo->value.enumerated.item].channels); 1748 return 0; 1749 } 1750 1751 int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1752 const struct hda_channel_mode *chmode, int num_chmodes, 1753 int max_channels) 1754 { 1755 int i; 1756 1757 for (i = 0; i < num_chmodes; i++) { 1758 if (max_channels == chmode[i].channels) { 1759 ucontrol->value.enumerated.item[0] = i; 1760 break; 1761 } 1762 } 1763 return 0; 1764 } 1765 1766 int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 1767 const struct hda_channel_mode *chmode, int num_chmodes, 1768 int *max_channelsp) 1769 { 1770 unsigned int mode; 1771 1772 mode = ucontrol->value.enumerated.item[0]; 1773 snd_assert(mode < num_chmodes, return -EINVAL); 1774 if (*max_channelsp == chmode[mode].channels && ! codec->in_resume) 1775 return 0; 1776 /* change the current channel setting */ 1777 *max_channelsp = chmode[mode].channels; 1778 if (chmode[mode].sequence) 1779 snd_hda_sequence_write(codec, chmode[mode].sequence); 1780 return 1; 1781 } 1575 1782 1576 1783 /* 1577 1784 * input MUX helper 1578 1785 */ 1579 int snd_hda_input_mux_info(const struct hda_input_mux *imux, s nd_ctl_elem_info_t*uinfo)1786 int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo) 1580 1787 { 1581 1788 unsigned int index; … … 1592 1799 1593 1800 int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 1594 s nd_ctl_elem_value_t*ucontrol, hda_nid_t nid,1801 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 1595 1802 unsigned int *cur_val) 1596 1803 { … … 1643 1850 */ 1644 1851 int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 1645 s nd_pcm_substream_t*substream)1852 struct snd_pcm_substream *substream) 1646 1853 { 1647 1854 substream->runtime->hw.channels_max = mout->max_channels; … … 1657 1864 unsigned int stream_tag, 1658 1865 unsigned int format, 1659 s nd_pcm_substream_t*substream)1866 struct snd_pcm_substream *substream) 1660 1867 { 1661 1868 hda_nid_t *nids = mout->dac_nids; … … 1665 1872 down(&codec->spdif_mutex); 1666 1873 if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { 1667 if (chs == 2 && 1668 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 1669 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { 1670 1874 if (chs == 2 && 1875 snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && 1876 ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { 1671 1877 mout->dig_out_used = HDA_DIG_ANALOG_DUP; 1672 1878 /* setup digital receiver */ 1673 1879 snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 1674 1880 stream_tag, 0, format); 1675 1676 1881 } else { 1677 1882 mout->dig_out_used = 0; … … 1687 1892 snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); 1688 1893 /* surrounds */ 1689 for (i = 0; i < mout->num_dacs; i++) { 1690 if (i == HDA_REAR && chs == 2) /* copy front to rear */ 1691 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, format); 1692 else if (chs >= (i + 1) * 2) /* independent out */ 1894 for (i = 1; i < mout->num_dacs; i++) { 1895 if (chs >= (i + 1) * 2) /* independent out */ 1693 1896 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, 1897 format); 1898 else /* copy front */ 1899 snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, 1694 1900 format); 1695 1901 } … … 1718 1924 } 1719 1925 1926 /* 1927 * Helper for automatic ping configuration 1928 */ 1929 1930 static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) 1931 { 1932 for (; *list; list++) 1933 if (*list == nid) 1934 return 1; 1935 return 0; 1936 } 1937 1938 /* parse all pin widgets and store the useful pin nids to cfg */ 1939 int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 1940 hda_nid_t *ignore_nids) 1941 { 1942 hda_nid_t nid, nid_start; 1943 int i, j, nodes; 1944 short seq, sequences[4], assoc_line_out; 1945 1946 memset(cfg, 0, sizeof(*cfg)); 1947 1948 memset(sequences, 0, sizeof(sequences)); 1949 assoc_line_out = 0; 1950 1951 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 1952 for (nid = nid_start; nid < nodes + nid_start; nid++) { 1953 unsigned int wid_caps = get_wcaps(codec, nid); 1954 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 1955 unsigned int def_conf; 1956 short assoc, loc; 1957 1958 /* read all default configuration for pin complex */ 1959 if (wid_type != AC_WID_PIN) 1960 continue; 1961 /* ignore the given nids (e.g. pc-beep returns error) */ 1962 if (ignore_nids && is_in_nid_list(nid, ignore_nids)) 1963 continue; 1964 1965 def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 1966 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 1967 continue; 1968 loc = get_defcfg_location(def_conf); 1969 switch (get_defcfg_device(def_conf)) { 1970 case AC_JACK_LINE_OUT: 1971 seq = get_defcfg_sequence(def_conf); 1972 assoc = get_defcfg_association(def_conf); 1973 if (! assoc) 1974 continue; 1975 if (! assoc_line_out) 1976 assoc_line_out = assoc; 1977 else if (assoc_line_out != assoc) 1978 continue; 1979 if (cfg->line_outs >= ARRAY_SIZE(cfg->line_out_pins)) 1980 continue; 1981 cfg->line_out_pins[cfg->line_outs] = nid; 1982 sequences[cfg->line_outs] = seq; 1983 cfg->line_outs++; 1984 break; 1985 case AC_JACK_SPEAKER: 1986 cfg->speaker_pin = nid; 1987 break; 1988 case AC_JACK_HP_OUT: 1989 cfg->hp_pin = nid; 1990 break; 1991 case AC_JACK_MIC_IN: 1992 if (loc == AC_JACK_LOC_FRONT) 1993 cfg->input_pins[AUTO_PIN_FRONT_MIC] = nid; 1994 else 1995 cfg->input_pins[AUTO_PIN_MIC] = nid; 1996 break; 1997 case AC_JACK_LINE_IN: 1998 if (loc == AC_JACK_LOC_FRONT) 1999 cfg->input_pins[AUTO_PIN_FRONT_LINE] = nid; 2000 else 2001 cfg->input_pins[AUTO_PIN_LINE] = nid; 2002 break; 2003 case AC_JACK_CD: 2004 cfg->input_pins[AUTO_PIN_CD] = nid; 2005 break; 2006 case AC_JACK_AUX: 2007 cfg->input_pins[AUTO_PIN_AUX] = nid; 2008 break; 2009 case AC_JACK_SPDIF_OUT: 2010 cfg->dig_out_pin = nid; 2011 break; 2012 case AC_JACK_SPDIF_IN: 2013 cfg->dig_in_pin = nid; 2014 break; 2015 } 2016 } 2017 2018 /* sort by sequence */ 2019 for (i = 0; i < cfg->line_outs; i++) 2020 for (j = i + 1; j < cfg->line_outs; j++) 2021 if (sequences[i] > sequences[j]) { 2022 seq = sequences[i]; 2023 sequences[i] = sequences[j]; 2024 sequences[j] = seq; 2025 nid = cfg->line_out_pins[i]; 2026 cfg->line_out_pins[i] = cfg->line_out_pins[j]; 2027 cfg->line_out_pins[j] = nid; 2028 } 2029 2030 /* Reorder the surround channels 2031 * ALSA sequence is front/surr/clfe/side 2032 * HDA sequence is: 2033 * 4-ch: front/surr => OK as it is 2034 * 6-ch: front/clfe/surr 2035 * 8-ch: front/clfe/side/surr 2036 */ 2037 switch (cfg->line_outs) { 2038 case 3: 2039 nid = cfg->line_out_pins[1]; 2040 cfg->line_out_pins[1] = cfg->line_out_pins[2]; 2041 cfg->line_out_pins[2] = nid; 2042 break; 2043 case 4: 2044 nid = cfg->line_out_pins[1]; 2045 cfg->line_out_pins[1] = cfg->line_out_pins[3]; 2046 cfg->line_out_pins[3] = cfg->line_out_pins[2]; 2047 cfg->line_out_pins[2] = nid; 2048 break; 2049 } 2050 2051 return 0; 2052 } 2053 2054 /* labels for input pins */ 2055 const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { 2056 "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" 2057 }; 2058 2059 1720 2060 #ifdef CONFIG_PM 1721 2061 /* … … 1730 2070 * Returns 0 if successful. 1731 2071 */ 1732 int snd_hda_suspend(struct hda_bus *bus, unsigned int state)2072 int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) 1733 2073 { 1734 2074 struct list_head *p; … … 1739 2079 if (codec->patch_ops.suspend) 1740 2080 codec->patch_ops.suspend(codec, state); 2081 hda_set_power_state(codec, 2082 codec->afg ? codec->afg : codec->mfg, 2083 AC_PWRST_D3); 1741 2084 } 1742 2085 return 0; … … 1750 2093 * Returns 0 if successful. 1751 2094 */ 1752 int snd_hda_resume(struct hda_bus *bus , unsigned int state)2095 int snd_hda_resume(struct hda_bus *bus) 1753 2096 { 1754 2097 struct list_head *p; … … 1756 2099 list_for_each(p, &bus->codec_list) { 1757 2100 struct hda_codec *codec = list_entry(p, struct hda_codec, list); 2101 hda_set_power_state(codec, 2102 codec->afg ? codec->afg : codec->mfg, 2103 AC_PWRST_D0); 1758 2104 if (codec->patch_ops.resume) 1759 2105 codec->patch_ops.resume(codec); … … 1765 2111 * snd_hda_resume_ctls - resume controls in the new control list 1766 2112 * @codec: the HDA codec 1767 * @knew: the array of s nd_kcontrol_new_t1768 * 1769 * This function resumes the mixer controls in the s nd_kcontrol_new_tarray,2113 * @knew: the array of struct snd_kcontrol_new 2114 * 2115 * This function resumes the mixer controls in the struct snd_kcontrol_new array, 1770 2116 * originally for snd_hda_add_new_ctls(). 1771 2117 * The array must be terminated with an empty entry as terminator. 1772 2118 */ 1773 int snd_hda_resume_ctls(struct hda_codec *codec, s nd_kcontrol_new_t*knew)1774 { 1775 s nd_ctl_elem_value_t*val;2119 int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) 2120 { 2121 struct snd_ctl_elem_value *val; 1776 2122 1777 2123 val = kmalloc(sizeof(*val), GFP_KERNEL); … … 1817 2163 int snd_hda_resume_spdif_in(struct hda_codec *codec) 1818 2164 { 1819 return snd_hda_resume_ctls(codec, dig_in_ctls);2165 return snd_hda_resume_ctls(codec, dig_in_ctls); 1820 2166 } 1821 2167 #endif -
GPL/trunk/alsa-kernel/pci/hda/hda_codec.h
r32 r69 76 76 #define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f 77 77 /* f10-f1a: GPIO */ 78 #define AC_VERB_GET_GPIO_DATA 0x0f15 79 #define AC_VERB_GET_GPIO_MASK 0x0f16 80 #define AC_VERB_GET_GPIO_DIRECTION 0x0f17 78 81 #define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c 82 /* f20: AFG/MFG */ 83 #define AC_VERB_GET_SUBSYSTEM_ID 0x0f20 79 84 80 85 /* … … 94 99 #define AC_VERB_SET_PIN_SENSE 0x709 95 100 #define AC_VERB_SET_BEEP_CONTROL 0x70a 96 #define AC_VERB_SET_EAPD_BTLENA LBE 0x70c101 #define AC_VERB_SET_EAPD_BTLENABLE 0x70c 97 102 #define AC_VERB_SET_DIGI_CONVERT_1 0x70d 98 103 #define AC_VERB_SET_DIGI_CONVERT_2 0x70e 99 104 #define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f 105 #define AC_VERB_SET_GPIO_DATA 0x715 106 #define AC_VERB_SET_GPIO_MASK 0x716 107 #define AC_VERB_SET_GPIO_DIRECTION 0x717 100 108 #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c 101 109 #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d … … 177 185 #define AC_PINCAP_IN (1<<5) /* input capable */ 178 186 #define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */ 179 #define AC_PINCAP_VREF (0x37<<8)187 #define AC_PINCAP_VREF (0x37<<8) 180 188 #define AC_PINCAP_VREF_SHIFT 8 181 189 #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */ 182 190 /* Vref status (used in pin cap) */ 183 #define AC_PINCAP_VREF_HIZ (1<<0)/* Hi-Z */184 #define AC_PINCAP_VREF_50 (1<<1)/* 50% */185 #define AC_PINCAP_VREF_GRD (1<<2)/* ground */186 #define AC_PINCAP_VREF_80 (1<<4)/* 80% */187 #define AC_PINCAP_VREF_100 (1<<5)/* 100% */191 #define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */ 192 #define AC_PINCAP_VREF_50 (1<<1) /* 50% */ 193 #define AC_PINCAP_VREF_GRD (1<<2) /* ground */ 194 #define AC_PINCAP_VREF_80 (1<<4) /* 80% */ 195 #define AC_PINCAP_VREF_100 (1<<5) /* 100% */ 188 196 189 197 /* Amplifier capabilities */ … … 206 214 #define AC_PWRST_D2SUP (1<<2) 207 215 #define AC_PWRST_D3SUP (1<<3) 216 217 /* Power state values */ 218 #define AC_PWRST_D0 0x00 219 #define AC_PWRST_D1 0x01 220 #define AC_PWRST_D2 0x02 221 #define AC_PWRST_D3 0x03 208 222 209 223 /* Processing capabilies */ … … 257 271 #define AC_PINCTL_HP_EN (1<<7) 258 272 273 /* Unsolicited response - 8bit */ 274 #define AC_USRSP_EN (1<<7) 275 259 276 /* configuration default - 32bit */ 260 277 #define AC_DEFCFG_SEQUENCE (0xf<<0) 261 278 #define AC_DEFCFG_DEF_ASSOC (0xf<<4) 262 #define AC_DEFCFG_ASSOC_SHIFT 4279 #define AC_DEFCFG_ASSOC_SHIFT 4 263 280 #define AC_DEFCFG_MISC (0xf<<8) 264 #define AC_DEFCFG_MISC_SHIFT 8281 #define AC_DEFCFG_MISC_SHIFT 8 265 282 #define AC_DEFCFG_COLOR (0xf<<12) 266 283 #define AC_DEFCFG_COLOR_SHIFT 12 … … 366 383 367 384 /* max. connections to a widget */ 368 #define HDA_MAX_CONNECTIONS 16385 #define HDA_MAX_CONNECTIONS 32 369 386 370 387 /* max. codec address */ … … 410 427 */ 411 428 struct hda_bus { 412 s nd_card_t*card;429 struct snd_card *card; 413 430 414 431 /* copied from template */ … … 419 436 420 437 /* codec linked list */ 421 struct list_head codec_list;422 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */438 struct list_head codec_list; 439 struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; /* caddr -> codec */ 423 440 424 441 struct semaphore cmd_mutex; … … 427 444 struct hda_bus_unsolicited *unsol; 428 445 429 s nd_info_entry_t*proc;446 struct snd_info_entry *proc; 430 447 }; 431 448 … … 454 471 void (*unsol_event)(struct hda_codec *codec, unsigned int res); 455 472 #ifdef CONFIG_PM 456 int (*suspend)(struct hda_codec *codec, unsigned int state);473 int (*suspend)(struct hda_codec *codec, pm_message_t state); 457 474 int (*resume)(struct hda_codec *codec); 458 475 #endif … … 471 488 struct hda_pcm_ops { 472 489 int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec, 473 s nd_pcm_substream_t*substream);490 struct snd_pcm_substream *substream); 474 491 int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec, 475 s nd_pcm_substream_t*substream);492 struct snd_pcm_substream *substream); 476 493 int (*prepare)(struct hda_pcm_stream *info, struct hda_codec *codec, 477 494 unsigned int stream_tag, unsigned int format, 478 s nd_pcm_substream_t*substream);495 struct snd_pcm_substream *substream); 479 496 int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, 480 s nd_pcm_substream_t*substream);497 struct snd_pcm_substream *substream); 481 498 }; 482 499 … … 497 514 char *name; 498 515 struct hda_pcm_stream stream[2]; 516 unsigned int is_modem; /* modem codec? */ 499 517 }; 500 518 … … 506 524 507 525 hda_nid_t afg; /* AFG node id */ 526 hda_nid_t mfg; /* MFG node id */ 508 527 509 528 /* ids */ … … 530 549 void *spec; 531 550 551 /* widget capabilities cache */ 552 unsigned int num_nodes; 553 hda_nid_t start_nid; 554 u32 *wcaps; 555 532 556 /* hash for amp access */ 533 557 u16 amp_hash[32]; 534 558 int num_amp_entries; 535 struct hda_amp_info amp_info[128]; /* big enough? */ 559 int amp_info_size; 560 struct hda_amp_info *amp_info; 536 561 537 562 struct semaphore spdif_mutex; 538 unsigned int spdif_status; 539 unsigned short spdif_ctls;/* SPDIF control bits */540 unsigned int spdif_in_enable;/* SPDIF input enable? */563 unsigned int spdif_status; /* IEC958 status bits */ 564 unsigned short spdif_ctls; /* SPDIF control bits */ 565 unsigned int spdif_in_enable; /* SPDIF input enable? */ 541 566 }; 542 567 … … 550 575 * constructors 551 576 */ 552 int snd_hda_bus_new(s nd_card_t*card, const struct hda_bus_template *temp,577 int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, 553 578 struct hda_bus **busp); 554 579 int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, … … 604 629 */ 605 630 #ifdef CONFIG_PM 606 int snd_hda_suspend(struct hda_bus *bus, unsigned int state);607 int snd_hda_resume(struct hda_bus *bus , unsigned int state);631 int snd_hda_suspend(struct hda_bus *bus, pm_message_t state); 632 int snd_hda_resume(struct hda_bus *bus); 608 633 #endif 609 634 -
GPL/trunk/alsa-kernel/pci/hda/hda_generic.c
r32 r69 31 31 /* widget node for parsing */ 32 32 struct hda_gnode { 33 hda_nid_t nid; /* NID of this widget */ 34 unsigned short nconns; /* number of input connections */ 35 hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; /* input connections */ 36 unsigned int wid_caps; /* widget capabilities */ 37 unsigned char type; /* widget type */ 38 unsigned char pin_ctl; /* pin controls */ 39 unsigned char checked; /* the flag indicates that the node is already parsed */ 40 unsigned int pin_caps; /* pin widget capabilities */ 41 unsigned int def_cfg; /* default configuration */ 42 unsigned int amp_out_caps; /* AMP out capabilities */ 43 unsigned int amp_in_caps; /* AMP in capabilities */ 44 struct list_head list; 33 hda_nid_t nid; /* NID of this widget */ 34 unsigned short nconns; /* number of input connections */ 35 hda_nid_t *conn_list; 36 hda_nid_t slist[2]; /* temporay list */ 37 unsigned int wid_caps; /* widget capabilities */ 38 unsigned char type; /* widget type */ 39 unsigned char pin_ctl; /* pin controls */ 40 unsigned char checked; /* the flag indicates that the node is already parsed */ 41 unsigned int pin_caps; /* pin widget capabilities */ 42 unsigned int def_cfg; /* default configuration */ 43 unsigned int amp_out_caps; /* AMP out capabilities */ 44 unsigned int amp_in_caps; /* AMP in capabilities */ 45 struct list_head list; 45 46 }; 46 47 47 48 /* patch-specific record */ 48 49 struct hda_gspec { 49 struct hda_gnode *dac_node; /* DAC node */50 struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */51 struct hda_gnode *pcm_vol_node; /* Node for PCM volume */52 unsigned int pcm_vol_index; /* connection of PCM volume */53 54 struct hda_gnode *adc_node; /* ADC node */55 struct hda_gnode *cap_vol_node; /* Node for capture volume */56 unsigned int cur_cap_src; /* current capture source */57 struct hda_input_mux input_mux;58 char cap_labels[HDA_MAX_NUM_INPUTS][16];59 60 unsigned int def_amp_in_caps;61 unsigned int def_amp_out_caps;62 63 struct hda_pcm pcm_rec; /* PCM information */64 65 struct list_head nid_list; /* list of widgets */50 struct hda_gnode *dac_node; /* DAC node */ 51 struct hda_gnode *out_pin_node; /* Output pin (Line-Out) node */ 52 struct hda_gnode *pcm_vol_node; /* Node for PCM volume */ 53 unsigned int pcm_vol_index; /* connection of PCM volume */ 54 55 struct hda_gnode *adc_node; /* ADC node */ 56 struct hda_gnode *cap_vol_node; /* Node for capture volume */ 57 unsigned int cur_cap_src; /* current capture source */ 58 struct hda_input_mux input_mux; 59 char cap_labels[HDA_MAX_NUM_INPUTS][16]; 60 61 unsigned int def_amp_in_caps; 62 unsigned int def_amp_out_caps; 63 64 struct hda_pcm pcm_rec; /* PCM information */ 65 66 struct list_head nid_list; /* list of widgets */ 66 67 }; 67 68 … … 69 70 * retrieve the default device type from the default config value 70 71 */ 71 #define get_defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT)72 #define get_defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT)72 #define defcfg_type(node) (((node)->def_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 73 #define defcfg_location(node) (((node)->def_cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 73 74 74 75 /* … … 77 78 static void snd_hda_generic_free(struct hda_codec *codec) 78 79 { 79 struct hda_gspec *spec = codec->spec; 80 struct list_head *p, *n; 81 82 if (! spec) 83 return; 84 /* free all widgets */ 85 list_for_each_safe(p, n, &spec->nid_list) { 86 struct hda_gnode *node = list_entry(p, struct hda_gnode, list); 87 kfree(node); 88 } 89 kfree(spec); 80 struct hda_gspec *spec = codec->spec; 81 struct list_head *p, *n; 82 83 if (! spec) 84 return; 85 /* free all widgets */ 86 list_for_each_safe(p, n, &spec->nid_list) { 87 struct hda_gnode *node = list_entry(p, struct hda_gnode, list); 88 if (node->conn_list != node->slist) 89 kfree(node->conn_list); 90 kfree(node); 91 } 92 kfree(spec); 90 93 } 91 94 … … 96 99 static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid_t nid) 97 100 { 98 struct hda_gnode *node; 99 int nconns; 100 101 node = kcalloc(1, sizeof(*node), GFP_KERNEL); 102 if (node == NULL) 103 return -ENOMEM; 104 node->nid = nid; 105 nconns = snd_hda_get_connections(codec, nid, node->conn_list, HDA_MAX_CONNECTIONS); 106 if (nconns < 0) { 107 kfree(node); 108 return nconns; 109 } 110 node->nconns = nconns; 111 node->wid_caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); 112 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 113 114 if (node->type == AC_WID_PIN) { 115 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP); 116 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 117 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 118 } 119 120 if (node->wid_caps & AC_WCAP_OUT_AMP) { 121 if (node->wid_caps & AC_WCAP_AMP_OVRD) 122 node->amp_out_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_OUT_CAP); 123 if (! node->amp_out_caps) 124 node->amp_out_caps = spec->def_amp_out_caps; 125 } 126 if (node->wid_caps & AC_WCAP_IN_AMP) { 127 if (node->wid_caps & AC_WCAP_AMP_OVRD) 128 node->amp_in_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_IN_CAP); 129 if (! node->amp_in_caps) 130 node->amp_in_caps = spec->def_amp_in_caps; 131 } 132 list_add_tail(&node->list, &spec->nid_list); 133 return 0; 101 struct hda_gnode *node; 102 int nconns; 103 hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; 104 105 node = kzalloc(sizeof(*node), GFP_KERNEL); 106 if (node == NULL) 107 return -ENOMEM; 108 node->nid = nid; 109 nconns = snd_hda_get_connections(codec, nid, conn_list, 110 HDA_MAX_CONNECTIONS); 111 if (nconns < 0) { 112 kfree(node); 113 return nconns; 114 } 115 if (nconns <= ARRAY_SIZE(node->slist)) 116 node->conn_list = node->slist; 117 else { 118 node->conn_list = kmalloc(sizeof(hda_nid_t) * nconns, 119 GFP_KERNEL); 120 if (! node->conn_list) { 121 snd_printk(KERN_ERR "hda-generic: cannot malloc\n"); 122 kfree(node); 123 return -ENOMEM; 124 } 125 } 126 memcpy(node->conn_list, conn_list, nconns); 127 node->nconns = nconns; 128 node->wid_caps = get_wcaps(codec, nid); 129 node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 130 131 if (node->type == AC_WID_PIN) { 132 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP); 133 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 134 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 135 } 136 137 if (node->wid_caps & AC_WCAP_OUT_AMP) { 138 if (node->wid_caps & AC_WCAP_AMP_OVRD) 139 node->amp_out_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_OUT_CAP); 140 if (! node->amp_out_caps) 141 node->amp_out_caps = spec->def_amp_out_caps; 142 } 143 if (node->wid_caps & AC_WCAP_IN_AMP) { 144 if (node->wid_caps & AC_WCAP_AMP_OVRD) 145 node->amp_in_caps = snd_hda_param_read(codec, node->nid, AC_PAR_AMP_IN_CAP); 146 if (! node->amp_in_caps) 147 node->amp_in_caps = spec->def_amp_in_caps; 148 } 149 list_add_tail(&node->list, &spec->nid_list); 150 return 0; 134 151 } 135 152 … … 139 156 static int build_afg_tree(struct hda_codec *codec) 140 157 { 141 struct hda_gspec *spec = codec->spec;142 int i, nodes, err;143 hda_nid_t nid;144 145 snd_assert(spec, return -EINVAL);146 147 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP);148 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP);149 150 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);151 if (! nid || nodes < 0) {152 printk(KERN_ERR "Invalid AFG subtree\n");153 return -EINVAL;154 }155 156 /* parse all nodes belonging to the AFG */157 for (i = 0; i < nodes; i++, nid++) {158 if ((err = add_new_node(codec, spec, nid)) < 0)159 return err;160 }161 162 return 0;158 struct hda_gspec *spec = codec->spec; 159 int i, nodes, err; 160 hda_nid_t nid; 161 162 snd_assert(spec, return -EINVAL); 163 164 spec->def_amp_out_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_OUT_CAP); 165 spec->def_amp_in_caps = snd_hda_param_read(codec, codec->afg, AC_PAR_AMP_IN_CAP); 166 167 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); 168 if (! nid || nodes < 0) { 169 printk(KERN_ERR "Invalid AFG subtree\n"); 170 return -EINVAL; 171 } 172 173 /* parse all nodes belonging to the AFG */ 174 for (i = 0; i < nodes; i++, nid++) { 175 if ((err = add_new_node(codec, spec, nid)) < 0) 176 return err; 177 } 178 179 return 0; 163 180 } 164 181 … … 170 187 static struct hda_gnode *hda_get_node(struct hda_gspec *spec, hda_nid_t nid) 171 188 { 172 struct list_head *p;173 struct hda_gnode *node;174 175 list_for_each(p, &spec->nid_list) {176 node = list_entry(p, struct hda_gnode, list);177 if (node->nid == nid)178 return node;179 }180 return NULL;189 struct list_head *p; 190 struct hda_gnode *node; 191 192 list_for_each(p, &spec->nid_list) { 193 node = list_entry(p, struct hda_gnode, list); 194 if (node->nid == nid) 195 return node; 196 } 197 return NULL; 181 198 } 182 199 … … 186 203 static int unmute_output(struct hda_codec *codec, struct hda_gnode *node) 187 204 { 188 unsigned int val, ofs;189 snd_printdd("UNMUTE OUT: NID=0x%x\n", node->nid);190 val = (node->amp_out_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;191 ofs = (node->amp_out_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;192 if (val >= ofs)193 val -= ofs;194 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;195 val |= AC_AMP_SET_OUTPUT;196 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val);205 unsigned int val, ofs; 206 snd_printdd("UNMUTE OUT: NID=0x%x\n", node->nid); 207 val = (node->amp_out_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; 208 ofs = (node->amp_out_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; 209 if (val >= ofs) 210 val -= ofs; 211 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT; 212 val |= AC_AMP_SET_OUTPUT; 213 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val); 197 214 } 198 215 … … 202 219 static int unmute_input(struct hda_codec *codec, struct hda_gnode *node, unsigned int index) 203 220 { 204 unsigned int val, ofs;205 snd_printdd("UNMUTE IN: NID=0x%x IDX=0x%x\n", node->nid, index);206 val = (node->amp_in_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;207 ofs = (node->amp_in_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT;208 if (val >= ofs)209 val -= ofs;210 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;211 val |= AC_AMP_SET_INPUT;212 // awk added - fixed to allow unmuting of indexed amps213 val |= index << AC_AMP_SET_INDEX_SHIFT;214 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val);221 unsigned int val, ofs; 222 snd_printdd("UNMUTE IN: NID=0x%x IDX=0x%x\n", node->nid, index); 223 val = (node->amp_in_caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; 224 ofs = (node->amp_in_caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; 225 if (val >= ofs) 226 val -= ofs; 227 val |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT; 228 val |= AC_AMP_SET_INPUT; 229 // awk added - fixed to allow unmuting of indexed amps 230 val |= index << AC_AMP_SET_INDEX_SHIFT; 231 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, val); 215 232 } 216 233 … … 219 236 */ 220 237 static int select_input_connection(struct hda_codec *codec, struct hda_gnode *node, 221 unsigned int index)222 { 223 snd_printdd("CONNECT: NID=0x%x IDX=0x%x\n", node->nid, index);224 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_CONNECT_SEL, index);238 unsigned int index) 239 { 240 snd_printdd("CONNECT: NID=0x%x IDX=0x%x\n", node->nid, index); 241 return snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_CONNECT_SEL, index); 225 242 } 226 243 … … 230 247 static void clear_check_flags(struct hda_gspec *spec) 231 248 { 232 struct list_head *p;233 struct hda_gnode *node;234 235 list_for_each(p, &spec->nid_list) {236 node = list_entry(p, struct hda_gnode, list);237 node->checked = 0;238 }249 struct list_head *p; 250 struct hda_gnode *node; 251 252 list_for_each(p, &spec->nid_list) { 253 node = list_entry(p, struct hda_gnode, list); 254 node->checked = 0; 255 } 239 256 } 240 257 … … 245 262 */ 246 263 static int parse_output_path(struct hda_codec *codec, struct hda_gspec *spec, 247 struct hda_gnode *node)248 { 249 int i, err;250 struct hda_gnode *child;251 252 if (node->checked)253 return 0;254 255 node->checked = 1;256 if (node->type == AC_WID_AUD_OUT) {257 if (node->wid_caps & AC_WCAP_DIGITAL) {258 snd_printdd("Skip Digital OUT node %x\n", node->nid);259 return 0;260 }261 snd_printdd("AUD_OUT found %x\n", node->nid);262 if (spec->dac_node) {263 /* already DAC node is assigned, just unmute & connect */264 return node == spec->dac_node;265 }266 spec->dac_node = node;267 if (node->wid_caps & AC_WCAP_OUT_AMP) {268 spec->pcm_vol_node = node;269 spec->pcm_vol_index = 0;270 }271 return 1; /* found */272 }273 274 for (i = 0; i < node->nconns; i++) {275 child = hda_get_node(spec, node->conn_list[i]);276 if (! child)277 continue;278 err = parse_output_path(codec, spec, child);279 if (err < 0)280 return err;281 else if (err > 0) {282 /* found one,283 * select the path, unmute both input and output284 */285 if (node->nconns > 1)286 select_input_connection(codec, node, i);287 unmute_input(codec, node, i);288 unmute_output(codec, node);289 if (! spec->pcm_vol_node) {290 if (node->wid_caps & AC_WCAP_IN_AMP) {291 spec->pcm_vol_node = node;292 spec->pcm_vol_index = i;293 } else if (node->wid_caps & AC_WCAP_OUT_AMP) {294 spec->pcm_vol_node = node;295 spec->pcm_vol_index = 0;296 }297 }298 return 1;299 }300 }301 return 0;264 struct hda_gnode *node) 265 { 266 int i, err; 267 struct hda_gnode *child; 268 269 if (node->checked) 270 return 0; 271 272 node->checked = 1; 273 if (node->type == AC_WID_AUD_OUT) { 274 if (node->wid_caps & AC_WCAP_DIGITAL) { 275 snd_printdd("Skip Digital OUT node %x\n", node->nid); 276 return 0; 277 } 278 snd_printdd("AUD_OUT found %x\n", node->nid); 279 if (spec->dac_node) { 280 /* already DAC node is assigned, just unmute & connect */ 281 return node == spec->dac_node; 282 } 283 spec->dac_node = node; 284 if (node->wid_caps & AC_WCAP_OUT_AMP) { 285 spec->pcm_vol_node = node; 286 spec->pcm_vol_index = 0; 287 } 288 return 1; /* found */ 289 } 290 291 for (i = 0; i < node->nconns; i++) { 292 child = hda_get_node(spec, node->conn_list[i]); 293 if (! child) 294 continue; 295 err = parse_output_path(codec, spec, child); 296 if (err < 0) 297 return err; 298 else if (err > 0) { 299 /* found one, 300 * select the path, unmute both input and output 301 */ 302 if (node->nconns > 1) 303 select_input_connection(codec, node, i); 304 unmute_input(codec, node, i); 305 unmute_output(codec, node); 306 if (! spec->pcm_vol_node) { 307 if (node->wid_caps & AC_WCAP_IN_AMP) { 308 spec->pcm_vol_node = node; 309 spec->pcm_vol_index = i; 310 } else if (node->wid_caps & AC_WCAP_OUT_AMP) { 311 spec->pcm_vol_node = node; 312 spec->pcm_vol_index = 0; 313 } 314 } 315 return 1; 316 } 317 } 318 return 0; 302 319 } 303 320 … … 309 326 */ 310 327 static struct hda_gnode *parse_output_jack(struct hda_codec *codec, 311 struct hda_gspec *spec,312 int jack_type)313 { 314 struct list_head *p;315 struct hda_gnode *node;316 int err;317 318 list_for_each(p, &spec->nid_list) {319 node = list_entry(p, struct hda_gnode, list);320 if (node->type != AC_WID_PIN)321 continue;322 /* output capable? */323 if (! (node->pin_caps & AC_PINCAP_OUT))324 continue;325 if (jack_type >= 0) {326 if (jack_type != get_defcfg_type(node))327 continue;328 if (node->wid_caps & AC_WCAP_DIGITAL)329 continue; /* skip SPDIF */330 } else {331 /* output as default? */332 if (! (node->pin_ctl & AC_PINCTL_OUT_EN))333 continue;334 }335 clear_check_flags(spec);336 err = parse_output_path(codec, spec, node);337 if (err < 0)338 return NULL;339 else if (err > 0) {340 /* unmute the PIN output */341 unmute_output(codec, node);342 /* set PIN-Out enable */343 snd_hda_codec_write(codec, node->nid, 0,344 AC_VERB_SET_PIN_WIDGET_CONTROL,345 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);346 return node;347 }348 }349 return NULL;328 struct hda_gspec *spec, 329 int jack_type) 330 { 331 struct list_head *p; 332 struct hda_gnode *node; 333 int err; 334 335 list_for_each(p, &spec->nid_list) { 336 node = list_entry(p, struct hda_gnode, list); 337 if (node->type != AC_WID_PIN) 338 continue; 339 /* output capable? */ 340 if (! (node->pin_caps & AC_PINCAP_OUT)) 341 continue; 342 if (jack_type >= 0) { 343 if (jack_type != defcfg_type(node)) 344 continue; 345 if (node->wid_caps & AC_WCAP_DIGITAL) 346 continue; /* skip SPDIF */ 347 } else { 348 /* output as default? */ 349 if (! (node->pin_ctl & AC_PINCTL_OUT_EN)) 350 continue; 351 } 352 clear_check_flags(spec); 353 err = parse_output_path(codec, spec, node); 354 if (err < 0) 355 return NULL; 356 else if (err > 0) { 357 /* unmute the PIN output */ 358 unmute_output(codec, node); 359 /* set PIN-Out enable */ 360 snd_hda_codec_write(codec, node->nid, 0, 361 AC_VERB_SET_PIN_WIDGET_CONTROL, 362 AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); 363 return node; 364 } 365 } 366 return NULL; 350 367 } 351 368 … … 356 373 static int parse_output(struct hda_codec *codec) 357 374 { 358 struct hda_gspec *spec = codec->spec;359 struct hda_gnode *node;360 361 /*362 * Look for the output PIN widget363 */364 /* first, look for the line-out pin */365 node = parse_output_jack(codec, spec, AC_JACK_LINE_OUT);366 if (node) /* found, remember the PIN node */367 spec->out_pin_node = node;368 /* look for the HP-out pin */369 node = parse_output_jack(codec, spec, AC_JACK_HP_OUT);370 if (node) {371 if (! spec->out_pin_node)372 spec->out_pin_node = node;373 }374 375 if (! spec->out_pin_node) {376 /* no line-out or HP pins found,377 * then choose for the first output pin378 */379 spec->out_pin_node = parse_output_jack(codec, spec, -1);380 if (! spec->out_pin_node)381 snd_printd("hda_generic: no proper output path found\n");382 }383 384 return 0;375 struct hda_gspec *spec = codec->spec; 376 struct hda_gnode *node; 377 378 /* 379 * Look for the output PIN widget 380 */ 381 /* first, look for the line-out pin */ 382 node = parse_output_jack(codec, spec, AC_JACK_LINE_OUT); 383 if (node) /* found, remember the PIN node */ 384 spec->out_pin_node = node; 385 /* look for the HP-out pin */ 386 node = parse_output_jack(codec, spec, AC_JACK_HP_OUT); 387 if (node) { 388 if (! spec->out_pin_node) 389 spec->out_pin_node = node; 390 } 391 392 if (! spec->out_pin_node) { 393 /* no line-out or HP pins found, 394 * then choose for the first output pin 395 */ 396 spec->out_pin_node = parse_output_jack(codec, spec, -1); 397 if (! spec->out_pin_node) 398 snd_printd("hda_generic: no proper output path found\n"); 399 } 400 401 return 0; 385 402 } 386 403 … … 390 407 391 408 /* control callbacks */ 392 static int capture_source_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)393 { 394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);395 struct hda_gspec *spec = codec->spec;396 return snd_hda_input_mux_info(&spec->input_mux, uinfo);397 } 398 399 static int capture_source_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)400 { 401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);402 struct hda_gspec *spec = codec->spec;403 404 ucontrol->value.enumerated.item[0] = spec->cur_cap_src;405 return 0;406 } 407 408 static int capture_source_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)409 { 410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);411 struct hda_gspec *spec = codec->spec;412 return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol,413 spec->adc_node->nid, &spec->cur_cap_src);409 static int capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 410 { 411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 412 struct hda_gspec *spec = codec->spec; 413 return snd_hda_input_mux_info(&spec->input_mux, uinfo); 414 } 415 416 static int capture_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 417 { 418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 419 struct hda_gspec *spec = codec->spec; 420 421 ucontrol->value.enumerated.item[0] = spec->cur_cap_src; 422 return 0; 423 } 424 425 static int capture_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 426 { 427 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 428 struct hda_gspec *spec = codec->spec; 429 return snd_hda_input_mux_put(codec, &spec->input_mux, ucontrol, 430 spec->adc_node->nid, &spec->cur_cap_src); 414 431 } 415 432 … … 419 436 static const char *get_input_type(struct hda_gnode *node, unsigned int *pinctl) 420 437 { 421 unsigned int location = get_defcfg_location(node);422 switch (get_defcfg_type(node)) {423 case AC_JACK_LINE_IN:424 if ((location & 0x0f) == AC_JACK_LOC_FRONT)425 return "Front Line";426 return "Line";427 case AC_JACK_CD:428 if (pinctl)429 *pinctl |= AC_PINCTL_VREF_GRD;430 return "CD";431 case AC_JACK_AUX:432 if ((location & 0x0f) == AC_JACK_LOC_FRONT)433 return "Front Aux";434 return "Aux";435 case AC_JACK_MIC_IN:436 if ((location & 0x0f) == AC_JACK_LOC_FRONT)437 return "Front Mic";438 return "Mic";439 case AC_JACK_SPDIF_IN:440 return "SPDIF";441 case AC_JACK_DIG_OTHER_IN:442 return "Digital";443 }444 return NULL;438 unsigned int location = defcfg_location(node); 439 switch (defcfg_type(node)) { 440 case AC_JACK_LINE_IN: 441 if ((location & 0x0f) == AC_JACK_LOC_FRONT) 442 return "Front Line"; 443 return "Line"; 444 case AC_JACK_CD: 445 if (pinctl) 446 *pinctl |= AC_PINCTL_VREF_GRD; 447 return "CD"; 448 case AC_JACK_AUX: 449 if ((location & 0x0f) == AC_JACK_LOC_FRONT) 450 return "Front Aux"; 451 return "Aux"; 452 case AC_JACK_MIC_IN: 453 if ((location & 0x0f) == AC_JACK_LOC_FRONT) 454 return "Front Mic"; 455 return "Mic"; 456 case AC_JACK_SPDIF_IN: 457 return "SPDIF"; 458 case AC_JACK_DIG_OTHER_IN: 459 return "Digital"; 460 } 461 return NULL; 445 462 } 446 463 … … 451 468 */ 452 469 static int parse_adc_sub_nodes(struct hda_codec *codec, struct hda_gspec *spec, 453 struct hda_gnode *node)454 { 455 int i, err;456 unsigned int pinctl;457 char *label;458 const char *type;459 460 if (node->checked)461 return 0;462 463 node->checked = 1;464 if (node->type != AC_WID_PIN) {465 for (i = 0; i < node->nconns; i++) {466 struct hda_gnode *child;467 child = hda_get_node(spec, node->conn_list[i]);468 if (! child)469 continue;470 err = parse_adc_sub_nodes(codec, spec, child);471 if (err < 0)472 return err;473 if (err > 0) {474 /* found one,475 * select the path, unmute both input and output476 */477 if (node->nconns > 1)478 select_input_connection(codec, node, i);479 unmute_input(codec, node, i);480 unmute_output(codec, node);481 return err;482 }483 }484 return 0;485 }486 487 /* input capable? */488 if (! (node->pin_caps & AC_PINCAP_IN))489 return 0;490 491 if (node->wid_caps & AC_WCAP_DIGITAL)492 return 0; /* skip SPDIF */493 494 if (spec->input_mux.num_items >= HDA_MAX_NUM_INPUTS) {495 snd_printk(KERN_ERR "hda_generic: Too many items for capture\n");496 return -EINVAL;497 }498 499 pinctl = AC_PINCTL_IN_EN;500 /* create a proper capture source label */501 type = get_input_type(node, &pinctl);502 if (! type) {503 /* input as default? */504 if (! (node->pin_ctl & AC_PINCTL_IN_EN))505 return 0;506 type = "Input";507 }508 label = spec->cap_labels[spec->input_mux.num_items];509 strcpy(label, type);510 spec->input_mux.items[spec->input_mux.num_items].label = label;511 512 /* unmute the PIN external input */513 unmute_input(codec, node, 0); /* index = 0? */514 /* set PIN-In enable */515 snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);516 517 return 1; /* found */470 struct hda_gnode *node) 471 { 472 int i, err; 473 unsigned int pinctl; 474 char *label; 475 const char *type; 476 477 if (node->checked) 478 return 0; 479 480 node->checked = 1; 481 if (node->type != AC_WID_PIN) { 482 for (i = 0; i < node->nconns; i++) { 483 struct hda_gnode *child; 484 child = hda_get_node(spec, node->conn_list[i]); 485 if (! child) 486 continue; 487 err = parse_adc_sub_nodes(codec, spec, child); 488 if (err < 0) 489 return err; 490 if (err > 0) { 491 /* found one, 492 * select the path, unmute both input and output 493 */ 494 if (node->nconns > 1) 495 select_input_connection(codec, node, i); 496 unmute_input(codec, node, i); 497 unmute_output(codec, node); 498 return err; 499 } 500 } 501 return 0; 502 } 503 504 /* input capable? */ 505 if (! (node->pin_caps & AC_PINCAP_IN)) 506 return 0; 507 508 if (node->wid_caps & AC_WCAP_DIGITAL) 509 return 0; /* skip SPDIF */ 510 511 if (spec->input_mux.num_items >= HDA_MAX_NUM_INPUTS) { 512 snd_printk(KERN_ERR "hda_generic: Too many items for capture\n"); 513 return -EINVAL; 514 } 515 516 pinctl = AC_PINCTL_IN_EN; 517 /* create a proper capture source label */ 518 type = get_input_type(node, &pinctl); 519 if (! type) { 520 /* input as default? */ 521 if (! (node->pin_ctl & AC_PINCTL_IN_EN)) 522 return 0; 523 type = "Input"; 524 } 525 label = spec->cap_labels[spec->input_mux.num_items]; 526 strcpy(label, type); 527 spec->input_mux.items[spec->input_mux.num_items].label = label; 528 529 /* unmute the PIN external input */ 530 unmute_input(codec, node, 0); /* index = 0? */ 531 /* set PIN-In enable */ 532 snd_hda_codec_write(codec, node->nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl); 533 534 return 1; /* found */ 518 535 } 519 536 … … 523 540 static int parse_input_path(struct hda_codec *codec, struct hda_gnode *adc_node) 524 541 { 525 struct hda_gspec *spec = codec->spec;526 struct hda_gnode *node;527 int i, err;528 529 snd_printdd("AUD_IN = %x\n", adc_node->nid);530 clear_check_flags(spec);531 532 // awk added - fixed no recording due to muted widget533 unmute_input(codec, adc_node, 0);534 535 /*536 * check each connection of the ADC537 * if it reaches to a proper input PIN, add the path as the538 * input path.539 */540 for (i = 0; i < adc_node->nconns; i++) {541 node = hda_get_node(spec, adc_node->conn_list[i]);542 if (! node)543 continue;544 err = parse_adc_sub_nodes(codec, spec, node);545 if (err < 0)546 return err;547 else if (err > 0) {548 struct hda_input_mux_item *csrc = &spec->input_mux.items[spec->input_mux.num_items];549 char *buf = spec->cap_labels[spec->input_mux.num_items];550 int ocap;551 for (ocap = 0; ocap < spec->input_mux.num_items; ocap++) {552 if (! strcmp(buf, spec->cap_labels[ocap])) {553 /* same label already exists,554 * put the index number to be unique555 */556 sprintf(buf, "%s %d", spec->cap_labels[ocap],557 spec->input_mux.num_items);558 }559 }560 csrc->index = i;561 spec->input_mux.num_items++;562 }563 }564 565 if (! spec->input_mux.num_items)566 return 0; /* no input path found... */567 568 snd_printdd("[Capture Source] NID=0x%x, #SRC=%d\n", adc_node->nid, spec->input_mux.num_items);569 for (i = 0; i < spec->input_mux.num_items; i++)570 snd_printdd(" [%s] IDX=0x%x\n", spec->input_mux.items[i].label,571 spec->input_mux.items[i].index);572 573 spec->adc_node = adc_node;574 return 1;542 struct hda_gspec *spec = codec->spec; 543 struct hda_gnode *node; 544 int i, err; 545 546 snd_printdd("AUD_IN = %x\n", adc_node->nid); 547 clear_check_flags(spec); 548 549 // awk added - fixed no recording due to muted widget 550 unmute_input(codec, adc_node, 0); 551 552 /* 553 * check each connection of the ADC 554 * if it reaches to a proper input PIN, add the path as the 555 * input path. 556 */ 557 for (i = 0; i < adc_node->nconns; i++) { 558 node = hda_get_node(spec, adc_node->conn_list[i]); 559 if (! node) 560 continue; 561 err = parse_adc_sub_nodes(codec, spec, node); 562 if (err < 0) 563 return err; 564 else if (err > 0) { 565 struct hda_input_mux_item *csrc = &spec->input_mux.items[spec->input_mux.num_items]; 566 char *buf = spec->cap_labels[spec->input_mux.num_items]; 567 int ocap; 568 for (ocap = 0; ocap < spec->input_mux.num_items; ocap++) { 569 if (! strcmp(buf, spec->cap_labels[ocap])) { 570 /* same label already exists, 571 * put the index number to be unique 572 */ 573 sprintf(buf, "%s %d", spec->cap_labels[ocap], 574 spec->input_mux.num_items); 575 } 576 } 577 csrc->index = i; 578 spec->input_mux.num_items++; 579 } 580 } 581 582 if (! spec->input_mux.num_items) 583 return 0; /* no input path found... */ 584 585 snd_printdd("[Capture Source] NID=0x%x, #SRC=%d\n", adc_node->nid, spec->input_mux.num_items); 586 for (i = 0; i < spec->input_mux.num_items; i++) 587 snd_printdd(" [%s] IDX=0x%x\n", spec->input_mux.items[i].label, 588 spec->input_mux.items[i].index); 589 590 spec->adc_node = adc_node; 591 return 1; 575 592 } 576 593 … … 580 597 static int parse_input(struct hda_codec *codec) 581 598 { 582 struct hda_gspec *spec = codec->spec;583 struct list_head *p;584 struct hda_gnode *node;585 int err;586 587 /*588 * At first we look for an audio input widget.589 * If it reaches to certain input PINs, we take it as the590 * input path.591 */592 list_for_each(p, &spec->nid_list) {593 node = list_entry(p, struct hda_gnode, list);594 if (node->wid_caps & AC_WCAP_DIGITAL)595 continue; /* skip SPDIF */596 if (node->type == AC_WID_AUD_IN) {597 err = parse_input_path(codec, node);598 if (err < 0)599 return err;600 else if (err > 0)601 return 0;602 }603 }604 snd_printd("hda_generic: no proper input path found\n");605 return 0;599 struct hda_gspec *spec = codec->spec; 600 struct list_head *p; 601 struct hda_gnode *node; 602 int err; 603 604 /* 605 * At first we look for an audio input widget. 606 * If it reaches to certain input PINs, we take it as the 607 * input path. 608 */ 609 list_for_each(p, &spec->nid_list) { 610 node = list_entry(p, struct hda_gnode, list); 611 if (node->wid_caps & AC_WCAP_DIGITAL) 612 continue; /* skip SPDIF */ 613 if (node->type == AC_WID_AUD_IN) { 614 err = parse_input_path(codec, node); 615 if (err < 0) 616 return err; 617 else if (err > 0) 618 return 0; 619 } 620 } 621 snd_printd("hda_generic: no proper input path found\n"); 622 return 0; 606 623 } 607 624 … … 613 630 614 631 static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, 615 unsigned int index, const char *type, const char *dir_sfx) 616 { 617 char name[32] = {0}; 618 int err; 619 int created = 0; 620 snd_kcontrol_new_t knew; 621 622 if (type) 623 sprintf(name, "%s %s Switch", type, dir_sfx); 624 else 625 sprintf(name, "%s Switch", dir_sfx); 626 if ((node->wid_caps & AC_WCAP_IN_AMP) && 627 (node->amp_in_caps & AC_AMPCAP_MUTE)) { 628 //knew = {0}; 629 //HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT); 630 631 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 632 knew.name = name; 633 knew.info = snd_hda_mixer_amp_switch_info; 634 knew.get = snd_hda_mixer_amp_switch_get; 635 knew.put = snd_hda_mixer_amp_switch_put; 636 knew.private_value = (node->nid | (3 << 16) | (HDA_INPUT << 18) | (index << 19)); 637 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); 638 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 639 return err; 640 created = 1; 641 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && 642 (node->amp_out_caps & AC_AMPCAP_MUTE)) { 643 //knew = {0}; 632 unsigned int index, const char *type, const char *dir_sfx) 633 { 634 char name[32]; 635 int err; 636 int created = 0; 637 struct snd_kcontrol_new knew = {0}; 638 639 if (type) 640 sprintf(name, "%s %s Switch", type, dir_sfx); 641 else 642 sprintf(name, "%s Switch", dir_sfx); 643 if ((node->wid_caps & AC_WCAP_IN_AMP) && 644 (node->amp_in_caps & AC_AMPCAP_MUTE)) { 645 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 646 knew.name = name; 647 knew.info = snd_hda_mixer_amp_switch_info; 648 knew.get = snd_hda_mixer_amp_switch_get; 649 knew.put = snd_hda_mixer_amp_switch_put; 650 knew.private_value = (node->nid | (3 << 16) | (HDA_INPUT << 18) | (index << 19)); 651 652 //knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT); 653 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); 654 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 655 return err; 656 created = 1; 657 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && 658 (node->amp_out_caps & AC_AMPCAP_MUTE)) { 644 659 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 645 660 knew.name = name; … … 649 664 knew.private_value = (node->nid | (3 << 16) | (HDA_OUTPUT << 18) | (0 << 19)); 650 665 651 //HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT); 652 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); 653 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 654 return err; 655 created = 1; 656 } 657 658 if (type) 659 sprintf(name, "%s %s Volume", type, dir_sfx); 660 else 661 sprintf(name, "%s Volume", dir_sfx); 662 if ((node->wid_caps & AC_WCAP_IN_AMP) && 663 (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) { 664 //knew = {0}; 666 //knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT); 667 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); 668 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 669 return err; 670 created = 1; 671 } 672 673 if (type) 674 sprintf(name, "%s %s Volume", type, dir_sfx); 675 else 676 sprintf(name, "%s Volume", dir_sfx); 677 if ((node->wid_caps & AC_WCAP_IN_AMP) && 678 (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) { 665 679 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 666 680 knew.name = name; … … 669 683 knew.put = snd_hda_mixer_amp_volume_put; 670 684 knew.private_value = (node->nid | (3 << 16) | (HDA_INPUT << 18) | (index << 19)); 671 //HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); 672 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); 673 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 674 return err; 675 created = 1; 676 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && 677 (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) { 678 //knew = {0}; 685 686 //knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); 687 snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); 688 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 689 return err; 690 created = 1; 691 } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && 692 (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) { 693 //knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); 679 694 knew.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 680 695 knew.name = name; … … 683 698 knew.put = snd_hda_mixer_amp_volume_put; 684 699 knew.private_value = (node->nid | (3 << 16) | (HDA_OUTPUT << 18) | (0 << 19)); 685 //HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); 686 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid);687 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0)688 return err;689 created = 1;690 }691 692 return created;700 701 snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); 702 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) 703 return err; 704 created = 1; 705 } 706 707 return created; 693 708 } 694 709 … … 698 713 static int check_existing_control(struct hda_codec *codec, const char *type, const char *dir) 699 714 { 700 snd_ctl_elem_id_tid;701 memset(&id, 0, sizeof(id));702 sprintf(id.name, "%s %s Volume", type, dir);703 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;704 if (snd_ctl_find_id(codec->bus->card, &id))705 return 1;706 sprintf(id.name, "%s %s Switch", type, dir);707 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;708 if (snd_ctl_find_id(codec->bus->card, &id))709 return 1;710 return 0;715 struct snd_ctl_elem_id id; 716 memset(&id, 0, sizeof(id)); 717 sprintf(id.name, "%s %s Volume", type, dir); 718 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 719 if (snd_ctl_find_id(codec->bus->card, &id)) 720 return 1; 721 sprintf(id.name, "%s %s Switch", type, dir); 722 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 723 if (snd_ctl_find_id(codec->bus->card, &id)) 724 return 1; 725 return 0; 711 726 } 712 727 … … 716 731 static int build_output_controls(struct hda_codec *codec) 717 732 { 718 struct hda_gspec *spec = codec->spec;719 int err;720 721 err = create_mixer(codec, spec->pcm_vol_node, spec->pcm_vol_index,722 "PCM", "Playback");723 if (err < 0)724 return err;725 return 0;733 struct hda_gspec *spec = codec->spec; 734 int err; 735 736 err = create_mixer(codec, spec->pcm_vol_node, spec->pcm_vol_index, 737 "PCM", "Playback"); 738 if (err < 0) 739 return err; 740 return 0; 726 741 } 727 742 … … 729 744 static int build_input_controls(struct hda_codec *codec) 730 745 { 731 struct hda_gspec *spec = codec->spec;732 struct hda_gnode *adc_node = spec->adc_node;733 int err;734 735 if (! adc_node)736 return 0; /* not found */737 738 /* create capture volume and switch controls if the ADC has an amp */739 err = create_mixer(codec, adc_node, 0, NULL, "Capture");740 741 /* create input MUX if multiple sources are available */742 if (spec->input_mux.num_items > 1) {743 static snd_kcontrol_new_tcap_sel = {744 SNDRV_CTL_ELEM_IFACE_MIXER,0,0,745 "Capture Source",0,0,0,746 capture_source_info,747 capture_source_get,748 capture_source_put,0 749 };750 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&cap_sel, codec))) < 0)751 return err;752 spec->cur_cap_src = 0;753 select_input_connection(codec, adc_node, spec->input_mux.items[0].index);754 }755 return 0;746 struct hda_gspec *spec = codec->spec; 747 struct hda_gnode *adc_node = spec->adc_node; 748 int err; 749 750 if (! adc_node) 751 return 0; /* not found */ 752 753 /* create capture volume and switch controls if the ADC has an amp */ 754 err = create_mixer(codec, adc_node, 0, NULL, "Capture"); 755 756 /* create input MUX if multiple sources are available */ 757 if (spec->input_mux.num_items > 1) { 758 static struct snd_kcontrol_new cap_sel = { 759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 760 .name = "Capture Source", 761 .info = capture_source_info, 762 .get = capture_source_get, 763 .put = capture_source_put, 764 }; 765 if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&cap_sel, codec))) < 0) 766 return err; 767 spec->cur_cap_src = 0; 768 select_input_connection(codec, adc_node, spec->input_mux.items[0].index); 769 } 770 return 0; 756 771 } 757 772 … … 766 781 */ 767 782 static int parse_loopback_path(struct hda_codec *codec, struct hda_gspec *spec, 768 struct hda_gnode *node, struct hda_gnode *dest_node,769 const char *type)770 { 771 int i, err;772 773 if (node->checked)774 return 0;775 776 node->checked = 1;777 if (node == dest_node) {778 /* loopback connection found */779 return 1;780 }781 782 for (i = 0; i < node->nconns; i++) {783 struct hda_gnode *child = hda_get_node(spec, node->conn_list[i]);784 if (! child)785 continue;786 err = parse_loopback_path(codec, spec, child, dest_node, type);787 if (err < 0)788 return err;789 else if (err >= 1) {790 if (err == 1) {791 err = create_mixer(codec, node, i, type, "Playback");792 if (err < 0)793 return err;794 if (err > 0)795 return 2; /* ok, created */796 /* not created, maybe in the lower path */797 err = 1;798 }799 /* connect and unmute */800 if (node->nconns > 1)801 select_input_connection(codec, node, i);802 unmute_input(codec, node, i);803 unmute_output(codec, node);804 return err;805 }806 }807 return 0;783 struct hda_gnode *node, struct hda_gnode *dest_node, 784 const char *type) 785 { 786 int i, err; 787 788 if (node->checked) 789 return 0; 790 791 node->checked = 1; 792 if (node == dest_node) { 793 /* loopback connection found */ 794 return 1; 795 } 796 797 for (i = 0; i < node->nconns; i++) { 798 struct hda_gnode *child = hda_get_node(spec, node->conn_list[i]); 799 if (! child) 800 continue; 801 err = parse_loopback_path(codec, spec, child, dest_node, type); 802 if (err < 0) 803 return err; 804 else if (err >= 1) { 805 if (err == 1) { 806 err = create_mixer(codec, node, i, type, "Playback"); 807 if (err < 0) 808 return err; 809 if (err > 0) 810 return 2; /* ok, created */ 811 /* not created, maybe in the lower path */ 812 err = 1; 813 } 814 /* connect and unmute */ 815 if (node->nconns > 1) 816 select_input_connection(codec, node, i); 817 unmute_input(codec, node, i); 818 unmute_output(codec, node); 819 return err; 820 } 821 } 822 return 0; 808 823 } 809 824 … … 813 828 static int build_loopback_controls(struct hda_codec *codec) 814 829 { 815 struct hda_gspec *spec = codec->spec;816 struct list_head *p;817 struct hda_gnode *node;818 int err;819 const char *type;820 821 if (! spec->out_pin_node)822 return 0;823 824 list_for_each(p, &spec->nid_list) {825 node = list_entry(p, struct hda_gnode, list);826 if (node->type != AC_WID_PIN)827 continue;828 /* input capable? */829 if (! (node->pin_caps & AC_PINCAP_IN))830 return 0;831 type = get_input_type(node, NULL);832 if (type) {833 if (check_existing_control(codec, type, "Playback"))834 continue;835 clear_check_flags(spec);836 err = parse_loopback_path(codec, spec, spec->out_pin_node,837 node, type);838 if (err < 0)839 return err;840 if (! err)841 continue;842 }843 }844 return 0;830 struct hda_gspec *spec = codec->spec; 831 struct list_head *p; 832 struct hda_gnode *node; 833 int err; 834 const char *type; 835 836 if (! spec->out_pin_node) 837 return 0; 838 839 list_for_each(p, &spec->nid_list) { 840 node = list_entry(p, struct hda_gnode, list); 841 if (node->type != AC_WID_PIN) 842 continue; 843 /* input capable? */ 844 if (! (node->pin_caps & AC_PINCAP_IN)) 845 return 0; 846 type = get_input_type(node, NULL); 847 if (type) { 848 if (check_existing_control(codec, type, "Playback")) 849 continue; 850 clear_check_flags(spec); 851 err = parse_loopback_path(codec, spec, spec->out_pin_node, 852 node, type); 853 if (err < 0) 854 return err; 855 if (! err) 856 continue; 857 } 858 } 859 return 0; 845 860 } 846 861 … … 850 865 static int build_generic_controls(struct hda_codec *codec) 851 866 { 852 int err;853 854 if ((err = build_input_controls(codec)) < 0 ||855 (err = build_output_controls(codec)) < 0 ||856 (err = build_loopback_controls(codec)) < 0)857 return err;858 859 return 0;867 int err; 868 869 if ((err = build_input_controls(codec)) < 0 || 870 (err = build_output_controls(codec)) < 0 || 871 (err = build_loopback_controls(codec)) < 0) 872 return err; 873 874 return 0; 860 875 } 861 876 … … 864 879 */ 865 880 static struct hda_pcm_stream generic_pcm_playback = { 866 /*.substreams = */1,867 /*.channels_min = */2,868 /*.channels_max = */2,881 .substreams = 1, 882 .channels_min = 2, 883 .channels_max = 2, 869 884 }; 870 885 871 886 static int build_generic_pcms(struct hda_codec *codec) 872 887 { 873 struct hda_gspec *spec = codec->spec;874 struct hda_pcm *info = &spec->pcm_rec;875 876 if (! spec->dac_node && ! spec->adc_node) {877 snd_printd("hda_generic: no PCM found\n");878 return 0;879 }880 881 codec->num_pcms = 1;882 codec->pcm_info = info;883 884 info->name = "HDA Generic";885 if (spec->dac_node) {886 info->stream[0] = generic_pcm_playback;887 info->stream[0].nid = spec->dac_node->nid;888 }889 if (spec->adc_node) {890 info->stream[1] = generic_pcm_playback;891 info->stream[1].nid = spec->adc_node->nid;892 }893 894 return 0;888 struct hda_gspec *spec = codec->spec; 889 struct hda_pcm *info = &spec->pcm_rec; 890 891 if (! spec->dac_node && ! spec->adc_node) { 892 snd_printd("hda_generic: no PCM found\n"); 893 return 0; 894 } 895 896 codec->num_pcms = 1; 897 codec->pcm_info = info; 898 899 info->name = "HDA Generic"; 900 if (spec->dac_node) { 901 info->stream[0] = generic_pcm_playback; 902 info->stream[0].nid = spec->dac_node->nid; 903 } 904 if (spec->adc_node) { 905 info->stream[1] = generic_pcm_playback; 906 info->stream[1].nid = spec->adc_node->nid; 907 } 908 909 return 0; 895 910 } 896 911 … … 899 914 */ 900 915 static struct hda_codec_ops generic_patch_ops = { 901 /*.build_controls = */build_generic_controls,902 /*.build_pcms = */build_generic_pcms,0,903 /*.free = */snd_hda_generic_free,916 .build_controls = build_generic_controls, 917 .build_pcms = build_generic_pcms, 918 .free = snd_hda_generic_free, 904 919 }; 905 920 … … 909 924 int snd_hda_parse_generic_codec(struct hda_codec *codec) 910 925 { 911 struct hda_gspec *spec; 912 int err; 913 914 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 915 if (spec == NULL) { 916 printk(KERN_ERR "hda_generic: can't allocate spec\n"); 917 return -ENOMEM; 918 } 919 codec->spec = spec; 920 INIT_LIST_HEAD(&spec->nid_list); 921 922 if ((err = build_afg_tree(codec)) < 0) 923 goto error; 924 925 if ((err = parse_input(codec)) < 0 || 926 (err = parse_output(codec)) < 0) 927 goto error; 928 929 codec->patch_ops = generic_patch_ops; 930 931 return 0; 932 933 error: 934 snd_hda_generic_free(codec); 935 return err; 936 } 926 struct hda_gspec *spec; 927 int err; 928 929 if(!codec->afg) 930 return 0; 931 932 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 933 if (spec == NULL) { 934 printk(KERN_ERR "hda_generic: can't allocate spec\n"); 935 return -ENOMEM; 936 } 937 codec->spec = spec; 938 INIT_LIST_HEAD(&spec->nid_list); 939 940 if ((err = build_afg_tree(codec)) < 0) 941 goto error; 942 943 if ((err = parse_input(codec)) < 0 || 944 (err = parse_output(codec)) < 0) 945 goto error; 946 947 codec->patch_ops = generic_patch_ops; 948 949 return 0; 950 951 error: 952 snd_hda_generic_free(codec); 953 return err; 954 } -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.c
r32 r69 31 31 * 32 32 * 2004.12.01 Major rewrite by tiwai, merged the work of pshou 33 * 33 * 34 34 */ 35 35 … … 38 38 #include <linux/delay.h> 39 39 #include <linux/interrupt.h> 40 #include <linux/kernel.h> 40 41 #include <linux/module.h> 41 42 #include <linux/moduleparam.h> … … 48 49 49 50 50 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; 51 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; 52 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; 53 static char *model[SNDRV_CARDS]; 54 static int position_fix[SNDRV_CARDS]; 55 56 //module_param_array(index, int, NULL, 0444); 51 static int index = SNDRV_DEFAULT_IDX1; 52 static char *id = SNDRV_DEFAULT_STR1; 53 static char *model; 54 static int position_fix; 55 static int probe_mask = -1; 56 static int single_cmd; 57 58 //module_param(index, int, 0444); 57 59 MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); 58 //module_param _array(id, charp, NULL, 0444);60 //module_param(id, charp, 0444); 59 61 MODULE_PARM_DESC(id, "ID string for Intel HD audio interface."); 60 //module_param_array(enable, bool, NULL, 0444); 61 MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); 62 //module_param_array(model, charp, NULL, 0444); 62 //module_param(model, charp, 0444); 63 63 MODULE_PARM_DESC(model, "Use the given board model."); 64 //module_param_array(position_fix, bool, NULL, 0444); 65 MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = FIFO size, 1 = none, 2 = POSBUF)."); 64 //module_param(position_fix, int, 0444); 65 MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); 66 //module_param(probe_mask, int, 0444); 67 MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); 68 //module_param(single_cmd, bool, 0444); 69 MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs (for debugging only)."); 70 71 72 /* just for backward compatibility */ 73 static int enable; 74 //module_param(enable, bool, 0444); 66 75 67 76 MODULE_LICENSE("GPL"); 68 77 MODULE_SUPPORTED_DEVICE("{{Intel, ICH6}," 69 "{Intel, ICH6M}," 70 "{Intel, ICH7}," 71 "{Intel, ESB2}," 72 "{ATI, SB450}," 73 "{VIA, VT8251}," 74 "{VIA, VT8237A}}"); 78 "{Intel, ICH6M}," 79 "{Intel, ICH7}," 80 "{Intel, ESB2}," 81 "{Intel, ICH8}," 82 "{ATI, SB450}," 83 "{VIA, VT8251}," 84 "{VIA, VT8237A}," 85 "{SiS, SIS966}," 86 "{ULI, M5461}}"); 75 87 MODULE_DESCRIPTION("Intel HDA driver"); 76 88 … … 92 104 #define ICH6_REG_INTSTS 0x24 93 105 #define ICH6_REG_WALCLK 0x30 94 #define ICH6_REG_SYNC 0x34 106 #define ICH6_REG_SYNC 0x34 95 107 #define ICH6_REG_CORBLBASE 0x40 96 108 #define ICH6_REG_CORBUBASE 0x44 … … 142 154 143 155 /* max number of SDs */ 144 #define MAX_ICH6_DEV 8 156 /* ICH, ATI and VIA have 4 playback and 4 capture */ 157 #define ICH6_CAPTURE_INDEX 0 158 #define ICH6_NUM_CAPTURE 4 159 #define ICH6_PLAYBACK_INDEX 4 160 #define ICH6_NUM_PLAYBACK 4 161 162 /* ULI has 6 playback and 5 capture */ 163 #define ULI_CAPTURE_INDEX 0 164 #define ULI_NUM_CAPTURE 5 165 #define ULI_PLAYBACK_INDEX 5 166 #define ULI_NUM_PLAYBACK 6 167 168 /* this number is statically defined for simplicity */ 169 #define MAX_AZX_DEV 16 170 145 171 /* max number of fragments - we may use more if allocating more pages for BDL */ 146 #define AZX_MAX_FRAG (PAGE_SIZE / (MAX_ICH6_DEV * 16)) 172 #define BDL_SIZE PAGE_ALIGN(8192) 173 #define AZX_MAX_FRAG (BDL_SIZE / (MAX_AZX_DEV * 16)) 147 174 /* max buffer size - no h/w limit, you can increase as you like */ 148 175 #define AZX_MAX_BUF_SIZE (1024*1024*1024) 149 176 /* max number of PCM devics per card */ 150 #define AZX_MAX_PCMS 8 177 #define AZX_MAX_AUDIO_PCMS 6 178 #define AZX_MAX_MODEM_PCMS 2 179 #define AZX_MAX_PCMS (AZX_MAX_AUDIO_PCMS + AZX_MAX_MODEM_PCMS) 151 180 152 181 /* RIRB int mask: overrun[2], response[0] */ … … 157 186 /* STATESTS int mask: SD2,SD1,SD0 */ 158 187 #define STATESTS_INT_MASK 0x07 159 #define AZX_MAX_CODECS 4188 #define AZX_MAX_CODECS 4 160 189 161 190 /* SD_CTL bits */ … … 178 207 #define ICH6_INT_CTRL_EN 0x40000000 /* controller interrupt enable bit */ 179 208 #define ICH6_INT_GLOBAL_EN 0x80000000 /* global interrupt enable bit */ 209 210 /* GCTL unsolicited response enable bit */ 211 #define ICH6_GCTL_UREN (1<<8) 180 212 181 213 /* GCTL reset bit */ … … 192 224 /* position fix mode */ 193 225 enum { 194 POS_FIX_FIFO, 195 POS_FIX_NONE, 196 POS_FIX_POSBUF 226 POS_FIX_AUTO, 227 POS_FIX_NONE, 228 POS_FIX_POSBUF, 229 POS_FIX_FIFO, 197 230 }; 198 231 199 232 /* Defines for ATI HD Audio support in SB450 south bridge */ 200 #define ATI_SB450_HDAUDIO_PCI_DEVICE_ID 0x437b201 233 #define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42 202 234 #define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02 203 235 204 /* 205 * Use CORB/RIRB for communication from/to codecs. 206 * This is the way recommended by Intel (see below). 207 */ 208 #define USE_CORB_RIRB 209 210 /* 211 */ 212 213 typedef struct snd_azx azx_t; 214 typedef struct snd_azx_rb azx_rb_t; 215 typedef struct snd_azx_dev azx_dev_t; 216 217 struct snd_azx_dev { 236 /* Defines for Nvidia HDA support */ 237 #define NVIDIA_HDA_TRANSREG_ADDR 0x4e 238 #define NVIDIA_HDA_ENABLE_COHBITS 0x0f 239 240 /* 241 */ 242 243 struct azx_dev { 218 244 u32 *bdl; /* virtual address of the BDL */ 219 245 dma_addr_t bdl_addr; /* physical address of the BDL */ … … 224 250 unsigned int frags; /* number for period in the play buffer */ 225 251 unsigned int fifo_size; /* FIFO size */ 252 unsigned int last_pos; /* last updated period position */ 226 253 227 254 void __iomem *sd_addr; /* stream descriptor pointer */ … … 230 257 231 258 /* pcm support */ 232 s nd_pcm_substream_t*substream; /* assigned substream, set in PCM open */259 struct snd_pcm_substream *substream; /* assigned substream, set in PCM open */ 233 260 unsigned int format_val; /* format value to be set in the controller and the codec */ 234 261 unsigned char stream_tag; /* assigned stream */ … … 237 264 unsigned int opened: 1; 238 265 unsigned int running: 1; 266 unsigned int period_updating: 1; 239 267 }; 240 268 241 269 /* CORB/RIRB */ 242 struct snd_azx_rb {270 struct azx_rb { 243 271 u32 *buf; /* CORB/RIRB buffer 244 272 * Each CORB entry is 4byte, RIRB is 8byte … … 251 279 }; 252 280 253 struct snd_azx {254 s nd_card_t*card;281 struct azx { 282 struct snd_card *card; 255 283 struct pci_dev *pci; 284 285 /* chip type specific */ 286 int driver_type; 287 int playback_streams; 288 int playback_index_offset; 289 int capture_streams; 290 int capture_index_offset; 291 int num_streams; 256 292 257 293 /* pci resources */ … … 264 300 struct semaphore open_mutex; 265 301 266 /* streams */267 azx_dev_t azx_dev[MAX_ICH6_DEV];302 /* streams (x num_streams) */ 303 struct azx_dev *azx_dev; 268 304 269 305 /* PCM */ 270 306 unsigned int pcm_devs; 271 s nd_pcm_t*pcm[AZX_MAX_PCMS];307 struct snd_pcm *pcm[AZX_MAX_PCMS]; 272 308 273 309 /* HD codec */ … … 276 312 277 313 /* CORB/RIRB */ 278 azx_rb_tcorb;279 azx_rb_trirb;314 struct azx_rb corb; 315 struct azx_rb rirb; 280 316 281 317 /* BDL, CORB/RIRB and position buffers */ 282 318 struct snd_dma_buffer bdl; 283 319 struct snd_dma_buffer rb; 284 struct snd_dma_buffer posbuf; 285 286 /* flags */ 287 int position_fix; 320 struct snd_dma_buffer posbuf; 321 322 /* flags */ 323 int position_fix; 324 unsigned int initialized: 1; 325 unsigned int single_cmd: 1; 288 326 }; 289 327 328 /* driver types */ 329 enum { 330 AZX_DRIVER_ICH, 331 AZX_DRIVER_ATI, 332 AZX_DRIVER_VIA, 333 AZX_DRIVER_SIS, 334 AZX_DRIVER_ULI, 335 AZX_DRIVER_NVIDIA, 336 }; 337 338 static char *driver_short_names[] __devinitdata = { 339 [AZX_DRIVER_ICH] = "HDA Intel", 340 [AZX_DRIVER_ATI] = "HDA ATI SB", 341 [AZX_DRIVER_VIA] = "HDA VIA VT82xx", 342 [AZX_DRIVER_SIS] = "HDA SIS966", 343 [AZX_DRIVER_ULI] = "HDA ULI M5461", 344 [AZX_DRIVER_NVIDIA] = "HDA NVidia", 345 }; 346 290 347 /* 291 348 * macros for easy use 292 349 */ 293 350 #define azx_writel(chip,reg,value) \ 294 writel(value, (ch ar*)(chip)->remap_addr + ICH6_REG_##reg)351 writel(value, (chip)->remap_addr + ICH6_REG_##reg) 295 352 #define azx_readl(chip,reg) \ 296 readl((ch ar*)(chip)->remap_addr + ICH6_REG_##reg)353 readl((chip)->remap_addr + ICH6_REG_##reg) 297 354 #define azx_writew(chip,reg,value) \ 298 writew(value, (ch ar*)(chip)->remap_addr + ICH6_REG_##reg)355 writew(value, (chip)->remap_addr + ICH6_REG_##reg) 299 356 #define azx_readw(chip,reg) \ 300 readw((ch ar*)(chip)->remap_addr + ICH6_REG_##reg)357 readw((chip)->remap_addr + ICH6_REG_##reg) 301 358 #define azx_writeb(chip,reg,value) \ 302 writeb(value, (ch ar*)(chip)->remap_addr + ICH6_REG_##reg)359 writeb(value, (chip)->remap_addr + ICH6_REG_##reg) 303 360 #define azx_readb(chip,reg) \ 304 readb((ch ar*)(chip)->remap_addr + ICH6_REG_##reg)361 readb((chip)->remap_addr + ICH6_REG_##reg) 305 362 306 363 #define azx_sd_writel(dev,reg,value) \ 307 writel(value, ( char*)(dev)->sd_addr + ICH6_REG_##reg)364 writel(value, (dev)->sd_addr + ICH6_REG_##reg) 308 365 #define azx_sd_readl(dev,reg) \ 309 readl(( char*)(dev)->sd_addr + ICH6_REG_##reg)366 readl((dev)->sd_addr + ICH6_REG_##reg) 310 367 #define azx_sd_writew(dev,reg,value) \ 311 writew(value, ( char*)(dev)->sd_addr + ICH6_REG_##reg)368 writew(value, (dev)->sd_addr + ICH6_REG_##reg) 312 369 #define azx_sd_readw(dev,reg) \ 313 readw(( char*)(dev)->sd_addr + ICH6_REG_##reg)370 readw((dev)->sd_addr + ICH6_REG_##reg) 314 371 #define azx_sd_writeb(dev,reg,value) \ 315 writeb(value, ( char*)(dev)->sd_addr + ICH6_REG_##reg)372 writeb(value, (dev)->sd_addr + ICH6_REG_##reg) 316 373 #define azx_sd_readb(dev,reg) \ 317 readb(( char*)(dev)->sd_addr + ICH6_REG_##reg)374 readb((dev)->sd_addr + ICH6_REG_##reg) 318 375 319 376 /* for pcm support */ 320 #define get_azx_dev(substream) ( azx_dev_t*)(substream->runtime->private_data)377 #define get_azx_dev(substream) (substream->runtime->private_data) 321 378 322 379 /* Get the upper 32bit of the given dma_addr_t … … 330 387 */ 331 388 332 #ifdef USE_CORB_RIRB333 389 /* 334 390 * CORB / RIRB interface 335 391 */ 336 static int azx_alloc_cmd_io( azx_t*chip)392 static int azx_alloc_cmd_io(struct azx *chip) 337 393 { 338 394 int err; … … 348 404 } 349 405 350 static void azx_init_cmd_io( azx_t*chip)406 static void azx_init_cmd_io(struct azx *chip) 351 407 { 352 408 /* CORB set up */ … … 356 412 azx_writel(chip, CORBUBASE, upper_32bit(chip->corb.addr)); 357 413 414 /* set the corb size to 256 entries (ULI requires explicitly) */ 415 azx_writeb(chip, CORBSIZE, 0x02); 358 416 /* set the corb write pointer to 0 */ 359 417 azx_writew(chip, CORBWP, 0); … … 369 427 azx_writel(chip, RIRBUBASE, upper_32bit(chip->rirb.addr)); 370 428 429 /* set the rirb size to 256 entries (ULI requires explicitly) */ 430 azx_writeb(chip, RIRBSIZE, 0x02); 371 431 /* reset the rirb hw write pointer */ 372 432 azx_writew(chip, RIRBWP, ICH6_RBRWP_CLR); … … 374 434 azx_writew(chip, RINTCNT, 1); 375 435 /* enable rirb dma and response irq */ 376 #ifdef USE_CORB_RIRB377 436 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); 378 #else379 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN);380 #endif381 437 chip->rirb.rp = chip->rirb.cmds = 0; 382 438 } 383 439 384 static void azx_free_cmd_io( azx_t*chip)440 static void azx_free_cmd_io(struct azx *chip) 385 441 { 386 442 /* disable ringbuffer DMAs */ … … 393 449 unsigned int verb, unsigned int para) 394 450 { 395 azx_t*chip = codec->bus->private_data;451 struct azx *chip = codec->bus->private_data; 396 452 unsigned int wp; 397 453 u32 val; … … 420 476 421 477 /* retrieve RIRB entry - called from interrupt handler */ 422 static void azx_update_rirb( azx_t*chip)478 static void azx_update_rirb(struct azx *chip) 423 479 { 424 480 unsigned int rp, wp; … … 429 485 return; 430 486 chip->rirb.wp = wp; 431 487 432 488 while (chip->rirb.rp != wp) { 433 489 chip->rirb.rp++; … … 449 505 static unsigned int azx_get_response(struct hda_codec *codec) 450 506 { 451 azx_t*chip = codec->bus->private_data;507 struct azx *chip = codec->bus->private_data; 452 508 int timeout = 50; 453 509 454 510 while (chip->rirb.cmds) { 455 511 if (! --timeout) { 456 snd_printk(KERN_ERR "azx_get_response timeout\n"); 512 if (printk_ratelimit()) 513 snd_printk(KERN_ERR 514 "azx_get_response timeout\n"); 457 515 chip->rirb.rp = azx_readb(chip, RIRBWP); 458 516 chip->rirb.cmds = 0; … … 464 522 } 465 523 466 #else467 524 /* 468 525 * Use the single immediate command instead of CORB/RIRB for simplicity … … 475 532 */ 476 533 477 #define azx_alloc_cmd_io(chip) 0478 #define azx_init_cmd_io(chip)479 #define azx_free_cmd_io(chip)480 481 534 /* send a command */ 482 static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, 483 unsigned int verb, unsigned int para) 484 { 485 azx_t *chip = codec->bus->private_data; 535 static int azx_single_send_cmd(struct hda_codec *codec, hda_nid_t nid, 536 int direct, unsigned int verb, 537 unsigned int para) 538 { 539 struct azx *chip = codec->bus->private_data; 486 540 u32 val; 487 541 int timeout = 50; … … 509 563 510 564 /* receive a response */ 511 static unsigned int azx_ get_response(struct hda_codec *codec)512 { 513 azx_t*chip = codec->bus->private_data;565 static unsigned int azx_single_get_response(struct hda_codec *codec) 566 { 567 struct azx *chip = codec->bus->private_data; 514 568 int timeout = 50; 515 569 … … 524 578 } 525 579 526 #define azx_update_rirb(chip)527 528 #endif /* USE_CORB_RIRB */529 530 580 /* reset codec link */ 531 static int azx_reset( azx_t*chip)581 static int azx_reset(struct azx *chip) 532 582 { 533 583 int count; … … 561 611 } 562 612 613 /* Accept unsolicited responses */ 614 azx_writel(chip, GCTL, azx_readl(chip, GCTL) | ICH6_GCTL_UREN); 615 563 616 /* detect codecs */ 564 617 if (! chip->codec_mask) { … … 573 626 /* 574 627 * Lowlevel interface 575 */ 628 */ 576 629 577 630 /* enable interrupts */ 578 static void azx_int_enable( azx_t*chip)631 static void azx_int_enable(struct azx *chip) 579 632 { 580 633 /* enable controller CIE and GIE */ … … 584 637 585 638 /* disable interrupts */ 586 static void azx_int_disable( azx_t*chip)639 static void azx_int_disable(struct azx *chip) 587 640 { 588 641 int i; 589 642 590 643 /* disable interrupts in stream descriptor */ 591 for (i = 0; i < MAX_ICH6_DEV; i++) {592 azx_dev_t*azx_dev = &chip->azx_dev[i];644 for (i = 0; i < chip->num_streams; i++) { 645 struct azx_dev *azx_dev = &chip->azx_dev[i]; 593 646 azx_sd_writeb(azx_dev, SD_CTL, 594 647 azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK); … … 604 657 605 658 /* clear interrupts */ 606 static void azx_int_clear( azx_t*chip)659 static void azx_int_clear(struct azx *chip) 607 660 { 608 661 int i; 609 662 610 663 /* clear stream status */ 611 for (i = 0; i < MAX_ICH6_DEV; i++) {612 azx_dev_t*azx_dev = &chip->azx_dev[i];664 for (i = 0; i < chip->num_streams; i++) { 665 struct azx_dev *azx_dev = &chip->azx_dev[i]; 613 666 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 614 667 } … … 625 678 626 679 /* start a stream */ 627 static void azx_stream_start( azx_t *chip, azx_dev_t*azx_dev)680 static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev) 628 681 { 629 682 /* enable SIE */ … … 636 689 637 690 /* stop a stream */ 638 static void azx_stream_stop( azx_t *chip, azx_dev_t*azx_dev)691 static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) 639 692 { 640 693 /* stop DMA */ … … 651 704 * initialize the chip 652 705 */ 653 static void azx_init_chip(azx_t *chip) 654 { 655 unsigned char tcsel_reg, ati_misc_cntl2; 656 657 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 658 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 659 * Ensuring these bits are 0 clears playback static on some HD Audio codecs 660 */ 661 pci_read_config_byte (chip->pci, ICH6_PCIREG_TCSEL, &tcsel_reg); 662 pci_write_config_byte(chip->pci, ICH6_PCIREG_TCSEL, tcsel_reg & 0xf8); 663 664 /* reset controller */ 665 azx_reset(chip); 666 667 /* initialize interrupts */ 668 azx_int_clear(chip); 669 azx_int_enable(chip); 670 671 /* initialize the codec command I/O */ 672 azx_init_cmd_io(chip); 673 674 if (chip->position_fix == POS_FIX_POSBUF) { 675 /* program the position buffer */ 676 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); 677 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); 678 } 679 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 680 if (chip->pci->vendor == PCI_VENDOR_ID_ATI && 681 chip->pci->device == ATI_SB450_HDAUDIO_PCI_DEVICE_ID) { 682 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 683 &ati_misc_cntl2); 684 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 685 (ati_misc_cntl2 & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP); 686 } 706 static void azx_init_chip(struct azx *chip) 707 { 708 unsigned char reg; 709 710 /* Clear bits 0-2 of PCI register TCSEL (at offset 0x44) 711 * TCSEL == Traffic Class Select Register, which sets PCI express QOS 712 * Ensuring these bits are 0 clears playback static on some HD Audio codecs 713 */ 714 pci_read_config_byte (chip->pci, ICH6_PCIREG_TCSEL, ®); 715 pci_write_config_byte(chip->pci, ICH6_PCIREG_TCSEL, reg & 0xf8); 716 717 /* reset controller */ 718 azx_reset(chip); 719 720 /* initialize interrupts */ 721 azx_int_clear(chip); 722 azx_int_enable(chip); 723 724 /* initialize the codec command I/O */ 725 if (! chip->single_cmd) 726 azx_init_cmd_io(chip); 727 728 /* program the position buffer */ 729 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr); 730 azx_writel(chip, DPUBASE, upper_32bit(chip->posbuf.addr)); 731 732 switch (chip->driver_type) { 733 case AZX_DRIVER_ATI: 734 /* For ATI SB450 azalia HD audio, we need to enable snoop */ 735 pci_read_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 736 ®); 737 pci_write_config_byte(chip->pci, ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR, 738 (reg & 0xf8) | ATI_SB450_HDAUDIO_ENABLE_SNOOP); 739 break; 740 case AZX_DRIVER_NVIDIA: 741 /* For NVIDIA HDA, enable snoop */ 742 pci_read_config_byte(chip->pci,NVIDIA_HDA_TRANSREG_ADDR, ®); 743 pci_write_config_byte(chip->pci,NVIDIA_HDA_TRANSREG_ADDR, 744 (reg & 0xf0) | NVIDIA_HDA_ENABLE_COHBITS); 745 break; 746 } 687 747 } 688 748 … … 693 753 static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) 694 754 { 695 azx_t*chip = dev_id;696 azx_dev_t*azx_dev;755 struct azx *chip = dev_id; 756 struct azx_dev *azx_dev; 697 757 u32 status; 698 758 int i; … … 705 765 return IRQ_NONE; 706 766 } 707 708 for (i = 0; i < MAX_ICH6_DEV; i++) {767 768 for (i = 0; i < chip->num_streams; i++) { 709 769 azx_dev = &chip->azx_dev[i]; 710 770 if (status & azx_dev->sd_int_sta_mask) { 711 771 azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); 712 772 if (azx_dev->substream && azx_dev->running) { 773 azx_dev->period_updating = 1; 713 774 spin_unlock(&chip->reg_lock); 714 775 snd_pcm_period_elapsed(azx_dev->substream); 715 776 spin_lock(&chip->reg_lock); 777 azx_dev->period_updating = 0; 716 778 } 717 779 } … … 721 783 status = azx_readb(chip, RIRBSTS); 722 784 if (status & RIRB_INT_MASK) { 723 if ( status & RIRB_INT_RESPONSE)785 if (! chip->single_cmd && (status & RIRB_INT_RESPONSE)) 724 786 azx_update_rirb(chip); 725 787 azx_writeb(chip, RIRBSTS, RIRB_INT_MASK); … … 732 794 #endif 733 795 spin_unlock(&chip->reg_lock); 734 796 735 797 return IRQ_HANDLED; 736 798 } … … 740 802 * set up BDL entries 741 803 */ 742 static void azx_setup_periods( azx_dev_t*azx_dev)804 static void azx_setup_periods(struct azx_dev *azx_dev) 743 805 { 744 806 u32 *bdl = azx_dev->bdl; … … 769 831 * set up the SD for streaming 770 832 */ 771 static int azx_setup_controller( azx_t *chip, azx_dev_t*azx_dev)833 static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev) 772 834 { 773 835 unsigned char val; … … 814 876 azx_sd_writel(azx_dev, SD_BDLPU, upper_32bit(azx_dev->bdl_addr)); 815 877 816 if (chip->position_fix == POS_FIX_POSBUF) { 817 /* enable the position buffer */ 818 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 819 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); 820 } 821 822 /* set the interrupt enable bits in the descriptor control register */ 878 /* enable the position buffer */ 879 if (! (azx_readl(chip, DPLBASE) & ICH6_DPLBASE_ENABLE)) 880 azx_writel(chip, DPLBASE, (u32)chip->posbuf.addr | ICH6_DPLBASE_ENABLE); 881 882 /* set the interrupt enable bits in the descriptor control register */ 823 883 azx_sd_writel(azx_dev, SD_CTL, azx_sd_readl(azx_dev, SD_CTL) | SD_INT_MASK); 824 884 … … 831 891 */ 832 892 833 static int __devinit azx_codec_create( azx_t*chip, const char *model)893 static int __devinit azx_codec_create(struct azx *chip, const char *model) 834 894 { 835 895 struct hda_bus_template bus_temp; … … 840 900 bus_temp.modelname = model; 841 901 bus_temp.pci = chip->pci; 842 bus_temp.ops.command = azx_send_cmd; 843 bus_temp.ops.get_response = azx_get_response; 902 if (chip->single_cmd) { 903 bus_temp.ops.command = azx_single_send_cmd; 904 bus_temp.ops.get_response = azx_single_get_response; 905 } else { 906 bus_temp.ops.command = azx_send_cmd; 907 bus_temp.ops.get_response = azx_get_response; 908 } 844 909 845 910 if ((err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus)) < 0) … … 848 913 codecs = 0; 849 914 for (c = 0; c < AZX_MAX_CODECS; c++) { 850 if ( chip->codec_mask & (1 << c)) {915 if ((chip->codec_mask & (1 << c)) & probe_mask) { 851 916 err = snd_hda_codec_new(chip->bus, c, NULL); 852 917 if (err < 0) … … 869 934 870 935 /* assign a stream for the PCM */ 871 static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream) 872 { 873 int dev, i; 874 dev = stream == SNDRV_PCM_STREAM_PLAYBACK ? 4 : 0; 875 for (i = 0; i < 4; i++, dev++) 936 static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream) 937 { 938 int dev, i, nums; 939 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 940 dev = chip->playback_index_offset; 941 nums = chip->playback_streams; 942 } else { 943 dev = chip->capture_index_offset; 944 nums = chip->capture_streams; 945 } 946 for (i = 0; i < nums; i++, dev++) 876 947 if (! chip->azx_dev[dev].opened) { 877 948 chip->azx_dev[dev].opened = 1; … … 882 953 883 954 /* release the assigned stream */ 884 static inline void azx_release_device( azx_dev_t*azx_dev)955 static inline void azx_release_device(struct azx_dev *azx_dev) 885 956 { 886 957 azx_dev->opened = 0; 887 958 } 888 959 889 static s nd_pcm_hardware_tazx_pcm_hw = {890 /*.info = */(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |960 static struct snd_pcm_hardware azx_pcm_hw = { 961 .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | 891 962 SNDRV_PCM_INFO_BLOCK_TRANSFER | 892 963 SNDRV_PCM_INFO_MMAP_VALID | 893 SNDRV_PCM_INFO_PAUSE |894 SNDRV_PCM_INFO_RESUME),895 /*.formats = */SNDRV_PCM_FMTBIT_S16_LE,896 /*.rates = */SNDRV_PCM_RATE_48000,897 /*.rate_min = */48000,898 /*.rate_max = */48000,899 /*.channels_min = */2,900 /*.channels_max = */2,901 /*.buffer_bytes_max = */AZX_MAX_BUF_SIZE,902 /*.period_bytes_min = */128,903 /*.period_bytes_max = */AZX_MAX_BUF_SIZE / 2,904 /*.periods_min = */2,905 /*.periods_max = */AZX_MAX_FRAG,906 /*.fifo_size = */0,964 SNDRV_PCM_INFO_PAUSE /*|*/ 965 /*SNDRV_PCM_INFO_RESUME*/), 966 .formats = SNDRV_PCM_FMTBIT_S16_LE, 967 .rates = SNDRV_PCM_RATE_48000, 968 .rate_min = 48000, 969 .rate_max = 48000, 970 .channels_min = 2, 971 .channels_max = 2, 972 .buffer_bytes_max = AZX_MAX_BUF_SIZE, 973 .period_bytes_min = 128, 974 .period_bytes_max = AZX_MAX_BUF_SIZE / 2, 975 .periods_min = 2, 976 .periods_max = AZX_MAX_FRAG, 977 .fifo_size = 0, 907 978 }; 908 979 909 980 struct azx_pcm { 910 azx_t*chip;981 struct azx *chip; 911 982 struct hda_codec *codec; 912 983 struct hda_pcm_stream *hinfo[2]; 913 984 }; 914 985 915 static int azx_pcm_open(s nd_pcm_substream_t*substream)986 static int azx_pcm_open(struct snd_pcm_substream *substream) 916 987 { 917 988 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 918 989 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 919 azx_t*chip = apcm->chip;920 azx_dev_t*azx_dev;921 s nd_pcm_runtime_t*runtime = substream->runtime;990 struct azx *chip = apcm->chip; 991 struct azx_dev *azx_dev; 992 struct snd_pcm_runtime *runtime = substream->runtime; 922 993 unsigned long flags; 923 994 int err; … … 951 1022 } 952 1023 953 static int azx_pcm_close(s nd_pcm_substream_t*substream)1024 static int azx_pcm_close(struct snd_pcm_substream *substream) 954 1025 { 955 1026 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 956 1027 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 957 azx_t*chip = apcm->chip;958 azx_dev_t*azx_dev = get_azx_dev(substream);1028 struct azx *chip = apcm->chip; 1029 struct azx_dev *azx_dev = get_azx_dev(substream); 959 1030 unsigned long flags; 960 1031 … … 970 1041 } 971 1042 972 static int azx_pcm_hw_params(s nd_pcm_substream_t *substream, snd_pcm_hw_params_t*hw_params)1043 static int azx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) 973 1044 { 974 1045 return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); 975 1046 } 976 1047 977 static int azx_pcm_hw_free(s nd_pcm_substream_t*substream)1048 static int azx_pcm_hw_free(struct snd_pcm_substream *substream) 978 1049 { 979 1050 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 980 azx_dev_t*azx_dev = get_azx_dev(substream);1051 struct azx_dev *azx_dev = get_azx_dev(substream); 981 1052 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 982 1053 … … 991 1062 } 992 1063 993 static int azx_pcm_prepare(s nd_pcm_substream_t*substream)1064 static int azx_pcm_prepare(struct snd_pcm_substream *substream) 994 1065 { 995 1066 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 996 azx_t*chip = apcm->chip;997 azx_dev_t*azx_dev = get_azx_dev(substream);1067 struct azx *chip = apcm->chip; 1068 struct azx_dev *azx_dev = get_azx_dev(substream); 998 1069 struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; 999 s nd_pcm_runtime_t*runtime = substream->runtime;1070 struct snd_pcm_runtime *runtime = substream->runtime; 1000 1071 1001 1072 azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); … … 1020 1091 else 1021 1092 azx_dev->fifo_size = 0; 1093 azx_dev->last_pos = 0; 1022 1094 1023 1095 return hinfo->ops.prepare(hinfo, apcm->codec, azx_dev->stream_tag, … … 1025 1097 } 1026 1098 1027 static int azx_pcm_trigger(s nd_pcm_substream_t*substream, int cmd)1099 static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 1028 1100 { 1029 1101 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1030 azx_dev_t*azx_dev = get_azx_dev(substream);1031 azx_t*chip = apcm->chip;1102 struct azx_dev *azx_dev = get_azx_dev(substream); 1103 struct azx *chip = apcm->chip; 1032 1104 int err = 0; 1033 1105 … … 1041 1113 break; 1042 1114 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 1115 case SNDRV_PCM_TRIGGER_SUSPEND: 1043 1116 case SNDRV_PCM_TRIGGER_STOP: 1044 1117 azx_stream_stop(chip, azx_dev); … … 1050 1123 spin_unlock(&chip->reg_lock); 1051 1124 if (cmd == SNDRV_PCM_TRIGGER_PAUSE_PUSH || 1125 cmd == SNDRV_PCM_TRIGGER_SUSPEND || 1052 1126 cmd == SNDRV_PCM_TRIGGER_STOP) { 1053 1127 int timeout = 5000; … … 1058 1132 } 1059 1133 1060 static snd_pcm_uframes_t azx_pcm_pointer(s nd_pcm_substream_t*substream)1061 { 1062 struct azx_pcm *apcm = snd_pcm_substream_chip(substream);1063 azx_t*chip = apcm->chip;1064 azx_dev_t*azx_dev = get_azx_dev(substream);1065 unsigned int pos;1066 1067 if (chip->position_fix == POS_FIX_POSBUF) {1068 /* use the position buffer */1069 pos = *azx_dev->posbuf;1070 } else {1071 /* read LPIB */1072 pos = azx_sd_readl(azx_dev, SD_LPIB);1073 if (chip->position_fix == POS_FIX_FIFO)1074 pos += azx_dev->fifo_size;1075 }1076 if (pos >= azx_dev->bufsize)1077 pos = 0;1078 return bytes_to_frames(substream->runtime, pos);1079 } 1080 1081 static s nd_pcm_ops_tazx_pcm_ops = {1082 /*.open = */azx_pcm_open,1083 /*.close = */azx_pcm_close,1084 /*.ioctl = */snd_pcm_lib_ioctl,1085 /*.hw_params = */azx_pcm_hw_params,1086 /*.hw_free = */azx_pcm_hw_free,1087 /*.prepare = */azx_pcm_prepare,1088 /*.trigger = */azx_pcm_trigger,1089 /*.pointer = */azx_pcm_pointer,0,0,0,01134 static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) 1135 { 1136 struct azx_pcm *apcm = snd_pcm_substream_chip(substream); 1137 struct azx *chip = apcm->chip; 1138 struct azx_dev *azx_dev = get_azx_dev(substream); 1139 unsigned int pos; 1140 1141 if (chip->position_fix == POS_FIX_POSBUF) { 1142 /* use the position buffer */ 1143 pos = *azx_dev->posbuf; 1144 } else { 1145 /* read LPIB */ 1146 pos = azx_sd_readl(azx_dev, SD_LPIB); 1147 if (chip->position_fix == POS_FIX_FIFO) 1148 pos += azx_dev->fifo_size; 1149 } 1150 if (pos >= azx_dev->bufsize) 1151 pos = 0; 1152 return bytes_to_frames(substream->runtime, pos); 1153 } 1154 1155 static struct snd_pcm_ops azx_pcm_ops = { 1156 .open = azx_pcm_open, 1157 .close = azx_pcm_close, 1158 .ioctl = snd_pcm_lib_ioctl, 1159 .hw_params = azx_pcm_hw_params, 1160 .hw_free = azx_pcm_hw_free, 1161 .prepare = azx_pcm_prepare, 1162 .trigger = azx_pcm_trigger, 1163 .pointer = azx_pcm_pointer, 1090 1164 }; 1091 1165 1092 static void azx_pcm_free(s nd_pcm_t*pcm)1166 static void azx_pcm_free(struct snd_pcm *pcm) 1093 1167 { 1094 1168 kfree(pcm->private_data); 1095 1169 } 1096 1170 1097 static int __devinit create_codec_pcm( azx_t*chip, struct hda_codec *codec,1171 static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec, 1098 1172 struct hda_pcm *cpcm, int pcm_dev) 1099 1173 { 1100 1174 int err; 1101 s nd_pcm_t*pcm;1175 struct snd_pcm *pcm; 1102 1176 struct azx_pcm *apcm; 1103 1177 … … 1128 1202 1024 * 64, 1024 * 128); 1129 1203 chip->pcm[pcm_dev] = pcm; 1204 chip->pcm_devs = pcm_dev + 1; 1130 1205 1131 1206 return 0; 1132 1207 } 1133 1208 1134 static int __devinit azx_pcm_create( azx_t*chip)1209 static int __devinit azx_pcm_create(struct azx *chip) 1135 1210 { 1136 1211 struct list_head *p; … … 1142 1217 return err; 1143 1218 1219 /* create audio PCMs */ 1144 1220 pcm_dev = 0; 1145 1221 list_for_each(p, &chip->bus->codec_list) { 1146 1222 codec = list_entry(p, struct hda_codec, list); 1147 1223 for (c = 0; c < codec->num_pcms; c++) { 1148 if (pcm_dev >= AZX_MAX_PCMS) { 1149 snd_printk(KERN_ERR SFX "Too many PCMs\n"); 1224 if (codec->pcm_info[c].is_modem) 1225 continue; /* create later */ 1226 if (pcm_dev >= AZX_MAX_AUDIO_PCMS) { 1227 snd_printk(KERN_ERR SFX "Too many audio PCMs\n"); 1150 1228 return -EINVAL; 1151 1229 } … … 1156 1234 } 1157 1235 } 1236 1237 /* create modem PCMs */ 1238 pcm_dev = AZX_MAX_AUDIO_PCMS; 1239 list_for_each(p, &chip->bus->codec_list) { 1240 codec = list_entry(p, struct hda_codec, list); 1241 for (c = 0; c < codec->num_pcms; c++) { 1242 if (! codec->pcm_info[c].is_modem) 1243 continue; /* already created */ 1244 if (pcm_dev >= AZX_MAX_PCMS) { 1245 snd_printk(KERN_ERR SFX "Too many modem PCMs\n"); 1246 return -EINVAL; 1247 } 1248 err = create_codec_pcm(chip, codec, &codec->pcm_info[c], pcm_dev); 1249 if (err < 0) 1250 return err; 1251 chip->pcm[pcm_dev]->dev_class = SNDRV_PCM_CLASS_MODEM; 1252 pcm_dev++; 1253 } 1254 } 1158 1255 return 0; 1159 1256 } … … 1162 1259 * mixer creation - all stuff is implemented in hda module 1163 1260 */ 1164 static int __devinit azx_mixer_create( azx_t*chip)1261 static int __devinit azx_mixer_create(struct azx *chip) 1165 1262 { 1166 1263 return snd_hda_build_controls(chip->bus); … … 1171 1268 * initialize SD streams 1172 1269 */ 1173 static int __devinit azx_init_stream( azx_t*chip)1270 static int __devinit azx_init_stream(struct azx *chip) 1174 1271 { 1175 1272 int i; … … 1178 1275 * assign the starting bdl address to each stream (device) and initialize 1179 1276 */ 1180 for (i = 0; i < MAX_ICH6_DEV; i++) {1277 for (i = 0; i < chip->num_streams; i++) { 1181 1278 unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4); 1182 azx_dev_t*azx_dev = &chip->azx_dev[i];1279 struct azx_dev *azx_dev = &chip->azx_dev[i]; 1183 1280 azx_dev->bdl = (u32 *)(chip->bdl.area + off); 1184 azx_dev->bdl_addr = chip->bdl.addr + off; 1185 if (chip->position_fix == POS_FIX_POSBUF) 1186 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); 1281 azx_dev->bdl_addr = chip->bdl.addr + off; 1282 azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); 1187 1283 /* offset: SDI0=0x80, SDI1=0xa0, ... SDO3=0x160 */ 1188 azx_dev->sd_addr = (char*)chip->remap_addr + (0x20 * i + 0x80);1284 azx_dev->sd_addr = chip->remap_addr + (0x20 * i + 0x80); 1189 1285 /* int mask: SDI0=0x01, SDI1=0x02, ... SDO3=0x80 */ 1190 1286 azx_dev->sd_int_sta_mask = 1 << i; … … 1202 1298 * power management 1203 1299 */ 1204 static int azx_suspend(snd_card_t *card, unsigned int state) 1205 { 1206 azx_t *chip = card->pm_private_data; 1300 static int azx_suspend(struct pci_dev *pci, pm_message_t state) 1301 { 1302 struct snd_card *card = pci_get_drvdata(pci); 1303 struct azx *chip = card->private_data; 1207 1304 int i; 1208 1305 1306 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 1209 1307 for (i = 0; i < chip->pcm_devs; i++) 1210 if (chip->pcm[i]) 1211 snd_pcm_suspend_all(chip->pcm[i]); 1308 snd_pcm_suspend_all(chip->pcm[i]); 1212 1309 snd_hda_suspend(chip->bus, state); 1213 azx_free_cmd_io(chip); 1214 pci_disable_device(chip->pci); 1310 if (! chip->single_cmd) 1311 azx_free_cmd_io(chip); 1312 pci_disable_device(pci); 1313 pci_save_state(pci); 1215 1314 return 0; 1216 1315 } 1217 1316 1218 static int azx_resume(snd_card_t *card, unsigned int state) 1219 { 1220 azx_t *chip = card->pm_private_data; 1221 1222 pci_enable_device(chip->pci); 1223 pci_set_master(chip->pci); 1317 static int azx_resume(struct pci_dev *pci) 1318 { 1319 struct snd_card *card = pci_get_drvdata(pci); 1320 struct azx *chip = card->private_data; 1321 1322 pci_restore_state(pci); 1323 pci_enable_device(pci); 1324 pci_set_master(pci); 1224 1325 azx_init_chip(chip); 1225 snd_hda_resume(chip->bus, state); 1326 snd_hda_resume(chip->bus); 1327 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 1226 1328 return 0; 1227 1329 } … … 1232 1334 * destructor 1233 1335 */ 1234 static int azx_free( azx_t*chip)1235 { 1236 if (chip-> remap_addr) {1336 static int azx_free(struct azx *chip) 1337 { 1338 if (chip->initialized) { 1237 1339 int i; 1238 1340 1239 for (i = 0; i < MAX_ICH6_DEV; i++)1341 for (i = 0; i < chip->num_streams; i++) 1240 1342 azx_stream_stop(chip, &chip->azx_dev[i]); 1241 1343 … … 1245 1347 1246 1348 /* disable CORB/RIRB */ 1247 azx_free_cmd_io(chip); 1349 if (! chip->single_cmd) 1350 azx_free_cmd_io(chip); 1248 1351 1249 1352 /* disable position buffer */ … … 1253 1356 /* wait a little for interrupts to finish */ 1254 1357 msleep(1); 1255 1358 } 1359 1360 if (chip->remap_addr) 1256 1361 iounmap(chip->remap_addr); 1257 }1258 1259 1362 if (chip->irq >= 0) 1260 1363 free_irq(chip->irq, (void*)chip); … … 1268 1371 pci_release_regions(chip->pci); 1269 1372 pci_disable_device(chip->pci); 1373 kfree(chip->azx_dev); 1270 1374 kfree(chip); 1271 1375 … … 1273 1377 } 1274 1378 1275 static int azx_dev_free(s nd_device_t*device)1379 static int azx_dev_free(struct snd_device *device) 1276 1380 { 1277 1381 return azx_free(device->device_data); … … 1281 1385 * constructor 1282 1386 */ 1283 static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, 1284 int posfix, azx_t **rchip) 1285 { 1286 azx_t *chip; 1387 static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, 1388 int driver_type, 1389 struct azx **rchip) 1390 { 1391 struct azx *chip; 1287 1392 int err = 0; 1288 static s nd_device_ops_tops = {1289 /*.dev_free = */azx_dev_free,0,0,01393 static struct snd_device_ops ops = { 1394 .dev_free = azx_dev_free, 1290 1395 }; 1291 1396 1292 1397 *rchip = NULL; 1293 1398 1294 1399 if ((err = pci_enable_device(pci)) < 0) 1295 1400 return err; 1296 1401 1297 chip = k calloc(1,sizeof(*chip), GFP_KERNEL);1298 1402 chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1403 1299 1404 if (NULL == chip) { 1300 1405 snd_printk(KERN_ERR SFX "cannot allocate chip\n"); … … 1308 1413 chip->pci = pci; 1309 1414 chip->irq = -1; 1310 1311 chip->position_fix = posfix; 1415 chip->driver_type = driver_type; 1416 1417 chip->position_fix = position_fix ? position_fix : POS_FIX_POSBUF; 1418 chip->single_cmd = single_cmd; 1419 1420 #if BITS_PER_LONG != 64 1421 /* Fix up base address on ULI M5461 */ 1422 if (chip->driver_type == AZX_DRIVER_ULI) { 1423 u16 tmp3; 1424 pci_read_config_word(pci, 0x40, &tmp3); 1425 pci_write_config_word(pci, 0x40, tmp3 | 0x10); 1426 pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, 0); 1427 } 1428 #endif 1312 1429 1313 1430 if ((err = pci_request_regions(pci, "ICH HD audio")) < 0) { … … 1336 1453 synchronize_irq(chip->irq); 1337 1454 1455 switch (chip->driver_type) { 1456 case AZX_DRIVER_ULI: 1457 chip->playback_streams = ULI_NUM_PLAYBACK; 1458 chip->capture_streams = ULI_NUM_CAPTURE; 1459 chip->playback_index_offset = ULI_PLAYBACK_INDEX; 1460 chip->capture_index_offset = ULI_CAPTURE_INDEX; 1461 break; 1462 default: 1463 chip->playback_streams = ICH6_NUM_PLAYBACK; 1464 chip->capture_streams = ICH6_NUM_CAPTURE; 1465 chip->playback_index_offset = ICH6_PLAYBACK_INDEX; 1466 chip->capture_index_offset = ICH6_CAPTURE_INDEX; 1467 break; 1468 } 1469 chip->num_streams = chip->playback_streams + chip->capture_streams; 1470 chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), GFP_KERNEL); 1471 if (! chip->azx_dev) { 1472 snd_printk(KERN_ERR "cannot malloc azx_dev\n"); 1473 goto errout; 1474 } 1475 1338 1476 /* allocate memory for the BDL for each stream */ 1339 1477 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1340 PAGE_SIZE, &chip->bdl)) < 0) {1478 BDL_SIZE, &chip->bdl)) < 0) { 1341 1479 snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); 1342 1480 goto errout; 1343 } 1344 if (chip->position_fix == POS_FIX_POSBUF) { 1345 /* allocate memory for the position buffer */ 1346 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1347 MAX_ICH6_DEV * 8, &chip->posbuf)) < 0) { 1348 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 1349 goto errout; 1350 } 1351 } 1481 } 1482 /* allocate memory for the position buffer */ 1483 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 1484 chip->num_streams * 8, &chip->posbuf)) < 0) { 1485 snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); 1486 goto errout; 1487 } 1352 1488 /* allocate CORB/RIRB */ 1353 if ((err = azx_alloc_cmd_io(chip)) < 0) 1354 goto errout; 1489 if (! chip->single_cmd) 1490 if ((err = azx_alloc_cmd_io(chip)) < 0) 1491 goto errout; 1355 1492 1356 1493 /* initialize streams */ … … 1359 1496 /* initialize chip */ 1360 1497 azx_init_chip(chip); 1498 1499 chip->initialized = 1; 1361 1500 1362 1501 /* codec detection */ … … 1372 1511 } 1373 1512 1513 strcpy(card->driver, "HDA-Intel"); 1514 strcpy(card->shortname, driver_short_names[chip->driver_type]); 1515 sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq); 1516 1374 1517 *rchip = chip; 1375 1518 return 0; … … 1382 1525 static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) 1383 1526 { 1384 static int dev; 1385 snd_card_t *card; 1386 azx_t *chip; 1527 struct snd_card *card; 1528 struct azx *chip; 1387 1529 int err = 0; 1388 1530 1389 if (dev >= SNDRV_CARDS) 1390 return -ENODEV; 1391 if (! enable[dev]) { 1392 dev++; 1393 return -ENOENT; 1394 } 1395 1396 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 1531 card = snd_card_new(index, id, THIS_MODULE, 0); 1397 1532 if (NULL == card) { 1398 1533 snd_printk(KERN_ERR SFX "Error creating card!\n"); … … 1400 1535 } 1401 1536 1402 if ((err = azx_create(card, pci, position_fix[dev], &chip)) < 0) { 1537 if ((err = azx_create(card, pci, pci_id->driver_data, 1538 &chip)) < 0) { 1403 1539 snd_card_free(card); 1404 1540 return err; 1405 1541 } 1406 1407 strcpy(card->driver, "HDA-Intel"); 1408 strcpy(card->shortname, "HDA Intel"); 1409 sprintf(card->longname, "%s at 0x%lx irq %i", card->shortname, chip->addr, chip->irq); 1542 card->private_data = chip; 1410 1543 1411 1544 /* create codec instances */ 1412 if ((err = azx_codec_create(chip, model [dev])) < 0) {1545 if ((err = azx_codec_create(chip, model)) < 0) { 1413 1546 snd_card_free(card); 1414 1547 return err; … … 1427 1560 } 1428 1561 1429 snd_card_set_pm_callback(card, azx_suspend, azx_resume, chip);1430 1562 snd_card_set_dev(card, &pci->dev); 1431 1563 … … 1436 1568 1437 1569 pci_set_drvdata(pci, card); 1438 dev++;1439 1570 1440 1571 return err; … … 1449 1580 /* PCI IDs */ 1450 1581 static struct pci_device_id azx_ids[] = { 1451 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH6 */ 1452 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ICH7 */ 1453 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ESB2 */ 1454 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* ATI SB450 */ 1455 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* VIA VT8251/VT8237A */ 1582 { 0x8086, 0x2668, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH6 */ 1583 { 0x8086, 0x27d8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH7 */ 1584 { 0x8086, 0x269a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ESB2 */ 1585 { 0x8086, 0x284b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ICH }, /* ICH8 */ 1586 { 0x1002, 0x437b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ATI }, /* ATI SB450 */ 1587 { 0x1106, 0x3288, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_VIA }, /* VIA VT8251/VT8237A */ 1588 { 0x1039, 0x7502, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_SIS }, /* SIS966 */ 1589 { 0x10b9, 0x5461, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_ULI }, /* ULI M5461 */ 1590 { 0x10de, 0x026c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 026c */ 1591 { 0x10de, 0x0371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, AZX_DRIVER_NVIDIA }, /* NVIDIA 0371 */ 1456 1592 { 0, } 1457 1593 }; … … 1460 1596 /* pci_driver definition */ 1461 1597 static struct pci_driver driver = { 1462 0,0,0, 1463 /*.name = */"HDA Intel", 1464 /*.id_table = */azx_ids, 1465 /*.probe = */azx_probe, 1466 /*.remove = */azx_remove, 1467 SND_PCI_PM_CALLBACKS 1598 .name = "HDA Intel", 1599 .id_table = azx_ids, 1600 .probe = azx_probe, 1601 .remove = __devexit_p(azx_remove), 1602 #ifdef CONFIG_PM 1603 .suspend = azx_suspend, 1604 .resume = azx_resume, 1605 #endif 1468 1606 }; 1469 1607 1470 1608 static int __init alsa_card_azx_init(void) 1471 1609 { 1472 return pci_ module_init(&driver);1610 return pci_register_driver(&driver); 1473 1611 } 1474 1612 -
GPL/trunk/alsa-kernel/pci/hda/hda_local.h
r32 r69 27 27 * for mixer controls 28 28 */ 29 #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) ((nid) | ((chs) << 16) | ((dir) << 18) | ((idx) <<19))30 29 #define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19)) 30 /* mono volume with index (index=0,1,...) (channel=1,2) */ 31 31 #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 32 { SNDRV_CTL_ELEM_IFACE_MIXER, 0,0, xname, xcidx, 0,0, \ 33 snd_hda_mixer_amp_volume_info, \ 34 snd_hda_mixer_amp_volume_get, \ 35 snd_hda_mixer_amp_volume_put, \ 36 HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) } 32 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 33 .info = snd_hda_mixer_amp_volume_info, \ 34 .get = snd_hda_mixer_amp_volume_get, \ 35 .put = snd_hda_mixer_amp_volume_put, \ 36 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) } 37 /* stereo volume with index */ 37 38 #define HDA_CODEC_VOLUME_IDX(xname, xcidx, nid, xindex, direction) \ 38 39 HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, 3, xindex, direction) 40 /* mono volume */ 39 41 #define HDA_CODEC_VOLUME_MONO(xname, nid, channel, xindex, direction) \ 40 HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, 3, xindex, direction) 42 HDA_CODEC_VOLUME_MONO_IDX(xname, 0, nid, channel, xindex, direction) 43 /* stereo volume */ 41 44 #define HDA_CODEC_VOLUME(xname, nid, xindex, direction) \ 42 HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction)43 45 HDA_CODEC_VOLUME_MONO(xname, nid, 3, xindex, direction) 46 /* mono mute switch with index (index=0,1,...) (channel=1,2) */ 44 47 #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 45 { SNDRV_CTL_ELEM_IFACE_MIXER,0,0,xname,xcidx,0,0, \46 snd_hda_mixer_amp_switch_info, \47 snd_hda_mixer_amp_switch_get, \48 snd_hda_mixer_amp_switch_put, \49 HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }50 48 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 49 .info = snd_hda_mixer_amp_switch_info, \ 50 .get = snd_hda_mixer_amp_switch_get, \ 51 .put = snd_hda_mixer_amp_switch_put, \ 52 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) } 53 /* stereo mute switch with index */ 51 54 #define HDA_CODEC_MUTE_IDX(xname, xcidx, nid, xindex, direction) \ 52 HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, 3, xindex, direction)53 55 HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, 3, xindex, direction) 56 /* mono mute switch */ 54 57 #define HDA_CODEC_MUTE_MONO(xname, nid, channel, xindex, direction) \ 55 HDA_CODEC_MUTE_MONO_IDX(xname, 0, nid, 3, xindex, direction)56 58 HDA_CODEC_MUTE_MONO_IDX(xname, 0, nid, channel, xindex, direction) 59 /* stereo mute switch */ 57 60 #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \ 58 HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction) 59 60 int snd_hda_mixer_amp_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo); 61 int snd_hda_mixer_amp_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); 62 int snd_hda_mixer_amp_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); 63 int snd_hda_mixer_amp_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo); 64 int snd_hda_mixer_amp_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); 65 int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); 61 HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction) 62 63 int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); 64 int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 65 int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 66 int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); 67 int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 68 int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 69 70 /* mono switch binding multiple inputs */ 71 #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \ 72 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 73 .info = snd_hda_mixer_amp_switch_info, \ 74 .get = snd_hda_mixer_bind_switch_get, \ 75 .put = snd_hda_mixer_bind_switch_put, \ 76 .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) } 77 78 /* stereo switch binding multiple inputs */ 79 #define HDA_BIND_MUTE(xname,nid,indices,dir) HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir) 80 81 int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 82 int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); 66 83 67 84 int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid); … … 71 88 * input MUX helper 72 89 */ 73 #define HDA_MAX_NUM_INPUTS 890 #define HDA_MAX_NUM_INPUTS 16 74 91 struct hda_input_mux_item { 75 92 const char *label; … … 81 98 }; 82 99 83 int snd_hda_input_mux_info(const struct hda_input_mux *imux, s nd_ctl_elem_info_t*uinfo);100 int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo); 84 101 int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, 85 s nd_ctl_elem_value_t*ucontrol, hda_nid_t nid,102 struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, 86 103 unsigned int *cur_val); 104 105 /* 106 * Channel mode helper 107 */ 108 struct hda_channel_mode { 109 int channels; 110 const struct hda_verb *sequence; 111 }; 112 113 int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, 114 const struct hda_channel_mode *chmode, int num_chmodes); 115 int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 116 const struct hda_channel_mode *chmode, int num_chmodes, 117 int max_channels); 118 int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, 119 const struct hda_channel_mode *chmode, int num_chmodes, 120 int *max_channelsp); 87 121 88 122 /* … … 105 139 int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout); 106 140 int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, 107 s nd_pcm_substream_t*substream);141 struct snd_pcm_substream *substream); 108 142 int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, 109 143 unsigned int stream_tag, 110 144 unsigned int format, 111 s nd_pcm_substream_t*substream);145 struct snd_pcm_substream *substream); 112 146 int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout); 113 147 … … 132 166 const char *modelname; 133 167 int config; 134 unsigned short pci_ vendor;135 unsigned short pci_ device;136 }; 137 138 int snd_hda_check_board_config(struct hda_codec *codec, struct hda_board_config *tbl);139 int snd_hda_add_new_ctls(struct hda_codec *codec, s nd_kcontrol_new_t*knew);168 unsigned short pci_subvendor; 169 unsigned short pci_subdevice; 170 }; 171 172 int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl); 173 int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew); 140 174 141 175 /* … … 143 177 */ 144 178 #ifdef CONFIG_PM 145 int snd_hda_resume_ctls(struct hda_codec *codec, s nd_kcontrol_new_t*knew);179 int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew); 146 180 int snd_hda_resume_spdif_out(struct hda_codec *codec); 147 181 int snd_hda_resume_spdif_in(struct hda_codec *codec); … … 164 198 }; 165 199 200 /* 201 * Helper for automatic ping configuration 202 */ 203 204 enum { 205 AUTO_PIN_MIC, 206 AUTO_PIN_FRONT_MIC, 207 AUTO_PIN_LINE, 208 AUTO_PIN_FRONT_LINE, 209 AUTO_PIN_CD, 210 AUTO_PIN_AUX, 211 AUTO_PIN_LAST 212 }; 213 214 extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; 215 216 struct auto_pin_cfg { 217 int line_outs; 218 hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ 219 hda_nid_t speaker_pin; 220 hda_nid_t hp_pin; 221 hda_nid_t input_pins[AUTO_PIN_LAST]; 222 hda_nid_t dig_out_pin; 223 hda_nid_t dig_in_pin; 224 }; 225 226 #define get_defcfg_connect(cfg) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) 227 #define get_defcfg_association(cfg) ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT) 228 #define get_defcfg_location(cfg) ((cfg & AC_DEFCFG_LOCATION) >> AC_DEFCFG_LOCATION_SHIFT) 229 #define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE) 230 #define get_defcfg_device(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) 231 232 int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, 233 hda_nid_t *ignore_nids); 234 235 /* amp values */ 236 #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) 237 #define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) 238 #define AMP_OUT_MUTE 0xb080 239 #define AMP_OUT_UNMUTE 0xb000 240 #define AMP_OUT_ZERO 0xb000 241 /* pinctl values */ 242 #define PIN_IN 0x20 243 #define PIN_VREF80 0x24 244 #define PIN_VREF50 0x21 245 #define PIN_OUT 0x40 246 #define PIN_HP 0xc0 247 #define PIN_HP_AMP 0x80 248 249 /* 250 * get widget capabilities 251 */ 252 static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) 253 { 254 if (nid < codec->start_nid || 255 nid >= codec->start_nid + codec->num_nodes) 256 return snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); 257 return codec->wcaps[nid - codec->start_nid]; 258 } 259 260 166 261 #endif /* __SOUND_HDA_LOCAL_H */ -
GPL/trunk/alsa-kernel/pci/hda/hda_patch.h
r32 r69 11 11 /* SigmaTel codecs */ 12 12 extern struct hda_codec_preset snd_hda_preset_sigmatel[]; 13 /* SiLabs 3054/3055 modem codecs */ 14 extern struct hda_codec_preset snd_hda_preset_si3054[]; 13 15 14 16 static const struct hda_codec_preset *hda_preset_tables[] = { 15 17 snd_hda_preset_realtek, 16 snd_hda_preset_cmedia, 17 snd_hda_preset_analog, 18 snd_hda_preset_sigmatel, 18 snd_hda_preset_cmedia, 19 snd_hda_preset_analog, 20 snd_hda_preset_sigmatel, 21 snd_hda_preset_si3054, 19 22 NULL 20 23 }; -
GPL/trunk/alsa-kernel/pci/hda/hda_proc.c
r32 r69 27 27 #include <sound/core.h> 28 28 #include "hda_codec.h" 29 #include "hda_local.h" 29 30 30 31 static const char *get_wid_type_name(unsigned int wid_value) 31 32 { 32 33 static char *names[16] = { 33 /*[AC_WID_AUD_OUT] = */"Audio Output", 34 /*[AC_WID_AUD_IN] = */"Audio Input", 35 /*[AC_WID_AUD_MIX] = */"Audio Mixer", 36 /*[AC_WID_AUD_SEL] = */"Audio Selector", 37 /*[AC_WID_PIN] = */"Pin Complex", 38 /*[AC_WID_POWER] = */"Power Widget", 39 /*[AC_WID_VOL_KNB] = */"Volume Knob Widget", 40 /*[AC_WID_BEEP] = */"Beep Generator Widget", 41 0,0,0,0,0,0,0, 42 /*[AC_WID_VENDOR] = */"Vendor Defined Widget", 34 [AC_WID_AUD_OUT] = "Audio Output", 35 [AC_WID_AUD_IN] = "Audio Input", 36 [AC_WID_AUD_MIX] = "Audio Mixer", 37 [AC_WID_AUD_SEL] = "Audio Selector", 38 [AC_WID_PIN] = "Pin Complex", 39 [AC_WID_POWER] = "Power Widget", 40 [AC_WID_VOL_KNB] = "Volume Knob Widget", 41 [AC_WID_BEEP] = "Beep Generator Widget", 42 [AC_WID_VENDOR] = "Vendor Defined Widget", 43 43 }; 44 44 wid_value &= 0xf; … … 49 49 } 50 50 51 static void print_amp_caps(s nd_info_buffer_t*buffer,51 static void print_amp_caps(struct snd_info_buffer *buffer, 52 52 struct hda_codec *codec, hda_nid_t nid, int dir) 53 53 { … … 68 68 } 69 69 70 static void print_amp_vals(s nd_info_buffer_t*buffer,70 static void print_amp_vals(struct snd_info_buffer *buffer, 71 71 struct hda_codec *codec, hda_nid_t nid, 72 int dir, int stereo )72 int dir, int stereo, int indices) 73 73 { 74 74 unsigned int val; 75 if (stereo) { 75 int i; 76 77 if (dir == HDA_OUTPUT) 78 dir = AC_AMP_GET_OUTPUT; 79 else 80 dir = AC_AMP_GET_INPUT; 81 for (i = 0; i < indices; i++) { 82 snd_iprintf(buffer, " ["); 83 if (stereo) { 84 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 85 AC_AMP_GET_LEFT | dir | i); 86 snd_iprintf(buffer, "0x%02x ", val); 87 } 76 88 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 77 AC_AMP_GET_LEFT | 78 (dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : 79 AC_AMP_GET_INPUT)); 80 snd_iprintf(buffer, "0x%02x ", val); 81 } 82 val = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_AMP_GAIN_MUTE, 83 AC_AMP_GET_RIGHT | 84 (dir == HDA_OUTPUT ? AC_AMP_GET_OUTPUT : 85 AC_AMP_GET_INPUT)); 86 snd_iprintf(buffer, "0x%02x\n", val); 87 } 88 89 static void print_pcm_caps(snd_info_buffer_t *buffer, 89 AC_AMP_GET_RIGHT | dir | i); 90 snd_iprintf(buffer, "0x%02x]", val); 91 } 92 snd_iprintf(buffer, "\n"); 93 } 94 95 static void print_pcm_caps(struct snd_info_buffer *buffer, 90 96 struct hda_codec *codec, hda_nid_t nid) 91 97 { … … 156 162 } 157 163 158 static void print_pin_caps(s nd_info_buffer_t*buffer,164 static void print_pin_caps(struct snd_info_buffer *buffer, 159 165 struct hda_codec *codec, hda_nid_t nid) 160 166 { 161 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" };167 static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; 162 168 static char *jack_types[16] = { 163 169 "Line Out", "Speaker", "HP Out", "CD", … … 178 184 snd_iprintf(buffer, " HP"); 179 185 snd_iprintf(buffer, "\n"); 180 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0);181 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps,182 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT],186 caps = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 187 snd_iprintf(buffer, " Pin Default 0x%08x: [%s] %s at %s %s\n", caps, 188 jack_conns[(caps & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT], 183 189 jack_types[(caps & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT], 184 190 jack_locations[(caps >> (AC_DEFCFG_LOCATION_SHIFT + 4)) & 3], … … 190 196 191 197 192 static void print_codec_info(s nd_info_entry_t *entry, snd_info_buffer_t*buffer)198 static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) 193 199 { 194 200 struct hda_codec *codec = entry->private_data; … … 203 209 snd_iprintf(buffer, "Subsystem Id: 0x%x\n", codec->subsystem_id); 204 210 snd_iprintf(buffer, "Revision Id: 0x%x\n", codec->revision_id); 211 if (! codec->afg) 212 return; 205 213 snd_iprintf(buffer, "Default PCM: "); 206 214 print_pcm_caps(buffer, codec, codec->afg); … … 219 227 AC_PAR_AUDIO_WIDGET_CAP); 220 228 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 229 int conn_len = 0; 230 hda_nid_t conn[HDA_MAX_CONNECTIONS]; 231 221 232 snd_iprintf(buffer, "Node 0x%02x [%s] wcaps 0x%x:", nid, 222 233 get_wid_type_name(wid_type), wid_caps); … … 233 244 snd_iprintf(buffer, "\n"); 234 245 246 if (wid_caps & AC_WCAP_CONN_LIST) 247 conn_len = snd_hda_get_connections(codec, nid, conn, 248 HDA_MAX_CONNECTIONS); 249 235 250 if (wid_caps & AC_WCAP_IN_AMP) { 236 251 snd_iprintf(buffer, " Amp-In caps: "); … … 238 253 snd_iprintf(buffer, " Amp-In vals: "); 239 254 print_amp_vals(buffer, codec, nid, HDA_INPUT, 240 wid_caps & AC_WCAP_STEREO );255 wid_caps & AC_WCAP_STEREO, conn_len); 241 256 } 242 257 if (wid_caps & AC_WCAP_OUT_AMP) { … … 245 260 snd_iprintf(buffer, " Amp-Out vals: "); 246 261 print_amp_vals(buffer, codec, nid, HDA_OUTPUT, 247 wid_caps & AC_WCAP_STEREO );262 wid_caps & AC_WCAP_STEREO, 1); 248 263 } 249 264 … … 268 283 } 269 284 285 if (wid_caps & AC_WCAP_POWER) 286 snd_iprintf(buffer, " Power: 0x%x\n", 287 snd_hda_codec_read(codec, nid, 0, 288 AC_VERB_GET_POWER_STATE, 0)); 289 270 290 if (wid_caps & AC_WCAP_CONN_LIST) { 271 hda_nid_t conn[HDA_MAX_CONNECTIONS]; 272 int c, conn_len, curr = -1; 273 conn_len = snd_hda_get_connections(codec, nid, conn, 274 HDA_MAX_CONNECTIONS); 275 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX) 276 curr = snd_hda_codec_read(codec, nid, 0, 277 AC_VERB_GET_CONNECT_SEL, 0); 291 int c, curr = -1; 292 if (conn_len > 1 && wid_type != AC_WID_AUD_MIX) 293 curr = snd_hda_codec_read(codec, nid, 0, 294 AC_VERB_GET_CONNECT_SEL, 0); 278 295 snd_iprintf(buffer, " Connection: %d\n", conn_len); 279 snd_iprintf(buffer, " ");280 for (c = 0; c < conn_len; c++) {281 snd_iprintf(buffer, " 0x%02x", conn[c]);282 if (c == curr)283 snd_iprintf(buffer, "*");284 }296 snd_iprintf(buffer, " "); 297 for (c = 0; c < conn_len; c++) { 298 snd_iprintf(buffer, " 0x%02x", conn[c]); 299 if (c == curr) 300 snd_iprintf(buffer, "*"); 301 } 285 302 snd_iprintf(buffer, "\n"); 286 303 } … … 293 310 int snd_hda_codec_proc_new(struct hda_codec *codec) 294 311 { 295 char name[32] = {0};296 s nd_info_entry_t*entry;312 char name[32]; 313 struct snd_info_entry *entry; 297 314 int err; 298 315 -
GPL/trunk/alsa-kernel/pci/hda/makefile.os2
r32 r69 15 15 FILE1 = hda_intel.obj hda_codec.obj hda_generic.obj patch_realtek.obj 16 16 FILE2 = patch_cmedia.obj hda_proc.obj patch_analog.obj patch_sigmatel.obj 17 FILE3 = 17 FILE3 = patch_si3054.obj 18 18 FILE4 = 19 19 FILE5 = -
GPL/trunk/alsa-kernel/pci/hda/patch_analog.c
r32 r69 1 1 /* 2 * HD audio interface patch for AD1981HD, AD1983, AD1986A 2 * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988 3 3 * 4 4 * Copyright (c) 2005 Takashi Iwai <tiwai@suse.de> … … 29 29 30 30 struct ad198x_spec { 31 struct snd_kcontrol_new *mixers[5]; 32 int num_mixers; 33 34 const struct hda_verb *init_verbs[5]; /* initialization verbs 35 * don't forget NULL termination! 36 */ 37 unsigned int num_init_verbs; 38 39 /* playback */ 40 struct hda_multi_out multiout; /* playback set-up 41 * max_channels, dacs must be set 42 * dig_out_nid and hp_nid are optional 43 */ 44 unsigned int cur_eapd; 45 46 /* capture */ 47 unsigned int num_adc_nids; 48 hda_nid_t *adc_nids; 49 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 50 51 /* capture source */ 52 const struct hda_input_mux *input_mux; 53 hda_nid_t *capsrc_nids; 54 unsigned int cur_mux[3]; 55 56 /* channel model */ 57 const struct hda_channel_mode *channel_mode; 58 int num_channel_mode; 59 60 /* PCM information */ 61 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ 62 31 63 struct semaphore amp_mutex; /* PCM volume/mute control mutex */ 32 struct hda_multi_out multiout; /* playback */ 33 hda_nid_t adc_nid; 34 const struct hda_input_mux *input_mux; 35 unsigned int cur_mux; /* capture source */ 36 unsigned int spdif_route;37 snd_kcontrol_new_t *mixers;38 const struct hda_verb *init_verbs;39 struct hda_pcm pcm_rec[2]; /* PCM information */64 unsigned int spdif_route; 65 66 /* dynamic controls, init_verbs and input_mux */ 67 struct auto_pin_cfg autocfg; 68 unsigned int num_kctl_alloc, num_kctl_used; 69 struct snd_kcontrol_new *kctl_alloc; 70 struct hda_input_mux private_imux; 71 hda_nid_t private_dac_nids[4]; 40 72 }; 41 73 … … 43 75 * input MUX handling (common part) 44 76 */ 45 static int ad198x_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 46 { 47 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 48 struct ad198x_spec *spec = codec->spec; 49 50 return snd_hda_input_mux_info(spec->input_mux, uinfo); 51 } 52 53 static int ad198x_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 54 { 55 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 56 struct ad198x_spec *spec = codec->spec; 57 58 ucontrol->value.enumerated.item[0] = spec->cur_mux; 59 return 0; 60 } 61 62 static int ad198x_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 63 { 64 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 65 struct ad198x_spec *spec = codec->spec; 66 67 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 68 spec->adc_nid, &spec->cur_mux); 77 static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 78 { 79 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 80 struct ad198x_spec *spec = codec->spec; 81 82 return snd_hda_input_mux_info(spec->input_mux, uinfo); 83 } 84 85 static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 86 { 87 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 88 struct ad198x_spec *spec = codec->spec; 89 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 90 91 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; 92 return 0; 93 } 94 95 static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 96 { 97 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 98 struct ad198x_spec *spec = codec->spec; 99 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 100 101 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 102 spec->capsrc_nids[adc_idx], 103 &spec->cur_mux[adc_idx]); 69 104 } 70 105 … … 74 109 static int ad198x_init(struct hda_codec *codec) 75 110 { 76 struct ad198x_spec *spec = codec->spec; 77 snd_hda_sequence_write(codec, spec->init_verbs); 78 return 0; 111 struct ad198x_spec *spec = codec->spec; 112 int i; 113 114 for (i = 0; i < spec->num_init_verbs; i++) 115 snd_hda_sequence_write(codec, spec->init_verbs[i]); 116 return 0; 79 117 } 80 118 81 119 static int ad198x_build_controls(struct hda_codec *codec) 82 120 { 83 struct ad198x_spec *spec = codec->spec; 84 int err; 85 86 err = snd_hda_add_new_ctls(codec, spec->mixers); 87 if (err < 0) 88 return err; 89 if (spec->multiout.dig_out_nid) 90 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 91 if (err < 0) 92 return err; 93 return 0; 121 struct ad198x_spec *spec = codec->spec; 122 unsigned int i; 123 int err; 124 125 for (i = 0; i < spec->num_mixers; i++) { 126 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 127 if (err < 0) 128 return err; 129 } 130 if (spec->multiout.dig_out_nid) { 131 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 132 if (err < 0) 133 return err; 134 } 135 if (spec->dig_in_nid) { 136 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 137 if (err < 0) 138 return err; 139 } 140 return 0; 94 141 } 95 142 … … 98 145 */ 99 146 static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, 100 struct hda_codec *codec,101 snd_pcm_substream_t*substream)102 { 103 struct ad198x_spec *spec = codec->spec;104 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);147 struct hda_codec *codec, 148 struct snd_pcm_substream *substream) 149 { 150 struct ad198x_spec *spec = codec->spec; 151 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 105 152 } 106 153 107 154 static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 108 struct hda_codec *codec,109 unsigned int stream_tag,110 unsigned int format,111 snd_pcm_substream_t*substream)112 { 113 struct ad198x_spec *spec = codec->spec;114 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,115 format, substream);155 struct hda_codec *codec, 156 unsigned int stream_tag, 157 unsigned int format, 158 struct snd_pcm_substream *substream) 159 { 160 struct ad198x_spec *spec = codec->spec; 161 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, 162 format, substream); 116 163 } 117 164 118 165 static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 119 struct hda_codec *codec,120 snd_pcm_substream_t*substream)121 { 122 struct ad198x_spec *spec = codec->spec;123 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);166 struct hda_codec *codec, 167 struct snd_pcm_substream *substream) 168 { 169 struct ad198x_spec *spec = codec->spec; 170 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 124 171 } 125 172 … … 128 175 */ 129 176 static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 130 struct hda_codec *codec,131 snd_pcm_substream_t*substream)132 { 133 struct ad198x_spec *spec = codec->spec;134 return snd_hda_multi_out_dig_open(codec, &spec->multiout);177 struct hda_codec *codec, 178 struct snd_pcm_substream *substream) 179 { 180 struct ad198x_spec *spec = codec->spec; 181 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 135 182 } 136 183 137 184 static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 138 struct hda_codec *codec,139 snd_pcm_substream_t*substream)140 { 141 struct ad198x_spec *spec = codec->spec;142 return snd_hda_multi_out_dig_close(codec, &spec->multiout);185 struct hda_codec *codec, 186 struct snd_pcm_substream *substream) 187 { 188 struct ad198x_spec *spec = codec->spec; 189 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 143 190 } 144 191 … … 147 194 */ 148 195 static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 149 struct hda_codec *codec, 150 unsigned int stream_tag, 151 unsigned int format, 152 snd_pcm_substream_t *substream) 153 { 154 struct ad198x_spec *spec = codec->spec; 155 snd_hda_codec_setup_stream(codec, spec->adc_nid, stream_tag, 0, format); 156 return 0; 196 struct hda_codec *codec, 197 unsigned int stream_tag, 198 unsigned int format, 199 struct snd_pcm_substream *substream) 200 { 201 struct ad198x_spec *spec = codec->spec; 202 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 203 stream_tag, 0, format); 204 return 0; 157 205 } 158 206 159 207 static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 160 struct hda_codec *codec, 161 snd_pcm_substream_t *substream) 162 { 163 struct ad198x_spec *spec = codec->spec; 164 snd_hda_codec_setup_stream(codec, spec->adc_nid, 0, 0, 0); 165 return 0; 208 struct hda_codec *codec, 209 struct snd_pcm_substream *substream) 210 { 211 struct ad198x_spec *spec = codec->spec; 212 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 213 0, 0, 0); 214 return 0; 166 215 } 167 216 … … 170 219 */ 171 220 static struct hda_pcm_stream ad198x_pcm_analog_playback = { 172 /*.substreams = */1, 173 /*.channels_min = */2, 174 /*.channels_max = */6, 175 /*.nid = */0, /* fill later */ 176 0,0,0, 177 /*.ops = */{ 178 /*.open = */ad198x_playback_pcm_open, 0, 179 /*.prepare = */ad198x_playback_pcm_prepare, 180 /*.cleanup = */ad198x_playback_pcm_cleanup 181 }, 221 .substreams = 1, 222 .channels_min = 2, 223 .channels_max = 6, /* changed later */ 224 .nid = 0, /* fill later */ 225 .ops = { 226 .open = ad198x_playback_pcm_open, 227 .prepare = ad198x_playback_pcm_prepare, 228 .cleanup = ad198x_playback_pcm_cleanup 229 }, 182 230 }; 183 231 184 232 static struct hda_pcm_stream ad198x_pcm_analog_capture = { 185 /*.substreams = */2, 186 /*.channels_min = */2, 187 /*.channels_max = */2, 188 /*.nid = */0, /* fill later */ 189 0,0,0, 190 /*.ops = */{ 191 0,0, 192 /*.prepare = */ad198x_capture_pcm_prepare, 193 /*.cleanup = */ad198x_capture_pcm_cleanup 194 }, 233 .substreams = 1, 234 .channels_min = 2, 235 .channels_max = 2, 236 .nid = 0, /* fill later */ 237 .ops = { 238 .prepare = ad198x_capture_pcm_prepare, 239 .cleanup = ad198x_capture_pcm_cleanup 240 }, 195 241 }; 196 242 197 243 static struct hda_pcm_stream ad198x_pcm_digital_playback = { 198 /*.substreams = */1, 199 /*.channels_min = */2, 200 /*.channels_max = */2, 201 /*.nid = */0, /* fill later */ 202 0,0,0, 203 /*.ops = */{ 204 /*.open = */ad198x_dig_playback_pcm_open, 205 /*.close = */ad198x_dig_playback_pcm_close, 206 0,0 207 }, 244 .substreams = 1, 245 .channels_min = 2, 246 .channels_max = 2, 247 .nid = 0, /* fill later */ 248 .ops = { 249 .open = ad198x_dig_playback_pcm_open, 250 .close = ad198x_dig_playback_pcm_close 251 }, 252 }; 253 254 static struct hda_pcm_stream ad198x_pcm_digital_capture = { 255 .substreams = 1, 256 .channels_min = 2, 257 .channels_max = 2, 258 /* NID is set in alc_build_pcms */ 208 259 }; 209 260 210 261 static int ad198x_build_pcms(struct hda_codec *codec) 211 262 { 212 struct ad198x_spec *spec = codec->spec; 213 struct hda_pcm *info = spec->pcm_rec; 214 215 codec->num_pcms = 1; 216 codec->pcm_info = info; 217 218 info->name = "AD198x Analog"; 219 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; 220 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; 221 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 222 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; 223 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nid; 224 225 if (spec->multiout.dig_out_nid) { 226 info++; 227 codec->num_pcms++; 228 info->name = "AD198x Digital"; 229 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; 230 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 231 } 232 233 return 0; 263 struct ad198x_spec *spec = codec->spec; 264 struct hda_pcm *info = spec->pcm_rec; 265 266 codec->num_pcms = 1; 267 codec->pcm_info = info; 268 269 info->name = "AD198x Analog"; 270 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback; 271 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels; 272 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 273 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture; 274 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids; 275 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 276 277 if (spec->multiout.dig_out_nid) { 278 info++; 279 codec->num_pcms++; 280 info->name = "AD198x Digital"; 281 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; 282 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 283 if (spec->dig_in_nid) { 284 info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture; 285 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 286 } 287 } 288 289 return 0; 234 290 } 235 291 236 292 static void ad198x_free(struct hda_codec *codec) 237 293 { 238 kfree(codec->spec); 294 struct ad198x_spec *spec = codec->spec; 295 unsigned int i; 296 297 if (spec->kctl_alloc) { 298 for (i = 0; i < spec->num_kctl_used; i++) 299 kfree(spec->kctl_alloc[i].name); 300 kfree(spec->kctl_alloc); 301 } 302 kfree(codec->spec); 239 303 } 240 304 … … 242 306 static int ad198x_resume(struct hda_codec *codec) 243 307 { 244 struct ad198x_spec *spec = codec->spec; 245 246 ad198x_init(codec); 247 snd_hda_resume_ctls(codec, spec->mixers); 248 snd_hda_resume_spdif_out(codec); 249 return 0; 308 struct ad198x_spec *spec = codec->spec; 309 int i; 310 311 ad198x_init(codec); 312 for (i = 0; i < spec->num_mixers; i++) 313 snd_hda_resume_ctls(codec, spec->mixers[i]); 314 if (spec->multiout.dig_out_nid) 315 snd_hda_resume_spdif_out(codec); 316 if (spec->dig_in_nid) 317 snd_hda_resume_spdif_in(codec); 318 return 0; 250 319 } 251 320 #endif 252 321 253 322 static struct hda_codec_ops ad198x_patch_ops = { 254 /*.build_controls = */ad198x_build_controls,255 /*.build_pcms = */ad198x_build_pcms,256 /*.init = */ad198x_init,257 /*.free = */ad198x_free,0,323 .build_controls = ad198x_build_controls, 324 .build_pcms = ad198x_build_pcms, 325 .init = ad198x_init, 326 .free = ad198x_free, 258 327 #ifdef CONFIG_PM 259 0, 260 /*.resume = */ad198x_resume, 328 .resume = ad198x_resume, 261 329 #endif 262 330 }; 331 263 332 264 333 /* … … 273 342 274 343 static hda_nid_t ad1986a_dac_nids[3] = { 275 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC 276 }; 344 AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC 345 }; 346 static hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC }; 277 347 278 348 static struct hda_input_mux ad1986a_capture_source = { 279 /*.num_items = */7,280 /*.items = */{349 .num_items = 7, 350 .items = { 281 351 { "Mic", 0x0 }, 282 352 { "CD", 0x1 }, … … 297 367 #define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info 298 368 299 static int ad1986a_pcm_amp_vol_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)300 { 301 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);302 struct ad198x_spec *ad = codec->spec;369 static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 370 { 371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 372 struct ad198x_spec *ad = codec->spec; 303 373 304 374 down(&ad->amp_mutex); … … 308 378 } 309 379 310 static int ad1986a_pcm_amp_vol_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)311 { 312 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);313 struct ad198x_spec *ad = codec->spec;380 static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 381 { 382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 383 struct ad198x_spec *ad = codec->spec; 314 384 int i, change = 0; 315 385 … … 324 394 } 325 395 326 #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info327 328 static int ad1986a_pcm_amp_sw_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)329 { 330 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);331 struct ad198x_spec *ad = codec->spec;396 #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info 397 398 static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 399 { 400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 401 struct ad198x_spec *ad = codec->spec; 332 402 333 403 down(&ad->amp_mutex); … … 337 407 } 338 408 339 static int ad1986a_pcm_amp_sw_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)340 { 341 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);342 struct ad198x_spec *ad = codec->spec;409 static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 410 { 411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 412 struct ad198x_spec *ad = codec->spec; 343 413 int i, change = 0; 344 414 … … 356 426 * mixers 357 427 */ 358 static s nd_kcontrol_new_tad1986a_mixers[] = {359 {360 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,361 /*.name = */"PCM Playback Volume",0,0,0,362 /*.info = */ad1986a_pcm_amp_vol_info,363 /*.get = */ad1986a_pcm_amp_vol_get,364 /*.put = */ad1986a_pcm_amp_vol_put,365 /*.private_value = */HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)366 },367 {368 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,369 /*.name = */"PCM Playback Switch",0,0,0,370 /*.info = */ad1986a_pcm_amp_sw_info,371 /*.get = */ad1986a_pcm_amp_sw_get,372 /*.put = */ad1986a_pcm_amp_sw_put,373 /*.private_value = */HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT)374 },375 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),376 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),377 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),378 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),379 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),380 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),381 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),382 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),383 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),384 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),385 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),386 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),387 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),388 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),389 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),390 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),391 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),392 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),393 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),394 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),395 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),396 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),397 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),398 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),399 {400 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,401 /*.name = */"Capture Source",0,0,0,402 /*.info = */ad198x_mux_enum_info,403 /*.get = */ad198x_mux_enum_get,404 /*.put = */ad198x_mux_enum_put,0 405 },406 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),407 {0} /* end */428 static struct snd_kcontrol_new ad1986a_mixers[] = { 429 { 430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 431 .name = "PCM Playback Volume", 432 .info = ad1986a_pcm_amp_vol_info, 433 .get = ad1986a_pcm_amp_vol_get, 434 .put = ad1986a_pcm_amp_vol_put, 435 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT) 436 }, 437 { 438 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 439 .name = "PCM Playback Switch", 440 .info = ad1986a_pcm_amp_sw_info, 441 .get = ad1986a_pcm_amp_sw_get, 442 .put = ad1986a_pcm_amp_sw_put, 443 .private_value = HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT) 444 }, 445 HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT), 446 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT), 448 HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT), 449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT), 450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT), 451 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT), 452 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT), 453 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT), 454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT), 455 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT), 456 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT), 457 HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT), 458 HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT), 459 HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT), 460 HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT), 461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 462 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 463 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), 464 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT), 465 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), 466 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), 467 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 468 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), 469 { 470 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 471 .name = "Capture Source", 472 .info = ad198x_mux_enum_info, 473 .get = ad198x_mux_enum_get, 474 .put = ad198x_mux_enum_put, 475 }, 476 HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT), 477 {0} /* end */ 408 478 }; 409 479 … … 446 516 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 447 517 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 448 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 449 /* HP Pin */ 450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 451 /* Front, Surround, CLFE Pins */ 452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 453 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 454 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 455 /* Mono Pin */ 456 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 457 /* Mic Pin */ 458 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 459 /* Line, Aux, CD, Beep-In Pin */ 460 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 461 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 462 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 463 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 464 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 465 {0} /* end */ 466 }; 518 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 519 /* HP Pin */ 520 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 521 /* Front, Surround, CLFE Pins */ 522 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 523 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 524 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 525 /* Mono Pin */ 526 {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 527 /* Mic Pin */ 528 {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 529 /* Line, Aux, CD, Beep-In Pin */ 530 {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 531 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 532 {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 533 {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 534 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 535 {0} /* end */ 536 }; 537 467 538 468 539 static int patch_ad1986a(struct hda_codec *codec) 469 540 { 470 struct ad198x_spec *spec; 471 472 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 473 if (spec == NULL) 474 return -ENOMEM; 475 476 init_MUTEX(&spec->amp_mutex); 477 codec->spec = spec; 478 479 spec->multiout.max_channels = 6; 480 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); 481 spec->multiout.dac_nids = ad1986a_dac_nids; 482 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; 483 spec->adc_nid = AD1986A_ADC; 484 spec->input_mux = &ad1986a_capture_source; 485 spec->mixers = ad1986a_mixers; 486 spec->init_verbs = ad1986a_init_verbs; 487 488 codec->patch_ops = ad198x_patch_ops; 489 490 return 0; 541 struct ad198x_spec *spec; 542 543 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 544 if (spec == NULL) 545 return -ENOMEM; 546 547 init_MUTEX(&spec->amp_mutex); 548 codec->spec = spec; 549 550 spec->multiout.max_channels = 6; 551 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); 552 spec->multiout.dac_nids = ad1986a_dac_nids; 553 spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; 554 spec->num_adc_nids = 1; 555 spec->adc_nids = ad1986a_adc_nids; 556 spec->capsrc_nids = ad1986a_adc_nids; 557 spec->input_mux = &ad1986a_capture_source; 558 spec->num_mixers = 1; 559 spec->mixers[0] = ad1986a_mixers; 560 spec->num_init_verbs = 1; 561 spec->init_verbs[0] = ad1986a_init_verbs; 562 563 codec->patch_ops = ad198x_patch_ops; 564 565 return 0; 491 566 } 492 567 … … 495 570 */ 496 571 497 #define AD1983_SPDIF_OUT 0x02498 #define AD1983_DAC 0x03499 #define AD1983_ADC 0x04572 #define AD1983_SPDIF_OUT 0x02 573 #define AD1983_DAC 0x03 574 #define AD1983_ADC 0x04 500 575 501 576 static hda_nid_t ad1983_dac_nids[1] = { AD1983_DAC }; 577 static hda_nid_t ad1983_adc_nids[1] = { AD1983_ADC }; 578 502 579 static struct hda_input_mux ad1983_capture_source = { 503 /*.num_items = */4, 504 /*.items = */{ 505 { "Mic", 0x0 }, 506 { "Line", 0x1 }, 507 { "Mix", 0x2 }, 508 { "Mix Mono", 0x3 }, 509 }, 510 }; 580 .num_items = 4, 581 .items = { 582 { "Mic", 0x0 }, 583 { "Line", 0x1 }, 584 { "Mix", 0x2 }, 585 { "Mix Mono", 0x3 }, 586 }, 587 }; 588 511 589 /* 512 590 * SPDIF playback route 513 591 */ 514 static int ad1983_spdif_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 515 { 516 static char *texts[] = { "PCM", "ADC" }; 517 518 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 519 uinfo->count = 1; 520 uinfo->value.enumerated.items = 2; 521 if (uinfo->value.enumerated.item > 1) 522 uinfo->value.enumerated.item = 1; 523 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 524 return 0; 525 } 526 527 static int ad1983_spdif_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 528 { 529 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 530 struct ad198x_spec *spec = codec->spec; 531 532 ucontrol->value.enumerated.item[0] = spec->spdif_route; 533 return 0; 534 } 535 536 static int ad1983_spdif_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 537 { 538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 539 struct ad198x_spec *spec = codec->spec; 540 541 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { 542 spec->spdif_route = ucontrol->value.enumerated.item[0]; 543 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0, 544 AC_VERB_SET_CONNECT_SEL, spec->spdif_route); 545 return 1; 546 } 547 return 0; 548 } 549 550 551 /* 552 */ 553 static snd_kcontrol_new_t ad1983_mixers[] = { 592 static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 593 { 594 static char *texts[] = { "PCM", "ADC" }; 595 596 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 597 uinfo->count = 1; 598 uinfo->value.enumerated.items = 2; 599 if (uinfo->value.enumerated.item > 1) 600 uinfo->value.enumerated.item = 1; 601 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 602 return 0; 603 } 604 605 static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 606 { 607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 608 struct ad198x_spec *spec = codec->spec; 609 610 ucontrol->value.enumerated.item[0] = spec->spdif_route; 611 return 0; 612 } 613 614 static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 615 { 616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 617 struct ad198x_spec *spec = codec->spec; 618 619 if (spec->spdif_route != ucontrol->value.enumerated.item[0]) { 620 spec->spdif_route = ucontrol->value.enumerated.item[0]; 621 snd_hda_codec_write(codec, spec->multiout.dig_out_nid, 0, 622 AC_VERB_SET_CONNECT_SEL, spec->spdif_route); 623 return 1; 624 } 625 return 0; 626 } 627 628 static struct snd_kcontrol_new ad1983_mixers[] = { 554 629 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), 555 630 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), … … 570 645 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), 571 646 { 572 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,573 /*.name = */"Capture Source",0,0,0,574 /*.info = */ad198x_mux_enum_info,575 /*.get = */ad198x_mux_enum_get,576 /*.put = */ad198x_mux_enum_put,0647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 648 .name = "Capture Source", 649 .info = ad198x_mux_enum_info, 650 .get = ad198x_mux_enum_get, 651 .put = ad198x_mux_enum_put, 577 652 }, 578 653 { 579 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,580 /*.name = */"IEC958 Playback Route",0,0,0,581 /*.info = */ad1983_spdif_route_info,582 /*.get = */ad1983_spdif_route_get,583 /*.put = */ad1983_spdif_route_put,0654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 655 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 656 .info = ad1983_spdif_route_info, 657 .get = ad1983_spdif_route_get, 658 .put = ad1983_spdif_route_put, 584 659 }, 585 660 {0} /* end */ … … 625 700 }; 626 701 702 627 703 static int patch_ad1983(struct hda_codec *codec) 628 704 { 629 705 struct ad198x_spec *spec; 630 706 631 spec = k calloc(1,sizeof(*spec), GFP_KERNEL);707 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 632 708 if (spec == NULL) 633 709 return -ENOMEM; … … 640 716 spec->multiout.dac_nids = ad1983_dac_nids; 641 717 spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; 642 spec->adc_nid = AD1983_ADC; 718 spec->num_adc_nids = 1; 719 spec->adc_nids = ad1983_adc_nids; 720 spec->capsrc_nids = ad1983_adc_nids; 643 721 spec->input_mux = &ad1983_capture_source; 644 spec->mixers = ad1983_mixers; 645 spec->init_verbs = ad1983_init_verbs; 722 spec->num_mixers = 1; 723 spec->mixers[0] = ad1983_mixers; 724 spec->num_init_verbs = 1; 725 spec->init_verbs[0] = ad1983_init_verbs; 646 726 spec->spdif_route = 0; 647 727 … … 651 731 } 652 732 733 653 734 /* 654 735 * AD1981 HD specific 655 736 */ 656 737 657 #define AD1981_SPDIF_OUT 0x02658 #define AD1981_DAC 0x03659 #define AD1981_ADC 0x04738 #define AD1981_SPDIF_OUT 0x02 739 #define AD1981_DAC 0x03 740 #define AD1981_ADC 0x04 660 741 661 742 static hda_nid_t ad1981_dac_nids[1] = { AD1981_DAC }; 743 static hda_nid_t ad1981_adc_nids[1] = { AD1981_ADC }; 662 744 663 745 /* 0x0c, 0x09, 0x0e, 0x0f, 0x19, 0x05, 0x18, 0x17 */ 664 746 static struct hda_input_mux ad1981_capture_source = { 665 /*.num_items = */7,666 /*.items = */{667 { "Front Mic", 0x0 },668 { "Line", 0x1 },669 { "Mix", 0x2 },670 { "Mix Mono", 0x3 },671 { "CD", 0x4 },672 { "Mic", 0x6 },673 { "Aux", 0x7 },674 },675 }; 676 677 static s nd_kcontrol_new_tad1981_mixers[] = {678 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT),679 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT),680 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT),681 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT),682 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT),683 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT),684 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT),685 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT),686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT),687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),688 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),689 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),690 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT),691 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT),692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT),693 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),694 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),695 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),696 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),697 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),698 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),699 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),700 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),701 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),702 {703 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,704 /*.name = */"Capture Source",0,0,0,705 /*.info = */ad198x_mux_enum_info,706 /*.get = */ad198x_mux_enum_get,707 /*.put = */ad198x_mux_enum_put,0 708 },709 /* identical with AD1983 */710 {711 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,712 /*.name = */"IEC958 Playback Route",0,0,0,713 /*.info = */ad1983_spdif_route_info,714 /*.get = */ad1983_spdif_route_get,715 /*.put = */ad1983_spdif_route_put,0 716 },717 {0} /* end */747 .num_items = 7, 748 .items = { 749 { "Front Mic", 0x0 }, 750 { "Line", 0x1 }, 751 { "Mix", 0x2 }, 752 { "Mix Mono", 0x3 }, 753 { "CD", 0x4 }, 754 { "Mic", 0x6 }, 755 { "Aux", 0x7 }, 756 }, 757 }; 758 759 static struct snd_kcontrol_new ad1981_mixers[] = { 760 HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), 761 HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), 762 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), 763 HDA_CODEC_MUTE("Headphone Playback Switch", 0x06, 0x0, HDA_OUTPUT), 764 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x07, 1, 0x0, HDA_OUTPUT), 765 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x07, 1, 0x0, HDA_OUTPUT), 766 HDA_CODEC_VOLUME("PCM Playback Volume", 0x11, 0x0, HDA_OUTPUT), 767 HDA_CODEC_MUTE("PCM Playback Switch", 0x11, 0x0, HDA_OUTPUT), 768 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x12, 0x0, HDA_OUTPUT), 769 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), 770 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), 771 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), 772 HDA_CODEC_VOLUME("Aux Playback Volume", 0x1b, 0x0, HDA_OUTPUT), 773 HDA_CODEC_MUTE("Aux Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x1c, 0x0, HDA_OUTPUT), 775 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), 776 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 777 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 778 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT), 779 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT), 780 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), 781 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), 782 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), 783 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), 784 { 785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 786 .name = "Capture Source", 787 .info = ad198x_mux_enum_info, 788 .get = ad198x_mux_enum_get, 789 .put = ad198x_mux_enum_put, 790 }, 791 /* identical with AD1983 */ 792 { 793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 794 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", 795 .info = ad1983_spdif_route_info, 796 .get = ad1983_spdif_route_get, 797 .put = ad1983_spdif_route_put, 798 }, 799 {0} /* end */ 718 800 }; 719 801 720 802 static struct hda_verb ad1981_init_verbs[] = { 721 /* Front, HP, Mono; mute as default */722 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},723 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},725 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},727 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},728 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},729 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},731 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},732 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},733 /* Front, HP selectors; from Mix */734 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},735 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01},736 /* Mono selector; from Mix */737 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03},738 /* Mic Mixer; select Front Mic */739 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},740 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},741 /* Mic boost: 0dB */742 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},744 /* Record selector: Front mic */745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},747 /* SPDIF route: PCM */748 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0},749 /* Front Pin */750 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },751 /* HP Pin */752 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },753 /* Mono Pin */754 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },755 /* Front & Rear Mic Pins */756 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },757 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },758 /* Line Pin */759 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },760 /* Digital Beep */761 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},762 /* Line-Out as Input: disabled */763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},764 {0} /* end */803 /* Front, HP, Mono; mute as default */ 804 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 805 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 806 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 807 /* Beep, PCM, Front Mic, Line, Rear Mic, Aux, CD-In: mute */ 808 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 809 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 810 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 811 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 812 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 813 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 814 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 815 /* Front, HP selectors; from Mix */ 816 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01}, 817 {0x06, AC_VERB_SET_CONNECT_SEL, 0x01}, 818 /* Mono selector; from Mix */ 819 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x03}, 820 /* Mic Mixer; select Front Mic */ 821 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 822 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 823 /* Mic boost: 0dB */ 824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 826 /* Record selector: Front mic */ 827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, 828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 829 /* SPDIF route: PCM */ 830 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, 831 /* Front Pin */ 832 {0x05, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 833 /* HP Pin */ 834 {0x06, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 835 /* Mono Pin */ 836 {0x07, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 837 /* Front & Rear Mic Pins */ 838 {0x08, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 840 /* Line Pin */ 841 {0x09, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 842 /* Digital Beep */ 843 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, 844 /* Line-Out as Input: disabled */ 845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 846 {0} /* end */ 765 847 }; 766 848 767 849 static int patch_ad1981(struct hda_codec *codec) 768 850 { 769 struct ad198x_spec *spec;770 771 spec = k calloc(1,sizeof(*spec), GFP_KERNEL);851 struct ad198x_spec *spec; 852 853 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 772 854 if (spec == NULL) 773 855 return -ENOMEM; … … 780 862 spec->multiout.dac_nids = ad1981_dac_nids; 781 863 spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; 782 spec->adc_nid = AD1981_ADC; 864 spec->num_adc_nids = 1; 865 spec->adc_nids = ad1981_adc_nids; 866 spec->capsrc_nids = ad1981_adc_nids; 783 867 spec->input_mux = &ad1981_capture_source; 784 spec->mixers = ad1981_mixers; 785 spec->init_verbs = ad1981_init_verbs; 868 spec->num_mixers = 1; 869 spec->mixers[0] = ad1981_mixers; 870 spec->num_init_verbs = 1; 871 spec->init_verbs[0] = ad1981_init_verbs; 786 872 spec->spdif_route = 0; 787 873 … … 791 877 } 792 878 879 880 /* 881 * AD1988 882 * 883 * Output pins and routes 884 * 885 * Pin Mix Sel DAC (*) 886 * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 887 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 888 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a 889 * port-D 0x12 (mute/hp) <- 0x29 <- 04 890 * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a 891 * port-F 0x16 (mute) <- 0x2a <- 06 892 * port-G 0x24 (mute) <- 0x27 <- 05 893 * port-H 0x25 (mute) <- 0x28 <- 0a 894 * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 895 * 896 * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah 897 * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug. 898 * 899 * Input pins and routes 900 * 901 * pin boost mix input # / adc input # 902 * port-A 0x11 -> 0x38 -> mix 2, ADC 0 903 * port-B 0x14 -> 0x39 -> mix 0, ADC 1 904 * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 905 * port-D 0x12 -> 0x3d -> mix 3, ADC 8 906 * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 907 * port-F 0x16 -> 0x3b -> mix 5, ADC 3 908 * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 909 * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 910 * 911 * 912 * DAC assignment 913 * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 914 * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 915 * 916 * Inputs of Analog Mix (0x20) 917 * 0:Port-B (front mic) 918 * 1:Port-C/G/H (line-in) 919 * 2:Port-A 920 * 3:Port-D (line-in/2) 921 * 4:Port-E/G/H (mic-in) 922 * 5:Port-F (mic2-in) 923 * 6:CD 924 * 7:Beep 925 * 926 * ADC selection 927 * 0:Port-A 928 * 1:Port-B (front mic-in) 929 * 2:Port-C (line-in) 930 * 3:Port-F (mic2-in) 931 * 4:Port-E (mic-in) 932 * 5:CD 933 * 6:Port-G 934 * 7:Port-H 935 * 8:Port-D (line-in/2) 936 * 9:Mix 937 * 938 * Proposed pin assignments by the datasheet 939 * 940 * 6-stack 941 * Port-A front headphone 942 * B front mic-in 943 * C rear line-in 944 * D rear front-out 945 * E rear mic-in 946 * F rear surround 947 * G rear CLFE 948 * H rear side 949 * 950 * 3-stack 951 * Port-A front headphone 952 * B front mic 953 * C rear line-in/surround 954 * D rear front-out 955 * E rear mic-in/CLFE 956 * 957 * laptop 958 * Port-A headphone 959 * B mic-in 960 * C docking station 961 * D internal speaker (with EAPD) 962 * E/F quad mic array 963 */ 964 965 966 /* models */ 967 enum { 968 AD1988_6STACK, 969 AD1988_6STACK_DIG, 970 AD1988_3STACK, 971 AD1988_3STACK_DIG, 972 AD1988_LAPTOP, 973 AD1988_LAPTOP_DIG, 974 AD1988_AUTO, 975 AD1988_MODEL_LAST, 976 }; 977 978 /* reivision id to check workarounds */ 979 #define AD1988A_REV2 0x100200 980 981 982 /* 983 * mixers 984 */ 985 986 static hda_nid_t ad1988_6stack_dac_nids[4] = { 987 0x04, 0x06, 0x05, 0x0a 988 }; 989 990 static hda_nid_t ad1988_3stack_dac_nids[3] = { 991 0x04, 0x05, 0x0a 992 }; 993 994 /* for AD1988A revision-2, DAC2-4 are swapped */ 995 static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { 996 0x04, 0x05, 0x0a, 0x06 997 }; 998 999 static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { 1000 0x04, 0x0a, 0x06 1001 }; 1002 1003 static hda_nid_t ad1988_adc_nids[3] = { 1004 0x08, 0x09, 0x0f 1005 }; 1006 1007 static hda_nid_t ad1988_capsrc_nids[3] = { 1008 0x0c, 0x0d, 0x0e 1009 }; 1010 1011 #define AD1988_SPDIF_OUT 0x02 1012 #define AD1988_SPDIF_IN 0x07 1013 1014 static struct hda_input_mux ad1988_6stack_capture_source = { 1015 .num_items = 5, 1016 .items = { 1017 { "Front Mic", 0x0 }, 1018 { "Line", 0x1 }, 1019 { "Mic", 0x4 }, 1020 { "CD", 0x5 }, 1021 { "Mix", 0x9 }, 1022 }, 1023 }; 1024 1025 static struct hda_input_mux ad1988_laptop_capture_source = { 1026 .num_items = 3, 1027 .items = { 1028 { "Mic/Line", 0x0 }, 1029 { "CD", 0x5 }, 1030 { "Mix", 0x9 }, 1031 }, 1032 }; 1033 1034 /* 1035 */ 1036 static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, 1037 struct snd_ctl_elem_info *uinfo) 1038 { 1039 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1040 struct ad198x_spec *spec = codec->spec; 1041 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 1042 spec->num_channel_mode); 1043 } 1044 1045 static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, 1046 struct snd_ctl_elem_value *ucontrol) 1047 { 1048 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1049 struct ad198x_spec *spec = codec->spec; 1050 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 1051 spec->num_channel_mode, spec->multiout.max_channels); 1052 } 1053 1054 static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, 1055 struct snd_ctl_elem_value *ucontrol) 1056 { 1057 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1058 struct ad198x_spec *spec = codec->spec; 1059 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 1060 spec->num_channel_mode, &spec->multiout.max_channels); 1061 } 1062 1063 /* 1064 * EAPD control 1065 */ 1066 static int ad1988_eapd_info(struct snd_kcontrol *kcontrol, 1067 struct snd_ctl_elem_info *uinfo) 1068 { 1069 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 1070 uinfo->count = 1; 1071 uinfo->value.integer.min = 0; 1072 uinfo->value.integer.max = 1; 1073 return 0; 1074 } 1075 1076 static int ad1988_eapd_get(struct snd_kcontrol *kcontrol, 1077 struct snd_ctl_elem_value *ucontrol) 1078 { 1079 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1080 struct ad198x_spec *spec = codec->spec; 1081 ucontrol->value.enumerated.item[0] = ! spec->cur_eapd; 1082 return 0; 1083 } 1084 1085 static int ad1988_eapd_put(struct snd_kcontrol *kcontrol, 1086 struct snd_ctl_elem_value *ucontrol) 1087 { 1088 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1089 struct ad198x_spec *spec = codec->spec; 1090 unsigned int eapd; 1091 eapd = ! ucontrol->value.enumerated.item[0]; 1092 if (eapd == spec->cur_eapd && ! codec->in_resume) 1093 return 0; 1094 spec->cur_eapd = eapd; 1095 snd_hda_codec_write(codec, 0x12 /* port-D */, 1096 0, AC_VERB_SET_EAPD_BTLENABLE, 1097 eapd ? 0x02 : 0x00); 1098 return 0; 1099 } 1100 1101 /* 6-stack mode */ 1102 static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { 1103 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), 1104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), 1105 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), 1106 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), 1107 HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), 1108 }; 1109 1110 static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { 1111 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), 1112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), 1113 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 1114 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), 1115 HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), 1116 }; 1117 1118 static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { 1119 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), 1120 HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), 1121 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), 1122 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), 1123 HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), 1124 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), 1125 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), 1126 1127 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), 1128 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), 1129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), 1130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), 1131 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), 1132 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), 1133 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), 1134 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), 1135 1136 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), 1137 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), 1138 1139 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 1140 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 1141 1142 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), 1143 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), 1144 1145 {0} /* end */ 1146 }; 1147 1148 /* 3-stack mode */ 1149 static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { 1150 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), 1151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), 1152 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), 1153 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), 1154 }; 1155 1156 static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { 1157 HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), 1158 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), 1159 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), 1160 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), 1161 }; 1162 1163 static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { 1164 HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), 1165 HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), 1166 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), 1167 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), 1168 HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), 1169 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), 1170 1171 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), 1172 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), 1173 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), 1174 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), 1175 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), 1176 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), 1177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), 1178 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), 1179 1180 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), 1181 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), 1182 1183 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 1184 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 1185 1186 HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), 1187 HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), 1188 { 1189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1190 .name = "Channel Mode", 1191 .info = ad198x_ch_mode_info, 1192 .get = ad198x_ch_mode_get, 1193 .put = ad198x_ch_mode_put, 1194 }, 1195 1196 {0} /* end */ 1197 }; 1198 1199 /* laptop mode */ 1200 static struct snd_kcontrol_new ad1988_laptop_mixers[] = { 1201 HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), 1202 HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), 1203 HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), 1204 1205 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), 1206 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), 1207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), 1208 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), 1209 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), 1210 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), 1211 1212 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), 1213 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), 1214 1215 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 1216 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 1217 1218 HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), 1219 1220 { 1221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1222 .name = "External Amplifier", 1223 .info = ad1988_eapd_info, 1224 .get = ad1988_eapd_get, 1225 .put = ad1988_eapd_put, 1226 }, 1227 1228 {0} /* end */ 1229 }; 1230 1231 /* capture */ 1232 static struct snd_kcontrol_new ad1988_capture_mixers[] = { 1233 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 1234 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), 1235 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), 1236 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), 1237 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), 1238 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), 1239 { 1240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1241 /* The multiple "Capture Source" controls confuse alsamixer 1242 * So call somewhat different.. 1243 * FIXME: the controls appear in the "playback" view! 1244 */ 1245 /* .name = "Capture Source", */ 1246 .name = "Input Source", 1247 .count = 3, 1248 .info = ad198x_mux_enum_info, 1249 .get = ad198x_mux_enum_get, 1250 .put = ad198x_mux_enum_put, 1251 }, 1252 {0} /* end */ 1253 }; 1254 1255 static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, 1256 struct snd_ctl_elem_info *uinfo) 1257 { 1258 static char *texts[] = { 1259 "PCM", "ADC1", "ADC2", "ADC3" 1260 }; 1261 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1262 uinfo->count = 1; 1263 uinfo->value.enumerated.items = 4; 1264 if (uinfo->value.enumerated.item >= 4) 1265 uinfo->value.enumerated.item = 3; 1266 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1267 return 0; 1268 } 1269 1270 static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, 1271 struct snd_ctl_elem_value *ucontrol) 1272 { 1273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1274 unsigned int sel; 1275 1276 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1277 if (sel > 0) { 1278 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); 1279 if (sel <= 3) 1280 sel++; 1281 else 1282 sel = 0; 1283 } 1284 ucontrol->value.enumerated.item[0] = sel; 1285 return 0; 1286 } 1287 1288 static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, 1289 struct snd_ctl_elem_value *ucontrol) 1290 { 1291 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1292 unsigned int sel; 1293 int change; 1294 1295 sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); 1296 if (! ucontrol->value.enumerated.item[0]) { 1297 change = sel != 0; 1298 if (change) 1299 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); 1300 } else { 1301 change = sel == 0; 1302 if (change) 1303 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); 1304 sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; 1305 change |= sel == ucontrol->value.enumerated.item[0]; 1306 if (change) 1307 snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1308 ucontrol->value.enumerated.item[0] - 1); 1309 } 1310 return change; 1311 } 1312 1313 static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { 1314 HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), 1315 { 1316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1317 .name = "IEC958 Playback Source", 1318 .info = ad1988_spdif_playback_source_info, 1319 .get = ad1988_spdif_playback_source_get, 1320 .put = ad1988_spdif_playback_source_put, 1321 }, 1322 {0} /* end */ 1323 }; 1324 1325 static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { 1326 HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), 1327 {0} /* end */ 1328 }; 1329 1330 1331 /* 1332 * initialization verbs 1333 */ 1334 1335 /* 1336 * for 6-stack (+dig) 1337 */ 1338 static struct hda_verb ad1988_6stack_init_verbs[] = { 1339 /* Front, Surround, CLFE, side DAC; unmute as default */ 1340 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1341 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1342 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1343 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1344 /* Port-A front headphon path */ 1345 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ 1346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1348 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1349 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1350 /* Port-D line-out path */ 1351 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1352 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1353 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1354 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1355 /* Port-F surround path */ 1356 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1357 {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1358 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1359 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1360 /* Port-G CLFE path */ 1361 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1362 {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1363 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1364 {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1365 /* Port-H side path */ 1366 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1367 {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1368 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1369 {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1370 /* Mono out path */ 1371 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ 1372 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1373 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1374 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1375 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ 1376 /* Port-B front mic-in path */ 1377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1379 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1380 /* Port-C line-in path */ 1381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1382 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1383 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1384 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, 1385 /* Port-E mic-in path */ 1386 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1387 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1388 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1389 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, 1390 1391 {0} 1392 }; 1393 1394 static struct hda_verb ad1988_capture_init_verbs[] = { 1395 /* mute analog mix */ 1396 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1397 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1398 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 1399 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 1400 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 1401 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 1402 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 1403 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 1404 /* select ADCs - front-mic */ 1405 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 1406 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 1407 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 1408 /* ADCs; muted */ 1409 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1410 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1411 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1412 1413 {0} 1414 }; 1415 1416 static struct hda_verb ad1988_spdif_init_verbs[] = { 1417 /* SPDIF out sel */ 1418 {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ 1419 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ 1420 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1421 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1422 /* SPDIF out pin */ 1423 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ 1424 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */ 1425 1426 {0} 1427 }; 1428 1429 /* 1430 * verbs for 3stack (+dig) 1431 */ 1432 static struct hda_verb ad1988_3stack_ch2_init[] = { 1433 /* set port-C to line-in */ 1434 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1435 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 1436 /* set port-E to mic-in */ 1437 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1438 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 1439 {0} /* end */ 1440 }; 1441 1442 static struct hda_verb ad1988_3stack_ch6_init[] = { 1443 /* set port-C to surround out */ 1444 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1445 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1446 /* set port-E to CLFE out */ 1447 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 1448 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1449 {0} /* end */ 1450 }; 1451 1452 static struct hda_channel_mode ad1988_3stack_modes[2] = { 1453 { 2, ad1988_3stack_ch2_init }, 1454 { 6, ad1988_3stack_ch6_init }, 1455 }; 1456 1457 static struct hda_verb ad1988_3stack_init_verbs[] = { 1458 /* Front, Surround, CLFE, side DAC; unmute as default */ 1459 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1460 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1461 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1462 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1463 /* Port-A front headphon path */ 1464 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ 1465 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1467 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1468 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1469 /* Port-D line-out path */ 1470 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1471 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1472 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1474 /* Mono out path */ 1475 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ 1476 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1477 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1478 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1479 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ 1480 /* Port-B front mic-in path */ 1481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1483 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1484 /* Port-C line-in/surround path - 6ch mode as default */ 1485 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1487 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1488 {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ 1489 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, 1490 /* Port-E mic-in/CLFE path - 6ch mode as default */ 1491 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1492 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1493 {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1494 {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ 1495 {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, 1496 /* mute analog mix */ 1497 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1498 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1499 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 1500 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 1501 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 1502 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 1503 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 1504 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 1505 /* select ADCs - front-mic */ 1506 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 1507 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 1508 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 1509 /* ADCs; muted */ 1510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1512 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1513 {0} 1514 }; 1515 1516 /* 1517 * verbs for laptop mode (+dig) 1518 */ 1519 static struct hda_verb ad1988_laptop_hp_on[] = { 1520 /* unmute port-A and mute port-D */ 1521 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1522 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1523 {0} /* end */ 1524 }; 1525 static struct hda_verb ad1988_laptop_hp_off[] = { 1526 /* mute port-A and unmute port-D */ 1527 { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 1528 { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 1529 {0} /* end */ 1530 }; 1531 1532 #define AD1988_HP_EVENT 0x01 1533 1534 static struct hda_verb ad1988_laptop_init_verbs[] = { 1535 /* Front, Surround, CLFE, side DAC; unmute as default */ 1536 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1537 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1538 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1540 /* Port-A front headphon path */ 1541 {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ 1542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1543 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1544 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1545 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1546 /* unsolicited event for pin-sense */ 1547 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, 1548 /* Port-D line-out path + EAPD */ 1549 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1550 {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1551 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1552 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1553 {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ 1554 /* Mono out path */ 1555 {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ 1556 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1557 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1558 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1559 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ 1560 /* Port-B mic-in path */ 1561 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1562 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1563 {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1564 /* Port-C docking station - try to output */ 1565 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1567 {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1568 {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, 1569 /* mute analog mix */ 1570 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1571 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1572 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 1573 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 1574 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 1575 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, 1576 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, 1577 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, 1578 /* select ADCs - mic */ 1579 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 1580 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 1581 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 1582 /* ADCs; muted */ 1583 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1584 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1586 {0} 1587 }; 1588 1589 static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) 1590 { 1591 if ((res >> 26) != AD1988_HP_EVENT) 1592 return; 1593 if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) 1594 snd_hda_sequence_write(codec, ad1988_laptop_hp_on); 1595 else 1596 snd_hda_sequence_write(codec, ad1988_laptop_hp_off); 1597 } 1598 1599 1600 /* 1601 * Automatic parse of I/O pins from the BIOS configuration 1602 */ 1603 1604 #define NUM_CONTROL_ALLOC 32 1605 #define NUM_VERB_ALLOC 32 1606 1607 enum { 1608 AD_CTL_WIDGET_VOL, 1609 AD_CTL_WIDGET_MUTE, 1610 AD_CTL_BIND_MUTE, 1611 }; 1612 static struct snd_kcontrol_new ad1988_control_templates[] = { 1613 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 1614 HDA_CODEC_MUTE(NULL, 0, 0, 0), 1615 HDA_BIND_MUTE(NULL, 0, 0, 0), 1616 }; 1617 1618 /* add dynamic controls */ 1619 static int add_control(struct ad198x_spec *spec, int type, const char *name, 1620 unsigned long val) 1621 { 1622 struct snd_kcontrol_new *knew; 1623 1624 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 1625 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 1626 1627 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 1628 if (! knew) 1629 return -ENOMEM; 1630 if (spec->kctl_alloc) { 1631 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 1632 kfree(spec->kctl_alloc); 1633 } 1634 spec->kctl_alloc = knew; 1635 spec->num_kctl_alloc = num; 1636 } 1637 1638 knew = &spec->kctl_alloc[spec->num_kctl_used]; 1639 *knew = ad1988_control_templates[type]; 1640 knew->name = kstrdup(name, GFP_KERNEL); 1641 if (! knew->name) 1642 return -ENOMEM; 1643 knew->private_value = val; 1644 spec->num_kctl_used++; 1645 return 0; 1646 } 1647 1648 #define AD1988_PIN_CD_NID 0x18 1649 #define AD1988_PIN_BEEP_NID 0x10 1650 1651 static hda_nid_t ad1988_mixer_nids[8] = { 1652 /* A B C D E F G H */ 1653 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 1654 }; 1655 1656 static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) 1657 { 1658 static hda_nid_t idx_to_dac[8] = { 1659 /* A B C D E F G H */ 1660 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a 1661 }; 1662 static hda_nid_t idx_to_dac_rev2[8] = { 1663 /* A B C D E F G H */ 1664 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 1665 }; 1666 if (codec->revision_id == AD1988A_REV2) 1667 return idx_to_dac_rev2[idx]; 1668 else 1669 return idx_to_dac[idx]; 1670 } 1671 1672 static hda_nid_t ad1988_boost_nids[8] = { 1673 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 1674 }; 1675 1676 static int ad1988_pin_idx(hda_nid_t nid) 1677 { 1678 static hda_nid_t ad1988_io_pins[8] = { 1679 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 1680 }; 1681 int i; 1682 for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) 1683 if (ad1988_io_pins[i] == nid) 1684 return i; 1685 return 0; /* should be -1 */ 1686 } 1687 1688 static int ad1988_pin_to_loopback_idx(hda_nid_t nid) 1689 { 1690 static int loopback_idx[8] = { 1691 2, 0, 1, 3, 4, 5, 1, 4 1692 }; 1693 switch (nid) { 1694 case AD1988_PIN_CD_NID: 1695 return 6; 1696 default: 1697 return loopback_idx[ad1988_pin_idx(nid)]; 1698 } 1699 } 1700 1701 static int ad1988_pin_to_adc_idx(hda_nid_t nid) 1702 { 1703 static int adc_idx[8] = { 1704 0, 1, 2, 8, 4, 3, 6, 7 1705 }; 1706 switch (nid) { 1707 case AD1988_PIN_CD_NID: 1708 return 5; 1709 default: 1710 return adc_idx[ad1988_pin_idx(nid)]; 1711 } 1712 } 1713 1714 /* fill in the dac_nids table from the parsed pin configuration */ 1715 static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, 1716 const struct auto_pin_cfg *cfg) 1717 { 1718 struct ad198x_spec *spec = codec->spec; 1719 int i, idx; 1720 1721 spec->multiout.dac_nids = spec->private_dac_nids; 1722 1723 /* check the pins hardwired to audio widget */ 1724 for (i = 0; i < cfg->line_outs; i++) { 1725 idx = ad1988_pin_idx(cfg->line_out_pins[i]); 1726 spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx); 1727 } 1728 spec->multiout.num_dacs = cfg->line_outs; 1729 return 0; 1730 } 1731 1732 /* add playback controls from the parsed DAC table */ 1733 static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, 1734 const struct auto_pin_cfg *cfg) 1735 { 1736 char name[32]; 1737 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 1738 hda_nid_t nid; 1739 int i, err; 1740 1741 for (i = 0; i < cfg->line_outs; i++) { 1742 hda_nid_t dac = spec->multiout.dac_nids[i]; 1743 if (! dac) 1744 continue; 1745 nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; 1746 if (i == 2) { 1747 /* Center/LFE */ 1748 err = add_control(spec, AD_CTL_WIDGET_VOL, 1749 "Center Playback Volume", 1750 HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); 1751 if (err < 0) 1752 return err; 1753 err = add_control(spec, AD_CTL_WIDGET_VOL, 1754 "LFE Playback Volume", 1755 HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); 1756 if (err < 0) 1757 return err; 1758 err = add_control(spec, AD_CTL_BIND_MUTE, 1759 "Center Playback Switch", 1760 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); 1761 if (err < 0) 1762 return err; 1763 err = add_control(spec, AD_CTL_BIND_MUTE, 1764 "LFE Playback Switch", 1765 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); 1766 if (err < 0) 1767 return err; 1768 } else { 1769 sprintf(name, "%s Playback Volume", chname[i]); 1770 err = add_control(spec, AD_CTL_WIDGET_VOL, name, 1771 HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); 1772 if (err < 0) 1773 return err; 1774 sprintf(name, "%s Playback Switch", chname[i]); 1775 err = add_control(spec, AD_CTL_BIND_MUTE, name, 1776 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); 1777 if (err < 0) 1778 return err; 1779 } 1780 } 1781 return 0; 1782 } 1783 1784 /* add playback controls for speaker and HP outputs */ 1785 static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, 1786 const char *pfx) 1787 { 1788 struct ad198x_spec *spec = codec->spec; 1789 hda_nid_t nid; 1790 int idx, err; 1791 char name[32]; 1792 1793 if (! pin) 1794 return 0; 1795 1796 idx = ad1988_pin_idx(pin); 1797 nid = ad1988_idx_to_dac(codec, idx); 1798 if (! spec->multiout.dac_nids[0]) { 1799 /* use this as the primary output */ 1800 spec->multiout.dac_nids[0] = nid; 1801 if (! spec->multiout.num_dacs) 1802 spec->multiout.num_dacs = 1; 1803 } else 1804 /* specify the DAC as the extra output */ 1805 spec->multiout.hp_nid = nid; 1806 /* control HP volume/switch on the output mixer amp */ 1807 sprintf(name, "%s Playback Volume", pfx); 1808 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, 1809 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 1810 return err; 1811 nid = ad1988_mixer_nids[idx]; 1812 sprintf(name, "%s Playback Switch", pfx); 1813 if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, 1814 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 1815 return err; 1816 return 0; 1817 } 1818 1819 /* create input playback/capture controls for the given pin */ 1820 static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, 1821 const char *ctlname, int boost) 1822 { 1823 char name[32]; 1824 int err, idx; 1825 1826 sprintf(name, "%s Playback Volume", ctlname); 1827 idx = ad1988_pin_to_loopback_idx(pin); 1828 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, 1829 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) 1830 return err; 1831 sprintf(name, "%s Playback Switch", ctlname); 1832 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, 1833 HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) 1834 return err; 1835 if (boost) { 1836 hda_nid_t bnid; 1837 idx = ad1988_pin_idx(pin); 1838 bnid = ad1988_boost_nids[idx]; 1839 if (bnid) { 1840 sprintf(name, "%s Boost", ctlname); 1841 return add_control(spec, AD_CTL_WIDGET_VOL, name, 1842 HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); 1843 1844 } 1845 } 1846 return 0; 1847 } 1848 1849 /* create playback/capture controls for input pins */ 1850 static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, 1851 const struct auto_pin_cfg *cfg) 1852 { 1853 struct hda_input_mux *imux = &spec->private_imux; 1854 int i, err; 1855 1856 for (i = 0; i < AUTO_PIN_LAST; i++) { 1857 err = new_analog_input(spec, cfg->input_pins[i], 1858 auto_pin_cfg_labels[i], 1859 i <= AUTO_PIN_FRONT_MIC); 1860 if (err < 0) 1861 return err; 1862 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 1863 imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); 1864 imux->num_items++; 1865 } 1866 imux->items[imux->num_items].label = "Mix"; 1867 imux->items[imux->num_items].index = 9; 1868 imux->num_items++; 1869 1870 if ((err = add_control(spec, AD_CTL_WIDGET_VOL, 1871 "Analog Mix Playback Volume", 1872 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) 1873 return err; 1874 if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, 1875 "Analog Mix Playback Switch", 1876 HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) 1877 return err; 1878 1879 return 0; 1880 } 1881 1882 static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, 1883 hda_nid_t nid, int pin_type, 1884 int dac_idx) 1885 { 1886 /* set as output */ 1887 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 1888 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 1889 switch (nid) { 1890 case 0x11: /* port-A - DAC 04 */ 1891 snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); 1892 break; 1893 case 0x14: /* port-B - DAC 06 */ 1894 snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); 1895 break; 1896 case 0x15: /* port-C - DAC 05 */ 1897 snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); 1898 break; 1899 case 0x17: /* port-E - DAC 0a */ 1900 snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); 1901 break; 1902 case 0x13: /* mono - DAC 04 */ 1903 snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); 1904 break; 1905 } 1906 } 1907 1908 static void ad1988_auto_init_multi_out(struct hda_codec *codec) 1909 { 1910 struct ad198x_spec *spec = codec->spec; 1911 int i; 1912 1913 for (i = 0; i < spec->autocfg.line_outs; i++) { 1914 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 1915 ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 1916 } 1917 } 1918 1919 static void ad1988_auto_init_extra_out(struct hda_codec *codec) 1920 { 1921 struct ad198x_spec *spec = codec->spec; 1922 hda_nid_t pin; 1923 1924 pin = spec->autocfg.speaker_pin; 1925 if (pin) /* connect to front */ 1926 ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 1927 pin = spec->autocfg.hp_pin; 1928 if (pin) /* connect to front */ 1929 ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 1930 } 1931 1932 static void ad1988_auto_init_analog_input(struct hda_codec *codec) 1933 { 1934 struct ad198x_spec *spec = codec->spec; 1935 int i, idx; 1936 1937 for (i = 0; i < AUTO_PIN_LAST; i++) { 1938 hda_nid_t nid = spec->autocfg.input_pins[i]; 1939 if (! nid) 1940 continue; 1941 switch (nid) { 1942 case 0x15: /* port-C */ 1943 snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); 1944 break; 1945 case 0x17: /* port-E */ 1946 snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); 1947 break; 1948 } 1949 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 1950 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 1951 if (nid != AD1988_PIN_CD_NID) 1952 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1953 AMP_OUT_MUTE); 1954 idx = ad1988_pin_idx(nid); 1955 if (ad1988_boost_nids[idx]) 1956 snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, 1957 AC_VERB_SET_AMP_GAIN_MUTE, 1958 AMP_OUT_ZERO); 1959 } 1960 } 1961 1962 /* parse the BIOS configuration and set up the alc_spec */ 1963 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 1964 static int ad1988_parse_auto_config(struct hda_codec *codec) 1965 { 1966 struct ad198x_spec *spec = codec->spec; 1967 int err; 1968 1969 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) 1970 return err; 1971 if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) 1972 return err; 1973 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 1974 ! spec->autocfg.hp_pin) 1975 return 0; /* can't find valid BIOS pin config */ 1976 if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 1977 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, 1978 "Speaker")) < 0 || 1979 (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, 1980 "Headphone")) < 0 || 1981 (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 1982 return err; 1983 1984 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 1985 1986 if (spec->autocfg.dig_out_pin) 1987 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 1988 if (spec->autocfg.dig_in_pin) 1989 spec->dig_in_nid = AD1988_SPDIF_IN; 1990 1991 if (spec->kctl_alloc) 1992 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 1993 1994 spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; 1995 1996 spec->input_mux = &spec->private_imux; 1997 1998 return 1; 1999 } 2000 2001 /* init callback for auto-configuration model -- overriding the default init */ 2002 static int ad1988_auto_init(struct hda_codec *codec) 2003 { 2004 ad198x_init(codec); 2005 ad1988_auto_init_multi_out(codec); 2006 ad1988_auto_init_extra_out(codec); 2007 ad1988_auto_init_analog_input(codec); 2008 return 0; 2009 } 2010 2011 2012 /* 2013 */ 2014 2015 static struct hda_board_config ad1988_cfg_tbl[] = { 2016 { .modelname = "6stack", .config = AD1988_6STACK }, 2017 { .modelname = "6stack-dig", .config = AD1988_6STACK_DIG }, 2018 { .modelname = "3stack", .config = AD1988_3STACK }, 2019 { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG }, 2020 { .modelname = "laptop", .config = AD1988_LAPTOP }, 2021 { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG }, 2022 { .modelname = "auto", .config = AD1988_AUTO }, 2023 {0} 2024 }; 2025 2026 static int patch_ad1988(struct hda_codec *codec) 2027 { 2028 struct ad198x_spec *spec; 2029 int board_config; 2030 2031 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2032 if (spec == NULL) 2033 return -ENOMEM; 2034 2035 init_MUTEX(&spec->amp_mutex); 2036 codec->spec = spec; 2037 2038 if (codec->revision_id == AD1988A_REV2) 2039 snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); 2040 2041 board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); 2042 if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { 2043 printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); 2044 board_config = AD1988_AUTO; 2045 } 2046 2047 if (board_config == AD1988_AUTO) { 2048 /* automatic parse from the BIOS config */ 2049 int err = ad1988_parse_auto_config(codec); 2050 if (err < 0) { 2051 ad198x_free(codec); 2052 return err; 2053 } else if (! err) { 2054 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); 2055 board_config = AD1988_6STACK; 2056 } 2057 } 2058 2059 switch (board_config) { 2060 case AD1988_6STACK: 2061 case AD1988_6STACK_DIG: 2062 spec->multiout.max_channels = 8; 2063 spec->multiout.num_dacs = 4; 2064 if (codec->revision_id == AD1988A_REV2) 2065 spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; 2066 else 2067 spec->multiout.dac_nids = ad1988_6stack_dac_nids; 2068 spec->input_mux = &ad1988_6stack_capture_source; 2069 spec->num_mixers = 2; 2070 if (codec->revision_id == AD1988A_REV2) 2071 spec->mixers[0] = ad1988_6stack_mixers1_rev2; 2072 else 2073 spec->mixers[0] = ad1988_6stack_mixers1; 2074 spec->mixers[1] = ad1988_6stack_mixers2; 2075 spec->num_init_verbs = 1; 2076 spec->init_verbs[0] = ad1988_6stack_init_verbs; 2077 if (board_config == AD1988_6STACK_DIG) { 2078 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 2079 spec->dig_in_nid = AD1988_SPDIF_IN; 2080 } 2081 break; 2082 case AD1988_3STACK: 2083 case AD1988_3STACK_DIG: 2084 spec->multiout.max_channels = 6; 2085 spec->multiout.num_dacs = 3; 2086 if (codec->revision_id == AD1988A_REV2) 2087 spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; 2088 else 2089 spec->multiout.dac_nids = ad1988_3stack_dac_nids; 2090 spec->input_mux = &ad1988_6stack_capture_source; 2091 spec->channel_mode = ad1988_3stack_modes; 2092 spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); 2093 spec->num_mixers = 2; 2094 if (codec->revision_id == AD1988A_REV2) 2095 spec->mixers[0] = ad1988_3stack_mixers1_rev2; 2096 else 2097 spec->mixers[0] = ad1988_3stack_mixers1; 2098 spec->mixers[1] = ad1988_3stack_mixers2; 2099 spec->num_init_verbs = 1; 2100 spec->init_verbs[0] = ad1988_3stack_init_verbs; 2101 if (board_config == AD1988_3STACK_DIG) 2102 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 2103 break; 2104 case AD1988_LAPTOP: 2105 case AD1988_LAPTOP_DIG: 2106 spec->multiout.max_channels = 2; 2107 spec->multiout.num_dacs = 1; 2108 spec->multiout.dac_nids = ad1988_3stack_dac_nids; 2109 spec->input_mux = &ad1988_laptop_capture_source; 2110 spec->num_mixers = 1; 2111 spec->mixers[0] = ad1988_laptop_mixers; 2112 spec->num_init_verbs = 1; 2113 spec->init_verbs[0] = ad1988_laptop_init_verbs; 2114 if (board_config == AD1988_LAPTOP_DIG) 2115 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 2116 break; 2117 } 2118 2119 spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); 2120 spec->adc_nids = ad1988_adc_nids; 2121 spec->capsrc_nids = ad1988_capsrc_nids; 2122 spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; 2123 spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; 2124 if (spec->multiout.dig_out_nid) { 2125 spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; 2126 spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; 2127 } 2128 if (spec->dig_in_nid) 2129 spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; 2130 2131 codec->patch_ops = ad198x_patch_ops; 2132 switch (board_config) { 2133 case AD1988_AUTO: 2134 codec->patch_ops.init = ad1988_auto_init; 2135 break; 2136 case AD1988_LAPTOP: 2137 case AD1988_LAPTOP_DIG: 2138 codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; 2139 break; 2140 } 2141 2142 return 0; 2143 } 2144 2145 793 2146 /* 794 2147 * patch entries 795 2148 */ 796 2149 struct hda_codec_preset snd_hda_preset_analog[] = { 797 { /*.id = */0x11d41981, 0, 0, 0, 0,/*.name = */"AD1981", /*.patch = */patch_ad1981 }, 798 { /*.id = */0x11d41983, 0, 0, 0, 0,/*.name = */"AD1983", /*.patch = */patch_ad1983 }, 799 { /*.id = */0x11d41986, 0, 0, 0, 0,/*.name = */"AD1986A", /*.patch = */patch_ad1986a }, 800 {0} /* terminator */ 801 }; 2150 { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, 2151 { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, 2152 { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, 2153 { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, 2154 {0} /* terminator */ 2155 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_cmedia.c
r32 r69 30 30 #include "hda_codec.h" 31 31 #include "hda_local.h" 32 33 #define NUM_PINS 11 32 #define NUM_PINS 11 33 34 34 35 35 /* board config type */ … … 39 39 CMI_FULL, /* back 6-jack + front-panel 2-jack */ 40 40 CMI_FULL_DIG, /* back 6-jack + front-panel 2-jack + digital I/O */ 41 CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */42 CMI_AUTO,/* let driver guess it */41 CMI_ALLOUT, /* back 5-jack + front-panel 2-jack + digital out */ 42 CMI_AUTO, /* let driver guess it */ 43 43 }; 44 44 45 45 struct cmi_spec { 46 46 int board_config; 47 unsigned int surr_switch: 1; /* switchable line,mic */48 47 unsigned int no_line_in: 1; /* no line-in (5-jack) */ 49 48 unsigned int front_panel: 1; /* has front-panel 2-jack */ 50 49 51 50 /* playback */ 52 struct hda_multi_out multiout; 53 hda_nid_t dac_nids[4]; /* NID for each DAC */ 51 struct hda_multi_out multiout; 52 hda_nid_t dac_nids[4]; /* NID for each DAC */ 53 int num_dacs; 54 54 55 55 /* capture */ … … 62 62 63 63 /* channel mode */ 64 unsigned int num_ch_modes; 65 unsigned int cur_ch_mode; 66 const struct cmi_channel_mode *channel_modes; 67 68 struct hda_pcm pcm_rec[2]; /* PCM information */ 69 70 /* pin deafault configuration */ 71 hda_nid_t pin_nid[NUM_PINS]; 72 unsigned int def_conf[NUM_PINS]; 73 unsigned int pin_def_confs; 74 75 /* multichannel pins */ 76 hda_nid_t multich_pin[4]; /* max 8-channel */ 77 struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */ 64 int num_channel_modes; 65 const struct hda_channel_mode *channel_modes; 66 67 struct hda_pcm pcm_rec[2]; /* PCM information */ 68 69 /* pin deafault configuration */ 70 hda_nid_t pin_nid[NUM_PINS]; 71 unsigned int def_conf[NUM_PINS]; 72 unsigned int pin_def_confs; 73 74 /* multichannel pins */ 75 hda_nid_t multich_pin[4]; /* max 8-channel */ 76 struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */ 78 77 }; 79 78 … … 81 80 * input MUX 82 81 */ 83 static int cmi_mux_enum_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)82 static int cmi_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 84 83 { 85 84 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 88 87 } 89 88 90 static int cmi_mux_enum_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)89 static int cmi_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 91 90 { 92 91 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 98 97 } 99 98 100 static int cmi_mux_enum_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)99 static int cmi_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 101 100 { 102 101 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 115 114 static struct hda_verb cmi9880_ch2_init[] = { 116 115 /* set line-in PIN for input */ 117 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},116 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 118 117 /* set mic PIN for input, also enable vref */ 119 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},118 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 120 119 /* route front PCM (DAC1) to HP */ 121 120 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, … … 125 124 /* 3-stack / 6 channel */ 126 125 static struct hda_verb cmi9880_ch6_init[] = { 127 /* set line-in PIN for output */128 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},129 /* set mic PIN for output */130 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},126 /* set line-in PIN for output */ 127 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 128 /* set mic PIN for output */ 129 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 131 130 /* route front PCM (DAC1) to HP */ 132 131 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, … … 136 135 /* 3-stack+front / 8 channel */ 137 136 static struct hda_verb cmi9880_ch8_init[] = { 138 /* set line-in PIN for output */139 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},140 /* set mic PIN for output */141 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},137 /* set line-in PIN for output */ 138 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 139 /* set mic PIN for output */ 140 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 142 141 /* route rear-surround PCM (DAC4) to HP */ 143 142 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x03 }, … … 145 144 }; 146 145 147 struct cmi_channel_mode { 148 unsigned int channels; 149 const struct hda_verb *sequence; 150 }; 151 152 static struct cmi_channel_mode cmi9880_channel_modes[3] = { 146 static struct hda_channel_mode cmi9880_channel_modes[3] = { 153 147 { 2, cmi9880_ch2_init }, 154 148 { 6, cmi9880_ch6_init }, … … 156 150 }; 157 151 158 static int cmi_ch_mode_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)152 static int cmi_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 159 153 { 160 154 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 161 155 struct cmi_spec *spec = codec->spec; 162 163 snd_assert(spec->channel_modes, return -EINVAL); 164 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 165 uinfo->count = 1; 166 uinfo->value.enumerated.items = spec->num_ch_modes; 167 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) 168 uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; 169 sprintf(uinfo->value.enumerated.name, "%dch", 170 spec->channel_modes[uinfo->value.enumerated.item].channels); 171 return 0; 172 } 173 174 static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 156 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_modes, 157 spec->num_channel_modes); 158 } 159 160 static int cmi_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 175 161 { 176 162 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 177 163 struct cmi_spec *spec = codec->spec; 178 179 ucontrol->value.enumerated.item[0] = spec->cur_ch_mode; 180 return 0; 181 } 182 183 static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 164 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_modes, 165 spec->num_channel_modes, spec->multiout.max_channels); 166 } 167 168 static int cmi_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 184 169 { 185 170 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 186 171 struct cmi_spec *spec = codec->spec; 187 188 snd_assert(spec->channel_modes, return -EINVAL); 189 if (ucontrol->value.enumerated.item[0] >= spec->num_ch_modes) 190 ucontrol->value.enumerated.item[0] = spec->num_ch_modes; 191 if (ucontrol->value.enumerated.item[0] == spec->cur_ch_mode && 192 ! codec->in_resume) 193 return 0; 194 195 spec->cur_ch_mode = ucontrol->value.enumerated.item[0]; 196 snd_hda_sequence_write(codec, spec->channel_modes[spec->cur_ch_mode].sequence); 197 spec->multiout.max_channels = spec->channel_modes[spec->cur_ch_mode].channels; 198 return 1; 199 } 200 201 /* 202 */ 203 static snd_kcontrol_new_t cmi9880_basic_mixer[] = { 172 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_modes, 173 spec->num_channel_modes, &spec->multiout.max_channels); 174 } 175 176 /* 177 */ 178 static struct snd_kcontrol_new cmi9880_basic_mixer[] = { 204 179 /* CMI9880 has no playback volumes! */ 205 180 HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), /* front */ … … 209 184 HDA_CODEC_MUTE("Side Playback Switch", 0x06, 0x0, HDA_OUTPUT), 210 185 { 211 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 212 187 /* The multiple "Capture Source" controls confuse alsamixer 213 188 * So call somewhat different.. … … 215 190 */ 216 191 /* .name = "Capture Source", */ 217 /*.name = */"Input Source",0,0,218 /*.count = */2,219 /*.info = */cmi_mux_enum_info,220 /*.get = */cmi_mux_enum_get,221 /*.put = */cmi_mux_enum_put,0192 .name = "Input Source", 193 .count = 2, 194 .info = cmi_mux_enum_info, 195 .get = cmi_mux_enum_get, 196 .put = cmi_mux_enum_put, 222 197 }, 223 198 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0, HDA_INPUT), … … 233 208 * shared I/O pins 234 209 */ 235 static s nd_kcontrol_new_tcmi9880_ch_mode_mixer[] = {210 static struct snd_kcontrol_new cmi9880_ch_mode_mixer[] = { 236 211 { 237 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,238 /*.name = */"Channel Mode",0,0,0,239 /*.info = */cmi_ch_mode_info,240 /*.get = */cmi_ch_mode_get,241 /*.put = */cmi_ch_mode_put,212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 213 .name = "Channel Mode", 214 .info = cmi_ch_mode_info, 215 .get = cmi_ch_mode_get, 216 .put = cmi_ch_mode_put, 242 217 }, 243 218 {0} /* end */ … … 248 223 */ 249 224 static struct hda_input_mux cmi9880_basic_mux = { 250 /*.num_items = */4,251 /*.items = */{225 .num_items = 4, 226 .items = { 252 227 { "Front Mic", 0x5 }, 253 228 { "Rear Mic", 0x2 }, … … 258 233 259 234 static struct hda_input_mux cmi9880_no_line_mux = { 260 /*.num_items = */3,261 /*.items = */{235 .num_items = 3, 236 .items = { 262 237 { "Front Mic", 0x5 }, 263 238 { "Rear Mic", 0x2 }, … … 282 257 static struct hda_verb cmi9880_basic_init[] = { 283 258 /* port-D for line out (rear panel) */ 284 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},259 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 285 260 /* port-E for HP out (front panel) */ 286 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},261 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 287 262 /* route front PCM to HP */ 288 263 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 289 264 /* port-A for surround (rear panel) */ 290 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},265 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 291 266 /* port-G for CLFE (rear panel) */ 292 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},293 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 },267 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 268 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 }, 294 269 /* port-H for side (rear panel) */ 295 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},296 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 },270 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 271 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 }, 297 272 /* port-C for line-in (rear panel) */ 298 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},273 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 299 274 /* port-B for mic-in (rear panel) with vref */ 300 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},275 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 301 276 /* port-F for mic-in (front panel) with vref */ 302 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},277 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 303 278 /* CD-in */ 304 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},279 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 305 280 /* route front mic to ADC1/2 */ 306 281 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, … … 311 286 static struct hda_verb cmi9880_allout_init[] = { 312 287 /* port-D for line out (rear panel) */ 313 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},288 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 314 289 /* port-E for HP out (front panel) */ 315 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},290 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 316 291 /* route front PCM to HP */ 317 292 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 318 293 /* port-A for side (rear panel) */ 319 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},294 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 320 295 /* port-G for CLFE (rear panel) */ 321 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},322 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 },323 /* port-H for side (rear panel) */324 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},325 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 },296 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 297 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x02 }, 298 /* port-H for side (rear panel) */ 299 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 300 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x01 }, 326 301 /* port-C for surround (rear panel) */ 327 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},302 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 328 303 /* port-B for mic-in (rear panel) with vref */ 329 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},304 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 330 305 /* port-F for mic-in (front panel) with vref */ 331 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},306 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 332 307 /* CD-in */ 333 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},308 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 334 309 /* route front mic to ADC1/2 */ 335 310 { 0x08, AC_VERB_SET_CONNECT_SEL, 0x05 }, … … 348 323 if (err < 0) 349 324 return err; 350 if (spec-> surr_switch) {325 if (spec->channel_modes) { 351 326 err = snd_hda_add_new_ctls(codec, cmi9880_ch_mode_mixer); 352 327 if (err < 0) 353 328 return err; 354 329 } 355 if (spec->multiout.dig_out_nid) { 356 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 357 if (err < 0) 358 return err; 359 } 360 if (spec->dig_in_nid) { 361 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 362 if (err < 0) 363 return err; 364 } 365 return 0; 366 } 367 368 #define get_defcfg_connect(cfg) ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) 369 #define get_defcfg_association(cfg) ((cfg & AC_DEFCFG_DEF_ASSOC) >> AC_DEFCFG_ASSOC_SHIFT) 370 #define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE) 371 372 /* get all pin default configuration in def_conf */ 373 static int cmi9880_get_pin_def_config(struct hda_codec *codec) 374 { 375 struct cmi_spec *spec = codec->spec; 376 hda_nid_t nid, nid_start; 377 int i = 0, nodes; 378 379 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); 380 for (nid = nid_start; nid < nodes + nid_start; nid++) { 381 unsigned int wid_caps = snd_hda_param_read(codec, nid, 382 AC_PAR_AUDIO_WIDGET_CAP); 383 unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 384 /* read all default configuration for pin complex */ 385 if (wid_type == AC_WID_PIN) { 386 spec->pin_nid[i] = nid; 387 spec->def_conf[i] = 388 snd_hda_codec_read(codec, nid, 0, 389 AC_VERB_GET_CONFIG_DEFAULT, 0); 390 i++; 391 } 392 } 393 spec->pin_def_confs = i; 394 return 0; 395 } 396 397 /* get a pin default configuration of nid in def_conf */ 398 static unsigned int cmi9880_get_def_config(struct hda_codec *codec, hda_nid_t nid) 399 { 400 struct cmi_spec *spec = codec->spec; 401 int i = 0; 402 403 while (spec->pin_nid[i] != nid && i < spec->pin_def_confs) 404 i++; 405 if (i == spec->pin_def_confs) 406 return (unsigned int) -1; 407 else 408 return spec->def_conf[i]; 409 } 410 411 /* decide what pins to use for multichannel playback */ 412 static int cmi9880_get_multich_pins(struct hda_codec *codec) 413 { 414 struct cmi_spec *spec = codec->spec; 415 int i, j, pins, seq[4]; 416 int max_channel = 0; 417 unsigned int def_conf, sequence; 418 hda_nid_t nid; 419 420 memset(spec->multich_pin, 0, sizeof(spec->multich_pin)); 421 for (pins = 0, i = 0; i < spec->pin_def_confs && pins < 4; i++) { 422 def_conf = spec->def_conf[i]; 423 /* skip pin not connected */ 424 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 425 continue; 426 /* get the sequence if association == 1 */ 427 /* the other pins have association = 0, incorrect in spec 1.0 */ 428 if (get_defcfg_association(def_conf) == 1) { 429 sequence = get_defcfg_sequence(def_conf); 430 seq[pins] = sequence; 431 spec->multich_pin[pins] = spec->pin_nid[i]; 432 pins++; // ready for next slot 433 max_channel += 2; 434 } 435 } 436 /* sort by sequence, data collected here will be for Windows */ 437 for (i = 0; i < pins; i++) { 438 for (j = i + 1; j < pins; j++) { 439 if (seq[j] < seq[i]) { 440 sequence = seq[j]; 441 nid = spec->multich_pin[j]; 442 seq[j] = seq[i]; 443 spec->multich_pin[j] = spec->multich_pin[i]; 444 seq[i] = sequence; 445 spec->multich_pin[i] = nid; 446 } 447 } 448 } 449 /* the pin assignment is for front, C/LFE, surround and back */ 450 if (max_channel >= 6) { 451 hda_nid_t temp; 452 /* exchange pin of C/LFE and surround */ 453 temp = spec->multich_pin[1]; 454 spec->multich_pin[1] = spec->multich_pin[2]; 455 spec->multich_pin[2] = temp; 456 } 457 return max_channel; 330 if (spec->multiout.dig_out_nid) { 331 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 332 if (err < 0) 333 return err; 334 } 335 if (spec->dig_in_nid) { 336 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 337 if (err < 0) 338 return err; 339 } 340 return 0; 458 341 } 459 342 460 343 /* fill in the multi_dac_nids table, which will decide 461 which audio widget to use for each channel */ 462 static int cmi9880_fill_multi_dac_nids(struct hda_codec *codec) 463 { 464 struct cmi_spec *spec = codec->spec; 465 hda_nid_t nid; 466 int assigned[4]; 467 int i, j; 468 469 /* clear the table, only one c-media dac assumed here */ 470 memset(spec->dac_nids, 0, sizeof(spec->dac_nids)); 471 memset(assigned, 0, sizeof(assigned)); 472 /* check the pins we found */ 473 for (i = 0; i < spec->multiout.max_channels / 2; i++) { 474 nid = spec->multich_pin[i]; 475 /* nid 0x0b~0x0e is hardwired to audio widget 0x3~0x6 */ 476 if (nid <= 0x0e && nid >= 0x0b) { 477 spec->dac_nids[i] = nid - 0x08; 478 assigned[nid - 0x0b] = 1; 479 } 480 } 481 /* left pin can be connect to any audio widget */ 482 for (i = 0; i < spec->multiout.max_channels / 2; i++) { 483 if (!assigned[i]) { 484 /* search for an empty channel */ 485 /* I should also check the pin type */ 486 for (j = 0; j < ARRAY_SIZE(spec->dac_nids); j++) 487 if (! spec->dac_nids[j]) { 488 spec->dac_nids[j] = i + 3; 489 assigned[i] = 1; 490 break; 491 } 492 } 493 } 494 return 0; 344 which audio widget to use for each channel */ 345 static int cmi9880_fill_multi_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 346 { 347 struct cmi_spec *spec = codec->spec; 348 hda_nid_t nid; 349 int assigned[4]; 350 int i, j; 351 352 /* clear the table, only one c-media dac assumed here */ 353 memset(spec->dac_nids, 0, sizeof(spec->dac_nids)); 354 memset(assigned, 0, sizeof(assigned)); 355 /* check the pins we found */ 356 for (i = 0; i < cfg->line_outs; i++) { 357 nid = cfg->line_out_pins[i]; 358 /* nid 0x0b~0x0e is hardwired to audio widget 0x3~0x6 */ 359 if (nid >= 0x0b && nid <= 0x0e) { 360 spec->dac_nids[i] = (nid - 0x0b) + 0x03; 361 assigned[nid - 0x0b] = 1; 362 } 363 } 364 /* left pin can be connect to any audio widget */ 365 for (i = 0; i < cfg->line_outs; i++) { 366 nid = cfg->line_out_pins[i]; 367 if (nid <= 0x0e) 368 continue; 369 /* search for an empty channel */ 370 for (j = 0; j < cfg->line_outs; j++) { 371 if (! assigned[j]) { 372 spec->dac_nids[i] = j + 0x03; 373 assigned[j] = 1; 374 break; 375 } 376 } 377 } 378 spec->num_dacs = cfg->line_outs; 379 return 0; 495 380 } 496 381 497 382 /* create multi_init table, which is used for multichannel initialization */ 498 static int cmi9880_fill_multi_init(struct hda_codec *codec) 499 { 500 struct cmi_spec *spec = codec->spec; 501 hda_nid_t nid; 502 int i, j, k, len; 503 504 /* clear the table, only one c-media dac assumed here */ 505 memset(spec->multi_init, 0, sizeof(spec->multi_init)); 506 for (j = 0, i = 0; i < spec->multiout.max_channels / 2; i++) { 507 hda_nid_t conn[4]; 508 nid = spec->multich_pin[i]; 509 /* set as output */ 510 spec->multi_init[j].nid = nid; 511 spec->multi_init[j].verb = AC_VERB_SET_PIN_WIDGET_CONTROL; 512 spec->multi_init[j].param = 0xc0; 513 j++; 514 /* nid 0x0f,0x10,0x1f,0x20 are needed to set connection */ 515 switch (nid) { 516 case 0x0f: 517 case 0x10: 518 case 0x1f: 519 case 0x20: 520 /* set connection */ 521 spec->multi_init[j].nid = nid; 522 spec->multi_init[j].verb = AC_VERB_SET_CONNECT_SEL; 523 /* find the index in connect list */ 524 len = snd_hda_get_connections(codec, nid, conn, 4); 525 for (k = 0; k < len; k++) 526 if (conn[k] == spec->dac_nids[i]) 527 break; 528 spec->multi_init[j].param = k < len ? k : 0; 529 j++; 530 break; 531 } 532 } 533 return 0; 383 static int cmi9880_fill_multi_init(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 384 { 385 struct cmi_spec *spec = codec->spec; 386 hda_nid_t nid; 387 int i, j, k, len; 388 389 /* clear the table, only one c-media dac assumed here */ 390 memset(spec->multi_init, 0, sizeof(spec->multi_init)); 391 for (j = 0, i = 0; i < cfg->line_outs; i++) { 392 hda_nid_t conn[4]; 393 nid = cfg->line_out_pins[i]; 394 /* set as output */ 395 spec->multi_init[j].nid = nid; 396 spec->multi_init[j].verb = AC_VERB_SET_PIN_WIDGET_CONTROL; 397 spec->multi_init[j].param = PIN_OUT; 398 j++; 399 if (nid > 0x0e) { 400 /* set connection */ 401 spec->multi_init[j].nid = nid; 402 spec->multi_init[j].verb = AC_VERB_SET_CONNECT_SEL; 403 spec->multi_init[j].param = 0; 404 /* find the index in connect list */ 405 len = snd_hda_get_connections(codec, nid, conn, 4); 406 for (k = 0; k < len; k++) 407 if (conn[k] == spec->dac_nids[i]) { 408 spec->multi_init[j].param = k; 409 break; 410 } 411 j++; 412 } 413 } 414 return 0; 534 415 } 535 416 … … 540 421 snd_hda_sequence_write(codec, cmi9880_allout_init); 541 422 else 542 snd_hda_sequence_write(codec, cmi9880_basic_init);543 if (spec->board_config == CMI_AUTO)544 snd_hda_sequence_write(codec, spec->multi_init);423 snd_hda_sequence_write(codec, cmi9880_basic_init); 424 if (spec->board_config == CMI_AUTO) 425 snd_hda_sequence_write(codec, spec->multi_init); 545 426 return 0; 546 427 } … … 556 437 cmi9880_init(codec); 557 438 snd_hda_resume_ctls(codec, cmi9880_basic_mixer); 558 if (spec-> surr_switch)439 if (spec->channel_modes) 559 440 snd_hda_resume_ctls(codec, cmi9880_ch_mode_mixer); 560 441 if (spec->multiout.dig_out_nid) 561 snd_hda_resume_spdif_out(codec);562 if (spec->dig_in_nid)563 snd_hda_resume_spdif_in(codec);442 snd_hda_resume_spdif_out(codec); 443 if (spec->dig_in_nid) 444 snd_hda_resume_spdif_in(codec); 564 445 565 446 return 0; … … 572 453 static int cmi9880_playback_pcm_open(struct hda_pcm_stream *hinfo, 573 454 struct hda_codec *codec, 574 s nd_pcm_substream_t*substream)455 struct snd_pcm_substream *substream) 575 456 { 576 457 struct cmi_spec *spec = codec->spec; … … 582 463 unsigned int stream_tag, 583 464 unsigned int format, 584 s nd_pcm_substream_t*substream)465 struct snd_pcm_substream *substream) 585 466 { 586 467 struct cmi_spec *spec = codec->spec; … … 591 472 static int cmi9880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 592 473 struct hda_codec *codec, 593 s nd_pcm_substream_t*substream)474 struct snd_pcm_substream *substream) 594 475 { 595 476 struct cmi_spec *spec = codec->spec; … … 602 483 static int cmi9880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 603 484 struct hda_codec *codec, 604 s nd_pcm_substream_t*substream)485 struct snd_pcm_substream *substream) 605 486 { 606 487 struct cmi_spec *spec = codec->spec; … … 610 491 static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 611 492 struct hda_codec *codec, 612 s nd_pcm_substream_t*substream)493 struct snd_pcm_substream *substream) 613 494 { 614 495 struct cmi_spec *spec = codec->spec; … … 623 504 unsigned int stream_tag, 624 505 unsigned int format, 625 s nd_pcm_substream_t*substream)506 struct snd_pcm_substream *substream) 626 507 { 627 508 struct cmi_spec *spec = codec->spec; … … 634 515 static int cmi9880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 635 516 struct hda_codec *codec, 636 s nd_pcm_substream_t*substream)517 struct snd_pcm_substream *substream) 637 518 { 638 519 struct cmi_spec *spec = codec->spec; … … 646 527 */ 647 528 static struct hda_pcm_stream cmi9880_pcm_analog_playback = { 648 /*.substreams = */1, 649 /*.channels_min = */2, 650 /*.channels_max = */8, 651 /*.nid = */0x03, /* NID to query formats and rates */ 652 0,0,0, 653 /*.ops = */{ 654 /*.open = */cmi9880_playback_pcm_open,0, 655 /*.prepare = */cmi9880_playback_pcm_prepare, 656 /*.cleanup = */cmi9880_playback_pcm_cleanup 529 .substreams = 1, 530 .channels_min = 2, 531 .channels_max = 8, 532 .nid = 0x03, /* NID to query formats and rates */ 533 .ops = { 534 .open = cmi9880_playback_pcm_open, 535 .prepare = cmi9880_playback_pcm_prepare, 536 .cleanup = cmi9880_playback_pcm_cleanup 657 537 }, 658 538 }; 659 539 660 540 static struct hda_pcm_stream cmi9880_pcm_analog_capture = { 661 /*.substreams = */2, 662 /*.channels_min = */2, 663 /*.channels_max = */2, 664 /*.nid = */0x08, /* NID to query formats and rates */ 665 0,0,0, 666 /*.ops = */{ 667 0,0, 668 /*.prepare = */cmi9880_capture_pcm_prepare, 669 /*.cleanup = */cmi9880_capture_pcm_cleanup 541 .substreams = 2, 542 .channels_min = 2, 543 .channels_max = 2, 544 .nid = 0x08, /* NID to query formats and rates */ 545 .ops = { 546 .prepare = cmi9880_capture_pcm_prepare, 547 .cleanup = cmi9880_capture_pcm_cleanup 670 548 }, 671 549 }; 672 550 673 551 static struct hda_pcm_stream cmi9880_pcm_digital_playback = { 674 /*.substreams = */1, 675 /*.channels_min = */2, 676 /*.channels_max = */2, 677 /* NID is set in cmi9880_build_pcms */ 678 0,0,0,0, 679 /*.ops = */{ 680 /*.open = */cmi9880_dig_playback_pcm_open, 681 /*.close = */cmi9880_dig_playback_pcm_close,0,0 552 .substreams = 1, 553 .channels_min = 2, 554 .channels_max = 2, 555 /* NID is set in cmi9880_build_pcms */ 556 .ops = { 557 .open = cmi9880_dig_playback_pcm_open, 558 .close = cmi9880_dig_playback_pcm_close 682 559 }, 683 560 }; 684 561 685 562 static struct hda_pcm_stream cmi9880_pcm_digital_capture = { 686 /*.substreams = */1,687 /*.channels_min = */2,688 /*.channels_max = */2,563 .substreams = 1, 564 .channels_min = 2, 565 .channels_max = 2, 689 566 /* NID is set in cmi9880_build_pcms */ 690 567 }; … … 728 605 729 606 static struct hda_board_config cmi9880_cfg_tbl[] = { 730 { "minimal", CMI_MINIMAL, 0, 0 }, 731 { "min_fp", CMI_MIN_FP, 0, 0 }, 732 { "full", CMI_FULL, 0, 0 }, 733 { "full_dig",CMI_FULL_DIG, 0, 0 }, 734 { "allout", CMI_ALLOUT, 0, 0 }, 735 { "auto", CMI_AUTO, 0, 0 }, 607 { .modelname = "minimal", .config = CMI_MINIMAL }, 608 { .modelname = "min_fp", .config = CMI_MIN_FP }, 609 { .modelname = "full", .config = CMI_FULL }, 610 { .modelname = "full_dig", .config = CMI_FULL_DIG }, 611 { .pci_subvendor = 0x1043, .pci_subdevice = 0x813d, .config = CMI_FULL_DIG }, /* ASUS P5AD2 */ 612 { .modelname = "allout", .config = CMI_ALLOUT }, 613 { .modelname = "auto", .config = CMI_AUTO }, 736 614 {0} /* terminator */ 737 615 }; 738 616 739 617 static struct hda_codec_ops cmi9880_patch_ops = { 740 /*.build_controls = */cmi9880_build_controls,741 /*.build_pcms = */cmi9880_build_pcms,742 /*.init = */cmi9880_init,743 /*.free = */cmi9880_free,0,618 .build_controls = cmi9880_build_controls, 619 .build_pcms = cmi9880_build_pcms, 620 .init = cmi9880_init, 621 .free = cmi9880_free, 744 622 #ifdef CONFIG_PM 745 0, 746 /*.resume = */cmi9880_resume, 623 .resume = cmi9880_resume, 747 624 #endif 748 625 }; … … 752 629 struct cmi_spec *spec; 753 630 754 spec = k calloc(1,sizeof(*spec), GFP_KERNEL);631 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 755 632 if (spec == NULL) 756 633 return -ENOMEM; … … 759 636 spec->board_config = snd_hda_check_board_config(codec, cmi9880_cfg_tbl); 760 637 if (spec->board_config < 0) { 761 snd_printd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); 762 spec->board_config = CMI_AUTO; /* try everything */ 763 } 764 765 /* copy default DAC NIDs */ 766 memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids)); 638 snd_printdd(KERN_INFO "hda_codec: Unknown model for CMI9880\n"); 639 spec->board_config = CMI_AUTO; /* try everything */ 640 } 641 642 /* copy default DAC NIDs */ 643 memcpy(spec->dac_nids, cmi9880_dac_nids, sizeof(spec->dac_nids)); 644 spec->num_dacs = 4; 767 645 768 646 switch (spec->board_config) { 769 647 case CMI_MINIMAL: 770 648 case CMI_MIN_FP: 771 spec-> surr_switch = 1;649 spec->channel_modes = cmi9880_channel_modes; 772 650 if (spec->board_config == CMI_MINIMAL) 773 spec->num_ch _modes = 2;651 spec->num_channel_modes = 2; 774 652 else { 775 653 spec->front_panel = 1; 776 spec->num_ch_modes = 3; 777 } 778 spec->channel_modes = cmi9880_channel_modes; 654 spec->num_channel_modes = 3; 655 } 779 656 spec->multiout.max_channels = cmi9880_channel_modes[0].channels; 780 657 spec->input_mux = &cmi9880_basic_mux; … … 796 673 spec->input_mux = &cmi9880_no_line_mux; 797 674 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; 798 break; 799 case CMI_AUTO: 800 { 801 unsigned int port_e, port_f, port_g, port_h; 802 unsigned int port_spdifi, port_spdifo; 803 int max_channels; 804 /* collect pin default configuration */ 805 cmi9880_get_pin_def_config(codec); 806 port_e = cmi9880_get_def_config(codec, 0x0f); 807 port_f = cmi9880_get_def_config(codec, 0x10); 808 port_g = cmi9880_get_def_config(codec, 0x1f); 809 port_h = cmi9880_get_def_config(codec, 0x20); 810 port_spdifi = cmi9880_get_def_config(codec, 0x13); 811 port_spdifo = cmi9880_get_def_config(codec, 0x12); 812 spec->front_panel = 1; 813 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || 814 get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { 815 spec->surr_switch = 1; 816 /* no front panel */ 817 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || 818 get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) { 819 /* no optional rear panel */ 820 spec->board_config = CMI_MINIMAL; 821 spec->front_panel = 0; 822 spec->num_ch_modes = 2; 823 } else { 824 spec->board_config = CMI_MIN_FP; 825 spec->num_ch_modes = 3; 826 } 827 spec->channel_modes = cmi9880_channel_modes; 828 spec->input_mux = &cmi9880_basic_mux; 829 spec->multiout.max_channels = cmi9880_channel_modes[0].channels; 830 } else { 831 spec->input_mux = &cmi9880_basic_mux; 832 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) 833 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; 834 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) 835 spec->dig_in_nid = CMI_DIG_IN_NID; 836 spec->multiout.max_channels = 8; 837 } 838 max_channels = cmi9880_get_multich_pins(codec); 839 if (max_channels > 0) { 840 spec->multiout.max_channels = max_channels; 841 cmi9880_fill_multi_dac_nids(codec); 842 cmi9880_fill_multi_init(codec); 843 } else 844 snd_printd("patch_cmedia: cannot detect association in defcfg\n"); 845 break; 846 } 847 } 848 849 spec->multiout.num_dacs = 4; 850 spec->multiout.dac_nids = spec->dac_nids; 675 break; 676 case CMI_AUTO: 677 { 678 unsigned int port_e, port_f, port_g, port_h; 679 unsigned int port_spdifi, port_spdifo; 680 struct auto_pin_cfg cfg; 681 682 /* collect pin default configuration */ 683 port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 684 port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 685 spec->front_panel = 1; 686 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || 687 get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { 688 port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 689 port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 690 spec->channel_modes = cmi9880_channel_modes; 691 /* no front panel */ 692 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || 693 get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) { 694 /* no optional rear panel */ 695 spec->board_config = CMI_MINIMAL; 696 spec->front_panel = 0; 697 spec->num_channel_modes = 2; 698 } else { 699 spec->board_config = CMI_MIN_FP; 700 spec->num_channel_modes = 3; 701 } 702 spec->input_mux = &cmi9880_basic_mux; 703 spec->multiout.max_channels = cmi9880_channel_modes[0].channels; 704 } else { 705 spec->input_mux = &cmi9880_basic_mux; 706 port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 707 port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 708 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) 709 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; 710 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) 711 spec->dig_in_nid = CMI_DIG_IN_NID; 712 spec->multiout.max_channels = 8; 713 } 714 snd_hda_parse_pin_def_config(codec, &cfg, NULL); 715 if (cfg.line_outs) { 716 spec->multiout.max_channels = cfg.line_outs * 2; 717 cmi9880_fill_multi_dac_nids(codec, &cfg); 718 cmi9880_fill_multi_init(codec, &cfg); 719 } else 720 snd_printd("patch_cmedia: cannot detect association in defcfg\n"); 721 break; 722 } 723 } 724 725 spec->multiout.num_dacs = spec->num_dacs; 726 spec->multiout.dac_nids = spec->dac_nids; 851 727 852 728 spec->adc_nids = cmi9880_adc_nids; … … 861 737 */ 862 738 struct hda_codec_preset snd_hda_preset_cmedia[] = { 863 { 0x13f69880, 0,0,0,0,"CMI9880",patch_cmi9880 },864 { 0x434d4980, 0,0,0,0,"CMI9880",patch_cmi9880 },865 {0} /* terminator */866 }; 739 { .id = 0x13f69880, .name = "CMI9880", .patch = patch_cmi9880 }, 740 { .id = 0x434d4980, .name = "CMI9880", .patch = patch_cmi9880 }, 741 {0} /* terminator */ 742 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c
r32 r69 4 4 * HD audio interface patch for ALC 260/880/882 codecs 5 5 * 6 * Copyright (c) 2004 PeiSen Hou <pshou@realtek.com.tw> 6 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> 7 * PeiSen Hou <pshou@realtek.com.tw> 7 8 * Takashi Iwai <tiwai@suse.de> 8 9 * … … 34 35 /* ALC880 board config type */ 35 36 enum { 36 ALC880_MINIMAL,37 37 ALC880_3ST, 38 38 ALC880_3ST_DIG, 39 39 ALC880_5ST, 40 40 ALC880_5ST_DIG, 41 ALC880_W810, 42 ALC880_Z71V, 43 ALC880_TEST, 44 }; 41 ALC880_W810, 42 ALC880_Z71V, 43 ALC880_6ST, 44 ALC880_6ST_DIG, 45 ALC880_F1734, 46 ALC880_ASUS, 47 ALC880_ASUS_DIG, 48 ALC880_ASUS_W1V, 49 ALC880_ASUS_DIG2, 50 ALC880_UNIWILL_DIG, 51 ALC880_CLEVO, 52 ALC880_TCL_S700, 53 #ifdef CONFIG_SND_DEBUG 54 ALC880_TEST, 55 #endif 56 ALC880_AUTO, 57 ALC880_MODEL_LAST /* last tag */ 58 }; 59 60 /* ALC260 models */ 61 enum { 62 ALC260_BASIC, 63 ALC260_HP, 64 ALC260_HP_3013, 65 ALC260_FUJITSU_S702X, 66 ALC260_AUTO, 67 ALC260_MODEL_LAST /* last tag */ 68 }; 69 70 /* ALC262 models */ 71 enum { 72 ALC262_BASIC, 73 ALC262_AUTO, 74 ALC262_MODEL_LAST /* last tag */ 75 }; 76 77 /* ALC861 models */ 78 enum { 79 ALC861_3ST, 80 ALC861_3ST_DIG, 81 ALC861_6ST_DIG, 82 ALC861_AUTO, 83 ALC861_MODEL_LAST, 84 }; 85 86 /* ALC882 models */ 87 enum { 88 ALC882_3ST_DIG, 89 ALC882_6ST_DIG, 90 ALC882_AUTO, 91 ALC882_MODEL_LAST, 92 }; 93 94 /* for GPIO Poll */ 95 #define GPIO_MASK 0x03 45 96 46 97 struct alc_spec { 47 98 /* codec parameterization */ 48 unsigned int front_panel: 1; 49 50 snd_kcontrol_new_t* mixers[2]; 99 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 51 100 unsigned int num_mixers; 52 101 53 struct hda_verb *init_verbs; 54 55 char* stream_name_analog; 102 const struct hda_verb *init_verbs[5]; /* initialization verbs 103 * don't forget NULL termination! 104 */ 105 unsigned int num_init_verbs; 106 107 char *stream_name_analog; /* analog PCM stream */ 56 108 struct hda_pcm_stream *stream_analog_playback; 57 109 struct hda_pcm_stream *stream_analog_capture; 58 110 59 char * stream_name_digital;111 char *stream_name_digital; /* digital PCM stream */ 60 112 struct hda_pcm_stream *stream_digital_playback; 61 113 struct hda_pcm_stream *stream_digital_capture; 62 114 63 115 /* playback */ 64 struct hda_multi_out multiout; 116 struct hda_multi_out multiout; /* playback set-up 117 * max_channels, dacs must be set 118 * dig_out_nid and hp_nid are optional 119 */ 65 120 66 121 /* capture */ 67 122 unsigned int num_adc_nids; 68 123 hda_nid_t *adc_nids; 69 hda_nid_t dig_in_nid; 124 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 70 125 71 126 /* capture source */ … … 74 129 75 130 /* channel model */ 76 const struct alc_channel_mode *channel_mode;131 const struct hda_channel_mode *channel_mode; 77 132 int num_channel_mode; 78 133 79 134 /* PCM information */ 80 struct hda_pcm pcm_rec[2]; 81 82 struct semaphore bind_mutex; 83 }; 84 85 /* DAC/ADC assignment */ 86 87 static hda_nid_t alc880_dac_nids[4] = { 88 /* front, rear, clfe, rear_surr */ 89 0x02, 0x05, 0x04, 0x03 90 }; 91 92 static hda_nid_t alc880_w810_dac_nids[3] = { 93 /* front, rear/surround, clfe */ 94 0x02, 0x03, 0x04 95 }; 96 97 static hda_nid_t alc880_z71v_dac_nids[1] = { 98 /* front only? */ 99 0x02 100 }; 101 102 #if 0 103 /* The datasheet says the node 0x07 is connected from inputs, 104 * but it shows zero connection in the real implementation. 105 */ 106 static hda_nid_t alc880_adc_nids[3] = { 107 /* ADC0-2 */ 108 0x07, 0x08, 0x09, 109 }; 110 #else 111 static hda_nid_t alc880_adc_nids[2] = { 112 /* ADC1-2 */ 113 0x08, 0x09, 114 }; 115 #endif 116 117 #define ALC880_DIGOUT_NID 0x06 118 #define ALC880_DIGIN_NID 0x0a 119 120 static hda_nid_t alc260_dac_nids[1] = { 121 /* front */ 122 0x02, 123 }; 124 125 static hda_nid_t alc260_adc_nids[2] = { 126 /* ADC0-1 */ 127 0x04, 0x05, 128 }; 129 130 #define ALC260_DIGOUT_NID 0x03 131 #define ALC260_DIGIN_NID 0x06 132 133 static struct hda_input_mux alc880_capture_source = { 134 /*.num_items = */4, 135 /*.items = */{ 136 { "Mic", 0x0 }, 137 { "Front Mic", 0x3 }, 138 { "Line", 0x2 }, 139 { "CD", 0x4 }, 140 }, 141 }; 142 143 static struct hda_input_mux alc260_capture_source = { 144 /*.num_items = */4, 145 /*.items = */{ 146 { "Mic", 0x0 }, 147 { "Front Mic", 0x1 }, 148 { "Line", 0x2 }, 149 { "CD", 0x4 }, 150 }, 151 }; 135 struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */ 136 137 /* dynamic controls, init_verbs and input_mux */ 138 struct auto_pin_cfg autocfg; 139 unsigned int num_kctl_alloc, num_kctl_used; 140 struct snd_kcontrol_new *kctl_alloc; 141 struct hda_input_mux private_imux; 142 hda_nid_t private_dac_nids[5]; 143 }; 144 145 /* 146 * configuration template - to be copied to the spec instance 147 */ 148 struct alc_config_preset { 149 struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */ 150 const struct hda_verb *init_verbs[5]; 151 unsigned int num_dacs; 152 hda_nid_t *dac_nids; 153 hda_nid_t dig_out_nid; /* optional */ 154 hda_nid_t hp_nid; /* optional */ 155 unsigned int num_adc_nids; 156 hda_nid_t *adc_nids; 157 hda_nid_t dig_in_nid; 158 unsigned int num_channel_mode; 159 const struct hda_channel_mode *channel_mode; 160 const struct hda_input_mux *input_mux; 161 }; 162 152 163 153 164 /* 154 165 * input MUX handling 155 166 */ 156 static int alc_mux_enum_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)167 static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 157 168 { 158 169 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 161 172 } 162 173 163 static int alc_mux_enum_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)174 static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 164 175 { 165 176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 171 182 } 172 183 173 static int alc_mux_enum_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)184 static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 174 185 { 175 186 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 180 191 } 181 192 193 182 194 /* 183 195 * channel mode setting 184 196 */ 185 struct alc_channel_mode { 186 int channels; 187 const struct hda_verb *sequence; 188 }; 189 190 191 /* 192 * channel source setting (2/6 channel selection for 3-stack) 193 */ 194 195 /* 196 * set the path ways for 2 channel output 197 * need to set the codec line out and mic 1 pin widgets to inputs 198 */ 197 static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 198 { 199 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 200 struct alc_spec *spec = codec->spec; 201 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, 202 spec->num_channel_mode); 203 } 204 205 static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 206 { 207 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 208 struct alc_spec *spec = codec->spec; 209 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, 210 spec->num_channel_mode, spec->multiout.max_channels); 211 } 212 213 static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 214 { 215 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 216 struct alc_spec *spec = codec->spec; 217 return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, 218 spec->num_channel_mode, &spec->multiout.max_channels); 219 } 220 221 222 /* 223 * Control of pin widget settings via the mixer. Only boolean settings are 224 * supported, so VrefEn can't be controlled using these functions as they 225 * stand. 226 */ 227 static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 228 { 229 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 230 uinfo->count = 1; 231 uinfo->value.integer.min = 0; 232 uinfo->value.integer.max = 1; 233 return 0; 234 } 235 236 static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 237 { 238 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 239 hda_nid_t nid = kcontrol->private_value & 0xffff; 240 long mask = (kcontrol->private_value >> 16) & 0xff; 241 long *valp = ucontrol->value.integer.value; 242 243 *valp = 0; 244 if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask) 245 *valp = 1; 246 return 0; 247 } 248 249 static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 250 { 251 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 252 hda_nid_t nid = kcontrol->private_value & 0xffff; 253 long mask = (kcontrol->private_value >> 16) & 0xff; 254 long *valp = ucontrol->value.integer.value; 255 unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00); 256 int change = ((pinctl & mask)!=0) != *valp; 257 258 if (change) 259 snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL, 260 *valp?(pinctl|mask):(pinctl&~mask)); 261 return change; 262 } 263 264 #define ALC_PINCTL_SWITCH(xname, nid, mask) \ 265 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \ 266 .info = alc_pinctl_switch_info, \ 267 .get = alc_pinctl_switch_get, \ 268 .put = alc_pinctl_switch_put, \ 269 .private_value = (nid) | (mask<<16) } 270 271 272 /* 273 * set up from the preset table 274 */ 275 static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset) 276 { 277 int i; 278 279 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) 280 spec->mixers[spec->num_mixers++] = preset->mixers[i]; 281 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) 282 spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; 283 284 spec->channel_mode = preset->channel_mode; 285 spec->num_channel_mode = preset->num_channel_mode; 286 287 spec->multiout.max_channels = spec->channel_mode[0].channels; 288 289 spec->multiout.num_dacs = preset->num_dacs; 290 spec->multiout.dac_nids = preset->dac_nids; 291 spec->multiout.dig_out_nid = preset->dig_out_nid; 292 spec->multiout.hp_nid = preset->hp_nid; 293 294 spec->input_mux = preset->input_mux; 295 296 spec->num_adc_nids = preset->num_adc_nids; 297 spec->adc_nids = preset->adc_nids; 298 spec->dig_in_nid = preset->dig_in_nid; 299 } 300 301 /* 302 * ALC880 3-stack model 303 * 304 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e) 305 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b 306 * HP = 0x19 307 */ 308 309 static hda_nid_t alc880_dac_nids[4] = { 310 /* front, rear, clfe, rear_surr */ 311 0x02, 0x05, 0x04, 0x03 312 }; 313 314 static hda_nid_t alc880_adc_nids[3] = { 315 /* ADC0-2 */ 316 0x07, 0x08, 0x09, 317 }; 318 319 /* The datasheet says the node 0x07 is connected from inputs, 320 * but it shows zero connection in the real implementation on some devices. 321 * Note: this is a 915GAV bug, fixed on 915GLV 322 */ 323 static hda_nid_t alc880_adc_nids_alt[2] = { 324 /* ADC1-2 */ 325 0x08, 0x09, 326 }; 327 328 #define ALC880_DIGOUT_NID 0x06 329 #define ALC880_DIGIN_NID 0x0a 330 331 static struct hda_input_mux alc880_capture_source = { 332 .num_items = 4, 333 .items = { 334 { "Mic", 0x0 }, 335 { "Front Mic", 0x3 }, 336 { "Line", 0x2 }, 337 { "CD", 0x4 }, 338 }, 339 }; 340 341 /* channel source setting (2/6 channel selection for 3-stack) */ 342 /* 2ch mode */ 199 343 static struct hda_verb alc880_threestack_ch2_init[] = { 200 /* set pin widget 1Ah (line in) for input */ 201 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 202 /* set pin widget 18h (mic1) for input, for mic also enable the vref */ 203 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 204 /* mute the output for Line In PW */ 205 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 206 /* mute for Mic1 PW */ 207 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 344 /* set line-in to input, mute it */ 345 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 346 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 347 /* set mic-in to input vref 80%, mute it */ 348 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 349 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 208 350 {0} /* end */ 209 351 }; 210 352 211 /* 212 * 6ch mode 213 * need to set the codec line out and mic 1 pin widgets to outputs 214 */ 353 /* 6ch mode */ 215 354 static struct hda_verb alc880_threestack_ch6_init[] = { 216 /* set pin widget 1Ah (line in) for output */ 217 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 218 /* set pin widget 18h (mic1) for output */ 219 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 220 /* unmute the output for Line In PW */ 221 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 }, 222 /* unmute for Mic1 PW */ 223 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 }, 224 /* for rear channel output using Line In 1 225 * set select widget connection (nid = 0x12) - to summer node 226 * for rear NID = 0x0f...offset 3 in connection list 227 */ 228 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x3 }, 229 /* for Mic1 - retask for center/lfe */ 230 /* set select widget connection (nid = 0x10) - to summer node for 231 * front CLFE NID = 0x0e...offset 2 in connection list 232 */ 233 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x2 }, 355 /* set line-in to output, unmute it */ 356 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 357 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 358 /* set mic-in to output, unmute it */ 359 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 360 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 234 361 {0} /* end */ 235 362 }; 236 363 237 static struct alc_channel_mode alc880_threestack_modes[2] = {364 static struct hda_channel_mode alc880_threestack_modes[2] = { 238 365 { 2, alc880_threestack_ch2_init }, 239 366 { 6, alc880_threestack_ch6_init }, 240 367 }; 241 368 242 243 /* 244 * channel source setting (6/8 channel selection for 5-stack) 245 */ 246 247 /* set the path ways for 6 channel output 248 * need to set the codec line out and mic 1 pin widgets to inputs 249 */ 369 static struct snd_kcontrol_new alc880_three_stack_mixer[] = { 370 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 371 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 372 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 373 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT), 374 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 375 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 376 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 377 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 386 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 387 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 388 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 389 { 390 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 391 .name = "Channel Mode", 392 .info = alc_ch_mode_info, 393 .get = alc_ch_mode_get, 394 .put = alc_ch_mode_put, 395 }, 396 {0} /* end */ 397 }; 398 399 /* capture mixer elements */ 400 static struct snd_kcontrol_new alc880_capture_mixer[] = { 401 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 402 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 403 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 404 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 405 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 406 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 407 { 408 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 409 /* The multiple "Capture Source" controls confuse alsamixer 410 * So call somewhat different.. 411 * FIXME: the controls appear in the "playback" view! 412 */ 413 /* .name = "Capture Source", */ 414 .name = "Input Source", 415 .count = 3, 416 .info = alc_mux_enum_info, 417 .get = alc_mux_enum_get, 418 .put = alc_mux_enum_put, 419 }, 420 {0} /* end */ 421 }; 422 423 /* capture mixer elements (in case NID 0x07 not available) */ 424 static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { 425 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 426 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 427 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 428 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 429 { 430 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 431 /* The multiple "Capture Source" controls confuse alsamixer 432 * So call somewhat different.. 433 * FIXME: the controls appear in the "playback" view! 434 */ 435 /* .name = "Capture Source", */ 436 .name = "Input Source", 437 .count = 2, 438 .info = alc_mux_enum_info, 439 .get = alc_mux_enum_get, 440 .put = alc_mux_enum_put, 441 }, 442 {0} /* end */ 443 }; 444 445 446 447 /* 448 * ALC880 5-stack model 449 * 450 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd) 451 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16 452 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19 453 */ 454 455 /* additional mixers to alc880_three_stack_mixer */ 456 static struct snd_kcontrol_new alc880_five_stack_mixer[] = { 457 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 458 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), 459 {0} /* end */ 460 }; 461 462 /* channel source setting (6/8 channel selection for 5-stack) */ 463 /* 6ch mode */ 250 464 static struct hda_verb alc880_fivestack_ch6_init[] = { 251 /* set pin widget 1Ah (line in) for input */ 252 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 253 /* mute the output for Line In PW */ 254 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 465 /* set line-in to input, mute it */ 466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 255 468 {0} /* end */ 256 469 }; 257 470 258 /* need to set the codec line out and mic 1 pin widgets to outputs*/471 /* 8ch mode */ 259 472 static struct hda_verb alc880_fivestack_ch8_init[] = { 260 /* set pin widget 1Ah (line in) for output */ 261 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 262 /* unmute the output for Line In PW */ 263 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000 }, 264 /* output for surround channel output using Line In 1 */ 265 /* set select widget connection (nid = 0x12) - to summer node 266 * for surr_rear NID = 0x0d...offset 1 in connection list 267 */ 268 { 0x12, AC_VERB_SET_CONNECT_SEL, 0x1 }, 473 /* set line-in to output, unmute it */ 474 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 475 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 269 476 {0} /* end */ 270 477 }; 271 478 272 static struct alc_channel_mode alc880_fivestack_modes[2] = {479 static struct hda_channel_mode alc880_fivestack_modes[2] = { 273 480 { 6, alc880_fivestack_ch6_init }, 274 481 { 8, alc880_fivestack_ch8_init }, 275 482 }; 276 483 277 /* 278 * channel source setting for W810 system 484 485 /* 486 * ALC880 6-stack model 487 * 488 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f) 489 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17, 490 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b 491 */ 492 493 static hda_nid_t alc880_6st_dac_nids[4] = { 494 /* front, rear, clfe, rear_surr */ 495 0x02, 0x03, 0x04, 0x05 496 }; 497 498 static struct hda_input_mux alc880_6stack_capture_source = { 499 .num_items = 4, 500 .items = { 501 { "Mic", 0x0 }, 502 { "Front Mic", 0x1 }, 503 { "Line", 0x2 }, 504 { "CD", 0x4 }, 505 }, 506 }; 507 508 /* fixed 8-channels */ 509 static struct hda_channel_mode alc880_sixstack_modes[1] = { 510 { 8, NULL }, 511 }; 512 513 static struct snd_kcontrol_new alc880_six_stack_mixer[] = { 514 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 515 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 516 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 517 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 518 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 519 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 520 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 521 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 522 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 523 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 526 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 527 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 528 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 529 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 530 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 531 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 532 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 533 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 534 { 535 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 536 .name = "Channel Mode", 537 .info = alc_ch_mode_info, 538 .get = alc_ch_mode_get, 539 .put = alc_ch_mode_put, 540 }, 541 {0} /* end */ 542 }; 543 544 545 /* 546 * ALC880 W810 model 279 547 * 280 548 * W810 has rear IO for: … … 286 554 * The system also has a pair of internal speakers, and a headphone jack. 287 555 * These are both connected to Line2 on the codec, hence to DAC 02. 288 * 556 * 289 557 * There is a variable resistor to control the speaker or headphone 290 558 * volume. This is a hardware-only device without a software API. … … 300 568 */ 301 569 302 static struct alc_channel_mode alc880_w810_modes[1] = { 570 static hda_nid_t alc880_w810_dac_nids[3] = { 571 /* front, rear/surround, clfe */ 572 0x02, 0x03, 0x04 573 }; 574 575 /* fixed 6 channels */ 576 static struct hda_channel_mode alc880_w810_modes[1] = { 303 577 { 6, NULL } 304 578 }; 305 579 306 static struct alc_channel_mode alc880_z71v_modes[1] = { 307 { 2, NULL } 308 }; 309 310 /* 311 */ 312 static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 313 { 314 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 315 struct alc_spec *spec = codec->spec; 316 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; 317 318 snd_assert(spec->channel_mode, return -ENXIO); 319 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 320 uinfo->count = 1; 321 uinfo->value.enumerated.items = items; 322 if (uinfo->value.enumerated.item >= items) 323 uinfo->value.enumerated.item = items - 1; 324 sprintf(uinfo->value.enumerated.name, "%dch", 325 spec->channel_mode[uinfo->value.enumerated.item].channels); 326 return 0; 327 } 328 329 static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 330 { 331 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 332 struct alc_spec *spec = codec->spec; 333 int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; 334 int i; 335 336 snd_assert(spec->channel_mode, return -ENXIO); 337 for (i = 0; i < items; i++) { 338 if (spec->multiout.max_channels == spec->channel_mode[i].channels) { 339 ucontrol->value.enumerated.item[0] = i; 340 break; 341 } 342 } 343 return 0; 344 } 345 346 static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 347 { 348 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 349 struct alc_spec *spec = codec->spec; 350 int mode; 351 352 snd_assert(spec->channel_mode, return -ENXIO); 353 mode = ucontrol->value.enumerated.item[0] ? 1 : 0; 354 if (spec->multiout.max_channels == spec->channel_mode[mode].channels && 355 ! codec->in_resume) 356 return 0; 357 358 /* change the current channel setting */ 359 spec->multiout.max_channels = spec->channel_mode[mode].channels; 360 if (spec->channel_mode[mode].sequence) 361 snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence); 362 363 return 1; 364 } 365 366 367 /* 368 * bound volume controls 580 /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ 581 static struct snd_kcontrol_new alc880_w810_base_mixer[] = { 582 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 583 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 584 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 585 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 586 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 587 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 588 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 589 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 591 {0} /* end */ 592 }; 593 594 595 /* 596 * Z710V model 369 597 * 370 * bind multiple volumes (# indices, from 0) 371 */ 372 373 #define AMP_VAL_IDX_SHIFT 19 374 #define AMP_VAL_IDX_MASK (0x0f<<19) 375 376 static int alc_bind_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 377 { 378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 379 struct alc_spec *spec = codec->spec; 380 unsigned long pval; 381 382 down(&spec->bind_mutex); 383 pval = kcontrol->private_value; 384 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ 385 snd_hda_mixer_amp_volume_info(kcontrol, uinfo); 386 kcontrol->private_value = pval; 387 up(&spec->bind_mutex); 388 return 0; 389 } 390 391 static int alc_bind_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 392 { 393 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 394 struct alc_spec *spec = codec->spec; 395 unsigned long pval; 396 397 down(&spec->bind_mutex); 398 pval = kcontrol->private_value; 399 kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ 400 snd_hda_mixer_amp_volume_get(kcontrol, ucontrol); 401 kcontrol->private_value = pval; 402 up(&spec->bind_mutex); 403 return 0; 404 } 405 406 static int alc_bind_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 407 { 408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 409 struct alc_spec *spec = codec->spec; 410 unsigned long pval; 411 int i, indices, change = 0; 412 413 down(&spec->bind_mutex); 414 pval = kcontrol->private_value; 415 indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; 416 for (i = 0; i < indices; i++) { 417 kcontrol->private_value = (pval & ~AMP_VAL_IDX_MASK) | (i << AMP_VAL_IDX_SHIFT); 418 change |= snd_hda_mixer_amp_volume_put(kcontrol, ucontrol); 419 } 420 kcontrol->private_value = pval; 421 up(&spec->bind_mutex); 422 return change; 423 } 424 425 #define ALC_BIND_VOL_MONO(xname, nid, channel, indices, direction) \ 426 { SNDRV_CTL_ELEM_IFACE_MIXER, 0, 0, xname, 0, 0, 0, \ 427 alc_bind_vol_info, \ 428 alc_bind_vol_get, \ 429 alc_bind_vol_put, \ 430 HDA_COMPOSE_AMP_VAL(nid, channel, indices, direction) } 431 432 #define ALC_BIND_VOL(xname,nid,indices,dir) ALC_BIND_VOL_MONO(xname,nid,3,indices,dir) 433 434 /* 435 */ 436 /* 3-stack mode 437 * Pin assignment: Front=0x14, Line-In/Rear=0x1a, Mic/CLFE=0x18, F-Mic=0x1b 438 * HP=0x19 439 */ 440 static snd_kcontrol_new_t alc880_base_mixer[] = { 441 ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT), 442 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 443 ALC_BIND_VOL("Surround Playback Volume", 0x0f, 2, HDA_OUTPUT), 444 HDA_CODEC_MUTE("Surround Playback Switch", 0x1a, 0x0, HDA_OUTPUT), 445 ALC_BIND_VOL_MONO("Center Playback Volume", 0x0e, 1, 2, HDA_OUTPUT), 446 ALC_BIND_VOL_MONO("LFE Playback Volume", 0x0e, 2, 2, HDA_OUTPUT), 447 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x18, 1, 0x0, HDA_OUTPUT), 448 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x18, 2, 0x0, HDA_OUTPUT), 598 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d) 599 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a 600 */ 601 602 static hda_nid_t alc880_z71v_dac_nids[1] = { 603 0x02 604 }; 605 #define ALC880_Z71V_HP_DAC 0x03 606 607 /* fixed 2 channels */ 608 static struct hda_channel_mode alc880_2_jack_modes[1] = { 609 { 2, NULL } 610 }; 611 612 static struct snd_kcontrol_new alc880_z71v_mixer[] = { 613 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 615 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 616 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT), 617 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 618 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 621 {0} /* end */ 622 }; 623 624 625 /* FIXME! */ 626 /* 627 * ALC880 F1734 model 628 * 629 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d) 630 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18 631 */ 632 633 static hda_nid_t alc880_f1734_dac_nids[1] = { 634 0x03 635 }; 636 #define ALC880_F1734_HP_DAC 0x02 637 638 static struct snd_kcontrol_new alc880_f1734_mixer[] = { 639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 640 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), 641 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 642 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT), 643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 647 {0} /* end */ 648 }; 649 650 651 /* FIXME! */ 652 /* 653 * ALC880 ASUS model 654 * 655 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) 656 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, 657 * Mic = 0x18, Line = 0x1a 658 */ 659 660 #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ 661 #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ 662 663 static struct snd_kcontrol_new alc880_asus_mixer[] = { 664 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 665 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 667 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 668 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 669 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 670 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 671 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 449 672 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 450 673 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 451 674 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 452 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 455 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 456 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 675 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 678 { 679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 680 .name = "Channel Mode", 681 .info = alc_ch_mode_info, 682 .get = alc_ch_mode_get, 683 .put = alc_ch_mode_put, 684 }, 685 {0} /* end */ 686 }; 687 688 /* FIXME! */ 689 /* 690 * ALC880 ASUS W1V model 691 * 692 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e) 693 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16, 694 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b 695 */ 696 697 /* additional mixers to alc880_asus_mixer */ 698 static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { 699 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), 700 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), 701 {0} /* end */ 702 }; 703 704 /* additional mixers to alc880_asus_mixer */ 705 static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { 457 706 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 458 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 459 ALC_BIND_VOL("Headphone Playback Volume", 0x0d, 2, HDA_OUTPUT), 460 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 461 /* We don't use NID 0x07 - see above */ 462 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 463 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 464 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 465 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 707 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 708 {0} /* end */ 709 }; 710 711 /* TCL S700 */ 712 static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { 713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 714 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), 716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), 717 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), 718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), 719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), 720 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 721 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 466 722 { 467 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 468 724 /* The multiple "Capture Source" controls confuse alsamixer 469 725 * So call somewhat different.. … … 471 727 */ 472 728 /* .name = "Capture Source", */ 473 /*.name = */"Input Source",0,0, 474 /*.count = */2, 475 /*.info = */alc_mux_enum_info, 476 /*.get = */alc_mux_enum_get, 477 /*.put = */alc_mux_enum_put,0 478 }, 729 .name = "Input Source", 730 .count = 1, 731 .info = alc_mux_enum_info, 732 .get = alc_mux_enum_get, 733 .put = alc_mux_enum_put, 734 }, 735 {0} /* end */ 736 }; 737 738 /* 739 * build control elements 740 */ 741 static int alc_build_controls(struct hda_codec *codec) 742 { 743 struct alc_spec *spec = codec->spec; 744 int err; 745 int i; 746 747 for (i = 0; i < spec->num_mixers; i++) { 748 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 749 if (err < 0) 750 return err; 751 } 752 753 if (spec->multiout.dig_out_nid) { 754 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 755 if (err < 0) 756 return err; 757 } 758 if (spec->dig_in_nid) { 759 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 760 if (err < 0) 761 return err; 762 } 763 return 0; 764 } 765 766 767 /* 768 * initialize the codec volumes, etc 769 */ 770 771 /* 772 * generic initialization of ADC, input mixers and output mixers 773 */ 774 static struct hda_verb alc880_volume_init_verbs[] = { 775 /* 776 * Unmute ADC0-2 and set the default input to mic-in 777 */ 778 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 779 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 780 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 781 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 782 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 783 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 784 785 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 786 * mixer widget 787 * Note: PASD motherboards uses the Line In 2 as the input for front panel 788 * mic (mic 2) 789 */ 790 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 796 797 /* 798 * Set up output mixers (0x0c - 0x0f) 799 */ 800 /* set vol=0 to output mixers */ 801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 802 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 803 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 805 /* set up input amps for analog loopback */ 806 /* Amp Indices: DAC = 0, mixer = 1 */ 807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 809 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 811 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 814 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 815 816 {0} 817 }; 818 819 /* 820 * 3-stack pin configuration: 821 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b 822 */ 823 static struct hda_verb alc880_pin_3stack_init_verbs[] = { 824 /* 825 * preset connection lists of input pins 826 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround 827 */ 828 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */ 829 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 830 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */ 831 832 /* 833 * Set pin mode and muting 834 */ 835 /* set front pin widgets 0x14 for output */ 836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 837 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 838 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 839 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 840 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 841 /* Mic2 (as headphone out) for HP output */ 842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 843 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 844 /* Line In pin widget for input */ 845 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 846 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 847 /* Line2 (as front mic) pin widget for input and vref at 80% */ 848 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 849 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 850 /* CD pin widget for input */ 851 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 852 853 {0} 854 }; 855 856 /* 857 * 5-stack pin configuration: 858 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19, 859 * line-in/side = 0x1a, f-mic = 0x1b 860 */ 861 static struct hda_verb alc880_pin_5stack_init_verbs[] = { 862 /* 863 * preset connection lists of input pins 864 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround 865 */ 866 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 867 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */ 868 869 /* 870 * Set pin mode and muting 871 */ 872 /* set pin widgets 0x14-0x17 for output */ 873 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 874 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 875 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 876 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 877 /* unmute pins for output (no gain on this amp) */ 878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 880 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 881 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 882 883 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 886 /* Mic2 (as headphone out) for HP output */ 887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 889 /* Line In pin widget for input */ 890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 892 /* Line2 (as front mic) pin widget for input and vref at 80% */ 893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 895 /* CD pin widget for input */ 896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 897 898 {0} 899 }; 900 901 /* 902 * W810 pin configuration: 903 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b 904 */ 905 static struct hda_verb alc880_pin_w810_init_verbs[] = { 906 /* hphone/speaker input selector: front DAC */ 907 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 908 909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 911 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 914 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 915 916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 917 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 918 919 {0} 920 }; 921 922 /* 923 * Z71V pin configuration: 924 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?) 925 */ 926 static struct hda_verb alc880_pin_z71v_init_verbs[] = { 927 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 931 932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 934 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 936 937 {0} 938 }; 939 940 /* 941 * 6-stack pin configuration: 942 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19, 943 * line = 0x1a, HP = 0x1b 944 */ 945 static struct hda_verb alc880_pin_6stack_init_verbs[] = { 946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */ 947 948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 954 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 955 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 956 957 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 958 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 959 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 960 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 961 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 962 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 963 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 964 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 965 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 966 967 {0} 968 }; 969 970 /* FIXME! */ 971 /* 972 * F1734 pin configuration: 973 * HP = 0x14, speaker-out = 0x15, mic = 0x18 974 */ 975 static struct hda_verb alc880_pin_f1734_init_verbs[] = { 976 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 977 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 978 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 979 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 980 981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 982 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 984 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 985 986 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 988 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 989 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 990 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 992 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 994 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 995 996 {0} 997 }; 998 999 /* FIXME! */ 1000 /* 1001 * ASUS pin configuration: 1002 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a 1003 */ 1004 static struct hda_verb alc880_pin_asus_init_verbs[] = { 1005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, 1006 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, 1007 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, 1008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, 1009 1010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1014 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1016 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1017 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1018 1019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1025 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1028 1029 {0} 1030 }; 1031 1032 /* Enable GPIO mask and set output */ 1033 static struct hda_verb alc880_gpio1_init_verbs[] = { 1034 {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, 1035 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, 1036 {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, 1037 1038 {0} 1039 }; 1040 1041 /* Enable GPIO mask and set output */ 1042 static struct hda_verb alc880_gpio2_init_verbs[] = { 1043 {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, 1044 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, 1045 {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, 1046 1047 {0} 1048 }; 1049 1050 /* Clevo m520g init */ 1051 static struct hda_verb alc880_pin_clevo_init_verbs[] = { 1052 /* headphone output */ 1053 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 1054 /* line-out */ 1055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1057 /* Line-in */ 1058 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1059 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1060 /* CD */ 1061 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1062 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1063 /* Mic1 (rear panel) */ 1064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1066 /* Mic2 (front panel) */ 1067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1069 /* headphone */ 1070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1072 /* change to EAPD mode */ 1073 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 1074 {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, 1075 1076 {0} 1077 }; 1078 1079 static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { 1080 /* Headphone output */ 1081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 1082 /* Front output*/ 1083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1084 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1085 1086 /* Line In pin widget for input */ 1087 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1088 /* CD pin widget for input */ 1089 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1090 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 1091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1092 1093 /* change to EAPD mode */ 1094 {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, 1095 {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, 1096 1097 {0} 1098 }; 1099 1100 /* 1101 */ 1102 1103 static int alc_init(struct hda_codec *codec) 1104 { 1105 struct alc_spec *spec = codec->spec; 1106 unsigned int i; 1107 1108 for (i = 0; i < spec->num_init_verbs; i++) 1109 snd_hda_sequence_write(codec, spec->init_verbs[i]); 1110 return 0; 1111 } 1112 1113 #ifdef CONFIG_PM 1114 /* 1115 * resume 1116 */ 1117 static int alc_resume(struct hda_codec *codec) 1118 { 1119 struct alc_spec *spec = codec->spec; 1120 int i; 1121 1122 alc_init(codec); 1123 for (i = 0; i < spec->num_mixers; i++) 1124 snd_hda_resume_ctls(codec, spec->mixers[i]); 1125 if (spec->multiout.dig_out_nid) 1126 snd_hda_resume_spdif_out(codec); 1127 if (spec->dig_in_nid) 1128 snd_hda_resume_spdif_in(codec); 1129 1130 return 0; 1131 } 1132 #endif 1133 1134 /* 1135 * Analog playback callbacks 1136 */ 1137 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, 1138 struct hda_codec *codec, 1139 struct snd_pcm_substream *substream) 1140 { 1141 struct alc_spec *spec = codec->spec; 1142 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 1143 } 1144 1145 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 1146 struct hda_codec *codec, 1147 unsigned int stream_tag, 1148 unsigned int format, 1149 struct snd_pcm_substream *substream) 1150 { 1151 struct alc_spec *spec = codec->spec; 1152 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, 1153 format, substream); 1154 } 1155 1156 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 1157 struct hda_codec *codec, 1158 struct snd_pcm_substream *substream) 1159 { 1160 struct alc_spec *spec = codec->spec; 1161 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 1162 } 1163 1164 /* 1165 * Digital out 1166 */ 1167 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 1168 struct hda_codec *codec, 1169 struct snd_pcm_substream *substream) 1170 { 1171 struct alc_spec *spec = codec->spec; 1172 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 1173 } 1174 1175 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 1176 struct hda_codec *codec, 1177 struct snd_pcm_substream *substream) 1178 { 1179 struct alc_spec *spec = codec->spec; 1180 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 1181 } 1182 1183 /* 1184 * Analog capture 1185 */ 1186 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 1187 struct hda_codec *codec, 1188 unsigned int stream_tag, 1189 unsigned int format, 1190 struct snd_pcm_substream *substream) 1191 { 1192 struct alc_spec *spec = codec->spec; 1193 1194 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 1195 stream_tag, 0, format); 1196 return 0; 1197 } 1198 1199 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 1200 struct hda_codec *codec, 1201 struct snd_pcm_substream *substream) 1202 { 1203 struct alc_spec *spec = codec->spec; 1204 1205 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 1206 return 0; 1207 } 1208 1209 1210 /* 1211 */ 1212 static struct hda_pcm_stream alc880_pcm_analog_playback = { 1213 .substreams = 1, 1214 .channels_min = 2, 1215 .channels_max = 8, 1216 /* NID is set in alc_build_pcms */ 1217 .ops = { 1218 .open = alc880_playback_pcm_open, 1219 .prepare = alc880_playback_pcm_prepare, 1220 .cleanup = alc880_playback_pcm_cleanup 1221 }, 1222 }; 1223 1224 static struct hda_pcm_stream alc880_pcm_analog_capture = { 1225 .substreams = 2, 1226 .channels_min = 2, 1227 .channels_max = 2, 1228 /* NID is set in alc_build_pcms */ 1229 .ops = { 1230 .prepare = alc880_capture_pcm_prepare, 1231 .cleanup = alc880_capture_pcm_cleanup 1232 }, 1233 }; 1234 1235 static struct hda_pcm_stream alc880_pcm_digital_playback = { 1236 .substreams = 1, 1237 .channels_min = 2, 1238 .channels_max = 2, 1239 /* NID is set in alc_build_pcms */ 1240 .ops = { 1241 .open = alc880_dig_playback_pcm_open, 1242 .close = alc880_dig_playback_pcm_close 1243 }, 1244 }; 1245 1246 static struct hda_pcm_stream alc880_pcm_digital_capture = { 1247 .substreams = 1, 1248 .channels_min = 2, 1249 .channels_max = 2, 1250 /* NID is set in alc_build_pcms */ 1251 }; 1252 1253 static int alc_build_pcms(struct hda_codec *codec) 1254 { 1255 struct alc_spec *spec = codec->spec; 1256 struct hda_pcm *info = spec->pcm_rec; 1257 int i; 1258 1259 codec->num_pcms = 1; 1260 codec->pcm_info = info; 1261 1262 info->name = spec->stream_name_analog; 1263 if (spec->stream_analog_playback) { 1264 snd_assert(spec->multiout.dac_nids, return -EINVAL); 1265 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 1266 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; 1267 } 1268 if (spec->stream_analog_capture) { 1269 snd_assert(spec->adc_nids, return -EINVAL); 1270 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 1271 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; 1272 } 1273 1274 if (spec->channel_mode) { 1275 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 1276 for (i = 0; i < spec->num_channel_mode; i++) { 1277 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { 1278 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 1279 } 1280 } 1281 } 1282 1283 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 1284 codec->num_pcms++; 1285 info++; 1286 info->name = spec->stream_name_digital; 1287 if (spec->multiout.dig_out_nid && 1288 spec->stream_digital_playback) { 1289 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 1290 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 1291 } 1292 if (spec->dig_in_nid && 1293 spec->stream_digital_capture) { 1294 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); 1295 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 1296 } 1297 } 1298 1299 return 0; 1300 } 1301 1302 static void alc_free(struct hda_codec *codec) 1303 { 1304 struct alc_spec *spec = codec->spec; 1305 unsigned int i; 1306 1307 if (! spec) 1308 return; 1309 1310 if (spec->kctl_alloc) { 1311 for (i = 0; i < spec->num_kctl_used; i++) 1312 kfree(spec->kctl_alloc[i].name); 1313 kfree(spec->kctl_alloc); 1314 } 1315 kfree(spec); 1316 } 1317 1318 /* 1319 */ 1320 static struct hda_codec_ops alc_patch_ops = { 1321 .build_controls = alc_build_controls, 1322 .build_pcms = alc_build_pcms, 1323 .init = alc_init, 1324 .free = alc_free, 1325 #ifdef CONFIG_PM 1326 .resume = alc_resume, 1327 #endif 1328 }; 1329 1330 1331 /* 1332 * Test configuration for debugging 1333 * 1334 * Almost all inputs/outputs are enabled. I/O pins can be configured via 1335 * enum controls. 1336 */ 1337 #ifdef CONFIG_SND_DEBUG 1338 static hda_nid_t alc880_test_dac_nids[4] = { 1339 0x02, 0x03, 0x04, 0x05 1340 }; 1341 1342 static struct hda_input_mux alc880_test_capture_source = { 1343 .num_items = 5, 1344 .items = { 1345 { "In-1", 0x0 }, 1346 { "In-2", 0x1 }, 1347 { "In-3", 0x2 }, 1348 { "In-4", 0x3 }, 1349 { "CD", 0x4 }, 1350 }, 1351 }; 1352 1353 static struct hda_channel_mode alc880_test_modes[4] = { 1354 { 2, NULL }, 1355 { 4, NULL }, 1356 { 6, NULL }, 1357 { 8, NULL }, 1358 }; 1359 1360 static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1361 { 1362 static char *texts[] = { 1363 "N/A", "Line Out", "HP Out", 1364 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" 1365 }; 1366 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1367 uinfo->count = 1; 1368 uinfo->value.enumerated.items = 8; 1369 if (uinfo->value.enumerated.item >= 8) 1370 uinfo->value.enumerated.item = 7; 1371 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1372 return 0; 1373 } 1374 1375 static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1376 { 1377 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1378 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1379 unsigned int pin_ctl, item = 0; 1380 1381 pin_ctl = snd_hda_codec_read(codec, nid, 0, 1382 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1383 if (pin_ctl & AC_PINCTL_OUT_EN) { 1384 if (pin_ctl & AC_PINCTL_HP_EN) 1385 item = 2; 1386 else 1387 item = 1; 1388 } else if (pin_ctl & AC_PINCTL_IN_EN) { 1389 switch (pin_ctl & AC_PINCTL_VREFEN) { 1390 case AC_PINCTL_VREF_HIZ: item = 3; break; 1391 case AC_PINCTL_VREF_50: item = 4; break; 1392 case AC_PINCTL_VREF_GRD: item = 5; break; 1393 case AC_PINCTL_VREF_80: item = 6; break; 1394 case AC_PINCTL_VREF_100: item = 7; break; 1395 } 1396 } 1397 ucontrol->value.enumerated.item[0] = item; 1398 return 0; 1399 } 1400 1401 static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1402 { 1403 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1404 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1405 static unsigned int ctls[] = { 1406 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, 1407 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, 1408 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, 1409 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, 1410 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, 1411 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, 1412 }; 1413 unsigned int old_ctl, new_ctl; 1414 1415 old_ctl = snd_hda_codec_read(codec, nid, 0, 1416 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1417 new_ctl = ctls[ucontrol->value.enumerated.item[0]]; 1418 if (old_ctl != new_ctl) { 1419 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); 1420 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1421 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); 1422 return 1; 1423 } 1424 return 0; 1425 } 1426 1427 static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 1428 { 1429 static char *texts[] = { 1430 "Front", "Surround", "CLFE", "Side" 1431 }; 1432 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1433 uinfo->count = 1; 1434 uinfo->value.enumerated.items = 4; 1435 if (uinfo->value.enumerated.item >= 4) 1436 uinfo->value.enumerated.item = 3; 1437 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1438 return 0; 1439 } 1440 1441 static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1442 { 1443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1444 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1445 unsigned int sel; 1446 1447 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); 1448 ucontrol->value.enumerated.item[0] = sel & 3; 1449 return 0; 1450 } 1451 1452 static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 1453 { 1454 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1455 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1456 unsigned int sel; 1457 1458 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; 1459 if (ucontrol->value.enumerated.item[0] != sel) { 1460 sel = ucontrol->value.enumerated.item[0] & 3; 1461 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); 1462 return 1; 1463 } 1464 return 0; 1465 } 1466 1467 #define PIN_CTL_TEST(xname,nid) { \ 1468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1469 .name = xname, \ 1470 .info = alc_test_pin_ctl_info, \ 1471 .get = alc_test_pin_ctl_get, \ 1472 .put = alc_test_pin_ctl_put, \ 1473 .private_value = nid \ 1474 } 1475 1476 #define PIN_SRC_TEST(xname,nid) { \ 1477 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1478 .name = xname, \ 1479 .info = alc_test_pin_src_info, \ 1480 .get = alc_test_pin_src_get, \ 1481 .put = alc_test_pin_src_put, \ 1482 .private_value = nid \ 1483 } 1484 1485 static struct snd_kcontrol_new alc880_test_mixer[] = { 1486 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1487 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 1488 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), 1489 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 1490 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 1491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 1492 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT), 1493 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 1494 PIN_CTL_TEST("Front Pin Mode", 0x14), 1495 PIN_CTL_TEST("Surround Pin Mode", 0x15), 1496 PIN_CTL_TEST("CLFE Pin Mode", 0x16), 1497 PIN_CTL_TEST("Side Pin Mode", 0x17), 1498 PIN_CTL_TEST("In-1 Pin Mode", 0x18), 1499 PIN_CTL_TEST("In-2 Pin Mode", 0x19), 1500 PIN_CTL_TEST("In-3 Pin Mode", 0x1a), 1501 PIN_CTL_TEST("In-4 Pin Mode", 0x1b), 1502 PIN_SRC_TEST("In-1 Pin Source", 0x18), 1503 PIN_SRC_TEST("In-2 Pin Source", 0x19), 1504 PIN_SRC_TEST("In-3 Pin Source", 0x1a), 1505 PIN_SRC_TEST("In-4 Pin Source", 0x1b), 1506 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), 1507 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), 1508 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), 1509 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), 1510 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), 1511 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), 1512 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), 1513 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), 1514 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), 1515 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), 479 1516 { 480 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,481 /*.name = */"Channel Mode",0,0,0,482 /*.info = */alc880_ch_mode_info,483 /*.get = */alc880_ch_mode_get,484 /*.put = */alc880_ch_mode_put,01517 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1518 .name = "Channel Mode", 1519 .info = alc_ch_mode_info, 1520 .get = alc_ch_mode_get, 1521 .put = alc_ch_mode_put, 485 1522 }, 486 1523 {0} /* end */ 487 1524 }; 488 1525 489 /* 5-stack mode 490 * Pin assignment: Front=0x14, Rear=0x17, CLFE=0x16 491 * Line-In/Side=0x1a, Mic=0x18, F-Mic=0x1b, HP=0x19 492 */ 493 static snd_kcontrol_new_t alc880_five_stack_mixer[] = { 494 ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT), 495 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 496 ALC_BIND_VOL("Surround Playback Volume", 0x0f, 2, HDA_OUTPUT), 497 HDA_CODEC_MUTE("Surround Playback Switch", 0x17, 0x0, HDA_OUTPUT), 498 ALC_BIND_VOL_MONO("Center Playback Volume", 0x0e, 1, 2, HDA_OUTPUT), 499 ALC_BIND_VOL_MONO("LFE Playback Volume", 0x0e, 2, 2, HDA_OUTPUT), 500 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), 501 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 502 ALC_BIND_VOL("Side Playback Volume", 0x0d, 2, HDA_OUTPUT), 503 HDA_CODEC_MUTE("Side Playback Switch", 0x1a, 0x0, HDA_OUTPUT), 504 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 505 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 506 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 507 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 508 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 509 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 510 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 511 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 512 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 513 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 514 /* HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), */ 515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 516 /* We don't use NID 0x07 - see above */ 517 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 518 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 519 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 520 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 521 { 522 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 523 /* The multiple "Capture Source" controls confuse alsamixer 524 * So call somewhat different.. 525 * FIXME: the controls appear in the "playback" view! 526 */ 527 /* .name = "Capture Source", */ 528 "Input Source",0,0, 529 2, 530 alc_mux_enum_info, 531 alc_mux_enum_get, 532 alc_mux_enum_put,0 533 }, 534 { 535 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 536 "Channel Mode",0,0,0, 537 alc880_ch_mode_info, 538 alc880_ch_mode_get, 539 alc880_ch_mode_put,0 540 }, 541 {0} /* end */ 542 }; 543 544 static snd_kcontrol_new_t alc880_w810_base_mixer[] = { 545 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 546 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 547 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 548 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), 549 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 550 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 551 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), 552 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 554 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 555 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 556 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 557 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 558 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 559 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 1526 static struct hda_verb alc880_test_init_verbs[] = { 1527 /* Unmute inputs of 0x0c - 0x0f */ 1528 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1530 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1531 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1533 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 1535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 1536 /* Vol output for 0x0c-0x0f */ 1537 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1538 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1539 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 1541 /* Set output pins 0x14-0x17 */ 1542 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1543 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1544 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1545 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 1546 /* Unmute output pins 0x14-0x17 */ 1547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1549 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1550 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 1551 /* Set input pins 0x18-0x1c */ 1552 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1553 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 1554 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1555 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1556 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1557 /* Mute input pins 0x18-0x1b */ 1558 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1559 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1561 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 1562 /* ADC set up */ 1563 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1564 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 1565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1566 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 1567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1568 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 1569 /* Analog input/passthru */ 1570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 1571 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 1572 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 1573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 1574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 1575 {0} 1576 }; 1577 #endif 1578 1579 /* 1580 */ 1581 1582 static struct hda_board_config alc880_cfg_tbl[] = { 1583 /* Back 3 jack, front 2 jack */ 1584 { .modelname = "3stack", .config = ALC880_3ST }, 1585 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST }, 1586 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST }, 1587 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST }, 1588 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST }, 1589 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST }, 1590 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST }, 1591 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST }, 1592 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST }, 1593 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST }, 1594 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST }, 1595 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST }, 1596 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST }, 1597 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST }, 1598 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST }, 1599 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST }, 1600 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST }, 1601 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST }, 1602 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST }, 1603 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST }, 1604 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST }, 1605 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST }, 1606 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST }, 1607 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST }, 1608 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST }, 1609 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST }, 1610 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST }, 1611 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST }, 1612 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST }, 1613 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST }, 1614 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, 1615 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, 1616 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, 1617 /* TCL S700 */ 1618 { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, 1619 1620 /* Back 3 jack, front 2 jack (Internal add Aux-In) */ 1621 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, 1622 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST }, 1623 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST }, 1624 1625 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ 1626 { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, 1627 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, 1628 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, 1629 /* Clevo m520G NB */ 1630 { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO }, 1631 1632 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ 1633 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, 1634 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG }, 1635 { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG }, 1636 1637 /* Back 5 jack, front 2 jack */ 1638 { .modelname = "5stack", .config = ALC880_5ST }, 1639 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST }, 1640 { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST }, 1641 { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST }, 1642 { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST }, 1643 { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST }, 1644 1645 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ 1646 { .modelname = "5stack-digout", .config = ALC880_5ST_DIG }, 1647 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG }, 1648 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG }, 1649 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG }, 1650 { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG }, 1651 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG }, 1652 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG }, 1653 { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG }, 1654 { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG }, 1655 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG }, 1656 /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */ 1657 { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG }, 1658 /* note subvendor = 0 below */ 1659 /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */ 1660 1661 { .modelname = "w810", .config = ALC880_W810 }, 1662 { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 }, 1663 1664 { .modelname = "z71v", .config = ALC880_Z71V }, 1665 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, 1666 1667 { .modelname = "6stack", .config = ALC880_6ST }, 1668 { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ 1669 { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, 1670 { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ 1671 1672 { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, 1673 { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG }, 1674 { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, 1675 { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, 1676 { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, 1677 { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, 1678 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, 1679 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, 1680 { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, 1681 { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ 1682 1683 { .modelname = "asus", .config = ALC880_ASUS }, 1684 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, 1685 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG }, 1686 { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG }, 1687 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG }, 1688 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG }, 1689 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS }, 1690 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG }, 1691 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS }, 1692 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, 1693 { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, 1694 { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, 1695 { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, 1696 1697 { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, 1698 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, 1699 1700 { .modelname = "F1734", .config = ALC880_F1734 }, 1701 { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, 1702 { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, 1703 1704 #ifdef CONFIG_SND_DEBUG 1705 { .modelname = "test", .config = ALC880_TEST }, 1706 #endif 1707 { .modelname = "auto", .config = ALC880_AUTO }, 1708 1709 {0} 1710 }; 1711 1712 /* 1713 * ALC880 codec presets 1714 */ 1715 static struct alc_config_preset alc880_presets[] = { 1716 [ALC880_3ST] = { 1717 .mixers = { alc880_three_stack_mixer }, 1718 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 1719 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 1720 .dac_nids = alc880_dac_nids, 1721 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 1722 .channel_mode = alc880_threestack_modes, 1723 .input_mux = &alc880_capture_source, 1724 }, 1725 [ALC880_3ST_DIG] = { 1726 .mixers = { alc880_three_stack_mixer }, 1727 .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs }, 1728 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 1729 .dac_nids = alc880_dac_nids, 1730 .dig_out_nid = ALC880_DIGOUT_NID, 1731 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 1732 .channel_mode = alc880_threestack_modes, 1733 .input_mux = &alc880_capture_source, 1734 }, 1735 [ALC880_TCL_S700] = { 1736 .mixers = { alc880_tcl_s700_mixer }, 1737 .init_verbs = { alc880_volume_init_verbs, 1738 alc880_pin_tcl_S700_init_verbs, 1739 alc880_gpio2_init_verbs }, 1740 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 1741 .dac_nids = alc880_dac_nids, 1742 .hp_nid = 0x03, 1743 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 1744 .channel_mode = alc880_2_jack_modes, 1745 .input_mux = &alc880_capture_source, 1746 }, 1747 [ALC880_5ST] = { 1748 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, 1749 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 1750 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 1751 .dac_nids = alc880_dac_nids, 1752 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 1753 .channel_mode = alc880_fivestack_modes, 1754 .input_mux = &alc880_capture_source, 1755 }, 1756 [ALC880_5ST_DIG] = { 1757 .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer }, 1758 .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, 1759 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 1760 .dac_nids = alc880_dac_nids, 1761 .dig_out_nid = ALC880_DIGOUT_NID, 1762 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes), 1763 .channel_mode = alc880_fivestack_modes, 1764 .input_mux = &alc880_capture_source, 1765 }, 1766 [ALC880_6ST] = { 1767 .mixers = { alc880_six_stack_mixer }, 1768 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 1769 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 1770 .dac_nids = alc880_6st_dac_nids, 1771 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 1772 .channel_mode = alc880_sixstack_modes, 1773 .input_mux = &alc880_6stack_capture_source, 1774 }, 1775 [ALC880_6ST_DIG] = { 1776 .mixers = { alc880_six_stack_mixer }, 1777 .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs }, 1778 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids), 1779 .dac_nids = alc880_6st_dac_nids, 1780 .dig_out_nid = ALC880_DIGOUT_NID, 1781 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes), 1782 .channel_mode = alc880_sixstack_modes, 1783 .input_mux = &alc880_6stack_capture_source, 1784 }, 1785 [ALC880_W810] = { 1786 .mixers = { alc880_w810_base_mixer }, 1787 .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs, 1788 alc880_gpio2_init_verbs }, 1789 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids), 1790 .dac_nids = alc880_w810_dac_nids, 1791 .dig_out_nid = ALC880_DIGOUT_NID, 1792 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes), 1793 .channel_mode = alc880_w810_modes, 1794 .input_mux = &alc880_capture_source, 1795 }, 1796 [ALC880_Z71V] = { 1797 .mixers = { alc880_z71v_mixer }, 1798 .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs }, 1799 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids), 1800 .dac_nids = alc880_z71v_dac_nids, 1801 .dig_out_nid = ALC880_DIGOUT_NID, 1802 .hp_nid = 0x03, 1803 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 1804 .channel_mode = alc880_2_jack_modes, 1805 .input_mux = &alc880_capture_source, 1806 }, 1807 [ALC880_F1734] = { 1808 .mixers = { alc880_f1734_mixer }, 1809 .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs }, 1810 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids), 1811 .dac_nids = alc880_f1734_dac_nids, 1812 .hp_nid = 0x02, 1813 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), 1814 .channel_mode = alc880_2_jack_modes, 1815 .input_mux = &alc880_capture_source, 1816 }, 1817 [ALC880_ASUS] = { 1818 .mixers = { alc880_asus_mixer }, 1819 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 1820 alc880_gpio1_init_verbs }, 1821 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 1822 .dac_nids = alc880_asus_dac_nids, 1823 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 1824 .channel_mode = alc880_asus_modes, 1825 .input_mux = &alc880_capture_source, 1826 }, 1827 [ALC880_ASUS_DIG] = { 1828 .mixers = { alc880_asus_mixer }, 1829 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 1830 alc880_gpio1_init_verbs }, 1831 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 1832 .dac_nids = alc880_asus_dac_nids, 1833 .dig_out_nid = ALC880_DIGOUT_NID, 1834 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 1835 .channel_mode = alc880_asus_modes, 1836 .input_mux = &alc880_capture_source, 1837 }, 1838 [ALC880_ASUS_DIG2] = { 1839 .mixers = { alc880_asus_mixer }, 1840 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 1841 alc880_gpio2_init_verbs }, /* use GPIO2 */ 1842 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 1843 .dac_nids = alc880_asus_dac_nids, 1844 .dig_out_nid = ALC880_DIGOUT_NID, 1845 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 1846 .channel_mode = alc880_asus_modes, 1847 .input_mux = &alc880_capture_source, 1848 }, 1849 [ALC880_ASUS_W1V] = { 1850 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, 1851 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, 1852 alc880_gpio1_init_verbs }, 1853 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 1854 .dac_nids = alc880_asus_dac_nids, 1855 .dig_out_nid = ALC880_DIGOUT_NID, 1856 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 1857 .channel_mode = alc880_asus_modes, 1858 .input_mux = &alc880_capture_source, 1859 }, 1860 [ALC880_UNIWILL_DIG] = { 1861 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, 1862 .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs }, 1863 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 1864 .dac_nids = alc880_asus_dac_nids, 1865 .dig_out_nid = ALC880_DIGOUT_NID, 1866 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), 1867 .channel_mode = alc880_asus_modes, 1868 .input_mux = &alc880_capture_source, 1869 }, 1870 [ALC880_CLEVO] = { 1871 .mixers = { alc880_three_stack_mixer }, 1872 .init_verbs = { alc880_volume_init_verbs, 1873 alc880_pin_clevo_init_verbs }, 1874 .num_dacs = ARRAY_SIZE(alc880_dac_nids), 1875 .dac_nids = alc880_dac_nids, 1876 .hp_nid = 0x03, 1877 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), 1878 .channel_mode = alc880_threestack_modes, 1879 .input_mux = &alc880_capture_source, 1880 }, 1881 #ifdef CONFIG_SND_DEBUG 1882 [ALC880_TEST] = { 1883 .mixers = { alc880_test_mixer }, 1884 .init_verbs = { alc880_test_init_verbs }, 1885 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids), 1886 .dac_nids = alc880_test_dac_nids, 1887 .dig_out_nid = ALC880_DIGOUT_NID, 1888 .num_channel_mode = ARRAY_SIZE(alc880_test_modes), 1889 .channel_mode = alc880_test_modes, 1890 .input_mux = &alc880_test_capture_source, 1891 }, 1892 #endif 1893 }; 1894 1895 /* 1896 * Automatic parse of I/O pins from the BIOS configuration 1897 */ 1898 1899 #define NUM_CONTROL_ALLOC 32 1900 #define NUM_VERB_ALLOC 32 1901 1902 enum { 1903 ALC_CTL_WIDGET_VOL, 1904 ALC_CTL_WIDGET_MUTE, 1905 ALC_CTL_BIND_MUTE, 1906 }; 1907 static struct snd_kcontrol_new alc880_control_templates[] = { 1908 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 1909 HDA_CODEC_MUTE(NULL, 0, 0, 0), 1910 HDA_BIND_MUTE(NULL, 0, 0, 0), 1911 }; 1912 1913 /* add dynamic controls */ 1914 static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) 1915 { 1916 struct snd_kcontrol_new *knew; 1917 1918 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 1919 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 1920 1921 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 1922 if (! knew) 1923 return -ENOMEM; 1924 if (spec->kctl_alloc) { 1925 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 1926 kfree(spec->kctl_alloc); 1927 } 1928 spec->kctl_alloc = knew; 1929 spec->num_kctl_alloc = num; 1930 } 1931 1932 knew = &spec->kctl_alloc[spec->num_kctl_used]; 1933 *knew = alc880_control_templates[type]; 1934 knew->name = kstrdup(name, GFP_KERNEL); 1935 if (! knew->name) 1936 return -ENOMEM; 1937 knew->private_value = val; 1938 spec->num_kctl_used++; 1939 return 0; 1940 } 1941 1942 #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17) 1943 #define alc880_fixed_pin_idx(nid) ((nid) - 0x14) 1944 #define alc880_is_multi_pin(nid) ((nid) >= 0x18) 1945 #define alc880_multi_pin_idx(nid) ((nid) - 0x18) 1946 #define alc880_is_input_pin(nid) ((nid) >= 0x18) 1947 #define alc880_input_pin_idx(nid) ((nid) - 0x18) 1948 #define alc880_idx_to_dac(nid) ((nid) + 0x02) 1949 #define alc880_dac_to_idx(nid) ((nid) - 0x02) 1950 #define alc880_idx_to_mixer(nid) ((nid) + 0x0c) 1951 #define alc880_idx_to_selector(nid) ((nid) + 0x10) 1952 #define ALC880_PIN_CD_NID 0x1c 1953 1954 /* fill in the dac_nids table from the parsed pin configuration */ 1955 static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 1956 { 1957 hda_nid_t nid; 1958 int assigned[4]; 1959 int i, j; 1960 1961 memset(assigned, 0, sizeof(assigned)); 1962 spec->multiout.dac_nids = spec->private_dac_nids; 1963 1964 /* check the pins hardwired to audio widget */ 1965 for (i = 0; i < cfg->line_outs; i++) { 1966 nid = cfg->line_out_pins[i]; 1967 if (alc880_is_fixed_pin(nid)) { 1968 int idx = alc880_fixed_pin_idx(nid); 1969 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); 1970 assigned[idx] = 1; 1971 } 1972 } 1973 /* left pins can be connect to any audio widget */ 1974 for (i = 0; i < cfg->line_outs; i++) { 1975 nid = cfg->line_out_pins[i]; 1976 if (alc880_is_fixed_pin(nid)) 1977 continue; 1978 /* search for an empty channel */ 1979 for (j = 0; j < cfg->line_outs; j++) { 1980 if (! assigned[j]) { 1981 spec->multiout.dac_nids[i] = alc880_idx_to_dac(j); 1982 assigned[j] = 1; 1983 break; 1984 } 1985 } 1986 } 1987 spec->multiout.num_dacs = cfg->line_outs; 1988 return 0; 1989 } 1990 1991 /* add playback controls from the parsed DAC table */ 1992 static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, 1993 const struct auto_pin_cfg *cfg) 1994 { 1995 char name[32]; 1996 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 1997 hda_nid_t nid; 1998 int i, err; 1999 2000 for (i = 0; i < cfg->line_outs; i++) { 2001 if (! spec->multiout.dac_nids[i]) 2002 continue; 2003 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i])); 2004 if (i == 2) { 2005 /* Center/LFE */ 2006 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume", 2007 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 2008 return err; 2009 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume", 2010 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 2011 return err; 2012 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 2013 HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0) 2014 return err; 2015 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 2016 HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0) 2017 return err; 2018 } else { 2019 sprintf(name, "%s Playback Volume", chname[i]); 2020 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 2021 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 2022 return err; 2023 sprintf(name, "%s Playback Switch", chname[i]); 2024 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 2025 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 2026 return err; 2027 } 2028 } 2029 return 0; 2030 } 2031 2032 /* add playback controls for speaker and HP outputs */ 2033 static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, 2034 const char *pfx) 2035 { 2036 hda_nid_t nid; 2037 int err; 2038 char name[32]; 2039 2040 if (! pin) 2041 return 0; 2042 2043 if (alc880_is_fixed_pin(pin)) { 2044 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 2045 if (! spec->multiout.dac_nids[0]) { 2046 /* use this as the primary output */ 2047 spec->multiout.dac_nids[0] = nid; 2048 if (! spec->multiout.num_dacs) 2049 spec->multiout.num_dacs = 1; 2050 } else 2051 /* specify the DAC as the extra output */ 2052 spec->multiout.hp_nid = nid; 2053 /* control HP volume/switch on the output mixer amp */ 2054 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); 2055 sprintf(name, "%s Playback Volume", pfx); 2056 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 2057 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 2058 return err; 2059 sprintf(name, "%s Playback Switch", pfx); 2060 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 2061 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) 2062 return err; 2063 } else if (alc880_is_multi_pin(pin)) { 2064 /* set manual connection */ 2065 if (! spec->multiout.dac_nids[0]) { 2066 /* use this as the primary output */ 2067 spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin)); 2068 if (! spec->multiout.num_dacs) 2069 spec->multiout.num_dacs = 1; 2070 } 2071 /* we have only a switch on HP-out PIN */ 2072 sprintf(name, "%s Playback Switch", pfx); 2073 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 2074 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) 2075 return err; 2076 } 2077 return 0; 2078 } 2079 2080 /* create input playback/capture controls for the given pin */ 2081 static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, 2082 int idx, hda_nid_t mix_nid) 2083 { 2084 char name[32]; 2085 int err; 2086 2087 sprintf(name, "%s Playback Volume", ctlname); 2088 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, 2089 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 2090 return err; 2091 sprintf(name, "%s Playback Switch", ctlname); 2092 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, 2093 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) 2094 return err; 2095 return 0; 2096 } 2097 2098 /* create playback/capture controls for input pins */ 2099 static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 2100 const struct auto_pin_cfg *cfg) 2101 { 2102 struct hda_input_mux *imux = &spec->private_imux; 2103 int i, err, idx; 2104 2105 for (i = 0; i < AUTO_PIN_LAST; i++) { 2106 if (alc880_is_input_pin(cfg->input_pins[i])) { 2107 idx = alc880_input_pin_idx(cfg->input_pins[i]); 2108 err = new_analog_input(spec, cfg->input_pins[i], 2109 auto_pin_cfg_labels[i], 2110 idx, 0x0b); 2111 if (err < 0) 2112 return err; 2113 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 2114 imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); 2115 imux->num_items++; 2116 } 2117 } 2118 return 0; 2119 } 2120 2121 static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, 2122 hda_nid_t nid, int pin_type, 2123 int dac_idx) 2124 { 2125 /* set as output */ 2126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 2127 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 2128 /* need the manual connection? */ 2129 if (alc880_is_multi_pin(nid)) { 2130 struct alc_spec *spec = codec->spec; 2131 int idx = alc880_multi_pin_idx(nid); 2132 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0, 2133 AC_VERB_SET_CONNECT_SEL, 2134 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx])); 2135 } 2136 } 2137 2138 static void alc880_auto_init_multi_out(struct hda_codec *codec) 2139 { 2140 struct alc_spec *spec = codec->spec; 2141 int i; 2142 2143 for (i = 0; i < spec->autocfg.line_outs; i++) { 2144 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 2145 alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 2146 } 2147 } 2148 2149 static void alc880_auto_init_extra_out(struct hda_codec *codec) 2150 { 2151 struct alc_spec *spec = codec->spec; 2152 hda_nid_t pin; 2153 2154 pin = spec->autocfg.speaker_pin; 2155 if (pin) /* connect to front */ 2156 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 2157 pin = spec->autocfg.hp_pin; 2158 if (pin) /* connect to front */ 2159 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 2160 } 2161 2162 static void alc880_auto_init_analog_input(struct hda_codec *codec) 2163 { 2164 struct alc_spec *spec = codec->spec; 2165 int i; 2166 2167 for (i = 0; i < AUTO_PIN_LAST; i++) { 2168 hda_nid_t nid = spec->autocfg.input_pins[i]; 2169 if (alc880_is_input_pin(nid)) { 2170 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2171 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 2172 if (nid != ALC880_PIN_CD_NID) 2173 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 2174 AMP_OUT_MUTE); 2175 } 2176 } 2177 } 2178 2179 /* parse the BIOS configuration and set up the alc_spec */ 2180 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 2181 static int alc880_parse_auto_config(struct hda_codec *codec) 2182 { 2183 struct alc_spec *spec = codec->spec; 2184 int err; 2185 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 2186 2187 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 2188 alc880_ignore)) < 0) 2189 return err; 2190 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 2191 ! spec->autocfg.hp_pin) 2192 return 0; /* can't find valid BIOS pin config */ 2193 2194 if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 2195 (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 2196 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, 2197 "Speaker")) < 0 || 2198 (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, 2199 "Headphone")) < 0 || 2200 (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 2201 return err; 2202 2203 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2204 2205 if (spec->autocfg.dig_out_pin) 2206 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 2207 if (spec->autocfg.dig_in_pin) 2208 spec->dig_in_nid = ALC880_DIGIN_NID; 2209 2210 if (spec->kctl_alloc) 2211 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 2212 2213 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs; 2214 2215 spec->input_mux = &spec->private_imux; 2216 2217 return 1; 2218 } 2219 2220 /* init callback for auto-configuration model -- overriding the default init */ 2221 static int alc880_auto_init(struct hda_codec *codec) 2222 { 2223 alc_init(codec); 2224 alc880_auto_init_multi_out(codec); 2225 alc880_auto_init_extra_out(codec); 2226 alc880_auto_init_analog_input(codec); 2227 return 0; 2228 } 2229 2230 /* 2231 * OK, here we have finally the patch for ALC880 2232 */ 2233 2234 static int patch_alc880(struct hda_codec *codec) 2235 { 2236 struct alc_spec *spec; 2237 int board_config; 2238 int err; 2239 2240 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2241 if (spec == NULL) 2242 return -ENOMEM; 2243 2244 codec->spec = spec; 2245 2246 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); 2247 if (board_config < 0 || board_config >= ALC880_MODEL_LAST) { 2248 printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); 2249 board_config = ALC880_AUTO; 2250 } 2251 2252 if (board_config == ALC880_AUTO) { 2253 /* automatic parse from the BIOS config */ 2254 err = alc880_parse_auto_config(codec); 2255 if (err < 0) { 2256 alc_free(codec); 2257 return err; 2258 } else if (! err) { 2259 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n"); 2260 board_config = ALC880_3ST; 2261 } 2262 } 2263 2264 if (board_config != ALC880_AUTO) 2265 setup_preset(spec, &alc880_presets[board_config]); 2266 2267 spec->stream_name_analog = "ALC880 Analog"; 2268 spec->stream_analog_playback = &alc880_pcm_analog_playback; 2269 spec->stream_analog_capture = &alc880_pcm_analog_capture; 2270 2271 spec->stream_name_digital = "ALC880 Digital"; 2272 spec->stream_digital_playback = &alc880_pcm_digital_playback; 2273 spec->stream_digital_capture = &alc880_pcm_digital_capture; 2274 2275 if (! spec->adc_nids && spec->input_mux) { 2276 /* check whether NID 0x07 is valid */ 2277 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 2278 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 2279 if (wcap != AC_WID_AUD_IN) { 2280 spec->adc_nids = alc880_adc_nids_alt; 2281 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt); 2282 spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer; 2283 spec->num_mixers++; 2284 } else { 2285 spec->adc_nids = alc880_adc_nids; 2286 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 2287 spec->mixers[spec->num_mixers] = alc880_capture_mixer; 2288 spec->num_mixers++; 2289 } 2290 } 2291 2292 codec->patch_ops = alc_patch_ops; 2293 if (board_config == ALC880_AUTO) 2294 codec->patch_ops.init = alc880_auto_init; 2295 2296 return 0; 2297 } 2298 2299 2300 /* 2301 * ALC260 support 2302 */ 2303 2304 static hda_nid_t alc260_dac_nids[1] = { 2305 /* front */ 2306 0x02, 2307 }; 2308 2309 static hda_nid_t alc260_adc_nids[1] = { 2310 /* ADC0 */ 2311 0x04, 2312 }; 2313 2314 static hda_nid_t alc260_adc_nids_alt[1] = { 2315 /* ADC1 */ 2316 0x05, 2317 }; 2318 2319 static hda_nid_t alc260_hp_adc_nids[2] = { 2320 /* ADC1, 0 */ 2321 0x05, 0x04 2322 }; 2323 2324 #define ALC260_DIGOUT_NID 0x03 2325 #define ALC260_DIGIN_NID 0x06 2326 2327 static struct hda_input_mux alc260_capture_source = { 2328 .num_items = 4, 2329 .items = { 2330 { "Mic", 0x0 }, 2331 { "Front Mic", 0x1 }, 2332 { "Line", 0x2 }, 2333 { "CD", 0x4 }, 2334 }, 2335 }; 2336 2337 /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack 2338 * and the internal CD lines. 2339 */ 2340 static struct hda_input_mux alc260_fujitsu_capture_source = { 2341 .num_items = 2, 2342 .items = { 2343 { "Mic/Line", 0x0 }, 2344 { "CD", 0x4 }, 2345 }, 2346 }; 2347 2348 /* 2349 * This is just place-holder, so there's something for alc_build_pcms to look 2350 * at when it calculates the maximum number of channels. ALC260 has no mixer 2351 * element which allows changing the channel mode, so the verb list is 2352 * never used. 2353 */ 2354 static struct hda_channel_mode alc260_modes[1] = { 2355 { 2, NULL }, 2356 }; 2357 2358 2359 /* Mixer combinations 2360 * 2361 * basic: base_output + input + pc_beep + capture 2362 * HP: base_output + input + capture_alt 2363 * HP_3013: hp_3013 + input + capture 2364 * fujitsu: fujitsu + capture 2365 */ 2366 2367 static struct snd_kcontrol_new alc260_base_output_mixer[] = { 2368 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), 2369 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), 2370 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2371 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), 2372 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 2373 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), 2374 {0} /* end */ 2375 }; 2376 2377 static struct snd_kcontrol_new alc260_input_mixer[] = { 2378 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 2379 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 2380 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 2381 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 2382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 2383 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 2384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), 2385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), 2386 {0} /* end */ 2387 }; 2388 2389 static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { 2390 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), 2391 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), 2392 {0} /* end */ 2393 }; 2394 2395 static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { 2396 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2397 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), 2398 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), 2399 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), 2400 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 2401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 2402 HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), 2403 HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), 2404 {0} /* end */ 2405 }; 2406 2407 static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { 2408 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), 2409 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), 2410 ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP), 2411 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 2412 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 2413 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), 2414 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), 2415 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 2416 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 2417 HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 2418 HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), 2419 {0} /* end */ 2420 }; 2421 2422 /* capture mixer elements */ 2423 static struct snd_kcontrol_new alc260_capture_mixer[] = { 2424 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 2425 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), 2426 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), 2427 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), 560 2428 { 561 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,2429 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 562 2430 /* The multiple "Capture Source" controls confuse alsamixer 563 2431 * So call somewhat different.. … … 565 2433 */ 566 2434 /* .name = "Capture Source", */ 567 /*.name = */"Input Source",0,0,568 /*.count = */3,569 /*.info = */alc_mux_enum_info,570 /*.get = */alc_mux_enum_get,571 /*.put = */alc_mux_enum_put,02435 .name = "Input Source", 2436 .count = 2, 2437 .info = alc_mux_enum_info, 2438 .get = alc_mux_enum_get, 2439 .put = alc_mux_enum_put, 572 2440 }, 573 2441 {0} /* end */ 574 2442 }; 575 2443 576 static snd_kcontrol_new_t alc880_z71v_mixer[] = { 577 ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT), 578 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 579 ALC_BIND_VOL("Headphone Playback Volume", 0x0d, 2, HDA_OUTPUT), 580 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 581 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 582 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 585 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 586 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 587 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 588 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 589 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 590 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 591 { 592 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 593 /* The multiple "Capture Source" controls confuse alsamixer 594 * So call somewhat different.. 595 * FIXME: the controls appear in the "playback" view! 596 */ 597 /* .name = */"Capture Source",0,0, 598 // /*.name = */"Input Source",0,0, 599 /*.count = */3, 600 /*.info = */alc_mux_enum_info, 601 /*.get = */alc_mux_enum_get, 602 /*.put = */alc_mux_enum_put,0 603 }, 604 {0} /* end */ 605 }; 606 607 /* 608 */ 609 static int alc_build_controls(struct hda_codec *codec) 610 { 611 struct alc_spec *spec = codec->spec; 612 int err; 613 int i; 614 615 for (i = 0; i < spec->num_mixers; i++) { 616 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 617 if (err < 0) 618 return err; 619 } 620 621 if (spec->multiout.dig_out_nid) { 622 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 623 if (err < 0) 624 return err; 625 } 626 if (spec->dig_in_nid) { 627 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 628 if (err < 0) 629 return err; 630 } 631 return 0; 632 } 633 634 /* 635 * initialize the codec volumes, etc 636 */ 637 638 static struct hda_verb alc880_init_verbs_three_stack[] = { 639 /* Line In pin widget for input */ 640 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 641 /* CD pin widget for input */ 642 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 643 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 645 /* Mic2 (front panel) pin widget for input and vref at 80% */ 646 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 647 /* unmute amp left and right */ 648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 649 /* set connection select to mic in */ 650 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 651 /* unmute amp left and right */ 652 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 653 /* set connection select to mic in */ 654 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 655 /* unmute amp left and right */ 656 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 657 /* set connection select to mic in */ 658 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 659 /* unmute front mixer amp left (volume = 0) */ 660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 661 /* mute pin widget amp left and right (no gain on this amp) */ 662 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 663 /* unmute rear mixer amp left and right (volume = 0) */ 664 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 665 /* mute pin widget amp left and right (no gain on this amp) */ 666 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 667 /* unmute rear mixer amp left and right (volume = 0) */ 668 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 669 /* mute pin widget amp left and right (no gain on this amp) */ 670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 671 672 /* using rear surround as the path for headphone output */ 673 /* unmute rear surround mixer amp left and right (volume = 0) */ 674 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 675 /* PASD 3 stack boards use the Mic 2 as the headphone output */ 676 /* need to program the selector associated with the Mic 2 pin widget to 677 * surround path (index 0x01) for headphone output */ 678 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 679 /* mute pin widget amp left and right (no gain on this amp) */ 680 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 681 /* need to retask the Mic 2 pin widget to output */ 682 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 683 684 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer widget(nid=0x0B) 685 * to support the input path of analog loopback 686 * Note: PASD motherboards uses the Line In 2 as the input for front panel 687 * mic (mic 2) 688 */ 689 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 690 /* unmute CD */ 691 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 692 /* unmute Line In */ 693 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 694 /* unmute Mic 1 */ 695 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 696 /* unmute Line In 2 (for PASD boards Mic 2) */ 697 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 698 699 /* Unmute input amps for the line out paths to support the output path of 700 * analog loopback 701 * the mixers on the output path has 2 inputs, one from the DAC and one 702 * from the mixer 703 */ 704 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 705 /* Unmute Front out path */ 706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 708 /* Unmute Surround (used as HP) out path */ 709 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 710 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 711 /* Unmute C/LFE out path */ 712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */ 714 /* Unmute rear Surround out path */ 715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 717 718 {0} 719 }; 720 721 static struct hda_verb alc880_init_verbs_five_stack[] = { 722 /* Line In pin widget for input */ 723 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 724 /* CD pin widget for input */ 725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 726 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 728 /* Mic2 (front panel) pin widget for input and vref at 80% */ 729 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 730 /* unmute amp left and right */ 731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 732 /* set connection select to mic in */ 733 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 734 /* unmute amp left and right */ 735 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 736 /* set connection select to mic in */ 737 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 738 /* unmute amp left and right */ 739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 740 /* set connection select to mic in */ 741 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 742 /* unmute front mixer amp left and right (volume = 0) */ 743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 744 /* mute pin widget amp left and right (no gain on this amp) */ 745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 746 /* five rear and clfe */ 747 /* unmute rear mixer amp left and right (volume = 0) */ 748 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 749 /* mute pin widget amp left and right (no gain on this amp) */ 750 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 751 /* unmute clfe mixer amp left and right (volume = 0) */ 752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 753 /* mute pin widget amp left and right (no gain on this amp) */ 754 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 755 756 /* using rear surround as the path for headphone output */ 757 /* unmute rear surround mixer amp left and right (volume = 0) */ 758 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 759 /* PASD 3 stack boards use the Mic 2 as the headphone output */ 760 /* need to program the selector associated with the Mic 2 pin widget to 761 * surround path (index 0x01) for headphone output 762 */ 763 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, 764 /* mute pin widget amp left and right (no gain on this amp) */ 765 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 766 /* need to retask the Mic 2 pin widget to output */ 767 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 768 769 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer 770 * widget(nid=0x0B) to support the input path of analog loopback 771 */ 772 /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */ 773 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/ 774 /* unmute CD */ 775 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 776 /* unmute Line In */ 777 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 778 /* unmute Mic 1 */ 779 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 780 /* unmute Line In 2 (for PASD boards Mic 2) */ 781 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 782 783 /* Unmute input amps for the line out paths to support the output path of 784 * analog loopback 785 * the mixers on the output path has 2 inputs, one from the DAC and 786 * one from the mixer 787 */ 788 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 789 /* Unmute Front out path */ 790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 792 /* Unmute Surround (used as HP) out path */ 793 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 794 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 795 /* Unmute C/LFE out path */ 796 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 797 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, /* mute */ 798 /* Unmute rear Surround out path */ 799 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 800 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 801 802 {0} 803 }; 804 805 static struct hda_verb alc880_w810_init_verbs[] = { 806 /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 808 809 /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 811 812 /* front channel selector/amp: output 0: unmuted, max volume */ 813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 814 815 /* front out pin: muted, (no volume selection) */ 816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 817 818 /* front out pin: NOT headphone enable, out enable, vref disabled */ 819 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 820 821 822 /* surround channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 823 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 824 825 /* surround channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 826 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 827 828 /* surround channel selector/amp: output 0: unmuted, max volume */ 829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 830 831 /* surround out pin: muted, (no volume selection) */ 832 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 833 834 /* surround out pin: NOT headphone enable, out enable, vref disabled */ 835 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 836 837 838 /* c/lfe channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 839 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 840 841 /* c/lfe channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 843 844 /* c/lfe channel selector/amp: output 0: unmuted, max volume */ 845 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 846 847 /* c/lfe out pin: muted, (no volume selection) */ 848 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 849 850 /* c/lfe out pin: NOT headphone enable, out enable, vref disabled */ 851 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 852 853 854 /* hphone/speaker input selector: front DAC */ 855 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, 856 857 /* hphone/speaker out pin: muted, (no volume selection) */ 858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 859 860 /* hphone/speaker out pin: NOT headphone enable, out enable, vref disabled */ 861 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 862 863 864 {0} 865 }; 866 867 static struct hda_verb alc880_z71v_init_verbs[] = { 868 /* front channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 869 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 870 /* front channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 871 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 872 /* front channel selector/amp: output 0: unmuted, max volume */ 873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 874 /* front out pin: muted, (no volume selection) */ 875 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 876 /* front out pin: NOT headphone enable, out enable, vref disabled */ 877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 878 /* headphone channel selector/amp: input 0: DAC: unmuted, (no volume selection) */ 879 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 880 /* headphone channel selector/amp: input 1: capture mix: muted, (no volume selection) */ 881 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7180}, 882 /* headphone channel selector/amp: output 0: unmuted, max volume */ 883 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 884 /* headphone out pin: muted, (no volume selection) */ 885 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 886 /* headpohne out pin: headphone enable, out enable, vref disabled */ 887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 888 889 /* Line In pin widget for input */ 890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 891 /* CD pin widget for input */ 892 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 893 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 894 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 895 /* Mic2 (front panel) pin widget for input and vref at 80% */ 896 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 897 /* unmute amp left and right */ 898 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 899 /* set connection select to mic in */ 900 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 901 /* unmute amp left and right */ 902 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 903 /* set connection select to mic in */ 904 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 905 /* unmute amp left and right */ 906 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 907 /* set connection select to mic in */ 908 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 909 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) for mixer 910 * widget(nid=0x0B) to support the input path of analog loopback 911 */ 912 /* Note: PASD motherboards uses the Line In 2 as the input for front panel mic (mic 2) */ 913 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03*/ 914 /* unmute CD */ 915 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 916 /* unmute Line In */ 917 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 918 /* unmute Mic 1 */ 919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 920 /* unmute Line In 2 (for PASD boards Mic 2) */ 921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, 922 923 {0} 924 }; 925 926 static int alc_init(struct hda_codec *codec) 927 { 928 struct alc_spec *spec = codec->spec; 929 snd_hda_sequence_write(codec, spec->init_verbs); 930 return 0; 931 } 932 933 #ifdef CONFIG_PM 934 /* 935 * resume 936 */ 937 static int alc_resume(struct hda_codec *codec) 938 { 939 struct alc_spec *spec = codec->spec; 940 int i; 941 942 alc_init(codec); 943 for (i = 0; i < spec->num_mixers; i++) { 944 snd_hda_resume_ctls(codec, spec->mixers[i]); 945 } 946 if (spec->multiout.dig_out_nid) 947 snd_hda_resume_spdif_out(codec); 948 if (spec->dig_in_nid) 949 snd_hda_resume_spdif_in(codec); 950 return 0; 951 } 952 #endif 953 954 /* 955 * Analog playback callbacks 956 */ 957 static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, 958 struct hda_codec *codec, 959 snd_pcm_substream_t *substream) 960 { 961 struct alc_spec *spec = codec->spec; 962 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); 963 } 964 965 static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 966 struct hda_codec *codec, 967 unsigned int stream_tag, 968 unsigned int format, 969 snd_pcm_substream_t *substream) 970 { 971 struct alc_spec *spec = codec->spec; 972 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, 973 format, substream); 974 } 975 976 static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 977 struct hda_codec *codec, 978 snd_pcm_substream_t *substream) 979 { 980 struct alc_spec *spec = codec->spec; 981 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 982 } 983 984 /* 985 * Digital out 986 */ 987 static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 988 struct hda_codec *codec, 989 snd_pcm_substream_t *substream) 990 { 991 struct alc_spec *spec = codec->spec; 992 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 993 } 994 995 static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 996 struct hda_codec *codec, 997 snd_pcm_substream_t *substream) 998 { 999 struct alc_spec *spec = codec->spec; 1000 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 1001 } 1002 1003 /* 1004 * Analog capture 1005 */ 1006 static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, 1007 struct hda_codec *codec, 1008 unsigned int stream_tag, 1009 unsigned int format, 1010 snd_pcm_substream_t *substream) 1011 { 1012 struct alc_spec *spec = codec->spec; 1013 1014 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 1015 stream_tag, 0, format); 1016 return 0; 1017 } 1018 1019 static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 1020 struct hda_codec *codec, 1021 snd_pcm_substream_t *substream) 1022 { 1023 struct alc_spec *spec = codec->spec; 1024 1025 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0); 1026 return 0; 1027 } 1028 1029 1030 /* 1031 */ 1032 static struct hda_pcm_stream alc880_pcm_analog_playback = { 1033 /*.substreams = */1, 1034 /*.channels_min = */2, 1035 /*.channels_max = */8, 1036 /*.nid = */0x02, /* NID to query formats and rates */ 1037 0,0,0, 1038 /*.ops = */{ 1039 /*.open = */alc880_playback_pcm_open,0, 1040 /*.prepare = */alc880_playback_pcm_prepare, 1041 /*.cleanup = */alc880_playback_pcm_cleanup 1042 }, 1043 }; 1044 1045 static struct hda_pcm_stream alc880_pcm_analog_capture = { 1046 /*.substreams = */2, 1047 /*.channels_min = */2, 1048 /*.channels_max = */2, 1049 /*.nid = */0x08, /* NID to query formats and rates 1050 * (0x07 might be broken on some devices) 1051 */ 1052 0,0,0, 1053 /*.ops = */{ 1054 0,0, 1055 /*.prepare = */alc880_capture_pcm_prepare, 1056 /*.cleanup = */alc880_capture_pcm_cleanup 1057 }, 1058 }; 1059 1060 static struct hda_pcm_stream alc880_pcm_digital_playback = { 1061 /*.substreams = */1, 1062 /*.channels_min = */2, 1063 /*.channels_max = */2, 1064 /* NID is set in alc_build_pcms */ 1065 0,0,0,0, 1066 /*.ops = */{ 1067 /*.open = */alc880_dig_playback_pcm_open, 1068 /*.close = */alc880_dig_playback_pcm_close,0,0 1069 }, 1070 }; 1071 1072 static struct hda_pcm_stream alc880_pcm_digital_capture = { 1073 /*.substreams = */1, 1074 /*.channels_min = */2, 1075 /*.channels_max = */2, 1076 /* NID is set in alc_build_pcms */ 1077 }; 1078 1079 static int alc_build_pcms(struct hda_codec *codec) 1080 { 1081 struct alc_spec *spec = codec->spec; 1082 struct hda_pcm *info = spec->pcm_rec; 1083 int i; 1084 1085 codec->num_pcms = 1; 1086 codec->pcm_info = info; 1087 1088 info->name = spec->stream_name_analog; 1089 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); 1090 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); 1091 1092 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; 1093 for (i = 0; i < spec->num_channel_mode; i++) { 1094 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { 1095 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; 1096 } 1097 } 1098 1099 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 1100 codec->num_pcms++; 1101 info++; 1102 info->name = spec->stream_name_digital; 1103 if (spec->multiout.dig_out_nid) { 1104 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 1105 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 1106 } 1107 if (spec->dig_in_nid) { 1108 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); 1109 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 1110 } 1111 } 1112 1113 return 0; 1114 } 1115 1116 static void alc_free(struct hda_codec *codec) 1117 { 1118 kfree(codec->spec); 1119 } 1120 1121 /* 1122 */ 1123 static struct hda_codec_ops alc_patch_ops = { 1124 /*.build_controls = */alc_build_controls, 1125 /*.build_pcms = */alc_build_pcms, 1126 /*.init = */alc_init, 1127 /*.free = */alc_free,0, 1128 #ifdef CONFIG_PM 1129 0, 1130 /*.resume = */alc_resume, 1131 #endif 1132 }; 1133 1134 /* 1135 * Test configuration for debugging 1136 * 1137 * Almost all inputs/outputs are enabled. I/O pins can be configured via 1138 * enum controls. 1139 */ 1140 #ifdef CONFIG_SND_DEBUG 1141 static hda_nid_t alc880_test_dac_nids[4] = { 1142 0x02, 0x03, 0x04, 0x05 1143 }; 1144 1145 static struct hda_input_mux alc880_test_capture_source = { 1146 .num_items = 5, 1147 .items = { 1148 { "In-1", 0x0 }, 1149 { "In-2", 0x1 }, 1150 { "In-3", 0x2 }, 1151 { "In-4", 0x3 }, 1152 { "CD", 0x4 }, 1153 }, 1154 }; 1155 1156 static struct alc_channel_mode alc880_test_modes[4] = { 1157 { 2, NULL }, 1158 { 4, NULL }, 1159 { 6, NULL }, 1160 { 8, NULL }, 1161 }; 1162 1163 static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 1164 { 1165 static char *texts[] = { 1166 "N/A", "Line Out", "HP Out", 1167 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%" 1168 }; 1169 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1170 uinfo->count = 1; 1171 uinfo->value.enumerated.items = 8; 1172 if (uinfo->value.enumerated.item >= 8) 1173 uinfo->value.enumerated.item = 7; 1174 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1175 return 0; 1176 } 1177 1178 static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1179 { 1180 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1181 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1182 unsigned int pin_ctl, item = 0; 1183 1184 pin_ctl = snd_hda_codec_read(codec, nid, 0, 1185 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1186 if (pin_ctl & AC_PINCTL_OUT_EN) { 1187 if (pin_ctl & AC_PINCTL_HP_EN) 1188 item = 2; 1189 else 1190 item = 1; 1191 } else if (pin_ctl & AC_PINCTL_IN_EN) { 1192 switch (pin_ctl & AC_PINCTL_VREFEN) { 1193 case AC_PINCTL_VREF_HIZ: item = 3; break; 1194 case AC_PINCTL_VREF_50: item = 4; break; 1195 case AC_PINCTL_VREF_GRD: item = 5; break; 1196 case AC_PINCTL_VREF_80: item = 6; break; 1197 case AC_PINCTL_VREF_100: item = 7; break; 1198 } 1199 } 1200 ucontrol->value.enumerated.item[0] = item; 1201 return 0; 1202 } 1203 1204 static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1205 { 1206 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1207 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1208 static unsigned int ctls[] = { 1209 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN, 1210 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ, 1211 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50, 1212 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD, 1213 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80, 1214 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100, 1215 }; 1216 unsigned int old_ctl, new_ctl; 1217 1218 old_ctl = snd_hda_codec_read(codec, nid, 0, 1219 AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 1220 new_ctl = ctls[ucontrol->value.enumerated.item[0]]; 1221 if (old_ctl != new_ctl) { 1222 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl); 1223 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1224 ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000); 1225 return 1; 1226 } 1227 return 0; 1228 } 1229 1230 static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) 1231 { 1232 static char *texts[] = { 1233 "Front", "Surround", "CLFE", "Side" 1234 }; 1235 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; 1236 uinfo->count = 1; 1237 uinfo->value.enumerated.items = 4; 1238 if (uinfo->value.enumerated.item >= 4) 1239 uinfo->value.enumerated.item = 3; 1240 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); 1241 return 0; 1242 } 1243 1244 static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1245 { 1246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1247 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1248 unsigned int sel; 1249 1250 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); 1251 ucontrol->value.enumerated.item[0] = sel & 3; 1252 return 0; 1253 } 1254 1255 static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1256 { 1257 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1258 hda_nid_t nid = (hda_nid_t)kcontrol->private_value; 1259 unsigned int sel; 1260 1261 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3; 1262 if (ucontrol->value.enumerated.item[0] != sel) { 1263 sel = ucontrol->value.enumerated.item[0] & 3; 1264 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel); 1265 return 1; 1266 } 1267 return 0; 1268 } 1269 1270 #define PIN_CTL_TEST(xname,nid) { \ 1271 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1272 .name = xname, \ 1273 .info = alc_test_pin_ctl_info, \ 1274 .get = alc_test_pin_ctl_get, \ 1275 .put = alc_test_pin_ctl_put, \ 1276 .private_value = nid \ 1277 } 1278 1279 #define PIN_SRC_TEST(xname,nid) { \ 1280 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 1281 .name = xname, \ 1282 .info = alc_test_pin_src_info, \ 1283 .get = alc_test_pin_src_get, \ 1284 .put = alc_test_pin_src_put, \ 1285 .private_value = nid \ 1286 } 1287 1288 static snd_kcontrol_new_t alc880_test_mixer[] = { 1289 ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT), 1290 ALC_BIND_VOL("Surround Playback Volume", 0x0d, 2, HDA_OUTPUT), 1291 ALC_BIND_VOL("CLFE Playback Volume", 0x0e, 2, HDA_OUTPUT), 1292 ALC_BIND_VOL("Side Playback Volume", 0x0f, 2, HDA_OUTPUT), 1293 PIN_CTL_TEST("Front Pin Mode", 0x14), 1294 PIN_CTL_TEST("Surround Pin Mode", 0x15), 1295 PIN_CTL_TEST("CLFE Pin Mode", 0x16), 1296 PIN_CTL_TEST("Side Pin Mode", 0x17), 1297 PIN_CTL_TEST("In-1 Pin Mode", 0x18), 1298 PIN_CTL_TEST("In-2 Pin Mode", 0x19), 1299 PIN_CTL_TEST("In-3 Pin Mode", 0x1a), 1300 PIN_CTL_TEST("In-4 Pin Mode", 0x1b), 1301 PIN_SRC_TEST("In-1 Pin Source", 0x18), 1302 PIN_SRC_TEST("In-2 Pin Source", 0x19), 1303 PIN_SRC_TEST("In-3 Pin Source", 0x1a), 1304 PIN_SRC_TEST("In-4 Pin Source", 0x1b), 1305 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT), 1306 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT), 1307 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT), 1308 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT), 1309 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT), 1310 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT), 1311 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT), 1312 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT), 1313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT), 1314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT), 1315 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 1316 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 1317 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 1318 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 1319 { 1320 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1321 .name = "Input Source", 1322 .count = 2, 1323 .info = alc_mux_enum_info, 1324 .get = alc_mux_enum_get, 1325 .put = alc_mux_enum_put, 1326 }, 1327 { 1328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1329 .name = "Channel Mode", 1330 .info = alc880_ch_mode_info, 1331 .get = alc880_ch_mode_get, 1332 .put = alc880_ch_mode_put, 1333 .private_value = ARRAY_SIZE(alc880_test_modes), 1334 }, 1335 { } /* end */ 1336 }; 1337 1338 static struct hda_verb alc880_test_init_verbs[] = { 1339 /* Unmute inputs of 0x0c - 0x0f */ 1340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100}, 1342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100}, 1344 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1345 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100}, 1346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0x7100}, 1348 /* Vol output for 0x0c-0x0f */ 1349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1350 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1351 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1353 /* Set output pins 0x14-0x17 */ 1354 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1356 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1357 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1358 /* Unmute output pins 0x14-0x17 */ 1359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1361 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1362 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1363 /* Set input pins 0x18-0x1c */ 1364 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, /* vref 80% */ 1365 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 1366 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 1367 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 1368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 1369 /* Mute input pins 0x18-0x1b */ 1370 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1371 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1372 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1373 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1374 /* ADC set up */ 1375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1376 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 1377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1378 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 1379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1380 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 1381 { } 1382 }; 1383 #endif 1384 1385 /* 1386 */ 1387 1388 static struct hda_board_config alc880_cfg_tbl[] = { 1389 /* Back 3 jack, front 2 jack */ 1390 { "3stack", ALC880_3ST,0,0 }, 1391 { 0, ALC880_3ST, 0x8086, 0xe200 }, 1392 { 0, ALC880_3ST, 0x8086, 0xe201 }, 1393 { 0, ALC880_3ST, 0x8086, 0xe202 }, 1394 { 0, ALC880_3ST, 0x8086, 0xe203 }, 1395 { 0, ALC880_3ST, 0x8086, 0xe204 }, 1396 { 0, ALC880_3ST, 0x8086, 0xe205 }, 1397 { 0, ALC880_3ST, 0x8086, 0xe206 }, 1398 { 0, ALC880_3ST, 0x8086, 0xe207 }, 1399 { 0, ALC880_3ST, 0x8086, 0xe208 }, 1400 { 0, ALC880_3ST, 0x8086, 0xe209 }, 1401 { 0, ALC880_3ST, 0x8086, 0xe20a }, 1402 { 0, ALC880_3ST, 0x8086, 0xe20b }, 1403 { 0, ALC880_3ST, 0x8086, 0xe20c }, 1404 { 0, ALC880_3ST, 0x8086, 0xe20d }, 1405 { 0, ALC880_3ST, 0x8086, 0xe20e }, 1406 { 0, ALC880_3ST, 0x8086, 0xe20f }, 1407 { 0, ALC880_3ST, 0x8086, 0xe210 }, 1408 { 0, ALC880_3ST, 0x8086, 0xe211 }, 1409 { 0, ALC880_3ST, 0x8086, 0xe214 }, 1410 { 0, ALC880_3ST, 0x8086, 0xe302 }, 1411 { 0, ALC880_3ST, 0x8086, 0xe303 }, 1412 { 0, ALC880_3ST, 0x8086, 0xe304 }, 1413 { 0, ALC880_3ST, 0x8086, 0xe306 }, 1414 { 0, ALC880_3ST, 0x8086, 0xe307 }, 1415 { 0, ALC880_3ST, 0x8086, 0xe404 }, 1416 { 0, ALC880_3ST, 0x8086, 0xa101 }, 1417 { 0, ALC880_3ST, 0x107b, 0x3031 }, 1418 { 0, ALC880_3ST, 0x107b, 0x4036 }, 1419 { 0, ALC880_3ST, 0x107b, 0x4037 }, 1420 { 0, ALC880_3ST, 0x107b, 0x4038 }, 1421 { 0, ALC880_3ST, 0x107b, 0x4040 }, 1422 { 0, ALC880_3ST, 0x107b, 0x4041 }, 1423 1424 /* Back 3 jack, front 2 jack (Internal add Aux-In) */ 1425 { 0, ALC880_3ST, 0x1025, 0xe310, }, 1426 1427 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */ 1428 { "3stack-digout", ALC880_3ST_DIG, 0, 0 }, 1429 { 0, ALC880_3ST_DIG, 0x8086, 0xe308 }, 1430 1431 /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ 1432 { 0, ALC880_3ST_DIG, 0x8086, 0xe305 }, 1433 { 0, ALC880_3ST_DIG, 0x8086, 0xd402 }, 1434 { 0, ALC880_3ST_DIG, 0x1025, 0xe309 }, 1435 1436 /* Back 5 jack, front 2 jack */ 1437 { "5stack", ALC880_5ST, 0, 0 }, 1438 { 0, ALC880_5ST, 0x107b, 0x3033 }, 1439 { 0, ALC880_5ST, 0x107b, 0x4039 }, 1440 { 0, ALC880_5ST, 0x107b, 0x3032 }, 1441 { 0, ALC880_5ST, 0x103c, 0x2a09 }, 1442 1443 /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */ 1444 { "5stack-digout", ALC880_5ST_DIG, 0, 0 }, 1445 { 0, ALC880_5ST_DIG, 0x8086, 0xe224 }, 1446 { 0, ALC880_5ST_DIG, 0x8086, 0xe400 }, 1447 { 0, ALC880_5ST_DIG, 0x8086, 0xe401 }, 1448 { 0, ALC880_5ST_DIG, 0x8086, 0xe402 }, 1449 { 0, ALC880_5ST_DIG, 0x8086, 0xd400 }, 1450 { 0, ALC880_5ST_DIG, 0x8086, 0xd401 }, 1451 { 0, ALC880_5ST_DIG, 0x8086, 0xa100 }, 1452 { 0, ALC880_5ST_DIG, 0x1565, 0x8202 }, 1453 1454 { "w810", ALC880_W810, 0, 0 }, 1455 { 0, ALC880_W810, 0x161f, 0x203d }, 1456 { "z71v", ALC880_Z71V, 0, 0 }, 1457 { 0, ALC880_Z71V, 0x1043, 0x1964 }, 1458 1459 #ifdef CONFIG_SND_DEBUG 1460 { .modelname = "test", .config = ALC880_TEST }, 1461 #endif 1462 1463 {0} 1464 }; 1465 1466 static int patch_alc880(struct hda_codec *codec) 1467 { 1468 struct alc_spec *spec; 1469 int board_config; 1470 1471 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 1472 if (spec == NULL) 1473 return -ENOMEM; 1474 1475 init_MUTEX(&spec->bind_mutex); 1476 codec->spec = spec; 1477 1478 board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl); 1479 if (board_config < 0) { 1480 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC880\n"); 1481 board_config = ALC880_MINIMAL; 1482 } 1483 1484 switch (board_config) { 1485 case ALC880_W810: 1486 spec->mixers[spec->num_mixers] = alc880_w810_base_mixer; 1487 spec->num_mixers++; 1488 break; 1489 case ALC880_5ST: 1490 case ALC880_5ST_DIG: 1491 spec->mixers[spec->num_mixers] = alc880_five_stack_mixer; 1492 spec->num_mixers++; 1493 break; 1494 case ALC880_Z71V: 1495 spec->mixers[spec->num_mixers] = alc880_z71v_mixer; 1496 spec->num_mixers++; 1497 break; 1498 #ifdef CONFIG_SND_DEBUG 1499 case ALC880_TEST: 1500 spec->mixers[spec->num_mixers] = alc880_test_mixer; 1501 spec->num_mixers++; 1502 break; 1503 #endif 1504 default: 1505 spec->mixers[spec->num_mixers] = alc880_base_mixer; 1506 spec->num_mixers++; 1507 break; 1508 } 1509 1510 switch (board_config) { 1511 case ALC880_3ST_DIG: 1512 case ALC880_5ST_DIG: 1513 case ALC880_W810: 1514 case ALC880_Z71V: 1515 case ALC880_TEST: 1516 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 1517 break; 1518 default: 1519 break; 1520 } 1521 1522 switch (board_config) { 1523 case ALC880_3ST: 1524 case ALC880_3ST_DIG: 1525 case ALC880_5ST: 1526 case ALC880_5ST_DIG: 1527 case ALC880_W810: 1528 spec->front_panel = 1; 1529 break; 1530 default: 1531 break; 1532 } 1533 1534 switch (board_config) { 1535 case ALC880_5ST: 1536 case ALC880_5ST_DIG: 1537 spec->init_verbs = alc880_init_verbs_five_stack; 1538 spec->channel_mode = alc880_fivestack_modes; 1539 spec->num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes); 1540 break; 1541 case ALC880_W810: 1542 spec->init_verbs = alc880_w810_init_verbs; 1543 spec->channel_mode = alc880_w810_modes; 1544 spec->num_channel_mode = ARRAY_SIZE(alc880_w810_modes); 1545 break; 1546 case ALC880_Z71V: 1547 spec->init_verbs = alc880_z71v_init_verbs; 1548 spec->channel_mode = alc880_z71v_modes; 1549 spec->num_channel_mode = ARRAY_SIZE(alc880_z71v_modes); 1550 break; 1551 #ifdef CONFIG_SND_DEBUG 1552 case ALC880_TEST: 1553 spec->init_verbs = alc880_test_init_verbs; 1554 spec->channel_mode = alc880_test_modes; 1555 spec->num_channel_mode = ARRAY_SIZE(alc880_test_modes); 1556 break; 1557 #endif 1558 default: 1559 spec->init_verbs = alc880_init_verbs_three_stack; 1560 spec->channel_mode = alc880_threestack_modes; 1561 spec->num_channel_mode = ARRAY_SIZE(alc880_threestack_modes); 1562 break; 1563 } 1564 1565 spec->stream_name_analog = "ALC880 Analog"; 1566 spec->stream_analog_playback = &alc880_pcm_analog_playback; 1567 spec->stream_analog_capture = &alc880_pcm_analog_capture; 1568 1569 spec->stream_name_digital = "ALC880 Digital"; 1570 spec->stream_digital_playback = &alc880_pcm_digital_playback; 1571 spec->stream_digital_capture = &alc880_pcm_digital_capture; 1572 1573 spec->multiout.max_channels = spec->channel_mode[0].channels; 1574 1575 switch (board_config) { 1576 case ALC880_W810: 1577 spec->multiout.num_dacs = ARRAY_SIZE(alc880_w810_dac_nids); 1578 spec->multiout.dac_nids = alc880_w810_dac_nids; 1579 // No dedicated headphone socket - it's shared with built-in speakers. 1580 break; 1581 case ALC880_Z71V: 1582 spec->multiout.num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids); 1583 spec->multiout.dac_nids = alc880_z71v_dac_nids; 1584 spec->multiout.hp_nid = 0x03; 1585 break; 1586 #ifdef CONFIG_SND_DEBUG 1587 case ALC880_TEST: 1588 spec->multiout.num_dacs = ARRAY_SIZE(alc880_test_dac_nids); 1589 spec->multiout.dac_nids = alc880_test_dac_nids; 1590 spec->input_mux = &alc880_test_capture_source; 1591 break; 1592 #endif 1593 default: 1594 spec->multiout.num_dacs = ARRAY_SIZE(alc880_dac_nids); 1595 spec->multiout.dac_nids = alc880_dac_nids; 1596 spec->multiout.hp_nid = 0x03; /* rear-surround NID */ 1597 break; 1598 } 1599 1600 if (! spec->input_mux) 1601 spec->input_mux = &alc880_capture_source; 1602 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids); 1603 spec->adc_nids = alc880_adc_nids; 1604 1605 codec->patch_ops = alc_patch_ops; 1606 1607 return 0; 1608 } 1609 1610 /* 1611 * ALC260 support 1612 */ 1613 1614 /* 1615 * This is just place-holder, so there's something for alc_build_pcms to look 1616 * at when it calculates the maximum number of channels. ALC260 has no mixer 1617 * element which allows changing the channel mode, so the verb list is 1618 * never used. 1619 */ 1620 static struct alc_channel_mode alc260_modes[1] = { 1621 { 2, 0 }, 1622 }; 1623 1624 snd_kcontrol_new_t alc260_base_mixer[] = { 1625 ALC_BIND_VOL("Front Playback Volume", 0x08, 2, HDA_OUTPUT), 1626 /* use LINE2 for the output */ 1627 /* HDA_CODEC_MUTE("Front Playback Switch", 0x0f, 0x0, HDA_OUTPUT), */ 1628 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1629 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 1630 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 1631 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 1632 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 1633 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), 1634 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), 1635 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), 1636 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), 1637 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), 1638 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), 1639 ALC_BIND_VOL("Headphone Playback Volume", 0x09, 2, HDA_OUTPUT), 1640 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT), 1641 ALC_BIND_VOL_MONO("Mono Playback Volume", 0x0a, 1, 2, HDA_OUTPUT), 1642 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), 1643 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), 1644 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), 2444 static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { 2445 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), 2446 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), 1645 2447 { 1646 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 1647 /*.name = */"Capture Source",0,0,0, 1648 /*.info = */alc_mux_enum_info, 1649 /*.get = */alc_mux_enum_get, 1650 /*.put = */alc_mux_enum_put,0 2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2449 /* The multiple "Capture Source" controls confuse alsamixer 2450 * So call somewhat different.. 2451 * FIXME: the controls appear in the "playback" view! 2452 */ 2453 /* .name = "Capture Source", */ 2454 .name = "Input Source", 2455 .count = 1, 2456 .info = alc_mux_enum_info, 2457 .get = alc_mux_enum_get, 2458 .put = alc_mux_enum_put, 1651 2459 }, 1652 2460 {0} /* end */ 1653 2461 }; 1654 2462 2463 /* 2464 * initialization verbs 2465 */ 1655 2466 static struct hda_verb alc260_init_verbs[] = { 1656 2467 /* Line In pin widget for input */ 1657 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},2468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 1658 2469 /* CD pin widget for input */ 1659 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2471 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2472 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2473 /* Mic2 (front panel) pin widget for input and vref at 80% */ 2474 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 2475 /* LINE-2 is used for line-out in rear */ 2476 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2477 /* select line-out */ 2478 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 2479 /* LINE-OUT pin */ 2480 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2481 /* enable HP */ 2482 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2483 /* enable Mono */ 2484 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2485 /* mute capture amp left and right */ 2486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2487 /* set connection select to line in (default select for this ADC) */ 2488 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 2489 /* mute capture amp left and right */ 2490 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2491 /* set connection select to line in (default select for this ADC) */ 2492 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02}, 2493 /* set vol=0 Line-Out mixer amp left and right */ 2494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2495 /* unmute pin widget amp left and right (no gain on this amp) */ 2496 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2497 /* set vol=0 HP mixer amp left and right */ 2498 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2499 /* unmute pin widget amp left and right (no gain on this amp) */ 2500 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2501 /* set vol=0 Mono mixer amp left and right */ 2502 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2503 /* unmute pin widget amp left and right (no gain on this amp) */ 2504 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2505 /* unmute LINE-2 out pin */ 2506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2507 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 2508 /* mute CD */ 2509 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 2510 /* mute Line In */ 2511 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 2512 /* mute Mic */ 2513 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2514 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 2515 /* mute Front out path */ 2516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2517 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2518 /* mute Headphone out path */ 2519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2520 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2521 /* mute Mono out path */ 2522 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2523 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 2524 {0} 2525 }; 2526 2527 static struct hda_verb alc260_hp_init_verbs[] = { 2528 /* Headphone and output */ 2529 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 2530 /* mono output */ 2531 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1660 2532 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 1661 2533 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 1662 2534 /* Mic2 (front panel) pin widget for input and vref at 80% */ 1663 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 1664 /* LINE-2 is used for line-out in rear */ 1665 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1666 /* select line-out */ 1667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 1668 /* LINE-OUT pin */ 1669 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1670 /* enable HP */ 1671 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1672 /* enable Mono */ 1673 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2535 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 2536 /* Line In pin widget for input */ 2537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2538 /* Line-2 pin widget for output */ 2539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2540 /* CD pin widget for input */ 2541 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 1674 2542 /* unmute amp left and right */ 1675 2543 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, … … 1678 2546 /* unmute Line-Out mixer amp left and right (volume = 0) */ 1679 2547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1680 /* mute pin widget amp left and right (no gain on this amp) */ 1681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1682 /* unmute Mono mixer amp left and right (volume = 0) */ 1683 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1684 /* mute pin widget amp left and right (no gain on this amp) */ 1685 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 2548 /* mute pin widget amp left and right (no gain on this amp) */ 2549 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1686 2550 /* unmute HP mixer amp left and right (volume = 0) */ 1687 2551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1688 /* mute pin widget amp left and right (no gain on this amp) */ 1689 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1690 /* mute LINE-2 out */ 1691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 2552 /* mute pin widget amp left and right (no gain on this amp) */ 2553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1692 2554 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 1693 2555 /* unmute CD */ … … 1703 2565 /* Unmute Headphone out path */ 1704 2566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1705 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},1706 /* Unmute Mono out path */1707 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},1708 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},2567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2568 /* Unmute Mono out path */ 2569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2570 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1709 2571 {0} 1710 2572 }; 1711 2573 2574 static struct hda_verb alc260_hp_3013_init_verbs[] = { 2575 /* Line out and output */ 2576 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2577 /* mono output */ 2578 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 2579 /* Mic1 (rear panel) pin widget for input and vref at 80% */ 2580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 2581 /* Mic2 (front panel) pin widget for input and vref at 80% */ 2582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 2583 /* Line In pin widget for input */ 2584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2585 /* Headphone pin widget for output */ 2586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 2587 /* CD pin widget for input */ 2588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 2589 /* unmute amp left and right */ 2590 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 2591 /* set connection select to line in (default select for this ADC) */ 2592 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, 2593 /* unmute Line-Out mixer amp left and right (volume = 0) */ 2594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2595 /* mute pin widget amp left and right (no gain on this amp) */ 2596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 2597 /* unmute HP mixer amp left and right (volume = 0) */ 2598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 2599 /* mute pin widget amp left and right (no gain on this amp) */ 2600 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 2601 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ 2602 /* unmute CD */ 2603 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, 2604 /* unmute Line In */ 2605 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, 2606 /* unmute Mic */ 2607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2608 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ 2609 /* Unmute Front out path */ 2610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2612 /* Unmute Headphone out path */ 2613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2615 /* Unmute Mono out path */ 2616 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 2617 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 2618 {0} 2619 }; 2620 2621 /* Initialisation sequence for ALC260 as configured in Fujitsu S702x 2622 * laptops. 2623 */ 2624 static struct hda_verb alc260_fujitsu_init_verbs[] = { 2625 /* Disable all GPIOs */ 2626 {0x01, AC_VERB_SET_GPIO_MASK, 0}, 2627 /* Internal speaker is connected to headphone pin */ 2628 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 2629 /* Headphone/Line-out jack connects to Line1 pin; make it an output */ 2630 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 2631 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */ 2632 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 2633 /* Ensure all other unused pins are disabled and muted. 2634 * Note: trying to set widget 0x15 to anything blocks all audio 2635 * output for some reason, so just leave that at the default. 2636 */ 2637 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2638 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2639 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2640 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2641 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0}, 2642 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2643 /* Disable digital (SPDIF) pins */ 2644 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0}, 2645 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0}, 2646 2647 /* Start with mixer outputs muted */ 2648 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2650 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 2651 2652 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */ 2653 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2654 /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */ 2655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 2656 /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */ 2657 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2658 2659 /* Mute capture amp left and right */ 2660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 2661 /* Set ADC connection select to line in (on mic1 pin) */ 2662 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 2663 2664 /* Mute all inputs to mixer widget (even unconnected ones) */ 2665 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */ 2666 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */ 2667 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */ 2668 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */ 2669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */ 2670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ 2671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ 2672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ 2673 2674 {0} 2675 }; 2676 1712 2677 static struct hda_pcm_stream alc260_pcm_analog_playback = { 1713 /*.substreams = */1, 1714 /*.channels_min = */2, 1715 /*.channels_max = */2, 1716 /*.nid = */0x2, 2678 .substreams = 1, 2679 .channels_min = 2, 2680 .channels_max = 2, 1717 2681 }; 1718 2682 1719 2683 static struct hda_pcm_stream alc260_pcm_analog_capture = { 1720 /*.substreams = */1, 1721 /*.channels_min = */2, 1722 /*.channels_max = */2, 1723 /*.nid = */0x4, 2684 .substreams = 1, 2685 .channels_min = 2, 2686 .channels_max = 2, 2687 }; 2688 2689 #define alc260_pcm_digital_playback alc880_pcm_digital_playback 2690 #define alc260_pcm_digital_capture alc880_pcm_digital_capture 2691 2692 /* 2693 * for BIOS auto-configuration 2694 */ 2695 2696 static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, 2697 const char *pfx) 2698 { 2699 hda_nid_t nid_vol; 2700 unsigned long vol_val, sw_val; 2701 char name[32]; 2702 int err; 2703 2704 if (nid >= 0x0f && nid < 0x11) { 2705 nid_vol = nid - 0x7; 2706 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); 2707 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 2708 } else if (nid == 0x11) { 2709 nid_vol = nid - 0x7; 2710 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); 2711 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); 2712 } else if (nid >= 0x12 && nid <= 0x15) { 2713 nid_vol = 0x08; 2714 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); 2715 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); 2716 } else 2717 return 0; /* N/A */ 2718 2719 sprintf(name, "%s Playback Volume", pfx); 2720 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) 2721 return err; 2722 snprintf(name, sizeof(name), "%s Playback Switch", pfx); 2723 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) 2724 return err; 2725 return 1; 2726 } 2727 2728 /* add playback controls from the parsed DAC table */ 2729 static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, 2730 const struct auto_pin_cfg *cfg) 2731 { 2732 hda_nid_t nid; 2733 int err; 2734 2735 spec->multiout.num_dacs = 1; 2736 spec->multiout.dac_nids = spec->private_dac_nids; 2737 spec->multiout.dac_nids[0] = 0x02; 2738 2739 nid = cfg->line_out_pins[0]; 2740 if (nid) { 2741 err = alc260_add_playback_controls(spec, nid, "Front"); 2742 if (err < 0) 2743 return err; 2744 } 2745 2746 nid = cfg->speaker_pin; 2747 if (nid) { 2748 err = alc260_add_playback_controls(spec, nid, "Speaker"); 2749 if (err < 0) 2750 return err; 2751 } 2752 2753 nid = cfg->hp_pin; 2754 if (nid) { 2755 err = alc260_add_playback_controls(spec, nid, "Headphone"); 2756 if (err < 0) 2757 return err; 2758 } 2759 return 0; 2760 } 2761 2762 /* create playback/capture controls for input pins */ 2763 static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 2764 const struct auto_pin_cfg *cfg) 2765 { 2766 struct hda_input_mux *imux = &spec->private_imux; 2767 int i, err, idx; 2768 2769 for (i = 0; i < AUTO_PIN_LAST; i++) { 2770 if (cfg->input_pins[i] >= 0x12) { 2771 idx = cfg->input_pins[i] - 0x12; 2772 err = new_analog_input(spec, cfg->input_pins[i], 2773 auto_pin_cfg_labels[i], idx, 0x07); 2774 if (err < 0) 2775 return err; 2776 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 2777 imux->items[imux->num_items].index = idx; 2778 imux->num_items++; 2779 } 2780 if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ 2781 idx = cfg->input_pins[i] - 0x09; 2782 err = new_analog_input(spec, cfg->input_pins[i], 2783 auto_pin_cfg_labels[i], idx, 0x07); 2784 if (err < 0) 2785 return err; 2786 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 2787 imux->items[imux->num_items].index = idx; 2788 imux->num_items++; 2789 } 2790 } 2791 return 0; 2792 } 2793 2794 static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, 2795 hda_nid_t nid, int pin_type, 2796 int sel_idx) 2797 { 2798 /* set as output */ 2799 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 2800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 2801 /* need the manual connection? */ 2802 if (nid >= 0x12) { 2803 int idx = nid - 0x12; 2804 snd_hda_codec_write(codec, idx + 0x0b, 0, 2805 AC_VERB_SET_CONNECT_SEL, sel_idx); 2806 2807 } 2808 } 2809 2810 static void alc260_auto_init_multi_out(struct hda_codec *codec) 2811 { 2812 struct alc_spec *spec = codec->spec; 2813 hda_nid_t nid; 2814 2815 nid = spec->autocfg.line_out_pins[0]; 2816 if (nid) 2817 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 2818 2819 nid = spec->autocfg.speaker_pin; 2820 if (nid) 2821 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 2822 2823 nid = spec->autocfg.hp_pin; 2824 if (nid) 2825 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); 2826 } 2827 2828 #define ALC260_PIN_CD_NID 0x16 2829 static void alc260_auto_init_analog_input(struct hda_codec *codec) 2830 { 2831 struct alc_spec *spec = codec->spec; 2832 int i; 2833 2834 for (i = 0; i < AUTO_PIN_LAST; i++) { 2835 hda_nid_t nid = spec->autocfg.input_pins[i]; 2836 if (nid >= 0x12) { 2837 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 2838 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 2839 if (nid != ALC260_PIN_CD_NID) 2840 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 2841 AMP_OUT_MUTE); 2842 } 2843 } 2844 } 2845 2846 /* 2847 * generic initialization of ADC, input mixers and output mixers 2848 */ 2849 static struct hda_verb alc260_volume_init_verbs[] = { 2850 /* 2851 * Unmute ADC0-1 and set the default input to mic-in 2852 */ 2853 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, 2854 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2855 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, 2856 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2857 2858 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 2859 * mixer widget 2860 * Note: PASD motherboards uses the Line In 2 as the input for front panel 2861 * mic (mic 2) 2862 */ 2863 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 2864 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2865 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 2867 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 2868 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 2869 2870 /* 2871 * Set up output mixers (0x08 - 0x0a) 2872 */ 2873 /* set vol=0 to output mixers */ 2874 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2876 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 2877 /* set up input amps for analog loopback */ 2878 /* Amp Indices: DAC = 0, mixer = 1 */ 2879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2881 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2883 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 2884 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 2885 2886 {0} 2887 }; 2888 2889 static int alc260_parse_auto_config(struct hda_codec *codec) 2890 { 2891 struct alc_spec *spec = codec->spec; 2892 unsigned int wcap; 2893 int err; 2894 static hda_nid_t alc260_ignore[] = { 0x17, 0 }; 2895 2896 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 2897 alc260_ignore)) < 0) 2898 return err; 2899 if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) 2900 return err; 2901 if (! spec->kctl_alloc) 2902 return 0; /* can't find valid BIOS pin config */ 2903 if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 2904 return err; 2905 2906 spec->multiout.max_channels = 2; 2907 2908 if (spec->autocfg.dig_out_pin) 2909 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; 2910 if (spec->kctl_alloc) 2911 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 2912 2913 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; 2914 2915 spec->input_mux = &spec->private_imux; 2916 2917 /* check whether NID 0x04 is valid */ 2918 wcap = get_wcaps(codec, 0x04); 2919 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 2920 if (wcap != AC_WID_AUD_IN) { 2921 spec->adc_nids = alc260_adc_nids_alt; 2922 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); 2923 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; 2924 } else { 2925 spec->adc_nids = alc260_adc_nids; 2926 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 2927 spec->mixers[spec->num_mixers] = alc260_capture_mixer; 2928 } 2929 spec->num_mixers++; 2930 2931 return 1; 2932 } 2933 2934 /* init callback for auto-configuration model -- overriding the default init */ 2935 static int alc260_auto_init(struct hda_codec *codec) 2936 { 2937 alc_init(codec); 2938 alc260_auto_init_multi_out(codec); 2939 alc260_auto_init_analog_input(codec); 2940 return 0; 2941 } 2942 2943 /* 2944 * ALC260 configurations 2945 */ 2946 static struct hda_board_config alc260_cfg_tbl[] = { 2947 { .modelname = "basic", .config = ALC260_BASIC }, 2948 { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb, 2949 .config = ALC260_BASIC }, /* Sony VAIO */ 2950 { .modelname = "hp", .config = ALC260_HP }, 2951 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, 2952 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, 2953 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP }, 2954 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, 2955 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, 2956 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, 2957 { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, 2958 { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, 2959 { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, 2960 { .modelname = "auto", .config = ALC260_AUTO }, 2961 {0} 2962 }; 2963 2964 static struct alc_config_preset alc260_presets[] = { 2965 [ALC260_BASIC] = { 2966 .mixers = { alc260_base_output_mixer, 2967 alc260_input_mixer, 2968 alc260_pc_beep_mixer, 2969 alc260_capture_mixer }, 2970 .init_verbs = { alc260_init_verbs }, 2971 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 2972 .dac_nids = alc260_dac_nids, 2973 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 2974 .adc_nids = alc260_adc_nids, 2975 .num_channel_mode = ARRAY_SIZE(alc260_modes), 2976 .channel_mode = alc260_modes, 2977 .input_mux = &alc260_capture_source, 2978 }, 2979 [ALC260_HP] = { 2980 .mixers = { alc260_base_output_mixer, 2981 alc260_input_mixer, 2982 alc260_capture_alt_mixer }, 2983 .init_verbs = { alc260_hp_init_verbs }, 2984 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 2985 .dac_nids = alc260_dac_nids, 2986 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 2987 .adc_nids = alc260_hp_adc_nids, 2988 .num_channel_mode = ARRAY_SIZE(alc260_modes), 2989 .channel_mode = alc260_modes, 2990 .input_mux = &alc260_capture_source, 2991 }, 2992 [ALC260_HP_3013] = { 2993 .mixers = { alc260_hp_3013_mixer, 2994 alc260_input_mixer, 2995 alc260_capture_alt_mixer }, 2996 .init_verbs = { alc260_hp_3013_init_verbs }, 2997 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 2998 .dac_nids = alc260_dac_nids, 2999 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), 3000 .adc_nids = alc260_hp_adc_nids, 3001 .num_channel_mode = ARRAY_SIZE(alc260_modes), 3002 .channel_mode = alc260_modes, 3003 .input_mux = &alc260_capture_source, 3004 }, 3005 [ALC260_FUJITSU_S702X] = { 3006 .mixers = { alc260_fujitsu_mixer, 3007 alc260_capture_mixer }, 3008 .init_verbs = { alc260_fujitsu_init_verbs }, 3009 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 3010 .dac_nids = alc260_dac_nids, 3011 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), 3012 .adc_nids = alc260_adc_nids, 3013 .num_channel_mode = ARRAY_SIZE(alc260_modes), 3014 .channel_mode = alc260_modes, 3015 .input_mux = &alc260_fujitsu_capture_source, 3016 }, 1724 3017 }; 1725 3018 … … 1727 3020 { 1728 3021 struct alc_spec *spec; 1729 1730 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 3022 int err, board_config; 3023 3024 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1731 3025 if (spec == NULL) 1732 3026 return -ENOMEM; 1733 3027 1734 init_MUTEX(&spec->bind_mutex);1735 3028 codec->spec = spec; 1736 3029 1737 spec->mixers[spec->num_mixers] = alc260_base_mixer; 1738 spec->num_mixers++; 1739 1740 spec->init_verbs = alc260_init_verbs; 1741 spec->channel_mode = alc260_modes; 1742 spec->num_channel_mode = ARRAY_SIZE(alc260_modes); 3030 board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); 3031 if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { 3032 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); 3033 board_config = ALC260_AUTO; 3034 } 3035 3036 if (board_config == ALC260_AUTO) { 3037 /* automatic parse from the BIOS config */ 3038 err = alc260_parse_auto_config(codec); 3039 if (err < 0) { 3040 alc_free(codec); 3041 return err; 3042 } else if (! err) { 3043 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 3044 board_config = ALC260_BASIC; 3045 } 3046 } 3047 3048 if (board_config != ALC260_AUTO) 3049 setup_preset(spec, &alc260_presets[board_config]); 1743 3050 1744 3051 spec->stream_name_analog = "ALC260 Analog"; … … 1746 3053 spec->stream_analog_capture = &alc260_pcm_analog_capture; 1747 3054 1748 spec->multiout.max_channels = spec->channel_mode[0].channels; 1749 spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids); 1750 spec->multiout.dac_nids = alc260_dac_nids; 1751 1752 spec->input_mux = &alc260_capture_source; 1753 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); 1754 spec->adc_nids = alc260_adc_nids; 3055 spec->stream_name_digital = "ALC260 Digital"; 3056 spec->stream_digital_playback = &alc260_pcm_digital_playback; 3057 spec->stream_digital_capture = &alc260_pcm_digital_capture; 1755 3058 1756 3059 codec->patch_ops = alc_patch_ops; 3060 if (board_config == ALC260_AUTO) 3061 codec->patch_ops.init = alc260_auto_init; 1757 3062 1758 3063 return 0; 1759 3064 } 3065 1760 3066 1761 3067 /* … … 1770 3076 * driver yet). 1771 3077 */ 1772 1773 static struct alc_channel_mode alc882_ch_modes[1] = { 1774 { 8, NULL } 3078 #define ALC882_DIGOUT_NID 0x06 3079 #define ALC882_DIGIN_NID 0x0a 3080 3081 static struct hda_channel_mode alc882_ch_modes[1] = { 3082 { 8, NULL } 1775 3083 }; 1776 3084 1777 3085 static hda_nid_t alc882_dac_nids[4] = { 1778 /* front, rear, clfe, rear_surr */ 1779 0x02, 0x03, 0x04, 0x05 1780 }; 1781 1782 static hda_nid_t alc882_adc_nids[3] = { 1783 /* ADC0-2 */ 1784 0x07, 0x08, 0x09, 1785 }; 3086 /* front, rear, clfe, rear_surr */ 3087 0x02, 0x03, 0x04, 0x05 3088 }; 3089 3090 /* identical with ALC880 */ 3091 #define alc882_adc_nids alc880_adc_nids 3092 #define alc882_adc_nids_alt alc880_adc_nids_alt 1786 3093 1787 3094 /* input MUX */ … … 1789 3096 1790 3097 static struct hda_input_mux alc882_capture_source = { 1791 4,1792 {1793 { "Mic", 0x0 },1794 { "Front Mic", 0x1 },1795 { "Line", 0x2 },1796 { "CD", 0x4 },1797 },3098 .num_items = 4, 3099 .items = { 3100 { "Mic", 0x0 }, 3101 { "Front Mic", 0x1 }, 3102 { "Line", 0x2 }, 3103 { "CD", 0x4 }, 3104 }, 1798 3105 }; 1799 3106 … … 1801 3108 #define alc882_mux_enum_get alc_mux_enum_get 1802 3109 1803 static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) 1804 { 1805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1806 struct alc_spec *spec = codec->spec; 1807 const struct hda_input_mux *imux = spec->input_mux; 1808 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1809 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; 1810 hda_nid_t nid = capture_mixers[adc_idx]; 1811 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 1812 unsigned int i, idx; 1813 1814 idx = ucontrol->value.enumerated.item[0]; 1815 if (idx >= imux->num_items) 1816 idx = imux->num_items - 1; 1817 if (*cur_val == idx && ! codec->in_resume) 1818 return 0; 1819 for (i = 0; i < imux->num_items; i++) { 1820 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 1821 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1822 v | (imux->items[i].index << 8)); 1823 } 1824 *cur_val = idx; 1825 return 1; 1826 } 3110 static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 3111 { 3112 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 3113 struct alc_spec *spec = codec->spec; 3114 const struct hda_input_mux *imux = spec->input_mux; 3115 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 3116 static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 }; 3117 hda_nid_t nid = capture_mixers[adc_idx]; 3118 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 3119 unsigned int i, idx; 3120 3121 idx = ucontrol->value.enumerated.item[0]; 3122 if (idx >= imux->num_items) 3123 idx = imux->num_items - 1; 3124 if (*cur_val == idx && ! codec->in_resume) 3125 return 0; 3126 for (i = 0; i < imux->num_items; i++) { 3127 unsigned int v = (i == idx) ? 0x7000 : 0x7080; 3128 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3129 v | (imux->items[i].index << 8)); 3130 } 3131 *cur_val = idx; 3132 return 1; 3133 } 3134 3135 /* 3136 * 6ch mode 3137 */ 3138 static struct hda_verb alc882_sixstack_ch6_init[] = { 3139 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 3140 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3141 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3142 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3143 {0} /* end */ 3144 }; 3145 3146 /* 3147 * 8ch mode 3148 */ 3149 static struct hda_verb alc882_sixstack_ch8_init[] = { 3150 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3151 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3152 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3153 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 3154 {0} /* end */ 3155 }; 3156 3157 static struct hda_channel_mode alc882_sixstack_modes[2] = { 3158 { 6, alc882_sixstack_ch6_init }, 3159 { 8, alc882_sixstack_ch8_init }, 3160 }; 1827 3161 1828 3162 /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 1829 3163 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b 1830 3164 */ 1831 static snd_kcontrol_new_t alc882_base_mixer[] = { 1832 ALC_BIND_VOL("Front Playback Volume", 0x0c, 2, HDA_OUTPUT), 1833 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 1834 ALC_BIND_VOL("Surround Playback Volume", 0x0d, 2, HDA_OUTPUT), 1835 HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT), 1836 ALC_BIND_VOL_MONO("Center Playback Volume", 0x0e, 1, 2, HDA_OUTPUT), 1837 ALC_BIND_VOL_MONO("LFE Playback Volume", 0x0e, 2, 2, HDA_OUTPUT), 1838 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT), 1839 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 1840 ALC_BIND_VOL("Side Playback Volume", 0x0f, 2, HDA_OUTPUT), 1841 HDA_CODEC_MUTE("Side Playback Switch", 0x17, 0x0, HDA_OUTPUT), 1842 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 1843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 1844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 1845 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 1846 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 1847 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1849 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1850 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1851 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 1852 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 1853 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 1854 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 1855 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 1856 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 1857 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 1858 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 1859 { 1860 SNDRV_CTL_ELEM_IFACE_MIXER,0,0, 1861 /* .name = "Capture Source", */ 1862 "Input Source",0,0, 1863 3, 1864 alc882_mux_enum_info, 1865 alc882_mux_enum_get, 1866 alc882_mux_enum_put,0 1867 }, 1868 {0} /* end */ 3165 static struct snd_kcontrol_new alc882_base_mixer[] = { 3166 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 3167 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), 3168 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), 3169 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT), 3170 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT), 3171 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 3172 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT), 3173 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT), 3174 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT), 3175 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT), 3176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 3177 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 3178 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 3179 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 3180 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 3181 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 3182 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 3183 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 3184 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 3185 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), 3186 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), 3187 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 3188 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 3189 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 3190 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 3191 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 3192 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 3193 { 3194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3195 /* .name = "Capture Source", */ 3196 .name = "Input Source", 3197 .count = 3, 3198 .info = alc882_mux_enum_info, 3199 .get = alc882_mux_enum_get, 3200 .put = alc882_mux_enum_put, 3201 }, 3202 {0} /* end */ 3203 }; 3204 3205 static struct snd_kcontrol_new alc882_chmode_mixer[] = { 3206 { 3207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3208 .name = "Channel Mode", 3209 .info = alc_ch_mode_info, 3210 .get = alc_ch_mode_get, 3211 .put = alc_ch_mode_put, 3212 }, 3213 {0} /* end */ 1869 3214 }; 1870 3215 1871 3216 static struct hda_verb alc882_init_verbs[] = { 1872 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 1873 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1875 /* Rear mixer */ 1876 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1878 /* CLFE mixer */ 1879 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1881 /* Side mixer */ 1882 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1883 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1884 1885 /* Front Pin: to output mode */ 1886 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1887 /* Front Pin: mute amp left and right (no volume) */ 1888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1889 /* select Front mixer (0x0c, index 0) */ 1890 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 1891 /* Rear Pin */ 1892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1893 /* Rear Pin: mute amp left and right (no volume) */ 1894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1895 /* select Rear mixer (0x0d, index 1) */ 1896 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 1897 /* CLFE Pin */ 1898 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1899 /* CLFE Pin: mute amp left and right (no volume) */ 1900 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1901 /* select CLFE mixer (0x0e, index 2) */ 1902 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 1903 /* Side Pin */ 1904 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1905 /* Side Pin: mute amp left and right (no volume) */ 1906 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1907 /* select Side mixer (0x0f, index 3) */ 1908 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 1909 /* Headphone Pin */ 1910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 1911 /* Headphone Pin: mute amp left and right (no volume) */ 1912 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 1913 /* select Front mixer (0x0c, index 0) */ 1914 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 1915 /* Mic (rear) pin widget for input and vref at 80% */ 1916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 1917 /* Front Mic pin widget for input and vref at 80% */ 1918 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 1919 /* Line In pin widget for input */ 1920 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 1921 /* CD pin widget for input */ 1922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 1923 1924 /* FIXME: use matrix-type input source selection */ 1925 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 1926 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 1927 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1928 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 1929 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 1930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 1931 /* Input mixer2 */ 1932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 1934 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 1935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 1936 /* Input mixer3 */ 1937 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 1938 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 1939 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 1940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 1941 /* ADC1: unmute amp left and right */ 1942 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1943 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 1944 /* ADC2: unmute amp left and right */ 1945 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1946 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 1947 /* ADC3: unmute amp left and right */ 1948 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, 1949 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 1950 /* Unmute front loopback */ 1951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1952 /* Unmute rear loopback */ 1953 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1954 /* Mute CLFE loopback */ 1955 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))}, 1956 /* Unmute side loopback */ 1957 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, 1958 1959 {0} 1960 }; 3217 /* Front mixer: unmute input/output amp left and right (volume = 0) */ 3218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3221 /* Rear mixer */ 3222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3224 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3225 /* CLFE mixer */ 3226 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3229 /* Side mixer */ 3230 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3233 3234 /* Front Pin: output 0 (0x0c) */ 3235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 3238 /* Rear Pin: output 1 (0x0d) */ 3239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3241 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 3242 /* CLFE Pin: output 2 (0x0e) */ 3243 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3244 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3245 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, 3246 /* Side Pin: output 3 (0x0f) */ 3247 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 3248 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3249 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, 3250 /* Mic (rear) pin: input vref at 80% */ 3251 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3252 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3253 /* Front Mic pin: input vref at 80% */ 3254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3256 /* Line In pin: input */ 3257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3259 /* Line-2 In: Headphone output (output 0 - 0x0c) */ 3260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 3261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 3262 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, 3263 /* CD pin widget for input */ 3264 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3265 3266 /* FIXME: use matrix-type input source selection */ 3267 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 3268 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 3269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 3271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 3272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3273 /* Input mixer2 */ 3274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 3276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 3277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3278 /* Input mixer3 */ 3279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3280 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, 3281 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, 3282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3283 /* ADC1: mute amp left and right */ 3284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3285 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 3286 /* ADC2: mute amp left and right */ 3287 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3288 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 3289 /* ADC3: mute amp left and right */ 3290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3291 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 3292 3293 {0} 3294 }; 3295 3296 /* 3297 * generic initialization of ADC, input mixers and output mixers 3298 */ 3299 static struct hda_verb alc882_auto_init_verbs[] = { 3300 /* 3301 * Unmute ADC0-2 and set the default input to mic-in 3302 */ 3303 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 3304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 3306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3307 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 3308 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3309 3310 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 3311 * mixer widget 3312 * Note: PASD motherboards uses the Line In 2 as the input for front panel 3313 * mic (mic 2) 3314 */ 3315 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 3316 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3317 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3318 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 3319 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 3320 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3321 3322 /* 3323 * Set up output mixers (0x0c - 0x0f) 3324 */ 3325 /* set vol=0 to output mixers */ 3326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3328 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3329 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3330 /* set up input amps for analog loopback */ 3331 /* Amp Indices: DAC = 0, mixer = 1 */ 3332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3336 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3337 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3340 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3341 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3342 3343 /* FIXME: use matrix-type input source selection */ 3344 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 3345 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 3346 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3347 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3348 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3349 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3350 /* Input mixer2 */ 3351 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3352 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3353 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3354 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3355 /* Input mixer3 */ 3356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3360 3361 {0} 3362 }; 3363 3364 /* capture mixer elements */ 3365 static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { 3366 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 3367 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 3368 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), 3369 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), 3370 { 3371 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3372 /* The multiple "Capture Source" controls confuse alsamixer 3373 * So call somewhat different.. 3374 * FIXME: the controls appear in the "playback" view! 3375 */ 3376 /* .name = "Capture Source", */ 3377 .name = "Input Source", 3378 .count = 2, 3379 .info = alc882_mux_enum_info, 3380 .get = alc882_mux_enum_get, 3381 .put = alc882_mux_enum_put, 3382 }, 3383 {0} /* end */ 3384 }; 3385 3386 static struct snd_kcontrol_new alc882_capture_mixer[] = { 3387 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), 3388 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), 3389 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), 3390 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), 3391 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), 3392 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), 3393 { 3394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3395 /* The multiple "Capture Source" controls confuse alsamixer 3396 * So call somewhat different.. 3397 * FIXME: the controls appear in the "playback" view! 3398 */ 3399 /* .name = "Capture Source", */ 3400 .name = "Input Source", 3401 .count = 3, 3402 .info = alc882_mux_enum_info, 3403 .get = alc882_mux_enum_get, 3404 .put = alc882_mux_enum_put, 3405 }, 3406 {0} /* end */ 3407 }; 3408 3409 /* pcm configuration: identiacal with ALC880 */ 3410 #define alc882_pcm_analog_playback alc880_pcm_analog_playback 3411 #define alc882_pcm_analog_capture alc880_pcm_analog_capture 3412 #define alc882_pcm_digital_playback alc880_pcm_digital_playback 3413 #define alc882_pcm_digital_capture alc880_pcm_digital_capture 3414 3415 /* 3416 * configuration and preset 3417 */ 3418 static struct hda_board_config alc882_cfg_tbl[] = { 3419 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, 3420 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, 3421 { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ 3422 { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ 3423 { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ 3424 { .modelname = "auto", .config = ALC861_AUTO }, 3425 {0} 3426 }; 3427 3428 static struct alc_config_preset alc882_presets[] = { 3429 [ALC882_3ST_DIG] = { 3430 .mixers = { alc882_base_mixer }, 3431 .init_verbs = { alc882_init_verbs }, 3432 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 3433 .dac_nids = alc882_dac_nids, 3434 .dig_out_nid = ALC882_DIGOUT_NID, 3435 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 3436 .adc_nids = alc882_adc_nids, 3437 .dig_in_nid = ALC882_DIGIN_NID, 3438 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), 3439 .channel_mode = alc882_ch_modes, 3440 .input_mux = &alc882_capture_source, 3441 }, 3442 [ALC882_6ST_DIG] = { 3443 .mixers = { alc882_base_mixer, alc882_chmode_mixer }, 3444 .init_verbs = { alc882_init_verbs }, 3445 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 3446 .dac_nids = alc882_dac_nids, 3447 .dig_out_nid = ALC882_DIGOUT_NID, 3448 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), 3449 .adc_nids = alc882_adc_nids, 3450 .dig_in_nid = ALC882_DIGIN_NID, 3451 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), 3452 .channel_mode = alc882_sixstack_modes, 3453 .input_mux = &alc882_capture_source, 3454 }, 3455 }; 3456 3457 3458 /* 3459 * BIOS auto configuration 3460 */ 3461 static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 3462 hda_nid_t nid, int pin_type, 3463 int dac_idx) 3464 { 3465 /* set as output */ 3466 struct alc_spec *spec = codec->spec; 3467 int idx; 3468 3469 if (spec->multiout.dac_nids[dac_idx] == 0x25) 3470 idx = 4; 3471 else 3472 idx = spec->multiout.dac_nids[dac_idx] - 2; 3473 3474 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 3475 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 3476 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 3477 3478 } 3479 3480 static void alc882_auto_init_multi_out(struct hda_codec *codec) 3481 { 3482 struct alc_spec *spec = codec->spec; 3483 int i; 3484 3485 for (i = 0; i <= HDA_SIDE; i++) { 3486 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 3487 if (nid) 3488 alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); 3489 } 3490 } 3491 3492 static void alc882_auto_init_hp_out(struct hda_codec *codec) 3493 { 3494 struct alc_spec *spec = codec->spec; 3495 hda_nid_t pin; 3496 3497 pin = spec->autocfg.hp_pin; 3498 if (pin) /* connect to front */ 3499 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ 3500 } 3501 3502 #define alc882_is_input_pin(nid) alc880_is_input_pin(nid) 3503 #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID 3504 3505 static void alc882_auto_init_analog_input(struct hda_codec *codec) 3506 { 3507 struct alc_spec *spec = codec->spec; 3508 int i; 3509 3510 for (i = 0; i < AUTO_PIN_LAST; i++) { 3511 hda_nid_t nid = spec->autocfg.input_pins[i]; 3512 if (alc882_is_input_pin(nid)) { 3513 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 3514 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 3515 if (nid != ALC882_PIN_CD_NID) 3516 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, 3517 AMP_OUT_MUTE); 3518 } 3519 } 3520 } 3521 3522 /* almost identical with ALC880 parser... */ 3523 static int alc882_parse_auto_config(struct hda_codec *codec) 3524 { 3525 struct alc_spec *spec = codec->spec; 3526 int err = alc880_parse_auto_config(codec); 3527 3528 if (err < 0) 3529 return err; 3530 else if (err > 0) 3531 /* hack - override the init verbs */ 3532 spec->init_verbs[0] = alc882_auto_init_verbs; 3533 return err; 3534 } 3535 3536 /* init callback for auto-configuration model -- overriding the default init */ 3537 static int alc882_auto_init(struct hda_codec *codec) 3538 { 3539 alc_init(codec); 3540 alc882_auto_init_multi_out(codec); 3541 alc882_auto_init_hp_out(codec); 3542 alc882_auto_init_analog_input(codec); 3543 return 0; 3544 } 3545 3546 /* 3547 * ALC882 Headphone poll in 3.5.1a or 3.5.2 3548 */ 1961 3549 1962 3550 static int patch_alc882(struct hda_codec *codec) 1963 3551 { 1964 struct alc_spec *spec; 1965 1966 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 1967 if (spec == NULL) 1968 return -ENOMEM; 1969 1970 init_MUTEX(&spec->bind_mutex); 1971 codec->spec = spec; 1972 1973 spec->mixers[spec->num_mixers] = alc882_base_mixer; 1974 spec->num_mixers++; 1975 1976 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 1977 spec->dig_in_nid = ALC880_DIGIN_NID; 1978 spec->front_panel = 1; 1979 spec->init_verbs = alc882_init_verbs; 1980 spec->channel_mode = alc882_ch_modes; 1981 spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes); 1982 1983 spec->stream_name_analog = "ALC882 Analog"; 1984 spec->stream_analog_playback = &alc880_pcm_analog_playback; 1985 spec->stream_analog_capture = &alc880_pcm_analog_capture; 1986 1987 spec->stream_name_digital = "ALC882 Digital"; 1988 spec->stream_digital_playback = &alc880_pcm_digital_playback; 1989 spec->stream_digital_capture = &alc880_pcm_digital_capture; 1990 1991 spec->multiout.max_channels = spec->channel_mode[0].channels; 1992 spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids); 1993 spec->multiout.dac_nids = alc882_dac_nids; 1994 1995 spec->input_mux = &alc882_capture_source; 1996 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 1997 spec->adc_nids = alc882_adc_nids; 1998 1999 codec->patch_ops = alc_patch_ops; 2000 2001 return 0; 3552 struct alc_spec *spec; 3553 int err, board_config; 3554 3555 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3556 if (spec == NULL) 3557 return -ENOMEM; 3558 3559 codec->spec = spec; 3560 3561 board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); 3562 3563 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { 3564 printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n"); 3565 board_config = ALC882_AUTO; 3566 } 3567 3568 if (board_config == ALC882_AUTO) { 3569 /* automatic parse from the BIOS config */ 3570 err = alc882_parse_auto_config(codec); 3571 if (err < 0) { 3572 alc_free(codec); 3573 return err; 3574 } else if (! err) { 3575 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 3576 board_config = ALC882_3ST_DIG; 3577 } 3578 } 3579 3580 if (board_config != ALC882_AUTO) 3581 setup_preset(spec, &alc882_presets[board_config]); 3582 3583 spec->stream_name_analog = "ALC882 Analog"; 3584 spec->stream_analog_playback = &alc882_pcm_analog_playback; 3585 spec->stream_analog_capture = &alc882_pcm_analog_capture; 3586 3587 spec->stream_name_digital = "ALC882 Digital"; 3588 spec->stream_digital_playback = &alc882_pcm_digital_playback; 3589 spec->stream_digital_capture = &alc882_pcm_digital_capture; 3590 3591 if (! spec->adc_nids && spec->input_mux) { 3592 /* check whether NID 0x07 is valid */ 3593 unsigned int wcap = get_wcaps(codec, 0x07); 3594 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 3595 if (wcap != AC_WID_AUD_IN) { 3596 spec->adc_nids = alc882_adc_nids_alt; 3597 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); 3598 spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; 3599 spec->num_mixers++; 3600 } else { 3601 spec->adc_nids = alc882_adc_nids; 3602 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); 3603 spec->mixers[spec->num_mixers] = alc882_capture_mixer; 3604 spec->num_mixers++; 3605 } 3606 } 3607 3608 codec->patch_ops = alc_patch_ops; 3609 if (board_config == ALC882_AUTO) 3610 codec->patch_ops.init = alc882_auto_init; 3611 3612 return 0; 3613 } 3614 3615 /* 3616 * ALC262 support 3617 */ 3618 3619 #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID 3620 #define ALC262_DIGIN_NID ALC880_DIGIN_NID 3621 3622 #define alc262_dac_nids alc260_dac_nids 3623 #define alc262_adc_nids alc882_adc_nids 3624 #define alc262_adc_nids_alt alc882_adc_nids_alt 3625 3626 #define alc262_modes alc260_modes 3627 #define alc262_capture_source alc882_capture_source 3628 3629 static struct snd_kcontrol_new alc262_base_mixer[] = { 3630 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 3631 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), 3632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 3633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 3634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 3635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 3636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 3637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 3638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 3639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 3640 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), 3641 HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ 3642 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), 3643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 3644 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 3645 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), 3646 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 3647 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 3648 { 3649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3650 .name = "Capture Source", 3651 .count = 1, 3652 .info = alc882_mux_enum_info, 3653 .get = alc882_mux_enum_get, 3654 .put = alc882_mux_enum_put, 3655 }, 3656 {0} /* end */ 3657 }; 3658 3659 #define alc262_capture_mixer alc882_capture_mixer 3660 #define alc262_capture_alt_mixer alc882_capture_alt_mixer 3661 3662 /* 3663 * generic initialization of ADC, input mixers and output mixers 3664 */ 3665 static struct hda_verb alc262_init_verbs[] = { 3666 /* 3667 * Unmute ADC0-2 and set the default input to mic-in 3668 */ 3669 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 3670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3671 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 3672 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3673 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 3674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3675 3676 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 3677 * mixer widget 3678 * Note: PASD motherboards uses the Line In 2 as the input for front panel 3679 * mic (mic 2) 3680 */ 3681 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 3682 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3683 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3684 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 3685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 3686 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3687 3688 /* 3689 * Set up output mixers (0x0c - 0x0e) 3690 */ 3691 /* set vol=0 to output mixers */ 3692 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3693 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3694 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3695 /* set up input amps for analog loopback */ 3696 /* Amp Indices: DAC = 0, mixer = 1 */ 3697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3700 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3702 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3703 3704 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 3705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, 3706 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, 3707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 3708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 3709 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 3710 3711 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3713 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3714 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3715 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, 3716 3717 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 3718 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 3719 3720 /* FIXME: use matrix-type input source selection */ 3721 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 3722 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 3723 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3727 /* Input mixer2 */ 3728 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3729 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3730 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3731 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3732 /* Input mixer3 */ 3733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3734 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3735 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3736 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3737 3738 {0} 3739 }; 3740 3741 /* add playback controls from the parsed DAC table */ 3742 static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 3743 { 3744 hda_nid_t nid; 3745 int err; 3746 3747 spec->multiout.num_dacs = 1; /* only use one dac */ 3748 spec->multiout.dac_nids = spec->private_dac_nids; 3749 spec->multiout.dac_nids[0] = 2; 3750 3751 nid = cfg->line_out_pins[0]; 3752 if (nid) { 3753 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", 3754 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 3755 return err; 3756 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", 3757 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3758 return err; 3759 } 3760 3761 nid = cfg->speaker_pin; 3762 if (nid) { 3763 if (nid == 0x16) { 3764 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 3765 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 3766 return err; 3767 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 3768 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 3769 return err; 3770 } else { 3771 if (! cfg->line_out_pins[0]) 3772 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", 3773 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 3774 return err; 3775 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", 3776 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3777 return err; 3778 } 3779 } 3780 nid = cfg->hp_pin; 3781 if (nid) { 3782 /* spec->multiout.hp_nid = 2; */ 3783 if (nid == 0x16) { 3784 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 3785 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) 3786 return err; 3787 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 3788 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 3789 return err; 3790 } else { 3791 if (! cfg->line_out_pins[0]) 3792 if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", 3793 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) 3794 return err; 3795 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 3796 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 3797 return err; 3798 } 3799 } 3800 return 0; 3801 } 3802 3803 /* identical with ALC880 */ 3804 #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls 3805 3806 /* 3807 * generic initialization of ADC, input mixers and output mixers 3808 */ 3809 static struct hda_verb alc262_volume_init_verbs[] = { 3810 /* 3811 * Unmute ADC0-2 and set the default input to mic-in 3812 */ 3813 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 3814 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3815 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 3816 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3817 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, 3818 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3819 3820 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback 3821 * mixer widget 3822 * Note: PASD motherboards uses the Line In 2 as the input for front panel 3823 * mic (mic 2) 3824 */ 3825 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ 3826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 3829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 3830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, 3831 3832 /* 3833 * Set up output mixers (0x0c - 0x0f) 3834 */ 3835 /* set vol=0 to output mixers */ 3836 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3837 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3838 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3839 3840 /* set up input amps for analog loopback */ 3841 /* Amp Indices: DAC = 0, mixer = 1 */ 3842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3843 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3844 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3845 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3846 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 3847 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3848 3849 /* FIXME: use matrix-type input source selection */ 3850 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ 3851 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ 3852 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3853 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3854 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3856 /* Input mixer2 */ 3857 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3859 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3860 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3861 /* Input mixer3 */ 3862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, 3863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, 3864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, 3865 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, 3866 3867 {0} 3868 }; 3869 3870 /* pcm configuration: identiacal with ALC880 */ 3871 #define alc262_pcm_analog_playback alc880_pcm_analog_playback 3872 #define alc262_pcm_analog_capture alc880_pcm_analog_capture 3873 #define alc262_pcm_digital_playback alc880_pcm_digital_playback 3874 #define alc262_pcm_digital_capture alc880_pcm_digital_capture 3875 3876 /* 3877 * BIOS auto configuration 3878 */ 3879 static int alc262_parse_auto_config(struct hda_codec *codec) 3880 { 3881 struct alc_spec *spec = codec->spec; 3882 int err; 3883 static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; 3884 3885 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 3886 alc262_ignore)) < 0) 3887 return err; 3888 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 3889 ! spec->autocfg.hp_pin) 3890 return 0; /* can't find valid BIOS pin config */ 3891 if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 3892 (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 3893 return err; 3894 3895 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3896 3897 if (spec->autocfg.dig_out_pin) 3898 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; 3899 if (spec->autocfg.dig_in_pin) 3900 spec->dig_in_nid = ALC262_DIGIN_NID; 3901 3902 if (spec->kctl_alloc) 3903 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 3904 3905 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; 3906 spec->input_mux = &spec->private_imux; 3907 3908 return 1; 3909 } 3910 3911 #define alc262_auto_init_multi_out alc882_auto_init_multi_out 3912 #define alc262_auto_init_hp_out alc882_auto_init_hp_out 3913 #define alc262_auto_init_analog_input alc882_auto_init_analog_input 3914 3915 3916 /* init callback for auto-configuration model -- overriding the default init */ 3917 static int alc262_auto_init(struct hda_codec *codec) 3918 { 3919 alc_init(codec); 3920 alc262_auto_init_multi_out(codec); 3921 alc262_auto_init_hp_out(codec); 3922 alc262_auto_init_analog_input(codec); 3923 return 0; 3924 } 3925 3926 /* 3927 * configuration and preset 3928 */ 3929 static struct hda_board_config alc262_cfg_tbl[] = { 3930 { .modelname = "basic", .config = ALC262_BASIC }, 3931 { .modelname = "auto", .config = ALC262_AUTO }, 3932 {0} 3933 }; 3934 3935 static struct alc_config_preset alc262_presets[] = { 3936 [ALC262_BASIC] = { 3937 .mixers = { alc262_base_mixer }, 3938 .init_verbs = { alc262_init_verbs }, 3939 .num_dacs = ARRAY_SIZE(alc262_dac_nids), 3940 .dac_nids = alc262_dac_nids, 3941 .hp_nid = 0x03, 3942 .num_channel_mode = ARRAY_SIZE(alc262_modes), 3943 .channel_mode = alc262_modes, 3944 .input_mux = &alc262_capture_source, 3945 }, 3946 }; 3947 3948 static int patch_alc262(struct hda_codec *codec) 3949 { 3950 struct alc_spec *spec; 3951 int board_config; 3952 int err; 3953 3954 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 3955 if (spec == NULL) 3956 return -ENOMEM; 3957 3958 codec->spec = spec; 3959 #if 0 3960 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ 3961 { 3962 int tmp; 3963 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 3964 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 3965 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); 3966 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 3967 } 3968 #endif 3969 3970 board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); 3971 if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { 3972 printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n"); 3973 board_config = ALC262_AUTO; 3974 } 3975 3976 if (board_config == ALC262_AUTO) { 3977 /* automatic parse from the BIOS config */ 3978 err = alc262_parse_auto_config(codec); 3979 if (err < 0) { 3980 alc_free(codec); 3981 return err; 3982 } else if (! err) { 3983 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 3984 board_config = ALC262_BASIC; 3985 } 3986 } 3987 3988 if (board_config != ALC262_AUTO) 3989 setup_preset(spec, &alc262_presets[board_config]); 3990 3991 spec->stream_name_analog = "ALC262 Analog"; 3992 spec->stream_analog_playback = &alc262_pcm_analog_playback; 3993 spec->stream_analog_capture = &alc262_pcm_analog_capture; 3994 3995 spec->stream_name_digital = "ALC262 Digital"; 3996 spec->stream_digital_playback = &alc262_pcm_digital_playback; 3997 spec->stream_digital_capture = &alc262_pcm_digital_capture; 3998 3999 if (! spec->adc_nids && spec->input_mux) { 4000 /* check whether NID 0x07 is valid */ 4001 unsigned int wcap = get_wcaps(codec, 0x07); 4002 4003 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ 4004 if (wcap != AC_WID_AUD_IN) { 4005 spec->adc_nids = alc262_adc_nids_alt; 4006 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); 4007 spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; 4008 spec->num_mixers++; 4009 } else { 4010 spec->adc_nids = alc262_adc_nids; 4011 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); 4012 spec->mixers[spec->num_mixers] = alc262_capture_mixer; 4013 spec->num_mixers++; 4014 } 4015 } 4016 4017 codec->patch_ops = alc_patch_ops; 4018 if (board_config == ALC262_AUTO) 4019 codec->patch_ops.init = alc262_auto_init; 4020 4021 return 0; 4022 } 4023 4024 4025 /* 4026 * ALC861 channel source setting (2/6 channel selection for 3-stack) 4027 */ 4028 4029 /* 4030 * set the path ways for 2 channel output 4031 * need to set the codec line out and mic 1 pin widgets to inputs 4032 */ 4033 static struct hda_verb alc861_threestack_ch2_init[] = { 4034 /* set pin widget 1Ah (line in) for input */ 4035 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 4036 /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ 4037 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 4038 4039 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, 4040 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic 4041 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in 4042 {0} /* end */ 4043 }; 4044 /* 4045 * 6ch mode 4046 * need to set the codec line out and mic 1 pin widgets to outputs 4047 */ 4048 static struct hda_verb alc861_threestack_ch6_init[] = { 4049 /* set pin widget 1Ah (line in) for output (Back Surround)*/ 4050 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4051 /* set pin widget 18h (mic1) for output (CLFE)*/ 4052 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4053 4054 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4055 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4056 4057 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, 4058 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic 4059 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in 4060 {0} /* end */ 4061 }; 4062 4063 static struct hda_channel_mode alc861_threestack_modes[2] = { 4064 { 2, alc861_threestack_ch2_init }, 4065 { 6, alc861_threestack_ch6_init }, 4066 }; 4067 4068 /* patch-ALC861 */ 4069 4070 static struct snd_kcontrol_new alc861_base_mixer[] = { 4071 /* output mixer control */ 4072 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 4073 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 4074 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 4075 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 4076 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), 4077 4078 /*Input mixer control */ 4079 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 4080 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 4081 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 4082 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 4083 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 4084 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 4085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 4086 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 4087 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 4088 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 4089 4090 /* Capture mixer control */ 4091 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 4092 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 4093 { 4094 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4095 .name = "Capture Source", 4096 .count = 1, 4097 .info = alc_mux_enum_info, 4098 .get = alc_mux_enum_get, 4099 .put = alc_mux_enum_put, 4100 }, 4101 {0} /* end */ 4102 }; 4103 4104 static struct snd_kcontrol_new alc861_3ST_mixer[] = { 4105 /* output mixer control */ 4106 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), 4107 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), 4108 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), 4109 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), 4110 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ 4111 4112 /* Input mixer control */ 4113 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), 4114 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ 4115 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 4116 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 4117 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), 4118 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), 4119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), 4120 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), 4121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), 4122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), 4123 4124 /* Capture mixer control */ 4125 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 4126 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 4127 { 4128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4129 .name = "Capture Source", 4130 .count = 1, 4131 .info = alc_mux_enum_info, 4132 .get = alc_mux_enum_get, 4133 .put = alc_mux_enum_put, 4134 }, 4135 { 4136 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4137 .name = "Channel Mode", 4138 .info = alc_ch_mode_info, 4139 .get = alc_ch_mode_get, 4140 .put = alc_ch_mode_put, 4141 .private_value = ARRAY_SIZE(alc861_threestack_modes), 4142 }, 4143 {0} /* end */ 4144 }; 4145 4146 /* 4147 * generic initialization of ADC, input mixers and output mixers 4148 */ 4149 static struct hda_verb alc861_base_init_verbs[] = { 4150 /* 4151 * Unmute ADC0 and set the default input to mic-in 4152 */ 4153 /* port-A for surround (rear panel) */ 4154 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4155 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4156 /* port-B for mic-in (rear panel) with vref */ 4157 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 4158 /* port-C for line-in (rear panel) */ 4159 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 4160 /* port-D for Front */ 4161 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4162 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4163 /* port-E for HP out (front panel) */ 4164 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 4165 /* route front PCM to HP */ 4166 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, 4167 /* port-F for mic-in (front panel) with vref */ 4168 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 4169 /* port-G for CLFE (rear panel) */ 4170 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4171 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4172 /* port-H for side (rear panel) */ 4173 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4174 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4175 /* CD-in */ 4176 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 4177 /* route front mic to ADC1*/ 4178 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 4179 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4180 4181 /* Unmute DAC0~3 & spdif out*/ 4182 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4183 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4184 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4185 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4187 4188 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 4189 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4190 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4191 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4192 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4193 4194 /* Unmute Stereo Mixer 15 */ 4195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4196 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 4199 4200 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4201 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4202 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4204 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4206 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 4209 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4210 4211 {0} 4212 }; 4213 4214 static struct hda_verb alc861_threestack_init_verbs[] = { 4215 /* 4216 * Unmute ADC0 and set the default input to mic-in 4217 */ 4218 /* port-A for surround (rear panel) */ 4219 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 4220 /* port-B for mic-in (rear panel) with vref */ 4221 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 4222 /* port-C for line-in (rear panel) */ 4223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 4224 /* port-D for Front */ 4225 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, 4226 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, 4227 /* port-E for HP out (front panel) */ 4228 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, 4229 /* route front PCM to HP */ 4230 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, 4231 /* port-F for mic-in (front panel) with vref */ 4232 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, 4233 /* port-G for CLFE (rear panel) */ 4234 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 4235 /* port-H for side (rear panel) */ 4236 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, 4237 /* CD-in */ 4238 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, 4239 /* route front mic to ADC1*/ 4240 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 4241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4242 /* Unmute DAC0~3 & spdif out*/ 4243 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4244 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4245 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4246 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4248 4249 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 4250 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4251 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4252 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4253 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4254 4255 /* Unmute Stereo Mixer 15 */ 4256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step 4260 4261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4262 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) 4270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4271 {0} 4272 }; 4273 /* 4274 * generic initialization of ADC, input mixers and output mixers 4275 */ 4276 static struct hda_verb alc861_auto_init_verbs[] = { 4277 /* 4278 * Unmute ADC0 and set the default input to mic-in 4279 */ 4280 // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, 4281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4282 4283 /* Unmute DAC0~3 & spdif out*/ 4284 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 4285 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 4286 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 4287 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 4288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 4289 4290 /* Unmute Mixer 14 (mic) 1c (Line in)*/ 4291 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4292 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4293 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4294 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4295 4296 /* Unmute Stereo Mixer 15 */ 4297 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4298 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4299 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4300 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, 4301 4302 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4303 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4304 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4305 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4307 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4308 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 4309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 4310 4311 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4313 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4314 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 4315 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 4316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 4317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, 4318 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, 4319 4320 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 4321 4322 {0} 4323 }; 4324 4325 /* pcm configuration: identiacal with ALC880 */ 4326 #define alc861_pcm_analog_playback alc880_pcm_analog_playback 4327 #define alc861_pcm_analog_capture alc880_pcm_analog_capture 4328 #define alc861_pcm_digital_playback alc880_pcm_digital_playback 4329 #define alc861_pcm_digital_capture alc880_pcm_digital_capture 4330 4331 4332 #define ALC861_DIGOUT_NID 0x07 4333 4334 static struct hda_channel_mode alc861_8ch_modes[1] = { 4335 { 8, NULL } 4336 }; 4337 4338 static hda_nid_t alc861_dac_nids[4] = { 4339 /* front, surround, clfe, side */ 4340 0x03, 0x06, 0x05, 0x04 4341 }; 4342 4343 static hda_nid_t alc861_adc_nids[1] = { 4344 /* ADC0-2 */ 4345 0x08, 4346 }; 4347 4348 static struct hda_input_mux alc861_capture_source = { 4349 .num_items = 5, 4350 .items = { 4351 { "Mic", 0x0 }, 4352 { "Front Mic", 0x3 }, 4353 { "Line", 0x1 }, 4354 { "CD", 0x4 }, 4355 { "Mixer", 0x5 }, 4356 }, 4357 }; 4358 4359 /* fill in the dac_nids table from the parsed pin configuration */ 4360 static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 4361 { 4362 int i; 4363 hda_nid_t nid; 4364 4365 spec->multiout.dac_nids = spec->private_dac_nids; 4366 for (i = 0; i < cfg->line_outs; i++) { 4367 nid = cfg->line_out_pins[i]; 4368 if (nid) { 4369 if (i >= ARRAY_SIZE(alc861_dac_nids)) 4370 continue; 4371 spec->multiout.dac_nids[i] = alc861_dac_nids[i]; 4372 } 4373 } 4374 spec->multiout.num_dacs = cfg->line_outs; 4375 return 0; 4376 } 4377 4378 /* add playback controls from the parsed DAC table */ 4379 static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, 4380 const struct auto_pin_cfg *cfg) 4381 { 4382 char name[32]; 4383 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 4384 hda_nid_t nid; 4385 int i, idx, err; 4386 4387 for (i = 0; i < cfg->line_outs; i++) { 4388 nid = spec->multiout.dac_nids[i]; 4389 if (! nid) 4390 continue; 4391 if (nid == 0x05) { 4392 /* Center/LFE */ 4393 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", 4394 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 4395 return err; 4396 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", 4397 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 4398 return err; 4399 } else { 4400 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) 4401 if (nid == alc861_dac_nids[idx]) 4402 break; 4403 sprintf(name, "%s Playback Switch", chname[idx]); 4404 if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, 4405 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 4406 return err; 4407 } 4408 } 4409 return 0; 4410 } 4411 4412 static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) 4413 { 4414 int err; 4415 hda_nid_t nid; 4416 4417 if (! pin) 4418 return 0; 4419 4420 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { 4421 nid = 0x03; 4422 if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 4423 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 4424 return err; 4425 spec->multiout.hp_nid = nid; 4426 } 4427 return 0; 4428 } 4429 4430 /* create playback/capture controls for input pins */ 4431 static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) 4432 { 4433 struct hda_input_mux *imux = &spec->private_imux; 4434 int i, err, idx, idx1; 4435 4436 for (i = 0; i < AUTO_PIN_LAST; i++) { 4437 switch(cfg->input_pins[i]) { 4438 case 0x0c: 4439 idx1 = 1; 4440 idx = 2; // Line In 4441 break; 4442 case 0x0f: 4443 idx1 = 2; 4444 idx = 2; // Line In 4445 break; 4446 case 0x0d: 4447 idx1 = 0; 4448 idx = 1; // Mic In 4449 break; 4450 case 0x10: 4451 idx1 = 3; 4452 idx = 1; // Mic In 4453 break; 4454 case 0x11: 4455 idx1 = 4; 4456 idx = 0; // CD 4457 break; 4458 default: 4459 continue; 4460 } 4461 4462 err = new_analog_input(spec, cfg->input_pins[i], 4463 auto_pin_cfg_labels[i], idx, 0x15); 4464 if (err < 0) 4465 return err; 4466 4467 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 4468 imux->items[imux->num_items].index = idx1; 4469 imux->num_items++; 4470 } 4471 return 0; 4472 } 4473 4474 static struct snd_kcontrol_new alc861_capture_mixer[] = { 4475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), 4476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), 4477 4478 { 4479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 4480 /* The multiple "Capture Source" controls confuse alsamixer 4481 * So call somewhat different.. 4482 *FIXME: the controls appear in the "playback" view! 4483 */ 4484 /* .name = "Capture Source", */ 4485 .name = "Input Source", 4486 .count = 1, 4487 .info = alc_mux_enum_info, 4488 .get = alc_mux_enum_get, 4489 .put = alc_mux_enum_put, 4490 }, 4491 {0} /* end */ 4492 }; 4493 4494 static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, 4495 int pin_type, int dac_idx) 4496 { 4497 /* set as output */ 4498 4499 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 4500 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 4501 4502 } 4503 4504 static void alc861_auto_init_multi_out(struct hda_codec *codec) 4505 { 4506 struct alc_spec *spec = codec->spec; 4507 int i; 4508 4509 for (i = 0; i < spec->autocfg.line_outs; i++) { 4510 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 4511 if (nid) 4512 alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); 4513 } 4514 } 4515 4516 static void alc861_auto_init_hp_out(struct hda_codec *codec) 4517 { 4518 struct alc_spec *spec = codec->spec; 4519 hda_nid_t pin; 4520 4521 pin = spec->autocfg.hp_pin; 4522 if (pin) /* connect to front */ 4523 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); 4524 } 4525 4526 static void alc861_auto_init_analog_input(struct hda_codec *codec) 4527 { 4528 struct alc_spec *spec = codec->spec; 4529 int i; 4530 4531 for (i = 0; i < AUTO_PIN_LAST; i++) { 4532 hda_nid_t nid = spec->autocfg.input_pins[i]; 4533 if ((nid>=0x0c) && (nid <=0x11)) { 4534 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 4535 i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); 4536 } 4537 } 4538 } 4539 4540 /* parse the BIOS configuration and set up the alc_spec */ 4541 /* return 1 if successful, 0 if the proper config is not found, or a negative error code */ 4542 static int alc861_parse_auto_config(struct hda_codec *codec) 4543 { 4544 struct alc_spec *spec = codec->spec; 4545 int err; 4546 static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; 4547 4548 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4549 alc861_ignore)) < 0) 4550 return err; 4551 if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && 4552 ! spec->autocfg.hp_pin) 4553 return 0; /* can't find valid BIOS pin config */ 4554 4555 if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || 4556 (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 4557 (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || 4558 (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) 4559 return err; 4560 4561 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 4562 4563 if (spec->autocfg.dig_out_pin) 4564 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; 4565 4566 if (spec->kctl_alloc) 4567 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 4568 4569 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; 4570 4571 spec->input_mux = &spec->private_imux; 4572 4573 spec->adc_nids = alc861_adc_nids; 4574 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 4575 spec->mixers[spec->num_mixers] = alc861_capture_mixer; 4576 spec->num_mixers++; 4577 4578 return 1; 4579 } 4580 4581 /* init callback for auto-configuration model -- overriding the default init */ 4582 static int alc861_auto_init(struct hda_codec *codec) 4583 { 4584 alc_init(codec); 4585 alc861_auto_init_multi_out(codec); 4586 alc861_auto_init_hp_out(codec); 4587 alc861_auto_init_analog_input(codec); 4588 4589 return 0; 4590 } 4591 4592 4593 /* 4594 * configuration and preset 4595 */ 4596 static struct hda_board_config alc861_cfg_tbl[] = { 4597 { .modelname = "3stack", .config = ALC861_3ST }, 4598 { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST }, 4599 { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, 4600 { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, 4601 { .modelname = "auto", .config = ALC861_AUTO }, 4602 {0} 4603 }; 4604 4605 static struct alc_config_preset alc861_presets[] = { 4606 [ALC861_3ST] = { 4607 .mixers = { alc861_3ST_mixer }, 4608 .init_verbs = { alc861_threestack_init_verbs }, 4609 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 4610 .dac_nids = alc861_dac_nids, 4611 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 4612 .channel_mode = alc861_threestack_modes, 4613 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 4614 .adc_nids = alc861_adc_nids, 4615 .input_mux = &alc861_capture_source, 4616 }, 4617 [ALC861_3ST_DIG] = { 4618 .mixers = { alc861_base_mixer }, 4619 .init_verbs = { alc861_threestack_init_verbs }, 4620 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 4621 .dac_nids = alc861_dac_nids, 4622 .dig_out_nid = ALC861_DIGOUT_NID, 4623 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), 4624 .channel_mode = alc861_threestack_modes, 4625 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 4626 .adc_nids = alc861_adc_nids, 4627 .input_mux = &alc861_capture_source, 4628 }, 4629 [ALC861_6ST_DIG] = { 4630 .mixers = { alc861_base_mixer }, 4631 .init_verbs = { alc861_base_init_verbs }, 4632 .num_dacs = ARRAY_SIZE(alc861_dac_nids), 4633 .dac_nids = alc861_dac_nids, 4634 .dig_out_nid = ALC861_DIGOUT_NID, 4635 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), 4636 .channel_mode = alc861_8ch_modes, 4637 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), 4638 .adc_nids = alc861_adc_nids, 4639 .input_mux = &alc861_capture_source, 4640 }, 4641 }; 4642 4643 4644 static int patch_alc861(struct hda_codec *codec) 4645 { 4646 struct alc_spec *spec; 4647 int board_config; 4648 int err; 4649 4650 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 4651 if (spec == NULL) 4652 return -ENOMEM; 4653 4654 codec->spec = spec; 4655 4656 board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); 4657 if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { 4658 printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n"); 4659 board_config = ALC861_AUTO; 4660 } 4661 4662 if (board_config == ALC861_AUTO) { 4663 /* automatic parse from the BIOS config */ 4664 err = alc861_parse_auto_config(codec); 4665 if (err < 0) { 4666 alc_free(codec); 4667 return err; 4668 } else if (! err) { 4669 printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); 4670 board_config = ALC861_3ST_DIG; 4671 } 4672 } 4673 4674 if (board_config != ALC861_AUTO) 4675 setup_preset(spec, &alc861_presets[board_config]); 4676 4677 spec->stream_name_analog = "ALC861 Analog"; 4678 spec->stream_analog_playback = &alc861_pcm_analog_playback; 4679 spec->stream_analog_capture = &alc861_pcm_analog_capture; 4680 4681 spec->stream_name_digital = "ALC861 Digital"; 4682 spec->stream_digital_playback = &alc861_pcm_digital_playback; 4683 spec->stream_digital_capture = &alc861_pcm_digital_capture; 4684 4685 codec->patch_ops = alc_patch_ops; 4686 if (board_config == ALC861_AUTO) 4687 codec->patch_ops.init = alc861_auto_init; 4688 4689 return 0; 2002 4690 } 2003 4691 … … 2006 4694 */ 2007 4695 struct hda_codec_preset snd_hda_preset_realtek[] = { 2008 { /*.id = */0x10ec0260, 0,0,0,0,/*.name = */"ALC260", /*.patch = */patch_alc260 }, 2009 { /*.id = */0x10ec0880, 0,0,0,0,/*.name = */"ALC880", /*.patch = */patch_alc880 }, 2010 { /*.id = */0x10ec0882, 0,0,0,0,/*.name = */"ALC882", /*.patch = */patch_alc882 }, 2011 {0} /* terminator */ 2012 }; 4696 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, 4697 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, 4698 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 4699 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, 4700 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, 4701 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, 4702 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, 4703 {0} /* terminator */ 4704 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c
r32 r69 5 5 * 6 6 * Copyright (c) 2005 Embedded Alley Solutions, Inc. 7 * <matt@embeddedalley.com>7 * Matt Porter <mporter@embeddedalley.com> 8 8 * 9 9 * Based on patch_cmedia.c and patch_realtek.c … … 31 31 #include <linux/pci.h> 32 32 #include <sound/core.h> 33 #include <sound/asoundef.h> 33 34 #include "hda_codec.h" 34 35 #include "hda_local.h" 35 36 36 #undef STAC_TEST 37 #define NUM_CONTROL_ALLOC 32 38 #define STAC_HP_EVENT 0x37 39 #define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT) 40 41 #define STAC_REF 0 42 #define STAC_D945GTP3 1 43 #define STAC_D945GTP5 2 37 44 38 45 struct sigmatel_spec { 46 struct snd_kcontrol_new *mixers[4]; 47 unsigned int num_mixers; 48 49 int board_config; 50 unsigned int surr_switch: 1; 51 unsigned int line_switch: 1; 52 unsigned int mic_switch: 1; 53 39 54 /* playback */ 40 55 struct hda_multi_out multiout; 41 hda_nid_t playback_nid;56 hda_nid_t dac_nids[4]; 42 57 43 58 /* capture */ 44 59 hda_nid_t *adc_nids; 60 unsigned int num_adcs; 45 61 hda_nid_t *mux_nids; 46 unsigned int num_adcs; 47 hda_nid_t capture_nid; 48 49 /* power management*/ 50 hda_nid_t *pstate_nids; 51 unsigned int num_pstates; 62 unsigned int num_muxes; 63 hda_nid_t dig_in_nid; 52 64 53 65 /* pin widgets */ 54 66 hda_nid_t *pin_nids; 55 67 unsigned int num_pins; 56 #ifdef STAC_TEST57 68 unsigned int *pin_configs; 58 #endif59 69 60 70 /* codec specific stuff */ 61 71 struct hda_verb *init; 62 s nd_kcontrol_new_t*mixer;72 struct snd_kcontrol_new *mixer; 63 73 64 74 /* capture source */ 65 conststruct hda_input_mux *input_mux;75 struct hda_input_mux *input_mux; 66 76 unsigned int cur_mux[2]; 67 77 68 /* channel mode */ 69 unsigned int num_ch_modes; 70 unsigned int cur_ch_mode; 71 const struct sigmatel_channel_mode *channel_modes; 72 73 struct hda_pcm pcm_rec[1]; /* PCM information */ 78 /* i/o switches */ 79 unsigned int io_switch[2]; 80 81 struct hda_pcm pcm_rec[2]; /* PCM information */ 82 83 /* dynamic controls and input_mux */ 84 struct auto_pin_cfg autocfg; 85 unsigned int num_kctl_alloc, num_kctl_used; 86 struct snd_kcontrol_new *kctl_alloc; 87 struct hda_input_mux private_imux; 74 88 }; 75 89 … … 86 100 }; 87 101 88 static hda_nid_t stac9200_pstate_nids[3] = { 89 0x01, 0x02, 0x03, 102 static hda_nid_t stac922x_adc_nids[2] = { 103 0x06, 0x07, 104 }; 105 106 static hda_nid_t stac922x_mux_nids[2] = { 107 0x12, 0x13, 90 108 }; 91 109 92 110 static hda_nid_t stac9200_pin_nids[8] = { 93 111 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 94 };95 96 static hda_nid_t stac922x_adc_nids[2] = {97 0x06, 0x07,98 };99 100 static hda_nid_t stac922x_mux_nids[2] = {101 0x12, 0x13,102 };103 104 static hda_nid_t stac922x_dac_nids[4] = {105 0x02, 0x03, 0x04, 0x05,106 };107 108 static hda_nid_t stac922x_pstate_nids[7] = {109 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,110 112 }; 111 113 … … 115 117 }; 116 118 117 static int stac92xx_mux_enum_info(s nd_kcontrol_t *kcontrol, snd_ctl_elem_info_t*uinfo)119 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 118 120 { 119 121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 122 124 } 123 125 124 static int stac92xx_mux_enum_get(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)126 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 125 127 { 126 128 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 132 134 } 133 135 134 static int stac92xx_mux_enum_put(s nd_kcontrol_t *kcontrol, snd_ctl_elem_value_t*ucontrol)136 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 135 137 { 136 138 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); … … 142 144 } 143 145 144 static struct hda_verb stac9200_c h2_init[] = {146 static struct hda_verb stac9200_core_init[] = { 145 147 /* set dac0mux for dac converter */ 146 { 0x07, 0x701, 0x00},148 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, 147 149 {0} 148 150 }; 149 151 150 static struct hda_verb stac922x_c h2_init[] = {152 static struct hda_verb stac922x_core_init[] = { 151 153 /* set master volume and direct control */ 152 { 0x16, 0x70f, 0xff},154 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 153 155 {0} 154 156 }; 155 157 156 struct sigmatel_channel_mode { 157 unsigned int channels; 158 const struct hda_verb *sequence; 159 }; 160 161 static snd_kcontrol_new_t stac9200_mixer[] = { 158 static struct snd_kcontrol_new stac9200_mixer[] = { 162 159 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 163 160 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), 164 161 { 165 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER, 0,0,166 /*.name = */"Input Source",0,0,167 /*.count = */1,168 /*.info = */stac92xx_mux_enum_info,169 /*.get = */stac92xx_mux_enum_get,170 /*.put = */stac92xx_mux_enum_put,0162 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 163 .name = "Input Source", 164 .count = 1, 165 .info = stac92xx_mux_enum_info, 166 .get = stac92xx_mux_enum_get, 167 .put = stac92xx_mux_enum_put, 171 168 }, 172 169 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), 173 170 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), 174 HDA_CODEC_VOLUME(" InputMux Volume", 0x0c, 0, HDA_OUTPUT),171 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT), 175 172 {0} /* end */ 176 173 }; 177 174 178 static snd_kcontrol_new_t stac922x_mixer[] = { 179 HDA_CODEC_VOLUME("PCM Playback Volume", 0x2, 0x0, HDA_OUTPUT), 180 HDA_CODEC_MUTE("PCM Playback Switch", 0x2, 0x0, HDA_OUTPUT), 175 /* This needs to be generated dynamically based on sequence */ 176 static struct snd_kcontrol_new stac922x_mixer[] = { 181 177 { 182 /*.iface = */SNDRV_CTL_ELEM_IFACE_MIXER,0,0,183 /*.name = */"Input Source",0,0,184 /*.count = */1,185 /*.info = */stac92xx_mux_enum_info,186 /*.get = */stac92xx_mux_enum_get,187 /*.put = */stac92xx_mux_enum_put,0178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 179 .name = "Input Source", 180 .count = 1, 181 .info = stac92xx_mux_enum_info, 182 .get = stac92xx_mux_enum_get, 183 .put = stac92xx_mux_enum_put, 188 184 }, 189 185 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), … … 193 189 }; 194 190 195 static struct hda_input_mux stac9200_input_mux = {196 /*.num_items = */5,197 /*.items = */{198 { "Port B", 0x0 },199 { "Port C", 0x1 },200 { "Port D", 0x2 },201 { "Port A", 0x3 },202 { "CD", 0x4 },203 }204 };205 206 static struct hda_input_mux stac922x_input_mux = {207 /*.num_items = */7,208 /*.items = */{209 { "Port E", 0x0 },210 { "CD", 0x1 },211 { "Port F", 0x2 },212 { "Port B", 0x3 },213 { "Port C", 0x4 },214 { "Port D", 0x5 },215 { "Port A", 0x6 },216 }217 };218 219 191 static int stac92xx_build_controls(struct hda_codec *codec) 220 192 { 221 193 struct sigmatel_spec *spec = codec->spec; 222 194 int err; 195 int i; 223 196 224 197 err = snd_hda_add_new_ctls(codec, spec->mixer); … … 226 199 return err; 227 200 228 return 0; 229 } 230 231 #ifdef STAC_TEST 232 static unsigned int stac9200_pin_configs[8] = { 233 0x40000100, 0x40000100, 0x0221401f, 0x01114010, 201 for (i = 0; i < spec->num_mixers; i++) { 202 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 203 if (err < 0) 204 return err; 205 } 206 207 if (spec->multiout.dig_out_nid) { 208 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 209 if (err < 0) 210 return err; 211 } 212 if (spec->dig_in_nid) { 213 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 214 if (err < 0) 215 return err; 216 } 217 return 0; 218 } 219 220 static unsigned int ref9200_pin_configs[8] = { 221 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, 234 222 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, 235 223 }; 236 224 237 static unsigned int stac922x_pin_configs[14] = { 238 0x40000100, 0x40000100, 0x40000100, 0x01114010, 239 0x01813122, 0x40000100, 0x40000100, 0x40000100, 225 static unsigned int *stac9200_brd_tbl[] = { 226 ref9200_pin_configs, 227 }; 228 229 static struct hda_board_config stac9200_cfg_tbl[] = { 230 { .modelname = "ref", 231 .pci_subvendor = PCI_VENDOR_ID_INTEL, 232 .pci_subdevice = 0x2668, /* DFI LanParty */ 233 .config = STAC_REF }, 234 {0} /* terminator */ 235 }; 236 237 static unsigned int ref922x_pin_configs[10] = { 238 0x01014010, 0x01016011, 0x01012012, 0x0221401f, 239 0x01813122, 0x01011014, 0x01441030, 0x01c41030, 240 240 0x40000100, 0x40000100, 241 }; 242 243 static unsigned int d945gtp3_pin_configs[10] = { 244 0x0221401f, 0x01a19022, 0x01813021, 0x01114010, 245 0x40000100, 0x40000100, 0x40000100, 0x40000100, 246 0x02a19120, 0x40000100, 247 }; 248 249 static unsigned int d945gtp5_pin_configs[10] = { 250 0x0221401f, 0x01111012, 0x01813024, 0x01114010, 251 0x01a19021, 0x01116011, 0x01452130, 0x40000100, 252 0x02a19320, 0x40000100, 253 }; 254 255 static unsigned int *stac922x_brd_tbl[] = { 256 ref922x_pin_configs, 257 d945gtp3_pin_configs, 258 d945gtp5_pin_configs, 259 }; 260 261 static struct hda_board_config stac922x_cfg_tbl[] = { 262 { .modelname = "ref", 263 .pci_subvendor = PCI_VENDOR_ID_INTEL, 264 .pci_subdevice = 0x2668, /* DFI LanParty */ 265 .config = STAC_REF }, /* SigmaTel reference board */ 266 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 267 .pci_subdevice = 0x0101, 268 .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ 269 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 270 .pci_subdevice = 0x0404, 271 .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */ 272 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 273 .pci_subdevice = 0x0303, 274 .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */ 275 { .pci_subvendor = PCI_VENDOR_ID_INTEL, 276 .pci_subdevice = 0x0013, 277 .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ 278 {0} /* terminator */ 241 279 }; 242 280 … … 263 301 AC_VERB_GET_CONFIG_DEFAULT, 264 302 0x00); 265 printk("pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); 266 } 267 } 268 #endif 269 270 static int stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, unsigned int value) 271 { 272 unsigned int pin_ctl; 273 274 pin_ctl = snd_hda_codec_read(codec, nid, 0, 275 AC_VERB_GET_PIN_WIDGET_CONTROL, 276 0x00); 277 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, 278 pin_ctl | value); 279 280 return 0; 281 } 282 283 static int stac92xx_set_vref(struct hda_codec *codec, hda_nid_t nid) 284 { 285 unsigned int vref_caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP) >> AC_PINCAP_VREF_SHIFT; 286 unsigned int vref_ctl = AC_PINCTL_VREF_HIZ; 287 288 if (vref_caps & AC_PINCAP_VREF_100) 289 vref_ctl = AC_PINCTL_VREF_100; 290 else if (vref_caps & AC_PINCAP_VREF_80) 291 vref_ctl = AC_PINCTL_VREF_80; 292 else if (vref_caps & AC_PINCAP_VREF_50) 293 vref_ctl = AC_PINCTL_VREF_50; 294 else if (vref_caps & AC_PINCAP_VREF_GRD) 295 vref_ctl = AC_PINCTL_VREF_GRD; 296 297 stac92xx_set_pinctl(codec, nid, vref_ctl); 298 299 return 0; 300 } 301 302 static int stac92xx_config_pin(struct hda_codec *codec, hda_nid_t nid, unsigned int pin_cfg) 303 { 304 switch((pin_cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) { 305 case AC_JACK_HP_OUT: 306 /* Enable HP amp */ 307 stac92xx_set_pinctl(codec, nid, AC_PINCTL_HP_EN); 308 /* Fall through */ 309 case AC_JACK_LINE_OUT: 310 case AC_JACK_SPEAKER: 311 /* Enable output */ 312 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); 313 break; 314 case AC_JACK_MIC_IN: 315 /* Set vref */ 316 stac92xx_set_vref(codec, nid); 317 case AC_JACK_CD: 318 case AC_JACK_LINE_IN: 319 case AC_JACK_AUX: 320 /* Enable input */ 321 stac92xx_set_pinctl(codec, nid, AC_PINCTL_IN_EN); 322 break; 323 } 324 325 return 0; 326 } 327 328 static int stac92xx_config_pins(struct hda_codec *codec) 329 { 330 struct sigmatel_spec *spec = codec->spec; 331 int i; 332 unsigned int pin_cfg; 333 334 for (i=0; i < spec->num_pins; i++) { 335 /* Default to disabled */ 336 snd_hda_codec_write(codec, spec->pin_nids[i], 0, 337 AC_VERB_SET_PIN_WIDGET_CONTROL, 338 0x00); 339 340 pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, 341 AC_VERB_GET_CONFIG_DEFAULT, 342 0x00); 343 if (((pin_cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) == AC_JACK_PORT_NONE) 344 continue; /* Move on */ 345 346 stac92xx_config_pin(codec, spec->pin_nids[i], pin_cfg); 347 } 348 349 return 0; 350 } 351 352 static int stac92xx_init(struct hda_codec *codec) 353 { 354 struct sigmatel_spec *spec = codec->spec; 355 int i; 356 357 for (i=0; i < spec->num_pstates; i++) 358 snd_hda_codec_write(codec, spec->pstate_nids[i], 0, 359 AC_VERB_SET_POWER_STATE, 0x00); 360 361 mdelay(100); 362 363 snd_hda_sequence_write(codec, spec->init); 364 365 #ifdef STAC_TEST 366 stac92xx_set_config_regs(codec); 367 #endif 368 369 stac92xx_config_pins(codec); 370 371 return 0; 303 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); 304 } 372 305 } 373 306 … … 377 310 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, 378 311 struct hda_codec *codec, 379 s nd_pcm_substream_t*substream)312 struct snd_pcm_substream *substream) 380 313 { 381 314 struct sigmatel_spec *spec = codec->spec; … … 387 320 unsigned int stream_tag, 388 321 unsigned int format, 389 snd_pcm_substream_t *substream) 390 { 391 struct sigmatel_spec *spec = codec->spec; 392 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, 393 format, substream); 322 struct snd_pcm_substream *substream) 323 { 324 struct sigmatel_spec *spec = codec->spec; 325 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream); 394 326 } 395 327 396 328 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 397 329 struct hda_codec *codec, 398 s nd_pcm_substream_t*substream)330 struct snd_pcm_substream *substream) 399 331 { 400 332 struct sigmatel_spec *spec = codec->spec; 401 333 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); 402 334 } 335 336 /* 337 * Digital playback callbacks 338 */ 339 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, 340 struct hda_codec *codec, 341 struct snd_pcm_substream *substream) 342 { 343 struct sigmatel_spec *spec = codec->spec; 344 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 345 } 346 347 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 348 struct hda_codec *codec, 349 struct snd_pcm_substream *substream) 350 { 351 struct sigmatel_spec *spec = codec->spec; 352 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 353 } 354 403 355 404 356 /* … … 409 361 unsigned int stream_tag, 410 362 unsigned int format, 411 s nd_pcm_substream_t*substream)363 struct snd_pcm_substream *substream) 412 364 { 413 365 struct sigmatel_spec *spec = codec->spec; … … 420 372 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, 421 373 struct hda_codec *codec, 422 s nd_pcm_substream_t*substream)374 struct snd_pcm_substream *substream) 423 375 { 424 376 struct sigmatel_spec *spec = codec->spec; … … 428 380 } 429 381 382 static struct hda_pcm_stream stac92xx_pcm_digital_playback = { 383 .substreams = 1, 384 .channels_min = 2, 385 .channels_max = 2, 386 /* NID is set in stac92xx_build_pcms */ 387 .ops = { 388 .open = stac92xx_dig_playback_pcm_open, 389 .close = stac92xx_dig_playback_pcm_close 390 }, 391 }; 392 393 static struct hda_pcm_stream stac92xx_pcm_digital_capture = { 394 .substreams = 1, 395 .channels_min = 2, 396 .channels_max = 2, 397 /* NID is set in stac92xx_build_pcms */ 398 }; 399 430 400 static struct hda_pcm_stream stac92xx_pcm_analog_playback = { 431 /*.substreams = */1, 432 /*.channels_min = */2, 433 /*.channels_max = */2, 434 /*.nid = */0x02, /* NID to query formats and rates */ 435 0,0,0, 436 /*.ops = */{ 437 /*.open = */stac92xx_playback_pcm_open, 0, 438 /*.prepare = */stac92xx_playback_pcm_prepare, 439 /*.cleanup = */stac92xx_playback_pcm_cleanup 401 .substreams = 1, 402 .channels_min = 2, 403 .channels_max = 8, 404 .nid = 0x02, /* NID to query formats and rates */ 405 .ops = { 406 .open = stac92xx_playback_pcm_open, 407 .prepare = stac92xx_playback_pcm_prepare, 408 .cleanup = stac92xx_playback_pcm_cleanup 440 409 }, 441 410 }; 442 411 443 412 static struct hda_pcm_stream stac92xx_pcm_analog_capture = { 444 /*.substreams = */2, 445 /*.channels_min = */2, 446 /*.channels_max = */2, 447 /*.nid = */0x06, /* NID to query formats and rates */ 448 0,0,0, 449 /*.ops = */{ 450 0,0, 451 /*.prepare = */stac92xx_capture_pcm_prepare, 452 /*.cleanup = */stac92xx_capture_pcm_cleanup 413 .substreams = 2, 414 .channels_min = 2, 415 .channels_max = 2, 416 .nid = 0x06, /* NID to query formats and rates */ 417 .ops = { 418 .prepare = stac92xx_capture_pcm_prepare, 419 .cleanup = stac92xx_capture_pcm_cleanup 453 420 }, 454 421 }; … … 462 429 codec->pcm_info = info; 463 430 464 info->name = "STAC92xx ";431 info->name = "STAC92xx Analog"; 465 432 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback; 466 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->playback_nid;467 433 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture; 468 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->capture_nid; 434 435 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 436 codec->num_pcms++; 437 info++; 438 info->name = "STAC92xx Digital"; 439 if (spec->multiout.dig_out_nid) { 440 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; 441 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 442 } 443 if (spec->dig_in_nid) { 444 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture; 445 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; 446 } 447 } 448 449 return 0; 450 } 451 452 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) 453 454 { 455 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); 456 } 457 458 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) 459 { 460 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; 461 uinfo->count = 1; 462 uinfo->value.integer.min = 0; 463 uinfo->value.integer.max = 1; 464 return 0; 465 } 466 467 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 468 { 469 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 470 struct sigmatel_spec *spec = codec->spec; 471 int io_idx = kcontrol-> private_value & 0xff; 472 473 ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; 474 return 0; 475 } 476 477 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 478 { 479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 480 struct sigmatel_spec *spec = codec->spec; 481 hda_nid_t nid = kcontrol->private_value >> 8; 482 int io_idx = kcontrol-> private_value & 0xff; 483 unsigned short val = ucontrol->value.integer.value[0]; 484 485 spec->io_switch[io_idx] = val; 486 487 if (val) 488 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); 489 else 490 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN); 491 492 return 1; 493 } 494 495 #define STAC_CODEC_IO_SWITCH(xname, xpval) \ 496 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 497 .name = xname, \ 498 .index = 0, \ 499 .info = stac92xx_io_switch_info, \ 500 .get = stac92xx_io_switch_get, \ 501 .put = stac92xx_io_switch_put, \ 502 .private_value = xpval, \ 503 } 504 505 506 enum { 507 STAC_CTL_WIDGET_VOL, 508 STAC_CTL_WIDGET_MUTE, 509 STAC_CTL_WIDGET_IO_SWITCH, 510 }; 511 512 static struct snd_kcontrol_new stac92xx_control_templates[] = { 513 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 514 HDA_CODEC_MUTE(NULL, 0, 0, 0), 515 STAC_CODEC_IO_SWITCH(NULL, 0), 516 }; 517 518 /* add dynamic controls */ 519 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) 520 { 521 struct snd_kcontrol_new *knew; 522 523 if (spec->num_kctl_used >= spec->num_kctl_alloc) { 524 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; 525 526 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ 527 if (! knew) 528 return -ENOMEM; 529 if (spec->kctl_alloc) { 530 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); 531 kfree(spec->kctl_alloc); 532 } 533 spec->kctl_alloc = knew; 534 spec->num_kctl_alloc = num; 535 } 536 537 knew = &spec->kctl_alloc[spec->num_kctl_used]; 538 *knew = stac92xx_control_templates[type]; 539 knew->name = kstrdup(name, GFP_KERNEL); 540 if (! knew->name) 541 return -ENOMEM; 542 knew->private_value = val; 543 spec->num_kctl_used++; 544 return 0; 545 } 546 547 /* flag inputs as additional dynamic lineouts */ 548 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) 549 { 550 struct sigmatel_spec *spec = codec->spec; 551 552 switch (cfg->line_outs) { 553 case 3: 554 /* add line-in as side */ 555 if (cfg->input_pins[AUTO_PIN_LINE]) { 556 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; 557 spec->line_switch = 1; 558 cfg->line_outs++; 559 } 560 break; 561 case 2: 562 /* add line-in as clfe and mic as side */ 563 if (cfg->input_pins[AUTO_PIN_LINE]) { 564 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; 565 spec->line_switch = 1; 566 cfg->line_outs++; 567 } 568 if (cfg->input_pins[AUTO_PIN_MIC]) { 569 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; 570 spec->mic_switch = 1; 571 cfg->line_outs++; 572 } 573 break; 574 case 1: 575 /* add line-in as surr and mic as clfe */ 576 if (cfg->input_pins[AUTO_PIN_LINE]) { 577 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; 578 spec->line_switch = 1; 579 cfg->line_outs++; 580 } 581 if (cfg->input_pins[AUTO_PIN_MIC]) { 582 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; 583 spec->mic_switch = 1; 584 cfg->line_outs++; 585 } 586 break; 587 } 588 589 return 0; 590 } 591 592 /* fill in the dac_nids table from the parsed pin configuration */ 593 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 594 { 595 struct sigmatel_spec *spec = codec->spec; 596 hda_nid_t nid; 597 int i; 598 599 /* check the pins hardwired to audio widget */ 600 for (i = 0; i < cfg->line_outs; i++) { 601 nid = cfg->line_out_pins[i]; 602 spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0, 603 AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 604 } 605 606 spec->multiout.num_dacs = cfg->line_outs; 607 608 return 0; 609 } 610 611 /* add playback controls from the parsed DAC table */ 612 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg) 613 { 614 char name[32]; 615 static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; 616 hda_nid_t nid; 617 int i, err; 618 619 for (i = 0; i < cfg->line_outs; i++) { 620 if (!spec->multiout.dac_nids[i]) 621 continue; 622 623 nid = spec->multiout.dac_nids[i]; 624 625 if (i == 2) { 626 /* Center/LFE */ 627 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume", 628 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 629 return err; 630 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume", 631 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 632 return err; 633 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch", 634 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) 635 return err; 636 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch", 637 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) 638 return err; 639 } else { 640 sprintf(name, "%s Playback Volume", chname[i]); 641 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, 642 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 643 return err; 644 sprintf(name, "%s Playback Switch", chname[i]); 645 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, 646 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 647 return err; 648 } 649 } 650 651 if (spec->line_switch) 652 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) 653 return err; 654 655 if (spec->mic_switch) 656 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) 657 return err; 658 659 return 0; 660 } 661 662 /* add playback controls for HP output */ 663 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg) 664 { 665 struct sigmatel_spec *spec = codec->spec; 666 hda_nid_t pin = cfg->hp_pin; 667 hda_nid_t nid; 668 int i, err; 669 unsigned int wid_caps; 670 671 if (! pin) 672 return 0; 673 674 wid_caps = get_wcaps(codec, pin); 675 if (wid_caps & AC_WCAP_UNSOL_CAP) 676 /* Enable unsolicited responses on the HP widget */ 677 snd_hda_codec_write(codec, pin, 0, 678 AC_VERB_SET_UNSOLICITED_ENABLE, 679 STAC_UNSOL_ENABLE); 680 681 nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff; 682 for (i = 0; i < cfg->line_outs; i++) { 683 if (! spec->multiout.dac_nids[i]) 684 continue; 685 if (spec->multiout.dac_nids[i] == nid) 686 return 0; 687 } 688 689 spec->multiout.hp_nid = nid; 690 691 /* control HP volume/switch on the output mixer amp */ 692 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume", 693 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 694 return err; 695 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch", 696 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) 697 return err; 698 699 return 0; 700 } 701 702 /* create playback/capture controls for input pins */ 703 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 704 { 705 struct sigmatel_spec *spec = codec->spec; 706 struct hda_input_mux *imux = &spec->private_imux; 707 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 708 int i, j, k; 709 710 for (i = 0; i < AUTO_PIN_LAST; i++) { 711 int index = -1; 712 if (cfg->input_pins[i]) { 713 /* Enable active pin widget as an input */ 714 stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN); 715 716 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 717 718 for (j=0; j<spec->num_muxes; j++) { 719 int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); 720 for (k=0; k<num_cons; k++) 721 if (con_lst[k] == cfg->input_pins[i]) { 722 index = k; 723 break; 724 } 725 if (index >= 0) 726 break; 727 } 728 imux->items[imux->num_items].index = index; 729 imux->num_items++; 730 } 731 } 732 733 return 0; 734 } 735 736 static void stac92xx_auto_init_multi_out(struct hda_codec *codec) 737 { 738 struct sigmatel_spec *spec = codec->spec; 739 int i; 740 741 for (i = 0; i < spec->autocfg.line_outs; i++) { 742 hda_nid_t nid = spec->autocfg.line_out_pins[i]; 743 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); 744 } 745 } 746 747 static void stac92xx_auto_init_hp_out(struct hda_codec *codec) 748 { 749 struct sigmatel_spec *spec = codec->spec; 750 hda_nid_t pin; 751 752 pin = spec->autocfg.hp_pin; 753 if (pin) /* connect to front */ 754 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN); 755 } 756 757 static int stac922x_parse_auto_config(struct hda_codec *codec) 758 { 759 struct sigmatel_spec *spec = codec->spec; 760 int err; 761 762 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) 763 return err; 764 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) 765 return err; 766 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) 767 return err; 768 if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin) 769 return 0; /* can't find valid pin config */ 770 771 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || 772 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 || 773 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) 774 return err; 775 776 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 777 if (spec->multiout.max_channels > 2) 778 spec->surr_switch = 1; 779 780 if (spec->autocfg.dig_out_pin) { 781 spec->multiout.dig_out_nid = 0x08; 782 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); 783 } 784 if (spec->autocfg.dig_in_pin) { 785 spec->dig_in_nid = 0x09; 786 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); 787 } 788 789 if (spec->kctl_alloc) 790 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 791 792 spec->input_mux = &spec->private_imux; 793 794 return 1; 795 } 796 797 static int stac9200_parse_auto_config(struct hda_codec *codec) 798 { 799 struct sigmatel_spec *spec = codec->spec; 800 int err; 801 802 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) 803 return err; 804 805 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) 806 return err; 807 808 if (spec->autocfg.dig_out_pin) { 809 spec->multiout.dig_out_nid = 0x05; 810 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN); 811 } 812 if (spec->autocfg.dig_in_pin) { 813 spec->dig_in_nid = 0x04; 814 stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN); 815 } 816 817 if (spec->kctl_alloc) 818 spec->mixers[spec->num_mixers++] = spec->kctl_alloc; 819 820 spec->input_mux = &spec->private_imux; 821 822 return 1; 823 } 824 825 static int stac92xx_init(struct hda_codec *codec) 826 { 827 struct sigmatel_spec *spec = codec->spec; 828 829 snd_hda_sequence_write(codec, spec->init); 830 831 stac92xx_auto_init_multi_out(codec); 832 stac92xx_auto_init_hp_out(codec); 469 833 470 834 return 0; … … 473 837 static void stac92xx_free(struct hda_codec *codec) 474 838 { 475 kfree(codec->spec); 476 } 839 struct sigmatel_spec *spec = codec->spec; 840 int i; 841 842 if (! spec) 843 return; 844 845 if (spec->kctl_alloc) { 846 for (i = 0; i < spec->num_kctl_used; i++) 847 kfree(spec->kctl_alloc[i].name); 848 kfree(spec->kctl_alloc); 849 } 850 851 kfree(spec); 852 } 853 854 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, 855 unsigned int flag) 856 { 857 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 858 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 859 snd_hda_codec_write(codec, nid, 0, 860 AC_VERB_SET_PIN_WIDGET_CONTROL, 861 pin_ctl | flag); 862 } 863 864 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, 865 unsigned int flag) 866 { 867 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 868 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 869 snd_hda_codec_write(codec, nid, 0, 870 AC_VERB_SET_PIN_WIDGET_CONTROL, 871 pin_ctl & ~flag); 872 } 873 874 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) 875 { 876 struct sigmatel_spec *spec = codec->spec; 877 struct auto_pin_cfg *cfg = &spec->autocfg; 878 int i, presence; 879 880 if ((res >> 26) != STAC_HP_EVENT) 881 return; 882 883 presence = snd_hda_codec_read(codec, cfg->hp_pin, 0, 884 AC_VERB_GET_PIN_SENSE, 0x00) >> 31; 885 886 if (presence) { 887 /* disable lineouts, enable hp */ 888 for (i = 0; i < cfg->line_outs; i++) 889 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], 890 AC_PINCTL_OUT_EN); 891 stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); 892 } else { 893 /* enable lineouts, disable hp */ 894 for (i = 0; i < cfg->line_outs; i++) 895 stac92xx_set_pinctl(codec, cfg->line_out_pins[i], 896 AC_PINCTL_OUT_EN); 897 stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN); 898 } 899 } 900 901 #ifdef CONFIG_PM 902 static int stac92xx_resume(struct hda_codec *codec) 903 { 904 struct sigmatel_spec *spec = codec->spec; 905 int i; 906 907 stac92xx_init(codec); 908 for (i = 0; i < spec->num_mixers; i++) 909 snd_hda_resume_ctls(codec, spec->mixers[i]); 910 if (spec->multiout.dig_out_nid) 911 snd_hda_resume_spdif_out(codec); 912 if (spec->dig_in_nid) 913 snd_hda_resume_spdif_in(codec); 914 915 return 0; 916 } 917 #endif 477 918 478 919 static struct hda_codec_ops stac92xx_patch_ops = { 479 /*.build_controls = */stac92xx_build_controls, 480 /*.build_pcms = */stac92xx_build_pcms, 481 /*.init = */stac92xx_init, 482 /*.free = */stac92xx_free,0, 483 0,0 920 .build_controls = stac92xx_build_controls, 921 .build_pcms = stac92xx_build_pcms, 922 .init = stac92xx_init, 923 .free = stac92xx_free, 924 .unsol_event = stac92xx_unsol_event, 925 #ifdef CONFIG_PM 926 .resume = stac92xx_resume, 927 #endif 484 928 }; 485 929 … … 487 931 { 488 932 struct sigmatel_spec *spec; 489 490 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 933 int err; 934 935 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 491 936 if (spec == NULL) 492 937 return -ENOMEM; 493 938 494 939 codec->spec = spec; 940 spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl); 941 if (spec->board_config < 0) 942 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); 943 else { 944 spec->num_pins = 8; 945 spec->pin_nids = stac9200_pin_nids; 946 spec->pin_configs = stac9200_brd_tbl[spec->board_config]; 947 stac92xx_set_config_regs(codec); 948 } 495 949 496 950 spec->multiout.max_channels = 2; … … 499 953 spec->adc_nids = stac9200_adc_nids; 500 954 spec->mux_nids = stac9200_mux_nids; 501 spec->input_mux = &stac9200_input_mux; 502 spec->pstate_nids = stac9200_pstate_nids; 503 spec->num_pstates = 3; 504 spec->pin_nids = stac9200_pin_nids; 505 #ifdef STAC_TEST 506 spec->pin_configs = stac9200_pin_configs; 507 #endif 508 spec->num_pins = 8; 509 spec->init = stac9200_ch2_init; 955 spec->num_muxes = 1; 956 957 spec->init = stac9200_core_init; 510 958 spec->mixer = stac9200_mixer; 511 spec->playback_nid = 0x02; 512 spec->capture_nid = 0x03; 959 960 err = stac9200_parse_auto_config(codec); 961 if (err < 0) { 962 stac92xx_free(codec); 963 return err; 964 } 513 965 514 966 codec->patch_ops = stac92xx_patch_ops; … … 520 972 { 521 973 struct sigmatel_spec *spec; 522 523 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 974 int err; 975 976 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 524 977 if (spec == NULL) 525 978 return -ENOMEM; 526 979 527 980 codec->spec = spec; 528 529 spec->multiout.max_channels = 2; 530 spec->multiout.num_dacs = 4; 531 spec->multiout.dac_nids = stac922x_dac_nids; 981 spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl); 982 if (spec->board_config < 0) 983 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n"); 984 else { 985 spec->num_pins = 10; 986 spec->pin_nids = stac922x_pin_nids; 987 spec->pin_configs = stac922x_brd_tbl[spec->board_config]; 988 stac92xx_set_config_regs(codec); 989 } 990 532 991 spec->adc_nids = stac922x_adc_nids; 533 992 spec->mux_nids = stac922x_mux_nids; 534 spec->input_mux = &stac922x_input_mux; 535 spec->pstate_nids = stac922x_pstate_nids; 536 spec->num_pstates = 7; 537 spec->pin_nids = stac922x_pin_nids; 538 #ifdef STAC_TEST 539 spec->pin_configs = stac922x_pin_configs; 540 #endif 541 spec->num_pins = 10; 542 spec->init = stac922x_ch2_init; 993 spec->num_muxes = 2; 994 995 spec->init = stac922x_core_init; 543 996 spec->mixer = stac922x_mixer; 544 spec->playback_nid = 0x02; 545 spec->capture_nid = 0x06; 997 998 spec->multiout.dac_nids = spec->dac_nids; 999 1000 err = stac922x_parse_auto_config(codec); 1001 if (err < 0) { 1002 stac92xx_free(codec); 1003 return err; 1004 } 546 1005 547 1006 codec->patch_ops = stac92xx_patch_ops; … … 554 1013 */ 555 1014 struct hda_codec_preset snd_hda_preset_sigmatel[] = { 556 { /*.id = */0x83847690, 0, 0, 0, 0,/*.name = */"STAC9200", /*.patch = */patch_stac9200 },557 { /*.id = */0x83847882, 0, 0, 0, 0,/*.name = */"STAC9220 A1", /*.patch = */patch_stac922x },558 { /*.id = */0x83847680, 0, 0, 0, 0,/*.name = */"STAC9221 A1", /*.patch = */patch_stac922x },559 { /*.id = */0x83847880, 0, 0, 0, 0,/*.name = */"STAC9220 A2", /*.patch = */patch_stac922x },560 { /*.id = */0x83847681, 0, 0, 0, 0,/*.name = */"STAC9220D/9223D A2", /*.patch = */patch_stac922x },561 { /*.id = */0x83847682, 0, 0, 0, 0,/*.name = */"STAC9221 A2", /*.patch = */patch_stac922x },562 { /*.id = */0x83847683, 0, 0, 0, 0,/*.name = */"STAC9221D A2", /*.patch = */patch_stac922x },1015 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 }, 1016 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x }, 1017 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x }, 1018 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x }, 1019 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x }, 1020 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x }, 1021 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x }, 563 1022 {0} /* terminator */ 564 1023 };
Note:
See TracChangeset
for help on using the changeset viewer.
