aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/Kconfig4
-rw-r--r--sound/pci/hda/hda_beep.c1
-rw-r--r--sound/pci/hda/hda_beep.h2
-rw-r--r--sound/pci/hda/hda_codec.c402
-rw-r--r--sound/pci/hda/hda_codec.h18
-rw-r--r--sound/pci/hda/hda_generic.c2
-rw-r--r--sound/pci/hda/hda_hwdep.c240
-rw-r--r--sound/pci/hda/hda_intel.c36
-rw-r--r--sound/pci/hda/hda_local.h32
-rw-r--r--sound/pci/hda/hda_proc.c10
-rw-r--r--sound/pci/hda/patch_analog.c195
-rw-r--r--sound/pci/hda/patch_cmedia.c12
-rw-r--r--sound/pci/hda/patch_conexant.c368
-rw-r--r--sound/pci/hda/patch_realtek.c1068
-rw-r--r--sound/pci/hda/patch_sigmatel.c1332
-rw-r--r--sound/pci/hda/patch_via.c17
-rw-r--r--sound/pci/oxygen/virtuoso.c20
17 files changed, 2369 insertions, 1390 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 6e3a1848447c..82b9bddcdcd6 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -744,8 +744,8 @@ config SND_VIRTUOSO
744 select SND_OXYGEN_LIB 744 select SND_OXYGEN_LIB
745 help 745 help
746 Say Y here to include support for sound cards based on the 746 Say Y here to include support for sound cards based on the
747 Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2, D2X and 747 Asus AV100/AV200 chips, i.e., Xonar D1, DX, D2 and D2X.
748 HDAV1.3 (Deluxe). 748 Support for the HDAV1.3 (Deluxe) is very experimental.
749 749
750 To compile this driver as a module, choose M here: the module 750 To compile this driver as a module, choose M here: the module
751 will be called snd-virtuoso. 751 will be called snd-virtuoso.
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c
index 960fd7970384..4de5bacd3929 100644
--- a/sound/pci/hda/hda_beep.c
+++ b/sound/pci/hda/hda_beep.c
@@ -138,6 +138,7 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
138 138
139 input_unregister_device(beep->dev); 139 input_unregister_device(beep->dev);
140 kfree(beep); 140 kfree(beep);
141 codec->beep = NULL;
141 } 142 }
142} 143}
143EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device); 144EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device);
diff --git a/sound/pci/hda/hda_beep.h b/sound/pci/hda/hda_beep.h
index b9679f081cae..51bf6a5daf39 100644
--- a/sound/pci/hda/hda_beep.h
+++ b/sound/pci/hda/hda_beep.h
@@ -39,7 +39,7 @@ struct hda_beep {
39int snd_hda_attach_beep_device(struct hda_codec *codec, int nid); 39int snd_hda_attach_beep_device(struct hda_codec *codec, int nid);
40void snd_hda_detach_beep_device(struct hda_codec *codec); 40void snd_hda_detach_beep_device(struct hda_codec *codec);
41#else 41#else
42#define snd_hda_attach_beep_device(...) 42#define snd_hda_attach_beep_device(...) 0
43#define snd_hda_detach_beep_device(...) 43#define snd_hda_detach_beep_device(...)
44#endif 44#endif
45#endif 45#endif
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index d03f99298be9..b90a2400f53d 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -682,11 +682,140 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
682 return 0; 682 return 0;
683} 683}
684 684
685/* read all pin default configurations and save codec->init_pins */
686static int read_pin_defaults(struct hda_codec *codec)
687{
688 int i;
689 hda_nid_t nid = codec->start_nid;
690
691 for (i = 0; i < codec->num_nodes; i++, nid++) {
692 struct hda_pincfg *pin;
693 unsigned int wcaps = get_wcaps(codec, nid);
694 unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >>
695 AC_WCAP_TYPE_SHIFT;
696 if (wid_type != AC_WID_PIN)
697 continue;
698 pin = snd_array_new(&codec->init_pins);
699 if (!pin)
700 return -ENOMEM;
701 pin->nid = nid;
702 pin->cfg = snd_hda_codec_read(codec, nid, 0,
703 AC_VERB_GET_CONFIG_DEFAULT, 0);
704 }
705 return 0;
706}
707
708/* look up the given pin config list and return the item matching with NID */
709static struct hda_pincfg *look_up_pincfg(struct hda_codec *codec,
710 struct snd_array *array,
711 hda_nid_t nid)
712{
713 int i;
714 for (i = 0; i < array->used; i++) {
715 struct hda_pincfg *pin = snd_array_elem(array, i);
716 if (pin->nid == nid)
717 return pin;
718 }
719 return NULL;
720}
721
722/* write a config value for the given NID */
723static void set_pincfg(struct hda_codec *codec, hda_nid_t nid,
724 unsigned int cfg)
725{
726 int i;
727 for (i = 0; i < 4; i++) {
728 snd_hda_codec_write(codec, nid, 0,
729 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
730 cfg & 0xff);
731 cfg >>= 8;
732 }
733}
734
735/* set the current pin config value for the given NID.
736 * the value is cached, and read via snd_hda_codec_get_pincfg()
737 */
738int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
739 hda_nid_t nid, unsigned int cfg)
740{
741 struct hda_pincfg *pin;
742 unsigned int oldcfg;
743
744 oldcfg = snd_hda_codec_get_pincfg(codec, nid);
745 pin = look_up_pincfg(codec, list, nid);
746 if (!pin) {
747 pin = snd_array_new(list);
748 if (!pin)
749 return -ENOMEM;
750 pin->nid = nid;
751 }
752 pin->cfg = cfg;
753
754 /* change only when needed; e.g. if the pincfg is already present
755 * in user_pins[], don't write it
756 */
757 cfg = snd_hda_codec_get_pincfg(codec, nid);
758 if (oldcfg != cfg)
759 set_pincfg(codec, nid, cfg);
760 return 0;
761}
762
763int snd_hda_codec_set_pincfg(struct hda_codec *codec,
764 hda_nid_t nid, unsigned int cfg)
765{
766 return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg);
767}
768EXPORT_SYMBOL_HDA(snd_hda_codec_set_pincfg);
769
770/* get the current pin config value of the given pin NID */
771unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
772{
773 struct hda_pincfg *pin;
774
775#ifdef CONFIG_SND_HDA_HWDEP
776 pin = look_up_pincfg(codec, &codec->user_pins, nid);
777 if (pin)
778 return pin->cfg;
779#endif
780 pin = look_up_pincfg(codec, &codec->driver_pins, nid);
781 if (pin)
782 return pin->cfg;
783 pin = look_up_pincfg(codec, &codec->init_pins, nid);
784 if (pin)
785 return pin->cfg;
786 return 0;
787}
788EXPORT_SYMBOL_HDA(snd_hda_codec_get_pincfg);
789
790/* restore all current pin configs */
791static void restore_pincfgs(struct hda_codec *codec)
792{
793 int i;
794 for (i = 0; i < codec->init_pins.used; i++) {
795 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
796 set_pincfg(codec, pin->nid,
797 snd_hda_codec_get_pincfg(codec, pin->nid));
798 }
799}
685 800
686static void init_hda_cache(struct hda_cache_rec *cache, 801static void init_hda_cache(struct hda_cache_rec *cache,
687 unsigned int record_size); 802 unsigned int record_size);
688static void free_hda_cache(struct hda_cache_rec *cache); 803static void free_hda_cache(struct hda_cache_rec *cache);
689 804
805/* restore the initial pin cfgs and release all pincfg lists */
806static void restore_init_pincfgs(struct hda_codec *codec)
807{
808 /* first free driver_pins and user_pins, then call restore_pincfg
809 * so that only the values in init_pins are restored
810 */
811 snd_array_free(&codec->driver_pins);
812#ifdef CONFIG_SND_HDA_HWDEP
813 snd_array_free(&codec->user_pins);
814#endif
815 restore_pincfgs(codec);
816 snd_array_free(&codec->init_pins);
817}
818
690/* 819/*
691 * codec destructor 820 * codec destructor
692 */ 821 */
@@ -694,6 +823,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
694{ 823{
695 if (!codec) 824 if (!codec)
696 return; 825 return;
826 restore_init_pincfgs(codec);
697#ifdef CONFIG_SND_HDA_POWER_SAVE 827#ifdef CONFIG_SND_HDA_POWER_SAVE
698 cancel_delayed_work(&codec->power_work); 828 cancel_delayed_work(&codec->power_work);
699 flush_workqueue(codec->bus->workq); 829 flush_workqueue(codec->bus->workq);
@@ -712,6 +842,9 @@ static void snd_hda_codec_free(struct hda_codec *codec)
712 kfree(codec); 842 kfree(codec);
713} 843}
714 844
845static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
846 unsigned int power_state);
847
715/** 848/**
716 * snd_hda_codec_new - create a HDA codec 849 * snd_hda_codec_new - create a HDA codec
717 * @bus: the bus to assign 850 * @bus: the bus to assign
@@ -751,6 +884,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
751 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 884 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
752 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 885 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
753 snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); 886 snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32);
887 snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
888 snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
754 if (codec->bus->modelname) { 889 if (codec->bus->modelname) {
755 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); 890 codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
756 if (!codec->modelname) { 891 if (!codec->modelname) {
@@ -787,15 +922,18 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
787 setup_fg_nodes(codec); 922 setup_fg_nodes(codec);
788 if (!codec->afg && !codec->mfg) { 923 if (!codec->afg && !codec->mfg) {
789 snd_printdd("hda_codec: no AFG or MFG node found\n"); 924 snd_printdd("hda_codec: no AFG or MFG node found\n");
790 snd_hda_codec_free(codec); 925 err = -ENODEV;
791 return -ENODEV; 926 goto error;
792 } 927 }
793 928
794 if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) { 929 err = read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg);
930 if (err < 0) {
795 snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); 931 snd_printk(KERN_ERR "hda_codec: cannot malloc\n");
796 snd_hda_codec_free(codec); 932 goto error;
797 return -ENOMEM;
798 } 933 }
934 err = read_pin_defaults(codec);
935 if (err < 0)
936 goto error;
799 937
800 if (!codec->subsystem_id) { 938 if (!codec->subsystem_id) {
801 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; 939 hda_nid_t nid = codec->afg ? codec->afg : codec->mfg;
@@ -806,12 +944,15 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
806 if (bus->modelname) 944 if (bus->modelname)
807 codec->modelname = kstrdup(bus->modelname, GFP_KERNEL); 945 codec->modelname = kstrdup(bus->modelname, GFP_KERNEL);
808 946
947 /* power-up all before initialization */
948 hda_set_power_state(codec,
949 codec->afg ? codec->afg : codec->mfg,
950 AC_PWRST_D0);
951
809 if (do_init) { 952 if (do_init) {
810 err = snd_hda_codec_configure(codec); 953 err = snd_hda_codec_configure(codec);
811 if (err < 0) { 954 if (err < 0)
812 snd_hda_codec_free(codec); 955 goto error;
813 return err;
814 }
815 } 956 }
816 snd_hda_codec_proc_new(codec); 957 snd_hda_codec_proc_new(codec);
817 958
@@ -824,6 +965,10 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr
824 if (codecp) 965 if (codecp)
825 *codecp = codec; 966 *codecp = codec;
826 return 0; 967 return 0;
968
969 error:
970 snd_hda_codec_free(codec);
971 return err;
827} 972}
828EXPORT_SYMBOL_HDA(snd_hda_codec_new); 973EXPORT_SYMBOL_HDA(snd_hda_codec_new);
829 974
@@ -1120,6 +1265,7 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
1120 u16 nid = get_amp_nid(kcontrol); 1265 u16 nid = get_amp_nid(kcontrol);
1121 u8 chs = get_amp_channels(kcontrol); 1266 u8 chs = get_amp_channels(kcontrol);
1122 int dir = get_amp_direction(kcontrol); 1267 int dir = get_amp_direction(kcontrol);
1268 unsigned int ofs = get_amp_offset(kcontrol);
1123 u32 caps; 1269 u32 caps;
1124 1270
1125 caps = query_amp_caps(codec, nid, dir); 1271 caps = query_amp_caps(codec, nid, dir);
@@ -1131,6 +1277,8 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
1131 kcontrol->id.name); 1277 kcontrol->id.name);
1132 return -EINVAL; 1278 return -EINVAL;
1133 } 1279 }
1280 if (ofs < caps)
1281 caps -= ofs;
1134 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1282 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1135 uinfo->count = chs == 3 ? 2 : 1; 1283 uinfo->count = chs == 3 ? 2 : 1;
1136 uinfo->value.integer.min = 0; 1284 uinfo->value.integer.min = 0;
@@ -1139,6 +1287,32 @@ int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol,
1139} 1287}
1140EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info); 1288EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_info);
1141 1289
1290
1291static inline unsigned int
1292read_amp_value(struct hda_codec *codec, hda_nid_t nid,
1293 int ch, int dir, int idx, unsigned int ofs)
1294{
1295 unsigned int val;
1296 val = snd_hda_codec_amp_read(codec, nid, ch, dir, idx);
1297 val &= HDA_AMP_VOLMASK;
1298 if (val >= ofs)
1299 val -= ofs;
1300 else
1301 val = 0;
1302 return val;
1303}
1304
1305static inline int
1306update_amp_value(struct hda_codec *codec, hda_nid_t nid,
1307 int ch, int dir, int idx, unsigned int ofs,
1308 unsigned int val)
1309{
1310 if (val > 0)
1311 val += ofs;
1312 return snd_hda_codec_amp_update(codec, nid, ch, dir, idx,
1313 HDA_AMP_VOLMASK, val);
1314}
1315
1142int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, 1316int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
1143 struct snd_ctl_elem_value *ucontrol) 1317 struct snd_ctl_elem_value *ucontrol)
1144{ 1318{
@@ -1147,14 +1321,13 @@ int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol,
1147 int chs = get_amp_channels(kcontrol); 1321 int chs = get_amp_channels(kcontrol);
1148 int dir = get_amp_direction(kcontrol); 1322 int dir = get_amp_direction(kcontrol);
1149 int idx = get_amp_index(kcontrol); 1323 int idx = get_amp_index(kcontrol);
1324 unsigned int ofs = get_amp_offset(kcontrol);
1150 long *valp = ucontrol->value.integer.value; 1325 long *valp = ucontrol->value.integer.value;
1151 1326
1152 if (chs & 1) 1327 if (chs & 1)
1153 *valp++ = snd_hda_codec_amp_read(codec, nid, 0, dir, idx) 1328 *valp++ = read_amp_value(codec, nid, 0, dir, idx, ofs);
1154 & HDA_AMP_VOLMASK;
1155 if (chs & 2) 1329 if (chs & 2)
1156 *valp = snd_hda_codec_amp_read(codec, nid, 1, dir, idx) 1330 *valp = read_amp_value(codec, nid, 1, dir, idx, ofs);
1157 & HDA_AMP_VOLMASK;
1158 return 0; 1331 return 0;
1159} 1332}
1160EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get); 1333EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_volume_get);
@@ -1167,18 +1340,17 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol,
1167 int chs = get_amp_channels(kcontrol); 1340 int chs = get_amp_channels(kcontrol);
1168 int dir = get_amp_direction(kcontrol); 1341 int dir = get_amp_direction(kcontrol);
1169 int idx = get_amp_index(kcontrol); 1342 int idx = get_amp_index(kcontrol);
1343 unsigned int ofs = get_amp_offset(kcontrol);
1170 long *valp = ucontrol->value.integer.value; 1344 long *valp = ucontrol->value.integer.value;
1171 int change = 0; 1345 int change = 0;
1172 1346
1173 snd_hda_power_up(codec); 1347 snd_hda_power_up(codec);
1174 if (chs & 1) { 1348 if (chs & 1) {
1175 change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, 1349 change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp);
1176 0x7f, *valp);
1177 valp++; 1350 valp++;
1178 } 1351 }
1179 if (chs & 2) 1352 if (chs & 2)
1180 change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, 1353 change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp);
1181 0x7f, *valp);
1182 snd_hda_power_down(codec); 1354 snd_hda_power_down(codec);
1183 return change; 1355 return change;
1184} 1356}
@@ -1190,6 +1362,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1190 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1191 hda_nid_t nid = get_amp_nid(kcontrol); 1363 hda_nid_t nid = get_amp_nid(kcontrol);
1192 int dir = get_amp_direction(kcontrol); 1364 int dir = get_amp_direction(kcontrol);
1365 unsigned int ofs = get_amp_offset(kcontrol);
1193 u32 caps, val1, val2; 1366 u32 caps, val1, val2;
1194 1367
1195 if (size < 4 * sizeof(unsigned int)) 1368 if (size < 4 * sizeof(unsigned int))
@@ -1198,6 +1371,7 @@ int snd_hda_mixer_amp_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1198 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT; 1371 val2 = (caps & AC_AMPCAP_STEP_SIZE) >> AC_AMPCAP_STEP_SIZE_SHIFT;
1199 val2 = (val2 + 1) * 25; 1372 val2 = (val2 + 1) * 25;
1200 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT); 1373 val1 = -((caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT);
1374 val1 += ofs;
1201 val1 = ((int)val1) * ((int)val2); 1375 val1 = ((int)val1) * ((int)val2);
1202 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv)) 1376 if (put_user(SNDRV_CTL_TLVT_DB_SCALE, _tlv))
1203 return -EFAULT; 1377 return -EFAULT;
@@ -1268,7 +1442,6 @@ int snd_hda_ctl_add(struct hda_codec *codec, struct snd_kcontrol *kctl)
1268} 1442}
1269EXPORT_SYMBOL_HDA(snd_hda_ctl_add); 1443EXPORT_SYMBOL_HDA(snd_hda_ctl_add);
1270 1444
1271#ifdef CONFIG_SND_HDA_RECONFIG
1272/* Clear all controls assigned to the given codec */ 1445/* Clear all controls assigned to the given codec */
1273void snd_hda_ctls_clear(struct hda_codec *codec) 1446void snd_hda_ctls_clear(struct hda_codec *codec)
1274{ 1447{
@@ -1279,9 +1452,52 @@ void snd_hda_ctls_clear(struct hda_codec *codec)
1279 snd_array_free(&codec->mixers); 1452 snd_array_free(&codec->mixers);
1280} 1453}
1281 1454
1282void snd_hda_codec_reset(struct hda_codec *codec) 1455/* pseudo device locking
1456 * toggle card->shutdown to allow/disallow the device access (as a hack)
1457 */
1458static int hda_lock_devices(struct snd_card *card)
1283{ 1459{
1284 int i; 1460 spin_lock(&card->files_lock);
1461 if (card->shutdown) {
1462 spin_unlock(&card->files_lock);
1463 return -EINVAL;
1464 }
1465 card->shutdown = 1;
1466 spin_unlock(&card->files_lock);
1467 return 0;
1468}
1469
1470static void hda_unlock_devices(struct snd_card *card)
1471{
1472 spin_lock(&card->files_lock);
1473 card->shutdown = 0;
1474 spin_unlock(&card->files_lock);
1475}
1476
1477int snd_hda_codec_reset(struct hda_codec *codec)
1478{
1479 struct snd_card *card = codec->bus->card;
1480 int i, pcm;
1481
1482 if (hda_lock_devices(card) < 0)
1483 return -EBUSY;
1484 /* check whether the codec isn't used by any mixer or PCM streams */
1485 if (!list_empty(&card->ctl_files)) {
1486 hda_unlock_devices(card);
1487 return -EBUSY;
1488 }
1489 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
1490 struct hda_pcm *cpcm = &codec->pcm_info[pcm];
1491 if (!cpcm->pcm)
1492 continue;
1493 if (cpcm->pcm->streams[0].substream_opened ||
1494 cpcm->pcm->streams[1].substream_opened) {
1495 hda_unlock_devices(card);
1496 return -EBUSY;
1497 }
1498 }
1499
1500 /* OK, let it free */
1285 1501
1286#ifdef CONFIG_SND_HDA_POWER_SAVE 1502#ifdef CONFIG_SND_HDA_POWER_SAVE
1287 cancel_delayed_work(&codec->power_work); 1503 cancel_delayed_work(&codec->power_work);
@@ -1291,8 +1507,7 @@ void snd_hda_codec_reset(struct hda_codec *codec)
1291 /* relase PCMs */ 1507 /* relase PCMs */
1292 for (i = 0; i < codec->num_pcms; i++) { 1508 for (i = 0; i < codec->num_pcms; i++) {
1293 if (codec->pcm_info[i].pcm) { 1509 if (codec->pcm_info[i].pcm) {
1294 snd_device_free(codec->bus->card, 1510 snd_device_free(card, codec->pcm_info[i].pcm);
1295 codec->pcm_info[i].pcm);
1296 clear_bit(codec->pcm_info[i].device, 1511 clear_bit(codec->pcm_info[i].device,
1297 codec->bus->pcm_dev_bits); 1512 codec->bus->pcm_dev_bits);
1298 } 1513 }
@@ -1305,13 +1520,22 @@ void snd_hda_codec_reset(struct hda_codec *codec)
1305 free_hda_cache(&codec->cmd_cache); 1520 free_hda_cache(&codec->cmd_cache);
1306 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); 1521 init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info));
1307 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); 1522 init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head));
1523 /* free only driver_pins so that init_pins + user_pins are restored */
1524 snd_array_free(&codec->driver_pins);
1525 restore_pincfgs(codec);
1308 codec->num_pcms = 0; 1526 codec->num_pcms = 0;
1309 codec->pcm_info = NULL; 1527 codec->pcm_info = NULL;
1310 codec->preset = NULL; 1528 codec->preset = NULL;
1529 memset(&codec->patch_ops, 0, sizeof(codec->patch_ops));
1530 codec->slave_dig_outs = NULL;
1531 codec->spdif_status_reset = 0;
1311 module_put(codec->owner); 1532 module_put(codec->owner);
1312 codec->owner = NULL; 1533 codec->owner = NULL;
1534
1535 /* allow device access again */
1536 hda_unlock_devices(card);
1537 return 0;
1313} 1538}
1314#endif /* CONFIG_SND_HDA_RECONFIG */
1315 1539
1316/* create a virtual master control and add slaves */ 1540/* create a virtual master control and add slaves */
1317int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 1541int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
@@ -1336,15 +1560,20 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1336 1560
1337 for (s = slaves; *s; s++) { 1561 for (s = slaves; *s; s++) {
1338 struct snd_kcontrol *sctl; 1562 struct snd_kcontrol *sctl;
1339 1563 int i = 0;
1340 sctl = snd_hda_find_mixer_ctl(codec, *s); 1564 for (;;) {
1341 if (!sctl) { 1565 sctl = _snd_hda_find_mixer_ctl(codec, *s, i);
1342 snd_printdd("Cannot find slave %s, skipped\n", *s); 1566 if (!sctl) {
1343 continue; 1567 if (!i)
1568 snd_printdd("Cannot find slave %s, "
1569 "skipped\n", *s);
1570 break;
1571 }
1572 err = snd_ctl_add_slave(kctl, sctl);
1573 if (err < 0)
1574 return err;
1575 i++;
1344 } 1576 }
1345 err = snd_ctl_add_slave(kctl, sctl);
1346 if (err < 0)
1347 return err;
1348 } 1577 }
1349 return 0; 1578 return 0;
1350} 1579}
@@ -1955,6 +2184,8 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid)
1955 } 2184 }
1956 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { 2185 for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) {
1957 kctl = snd_ctl_new1(dig_mix, codec); 2186 kctl = snd_ctl_new1(dig_mix, codec);
2187 if (!kctl)
2188 return -ENOMEM;
1958 kctl->private_value = nid; 2189 kctl->private_value = nid;
1959 err = snd_hda_ctl_add(codec, kctl); 2190 err = snd_hda_ctl_add(codec, kctl);
1960 if (err < 0) 2191 if (err < 0)
@@ -2144,6 +2375,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
2144 hda_set_power_state(codec, 2375 hda_set_power_state(codec,
2145 codec->afg ? codec->afg : codec->mfg, 2376 codec->afg ? codec->afg : codec->mfg,
2146 AC_PWRST_D0); 2377 AC_PWRST_D0);
2378 restore_pincfgs(codec); /* restore all current pin configs */
2147 hda_exec_init_verbs(codec); 2379 hda_exec_init_verbs(codec);
2148 if (codec->patch_ops.resume) 2380 if (codec->patch_ops.resume)
2149 codec->patch_ops.resume(codec); 2381 codec->patch_ops.resume(codec);
@@ -2171,8 +2403,16 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
2171 2403
2172 list_for_each_entry(codec, &bus->codec_list, list) { 2404 list_for_each_entry(codec, &bus->codec_list, list) {
2173 int err = snd_hda_codec_build_controls(codec); 2405 int err = snd_hda_codec_build_controls(codec);
2174 if (err < 0) 2406 if (err < 0) {
2175 return err; 2407 printk(KERN_ERR "hda_codec: cannot build controls"
2408 "for #%d (error %d)\n", codec->addr, err);
2409 err = snd_hda_codec_reset(codec);
2410 if (err < 0) {
2411 printk(KERN_ERR
2412 "hda_codec: cannot revert codec\n");
2413 return err;
2414 }
2415 }
2176 } 2416 }
2177 return 0; 2417 return 0;
2178} 2418}
@@ -2181,19 +2421,12 @@ EXPORT_SYMBOL_HDA(snd_hda_build_controls);
2181int snd_hda_codec_build_controls(struct hda_codec *codec) 2421int snd_hda_codec_build_controls(struct hda_codec *codec)
2182{ 2422{
2183 int err = 0; 2423 int err = 0;
2184 /* fake as if already powered-on */
2185 hda_keep_power_on(codec);
2186 /* then fire up */
2187 hda_set_power_state(codec,
2188 codec->afg ? codec->afg : codec->mfg,
2189 AC_PWRST_D0);
2190 hda_exec_init_verbs(codec); 2424 hda_exec_init_verbs(codec);
2191 /* continue to initialize... */ 2425 /* continue to initialize... */
2192 if (codec->patch_ops.init) 2426 if (codec->patch_ops.init)
2193 err = codec->patch_ops.init(codec); 2427 err = codec->patch_ops.init(codec);
2194 if (!err && codec->patch_ops.build_controls) 2428 if (!err && codec->patch_ops.build_controls)
2195 err = codec->patch_ops.build_controls(codec); 2429 err = codec->patch_ops.build_controls(codec);
2196 snd_hda_power_down(codec);
2197 if (err < 0) 2430 if (err < 0)
2198 return err; 2431 return err;
2199 return 0; 2432 return 0;
@@ -2306,12 +2539,11 @@ EXPORT_SYMBOL_HDA(snd_hda_calc_stream_format);
2306static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, 2539static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2307 u32 *ratesp, u64 *formatsp, unsigned int *bpsp) 2540 u32 *ratesp, u64 *formatsp, unsigned int *bpsp)
2308{ 2541{
2309 int i; 2542 unsigned int i, val, wcaps;
2310 unsigned int val, streams;
2311 2543
2312 val = 0; 2544 val = 0;
2313 if (nid != codec->afg && 2545 wcaps = get_wcaps(codec, nid);
2314 (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { 2546 if (nid != codec->afg && (wcaps & AC_WCAP_FORMAT_OVRD)) {
2315 val = snd_hda_param_read(codec, nid, AC_PAR_PCM); 2547 val = snd_hda_param_read(codec, nid, AC_PAR_PCM);
2316 if (val == -1) 2548 if (val == -1)
2317 return -EIO; 2549 return -EIO;
@@ -2325,15 +2557,20 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2325 if (val & (1 << i)) 2557 if (val & (1 << i))
2326 rates |= rate_bits[i].alsa_bits; 2558 rates |= rate_bits[i].alsa_bits;
2327 } 2559 }
2560 if (rates == 0) {
2561 snd_printk(KERN_ERR "hda_codec: rates == 0 "
2562 "(nid=0x%x, val=0x%x, ovrd=%i)\n",
2563 nid, val,
2564 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0);
2565 return -EIO;
2566 }
2328 *ratesp = rates; 2567 *ratesp = rates;
2329 } 2568 }
2330 2569
2331 if (formatsp || bpsp) { 2570 if (formatsp || bpsp) {
2332 u64 formats = 0; 2571 u64 formats = 0;
2333 unsigned int bps; 2572 unsigned int streams, bps;
2334 unsigned int wcaps;
2335 2573
2336 wcaps = get_wcaps(codec, nid);
2337 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); 2574 streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM);
2338 if (streams == -1) 2575 if (streams == -1)
2339 return -EIO; 2576 return -EIO;
@@ -2386,6 +2623,15 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
2386 formats |= SNDRV_PCM_FMTBIT_U8; 2623 formats |= SNDRV_PCM_FMTBIT_U8;
2387 bps = 8; 2624 bps = 8;
2388 } 2625 }
2626 if (formats == 0) {
2627 snd_printk(KERN_ERR "hda_codec: formats == 0 "
2628 "(nid=0x%x, val=0x%x, ovrd=%i, "
2629 "streams=0x%x)\n",
2630 nid, val,
2631 (wcaps & AC_WCAP_FORMAT_OVRD) ? 1 : 0,
2632 streams);
2633 return -EIO;
2634 }
2389 if (formatsp) 2635 if (formatsp)
2390 *formatsp = formats; 2636 *formatsp = formats;
2391 if (bpsp) 2637 if (bpsp)
@@ -2501,12 +2747,16 @@ static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo,
2501static int set_pcm_default_values(struct hda_codec *codec, 2747static int set_pcm_default_values(struct hda_codec *codec,
2502 struct hda_pcm_stream *info) 2748 struct hda_pcm_stream *info)
2503{ 2749{
2750 int err;
2751
2504 /* query support PCM information from the given NID */ 2752 /* query support PCM information from the given NID */
2505 if (info->nid && (!info->rates || !info->formats)) { 2753 if (info->nid && (!info->rates || !info->formats)) {
2506 snd_hda_query_supported_pcm(codec, info->nid, 2754 err = snd_hda_query_supported_pcm(codec, info->nid,
2507 info->rates ? NULL : &info->rates, 2755 info->rates ? NULL : &info->rates,
2508 info->formats ? NULL : &info->formats, 2756 info->formats ? NULL : &info->formats,
2509 info->maxbps ? NULL : &info->maxbps); 2757 info->maxbps ? NULL : &info->maxbps);
2758 if (err < 0)
2759 return err;
2510 } 2760 }
2511 if (info->ops.open == NULL) 2761 if (info->ops.open == NULL)
2512 info->ops.open = hda_pcm_default_open_close; 2762 info->ops.open = hda_pcm_default_open_close;
@@ -2549,13 +2799,10 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
2549 for (i = 0; i < ARRAY_SIZE(audio_idx); i++) { 2799 for (i = 0; i < ARRAY_SIZE(audio_idx); i++) {
2550 dev = audio_idx[i]; 2800 dev = audio_idx[i];
2551 if (!test_bit(dev, bus->pcm_dev_bits)) 2801 if (!test_bit(dev, bus->pcm_dev_bits))
2552 break; 2802 goto ok;
2553 }
2554 if (i >= ARRAY_SIZE(audio_idx)) {
2555 snd_printk(KERN_WARNING "Too many audio devices\n");
2556 return -EAGAIN;
2557 } 2803 }
2558 break; 2804 snd_printk(KERN_WARNING "Too many audio devices\n");
2805 return -EAGAIN;
2559 case HDA_PCM_TYPE_SPDIF: 2806 case HDA_PCM_TYPE_SPDIF:
2560 case HDA_PCM_TYPE_HDMI: 2807 case HDA_PCM_TYPE_HDMI:
2561 case HDA_PCM_TYPE_MODEM: 2808 case HDA_PCM_TYPE_MODEM:
@@ -2570,6 +2817,7 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
2570 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type); 2817 snd_printk(KERN_WARNING "Invalid PCM type %d\n", type);
2571 return -EINVAL; 2818 return -EINVAL;
2572 } 2819 }
2820 ok:
2573 set_bit(dev, bus->pcm_dev_bits); 2821 set_bit(dev, bus->pcm_dev_bits);
2574 return dev; 2822 return dev;
2575} 2823}
@@ -2606,24 +2854,36 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
2606 if (!codec->patch_ops.build_pcms) 2854 if (!codec->patch_ops.build_pcms)
2607 return 0; 2855 return 0;
2608 err = codec->patch_ops.build_pcms(codec); 2856 err = codec->patch_ops.build_pcms(codec);
2609 if (err < 0) 2857 if (err < 0) {
2610 return err; 2858 printk(KERN_ERR "hda_codec: cannot build PCMs"
2859 "for #%d (error %d)\n", codec->addr, err);
2860 err = snd_hda_codec_reset(codec);
2861 if (err < 0) {
2862 printk(KERN_ERR
2863 "hda_codec: cannot revert codec\n");
2864 return err;
2865 }
2866 }
2611 } 2867 }
2612 for (pcm = 0; pcm < codec->num_pcms; pcm++) { 2868 for (pcm = 0; pcm < codec->num_pcms; pcm++) {
2613 struct hda_pcm *cpcm = &codec->pcm_info[pcm]; 2869 struct hda_pcm *cpcm = &codec->pcm_info[pcm];
2614 int dev; 2870 int dev;
2615 2871
2616 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams) 2872 if (!cpcm->stream[0].substreams && !cpcm->stream[1].substreams)
2617 return 0; /* no substreams assigned */ 2873 continue; /* no substreams assigned */
2618 2874
2619 if (!cpcm->pcm) { 2875 if (!cpcm->pcm) {
2620 dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type); 2876 dev = get_empty_pcm_device(codec->bus, cpcm->pcm_type);
2621 if (dev < 0) 2877 if (dev < 0)
2622 return 0; 2878 continue; /* no fatal error */
2623 cpcm->device = dev; 2879 cpcm->device = dev;
2624 err = snd_hda_attach_pcm(codec, cpcm); 2880 err = snd_hda_attach_pcm(codec, cpcm);
2625 if (err < 0) 2881 if (err < 0) {
2626 return err; 2882 printk(KERN_ERR "hda_codec: cannot attach "
2883 "PCM stream %d for codec #%d\n",
2884 dev, codec->addr);
2885 continue; /* no fatal error */
2886 }
2627 } 2887 }
2628 } 2888 }
2629 return 0; 2889 return 0;
@@ -3324,8 +3584,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3324 if (ignore_nids && is_in_nid_list(nid, ignore_nids)) 3584 if (ignore_nids && is_in_nid_list(nid, ignore_nids))
3325 continue; 3585 continue;
3326 3586
3327 def_conf = snd_hda_codec_read(codec, nid, 0, 3587 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3328 AC_VERB_GET_CONFIG_DEFAULT, 0);
3329 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 3588 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3330 continue; 3589 continue;
3331 loc = get_defcfg_location(def_conf); 3590 loc = get_defcfg_location(def_conf);
@@ -3401,10 +3660,22 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3401 cfg->input_pins[AUTO_PIN_AUX] = nid; 3660 cfg->input_pins[AUTO_PIN_AUX] = nid;
3402 break; 3661 break;
3403 case AC_JACK_SPDIF_OUT: 3662 case AC_JACK_SPDIF_OUT:
3404 cfg->dig_out_pin = nid; 3663 case AC_JACK_DIG_OTHER_OUT:
3664 if (cfg->dig_outs >= ARRAY_SIZE(cfg->dig_out_pins))
3665 continue;
3666 cfg->dig_out_pins[cfg->dig_outs] = nid;
3667 cfg->dig_out_type[cfg->dig_outs] =
3668 (loc == AC_JACK_LOC_HDMI) ?
3669 HDA_PCM_TYPE_HDMI : HDA_PCM_TYPE_SPDIF;
3670 cfg->dig_outs++;
3405 break; 3671 break;
3406 case AC_JACK_SPDIF_IN: 3672 case AC_JACK_SPDIF_IN:
3673 case AC_JACK_DIG_OTHER_IN:
3407 cfg->dig_in_pin = nid; 3674 cfg->dig_in_pin = nid;
3675 if (loc == AC_JACK_LOC_HDMI)
3676 cfg->dig_in_type = HDA_PCM_TYPE_HDMI;
3677 else
3678 cfg->dig_in_type = HDA_PCM_TYPE_SPDIF;
3408 break; 3679 break;
3409 } 3680 }
3410 } 3681 }
@@ -3510,6 +3781,9 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3510 cfg->hp_pins[1], cfg->hp_pins[2], 3781 cfg->hp_pins[1], cfg->hp_pins[2],
3511 cfg->hp_pins[3], cfg->hp_pins[4]); 3782 cfg->hp_pins[3], cfg->hp_pins[4]);
3512 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin); 3783 snd_printd(" mono: mono_out=0x%x\n", cfg->mono_out_pin);
3784 if (cfg->dig_outs)
3785 snd_printd(" dig-out=0x%x/0x%x\n",
3786 cfg->dig_out_pins[0], cfg->dig_out_pins[1]);
3513 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x," 3787 snd_printd(" inputs: mic=0x%x, fmic=0x%x, line=0x%x, fline=0x%x,"
3514 " cd=0x%x, aux=0x%x\n", 3788 " cd=0x%x, aux=0x%x\n",
3515 cfg->input_pins[AUTO_PIN_MIC], 3789 cfg->input_pins[AUTO_PIN_MIC],
@@ -3518,6 +3792,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
3518 cfg->input_pins[AUTO_PIN_FRONT_LINE], 3792 cfg->input_pins[AUTO_PIN_FRONT_LINE],
3519 cfg->input_pins[AUTO_PIN_CD], 3793 cfg->input_pins[AUTO_PIN_CD],
3520 cfg->input_pins[AUTO_PIN_AUX]); 3794 cfg->input_pins[AUTO_PIN_AUX]);
3795 if (cfg->dig_in_pin)
3796 snd_printd(" dig-in=0x%x\n", cfg->dig_in_pin);
3521 3797
3522 return 0; 3798 return 0;
3523} 3799}
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 09a332ada0c6..079e1ab718d4 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -778,11 +778,14 @@ struct hda_codec {
778 unsigned short spdif_ctls; /* SPDIF control bits */ 778 unsigned short spdif_ctls; /* SPDIF control bits */
779 unsigned int spdif_in_enable; /* SPDIF input enable? */ 779 unsigned int spdif_in_enable; /* SPDIF input enable? */
780 hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ 780 hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
781 struct snd_array init_pins; /* initial (BIOS) pin configurations */
782 struct snd_array driver_pins; /* pin configs set by codec parser */
781 783
782#ifdef CONFIG_SND_HDA_HWDEP 784#ifdef CONFIG_SND_HDA_HWDEP
783 struct snd_hwdep *hwdep; /* assigned hwdep device */ 785 struct snd_hwdep *hwdep; /* assigned hwdep device */
784 struct snd_array init_verbs; /* additional init verbs */ 786 struct snd_array init_verbs; /* additional init verbs */
785 struct snd_array hints; /* additional hints */ 787 struct snd_array hints; /* additional hints */
788 struct snd_array user_pins; /* default pin configs to override */
786#endif 789#endif
787 790
788 /* misc flags */ 791 /* misc flags */
@@ -790,6 +793,9 @@ struct hda_codec {
790 * status change 793 * status change
791 * (e.g. Realtek codecs) 794 * (e.g. Realtek codecs)
792 */ 795 */
796 unsigned int pin_amp_workaround:1; /* pin out-amp takes index
797 * (e.g. Conexant codecs)
798 */
793#ifdef CONFIG_SND_HDA_POWER_SAVE 799#ifdef CONFIG_SND_HDA_POWER_SAVE
794 unsigned int power_on :1; /* current (global) power-state */ 800 unsigned int power_on :1; /* current (global) power-state */
795 unsigned int power_transition :1; /* power-state in transition */ 801 unsigned int power_transition :1; /* power-state in transition */
@@ -855,6 +861,18 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec);
855#define snd_hda_sequence_write_cache snd_hda_sequence_write 861#define snd_hda_sequence_write_cache snd_hda_sequence_write
856#endif 862#endif
857 863
864/* the struct for codec->pin_configs */
865struct hda_pincfg {
866 hda_nid_t nid;
867 unsigned int cfg;
868};
869
870unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
871int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
872 unsigned int cfg);
873int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
874 hda_nid_t nid, unsigned int cfg); /* for hwdep */
875
858/* 876/*
859 * Mixer 877 * Mixer
860 */ 878 */
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 65745e96dc70..2c81a683e8f8 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -146,7 +146,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid
146 if (node->type == AC_WID_PIN) { 146 if (node->type == AC_WID_PIN) {
147 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP); 147 node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP);
148 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); 148 node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
149 node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 149 node->def_cfg = snd_hda_codec_get_pincfg(codec, node->nid);
150 } 150 }
151 151
152 if (node->wid_caps & AC_WCAP_OUT_AMP) { 152 if (node->wid_caps & AC_WCAP_OUT_AMP) {
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c
index 4ae51dcb81af..1c57505c2874 100644
--- a/sound/pci/hda/hda_hwdep.c
+++ b/sound/pci/hda/hda_hwdep.c
@@ -30,6 +30,12 @@
30#include <sound/hda_hwdep.h> 30#include <sound/hda_hwdep.h>
31#include <sound/minors.h> 31#include <sound/minors.h>
32 32
33/* hint string pair */
34struct hda_hint {
35 const char *key;
36 const char *val; /* contained in the same alloc as key */
37};
38
33/* 39/*
34 * write/read an out-of-bound verb 40 * write/read an out-of-bound verb
35 */ 41 */
@@ -99,16 +105,17 @@ static int hda_hwdep_open(struct snd_hwdep *hw, struct file *file)
99 105
100static void clear_hwdep_elements(struct hda_codec *codec) 106static void clear_hwdep_elements(struct hda_codec *codec)
101{ 107{
102 char **head;
103 int i; 108 int i;
104 109
105 /* clear init verbs */ 110 /* clear init verbs */
106 snd_array_free(&codec->init_verbs); 111 snd_array_free(&codec->init_verbs);
107 /* clear hints */ 112 /* clear hints */
108 head = codec->hints.list; 113 for (i = 0; i < codec->hints.used; i++) {
109 for (i = 0; i < codec->hints.used; i++, head++) 114 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
110 kfree(*head); 115 kfree(hint->key); /* we don't need to free hint->val */
116 }
111 snd_array_free(&codec->hints); 117 snd_array_free(&codec->hints);
118 snd_array_free(&codec->user_pins);
112} 119}
113 120
114static void hwdep_free(struct snd_hwdep *hwdep) 121static void hwdep_free(struct snd_hwdep *hwdep)
@@ -140,7 +147,8 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
140#endif 147#endif
141 148
142 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32); 149 snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32);
143 snd_array_init(&codec->hints, sizeof(char *), 32); 150 snd_array_init(&codec->hints, sizeof(struct hda_hint), 32);
151 snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16);
144 152
145 return 0; 153 return 0;
146} 154}
@@ -153,7 +161,13 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec)
153 161
154static int clear_codec(struct hda_codec *codec) 162static int clear_codec(struct hda_codec *codec)
155{ 163{
156 snd_hda_codec_reset(codec); 164 int err;
165
166 err = snd_hda_codec_reset(codec);
167 if (err < 0) {
168 snd_printk(KERN_ERR "The codec is being used, can't free.\n");
169 return err;
170 }
157 clear_hwdep_elements(codec); 171 clear_hwdep_elements(codec);
158 return 0; 172 return 0;
159} 173}
@@ -162,20 +176,29 @@ static int reconfig_codec(struct hda_codec *codec)
162{ 176{
163 int err; 177 int err;
164 178
179 snd_hda_power_up(codec);
165 snd_printk(KERN_INFO "hda-codec: reconfiguring\n"); 180 snd_printk(KERN_INFO "hda-codec: reconfiguring\n");
166 snd_hda_codec_reset(codec); 181 err = snd_hda_codec_reset(codec);
182 if (err < 0) {
183 snd_printk(KERN_ERR
184 "The codec is being used, can't reconfigure.\n");
185 goto error;
186 }
167 err = snd_hda_codec_configure(codec); 187 err = snd_hda_codec_configure(codec);
168 if (err < 0) 188 if (err < 0)
169 return err; 189 goto error;
170 /* rebuild PCMs */ 190 /* rebuild PCMs */
171 err = snd_hda_codec_build_pcms(codec); 191 err = snd_hda_codec_build_pcms(codec);
172 if (err < 0) 192 if (err < 0)
173 return err; 193 goto error;
174 /* rebuild mixers */ 194 /* rebuild mixers */
175 err = snd_hda_codec_build_controls(codec); 195 err = snd_hda_codec_build_controls(codec);
176 if (err < 0) 196 if (err < 0)
177 return err; 197 goto error;
178 return snd_card_register(codec->bus->card); 198 err = snd_card_register(codec->bus->card);
199 error:
200 snd_hda_power_down(codec);
201 return err;
179} 202}
180 203
181/* 204/*
@@ -271,6 +294,22 @@ static ssize_t type##_store(struct device *dev, \
271CODEC_ACTION_STORE(reconfig); 294CODEC_ACTION_STORE(reconfig);
272CODEC_ACTION_STORE(clear); 295CODEC_ACTION_STORE(clear);
273 296
297static ssize_t init_verbs_show(struct device *dev,
298 struct device_attribute *attr,
299 char *buf)
300{
301 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
302 struct hda_codec *codec = hwdep->private_data;
303 int i, len = 0;
304 for (i = 0; i < codec->init_verbs.used; i++) {
305 struct hda_verb *v = snd_array_elem(&codec->init_verbs, i);
306 len += snprintf(buf + len, PAGE_SIZE - len,
307 "0x%02x 0x%03x 0x%04x\n",
308 v->nid, v->verb, v->param);
309 }
310 return len;
311}
312
274static ssize_t init_verbs_store(struct device *dev, 313static ssize_t init_verbs_store(struct device *dev,
275 struct device_attribute *attr, 314 struct device_attribute *attr,
276 const char *buf, size_t count) 315 const char *buf, size_t count)
@@ -293,26 +332,157 @@ static ssize_t init_verbs_store(struct device *dev,
293 return count; 332 return count;
294} 333}
295 334
335static ssize_t hints_show(struct device *dev,
336 struct device_attribute *attr,
337 char *buf)
338{
339 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
340 struct hda_codec *codec = hwdep->private_data;
341 int i, len = 0;
342 for (i = 0; i < codec->hints.used; i++) {
343 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
344 len += snprintf(buf + len, PAGE_SIZE - len,
345 "%s = %s\n", hint->key, hint->val);
346 }
347 return len;
348}
349
350static struct hda_hint *get_hint(struct hda_codec *codec, const char *key)
351{
352 int i;
353
354 for (i = 0; i < codec->hints.used; i++) {
355 struct hda_hint *hint = snd_array_elem(&codec->hints, i);
356 if (!strcmp(hint->key, key))
357 return hint;
358 }
359 return NULL;
360}
361
362static void remove_trail_spaces(char *str)
363{
364 char *p;
365 if (!*str)
366 return;
367 p = str + strlen(str) - 1;
368 for (; isspace(*p); p--) {
369 *p = 0;
370 if (p == str)
371 return;
372 }
373}
374
375#define MAX_HINTS 1024
376
296static ssize_t hints_store(struct device *dev, 377static ssize_t hints_store(struct device *dev,
297 struct device_attribute *attr, 378 struct device_attribute *attr,
298 const char *buf, size_t count) 379 const char *buf, size_t count)
299{ 380{
300 struct snd_hwdep *hwdep = dev_get_drvdata(dev); 381 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
301 struct hda_codec *codec = hwdep->private_data; 382 struct hda_codec *codec = hwdep->private_data;
302 char *p; 383 char *key, *val;
303 char **hint; 384 struct hda_hint *hint;
304 385
305 if (!*buf || isspace(*buf) || *buf == '#' || *buf == '\n') 386 while (isspace(*buf))
387 buf++;
388 if (!*buf || *buf == '#' || *buf == '\n')
306 return count; 389 return count;
307 p = kstrndup_noeol(buf, 1024); 390 if (*buf == '=')
308 if (!p) 391 return -EINVAL;
392 key = kstrndup_noeol(buf, 1024);
393 if (!key)
309 return -ENOMEM; 394 return -ENOMEM;
310 hint = snd_array_new(&codec->hints); 395 /* extract key and val */
396 val = strchr(key, '=');
397 if (!val) {
398 kfree(key);
399 return -EINVAL;
400 }
401 *val++ = 0;
402 while (isspace(*val))
403 val++;
404 remove_trail_spaces(key);
405 remove_trail_spaces(val);
406 hint = get_hint(codec, key);
407 if (hint) {
408 /* replace */
409 kfree(hint->key);
410 hint->key = key;
411 hint->val = val;
412 return count;
413 }
414 /* allocate a new hint entry */
415 if (codec->hints.used >= MAX_HINTS)
416 hint = NULL;
417 else
418 hint = snd_array_new(&codec->hints);
311 if (!hint) { 419 if (!hint) {
312 kfree(p); 420 kfree(key);
313 return -ENOMEM; 421 return -ENOMEM;
314 } 422 }
315 *hint = p; 423 hint->key = key;
424 hint->val = val;
425 return count;
426}
427
428static ssize_t pin_configs_show(struct hda_codec *codec,
429 struct snd_array *list,
430 char *buf)
431{
432 int i, len = 0;
433 for (i = 0; i < list->used; i++) {
434 struct hda_pincfg *pin = snd_array_elem(list, i);
435 len += sprintf(buf + len, "0x%02x 0x%08x\n",
436 pin->nid, pin->cfg);
437 }
438 return len;
439}
440
441static ssize_t init_pin_configs_show(struct device *dev,
442 struct device_attribute *attr,
443 char *buf)
444{
445 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
446 struct hda_codec *codec = hwdep->private_data;
447 return pin_configs_show(codec, &codec->init_pins, buf);
448}
449
450static ssize_t user_pin_configs_show(struct device *dev,
451 struct device_attribute *attr,
452 char *buf)
453{
454 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
455 struct hda_codec *codec = hwdep->private_data;
456 return pin_configs_show(codec, &codec->user_pins, buf);
457}
458
459static ssize_t driver_pin_configs_show(struct device *dev,
460 struct device_attribute *attr,
461 char *buf)
462{
463 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
464 struct hda_codec *codec = hwdep->private_data;
465 return pin_configs_show(codec, &codec->driver_pins, buf);
466}
467
468#define MAX_PIN_CONFIGS 32
469
470static ssize_t user_pin_configs_store(struct device *dev,
471 struct device_attribute *attr,
472 const char *buf, size_t count)
473{
474 struct snd_hwdep *hwdep = dev_get_drvdata(dev);
475 struct hda_codec *codec = hwdep->private_data;
476 int nid, cfg;
477 int err;
478
479 if (sscanf(buf, "%i %i", &nid, &cfg) != 2)
480 return -EINVAL;
481 if (!nid)
482 return -EINVAL;
483 err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg);
484 if (err < 0)
485 return err;
316 return count; 486 return count;
317} 487}
318 488
@@ -331,8 +501,11 @@ static struct device_attribute codec_attrs[] = {
331 CODEC_ATTR_RO(mfg), 501 CODEC_ATTR_RO(mfg),
332 CODEC_ATTR_RW(name), 502 CODEC_ATTR_RW(name),
333 CODEC_ATTR_RW(modelname), 503 CODEC_ATTR_RW(modelname),
334 CODEC_ATTR_WO(init_verbs), 504 CODEC_ATTR_RW(init_verbs),
335 CODEC_ATTR_WO(hints), 505 CODEC_ATTR_RW(hints),
506 CODEC_ATTR_RO(init_pin_configs),
507 CODEC_ATTR_RW(user_pin_configs),
508 CODEC_ATTR_RO(driver_pin_configs),
336 CODEC_ATTR_WO(reconfig), 509 CODEC_ATTR_WO(reconfig),
337 CODEC_ATTR_WO(clear), 510 CODEC_ATTR_WO(clear),
338}; 511};
@@ -351,4 +524,29 @@ int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
351 return 0; 524 return 0;
352} 525}
353 526
527/*
528 * Look for hint string
529 */
530const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
531{
532 struct hda_hint *hint = get_hint(codec, key);
533 return hint ? hint->val : NULL;
534}
535EXPORT_SYMBOL_HDA(snd_hda_get_hint);
536
537int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
538{
539 const char *p = snd_hda_get_hint(codec, key);
540 if (!p || !*p)
541 return -ENOENT;
542 switch (toupper(*p)) {
543 case 'T': /* true */
544 case 'Y': /* yes */
545 case '1':
546 return 1;
547 }
548 return 0;
549}
550EXPORT_SYMBOL_HDA(snd_hda_get_bool_hint);
551
354#endif /* CONFIG_SND_HDA_RECONFIG */ 552#endif /* CONFIG_SND_HDA_RECONFIG */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index f3b5723c2859..6bcf5af6edce 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -381,6 +381,7 @@ struct azx {
381 381
382 /* HD codec */ 382 /* HD codec */
383 unsigned short codec_mask; 383 unsigned short codec_mask;
384 int codec_probe_mask; /* copied from probe_mask option */
384 struct hda_bus *bus; 385 struct hda_bus *bus;
385 386
386 /* CORB/RIRB */ 387 /* CORB/RIRB */
@@ -1228,7 +1229,6 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = {
1228}; 1229};
1229 1230
1230static int __devinit azx_codec_create(struct azx *chip, const char *model, 1231static int __devinit azx_codec_create(struct azx *chip, const char *model,
1231 unsigned int codec_probe_mask,
1232 int no_init) 1232 int no_init)
1233{ 1233{
1234 struct hda_bus_template bus_temp; 1234 struct hda_bus_template bus_temp;
@@ -1261,7 +1261,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1261 1261
1262 /* First try to probe all given codec slots */ 1262 /* First try to probe all given codec slots */
1263 for (c = 0; c < max_slots; c++) { 1263 for (c = 0; c < max_slots; c++) {
1264 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1264 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1265 if (probe_codec(chip, c) < 0) { 1265 if (probe_codec(chip, c) < 0) {
1266 /* Some BIOSen give you wrong codec addresses 1266 /* Some BIOSen give you wrong codec addresses
1267 * that don't exist 1267 * that don't exist
@@ -1285,7 +1285,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model,
1285 1285
1286 /* Then create codec instances */ 1286 /* Then create codec instances */
1287 for (c = 0; c < max_slots; c++) { 1287 for (c = 0; c < max_slots; c++) {
1288 if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { 1288 if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1289 struct hda_codec *codec; 1289 struct hda_codec *codec;
1290 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); 1290 err = snd_hda_codec_new(chip->bus, c, !no_init, &codec);
1291 if (err < 0) 1291 if (err < 0)
@@ -2100,25 +2100,36 @@ static struct snd_pci_quirk probe_mask_list[] __devinitdata = {
2100 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01), 2100 SND_PCI_QUIRK(0x1028, 0x20ac, "Dell Studio Desktop", 0x01),
2101 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */ 2101 /* including bogus ALC268 in slot#2 that conflicts with ALC888 */
2102 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01), 2102 SND_PCI_QUIRK(0x17c0, 0x4085, "Medion MD96630", 0x01),
2103 /* conflict of ALC268 in slot#3 (digital I/O); a temporary fix */ 2103 /* forced codec slots */
2104 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba laptop", 0x03), 2104 SND_PCI_QUIRK(0x1046, 0x1262, "ASUS W5F", 0x103),
2105 {} 2105 {}
2106}; 2106};
2107 2107
2108#define AZX_FORCE_CODEC_MASK 0x100
2109
2108static void __devinit check_probe_mask(struct azx *chip, int dev) 2110static void __devinit check_probe_mask(struct azx *chip, int dev)
2109{ 2111{
2110 const struct snd_pci_quirk *q; 2112 const struct snd_pci_quirk *q;
2111 2113
2112 if (probe_mask[dev] == -1) { 2114 chip->codec_probe_mask = probe_mask[dev];
2115 if (chip->codec_probe_mask == -1) {
2113 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list); 2116 q = snd_pci_quirk_lookup(chip->pci, probe_mask_list);
2114 if (q) { 2117 if (q) {
2115 printk(KERN_INFO 2118 printk(KERN_INFO
2116 "hda_intel: probe_mask set to 0x%x " 2119 "hda_intel: probe_mask set to 0x%x "
2117 "for device %04x:%04x\n", 2120 "for device %04x:%04x\n",
2118 q->value, q->subvendor, q->subdevice); 2121 q->value, q->subvendor, q->subdevice);
2119 probe_mask[dev] = q->value; 2122 chip->codec_probe_mask = q->value;
2120 } 2123 }
2121 } 2124 }
2125
2126 /* check forced option */
2127 if (chip->codec_probe_mask != -1 &&
2128 (chip->codec_probe_mask & AZX_FORCE_CODEC_MASK)) {
2129 chip->codec_mask = chip->codec_probe_mask & 0xff;
2130 printk(KERN_INFO "hda_intel: codec_mask forced to 0x%x\n",
2131 chip->codec_mask);
2132 }
2122} 2133}
2123 2134
2124 2135
@@ -2359,8 +2370,7 @@ static int __devinit azx_probe(struct pci_dev *pci,
2359 card->private_data = chip; 2370 card->private_data = chip;
2360 2371
2361 /* create codec instances */ 2372 /* create codec instances */
2362 err = azx_codec_create(chip, model[dev], probe_mask[dev], 2373 err = azx_codec_create(chip, model[dev], probe_only[dev]);
2363 probe_only[dev]);
2364 if (err < 0) 2374 if (err < 0)
2365 goto out_free; 2375 goto out_free;
2366 2376
@@ -2457,10 +2467,10 @@ static struct pci_device_id azx_ids[] = {
2457 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA }, 2467 { PCI_DEVICE(0x10de, 0x0ac1), .driver_data = AZX_DRIVER_NVIDIA },
2458 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA }, 2468 { PCI_DEVICE(0x10de, 0x0ac2), .driver_data = AZX_DRIVER_NVIDIA },
2459 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA }, 2469 { PCI_DEVICE(0x10de, 0x0ac3), .driver_data = AZX_DRIVER_NVIDIA },
2460 { PCI_DEVICE(0x10de, 0x0bd4), .driver_data = AZX_DRIVER_NVIDIA }, 2470 { PCI_DEVICE(0x10de, 0x0d94), .driver_data = AZX_DRIVER_NVIDIA },
2461 { PCI_DEVICE(0x10de, 0x0bd5), .driver_data = AZX_DRIVER_NVIDIA }, 2471 { PCI_DEVICE(0x10de, 0x0d95), .driver_data = AZX_DRIVER_NVIDIA },
2462 { PCI_DEVICE(0x10de, 0x0bd6), .driver_data = AZX_DRIVER_NVIDIA }, 2472 { PCI_DEVICE(0x10de, 0x0d96), .driver_data = AZX_DRIVER_NVIDIA },
2463 { PCI_DEVICE(0x10de, 0x0bd7), .driver_data = AZX_DRIVER_NVIDIA }, 2473 { PCI_DEVICE(0x10de, 0x0d97), .driver_data = AZX_DRIVER_NVIDIA },
2464 /* Teradici */ 2474 /* Teradici */
2465 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA }, 2475 { PCI_DEVICE(0x6549, 0x1200), .driver_data = AZX_DRIVER_TERA },
2466 /* AMD Generic, PCI class code and Vendor ID for HD Audio */ 2476 /* AMD Generic, PCI class code and Vendor ID for HD Audio */
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 44f189cb97ae..27428c718fd7 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -26,8 +26,10 @@
26/* 26/*
27 * for mixer controls 27 * for mixer controls
28 */ 28 */
29#define HDA_COMPOSE_AMP_VAL_OFS(nid,chs,idx,dir,ofs) \
30 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19) | ((ofs)<<23))
29#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \ 31#define HDA_COMPOSE_AMP_VAL(nid,chs,idx,dir) \
30 ((nid) | ((chs)<<16) | ((dir)<<18) | ((idx)<<19)) 32 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, idx, dir, 0)
31/* mono volume with index (index=0,1,...) (channel=1,2) */ 33/* mono volume with index (index=0,1,...) (channel=1,2) */
32#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \ 34#define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
33 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \ 35 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
@@ -96,7 +98,7 @@ struct snd_kcontrol *snd_hda_find_mixer_ctl(struct hda_codec *codec,
96 const char *name); 98 const char *name);
97int snd_hda_add_vmaster(struct hda_codec *codec, char *name, 99int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
98 unsigned int *tlv, const char **slaves); 100 unsigned int *tlv, const char **slaves);
99void snd_hda_codec_reset(struct hda_codec *codec); 101int snd_hda_codec_reset(struct hda_codec *codec);
100int snd_hda_codec_configure(struct hda_codec *codec); 102int snd_hda_codec_configure(struct hda_codec *codec);
101 103
102/* amp value bits */ 104/* amp value bits */
@@ -134,7 +136,7 @@ extern struct hda_ctl_ops snd_hda_bind_sw; /* for bind-switch */
134 136
135struct hda_bind_ctls { 137struct hda_bind_ctls {
136 struct hda_ctl_ops *ops; 138 struct hda_ctl_ops *ops;
137 long values[]; 139 unsigned long values[];
138}; 140};
139 141
140int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, 142int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol,
@@ -227,6 +229,7 @@ struct hda_multi_out {
227 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */ 229 hda_nid_t hp_nid; /* optional DAC for HP, 0 when not exists */
228 hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */ 230 hda_nid_t extra_out_nid[3]; /* optional DACs, 0 when not exists */
229 hda_nid_t dig_out_nid; /* digital out audio widget */ 231 hda_nid_t dig_out_nid; /* digital out audio widget */
232 hda_nid_t *slave_dig_outs;
230 int max_channels; /* currently supported analog channels */ 233 int max_channels; /* currently supported analog channels */
231 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */ 234 int dig_out_used; /* current usage of digital out (HDA_DIG_XXX) */
232 int no_share_stream; /* don't share a stream with multiple pins */ 235 int no_share_stream; /* don't share a stream with multiple pins */
@@ -354,9 +357,12 @@ struct auto_pin_cfg {
354 int line_out_type; /* AUTO_PIN_XXX_OUT */ 357 int line_out_type; /* AUTO_PIN_XXX_OUT */
355 hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS]; 358 hda_nid_t hp_pins[AUTO_CFG_MAX_OUTS];
356 hda_nid_t input_pins[AUTO_PIN_LAST]; 359 hda_nid_t input_pins[AUTO_PIN_LAST];
357 hda_nid_t dig_out_pin; 360 int dig_outs;
361 hda_nid_t dig_out_pins[2];
358 hda_nid_t dig_in_pin; 362 hda_nid_t dig_in_pin;
359 hda_nid_t mono_out_pin; 363 hda_nid_t mono_out_pin;
364 int dig_out_type[2]; /* HDA_PCM_TYPE_XXX */
365 int dig_in_type; /* HDA_PCM_TYPE_XXX */
360}; 366};
361 367
362#define get_defcfg_connect(cfg) \ 368#define get_defcfg_connect(cfg) \
@@ -427,6 +433,23 @@ static inline int snd_hda_hwdep_add_sysfs(struct hda_codec *codec)
427} 433}
428#endif 434#endif
429 435
436#ifdef CONFIG_SND_HDA_RECONFIG
437const char *snd_hda_get_hint(struct hda_codec *codec, const char *key);
438int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key);
439#else
440static inline
441const char *snd_hda_get_hint(struct hda_codec *codec, const char *key)
442{
443 return NULL;
444}
445
446static inline
447int snd_hda_get_bool_hint(struct hda_codec *codec, const char *key)
448{
449 return -ENOENT;
450}
451#endif
452
430/* 453/*
431 * power-management 454 * power-management
432 */ 455 */
@@ -458,6 +481,7 @@ int snd_hda_check_amp_list_power(struct hda_codec *codec,
458#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3) 481#define get_amp_channels(kc) (((kc)->private_value >> 16) & 0x3)
459#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1) 482#define get_amp_direction(kc) (((kc)->private_value >> 18) & 0x1)
460#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) 483#define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf)
484#define get_amp_offset(kc) (((kc)->private_value >> 23) & 0x3f)
461 485
462/* 486/*
463 * CEA Short Audio Descriptor data 487 * CEA Short Audio Descriptor data
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c
index 144b85276d5a..93b25ba4d00b 100644
--- a/sound/pci/hda/hda_proc.c
+++ b/sound/pci/hda/hda_proc.c
@@ -554,8 +554,14 @@ static void print_codec_info(struct snd_info_entry *entry,
554 snd_iprintf(buffer, " Amp-Out caps: "); 554 snd_iprintf(buffer, " Amp-Out caps: ");
555 print_amp_caps(buffer, codec, nid, HDA_OUTPUT); 555 print_amp_caps(buffer, codec, nid, HDA_OUTPUT);
556 snd_iprintf(buffer, " Amp-Out vals: "); 556 snd_iprintf(buffer, " Amp-Out vals: ");
557 print_amp_vals(buffer, codec, nid, HDA_OUTPUT, 557 if (wid_type == AC_WID_PIN &&
558 wid_caps & AC_WCAP_STEREO, 1); 558 codec->pin_amp_workaround)
559 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
560 wid_caps & AC_WCAP_STEREO,
561 conn_len);
562 else
563 print_amp_vals(buffer, codec, nid, HDA_OUTPUT,
564 wid_caps & AC_WCAP_STEREO, 1);
559 } 565 }
560 566
561 switch (wid_type) { 567 switch (wid_type) {
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index e48612323aa0..5bb48ee8b6c6 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -27,11 +27,12 @@
27#include <sound/core.h> 27#include <sound/core.h>
28#include "hda_codec.h" 28#include "hda_codec.h"
29#include "hda_local.h" 29#include "hda_local.h"
30#include "hda_beep.h"
30 31
31struct ad198x_spec { 32struct ad198x_spec {
32 struct snd_kcontrol_new *mixers[5]; 33 struct snd_kcontrol_new *mixers[5];
33 int num_mixers; 34 int num_mixers;
34 35 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
35 const struct hda_verb *init_verbs[5]; /* initialization verbs 36 const struct hda_verb *init_verbs[5]; /* initialization verbs
36 * don't forget NULL termination! 37 * don't forget NULL termination!
37 */ 38 */
@@ -154,6 +155,16 @@ static const char *ad_slave_sws[] = {
154 155
155static void ad198x_free_kctls(struct hda_codec *codec); 156static void ad198x_free_kctls(struct hda_codec *codec);
156 157
158/* additional beep mixers; the actual parameters are overwritten at build */
159static struct snd_kcontrol_new ad_beep_mixer[] = {
160 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
161 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_OUTPUT),
162 { } /* end */
163};
164
165#define set_beep_amp(spec, nid, idx, dir) \
166 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
167
157static int ad198x_build_controls(struct hda_codec *codec) 168static int ad198x_build_controls(struct hda_codec *codec)
158{ 169{
159 struct ad198x_spec *spec = codec->spec; 170 struct ad198x_spec *spec = codec->spec;
@@ -181,6 +192,21 @@ static int ad198x_build_controls(struct hda_codec *codec)
181 return err; 192 return err;
182 } 193 }
183 194
195 /* create beep controls if needed */
196 if (spec->beep_amp) {
197 struct snd_kcontrol_new *knew;
198 for (knew = ad_beep_mixer; knew->name; knew++) {
199 struct snd_kcontrol *kctl;
200 kctl = snd_ctl_new1(knew, codec);
201 if (!kctl)
202 return -ENOMEM;
203 kctl->private_value = spec->beep_amp;
204 err = snd_hda_ctl_add(codec, kctl);
205 if (err < 0)
206 return err;
207 }
208 }
209
184 /* if we have no master control, let's create it */ 210 /* if we have no master control, let's create it */
185 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 211 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
186 unsigned int vmaster_tlv[4]; 212 unsigned int vmaster_tlv[4];
@@ -406,7 +432,8 @@ static void ad198x_free(struct hda_codec *codec)
406 return; 432 return;
407 433
408 ad198x_free_kctls(codec); 434 ad198x_free_kctls(codec);
409 kfree(codec->spec); 435 kfree(spec);
436 snd_hda_detach_beep_device(codec);
410} 437}
411 438
412static struct hda_codec_ops ad198x_patch_ops = { 439static struct hda_codec_ops ad198x_patch_ops = {
@@ -545,8 +572,6 @@ static struct snd_kcontrol_new ad1986a_mixers[] = {
545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
546 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 573 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
547 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 574 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
548 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT),
549 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
550 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), 575 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
551 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), 576 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
552 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 577 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
@@ -610,8 +635,7 @@ static struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
611 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 636 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
612 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 637 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
613 /* HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x18, 0x0, HDA_OUTPUT), 638 /*
614 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x18, 0x0, HDA_OUTPUT),
615 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT), 639 HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
616 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */ 640 HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
617 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 641 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
@@ -809,8 +833,6 @@ static struct snd_kcontrol_new ad1986a_laptop_automute_mixers[] = {
809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT), 833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
810 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT), 834 HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
811 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT), 835 HDA_CODEC_VOLUME("Mic Boost", 0x0f, 0x0, HDA_OUTPUT),
812 HDA_CODEC_VOLUME("Beep Playback Volume", 0x18, 0x0, HDA_OUTPUT),
813 HDA_CODEC_MUTE("Beep Playback Switch", 0x18, 0x0, HDA_OUTPUT),
814 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT), 836 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
815 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT), 837 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
816 { 838 {
@@ -1002,10 +1024,8 @@ static struct snd_pci_quirk ad1986a_cfg_tbl[] = {
1002 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD), 1024 SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba", AD1986A_LAPTOP_EAPD),
1003 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK), 1025 SND_PCI_QUIRK(0x144d, 0xb03c, "Samsung R55", AD1986A_3STACK),
1004 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP), 1026 SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
1005 SND_PCI_QUIRK(0x144d, 0xc023, "Samsung X60", AD1986A_SAMSUNG),
1006 SND_PCI_QUIRK(0x144d, 0xc024, "Samsung R65", AD1986A_SAMSUNG),
1007 SND_PCI_QUIRK(0x144d, 0xc026, "Samsung X11", AD1986A_SAMSUNG),
1008 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA), 1027 SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_ULTRA),
1028 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_SAMSUNG),
1009 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK), 1029 SND_PCI_QUIRK(0x144d, 0xc504, "Samsung Q35", AD1986A_3STACK),
1010 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP), 1030 SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
1011 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK), 1031 SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
@@ -1027,15 +1047,14 @@ static struct hda_amp_list ad1986a_loopbacks[] = {
1027 1047
1028static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) 1048static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
1029{ 1049{
1030 unsigned int conf = snd_hda_codec_read(codec, nid, 0, 1050 unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
1031 AC_VERB_GET_CONFIG_DEFAULT, 0);
1032 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; 1051 return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
1033} 1052}
1034 1053
1035static int patch_ad1986a(struct hda_codec *codec) 1054static int patch_ad1986a(struct hda_codec *codec)
1036{ 1055{
1037 struct ad198x_spec *spec; 1056 struct ad198x_spec *spec;
1038 int board_config; 1057 int err, board_config;
1039 1058
1040 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1059 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1041 if (spec == NULL) 1060 if (spec == NULL)
@@ -1043,6 +1062,13 @@ static int patch_ad1986a(struct hda_codec *codec)
1043 1062
1044 codec->spec = spec; 1063 codec->spec = spec;
1045 1064
1065 err = snd_hda_attach_beep_device(codec, 0x19);
1066 if (err < 0) {
1067 ad198x_free(codec);
1068 return err;
1069 }
1070 set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
1071
1046 spec->multiout.max_channels = 6; 1072 spec->multiout.max_channels = 6;
1047 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids); 1073 spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
1048 spec->multiout.dac_nids = ad1986a_dac_nids; 1074 spec->multiout.dac_nids = ad1986a_dac_nids;
@@ -1222,8 +1248,6 @@ static struct snd_kcontrol_new ad1983_mixers[] = {
1222 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT), 1248 HDA_CODEC_MUTE("Mic Playback Switch", 0x12, 0x0, HDA_OUTPUT),
1223 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT), 1249 HDA_CODEC_VOLUME("Line Playback Volume", 0x13, 0x0, HDA_OUTPUT),
1224 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT), 1250 HDA_CODEC_MUTE("Line Playback Switch", 0x13, 0x0, HDA_OUTPUT),
1225 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x10, 1, 0x0, HDA_OUTPUT),
1226 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x10, 1, 0x0, HDA_OUTPUT),
1227 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT), 1251 HDA_CODEC_VOLUME("Mic Boost", 0x0c, 0x0, HDA_OUTPUT),
1228 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), 1252 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
1229 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT), 1253 HDA_CODEC_MUTE("Capture Switch", 0x15, 0x0, HDA_OUTPUT),
@@ -1294,6 +1318,7 @@ static struct hda_amp_list ad1983_loopbacks[] = {
1294static int patch_ad1983(struct hda_codec *codec) 1318static int patch_ad1983(struct hda_codec *codec)
1295{ 1319{
1296 struct ad198x_spec *spec; 1320 struct ad198x_spec *spec;
1321 int err;
1297 1322
1298 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1323 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1299 if (spec == NULL) 1324 if (spec == NULL)
@@ -1301,6 +1326,13 @@ static int patch_ad1983(struct hda_codec *codec)
1301 1326
1302 codec->spec = spec; 1327 codec->spec = spec;
1303 1328
1329 err = snd_hda_attach_beep_device(codec, 0x10);
1330 if (err < 0) {
1331 ad198x_free(codec);
1332 return err;
1333 }
1334 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
1335
1304 spec->multiout.max_channels = 2; 1336 spec->multiout.max_channels = 2;
1305 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids); 1337 spec->multiout.num_dacs = ARRAY_SIZE(ad1983_dac_nids);
1306 spec->multiout.dac_nids = ad1983_dac_nids; 1338 spec->multiout.dac_nids = ad1983_dac_nids;
@@ -1370,8 +1402,6 @@ static struct snd_kcontrol_new ad1981_mixers[] = {
1370 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT), 1402 HDA_CODEC_MUTE("Mic Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
1371 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT), 1403 HDA_CODEC_VOLUME("CD Playback Volume", 0x1d, 0x0, HDA_OUTPUT),
1372 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT), 1404 HDA_CODEC_MUTE("CD Playback Switch", 0x1d, 0x0, HDA_OUTPUT),
1373 HDA_CODEC_VOLUME_MONO("PC Speaker Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
1374 HDA_CODEC_MUTE_MONO("PC Speaker Playback Switch", 0x0d, 1, 0x0, HDA_OUTPUT),
1375 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT), 1405 HDA_CODEC_VOLUME("Front Mic Boost", 0x08, 0x0, HDA_INPUT),
1376 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT), 1406 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x0, HDA_INPUT),
1377 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT), 1407 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
@@ -1416,8 +1446,8 @@ static struct hda_verb ad1981_init_verbs[] = {
1416 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1446 {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
1417 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1447 {0x1f, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
1418 /* Mic boost: 0dB */ 1448 /* Mic boost: 0dB */
1419 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1420 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, 1450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1421 /* Record selector: Front mic */ 1451 /* Record selector: Front mic */
1422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, 1452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0},
1423 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080}, 1453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
@@ -1682,10 +1712,10 @@ static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1682 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD), 1712 SND_PCI_QUIRK(0x1014, 0x0597, "Lenovo Z60", AD1981_THINKPAD),
1683 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD), 1713 SND_PCI_QUIRK(0x1014, 0x05b7, "Lenovo Z60m", AD1981_THINKPAD),
1684 /* All HP models */ 1714 /* All HP models */
1685 SND_PCI_QUIRK(0x103c, 0, "HP nx", AD1981_HP), 1715 SND_PCI_QUIRK_VENDOR(0x103c, "HP nx", AD1981_HP),
1686 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA), 1716 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba U205", AD1981_TOSHIBA),
1687 /* Lenovo Thinkpad T60/X60/Z6xx */ 1717 /* Lenovo Thinkpad T60/X60/Z6xx */
1688 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1981_THINKPAD), 1718 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1981_THINKPAD),
1689 /* HP nx6320 (reversed SSID, H/W bug) */ 1719 /* HP nx6320 (reversed SSID, H/W bug) */
1690 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP), 1720 SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_HP),
1691 {} 1721 {}
@@ -1694,7 +1724,7 @@ static struct snd_pci_quirk ad1981_cfg_tbl[] = {
1694static int patch_ad1981(struct hda_codec *codec) 1724static int patch_ad1981(struct hda_codec *codec)
1695{ 1725{
1696 struct ad198x_spec *spec; 1726 struct ad198x_spec *spec;
1697 int board_config; 1727 int err, board_config;
1698 1728
1699 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 1729 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
1700 if (spec == NULL) 1730 if (spec == NULL)
@@ -1702,6 +1732,13 @@ static int patch_ad1981(struct hda_codec *codec)
1702 1732
1703 codec->spec = spec; 1733 codec->spec = spec;
1704 1734
1735 err = snd_hda_attach_beep_device(codec, 0x10);
1736 if (err < 0) {
1737 ad198x_free(codec);
1738 return err;
1739 }
1740 set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
1741
1705 spec->multiout.max_channels = 2; 1742 spec->multiout.max_channels = 2;
1706 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids); 1743 spec->multiout.num_dacs = ARRAY_SIZE(ad1981_dac_nids);
1707 spec->multiout.dac_nids = ad1981_dac_nids; 1744 spec->multiout.dac_nids = ad1981_dac_nids;
@@ -1988,9 +2025,6 @@ static struct snd_kcontrol_new ad1988_6stack_mixers2[] = {
1988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), 2025 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
1989 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), 2026 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
1990 2027
1991 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
1992 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
1993
1994 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 2028 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
1995 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 2029 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
1996 2030
@@ -2034,9 +2068,6 @@ static struct snd_kcontrol_new ad1988_3stack_mixers2[] = {
2034 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), 2068 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT),
2035 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), 2069 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT),
2036 2070
2037 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2038 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2039
2040 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 2071 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2041 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 2072 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2042 2073
@@ -2066,9 +2097,6 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = {
2066 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), 2097 HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT),
2067 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), 2098 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT),
2068 2099
2069 HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
2070 HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
2071
2072 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), 2100 HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT),
2073 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), 2101 HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT),
2074 2102
@@ -2297,10 +2325,6 @@ static struct hda_verb ad1988_capture_init_verbs[] = {
2297 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 2325 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2298 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 2326 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2299 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 2327 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2300 /* ADCs; muted */
2301 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2302 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2304 2328
2305 { } 2329 { }
2306}; 2330};
@@ -2408,10 +2432,6 @@ static struct hda_verb ad1988_3stack_init_verbs[] = {
2408 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 2432 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2409 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 2433 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2410 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 2434 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2411 /* ADCs; muted */
2412 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2413 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2414 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2415 /* Analog Mix output amp */ 2435 /* Analog Mix output amp */
2416 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ 2436 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2417 { } 2437 { }
@@ -2483,10 +2503,6 @@ static struct hda_verb ad1988_laptop_init_verbs[] = {
2483 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, 2503 {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1},
2484 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, 2504 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1},
2485 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 2505 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
2486 /* ADCs; muted */
2487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2488 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2490 /* Analog Mix output amp */ 2506 /* Analog Mix output amp */
2491 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */ 2507 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x1f}, /* 0dB */
2492 { } 2508 { }
@@ -2890,7 +2906,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec)
2890 2906
2891 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2907 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2892 2908
2893 if (spec->autocfg.dig_out_pin) 2909 if (spec->autocfg.dig_outs)
2894 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; 2910 spec->multiout.dig_out_nid = AD1988_SPDIF_OUT;
2895 if (spec->autocfg.dig_in_pin) 2911 if (spec->autocfg.dig_in_pin)
2896 spec->dig_in_nid = AD1988_SPDIF_IN; 2912 spec->dig_in_nid = AD1988_SPDIF_IN;
@@ -2940,7 +2956,7 @@ static struct snd_pci_quirk ad1988_cfg_tbl[] = {
2940static int patch_ad1988(struct hda_codec *codec) 2956static int patch_ad1988(struct hda_codec *codec)
2941{ 2957{
2942 struct ad198x_spec *spec; 2958 struct ad198x_spec *spec;
2943 int board_config; 2959 int err, board_config;
2944 2960
2945 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2961 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2946 if (spec == NULL) 2962 if (spec == NULL)
@@ -2960,7 +2976,7 @@ static int patch_ad1988(struct hda_codec *codec)
2960 2976
2961 if (board_config == AD1988_AUTO) { 2977 if (board_config == AD1988_AUTO) {
2962 /* automatic parse from the BIOS config */ 2978 /* automatic parse from the BIOS config */
2963 int err = ad1988_parse_auto_config(codec); 2979 err = ad1988_parse_auto_config(codec);
2964 if (err < 0) { 2980 if (err < 0) {
2965 ad198x_free(codec); 2981 ad198x_free(codec);
2966 return err; 2982 return err;
@@ -2970,6 +2986,13 @@ static int patch_ad1988(struct hda_codec *codec)
2970 } 2986 }
2971 } 2987 }
2972 2988
2989 err = snd_hda_attach_beep_device(codec, 0x10);
2990 if (err < 0) {
2991 ad198x_free(codec);
2992 return err;
2993 }
2994 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
2995
2973 switch (board_config) { 2996 switch (board_config) {
2974 case AD1988_6STACK: 2997 case AD1988_6STACK:
2975 case AD1988_6STACK_DIG: 2998 case AD1988_6STACK_DIG:
@@ -3126,12 +3149,6 @@ static struct snd_kcontrol_new ad1884_base_mixers[] = {
3126 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT), 3149 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3127 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), 3150 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3128 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), 3151 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3129 /*
3130 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3131 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3132 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT),
3133 HDA_CODEC_MUTE("Digital Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT),
3134 */
3135 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT), 3152 HDA_CODEC_VOLUME("Mic Boost", 0x15, 0x0, HDA_INPUT),
3136 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), 3153 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3137 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3154 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3204,10 +3221,10 @@ static struct hda_verb ad1884_init_verbs[] = {
3204 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, 3221 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1},
3205 /* Port-B (front mic) pin */ 3222 /* Port-B (front mic) pin */
3206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3207 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3224 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3208 /* Port-C (rear mic) pin */ 3225 /* Port-C (rear mic) pin */
3209 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3210 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3227 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3211 /* Analog mixer; mute as default */ 3228 /* Analog mixer; mute as default */
3212 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3229 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3213 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 3230 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
@@ -3240,7 +3257,7 @@ static const char *ad1884_slave_vols[] = {
3240 "CD Playback Volume", 3257 "CD Playback Volume",
3241 "Internal Mic Playback Volume", 3258 "Internal Mic Playback Volume",
3242 "Docking Mic Playback Volume" 3259 "Docking Mic Playback Volume"
3243 "Beep Playback Volume", 3260 /* "Beep Playback Volume", */
3244 "IEC958 Playback Volume", 3261 "IEC958 Playback Volume",
3245 NULL 3262 NULL
3246}; 3263};
@@ -3248,6 +3265,7 @@ static const char *ad1884_slave_vols[] = {
3248static int patch_ad1884(struct hda_codec *codec) 3265static int patch_ad1884(struct hda_codec *codec)
3249{ 3266{
3250 struct ad198x_spec *spec; 3267 struct ad198x_spec *spec;
3268 int err;
3251 3269
3252 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3270 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3253 if (spec == NULL) 3271 if (spec == NULL)
@@ -3255,6 +3273,13 @@ static int patch_ad1884(struct hda_codec *codec)
3255 3273
3256 codec->spec = spec; 3274 codec->spec = spec;
3257 3275
3276 err = snd_hda_attach_beep_device(codec, 0x10);
3277 if (err < 0) {
3278 ad198x_free(codec);
3279 return err;
3280 }
3281 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3282
3258 spec->multiout.max_channels = 2; 3283 spec->multiout.max_channels = 2;
3259 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids); 3284 spec->multiout.num_dacs = ARRAY_SIZE(ad1884_dac_nids);
3260 spec->multiout.dac_nids = ad1884_dac_nids; 3285 spec->multiout.dac_nids = ad1884_dac_nids;
@@ -3321,8 +3346,6 @@ static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3321 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3346 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3322 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), 3347 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3323 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT), 3348 HDA_CODEC_VOLUME("Docking Mic Boost", 0x25, 0x0, HDA_OUTPUT),
3324 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3325 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3326 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3349 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
3327 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), 3350 HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT),
3328 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), 3351 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT),
@@ -3358,7 +3381,7 @@ static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3358 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3381 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3359 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3382 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3360 /* docking mic boost */ 3383 /* docking mic boost */
3361 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3384 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3362 /* Analog mixer - docking mic; mute as default */ 3385 /* Analog mixer - docking mic; mute as default */
3363 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3386 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3364 /* enable EAPD bit */ 3387 /* enable EAPD bit */
@@ -3379,10 +3402,6 @@ static struct snd_kcontrol_new ad1984_dell_desktop_mixers[] = {
3379 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT), 3402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3380 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT), 3403 HDA_CODEC_VOLUME("Line-In Playback Volume", 0x20, 0x01, HDA_INPUT),
3381 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT), 3404 HDA_CODEC_MUTE("Line-In Playback Switch", 0x20, 0x01, HDA_INPUT),
3382 /*
3383 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x20, 0x03, HDA_INPUT),
3384 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x20, 0x03, HDA_INPUT),
3385 */
3386 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT), 3405 HDA_CODEC_VOLUME("Line-In Boost", 0x15, 0x0, HDA_INPUT),
3387 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), 3406 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3388 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3407 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3468,7 +3487,7 @@ static const char *ad1984_models[AD1984_MODELS] = {
3468 3487
3469static struct snd_pci_quirk ad1984_cfg_tbl[] = { 3488static struct snd_pci_quirk ad1984_cfg_tbl[] = {
3470 /* Lenovo Thinkpad T61/X61 */ 3489 /* Lenovo Thinkpad T61/X61 */
3471 SND_PCI_QUIRK(0x17aa, 0, "Lenovo Thinkpad", AD1984_THINKPAD), 3490 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1984_THINKPAD),
3472 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP), 3491 SND_PCI_QUIRK(0x1028, 0x0214, "Dell T3400", AD1984_DELL_DESKTOP),
3473 {} 3492 {}
3474}; 3493};
@@ -3561,8 +3580,6 @@ static struct snd_kcontrol_new ad1884a_base_mixers[] = {
3561 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT), 3580 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3562 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT), 3581 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x02, HDA_INPUT),
3563 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT), 3582 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x02, HDA_INPUT),
3564 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3565 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3566 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT), 3583 HDA_CODEC_VOLUME("Front Mic Boost", 0x14, 0x0, HDA_INPUT),
3567 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT), 3584 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x0, HDA_INPUT),
3568 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT), 3585 HDA_CODEC_VOLUME("Mic Boost", 0x25, 0x0, HDA_OUTPUT),
@@ -3622,10 +3639,10 @@ static struct hda_verb ad1884a_init_verbs[] = {
3622 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3639 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3623 /* Port-B (front mic) pin */ 3640 /* Port-B (front mic) pin */
3624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3641 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3625 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3642 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3626 /* Port-C (rear line-in) pin */ 3643 /* Port-C (rear line-in) pin */
3627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 3644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3629 /* Port-E (rear mic) pin */ 3646 /* Port-E (rear mic) pin */
3630 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3647 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3631 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3648 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
@@ -3695,8 +3712,6 @@ static struct snd_kcontrol_new ad1884a_laptop_mixers[] = {
3695 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), 3712 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3696 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT), 3713 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3697 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT), 3714 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3698 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3699 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3700 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3715 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3701 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT), 3716 HDA_CODEC_VOLUME("Internal Mic Boost", 0x15, 0x0, HDA_INPUT),
3702 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT), 3717 HDA_CODEC_VOLUME("Dock Mic Boost", 0x25, 0x0, HDA_OUTPUT),
@@ -3724,8 +3739,6 @@ static struct snd_kcontrol_new ad1884a_mobile_mixers[] = {
3724 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT), 3739 HDA_CODEC_MUTE("Master Playback Switch", 0x21, 0x0, HDA_OUTPUT),
3725 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT), 3740 HDA_CODEC_VOLUME("PCM Playback Volume", 0x20, 0x5, HDA_INPUT),
3726 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), 3741 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3727 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3728 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3729 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT), 3742 HDA_CODEC_VOLUME("Mic Capture Volume", 0x14, 0x0, HDA_INPUT),
3730 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT), 3743 HDA_CODEC_VOLUME("Internal Mic Capture Volume", 0x15, 0x0, HDA_INPUT),
3731 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3744 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3836,8 +3849,6 @@ static struct snd_kcontrol_new ad1984a_thinkpad_mixers[] = {
3836 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT), 3849 HDA_CODEC_MUTE("PCM Playback Switch", 0x20, 0x5, HDA_INPUT),
3837 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT), 3850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x00, HDA_INPUT),
3838 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), 3851 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3839 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3840 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3841 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3852 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
3842 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT), 3853 HDA_CODEC_VOLUME("Internal Mic Boost", 0x17, 0x0, HDA_INPUT),
3843 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), 3854 HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -3911,9 +3922,9 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3911 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), 3922 SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE),
3912 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), 3923 SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP),
3913 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), 3924 SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE),
3914 SND_PCI_QUIRK(0x103c, 0x30e6, "HP 6730b", AD1884A_LAPTOP), 3925 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x3070, "HP", AD1884A_MOBILE),
3915 SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP), 3926 SND_PCI_QUIRK_MASK(0x103c, 0xfff0, 0x30e0, "HP laptop", AD1884A_LAPTOP),
3916 SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP), 3927 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3600, "HP laptop", AD1884A_LAPTOP),
3917 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), 3928 SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD),
3918 {} 3929 {}
3919}; 3930};
@@ -3921,7 +3932,7 @@ static struct snd_pci_quirk ad1884a_cfg_tbl[] = {
3921static int patch_ad1884a(struct hda_codec *codec) 3932static int patch_ad1884a(struct hda_codec *codec)
3922{ 3933{
3923 struct ad198x_spec *spec; 3934 struct ad198x_spec *spec;
3924 int board_config; 3935 int err, board_config;
3925 3936
3926 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3937 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3927 if (spec == NULL) 3938 if (spec == NULL)
@@ -3929,6 +3940,13 @@ static int patch_ad1884a(struct hda_codec *codec)
3929 3940
3930 codec->spec = spec; 3941 codec->spec = spec;
3931 3942
3943 err = snd_hda_attach_beep_device(codec, 0x10);
3944 if (err < 0) {
3945 ad198x_free(codec);
3946 return err;
3947 }
3948 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
3949
3932 spec->multiout.max_channels = 2; 3950 spec->multiout.max_channels = 2;
3933 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids); 3951 spec->multiout.num_dacs = ARRAY_SIZE(ad1884a_dac_nids);
3934 spec->multiout.dac_nids = ad1884a_dac_nids; 3952 spec->multiout.dac_nids = ad1884a_dac_nids;
@@ -3966,6 +3984,14 @@ static int patch_ad1884a(struct hda_codec *codec)
3966 spec->multiout.dig_out_nid = 0; 3984 spec->multiout.dig_out_nid = 0;
3967 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event; 3985 codec->patch_ops.unsol_event = ad1884a_hp_unsol_event;
3968 codec->patch_ops.init = ad1884a_hp_init; 3986 codec->patch_ops.init = ad1884a_hp_init;
3987 /* set the upper-limit for mixer amp to 0dB for avoiding the
3988 * possible damage by overloading
3989 */
3990 snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
3991 (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
3992 (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3993 (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3994 (1 << AC_AMPCAP_MUTE_SHIFT));
3969 break; 3995 break;
3970 case AD1884A_THINKPAD: 3996 case AD1884A_THINKPAD:
3971 spec->mixers[0] = ad1984a_thinkpad_mixers; 3997 spec->mixers[0] = ad1984a_thinkpad_mixers;
@@ -4083,8 +4109,6 @@ static struct snd_kcontrol_new ad1882_loopback_mixers[] = {
4083 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT), 4109 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x04, HDA_INPUT),
4084 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), 4110 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4085 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), 4111 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4086 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
4087 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
4088 { } /* end */ 4112 { } /* end */
4089}; 4113};
4090 4114
@@ -4097,8 +4121,6 @@ static struct snd_kcontrol_new ad1882a_loopback_mixers[] = {
4097 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT), 4121 HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x01, HDA_INPUT),
4098 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT), 4122 HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x06, HDA_INPUT),
4099 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT), 4123 HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x06, HDA_INPUT),
4100 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x07, HDA_INPUT),
4101 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x07, HDA_INPUT),
4102 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT), 4124 HDA_CODEC_VOLUME("Digital Mic Boost", 0x1f, 0x0, HDA_INPUT),
4103 { } /* end */ 4125 { } /* end */
4104}; 4126};
@@ -4257,7 +4279,7 @@ static const char *ad1882_models[AD1986A_MODELS] = {
4257static int patch_ad1882(struct hda_codec *codec) 4279static int patch_ad1882(struct hda_codec *codec)
4258{ 4280{
4259 struct ad198x_spec *spec; 4281 struct ad198x_spec *spec;
4260 int board_config; 4282 int err, board_config;
4261 4283
4262 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4284 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4263 if (spec == NULL) 4285 if (spec == NULL)
@@ -4265,6 +4287,13 @@ static int patch_ad1882(struct hda_codec *codec)
4265 4287
4266 codec->spec = spec; 4288 codec->spec = spec;
4267 4289
4290 err = snd_hda_attach_beep_device(codec, 0x10);
4291 if (err < 0) {
4292 ad198x_free(codec);
4293 return err;
4294 }
4295 set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
4296
4268 spec->multiout.max_channels = 6; 4297 spec->multiout.max_channels = 6;
4269 spec->multiout.num_dacs = 3; 4298 spec->multiout.num_dacs = 3;
4270 spec->multiout.dac_nids = ad1882_dac_nids; 4299 spec->multiout.dac_nids = ad1882_dac_nids;
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c
index f3ebe837f2d5..c921264bbd71 100644
--- a/sound/pci/hda/patch_cmedia.c
+++ b/sound/pci/hda/patch_cmedia.c
@@ -680,13 +680,13 @@ static int patch_cmi9880(struct hda_codec *codec)
680 struct auto_pin_cfg cfg; 680 struct auto_pin_cfg cfg;
681 681
682 /* collect pin default configuration */ 682 /* collect pin default configuration */
683 port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 683 port_e = snd_hda_codec_get_pincfg(codec, 0x0f);
684 port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 684 port_f = snd_hda_codec_get_pincfg(codec, 0x10);
685 spec->front_panel = 1; 685 spec->front_panel = 1;
686 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || 686 if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE ||
687 get_defcfg_connect(port_f) == 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); 688 port_g = snd_hda_codec_get_pincfg(codec, 0x1f);
689 port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 689 port_h = snd_hda_codec_get_pincfg(codec, 0x20);
690 spec->channel_modes = cmi9880_channel_modes; 690 spec->channel_modes = cmi9880_channel_modes;
691 /* no front panel */ 691 /* no front panel */
692 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || 692 if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE ||
@@ -703,8 +703,8 @@ static int patch_cmi9880(struct hda_codec *codec)
703 spec->multiout.max_channels = cmi9880_channel_modes[0].channels; 703 spec->multiout.max_channels = cmi9880_channel_modes[0].channels;
704 } else { 704 } else {
705 spec->input_mux = &cmi9880_basic_mux; 705 spec->input_mux = &cmi9880_basic_mux;
706 port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 706 port_spdifi = snd_hda_codec_get_pincfg(codec, 0x13);
707 port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); 707 port_spdifo = snd_hda_codec_get_pincfg(codec, 0x12);
708 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) 708 if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE)
709 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; 709 spec->multiout.dig_out_nid = CMI_DIG_OUT_NID;
710 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) 710 if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE)
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 0177ef8f4c9e..1f2ad76ca94b 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -58,6 +58,7 @@ struct conexant_spec {
58 58
59 struct snd_kcontrol_new *mixers[5]; 59 struct snd_kcontrol_new *mixers[5];
60 int num_mixers; 60 int num_mixers;
61 hda_nid_t vmaster_nid;
61 62
62 const struct hda_verb *init_verbs[5]; /* initialization verbs 63 const struct hda_verb *init_verbs[5]; /* initialization verbs
63 * don't forget NULL 64 * don't forget NULL
@@ -72,6 +73,7 @@ struct conexant_spec {
72 */ 73 */
73 unsigned int cur_eapd; 74 unsigned int cur_eapd;
74 unsigned int hp_present; 75 unsigned int hp_present;
76 unsigned int no_auto_mic;
75 unsigned int need_dac_fix; 77 unsigned int need_dac_fix;
76 78
77 /* capture */ 79 /* capture */
@@ -461,6 +463,29 @@ static void conexant_free(struct hda_codec *codec)
461 kfree(codec->spec); 463 kfree(codec->spec);
462} 464}
463 465
466static struct snd_kcontrol_new cxt_capture_mixers[] = {
467 {
468 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
469 .name = "Capture Source",
470 .info = conexant_mux_enum_info,
471 .get = conexant_mux_enum_get,
472 .put = conexant_mux_enum_put
473 },
474 {}
475};
476
477static const char *slave_vols[] = {
478 "Headphone Playback Volume",
479 "Speaker Playback Volume",
480 NULL
481};
482
483static const char *slave_sws[] = {
484 "Headphone Playback Switch",
485 "Speaker Playback Switch",
486 NULL
487};
488
464static int conexant_build_controls(struct hda_codec *codec) 489static int conexant_build_controls(struct hda_codec *codec)
465{ 490{
466 struct conexant_spec *spec = codec->spec; 491 struct conexant_spec *spec = codec->spec;
@@ -488,6 +513,32 @@ static int conexant_build_controls(struct hda_codec *codec)
488 if (err < 0) 513 if (err < 0)
489 return err; 514 return err;
490 } 515 }
516
517 /* if we have no master control, let's create it */
518 if (spec->vmaster_nid &&
519 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
520 unsigned int vmaster_tlv[4];
521 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
522 HDA_OUTPUT, vmaster_tlv);
523 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
524 vmaster_tlv, slave_vols);
525 if (err < 0)
526 return err;
527 }
528 if (spec->vmaster_nid &&
529 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
530 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
531 NULL, slave_sws);
532 if (err < 0)
533 return err;
534 }
535
536 if (spec->input_mux) {
537 err = snd_hda_add_new_ctls(codec, cxt_capture_mixers);
538 if (err < 0)
539 return err;
540 }
541
491 return 0; 542 return 0;
492} 543}
493 544
@@ -719,13 +770,6 @@ static void cxt5045_hp_unsol_event(struct hda_codec *codec,
719} 770}
720 771
721static struct snd_kcontrol_new cxt5045_mixers[] = { 772static struct snd_kcontrol_new cxt5045_mixers[] = {
722 {
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
724 .name = "Capture Source",
725 .info = conexant_mux_enum_info,
726 .get = conexant_mux_enum_get,
727 .put = conexant_mux_enum_put
728 },
729 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), 773 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
730 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT), 774 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x01, HDA_INPUT),
731 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), 775 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
@@ -759,13 +803,6 @@ static struct snd_kcontrol_new cxt5045_benq_mixers[] = {
759}; 803};
760 804
761static struct snd_kcontrol_new cxt5045_mixers_hp530[] = { 805static struct snd_kcontrol_new cxt5045_mixers_hp530[] = {
762 {
763 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
764 .name = "Capture Source",
765 .info = conexant_mux_enum_info,
766 .get = conexant_mux_enum_get,
767 .put = conexant_mux_enum_put
768 },
769 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT), 806 HDA_CODEC_VOLUME("Int Mic Capture Volume", 0x1a, 0x02, HDA_INPUT),
770 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT), 807 HDA_CODEC_MUTE("Int Mic Capture Switch", 0x1a, 0x02, HDA_INPUT),
771 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT), 808 HDA_CODEC_VOLUME("Ext Mic Capture Volume", 0x1a, 0x01, HDA_INPUT),
@@ -1002,15 +1039,9 @@ static const char *cxt5045_models[CXT5045_MODELS] = {
1002}; 1039};
1003 1040
1004static struct snd_pci_quirk cxt5045_cfg_tbl[] = { 1041static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1005 SND_PCI_QUIRK(0x103c, 0x30a5, "HP", CXT5045_LAPTOP_HPSENSE),
1006 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
1007 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2120", CXT5045_LAPTOP_HPSENSE),
1008 SND_PCI_QUIRK(0x103c, 0x30b7, "HP DV6000Z", CXT5045_LAPTOP_HPSENSE),
1009 SND_PCI_QUIRK(0x103c, 0x30bb, "HP DV8000", CXT5045_LAPTOP_HPSENSE),
1010 SND_PCI_QUIRK(0x103c, 0x30cd, "HP DV Series", CXT5045_LAPTOP_HPSENSE),
1011 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV9533EG", CXT5045_LAPTOP_HPSENSE),
1012 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530), 1042 SND_PCI_QUIRK(0x103c, 0x30d5, "HP 530", CXT5045_LAPTOP_HP530),
1013 SND_PCI_QUIRK(0x103c, 0x30d9, "HP Spartan", CXT5045_LAPTOP_HPSENSE), 1043 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1044 CXT5045_LAPTOP_HPSENSE),
1014 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE), 1045 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P105", CXT5045_LAPTOP_MICSENSE),
1015 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ), 1046 SND_PCI_QUIRK(0x152d, 0x0753, "Benq R55E", CXT5045_BENQ),
1016 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE), 1047 SND_PCI_QUIRK(0x1734, 0x10ad, "Fujitsu Si1520", CXT5045_LAPTOP_MICSENSE),
@@ -1020,8 +1051,8 @@ static struct snd_pci_quirk cxt5045_cfg_tbl[] = {
1020 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1051 SND_PCI_QUIRK(0x1509, 0x1e40, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1021 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1052 SND_PCI_QUIRK(0x1509, 0x2f05, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1022 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE), 1053 SND_PCI_QUIRK(0x1509, 0x2f06, "FIC", CXT5045_LAPTOP_HPMICSENSE),
1023 SND_PCI_QUIRK(0x1631, 0xc106, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE), 1054 SND_PCI_QUIRK_MASK(0x1631, 0xff00, 0xc100, "Packard Bell",
1024 SND_PCI_QUIRK(0x1631, 0xc107, "Packard Bell", CXT5045_LAPTOP_HPMICSENSE), 1055 CXT5045_LAPTOP_HPMICSENSE),
1025 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE), 1056 SND_PCI_QUIRK(0x8086, 0x2111, "Conexant Reference board", CXT5045_LAPTOP_HPSENSE),
1026 {} 1057 {}
1027}; 1058};
@@ -1035,6 +1066,7 @@ static int patch_cxt5045(struct hda_codec *codec)
1035 if (!spec) 1066 if (!spec)
1036 return -ENOMEM; 1067 return -ENOMEM;
1037 codec->spec = spec; 1068 codec->spec = spec;
1069 codec->pin_amp_workaround = 1;
1038 1070
1039 spec->multiout.max_channels = 2; 1071 spec->multiout.max_channels = 2;
1040 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids); 1072 spec->multiout.num_dacs = ARRAY_SIZE(cxt5045_dac_nids);
@@ -1134,7 +1166,7 @@ static int patch_cxt5045(struct hda_codec *codec)
1134/* Conexant 5047 specific */ 1166/* Conexant 5047 specific */
1135#define CXT5047_SPDIF_OUT 0x11 1167#define CXT5047_SPDIF_OUT 0x11
1136 1168
1137static hda_nid_t cxt5047_dac_nids[2] = { 0x10, 0x1c }; 1169static hda_nid_t cxt5047_dac_nids[1] = { 0x10 }; /* 0x1c */
1138static hda_nid_t cxt5047_adc_nids[1] = { 0x12 }; 1170static hda_nid_t cxt5047_adc_nids[1] = { 0x12 };
1139static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a }; 1171static hda_nid_t cxt5047_capsrc_nids[1] = { 0x1a };
1140 1172
@@ -1142,20 +1174,6 @@ static struct hda_channel_mode cxt5047_modes[1] = {
1142 { 2, NULL }, 1174 { 2, NULL },
1143}; 1175};
1144 1176
1145static struct hda_input_mux cxt5047_capture_source = {
1146 .num_items = 1,
1147 .items = {
1148 { "Mic", 0x2 },
1149 }
1150};
1151
1152static struct hda_input_mux cxt5047_hp_capture_source = {
1153 .num_items = 1,
1154 .items = {
1155 { "ExtMic", 0x2 },
1156 }
1157};
1158
1159static struct hda_input_mux cxt5047_toshiba_capture_source = { 1177static struct hda_input_mux cxt5047_toshiba_capture_source = {
1160 .num_items = 2, 1178 .num_items = 2,
1161 .items = { 1179 .items = {
@@ -1179,7 +1197,11 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1179 * the headphone jack 1197 * the headphone jack
1180 */ 1198 */
1181 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE; 1199 bits = (!spec->hp_present && spec->cur_eapd) ? 0 : HDA_AMP_MUTE;
1182 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0, 1200 /* NOTE: Conexat codec needs the index for *OUTPUT* amp of
1201 * pin widgets unlike other codecs. In this case, we need to
1202 * set index 0x01 for the volume from the mixer amp 0x19.
1203 */
1204 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1183 HDA_AMP_MUTE, bits); 1205 HDA_AMP_MUTE, bits);
1184 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE; 1206 bits = spec->cur_eapd ? 0 : HDA_AMP_MUTE;
1185 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0, 1207 snd_hda_codec_amp_stereo(codec, 0x13, HDA_OUTPUT, 0,
@@ -1187,16 +1209,6 @@ static int cxt5047_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1187 return 1; 1209 return 1;
1188} 1210}
1189 1211
1190/* bind volumes of both NID 0x13 (Headphones) and 0x1d (Speakers) */
1191static struct hda_bind_ctls cxt5047_bind_master_vol = {
1192 .ops = &snd_hda_bind_vol,
1193 .values = {
1194 HDA_COMPOSE_AMP_VAL(0x13, 3, 0, HDA_OUTPUT),
1195 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
1196 0
1197 },
1198};
1199
1200/* mute internal speaker if HP is plugged */ 1212/* mute internal speaker if HP is plugged */
1201static void cxt5047_hp_automute(struct hda_codec *codec) 1213static void cxt5047_hp_automute(struct hda_codec *codec)
1202{ 1214{
@@ -1207,27 +1219,8 @@ static void cxt5047_hp_automute(struct hda_codec *codec)
1207 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000; 1219 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1208 1220
1209 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0; 1221 bits = (spec->hp_present || !spec->cur_eapd) ? HDA_AMP_MUTE : 0;
1210 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0, 1222 /* See the note in cxt5047_hp_master_sw_put */
1211 HDA_AMP_MUTE, bits); 1223 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0x01,
1212 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1213 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1214 HDA_AMP_MUTE, bits);
1215}
1216
1217/* mute internal speaker if HP is plugged */
1218static void cxt5047_hp2_automute(struct hda_codec *codec)
1219{
1220 struct conexant_spec *spec = codec->spec;
1221 unsigned int bits;
1222
1223 spec->hp_present = snd_hda_codec_read(codec, 0x13, 0,
1224 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1225
1226 bits = spec->hp_present ? HDA_AMP_MUTE : 0;
1227 snd_hda_codec_amp_stereo(codec, 0x1d, HDA_OUTPUT, 0,
1228 HDA_AMP_MUTE, bits);
1229 /* Mute/Unmute PCM 2 for good measure - some systems need this */
1230 snd_hda_codec_amp_stereo(codec, 0x1c, HDA_OUTPUT, 0,
1231 HDA_AMP_MUTE, bits); 1224 HDA_AMP_MUTE, bits);
1232} 1225}
1233 1226
@@ -1268,55 +1261,14 @@ static void cxt5047_hp_unsol_event(struct hda_codec *codec,
1268 } 1261 }
1269} 1262}
1270 1263
1271/* unsolicited event for HP jack sensing - non-EAPD systems */ 1264static struct snd_kcontrol_new cxt5047_base_mixers[] = {
1272static void cxt5047_hp2_unsol_event(struct hda_codec *codec, 1265 HDA_CODEC_VOLUME("Mic Playback Volume", 0x19, 0x02, HDA_INPUT),
1273 unsigned int res) 1266 HDA_CODEC_MUTE("Mic Playback Switch", 0x19, 0x02, HDA_INPUT),
1274{ 1267 HDA_CODEC_VOLUME("Mic Boost", 0x1a, 0x0, HDA_OUTPUT),
1275 res >>= 26;
1276 switch (res) {
1277 case CONEXANT_HP_EVENT:
1278 cxt5047_hp2_automute(codec);
1279 break;
1280 case CONEXANT_MIC_EVENT:
1281 cxt5047_hp_automic(codec);
1282 break;
1283 }
1284}
1285
1286static struct snd_kcontrol_new cxt5047_mixers[] = {
1287 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1288 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1289 HDA_CODEC_VOLUME("Mic Gain Volume", 0x1a, 0x0, HDA_OUTPUT),
1290 HDA_CODEC_MUTE("Mic Gain Switch", 0x1a, 0x0, HDA_OUTPUT),
1291 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT), 1268 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1292 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT), 1269 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1293 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT), 1270 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1294 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT), 1271 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1295 HDA_CODEC_VOLUME("PCM-2 Volume", 0x1c, 0x00, HDA_OUTPUT),
1296 HDA_CODEC_MUTE("PCM-2 Switch", 0x1c, 0x00, HDA_OUTPUT),
1297 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x00, HDA_OUTPUT),
1298 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1d, 0x00, HDA_OUTPUT),
1299 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1300 HDA_CODEC_MUTE("Headphone Playback Switch", 0x13, 0x00, HDA_OUTPUT),
1301
1302 {}
1303};
1304
1305static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1306 {
1307 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1308 .name = "Capture Source",
1309 .info = conexant_mux_enum_info,
1310 .get = conexant_mux_enum_get,
1311 .put = conexant_mux_enum_put
1312 },
1313 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1314 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19, 0x02, HDA_INPUT),
1315 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1316 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1317 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1318 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1319 HDA_BIND_VOL("Master Playback Volume", &cxt5047_bind_master_vol),
1320 { 1272 {
1321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1273 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1322 .name = "Master Playback Switch", 1274 .name = "Master Playback Switch",
@@ -1329,29 +1281,15 @@ static struct snd_kcontrol_new cxt5047_toshiba_mixers[] = {
1329 {} 1281 {}
1330}; 1282};
1331 1283
1332static struct snd_kcontrol_new cxt5047_hp_mixers[] = { 1284static struct snd_kcontrol_new cxt5047_hp_spk_mixers[] = {
1333 { 1285 /* See the note in cxt5047_hp_master_sw_put */
1334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1286 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x1d, 0x01, HDA_OUTPUT),
1335 .name = "Capture Source", 1287 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1336 .info = conexant_mux_enum_info, 1288 {}
1337 .get = conexant_mux_enum_get, 1289};
1338 .put = conexant_mux_enum_put 1290
1339 }, 1291static struct snd_kcontrol_new cxt5047_hp_only_mixers[] = {
1340 HDA_CODEC_VOLUME("Mic Bypass Capture Volume", 0x19, 0x02, HDA_INPUT),
1341 HDA_CODEC_MUTE("Mic Bypass Capture Switch", 0x19,0x02,HDA_INPUT),
1342 HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x03, HDA_INPUT),
1343 HDA_CODEC_MUTE("Capture Switch", 0x12, 0x03, HDA_INPUT),
1344 HDA_CODEC_VOLUME("PCM Volume", 0x10, 0x00, HDA_OUTPUT),
1345 HDA_CODEC_MUTE("PCM Switch", 0x10, 0x00, HDA_OUTPUT),
1346 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT), 1292 HDA_CODEC_VOLUME("Master Playback Volume", 0x13, 0x00, HDA_OUTPUT),
1347 {
1348 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1349 .name = "Master Playback Switch",
1350 .info = cxt_eapd_info,
1351 .get = cxt_eapd_get,
1352 .put = cxt5047_hp_master_sw_put,
1353 .private_value = 0x13,
1354 },
1355 { } /* end */ 1293 { } /* end */
1356}; 1294};
1357 1295
@@ -1362,8 +1300,8 @@ static struct hda_verb cxt5047_init_verbs[] = {
1362 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 }, 1300 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN|AC_PINCTL_VREF_50 },
1363 /* HP, Speaker */ 1301 /* HP, Speaker */
1364 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, 1302 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
1365 {0x13, AC_VERB_SET_CONNECT_SEL,0x1}, 1303 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mixer(0x19) */
1366 {0x1d, AC_VERB_SET_CONNECT_SEL,0x0}, 1304 {0x1d, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mixer(0x19) */
1367 /* Record selector: Mic */ 1305 /* Record selector: Mic */
1368 {0x12, AC_VERB_SET_CONNECT_SEL,0x03}, 1306 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1369 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 1307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
@@ -1383,30 +1321,7 @@ static struct hda_verb cxt5047_init_verbs[] = {
1383 1321
1384/* configuration for Toshiba Laptops */ 1322/* configuration for Toshiba Laptops */
1385static struct hda_verb cxt5047_toshiba_init_verbs[] = { 1323static struct hda_verb cxt5047_toshiba_init_verbs[] = {
1386 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0 }, /* default on */ 1324 {0x13, AC_VERB_SET_EAPD_BTLENABLE, 0x0}, /* default off */
1387 /* pin sensing on HP and Mic jacks */
1388 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1389 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_MIC_EVENT},
1390 /* Speaker routing */
1391 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1392 {}
1393};
1394
1395/* configuration for HP Laptops */
1396static struct hda_verb cxt5047_hp_init_verbs[] = {
1397 /* pin sensing on HP jack */
1398 {0x13, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | CONEXANT_HP_EVENT},
1399 /* 0x13 is actually shared by both HP and speaker;
1400 * setting the connection to 0 (=0x19) makes the master volume control
1401 * working mysteriouslly...
1402 */
1403 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1404 /* Record selector: Ext Mic */
1405 {0x12, AC_VERB_SET_CONNECT_SEL,0x03},
1406 {0x19, AC_VERB_SET_AMP_GAIN_MUTE,
1407 AC_AMP_SET_INPUT|AC_AMP_SET_RIGHT|AC_AMP_SET_LEFT|0x17},
1408 /* Speaker routing */
1409 {0x1d, AC_VERB_SET_CONNECT_SEL,0x1},
1410 {} 1325 {}
1411}; 1326};
1412 1327
@@ -1571,11 +1486,9 @@ static const char *cxt5047_models[CXT5047_MODELS] = {
1571}; 1486};
1572 1487
1573static struct snd_pci_quirk cxt5047_cfg_tbl[] = { 1488static struct snd_pci_quirk cxt5047_cfg_tbl[] = {
1574 SND_PCI_QUIRK(0x103c, 0x30a0, "HP DV1000", CXT5047_LAPTOP),
1575 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP), 1489 SND_PCI_QUIRK(0x103c, 0x30a5, "HP DV5200T/DV8000T", CXT5047_LAPTOP_HP),
1576 SND_PCI_QUIRK(0x103c, 0x30b2, "HP DV2000T/DV3000T", CXT5047_LAPTOP), 1490 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP DV Series",
1577 SND_PCI_QUIRK(0x103c, 0x30b5, "HP DV2000Z", CXT5047_LAPTOP), 1491 CXT5047_LAPTOP),
1578 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6700", CXT5047_LAPTOP),
1579 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD), 1492 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba P100", CXT5047_LAPTOP_EAPD),
1580 {} 1493 {}
1581}; 1494};
@@ -1589,6 +1502,7 @@ static int patch_cxt5047(struct hda_codec *codec)
1589 if (!spec) 1502 if (!spec)
1590 return -ENOMEM; 1503 return -ENOMEM;
1591 codec->spec = spec; 1504 codec->spec = spec;
1505 codec->pin_amp_workaround = 1;
1592 1506
1593 spec->multiout.max_channels = 2; 1507 spec->multiout.max_channels = 2;
1594 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids); 1508 spec->multiout.num_dacs = ARRAY_SIZE(cxt5047_dac_nids);
@@ -1597,9 +1511,8 @@ static int patch_cxt5047(struct hda_codec *codec)
1597 spec->num_adc_nids = 1; 1511 spec->num_adc_nids = 1;
1598 spec->adc_nids = cxt5047_adc_nids; 1512 spec->adc_nids = cxt5047_adc_nids;
1599 spec->capsrc_nids = cxt5047_capsrc_nids; 1513 spec->capsrc_nids = cxt5047_capsrc_nids;
1600 spec->input_mux = &cxt5047_capture_source;
1601 spec->num_mixers = 1; 1514 spec->num_mixers = 1;
1602 spec->mixers[0] = cxt5047_mixers; 1515 spec->mixers[0] = cxt5047_base_mixers;
1603 spec->num_init_verbs = 1; 1516 spec->num_init_verbs = 1;
1604 spec->init_verbs[0] = cxt5047_init_verbs; 1517 spec->init_verbs[0] = cxt5047_init_verbs;
1605 spec->spdif_route = 0; 1518 spec->spdif_route = 0;
@@ -1613,21 +1526,22 @@ static int patch_cxt5047(struct hda_codec *codec)
1613 cxt5047_cfg_tbl); 1526 cxt5047_cfg_tbl);
1614 switch (board_config) { 1527 switch (board_config) {
1615 case CXT5047_LAPTOP: 1528 case CXT5047_LAPTOP:
1616 codec->patch_ops.unsol_event = cxt5047_hp2_unsol_event; 1529 spec->num_mixers = 2;
1530 spec->mixers[1] = cxt5047_hp_spk_mixers;
1531 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1617 break; 1532 break;
1618 case CXT5047_LAPTOP_HP: 1533 case CXT5047_LAPTOP_HP:
1619 spec->input_mux = &cxt5047_hp_capture_source; 1534 spec->num_mixers = 2;
1620 spec->num_init_verbs = 2; 1535 spec->mixers[1] = cxt5047_hp_only_mixers;
1621 spec->init_verbs[1] = cxt5047_hp_init_verbs;
1622 spec->mixers[0] = cxt5047_hp_mixers;
1623 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1536 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1624 codec->patch_ops.init = cxt5047_hp_init; 1537 codec->patch_ops.init = cxt5047_hp_init;
1625 break; 1538 break;
1626 case CXT5047_LAPTOP_EAPD: 1539 case CXT5047_LAPTOP_EAPD:
1627 spec->input_mux = &cxt5047_toshiba_capture_source; 1540 spec->input_mux = &cxt5047_toshiba_capture_source;
1541 spec->num_mixers = 2;
1542 spec->mixers[1] = cxt5047_hp_spk_mixers;
1628 spec->num_init_verbs = 2; 1543 spec->num_init_verbs = 2;
1629 spec->init_verbs[1] = cxt5047_toshiba_init_verbs; 1544 spec->init_verbs[1] = cxt5047_toshiba_init_verbs;
1630 spec->mixers[0] = cxt5047_toshiba_mixers;
1631 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1545 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1632 break; 1546 break;
1633#ifdef CONFIG_SND_DEBUG 1547#ifdef CONFIG_SND_DEBUG
@@ -1638,6 +1552,7 @@ static int patch_cxt5047(struct hda_codec *codec)
1638 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event; 1552 codec->patch_ops.unsol_event = cxt5047_hp_unsol_event;
1639#endif 1553#endif
1640 } 1554 }
1555 spec->vmaster_nid = 0x13;
1641 return 0; 1556 return 0;
1642} 1557}
1643 1558
@@ -1673,8 +1588,11 @@ static int cxt5051_hp_master_sw_put(struct snd_kcontrol *kcontrol,
1673/* toggle input of built-in and mic jack appropriately */ 1588/* toggle input of built-in and mic jack appropriately */
1674static void cxt5051_portb_automic(struct hda_codec *codec) 1589static void cxt5051_portb_automic(struct hda_codec *codec)
1675{ 1590{
1591 struct conexant_spec *spec = codec->spec;
1676 unsigned int present; 1592 unsigned int present;
1677 1593
1594 if (spec->no_auto_mic)
1595 return;
1678 present = snd_hda_codec_read(codec, 0x17, 0, 1596 present = snd_hda_codec_read(codec, 0x17, 0,
1679 AC_VERB_GET_PIN_SENSE, 0) & 1597 AC_VERB_GET_PIN_SENSE, 0) &
1680 AC_PINSENSE_PRESENCE; 1598 AC_PINSENSE_PRESENCE;
@@ -1690,6 +1608,8 @@ static void cxt5051_portc_automic(struct hda_codec *codec)
1690 unsigned int present; 1608 unsigned int present;
1691 hda_nid_t new_adc; 1609 hda_nid_t new_adc;
1692 1610
1611 if (spec->no_auto_mic)
1612 return;
1693 present = snd_hda_codec_read(codec, 0x18, 0, 1613 present = snd_hda_codec_read(codec, 0x18, 0,
1694 AC_VERB_GET_PIN_SENSE, 0) & 1614 AC_VERB_GET_PIN_SENSE, 0) &
1695 AC_PINSENSE_PRESENCE; 1615 AC_PINSENSE_PRESENCE;
@@ -1776,6 +1696,22 @@ static struct snd_kcontrol_new cxt5051_hp_mixers[] = {
1776 {} 1696 {}
1777}; 1697};
1778 1698
1699static struct snd_kcontrol_new cxt5051_hp_dv6736_mixers[] = {
1700 HDA_CODEC_VOLUME("Mic Volume", 0x14, 0x00, HDA_INPUT),
1701 HDA_CODEC_MUTE("Mic Switch", 0x14, 0x00, HDA_INPUT),
1702 HDA_CODEC_VOLUME("Master Playback Volume", 0x10, 0x00, HDA_OUTPUT),
1703 {
1704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1705 .name = "Master Playback Switch",
1706 .info = cxt_eapd_info,
1707 .get = cxt_eapd_get,
1708 .put = cxt5051_hp_master_sw_put,
1709 .private_value = 0x1a,
1710 },
1711
1712 {}
1713};
1714
1779static struct hda_verb cxt5051_init_verbs[] = { 1715static struct hda_verb cxt5051_init_verbs[] = {
1780 /* Line in, Mic */ 1716 /* Line in, Mic */
1781 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03}, 1717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
@@ -1806,6 +1742,66 @@ static struct hda_verb cxt5051_init_verbs[] = {
1806 { } /* end */ 1742 { } /* end */
1807}; 1743};
1808 1744
1745static struct hda_verb cxt5051_hp_dv6736_init_verbs[] = {
1746 /* Line in, Mic */
1747 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1748 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1749 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1750 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0},
1751 /* SPK */
1752 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1753 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1754 /* HP, Amp */
1755 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1756 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1757 /* DAC1 */
1758 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1759 /* Record selector: Int mic */
1760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1761 {0x14, AC_VERB_SET_CONNECT_SEL, 0x1},
1762 /* SPDIF route: PCM */
1763 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1764 /* EAPD */
1765 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1766 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1767 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1768 { } /* end */
1769};
1770
1771static struct hda_verb cxt5051_lenovo_x200_init_verbs[] = {
1772 /* Line in, Mic */
1773 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1774 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1777 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1778 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x03},
1779 /* SPK */
1780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1781 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
1782 /* HP, Amp */
1783 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1784 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
1785 /* Docking HP */
1786 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1787 {0x19, AC_VERB_SET_CONNECT_SEL, 0x00},
1788 /* DAC1 */
1789 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1790 /* Record selector: Int mic */
1791 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1792 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1) | 0x44},
1793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x44},
1794 /* SPDIF route: PCM */
1795 {0x1c, AC_VERB_SET_CONNECT_SEL, 0x0},
1796 /* EAPD */
1797 {0x1a, AC_VERB_SET_EAPD_BTLENABLE, 0x2}, /* default on */
1798 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1799 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTB_EVENT},
1800 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CXT5051_PORTC_EVENT},
1801 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|CONEXANT_HP_EVENT},
1802 { } /* end */
1803};
1804
1809/* initialize jack-sensing, too */ 1805/* initialize jack-sensing, too */
1810static int cxt5051_init(struct hda_codec *codec) 1806static int cxt5051_init(struct hda_codec *codec)
1811{ 1807{
@@ -1823,18 +1819,24 @@ static int cxt5051_init(struct hda_codec *codec)
1823enum { 1819enum {
1824 CXT5051_LAPTOP, /* Laptops w/ EAPD support */ 1820 CXT5051_LAPTOP, /* Laptops w/ EAPD support */
1825 CXT5051_HP, /* no docking */ 1821 CXT5051_HP, /* no docking */
1822 CXT5051_HP_DV6736, /* HP without mic switch */
1823 CXT5051_LENOVO_X200, /* Lenovo X200 laptop */
1826 CXT5051_MODELS 1824 CXT5051_MODELS
1827}; 1825};
1828 1826
1829static const char *cxt5051_models[CXT5051_MODELS] = { 1827static const char *cxt5051_models[CXT5051_MODELS] = {
1830 [CXT5051_LAPTOP] = "laptop", 1828 [CXT5051_LAPTOP] = "laptop",
1831 [CXT5051_HP] = "hp", 1829 [CXT5051_HP] = "hp",
1830 [CXT5051_HP_DV6736] = "hp-dv6736",
1831 [CXT5051_LENOVO_X200] = "lenovo-x200",
1832}; 1832};
1833 1833
1834static struct snd_pci_quirk cxt5051_cfg_tbl[] = { 1834static struct snd_pci_quirk cxt5051_cfg_tbl[] = {
1835 SND_PCI_QUIRK(0x103c, 0x30cf, "HP DV6736", CXT5051_HP_DV6736),
1835 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board", 1836 SND_PCI_QUIRK(0x14f1, 0x0101, "Conexant Reference board",
1836 CXT5051_LAPTOP), 1837 CXT5051_LAPTOP),
1837 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP), 1838 SND_PCI_QUIRK(0x14f1, 0x5051, "HP Spartan 1.1", CXT5051_HP),
1839 SND_PCI_QUIRK(0x17aa, 0x20f2, "Lenovo X200", CXT5051_LENOVO_X200),
1838 {} 1840 {}
1839}; 1841};
1840 1842
@@ -1847,6 +1849,7 @@ static int patch_cxt5051(struct hda_codec *codec)
1847 if (!spec) 1849 if (!spec)
1848 return -ENOMEM; 1850 return -ENOMEM;
1849 codec->spec = spec; 1851 codec->spec = spec;
1852 codec->pin_amp_workaround = 1;
1850 1853
1851 codec->patch_ops = conexant_patch_ops; 1854 codec->patch_ops = conexant_patch_ops;
1852 codec->patch_ops.init = cxt5051_init; 1855 codec->patch_ops.init = cxt5051_init;
@@ -1867,17 +1870,22 @@ static int patch_cxt5051(struct hda_codec *codec)
1867 spec->cur_adc = 0; 1870 spec->cur_adc = 0;
1868 spec->cur_adc_idx = 0; 1871 spec->cur_adc_idx = 0;
1869 1872
1873 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1874
1870 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS, 1875 board_config = snd_hda_check_board_config(codec, CXT5051_MODELS,
1871 cxt5051_models, 1876 cxt5051_models,
1872 cxt5051_cfg_tbl); 1877 cxt5051_cfg_tbl);
1873 switch (board_config) { 1878 switch (board_config) {
1874 case CXT5051_HP: 1879 case CXT5051_HP:
1875 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event;
1876 spec->mixers[0] = cxt5051_hp_mixers; 1880 spec->mixers[0] = cxt5051_hp_mixers;
1877 break; 1881 break;
1878 default: 1882 case CXT5051_HP_DV6736:
1879 case CXT5051_LAPTOP: 1883 spec->init_verbs[0] = cxt5051_hp_dv6736_init_verbs;
1880 codec->patch_ops.unsol_event = cxt5051_hp_unsol_event; 1884 spec->mixers[0] = cxt5051_hp_dv6736_mixers;
1885 spec->no_auto_mic = 1;
1886 break;
1887 case CXT5051_LENOVO_X200:
1888 spec->init_verbs[0] = cxt5051_lenovo_x200_init_verbs;
1881 break; 1889 break;
1882 } 1890 }
1883 1891
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 6c26afcb8262..5ad0f8d72ddb 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -30,6 +30,7 @@
30#include <sound/core.h> 30#include <sound/core.h>
31#include "hda_codec.h" 31#include "hda_codec.h"
32#include "hda_local.h" 32#include "hda_local.h"
33#include "hda_beep.h"
33 34
34#define ALC880_FRONT_EVENT 0x01 35#define ALC880_FRONT_EVENT 0x01
35#define ALC880_DCVOL_EVENT 0x02 36#define ALC880_DCVOL_EVENT 0x02
@@ -77,6 +78,7 @@ enum {
77 ALC260_ACER, 78 ALC260_ACER,
78 ALC260_WILL, 79 ALC260_WILL,
79 ALC260_REPLACER_672V, 80 ALC260_REPLACER_672V,
81 ALC260_FAVORIT100,
80#ifdef CONFIG_SND_DEBUG 82#ifdef CONFIG_SND_DEBUG
81 ALC260_TEST, 83 ALC260_TEST,
82#endif 84#endif
@@ -103,6 +105,7 @@ enum {
103 ALC262_NEC, 105 ALC262_NEC,
104 ALC262_TOSHIBA_S06, 106 ALC262_TOSHIBA_S06,
105 ALC262_TOSHIBA_RX1, 107 ALC262_TOSHIBA_RX1,
108 ALC262_TYAN,
106 ALC262_AUTO, 109 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */ 110 ALC262_MODEL_LAST /* last tag */
108}; 111};
@@ -238,6 +241,13 @@ enum {
238 ALC883_MODEL_LAST, 241 ALC883_MODEL_LAST,
239}; 242};
240 243
244/* styles of capture selection */
245enum {
246 CAPT_MUX = 0, /* only mux based */
247 CAPT_MIX, /* only mixer based */
248 CAPT_1MUX_MIX, /* first mux and other mixers */
249};
250
241/* for GPIO Poll */ 251/* for GPIO Poll */
242#define GPIO_MASK 0x03 252#define GPIO_MASK 0x03
243 253
@@ -246,6 +256,7 @@ struct alc_spec {
246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 256 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
247 unsigned int num_mixers; 257 unsigned int num_mixers;
248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */ 258 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
259 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
249 260
250 const struct hda_verb *init_verbs[5]; /* initialization verbs 261 const struct hda_verb *init_verbs[5]; /* initialization verbs
251 * don't forget NULL 262 * don't forget NULL
@@ -269,13 +280,15 @@ struct alc_spec {
269 * dig_out_nid and hp_nid are optional 280 * dig_out_nid and hp_nid are optional
270 */ 281 */
271 hda_nid_t alt_dac_nid; 282 hda_nid_t alt_dac_nid;
283 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
284 int dig_out_type;
272 285
273 /* capture */ 286 /* capture */
274 unsigned int num_adc_nids; 287 unsigned int num_adc_nids;
275 hda_nid_t *adc_nids; 288 hda_nid_t *adc_nids;
276 hda_nid_t *capsrc_nids; 289 hda_nid_t *capsrc_nids;
277 hda_nid_t dig_in_nid; /* digital-in NID; optional */ 290 hda_nid_t dig_in_nid; /* digital-in NID; optional */
278 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */ 291 int capture_style; /* capture style (CAPT_*) */
279 292
280 /* capture source */ 293 /* capture source */
281 unsigned int num_mux_defs; 294 unsigned int num_mux_defs;
@@ -293,7 +306,7 @@ struct alc_spec {
293 /* dynamic controls, init_verbs and input_mux */ 306 /* dynamic controls, init_verbs and input_mux */
294 struct auto_pin_cfg autocfg; 307 struct auto_pin_cfg autocfg;
295 struct snd_array kctls; 308 struct snd_array kctls;
296 struct hda_input_mux private_imux; 309 struct hda_input_mux private_imux[3];
297 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 310 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
298 311
299 /* hooks */ 312 /* hooks */
@@ -305,6 +318,9 @@ struct alc_spec {
305 unsigned int jack_present: 1; 318 unsigned int jack_present: 1;
306 unsigned int master_sw: 1; 319 unsigned int master_sw: 1;
307 320
321 /* other flags */
322 unsigned int no_analog :1; /* digital I/O only */
323
308 /* for virtual master */ 324 /* for virtual master */
309 hda_nid_t vmaster_nid; 325 hda_nid_t vmaster_nid;
310#ifdef CONFIG_SND_HDA_POWER_SAVE 326#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -314,13 +330,6 @@ struct alc_spec {
314 /* for PLL fix */ 330 /* for PLL fix */
315 hda_nid_t pll_nid; 331 hda_nid_t pll_nid;
316 unsigned int pll_coef_idx, pll_coef_bit; 332 unsigned int pll_coef_idx, pll_coef_bit;
317
318#ifdef SND_HDA_NEEDS_RESUME
319#define ALC_MAX_PINS 16
320 unsigned int num_pins;
321 hda_nid_t pin_nids[ALC_MAX_PINS];
322 unsigned int pin_cfgs[ALC_MAX_PINS];
323#endif
324}; 333};
325 334
326/* 335/*
@@ -336,6 +345,7 @@ struct alc_config_preset {
336 hda_nid_t *dac_nids; 345 hda_nid_t *dac_nids;
337 hda_nid_t dig_out_nid; /* optional */ 346 hda_nid_t dig_out_nid; /* optional */
338 hda_nid_t hp_nid; /* optional */ 347 hda_nid_t hp_nid; /* optional */
348 hda_nid_t *slave_dig_outs;
339 unsigned int num_adc_nids; 349 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids; 350 hda_nid_t *adc_nids;
341 hda_nid_t *capsrc_nids; 351 hda_nid_t *capsrc_nids;
@@ -392,7 +402,8 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
392 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; 402 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
393 imux = &spec->input_mux[mux_idx]; 403 imux = &spec->input_mux[mux_idx];
394 404
395 if (spec->is_mix_capture) { 405 if (spec->capture_style &&
406 !(spec->capture_style == CAPT_1MUX_MIX && !adc_idx)) {
396 /* Matrix-mixer style (e.g. ALC882) */ 407 /* Matrix-mixer style (e.g. ALC882) */
397 unsigned int *cur_val = &spec->cur_mux[adc_idx]; 408 unsigned int *cur_val = &spec->cur_mux[adc_idx];
398 unsigned int i, idx; 409 unsigned int i, idx;
@@ -750,6 +761,24 @@ static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
750#endif /* CONFIG_SND_DEBUG */ 761#endif /* CONFIG_SND_DEBUG */
751 762
752/* 763/*
764 * set up the input pin config (depending on the given auto-pin type)
765 */
766static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
767 int auto_pin_type)
768{
769 unsigned int val = PIN_IN;
770
771 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
772 unsigned int pincap;
773 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
774 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
775 if (pincap & AC_PINCAP_VREF_80)
776 val = PIN_VREF80;
777 }
778 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
779}
780
781/*
753 */ 782 */
754static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix) 783static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
755{ 784{
@@ -810,6 +839,7 @@ static void setup_preset(struct alc_spec *spec,
810 spec->multiout.num_dacs = preset->num_dacs; 839 spec->multiout.num_dacs = preset->num_dacs;
811 spec->multiout.dac_nids = preset->dac_nids; 840 spec->multiout.dac_nids = preset->dac_nids;
812 spec->multiout.dig_out_nid = preset->dig_out_nid; 841 spec->multiout.dig_out_nid = preset->dig_out_nid;
842 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
813 spec->multiout.hp_nid = preset->hp_nid; 843 spec->multiout.hp_nid = preset->hp_nid;
814 844
815 spec->num_mux_defs = preset->num_mux_defs; 845 spec->num_mux_defs = preset->num_mux_defs;
@@ -921,7 +951,7 @@ static void alc_mic_automute(struct hda_codec *codec)
921 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0); 951 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
922} 952}
923#else 953#else
924#define alc_mic_automute(codec) /* NOP */ 954#define alc_mic_automute(codec) do {} while(0) /* NOP */
925#endif /* disabled */ 955#endif /* disabled */
926 956
927/* unsolicited event for HP jack sensing */ 957/* unsolicited event for HP jack sensing */
@@ -952,7 +982,7 @@ static void alc888_coef_init(struct hda_codec *codec)
952 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); 982 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
953 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); 983 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
954 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); 984 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
955 if ((tmp & 0xf0) == 2) 985 if ((tmp & 0xf0) == 0x20)
956 /* alc888S-VC */ 986 /* alc888S-VC */
957 snd_hda_codec_read(codec, 0x20, 0, 987 snd_hda_codec_read(codec, 0x20, 0,
958 AC_VERB_SET_PROC_COEF, 0x830); 988 AC_VERB_SET_PROC_COEF, 0x830);
@@ -991,8 +1021,7 @@ static void alc_subsystem_id(struct hda_codec *codec,
991 nid = 0x1d; 1021 nid = 0x1d;
992 if (codec->vendor_id == 0x10ec0260) 1022 if (codec->vendor_id == 0x10ec0260)
993 nid = 0x17; 1023 nid = 0x17;
994 ass = snd_hda_codec_read(codec, nid, 0, 1024 ass = snd_hda_codec_get_pincfg(codec, nid);
995 AC_VERB_GET_CONFIG_DEFAULT, 0);
996 if (!(ass & 1) && !(ass & 0x100000)) 1025 if (!(ass & 1) && !(ass & 0x100000))
997 return; 1026 return;
998 if ((ass >> 30) != 1) /* no physical connection */ 1027 if ((ass >> 30) != 1) /* no physical connection */
@@ -1166,16 +1195,8 @@ static void alc_fix_pincfg(struct hda_codec *codec,
1166 return; 1195 return;
1167 1196
1168 cfg = pinfix[quirk->value]; 1197 cfg = pinfix[quirk->value];
1169 for (; cfg->nid; cfg++) { 1198 for (; cfg->nid; cfg++)
1170 int i; 1199 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1171 u32 val = cfg->val;
1172 for (i = 0; i < 4; i++) {
1173 snd_hda_codec_write(codec, cfg->nid, 0,
1174 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1175 val & 0xff);
1176 val >>= 8;
1177 }
1178 }
1179} 1200}
1180 1201
1181/* 1202/*
@@ -1375,8 +1396,6 @@ static struct snd_kcontrol_new alc888_base_mixer[] = {
1375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 1396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1376 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 1397 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1377 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1378 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1379 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1380 { } /* end */ 1399 { } /* end */
1381}; 1400};
1382 1401
@@ -1483,8 +1502,6 @@ static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
1483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1484 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT), 1503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1485 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT), 1504 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1486 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1487 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1488 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT), 1505 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
1489 { 1506 {
1490 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1507 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -1706,8 +1723,6 @@ static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
1706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1707 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1724 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1708 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1725 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1709 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1710 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1711 { 1726 {
1712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1727 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1713 .name = "Channel Mode", 1728 .name = "Channel Mode",
@@ -1884,13 +1899,6 @@ static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
1884 { } /* end */ 1899 { } /* end */
1885}; 1900};
1886 1901
1887/* additional mixers to alc880_asus_mixer */
1888static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
1889 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1890 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1891 { } /* end */
1892};
1893
1894/* TCL S700 */ 1902/* TCL S700 */
1895static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { 1903static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1896 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), 1904 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
@@ -1923,8 +1931,6 @@ static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
1923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 1931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1924 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 1932 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1925 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 1933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1926 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1927 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1928 { 1934 {
1929 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1930 .name = "Channel Mode", 1936 .name = "Channel Mode",
@@ -1999,6 +2005,13 @@ static const char *alc_slave_sws[] = {
1999 2005
2000static void alc_free_kctls(struct hda_codec *codec); 2006static void alc_free_kctls(struct hda_codec *codec);
2001 2007
2008/* additional beep mixers; the actual parameters are overwritten at build */
2009static struct snd_kcontrol_new alc_beep_mixer[] = {
2010 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2011 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2012 { } /* end */
2013};
2014
2002static int alc_build_controls(struct hda_codec *codec) 2015static int alc_build_controls(struct hda_codec *codec)
2003{ 2016{
2004 struct alc_spec *spec = codec->spec; 2017 struct alc_spec *spec = codec->spec;
@@ -2020,11 +2033,13 @@ static int alc_build_controls(struct hda_codec *codec)
2020 spec->multiout.dig_out_nid); 2033 spec->multiout.dig_out_nid);
2021 if (err < 0) 2034 if (err < 0)
2022 return err; 2035 return err;
2023 err = snd_hda_create_spdif_share_sw(codec, 2036 if (!spec->no_analog) {
2024 &spec->multiout); 2037 err = snd_hda_create_spdif_share_sw(codec,
2025 if (err < 0) 2038 &spec->multiout);
2026 return err; 2039 if (err < 0)
2027 spec->multiout.share_spdif = 1; 2040 return err;
2041 spec->multiout.share_spdif = 1;
2042 }
2028 } 2043 }
2029 if (spec->dig_in_nid) { 2044 if (spec->dig_in_nid) {
2030 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); 2045 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -2032,8 +2047,24 @@ static int alc_build_controls(struct hda_codec *codec)
2032 return err; 2047 return err;
2033 } 2048 }
2034 2049
2050 /* create beep controls if needed */
2051 if (spec->beep_amp) {
2052 struct snd_kcontrol_new *knew;
2053 for (knew = alc_beep_mixer; knew->name; knew++) {
2054 struct snd_kcontrol *kctl;
2055 kctl = snd_ctl_new1(knew, codec);
2056 if (!kctl)
2057 return -ENOMEM;
2058 kctl->private_value = spec->beep_amp;
2059 err = snd_hda_ctl_add(codec, kctl);
2060 if (err < 0)
2061 return err;
2062 }
2063 }
2064
2035 /* if we have no master control, let's create it */ 2065 /* if we have no master control, let's create it */
2036 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { 2066 if (!spec->no_analog &&
2067 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
2037 unsigned int vmaster_tlv[4]; 2068 unsigned int vmaster_tlv[4];
2038 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, 2069 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
2039 HDA_OUTPUT, vmaster_tlv); 2070 HDA_OUTPUT, vmaster_tlv);
@@ -2042,7 +2073,8 @@ static int alc_build_controls(struct hda_codec *codec)
2042 if (err < 0) 2073 if (err < 0)
2043 return err; 2074 return err;
2044 } 2075 }
2045 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { 2076 if (!spec->no_analog &&
2077 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
2046 err = snd_hda_add_vmaster(codec, "Master Playback Switch", 2078 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2047 NULL, alc_slave_sws); 2079 NULL, alc_slave_sws);
2048 if (err < 0) 2080 if (err < 0)
@@ -2951,6 +2983,14 @@ static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2951 stream_tag, format, substream); 2983 stream_tag, format, substream);
2952} 2984}
2953 2985
2986static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2987 struct hda_codec *codec,
2988 struct snd_pcm_substream *substream)
2989{
2990 struct alc_spec *spec = codec->spec;
2991 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2992}
2993
2954static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, 2994static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2955 struct hda_codec *codec, 2995 struct hda_codec *codec,
2956 struct snd_pcm_substream *substream) 2996 struct snd_pcm_substream *substream)
@@ -3034,7 +3074,8 @@ static struct hda_pcm_stream alc880_pcm_digital_playback = {
3034 .ops = { 3074 .ops = {
3035 .open = alc880_dig_playback_pcm_open, 3075 .open = alc880_dig_playback_pcm_open,
3036 .close = alc880_dig_playback_pcm_close, 3076 .close = alc880_dig_playback_pcm_close,
3037 .prepare = alc880_dig_playback_pcm_prepare 3077 .prepare = alc880_dig_playback_pcm_prepare,
3078 .cleanup = alc880_dig_playback_pcm_cleanup
3038 }, 3079 },
3039}; 3080};
3040 3081
@@ -3061,6 +3102,9 @@ static int alc_build_pcms(struct hda_codec *codec)
3061 codec->num_pcms = 1; 3102 codec->num_pcms = 1;
3062 codec->pcm_info = info; 3103 codec->pcm_info = info;
3063 3104
3105 if (spec->no_analog)
3106 goto skip_analog;
3107
3064 info->name = spec->stream_name_analog; 3108 info->name = spec->stream_name_analog;
3065 if (spec->stream_analog_playback) { 3109 if (spec->stream_analog_playback) {
3066 if (snd_BUG_ON(!spec->multiout.dac_nids)) 3110 if (snd_BUG_ON(!spec->multiout.dac_nids))
@@ -3084,12 +3128,17 @@ static int alc_build_pcms(struct hda_codec *codec)
3084 } 3128 }
3085 } 3129 }
3086 3130
3131 skip_analog:
3087 /* SPDIF for stream index #1 */ 3132 /* SPDIF for stream index #1 */
3088 if (spec->multiout.dig_out_nid || spec->dig_in_nid) { 3133 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
3089 codec->num_pcms = 2; 3134 codec->num_pcms = 2;
3135 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
3090 info = spec->pcm_rec + 1; 3136 info = spec->pcm_rec + 1;
3091 info->name = spec->stream_name_digital; 3137 info->name = spec->stream_name_digital;
3092 info->pcm_type = HDA_PCM_TYPE_SPDIF; 3138 if (spec->dig_out_type)
3139 info->pcm_type = spec->dig_out_type;
3140 else
3141 info->pcm_type = HDA_PCM_TYPE_SPDIF;
3093 if (spec->multiout.dig_out_nid && 3142 if (spec->multiout.dig_out_nid &&
3094 spec->stream_digital_playback) { 3143 spec->stream_digital_playback) {
3095 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); 3144 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
@@ -3104,6 +3153,9 @@ static int alc_build_pcms(struct hda_codec *codec)
3104 codec->spdif_status_reset = 1; 3153 codec->spdif_status_reset = 1;
3105 } 3154 }
3106 3155
3156 if (spec->no_analog)
3157 return 0;
3158
3107 /* If the use of more than one ADC is requested for the current 3159 /* If the use of more than one ADC is requested for the current
3108 * model, configure a second analog capture-only PCM. 3160 * model, configure a second analog capture-only PCM.
3109 */ 3161 */
@@ -3162,65 +3214,17 @@ static void alc_free(struct hda_codec *codec)
3162 3214
3163 alc_free_kctls(codec); 3215 alc_free_kctls(codec);
3164 kfree(spec); 3216 kfree(spec);
3165 codec->spec = NULL; /* to be sure */ 3217 snd_hda_detach_beep_device(codec);
3166} 3218}
3167 3219
3168#ifdef SND_HDA_NEEDS_RESUME 3220#ifdef SND_HDA_NEEDS_RESUME
3169static void store_pin_configs(struct hda_codec *codec)
3170{
3171 struct alc_spec *spec = codec->spec;
3172 hda_nid_t nid, end_nid;
3173
3174 end_nid = codec->start_nid + codec->num_nodes;
3175 for (nid = codec->start_nid; nid < end_nid; nid++) {
3176 unsigned int wid_caps = get_wcaps(codec, nid);
3177 unsigned int wid_type =
3178 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3179 if (wid_type != AC_WID_PIN)
3180 continue;
3181 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3182 break;
3183 spec->pin_nids[spec->num_pins] = nid;
3184 spec->pin_cfgs[spec->num_pins] =
3185 snd_hda_codec_read(codec, nid, 0,
3186 AC_VERB_GET_CONFIG_DEFAULT, 0);
3187 spec->num_pins++;
3188 }
3189}
3190
3191static void resume_pin_configs(struct hda_codec *codec)
3192{
3193 struct alc_spec *spec = codec->spec;
3194 int i;
3195
3196 for (i = 0; i < spec->num_pins; i++) {
3197 hda_nid_t pin_nid = spec->pin_nids[i];
3198 unsigned int pin_config = spec->pin_cfgs[i];
3199 snd_hda_codec_write(codec, pin_nid, 0,
3200 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3201 pin_config & 0x000000ff);
3202 snd_hda_codec_write(codec, pin_nid, 0,
3203 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3204 (pin_config & 0x0000ff00) >> 8);
3205 snd_hda_codec_write(codec, pin_nid, 0,
3206 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3207 (pin_config & 0x00ff0000) >> 16);
3208 snd_hda_codec_write(codec, pin_nid, 0,
3209 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3210 pin_config >> 24);
3211 }
3212}
3213
3214static int alc_resume(struct hda_codec *codec) 3221static int alc_resume(struct hda_codec *codec)
3215{ 3222{
3216 resume_pin_configs(codec);
3217 codec->patch_ops.init(codec); 3223 codec->patch_ops.init(codec);
3218 snd_hda_codec_resume_amp(codec); 3224 snd_hda_codec_resume_amp(codec);
3219 snd_hda_codec_resume_cache(codec); 3225 snd_hda_codec_resume_cache(codec);
3220 return 0; 3226 return 0;
3221} 3227}
3222#else
3223#define store_pin_configs(codec)
3224#endif 3228#endif
3225 3229
3226/* 3230/*
@@ -3559,7 +3563,7 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
3559 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG), 3563 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3560 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST), 3564 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3561 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST), 3565 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
3562 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */ 3566 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
3563 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST), 3567 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
3564 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST), 3568 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3565 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST), 3569 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
@@ -3602,7 +3606,8 @@ static struct snd_pci_quirk alc880_cfg_tbl[] = {
3602 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG), 3606 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3603 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG), 3607 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3604 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG), 3608 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
3605 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */ 3609 /* default Intel */
3610 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
3606 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG), 3611 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3607 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG), 3612 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
3608 {} 3613 {}
@@ -3782,7 +3787,7 @@ static struct alc_config_preset alc880_presets[] = {
3782 .input_mux = &alc880_capture_source, 3787 .input_mux = &alc880_capture_source,
3783 }, 3788 },
3784 [ALC880_UNIWILL_DIG] = { 3789 [ALC880_UNIWILL_DIG] = {
3785 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer }, 3790 .mixers = { alc880_asus_mixer },
3786 .init_verbs = { alc880_volume_init_verbs, 3791 .init_verbs = { alc880_volume_init_verbs,
3787 alc880_pin_asus_init_verbs }, 3792 alc880_pin_asus_init_verbs },
3788 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), 3793 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
@@ -3820,8 +3825,7 @@ static struct alc_config_preset alc880_presets[] = {
3820 .init_hook = alc880_uniwill_p53_hp_automute, 3825 .init_hook = alc880_uniwill_p53_hp_automute,
3821 }, 3826 },
3822 [ALC880_FUJITSU] = { 3827 [ALC880_FUJITSU] = {
3823 .mixers = { alc880_fujitsu_mixer, 3828 .mixers = { alc880_fujitsu_mixer },
3824 alc880_pcbeep_mixer, },
3825 .init_verbs = { alc880_volume_init_verbs, 3829 .init_verbs = { alc880_volume_init_verbs,
3826 alc880_uniwill_p53_init_verbs, 3830 alc880_uniwill_p53_init_verbs,
3827 alc880_beep_init_verbs }, 3831 alc880_beep_init_verbs },
@@ -4114,7 +4118,7 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4114static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, 4118static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4115 const struct auto_pin_cfg *cfg) 4119 const struct auto_pin_cfg *cfg)
4116{ 4120{
4117 struct hda_input_mux *imux = &spec->private_imux; 4121 struct hda_input_mux *imux = &spec->private_imux[0];
4118 int i, err, idx; 4122 int i, err, idx;
4119 4123
4120 for (i = 0; i < AUTO_PIN_LAST; i++) { 4124 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -4202,10 +4206,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4202 for (i = 0; i < AUTO_PIN_LAST; i++) { 4206 for (i = 0; i < AUTO_PIN_LAST; i++) {
4203 hda_nid_t nid = spec->autocfg.input_pins[i]; 4207 hda_nid_t nid = spec->autocfg.input_pins[i];
4204 if (alc880_is_input_pin(nid)) { 4208 if (alc880_is_input_pin(nid)) {
4205 snd_hda_codec_write(codec, nid, 0, 4209 alc_set_input_pin(codec, nid, i);
4206 AC_VERB_SET_PIN_WIDGET_CONTROL,
4207 i <= AUTO_PIN_FRONT_MIC ?
4208 PIN_VREF80 : PIN_IN);
4209 if (nid != ALC880_PIN_CD_NID) 4210 if (nid != ALC880_PIN_CD_NID)
4210 snd_hda_codec_write(codec, nid, 0, 4211 snd_hda_codec_write(codec, nid, 0,
4211 AC_VERB_SET_AMP_GAIN_MUTE, 4212 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -4221,7 +4222,7 @@ static void alc880_auto_init_analog_input(struct hda_codec *codec)
4221static int alc880_parse_auto_config(struct hda_codec *codec) 4222static int alc880_parse_auto_config(struct hda_codec *codec)
4222{ 4223{
4223 struct alc_spec *spec = codec->spec; 4224 struct alc_spec *spec = codec->spec;
4224 int err; 4225 int i, err;
4225 static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; 4226 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
4226 4227
4227 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 4228 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
@@ -4252,8 +4253,23 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4252 4253
4253 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 4254 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4254 4255
4255 if (spec->autocfg.dig_out_pin) 4256 /* check multiple SPDIF-out (for recent codecs) */
4256 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 4257 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4258 hda_nid_t dig_nid;
4259 err = snd_hda_get_connections(codec,
4260 spec->autocfg.dig_out_pins[i],
4261 &dig_nid, 1);
4262 if (err < 0)
4263 continue;
4264 if (!i)
4265 spec->multiout.dig_out_nid = dig_nid;
4266 else {
4267 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4268 spec->slave_dig_outs[i - 1] = dig_nid;
4269 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4270 break;
4271 }
4272 }
4257 if (spec->autocfg.dig_in_pin) 4273 if (spec->autocfg.dig_in_pin)
4258 spec->dig_in_nid = ALC880_DIGIN_NID; 4274 spec->dig_in_nid = ALC880_DIGIN_NID;
4259 4275
@@ -4263,9 +4279,8 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
4263 add_verb(spec, alc880_volume_init_verbs); 4279 add_verb(spec, alc880_volume_init_verbs);
4264 4280
4265 spec->num_mux_defs = 1; 4281 spec->num_mux_defs = 1;
4266 spec->input_mux = &spec->private_imux; 4282 spec->input_mux = &spec->private_imux[0];
4267 4283
4268 store_pin_configs(codec);
4269 return 1; 4284 return 1;
4270} 4285}
4271 4286
@@ -4280,10 +4295,6 @@ static void alc880_auto_init(struct hda_codec *codec)
4280 alc_inithook(codec); 4295 alc_inithook(codec);
4281} 4296}
4282 4297
4283/*
4284 * OK, here we have finally the patch for ALC880
4285 */
4286
4287static void set_capture_mixer(struct alc_spec *spec) 4298static void set_capture_mixer(struct alc_spec *spec)
4288{ 4299{
4289 static struct snd_kcontrol_new *caps[3] = { 4300 static struct snd_kcontrol_new *caps[3] = {
@@ -4295,6 +4306,13 @@ static void set_capture_mixer(struct alc_spec *spec)
4295 spec->cap_mixer = caps[spec->num_adc_nids - 1]; 4306 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4296} 4307}
4297 4308
4309#define set_beep_amp(spec, nid, idx, dir) \
4310 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4311
4312/*
4313 * OK, here we have finally the patch for ALC880
4314 */
4315
4298static int patch_alc880(struct hda_codec *codec) 4316static int patch_alc880(struct hda_codec *codec)
4299{ 4317{
4300 struct alc_spec *spec; 4318 struct alc_spec *spec;
@@ -4330,6 +4348,12 @@ static int patch_alc880(struct hda_codec *codec)
4330 } 4348 }
4331 } 4349 }
4332 4350
4351 err = snd_hda_attach_beep_device(codec, 0x1);
4352 if (err < 0) {
4353 alc_free(codec);
4354 return err;
4355 }
4356
4333 if (board_config != ALC880_AUTO) 4357 if (board_config != ALC880_AUTO)
4334 setup_preset(spec, &alc880_presets[board_config]); 4358 setup_preset(spec, &alc880_presets[board_config]);
4335 4359
@@ -4356,6 +4380,7 @@ static int patch_alc880(struct hda_codec *codec)
4356 } 4380 }
4357 } 4381 }
4358 set_capture_mixer(spec); 4382 set_capture_mixer(spec);
4383 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
4359 4384
4360 spec->vmaster_nid = 0x0c; 4385 spec->vmaster_nid = 0x0c;
4361 4386
@@ -4463,6 +4488,26 @@ static struct hda_input_mux alc260_acer_capture_sources[2] = {
4463 }, 4488 },
4464 }, 4489 },
4465}; 4490};
4491
4492/* Maxdata Favorit 100XS */
4493static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4494 {
4495 .num_items = 2,
4496 .items = {
4497 { "Line/Mic", 0x0 },
4498 { "CD", 0x4 },
4499 },
4500 },
4501 {
4502 .num_items = 3,
4503 .items = {
4504 { "Line/Mic", 0x0 },
4505 { "CD", 0x4 },
4506 { "Mixer", 0x5 },
4507 },
4508 },
4509};
4510
4466/* 4511/*
4467 * This is just place-holder, so there's something for alc_build_pcms to look 4512 * This is just place-holder, so there's something for alc_build_pcms to look
4468 * at when it calculates the maximum number of channels. ALC260 has no mixer 4513 * at when it calculates the maximum number of channels. ALC260 has no mixer
@@ -4505,12 +4550,6 @@ static struct snd_kcontrol_new alc260_input_mixer[] = {
4505 { } /* end */ 4550 { } /* end */
4506}; 4551};
4507 4552
4508static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4509 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4510 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4511 { } /* end */
4512};
4513
4514/* update HP, line and mono out pins according to the master switch */ 4553/* update HP, line and mono out pins according to the master switch */
4515static void alc260_hp_master_update(struct hda_codec *codec, 4554static void alc260_hp_master_update(struct hda_codec *codec,
4516 hda_nid_t hp, hda_nid_t line, 4555 hda_nid_t hp, hda_nid_t line,
@@ -4702,8 +4741,6 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
4702 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT), 4741 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4703 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT), 4742 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
4704 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN), 4743 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
4705 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4706 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4707 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), 4744 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4708 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT), 4745 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
4709 { } /* end */ 4746 { } /* end */
@@ -4748,8 +4785,18 @@ static struct snd_kcontrol_new alc260_acer_mixer[] = {
4748 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), 4785 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4749 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), 4786 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4750 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4787 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4751 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT), 4788 { } /* end */
4752 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), 4789};
4790
4791/* Maxdata Favorit 100XS: one output and one input (0x12) jack
4792 */
4793static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
4794 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4795 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
4796 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
4797 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4798 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4799 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4753 { } /* end */ 4800 { } /* end */
4754}; 4801};
4755 4802
@@ -4767,8 +4814,6 @@ static struct snd_kcontrol_new alc260_will_mixer[] = {
4767 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT), 4814 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4768 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 4815 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4769 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 4816 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4770 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4771 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4772 { } /* end */ 4817 { } /* end */
4773}; 4818};
4774 4819
@@ -5126,6 +5171,89 @@ static struct hda_verb alc260_acer_init_verbs[] = {
5126 { } 5171 { }
5127}; 5172};
5128 5173
5174/* Initialisation sequence for Maxdata Favorit 100XS
5175 * (adapted from Acer init verbs).
5176 */
5177static struct hda_verb alc260_favorit100_init_verbs[] = {
5178 /* GPIO 0 enables the output jack.
5179 * Turn this on and rely on the standard mute
5180 * methods whenever the user wants to turn these outputs off.
5181 */
5182 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5183 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5184 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5185 /* Line/Mic input jack is connected to Mic1 pin */
5186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5187 /* Ensure all other unused pins are disabled and muted. */
5188 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5189 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5190 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5191 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5192 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5193 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5194 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5195 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5197 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5198 /* Disable digital (SPDIF) pins */
5199 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5200 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5201
5202 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5203 * bus when acting as outputs.
5204 */
5205 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5206 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5207
5208 /* Start with output sum widgets muted and their output gains at min */
5209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5214 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5216 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5217 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5218
5219 /* Unmute Line-out pin widget amp left and right
5220 * (no equiv mixer ctrl)
5221 */
5222 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5223 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5224 * inputs. If the pin mode is changed by the user the pin mode control
5225 * will take care of enabling the pin's input/output buffers as needed.
5226 * Therefore there's no need to enable the input buffer at this
5227 * stage.
5228 */
5229 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5230
5231 /* Mute capture amp left and right */
5232 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5233 /* Set ADC connection select to match default mixer setting - mic
5234 * (on mic1 pin)
5235 */
5236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5237
5238 /* Do similar with the second ADC: mute capture input amp and
5239 * set ADC connection to mic to match ALSA's default state.
5240 */
5241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5242 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5243
5244 /* Mute all inputs to mixer widget (even unconnected ones) */
5245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5253
5254 { }
5255};
5256
5129static struct hda_verb alc260_will_verbs[] = { 5257static struct hda_verb alc260_will_verbs[] = {
5130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 5258 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5131 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00}, 5259 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
@@ -5272,8 +5400,6 @@ static struct snd_kcontrol_new alc260_test_mixer[] = {
5272 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT), 5400 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5273 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), 5401 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5274 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), 5402 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5275 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5276 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5277 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT), 5403 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5278 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT), 5404 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5279 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT), 5405 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
@@ -5471,7 +5597,7 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5471static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, 5597static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5472 const struct auto_pin_cfg *cfg) 5598 const struct auto_pin_cfg *cfg)
5473{ 5599{
5474 struct hda_input_mux *imux = &spec->private_imux; 5600 struct hda_input_mux *imux = &spec->private_imux[0];
5475 int i, err, idx; 5601 int i, err, idx;
5476 5602
5477 for (i = 0; i < AUTO_PIN_LAST; i++) { 5603 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -5546,10 +5672,7 @@ static void alc260_auto_init_analog_input(struct hda_codec *codec)
5546 for (i = 0; i < AUTO_PIN_LAST; i++) { 5672 for (i = 0; i < AUTO_PIN_LAST; i++) {
5547 hda_nid_t nid = spec->autocfg.input_pins[i]; 5673 hda_nid_t nid = spec->autocfg.input_pins[i];
5548 if (nid >= 0x12) { 5674 if (nid >= 0x12) {
5549 snd_hda_codec_write(codec, nid, 0, 5675 alc_set_input_pin(codec, nid, i);
5550 AC_VERB_SET_PIN_WIDGET_CONTROL,
5551 i <= AUTO_PIN_FRONT_MIC ?
5552 PIN_VREF80 : PIN_IN);
5553 if (nid != ALC260_PIN_CD_NID) 5676 if (nid != ALC260_PIN_CD_NID)
5554 snd_hda_codec_write(codec, nid, 0, 5677 snd_hda_codec_write(codec, nid, 0,
5555 AC_VERB_SET_AMP_GAIN_MUTE, 5678 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -5623,7 +5746,7 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5623 5746
5624 spec->multiout.max_channels = 2; 5747 spec->multiout.max_channels = 2;
5625 5748
5626 if (spec->autocfg.dig_out_pin) 5749 if (spec->autocfg.dig_outs)
5627 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; 5750 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5628 if (spec->kctls.list) 5751 if (spec->kctls.list)
5629 add_mixer(spec, spec->kctls.list); 5752 add_mixer(spec, spec->kctls.list);
@@ -5631,9 +5754,8 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
5631 add_verb(spec, alc260_volume_init_verbs); 5754 add_verb(spec, alc260_volume_init_verbs);
5632 5755
5633 spec->num_mux_defs = 1; 5756 spec->num_mux_defs = 1;
5634 spec->input_mux = &spec->private_imux; 5757 spec->input_mux = &spec->private_imux[0];
5635 5758
5636 store_pin_configs(codec);
5637 return 1; 5759 return 1;
5638} 5760}
5639 5761
@@ -5670,6 +5792,7 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
5670 [ALC260_ACER] = "acer", 5792 [ALC260_ACER] = "acer",
5671 [ALC260_WILL] = "will", 5793 [ALC260_WILL] = "will",
5672 [ALC260_REPLACER_672V] = "replacer", 5794 [ALC260_REPLACER_672V] = "replacer",
5795 [ALC260_FAVORIT100] = "favorit100",
5673#ifdef CONFIG_SND_DEBUG 5796#ifdef CONFIG_SND_DEBUG
5674 [ALC260_TEST] = "test", 5797 [ALC260_TEST] = "test",
5675#endif 5798#endif
@@ -5679,6 +5802,7 @@ static const char *alc260_models[ALC260_MODEL_LAST] = {
5679static struct snd_pci_quirk alc260_cfg_tbl[] = { 5802static struct snd_pci_quirk alc260_cfg_tbl[] = {
5680 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER), 5803 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
5681 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER), 5804 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
5805 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
5682 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013), 5806 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
5683 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013), 5807 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
5684 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013), 5808 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
@@ -5701,8 +5825,7 @@ static struct snd_pci_quirk alc260_cfg_tbl[] = {
5701static struct alc_config_preset alc260_presets[] = { 5825static struct alc_config_preset alc260_presets[] = {
5702 [ALC260_BASIC] = { 5826 [ALC260_BASIC] = {
5703 .mixers = { alc260_base_output_mixer, 5827 .mixers = { alc260_base_output_mixer,
5704 alc260_input_mixer, 5828 alc260_input_mixer },
5705 alc260_pc_beep_mixer },
5706 .init_verbs = { alc260_init_verbs }, 5829 .init_verbs = { alc260_init_verbs },
5707 .num_dacs = ARRAY_SIZE(alc260_dac_nids), 5830 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5708 .dac_nids = alc260_dac_nids, 5831 .dac_nids = alc260_dac_nids,
@@ -5781,6 +5904,18 @@ static struct alc_config_preset alc260_presets[] = {
5781 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources), 5904 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5782 .input_mux = alc260_acer_capture_sources, 5905 .input_mux = alc260_acer_capture_sources,
5783 }, 5906 },
5907 [ALC260_FAVORIT100] = {
5908 .mixers = { alc260_favorit100_mixer },
5909 .init_verbs = { alc260_favorit100_init_verbs },
5910 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5911 .dac_nids = alc260_dac_nids,
5912 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5913 .adc_nids = alc260_dual_adc_nids,
5914 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5915 .channel_mode = alc260_modes,
5916 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
5917 .input_mux = alc260_favorit100_capture_sources,
5918 },
5784 [ALC260_WILL] = { 5919 [ALC260_WILL] = {
5785 .mixers = { alc260_will_mixer }, 5920 .mixers = { alc260_will_mixer },
5786 .init_verbs = { alc260_init_verbs, alc260_will_verbs }, 5921 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
@@ -5857,6 +5992,12 @@ static int patch_alc260(struct hda_codec *codec)
5857 } 5992 }
5858 } 5993 }
5859 5994
5995 err = snd_hda_attach_beep_device(codec, 0x1);
5996 if (err < 0) {
5997 alc_free(codec);
5998 return err;
5999 }
6000
5860 if (board_config != ALC260_AUTO) 6001 if (board_config != ALC260_AUTO)
5861 setup_preset(spec, &alc260_presets[board_config]); 6002 setup_preset(spec, &alc260_presets[board_config]);
5862 6003
@@ -5882,6 +6023,7 @@ static int patch_alc260(struct hda_codec *codec)
5882 } 6023 }
5883 } 6024 }
5884 set_capture_mixer(spec); 6025 set_capture_mixer(spec);
6026 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
5885 6027
5886 spec->vmaster_nid = 0x08; 6028 spec->vmaster_nid = 0x08;
5887 6029
@@ -6053,8 +6195,6 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
6053 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 6195 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6054 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 6196 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6055 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 6197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6056 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6057 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6058 { } /* end */ 6198 { } /* end */
6059}; 6199};
6060 6200
@@ -6081,8 +6221,6 @@ static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6081 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6222 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6083 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6084 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6085 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6086 { } /* end */ 6224 { } /* end */
6087}; 6225};
6088 6226
@@ -6134,8 +6272,6 @@ static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 6272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6135 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 6273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 6274 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6137 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6138 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6139 { } /* end */ 6275 { } /* end */
6140}; 6276};
6141 6277
@@ -6244,8 +6380,10 @@ static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6244 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT), 6380 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT), 6381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 6382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6383 /* FIXME: this looks suspicious...
6247 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT), 6384 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6248 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT), 6385 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6386 */
6249 { } /* end */ 6387 { } /* end */
6250}; 6388};
6251 6389
@@ -6877,19 +7015,9 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
6877 7015
6878 for (i = 0; i < AUTO_PIN_LAST; i++) { 7016 for (i = 0; i < AUTO_PIN_LAST; i++) {
6879 hda_nid_t nid = spec->autocfg.input_pins[i]; 7017 hda_nid_t nid = spec->autocfg.input_pins[i];
6880 unsigned int vref;
6881 if (!nid) 7018 if (!nid)
6882 continue; 7019 continue;
6883 vref = PIN_IN; 7020 alc_set_input_pin(codec, nid, AUTO_PIN_FRONT_MIC /*i*/);
6884 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
6885 unsigned int pincap;
6886 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6887 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
6888 AC_PINCAP_VREF_80)
6889 vref = PIN_VREF80;
6890 }
6891 snd_hda_codec_write(codec, nid, 0,
6892 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6893 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) 7021 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6894 snd_hda_codec_write(codec, nid, 0, 7022 snd_hda_codec_write(codec, nid, 0,
6895 AC_VERB_SET_AMP_GAIN_MUTE, 7023 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -6900,18 +7028,21 @@ static void alc882_auto_init_analog_input(struct hda_codec *codec)
6900static void alc882_auto_init_input_src(struct hda_codec *codec) 7028static void alc882_auto_init_input_src(struct hda_codec *codec)
6901{ 7029{
6902 struct alc_spec *spec = codec->spec; 7030 struct alc_spec *spec = codec->spec;
6903 const struct hda_input_mux *imux = spec->input_mux;
6904 int c; 7031 int c;
6905 7032
6906 for (c = 0; c < spec->num_adc_nids; c++) { 7033 for (c = 0; c < spec->num_adc_nids; c++) {
6907 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; 7034 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6908 hda_nid_t nid = spec->capsrc_nids[c]; 7035 hda_nid_t nid = spec->capsrc_nids[c];
7036 unsigned int mux_idx;
7037 const struct hda_input_mux *imux;
6909 int conns, mute, idx, item; 7038 int conns, mute, idx, item;
6910 7039
6911 conns = snd_hda_get_connections(codec, nid, conn_list, 7040 conns = snd_hda_get_connections(codec, nid, conn_list,
6912 ARRAY_SIZE(conn_list)); 7041 ARRAY_SIZE(conn_list));
6913 if (conns < 0) 7042 if (conns < 0)
6914 continue; 7043 continue;
7044 mux_idx = c >= spec->num_mux_defs ? 0 : c;
7045 imux = &spec->input_mux[mux_idx];
6915 for (idx = 0; idx < conns; idx++) { 7046 for (idx = 0; idx < conns; idx++) {
6916 /* if the current connection is the selected one, 7047 /* if the current connection is the selected one,
6917 * unmute it as default - otherwise mute it 7048 * unmute it as default - otherwise mute it
@@ -6924,8 +7055,20 @@ static void alc882_auto_init_input_src(struct hda_codec *codec)
6924 break; 7055 break;
6925 } 7056 }
6926 } 7057 }
6927 snd_hda_codec_write(codec, nid, 0, 7058 /* check if we have a selector or mixer
6928 AC_VERB_SET_AMP_GAIN_MUTE, mute); 7059 * we could check for the widget type instead, but
7060 * just check for Amp-In presence (in case of mixer
7061 * without amp-in there is something wrong, this
7062 * function shouldn't be used or capsrc nid is wrong)
7063 */
7064 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
7065 snd_hda_codec_write(codec, nid, 0,
7066 AC_VERB_SET_AMP_GAIN_MUTE,
7067 mute);
7068 else if (mute != AMP_IN_MUTE(idx))
7069 snd_hda_codec_write(codec, nid, 0,
7070 AC_VERB_SET_CONNECT_SEL,
7071 idx);
6929 } 7072 }
6930 } 7073 }
6931} 7074}
@@ -7054,6 +7197,12 @@ static int patch_alc882(struct hda_codec *codec)
7054 } 7197 }
7055 } 7198 }
7056 7199
7200 err = snd_hda_attach_beep_device(codec, 0x1);
7201 if (err < 0) {
7202 alc_free(codec);
7203 return err;
7204 }
7205
7057 if (board_config != ALC882_AUTO) 7206 if (board_config != ALC882_AUTO)
7058 setup_preset(spec, &alc882_presets[board_config]); 7207 setup_preset(spec, &alc882_presets[board_config]);
7059 7208
@@ -7074,7 +7223,7 @@ static int patch_alc882(struct hda_codec *codec)
7074 spec->stream_digital_playback = &alc882_pcm_digital_playback; 7223 spec->stream_digital_playback = &alc882_pcm_digital_playback;
7075 spec->stream_digital_capture = &alc882_pcm_digital_capture; 7224 spec->stream_digital_capture = &alc882_pcm_digital_capture;
7076 7225
7077 spec->is_mix_capture = 1; /* matrix-style capture */ 7226 spec->capture_style = CAPT_MIX; /* matrix-style capture */
7078 if (!spec->adc_nids && spec->input_mux) { 7227 if (!spec->adc_nids && spec->input_mux) {
7079 /* check whether NID 0x07 is valid */ 7228 /* check whether NID 0x07 is valid */
7080 unsigned int wcap = get_wcaps(codec, 0x07); 7229 unsigned int wcap = get_wcaps(codec, 0x07);
@@ -7091,6 +7240,7 @@ static int patch_alc882(struct hda_codec *codec)
7091 } 7240 }
7092 } 7241 }
7093 set_capture_mixer(spec); 7242 set_capture_mixer(spec);
7243 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
7094 7244
7095 spec->vmaster_nid = 0x0c; 7245 spec->vmaster_nid = 0x0c;
7096 7246
@@ -7142,10 +7292,14 @@ static hda_nid_t alc883_adc_nids_rev[2] = {
7142 0x09, 0x08 7292 0x09, 0x08
7143}; 7293};
7144 7294
7295#define alc889_adc_nids alc880_adc_nids
7296
7145static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 }; 7297static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
7146 7298
7147static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 }; 7299static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7148 7300
7301#define alc889_capsrc_nids alc882_capsrc_nids
7302
7149/* input MUX */ 7303/* input MUX */
7150/* FIXME: should be a matrix-type input source selection */ 7304/* FIXME: should be a matrix-type input source selection */
7151 7305
@@ -7363,8 +7517,6 @@ static struct snd_kcontrol_new alc883_base_mixer[] = {
7363 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7517 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7364 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7518 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7365 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7366 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7367 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7368 { } /* end */ 7520 { } /* end */
7369}; 7521};
7370 7522
@@ -7427,8 +7579,6 @@ static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7579 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7428 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7580 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7429 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7581 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7430 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7431 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7432 { } /* end */ 7582 { } /* end */
7433}; 7583};
7434 7584
@@ -7452,8 +7602,6 @@ static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7452 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7602 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7603 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7604 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7455 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7456 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7457 { } /* end */ 7605 { } /* end */
7458}; 7606};
7459 7607
@@ -7478,8 +7626,6 @@ static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7478 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 7626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7479 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT), 7627 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7480 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 7628 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7481 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7482 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7483 { } /* end */ 7629 { } /* end */
7484}; 7630};
7485 7631
@@ -7503,8 +7649,6 @@ static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
7503 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 7649 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7504 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 7650 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 7651 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7506 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7507 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7508 { } /* end */ 7652 { } /* end */
7509}; 7653};
7510 7654
@@ -7912,36 +8056,83 @@ static struct hda_verb alc888_lenovo_sky_verbs[] = {
7912 { } /* end */ 8056 { } /* end */
7913}; 8057};
7914 8058
8059static struct hda_verb alc888_6st_dell_verbs[] = {
8060 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8061 { }
8062};
8063
8064static void alc888_3st_hp_front_automute(struct hda_codec *codec)
8065{
8066 unsigned int present, bits;
8067
8068 present = snd_hda_codec_read(codec, 0x1b, 0,
8069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8070 bits = present ? HDA_AMP_MUTE : 0;
8071 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8072 HDA_AMP_MUTE, bits);
8073 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8074 HDA_AMP_MUTE, bits);
8075 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
8076 HDA_AMP_MUTE, bits);
8077}
8078
8079static void alc888_3st_hp_unsol_event(struct hda_codec *codec,
8080 unsigned int res)
8081{
8082 switch (res >> 26) {
8083 case ALC880_HP_EVENT:
8084 alc888_3st_hp_front_automute(codec);
8085 break;
8086 }
8087}
8088
7915static struct hda_verb alc888_3st_hp_verbs[] = { 8089static struct hda_verb alc888_3st_hp_verbs[] = {
7916 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */ 8090 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
7917 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */ 8091 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7918 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */ 8092 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
7919 { }
7920};
7921
7922static struct hda_verb alc888_6st_dell_verbs[] = {
7923 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 8093 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7924 { } 8094 { } /* end */
7925}; 8095};
7926 8096
8097/*
8098 * 2ch mode
8099 */
7927static struct hda_verb alc888_3st_hp_2ch_init[] = { 8100static struct hda_verb alc888_3st_hp_2ch_init[] = {
7928 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, 8101 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7929 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 8102 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7930 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, 8103 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7931 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, 8104 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7932 { } 8105 { } /* end */
8106};
8107
8108/*
8109 * 4ch mode
8110 */
8111static struct hda_verb alc888_3st_hp_4ch_init[] = {
8112 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8113 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8114 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8115 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8116 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8117 { } /* end */
7933}; 8118};
7934 8119
8120/*
8121 * 6ch mode
8122 */
7935static struct hda_verb alc888_3st_hp_6ch_init[] = { 8123static struct hda_verb alc888_3st_hp_6ch_init[] = {
7936 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8124 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7937 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 8125 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8126 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7938 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 8127 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7939 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, 8128 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7940 { } 8129 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8130 { } /* end */
7941}; 8131};
7942 8132
7943static struct hda_channel_mode alc888_3st_hp_modes[2] = { 8133static struct hda_channel_mode alc888_3st_hp_modes[3] = {
7944 { 2, alc888_3st_hp_2ch_init }, 8134 { 2, alc888_3st_hp_2ch_init },
8135 { 4, alc888_3st_hp_4ch_init },
7945 { 6, alc888_3st_hp_6ch_init }, 8136 { 6, alc888_3st_hp_6ch_init },
7946}; 8137};
7947 8138
@@ -8202,7 +8393,7 @@ static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8202{ 8393{
8203 switch (res >> 26) { 8394 switch (res >> 26) {
8204 case ALC880_HP_EVENT: 8395 case ALC880_HP_EVENT:
8205 printk("hp_event\n"); 8396 /* printk(KERN_DEBUG "hp_event\n"); */
8206 alc888_6st_dell_front_automute(codec); 8397 alc888_6st_dell_front_automute(codec);
8207 break; 8398 break;
8208 } 8399 }
@@ -8468,17 +8659,21 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8468 ALC888_ACER_ASPIRE_4930G), 8659 ALC888_ACER_ASPIRE_4930G),
8469 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", 8660 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8470 ALC888_ACER_ASPIRE_4930G), 8661 ALC888_ACER_ASPIRE_4930G),
8662 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
8663 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
8471 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", 8664 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8472 ALC888_ACER_ASPIRE_4930G), 8665 ALC888_ACER_ASPIRE_4930G),
8473 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", 8666 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
8474 ALC888_ACER_ASPIRE_4930G), 8667 ALC888_ACER_ASPIRE_4930G),
8475 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ 8668 /* default Acer */
8669 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
8476 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), 8670 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
8477 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), 8671 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
8478 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), 8672 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8479 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), 8673 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
8480 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), 8674 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
8481 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), 8675 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
8676 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
8482 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), 8677 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
8483 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), 8678 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
8484 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG), 8679 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
@@ -8518,7 +8713,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8518 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG), 8713 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
8519 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720), 8714 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8520 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720), 8715 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
8521 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD), 8716 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
8522 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch), 8717 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
8523 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION), 8718 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
8524 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550", 8719 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
@@ -8543,6 +8738,10 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = {
8543 {} 8738 {}
8544}; 8739};
8545 8740
8741static hda_nid_t alc1200_slave_dig_outs[] = {
8742 ALC883_DIGOUT_NID, 0,
8743};
8744
8546static struct alc_config_preset alc883_presets[] = { 8745static struct alc_config_preset alc883_presets[] = {
8547 [ALC883_3ST_2ch_DIG] = { 8746 [ALC883_3ST_2ch_DIG] = {
8548 .mixers = { alc883_3ST_2ch_mixer }, 8747 .mixers = { alc883_3ST_2ch_mixer },
@@ -8778,6 +8977,8 @@ static struct alc_config_preset alc883_presets[] = {
8778 .channel_mode = alc888_3st_hp_modes, 8977 .channel_mode = alc888_3st_hp_modes,
8779 .need_dac_fix = 1, 8978 .need_dac_fix = 1,
8780 .input_mux = &alc883_capture_source, 8979 .input_mux = &alc883_capture_source,
8980 .unsol_event = alc888_3st_hp_unsol_event,
8981 .init_hook = alc888_3st_hp_front_automute,
8781 }, 8982 },
8782 [ALC888_6ST_DELL] = { 8983 [ALC888_6ST_DELL] = {
8783 .mixers = { alc883_base_mixer, alc883_chmode_mixer }, 8984 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
@@ -8883,6 +9084,7 @@ static struct alc_config_preset alc883_presets[] = {
8883 .dac_nids = alc883_dac_nids, 9084 .dac_nids = alc883_dac_nids,
8884 .dig_out_nid = ALC1200_DIGOUT_NID, 9085 .dig_out_nid = ALC1200_DIGOUT_NID,
8885 .dig_in_nid = ALC883_DIGIN_NID, 9086 .dig_in_nid = ALC883_DIGIN_NID,
9087 .slave_dig_outs = alc1200_slave_dig_outs,
8886 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes), 9088 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8887 .channel_mode = alc883_sixstack_modes, 9089 .channel_mode = alc883_sixstack_modes,
8888 .input_mux = &alc883_capture_source, 9090 .input_mux = &alc883_capture_source,
@@ -8950,10 +9152,7 @@ static void alc883_auto_init_analog_input(struct hda_codec *codec)
8950 for (i = 0; i < AUTO_PIN_LAST; i++) { 9152 for (i = 0; i < AUTO_PIN_LAST; i++) {
8951 hda_nid_t nid = spec->autocfg.input_pins[i]; 9153 hda_nid_t nid = spec->autocfg.input_pins[i];
8952 if (alc883_is_input_pin(nid)) { 9154 if (alc883_is_input_pin(nid)) {
8953 snd_hda_codec_write(codec, nid, 0, 9155 alc_set_input_pin(codec, nid, i);
8954 AC_VERB_SET_PIN_WIDGET_CONTROL,
8955 (i <= AUTO_PIN_FRONT_MIC ?
8956 PIN_VREF80 : PIN_IN));
8957 if (nid != ALC883_PIN_CD_NID) 9156 if (nid != ALC883_PIN_CD_NID)
8958 snd_hda_codec_write(codec, nid, 0, 9157 snd_hda_codec_write(codec, nid, 0,
8959 AC_VERB_SET_AMP_GAIN_MUTE, 9158 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -8969,6 +9168,8 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8969{ 9168{
8970 struct alc_spec *spec = codec->spec; 9169 struct alc_spec *spec = codec->spec;
8971 int err = alc880_parse_auto_config(codec); 9170 int err = alc880_parse_auto_config(codec);
9171 struct auto_pin_cfg *cfg = &spec->autocfg;
9172 int i;
8972 9173
8973 if (err < 0) 9174 if (err < 0)
8974 return err; 9175 return err;
@@ -8982,6 +9183,26 @@ static int alc883_parse_auto_config(struct hda_codec *codec)
8982 /* hack - override the init verbs */ 9183 /* hack - override the init verbs */
8983 spec->init_verbs[0] = alc883_auto_init_verbs; 9184 spec->init_verbs[0] = alc883_auto_init_verbs;
8984 9185
9186 /* setup input_mux for ALC889 */
9187 if (codec->vendor_id == 0x10ec0889) {
9188 /* digital-mic input pin is excluded in alc880_auto_create..()
9189 * because it's under 0x18
9190 */
9191 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9192 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9193 struct hda_input_mux *imux = &spec->private_imux[0];
9194 for (i = 1; i < 3; i++)
9195 memcpy(&spec->private_imux[i],
9196 &spec->private_imux[0],
9197 sizeof(spec->private_imux[0]));
9198 imux->items[imux->num_items].label = "Int DMic";
9199 imux->items[imux->num_items].index = 0x0b;
9200 imux->num_items++;
9201 spec->num_mux_defs = 3;
9202 spec->input_mux = spec->private_imux;
9203 }
9204 }
9205
8985 return 1; /* config found */ 9206 return 1; /* config found */
8986} 9207}
8987 9208
@@ -9033,6 +9254,12 @@ static int patch_alc883(struct hda_codec *codec)
9033 } 9254 }
9034 } 9255 }
9035 9256
9257 err = snd_hda_attach_beep_device(codec, 0x1);
9258 if (err < 0) {
9259 alc_free(codec);
9260 return err;
9261 }
9262
9036 if (board_config != ALC883_AUTO) 9263 if (board_config != ALC883_AUTO)
9037 setup_preset(spec, &alc883_presets[board_config]); 9264 setup_preset(spec, &alc883_presets[board_config]);
9038 9265
@@ -9045,14 +9272,36 @@ static int patch_alc883(struct hda_codec *codec)
9045 spec->stream_name_analog = "ALC888 Analog"; 9272 spec->stream_name_analog = "ALC888 Analog";
9046 spec->stream_name_digital = "ALC888 Digital"; 9273 spec->stream_name_digital = "ALC888 Digital";
9047 } 9274 }
9275 if (!spec->num_adc_nids) {
9276 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9277 spec->adc_nids = alc883_adc_nids;
9278 }
9279 if (!spec->capsrc_nids)
9280 spec->capsrc_nids = alc883_capsrc_nids;
9281 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9048 break; 9282 break;
9049 case 0x10ec0889: 9283 case 0x10ec0889:
9050 spec->stream_name_analog = "ALC889 Analog"; 9284 spec->stream_name_analog = "ALC889 Analog";
9051 spec->stream_name_digital = "ALC889 Digital"; 9285 spec->stream_name_digital = "ALC889 Digital";
9286 if (!spec->num_adc_nids) {
9287 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9288 spec->adc_nids = alc889_adc_nids;
9289 }
9290 if (!spec->capsrc_nids)
9291 spec->capsrc_nids = alc889_capsrc_nids;
9292 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9293 capture */
9052 break; 9294 break;
9053 default: 9295 default:
9054 spec->stream_name_analog = "ALC883 Analog"; 9296 spec->stream_name_analog = "ALC883 Analog";
9055 spec->stream_name_digital = "ALC883 Digital"; 9297 spec->stream_name_digital = "ALC883 Digital";
9298 if (!spec->num_adc_nids) {
9299 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9300 spec->adc_nids = alc883_adc_nids;
9301 }
9302 if (!spec->capsrc_nids)
9303 spec->capsrc_nids = alc883_capsrc_nids;
9304 spec->capture_style = CAPT_MIX; /* matrix-style capture */
9056 break; 9305 break;
9057 } 9306 }
9058 9307
@@ -9063,15 +9312,9 @@ static int patch_alc883(struct hda_codec *codec)
9063 spec->stream_digital_playback = &alc883_pcm_digital_playback; 9312 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9064 spec->stream_digital_capture = &alc883_pcm_digital_capture; 9313 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9065 9314
9066 if (!spec->num_adc_nids) {
9067 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9068 spec->adc_nids = alc883_adc_nids;
9069 }
9070 if (!spec->capsrc_nids)
9071 spec->capsrc_nids = alc883_capsrc_nids;
9072 spec->is_mix_capture = 1; /* matrix-style capture */
9073 if (!spec->cap_mixer) 9315 if (!spec->cap_mixer)
9074 set_capture_mixer(spec); 9316 set_capture_mixer(spec);
9317 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
9075 9318
9076 spec->vmaster_nid = 0x0c; 9319 spec->vmaster_nid = 0x0c;
9077 9320
@@ -9124,8 +9367,6 @@ static struct snd_kcontrol_new alc262_base_mixer[] = {
9124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9367 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9368 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9126 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9369 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9127 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9128 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
9129 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), 9370 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), 9371 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9131 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), 9372 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
@@ -9146,8 +9387,6 @@ static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 9387 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 9388 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9148 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT), 9389 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9149 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9150 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
9151 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/ 9390 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT), 9391 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9153 { } /* end */ 9392 { } /* end */
@@ -9256,8 +9495,6 @@ static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
9256 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 9495 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9496 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9497 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9259 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9260 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9261 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT), 9498 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9262 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT), 9499 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9263 { } /* end */ 9500 { } /* end */
@@ -9286,8 +9523,6 @@ static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
9286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT), 9523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9287 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 9524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9288 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 9525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9289 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9290 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9291 { } /* end */ 9526 { } /* end */
9292}; 9527};
9293 9528
@@ -9435,6 +9670,67 @@ static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9435 { } /* end */ 9670 { } /* end */
9436}; 9671};
9437 9672
9673static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9674 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9675 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9676 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9677 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9678 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9679 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9682 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9683 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9684 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9685 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9686 { } /* end */
9687};
9688
9689static struct hda_verb alc262_tyan_verbs[] = {
9690 /* Headphone automute */
9691 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9693 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9694
9695 /* P11 AUX_IN, white 4-pin connector */
9696 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9697 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9698 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9699 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9700
9701 {}
9702};
9703
9704/* unsolicited event for HP jack sensing */
9705static void alc262_tyan_automute(struct hda_codec *codec)
9706{
9707 unsigned int mute;
9708 unsigned int present;
9709
9710 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9711 present = snd_hda_codec_read(codec, 0x1b, 0,
9712 AC_VERB_GET_PIN_SENSE, 0);
9713 present = (present & 0x80000000) != 0;
9714 if (present) {
9715 /* mute line output on ATX panel */
9716 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9717 HDA_AMP_MUTE, HDA_AMP_MUTE);
9718 } else {
9719 /* unmute line output if necessary */
9720 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9721 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9722 HDA_AMP_MUTE, mute);
9723 }
9724}
9725
9726static void alc262_tyan_unsol_event(struct hda_codec *codec,
9727 unsigned int res)
9728{
9729 if ((res >> 26) != ALC880_HP_EVENT)
9730 return;
9731 alc262_tyan_automute(codec);
9732}
9733
9438#define alc262_capture_mixer alc882_capture_mixer 9734#define alc262_capture_mixer alc882_capture_mixer
9439#define alc262_capture_alt_mixer alc882_capture_alt_mixer 9735#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9440 9736
@@ -9901,8 +10197,6 @@ static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
9901 }, 10197 },
9902 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 10198 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9903 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 10199 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9904 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9905 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
9906 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 10200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 10201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 10202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
@@ -10474,8 +10768,14 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10474 alc262_ignore); 10768 alc262_ignore);
10475 if (err < 0) 10769 if (err < 0)
10476 return err; 10770 return err;
10477 if (!spec->autocfg.line_outs) 10771 if (!spec->autocfg.line_outs) {
10772 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
10773 spec->multiout.max_channels = 2;
10774 spec->no_analog = 1;
10775 goto dig_only;
10776 }
10478 return 0; /* can't find valid BIOS pin config */ 10777 return 0; /* can't find valid BIOS pin config */
10778 }
10479 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg); 10779 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10480 if (err < 0) 10780 if (err < 0)
10481 return err; 10781 return err;
@@ -10485,8 +10785,11 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10485 10785
10486 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 10786 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10487 10787
10488 if (spec->autocfg.dig_out_pin) 10788 dig_only:
10789 if (spec->autocfg.dig_outs) {
10489 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; 10790 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10791 spec->dig_out_type = spec->autocfg.dig_out_type[0];
10792 }
10490 if (spec->autocfg.dig_in_pin) 10793 if (spec->autocfg.dig_in_pin)
10491 spec->dig_in_nid = ALC262_DIGIN_NID; 10794 spec->dig_in_nid = ALC262_DIGIN_NID;
10492 10795
@@ -10495,13 +10798,12 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
10495 10798
10496 add_verb(spec, alc262_volume_init_verbs); 10799 add_verb(spec, alc262_volume_init_verbs);
10497 spec->num_mux_defs = 1; 10800 spec->num_mux_defs = 1;
10498 spec->input_mux = &spec->private_imux; 10801 spec->input_mux = &spec->private_imux[0];
10499 10802
10500 err = alc_auto_add_mic_boost(codec); 10803 err = alc_auto_add_mic_boost(codec);
10501 if (err < 0) 10804 if (err < 0)
10502 return err; 10805 return err;
10503 10806
10504 store_pin_configs(codec);
10505 return 1; 10807 return 1;
10506} 10808}
10507 10809
@@ -10543,21 +10845,19 @@ static const char *alc262_models[ALC262_MODEL_LAST] = {
10543 [ALC262_ULTRA] = "ultra", 10845 [ALC262_ULTRA] = "ultra",
10544 [ALC262_LENOVO_3000] = "lenovo-3000", 10846 [ALC262_LENOVO_3000] = "lenovo-3000",
10545 [ALC262_NEC] = "nec", 10847 [ALC262_NEC] = "nec",
10848 [ALC262_TYAN] = "tyan",
10546 [ALC262_AUTO] = "auto", 10849 [ALC262_AUTO] = "auto",
10547}; 10850};
10548 10851
10549static struct snd_pci_quirk alc262_cfg_tbl[] = { 10852static struct snd_pci_quirk alc262_cfg_tbl[] = {
10550 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO), 10853 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
10551 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC), 10854 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
10552 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC), 10855 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10553 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC), 10856 ALC262_HP_BPC),
10554 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC), 10857 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10555 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC), 10858 ALC262_HP_BPC),
10556 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC), 10859 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
10557 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC), 10860 ALC262_HP_BPC),
10558 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
10559 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
10560 SND_PCI_QUIRK(0x103c, 0x170b, "HP xw*", ALC262_HP_BPC),
10561 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL), 10861 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
10562 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF), 10862 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
10563 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL), 10863 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
@@ -10575,17 +10875,17 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = {
10575 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10875 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10576 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO), 10876 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
10577 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10877 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10578 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), 10878 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
10579 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), 10879 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
10580 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN", 10880 ALC262_SONY_ASSAMD),
10581 ALC262_SONY_ASSAMD),
10582 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", 10881 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
10583 ALC262_TOSHIBA_RX1), 10882 ALC262_TOSHIBA_RX1),
10584 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), 10883 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
10585 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU), 10884 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
10586 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU), 10885 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
10587 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA), 10886 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
10588 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA), 10887 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10888 ALC262_ULTRA),
10589 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO), 10889 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
10590 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000), 10890 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
10591 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8), 10891 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
@@ -10802,6 +11102,19 @@ static struct alc_config_preset alc262_presets[] = {
10802 .unsol_event = alc262_hippo_unsol_event, 11102 .unsol_event = alc262_hippo_unsol_event,
10803 .init_hook = alc262_hippo_automute, 11103 .init_hook = alc262_hippo_automute,
10804 }, 11104 },
11105 [ALC262_TYAN] = {
11106 .mixers = { alc262_tyan_mixer },
11107 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11108 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11109 .dac_nids = alc262_dac_nids,
11110 .hp_nid = 0x02,
11111 .dig_out_nid = ALC262_DIGOUT_NID,
11112 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11113 .channel_mode = alc262_modes,
11114 .input_mux = &alc262_capture_source,
11115 .unsol_event = alc262_tyan_unsol_event,
11116 .init_hook = alc262_tyan_automute,
11117 },
10805}; 11118};
10806 11119
10807static int patch_alc262(struct hda_codec *codec) 11120static int patch_alc262(struct hda_codec *codec)
@@ -10854,6 +11167,14 @@ static int patch_alc262(struct hda_codec *codec)
10854 } 11167 }
10855 } 11168 }
10856 11169
11170 if (!spec->no_analog) {
11171 err = snd_hda_attach_beep_device(codec, 0x1);
11172 if (err < 0) {
11173 alc_free(codec);
11174 return err;
11175 }
11176 }
11177
10857 if (board_config != ALC262_AUTO) 11178 if (board_config != ALC262_AUTO)
10858 setup_preset(spec, &alc262_presets[board_config]); 11179 setup_preset(spec, &alc262_presets[board_config]);
10859 11180
@@ -10865,7 +11186,7 @@ static int patch_alc262(struct hda_codec *codec)
10865 spec->stream_digital_playback = &alc262_pcm_digital_playback; 11186 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10866 spec->stream_digital_capture = &alc262_pcm_digital_capture; 11187 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10867 11188
10868 spec->is_mix_capture = 1; 11189 spec->capture_style = CAPT_MIX;
10869 if (!spec->adc_nids && spec->input_mux) { 11190 if (!spec->adc_nids && spec->input_mux) {
10870 /* check whether NID 0x07 is valid */ 11191 /* check whether NID 0x07 is valid */
10871 unsigned int wcap = get_wcaps(codec, 0x07); 11192 unsigned int wcap = get_wcaps(codec, 0x07);
@@ -10882,8 +11203,10 @@ static int patch_alc262(struct hda_codec *codec)
10882 spec->capsrc_nids = alc262_capsrc_nids; 11203 spec->capsrc_nids = alc262_capsrc_nids;
10883 } 11204 }
10884 } 11205 }
10885 if (!spec->cap_mixer) 11206 if (!spec->cap_mixer && !spec->no_analog)
10886 set_capture_mixer(spec); 11207 set_capture_mixer(spec);
11208 if (!spec->no_analog)
11209 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10887 11210
10888 spec->vmaster_nid = 0x0c; 11211 spec->vmaster_nid = 0x0c;
10889 11212
@@ -11263,19 +11586,13 @@ static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11263static struct hda_verb alc268_base_init_verbs[] = { 11586static struct hda_verb alc268_base_init_verbs[] = {
11264 /* Unmute DAC0-1 and set vol = 0 */ 11587 /* Unmute DAC0-1 and set vol = 0 */
11265 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11588 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11266 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11267 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 11589 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11269 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11270 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11271 11590
11272 /* 11591 /*
11273 * Set up output mixers (0x0c - 0x0e) 11592 * Set up output mixers (0x0c - 0x0e)
11274 */ 11593 */
11275 /* set vol=0 to output mixers */ 11594 /* set vol=0 to output mixers */
11276 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11595 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11277 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11279 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00}, 11596 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11280 11597
11281 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -11294,9 +11611,7 @@ static struct hda_verb alc268_base_init_verbs[] = {
11294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11611 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11295 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11612 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11613 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11297 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11298 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11614 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11299 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11300 11615
11301 /* set PCBEEP vol = 0, mute connections */ 11616 /* set PCBEEP vol = 0, mute connections */
11302 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11617 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -11318,10 +11633,8 @@ static struct hda_verb alc268_base_init_verbs[] = {
11318 */ 11633 */
11319static struct hda_verb alc268_volume_init_verbs[] = { 11634static struct hda_verb alc268_volume_init_verbs[] = {
11320 /* set output DAC */ 11635 /* set output DAC */
11321 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11636 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11322 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 11637 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11323 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11324 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11325 11638
11326 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11327 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, 11640 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
@@ -11329,16 +11642,12 @@ static struct hda_verb alc268_volume_init_verbs[] = {
11329 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11642 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11330 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, 11643 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11331 11644
11332 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11646 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11336 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11647 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11337 11648
11338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11649 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 11650 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11341 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11342 11651
11343 /* set PCBEEP vol = 0, mute connections */ 11652 /* set PCBEEP vol = 0, mute connections */
11344 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 11653 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -11537,7 +11846,7 @@ static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11537static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec, 11846static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11538 const struct auto_pin_cfg *cfg) 11847 const struct auto_pin_cfg *cfg)
11539{ 11848{
11540 struct hda_input_mux *imux = &spec->private_imux; 11849 struct hda_input_mux *imux = &spec->private_imux[0];
11541 int i, idx1; 11850 int i, idx1;
11542 11851
11543 for (i = 0; i < AUTO_PIN_LAST; i++) { 11852 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -11631,9 +11940,14 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
11631 alc268_ignore); 11940 alc268_ignore);
11632 if (err < 0) 11941 if (err < 0)
11633 return err; 11942 return err;
11634 if (!spec->autocfg.line_outs) 11943 if (!spec->autocfg.line_outs) {
11944 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11945 spec->multiout.max_channels = 2;
11946 spec->no_analog = 1;
11947 goto dig_only;
11948 }
11635 return 0; /* can't find valid BIOS pin config */ 11949 return 0; /* can't find valid BIOS pin config */
11636 11950 }
11637 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg); 11951 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11638 if (err < 0) 11952 if (err < 0)
11639 return err; 11953 return err;
@@ -11643,25 +11957,26 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
11643 11957
11644 spec->multiout.max_channels = 2; 11958 spec->multiout.max_channels = 2;
11645 11959
11960 dig_only:
11646 /* digital only support output */ 11961 /* digital only support output */
11647 if (spec->autocfg.dig_out_pin) 11962 if (spec->autocfg.dig_outs) {
11648 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID; 11963 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11649 11964 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11965 }
11650 if (spec->kctls.list) 11966 if (spec->kctls.list)
11651 add_mixer(spec, spec->kctls.list); 11967 add_mixer(spec, spec->kctls.list);
11652 11968
11653 if (spec->autocfg.speaker_pins[0] != 0x1d) 11969 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
11654 add_mixer(spec, alc268_beep_mixer); 11970 add_mixer(spec, alc268_beep_mixer);
11655 11971
11656 add_verb(spec, alc268_volume_init_verbs); 11972 add_verb(spec, alc268_volume_init_verbs);
11657 spec->num_mux_defs = 1; 11973 spec->num_mux_defs = 1;
11658 spec->input_mux = &spec->private_imux; 11974 spec->input_mux = &spec->private_imux[0];
11659 11975
11660 err = alc_auto_add_mic_boost(codec); 11976 err = alc_auto_add_mic_boost(codec);
11661 if (err < 0) 11977 if (err < 0)
11662 return err; 11978 return err;
11663 11979
11664 store_pin_configs(codec);
11665 return 1; 11980 return 1;
11666} 11981}
11667 11982
@@ -11723,7 +12038,7 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
11723 12038
11724static struct alc_config_preset alc268_presets[] = { 12039static struct alc_config_preset alc268_presets[] = {
11725 [ALC267_QUANTA_IL1] = { 12040 [ALC267_QUANTA_IL1] = {
11726 .mixers = { alc267_quanta_il1_mixer }, 12041 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
11727 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12042 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11728 alc267_quanta_il1_verbs }, 12043 alc267_quanta_il1_verbs },
11729 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12044 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -11805,7 +12120,8 @@ static struct alc_config_preset alc268_presets[] = {
11805 }, 12120 },
11806 [ALC268_ACER_ASPIRE_ONE] = { 12121 [ALC268_ACER_ASPIRE_ONE] = {
11807 .mixers = { alc268_acer_aspire_one_mixer, 12122 .mixers = { alc268_acer_aspire_one_mixer,
11808 alc268_capture_alt_mixer }, 12123 alc268_beep_mixer,
12124 alc268_capture_alt_mixer },
11809 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs, 12125 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11810 alc268_acer_aspire_one_verbs }, 12126 alc268_acer_aspire_one_verbs },
11811 .num_dacs = ARRAY_SIZE(alc268_dac_nids), 12127 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
@@ -11874,7 +12190,7 @@ static int patch_alc268(struct hda_codec *codec)
11874{ 12190{
11875 struct alc_spec *spec; 12191 struct alc_spec *spec;
11876 int board_config; 12192 int board_config;
11877 int err; 12193 int i, has_beep, err;
11878 12194
11879 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); 12195 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11880 if (spec == NULL) 12196 if (spec == NULL)
@@ -11923,15 +12239,30 @@ static int patch_alc268(struct hda_codec *codec)
11923 12239
11924 spec->stream_digital_playback = &alc268_pcm_digital_playback; 12240 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11925 12241
11926 if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) 12242 has_beep = 0;
11927 /* override the amp caps for beep generator */ 12243 for (i = 0; i < spec->num_mixers; i++) {
11928 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, 12244 if (spec->mixers[i] == alc268_beep_mixer) {
12245 has_beep = 1;
12246 break;
12247 }
12248 }
12249
12250 if (has_beep) {
12251 err = snd_hda_attach_beep_device(codec, 0x1);
12252 if (err < 0) {
12253 alc_free(codec);
12254 return err;
12255 }
12256 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12257 /* override the amp caps for beep generator */
12258 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11929 (0x0c << AC_AMPCAP_OFFSET_SHIFT) | 12259 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11930 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | 12260 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11931 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | 12261 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11932 (0 << AC_AMPCAP_MUTE_SHIFT)); 12262 (0 << AC_AMPCAP_MUTE_SHIFT));
12263 }
11933 12264
11934 if (!spec->adc_nids && spec->input_mux) { 12265 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
11935 /* check whether NID 0x07 is valid */ 12266 /* check whether NID 0x07 is valid */
11936 unsigned int wcap = get_wcaps(codec, 0x07); 12267 unsigned int wcap = get_wcaps(codec, 0x07);
11937 int i; 12268 int i;
@@ -12012,8 +12343,6 @@ static struct snd_kcontrol_new alc269_base_mixer[] = {
12012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 12343 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12013 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), 12344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12014 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 12345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12015 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12016 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT), 12346 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12018 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 12347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12019 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 12348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
@@ -12040,8 +12369,6 @@ static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12040 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), 12369 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12041 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), 12370 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12042 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT), 12371 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12043 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12044 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12045 { } 12372 { }
12046}; 12373};
12047 12374
@@ -12065,8 +12392,6 @@ static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12065 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT), 12392 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12066 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT), 12393 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12067 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT), 12394 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
12068 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
12069 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
12070 { } 12395 { }
12071}; 12396};
12072 12397
@@ -12103,13 +12428,6 @@ static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12103 { } /* end */ 12428 { } /* end */
12104}; 12429};
12105 12430
12106/* beep control */
12107static struct snd_kcontrol_new alc269_beep_mixer[] = {
12108 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
12109 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
12110 { } /* end */
12111};
12112
12113static struct hda_verb alc269_quanta_fl1_verbs[] = { 12431static struct hda_verb alc269_quanta_fl1_verbs[] = {
12114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, 12432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12115 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, 12433 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
@@ -12509,7 +12827,7 @@ static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12509 */ 12827 */
12510 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 || 12828 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12511 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) { 12829 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12512 struct hda_input_mux *imux = &spec->private_imux; 12830 struct hda_input_mux *imux = &spec->private_imux[0];
12513 imux->items[imux->num_items].label = "Int Mic"; 12831 imux->items[imux->num_items].label = "Int Mic";
12514 imux->items[imux->num_items].index = 0x05; 12832 imux->items[imux->num_items].index = 0x05;
12515 imux->num_items++; 12833 imux->num_items++;
@@ -12527,13 +12845,34 @@ static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12527#define alc269_pcm_digital_playback alc880_pcm_digital_playback 12845#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12528#define alc269_pcm_digital_capture alc880_pcm_digital_capture 12846#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12529 12847
12848static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
12849 .substreams = 1,
12850 .channels_min = 2,
12851 .channels_max = 8,
12852 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12853 /* NID is set in alc_build_pcms */
12854 .ops = {
12855 .open = alc880_playback_pcm_open,
12856 .prepare = alc880_playback_pcm_prepare,
12857 .cleanup = alc880_playback_pcm_cleanup
12858 },
12859};
12860
12861static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
12862 .substreams = 1,
12863 .channels_min = 2,
12864 .channels_max = 2,
12865 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
12866 /* NID is set in alc_build_pcms */
12867};
12868
12530/* 12869/*
12531 * BIOS auto configuration 12870 * BIOS auto configuration
12532 */ 12871 */
12533static int alc269_parse_auto_config(struct hda_codec *codec) 12872static int alc269_parse_auto_config(struct hda_codec *codec)
12534{ 12873{
12535 struct alc_spec *spec = codec->spec; 12874 struct alc_spec *spec = codec->spec;
12536 int i, err; 12875 int err;
12537 static hda_nid_t alc269_ignore[] = { 0x1d, 0 }; 12876 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12538 12877
12539 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, 12878 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
@@ -12550,22 +12889,15 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12550 12889
12551 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 12890 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12552 12891
12553 if (spec->autocfg.dig_out_pin) 12892 if (spec->autocfg.dig_outs)
12554 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID; 12893 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12555 12894
12556 if (spec->kctls.list) 12895 if (spec->kctls.list)
12557 add_mixer(spec, spec->kctls.list); 12896 add_mixer(spec, spec->kctls.list);
12558 12897
12559 /* create a beep mixer control if the pin 0x1d isn't assigned */
12560 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12561 if (spec->autocfg.input_pins[i] == 0x1d)
12562 break;
12563 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
12564 add_mixer(spec, alc269_beep_mixer);
12565
12566 add_verb(spec, alc269_init_verbs); 12898 add_verb(spec, alc269_init_verbs);
12567 spec->num_mux_defs = 1; 12899 spec->num_mux_defs = 1;
12568 spec->input_mux = &spec->private_imux; 12900 spec->input_mux = &spec->private_imux[0];
12569 /* set default input source */ 12901 /* set default input source */
12570 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0], 12902 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12571 0, AC_VERB_SET_CONNECT_SEL, 12903 0, AC_VERB_SET_CONNECT_SEL,
@@ -12575,10 +12907,9 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
12575 if (err < 0) 12907 if (err < 0)
12576 return err; 12908 return err;
12577 12909
12578 if (!spec->cap_mixer) 12910 if (!spec->cap_mixer && !spec->no_analog)
12579 set_capture_mixer(spec); 12911 set_capture_mixer(spec);
12580 12912
12581 store_pin_configs(codec);
12582 return 1; 12913 return 1;
12583} 12914}
12584 12915
@@ -12675,7 +13006,7 @@ static struct alc_config_preset alc269_presets[] = {
12675 .init_hook = alc269_eeepc_dmic_inithook, 13006 .init_hook = alc269_eeepc_dmic_inithook,
12676 }, 13007 },
12677 [ALC269_FUJITSU] = { 13008 [ALC269_FUJITSU] = {
12678 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer }, 13009 .mixers = { alc269_fujitsu_mixer },
12679 .cap_mixer = alc269_epc_capture_mixer, 13010 .cap_mixer = alc269_epc_capture_mixer,
12680 .init_verbs = { alc269_init_verbs, 13011 .init_verbs = { alc269_init_verbs,
12681 alc269_eeepc_dmic_init_verbs }, 13012 alc269_eeepc_dmic_init_verbs },
@@ -12740,13 +13071,26 @@ static int patch_alc269(struct hda_codec *codec)
12740 } 13071 }
12741 } 13072 }
12742 13073
13074 err = snd_hda_attach_beep_device(codec, 0x1);
13075 if (err < 0) {
13076 alc_free(codec);
13077 return err;
13078 }
13079
12743 if (board_config != ALC269_AUTO) 13080 if (board_config != ALC269_AUTO)
12744 setup_preset(spec, &alc269_presets[board_config]); 13081 setup_preset(spec, &alc269_presets[board_config]);
12745 13082
12746 spec->stream_name_analog = "ALC269 Analog"; 13083 spec->stream_name_analog = "ALC269 Analog";
12747 spec->stream_analog_playback = &alc269_pcm_analog_playback; 13084 if (codec->subsystem_id == 0x17aa3bf8) {
12748 spec->stream_analog_capture = &alc269_pcm_analog_capture; 13085 /* Due to a hardware problem on Lenovo Ideadpad, we need to
12749 13086 * fix the sample rate of analog I/O to 44.1kHz
13087 */
13088 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13089 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13090 } else {
13091 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13092 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13093 }
12750 spec->stream_name_digital = "ALC269 Digital"; 13094 spec->stream_name_digital = "ALC269 Digital";
12751 spec->stream_digital_playback = &alc269_pcm_digital_playback; 13095 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12752 spec->stream_digital_capture = &alc269_pcm_digital_capture; 13096 spec->stream_digital_capture = &alc269_pcm_digital_capture;
@@ -12756,6 +13100,7 @@ static int patch_alc269(struct hda_codec *codec)
12756 spec->capsrc_nids = alc269_capsrc_nids; 13100 spec->capsrc_nids = alc269_capsrc_nids;
12757 if (!spec->cap_mixer) 13101 if (!spec->cap_mixer)
12758 set_capture_mixer(spec); 13102 set_capture_mixer(spec);
13103 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
12759 13104
12760 codec->patch_ops = alc_patch_ops; 13105 codec->patch_ops = alc_patch_ops;
12761 if (board_config == ALC269_AUTO) 13106 if (board_config == ALC269_AUTO)
@@ -13006,8 +13351,6 @@ static struct snd_kcontrol_new alc861_asus_mixer[] = {
13006static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = { 13351static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
13007 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), 13352 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13008 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), 13353 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13009 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
13010 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
13011 { } 13354 { }
13012}; 13355};
13013 13356
@@ -13481,7 +13824,7 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13481static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, 13824static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13482 const struct auto_pin_cfg *cfg) 13825 const struct auto_pin_cfg *cfg)
13483{ 13826{
13484 struct hda_input_mux *imux = &spec->private_imux; 13827 struct hda_input_mux *imux = &spec->private_imux[0];
13485 int i, err, idx, idx1; 13828 int i, err, idx, idx1;
13486 13829
13487 for (i = 0; i < AUTO_PIN_LAST; i++) { 13830 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -13568,12 +13911,8 @@ static void alc861_auto_init_analog_input(struct hda_codec *codec)
13568 13911
13569 for (i = 0; i < AUTO_PIN_LAST; i++) { 13912 for (i = 0; i < AUTO_PIN_LAST; i++) {
13570 hda_nid_t nid = spec->autocfg.input_pins[i]; 13913 hda_nid_t nid = spec->autocfg.input_pins[i];
13571 if (nid >= 0x0c && nid <= 0x11) { 13914 if (nid >= 0x0c && nid <= 0x11)
13572 snd_hda_codec_write(codec, nid, 0, 13915 alc_set_input_pin(codec, nid, i);
13573 AC_VERB_SET_PIN_WIDGET_CONTROL,
13574 i <= AUTO_PIN_FRONT_MIC ?
13575 PIN_VREF80 : PIN_IN);
13576 }
13577 } 13916 }
13578} 13917}
13579 13918
@@ -13609,7 +13948,7 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
13609 13948
13610 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 13949 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13611 13950
13612 if (spec->autocfg.dig_out_pin) 13951 if (spec->autocfg.dig_outs)
13613 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; 13952 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13614 13953
13615 if (spec->kctls.list) 13954 if (spec->kctls.list)
@@ -13618,13 +13957,12 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
13618 add_verb(spec, alc861_auto_init_verbs); 13957 add_verb(spec, alc861_auto_init_verbs);
13619 13958
13620 spec->num_mux_defs = 1; 13959 spec->num_mux_defs = 1;
13621 spec->input_mux = &spec->private_imux; 13960 spec->input_mux = &spec->private_imux[0];
13622 13961
13623 spec->adc_nids = alc861_adc_nids; 13962 spec->adc_nids = alc861_adc_nids;
13624 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 13963 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
13625 set_capture_mixer(spec); 13964 set_capture_mixer(spec);
13626 13965
13627 store_pin_configs(codec);
13628 return 1; 13966 return 1;
13629} 13967}
13630 13968
@@ -13833,6 +14171,12 @@ static int patch_alc861(struct hda_codec *codec)
13833 } 14171 }
13834 } 14172 }
13835 14173
14174 err = snd_hda_attach_beep_device(codec, 0x23);
14175 if (err < 0) {
14176 alc_free(codec);
14177 return err;
14178 }
14179
13836 if (board_config != ALC861_AUTO) 14180 if (board_config != ALC861_AUTO)
13837 setup_preset(spec, &alc861_presets[board_config]); 14181 setup_preset(spec, &alc861_presets[board_config]);
13838 14182
@@ -13844,6 +14188,8 @@ static int patch_alc861(struct hda_codec *codec)
13844 spec->stream_digital_playback = &alc861_pcm_digital_playback; 14188 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13845 spec->stream_digital_capture = &alc861_pcm_digital_capture; 14189 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13846 14190
14191 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14192
13847 spec->vmaster_nid = 0x03; 14193 spec->vmaster_nid = 0x03;
13848 14194
13849 codec->patch_ops = alc_patch_ops; 14195 codec->patch_ops = alc_patch_ops;
@@ -14000,9 +14346,6 @@ static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14000 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 14346 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14001 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 14347 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14002 14348
14003 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14004 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14005
14006 { } /* end */ 14349 { } /* end */
14007}; 14350};
14008 14351
@@ -14026,9 +14369,6 @@ static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14026 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), 14369 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14027 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), 14370 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14028 14371
14029 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14030 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14031
14032 { } /* end */ 14372 { } /* end */
14033}; 14373};
14034 14374
@@ -14067,8 +14407,6 @@ static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
14067 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT), 14407 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14068 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 14408 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14069 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 14409 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14070 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
14071 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
14072 { } /* end */ 14410 { } /* end */
14073}; 14411};
14074 14412
@@ -14379,9 +14717,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
14379 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 14717 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
14380 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 14718 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
14381 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 14719 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
14382 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO), 14720 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
14383 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
14384 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
14385 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG), 14721 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
14386 {} 14722 {}
14387}; 14723};
@@ -14543,10 +14879,7 @@ static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14543 for (i = 0; i < AUTO_PIN_LAST; i++) { 14879 for (i = 0; i < AUTO_PIN_LAST; i++) {
14544 hda_nid_t nid = spec->autocfg.input_pins[i]; 14880 hda_nid_t nid = spec->autocfg.input_pins[i];
14545 if (alc861vd_is_input_pin(nid)) { 14881 if (alc861vd_is_input_pin(nid)) {
14546 snd_hda_codec_write(codec, nid, 0, 14882 alc_set_input_pin(codec, nid, i);
14547 AC_VERB_SET_PIN_WIDGET_CONTROL,
14548 i <= AUTO_PIN_FRONT_MIC ?
14549 PIN_VREF80 : PIN_IN);
14550 if (nid != ALC861VD_PIN_CD_NID) 14883 if (nid != ALC861VD_PIN_CD_NID)
14551 snd_hda_codec_write(codec, nid, 0, 14884 snd_hda_codec_write(codec, nid, 0,
14552 AC_VERB_SET_AMP_GAIN_MUTE, 14885 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -14713,7 +15046,7 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
14713 15046
14714 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 15047 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14715 15048
14716 if (spec->autocfg.dig_out_pin) 15049 if (spec->autocfg.dig_outs)
14717 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID; 15050 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14718 15051
14719 if (spec->kctls.list) 15052 if (spec->kctls.list)
@@ -14722,13 +15055,12 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
14722 add_verb(spec, alc861vd_volume_init_verbs); 15055 add_verb(spec, alc861vd_volume_init_verbs);
14723 15056
14724 spec->num_mux_defs = 1; 15057 spec->num_mux_defs = 1;
14725 spec->input_mux = &spec->private_imux; 15058 spec->input_mux = &spec->private_imux[0];
14726 15059
14727 err = alc_auto_add_mic_boost(codec); 15060 err = alc_auto_add_mic_boost(codec);
14728 if (err < 0) 15061 if (err < 0)
14729 return err; 15062 return err;
14730 15063
14731 store_pin_configs(codec);
14732 return 1; 15064 return 1;
14733} 15065}
14734 15066
@@ -14779,6 +15111,12 @@ static int patch_alc861vd(struct hda_codec *codec)
14779 } 15111 }
14780 } 15112 }
14781 15113
15114 err = snd_hda_attach_beep_device(codec, 0x23);
15115 if (err < 0) {
15116 alc_free(codec);
15117 return err;
15118 }
15119
14782 if (board_config != ALC861VD_AUTO) 15120 if (board_config != ALC861VD_AUTO)
14783 setup_preset(spec, &alc861vd_presets[board_config]); 15121 setup_preset(spec, &alc861vd_presets[board_config]);
14784 15122
@@ -14801,9 +15139,10 @@ static int patch_alc861vd(struct hda_codec *codec)
14801 spec->adc_nids = alc861vd_adc_nids; 15139 spec->adc_nids = alc861vd_adc_nids;
14802 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 15140 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
14803 spec->capsrc_nids = alc861vd_capsrc_nids; 15141 spec->capsrc_nids = alc861vd_capsrc_nids;
14804 spec->is_mix_capture = 1; 15142 spec->capture_style = CAPT_MIX;
14805 15143
14806 set_capture_mixer(spec); 15144 set_capture_mixer(spec);
15145 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
14807 15146
14808 spec->vmaster_nid = 0x02; 15147 spec->vmaster_nid = 0x02;
14809 15148
@@ -14992,8 +15331,6 @@ static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 15331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14993 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 15332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14994 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 15333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14995 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14996 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
14997 { } /* end */ 15334 { } /* end */
14998}; 15335};
14999 15336
@@ -15015,8 +15352,6 @@ static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), 15352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15016 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT), 15353 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15017 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT), 15354 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15018 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
15019 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
15020 { } /* end */ 15355 { } /* end */
15021}; 15356};
15022 15357
@@ -15992,56 +16327,55 @@ static const char *alc662_models[ALC662_MODEL_LAST] = {
15992}; 16327};
15993 16328
15994static struct snd_pci_quirk alc662_cfg_tbl[] = { 16329static struct snd_pci_quirk alc662_cfg_tbl[] = {
15995 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA), 16330 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15996 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
15997 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
15998 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
15999 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16000 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16001 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
16002 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1), 16331 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16003 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1), 16332 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16004 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1), 16333 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16005 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
16006 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1), 16334 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16335 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16007 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1), 16336 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16008 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16009 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16010 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16011 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2), 16337 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16012 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2), 16338 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16013 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2), 16339 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16340 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16341 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16342 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16014 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2), 16343 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16015 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2), 16344 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16016 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2), 16345 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16346 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16017 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2), 16347 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16018 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2), 16348 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
16019 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2), 16349 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
16020 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2), 16350 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16021 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16022 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3), 16351 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16023 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16024 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16025 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3), 16352 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16026 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3), 16353 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16354 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16355 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16356 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16357 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16358 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
16359 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
16360 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16361 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16362 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16363 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16027 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4), 16364 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
16028 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5), 16365 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
16029 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6), 16366 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
16030 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6), 16367 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
16031 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6), 16368 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16032 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K", 16369 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16033 ALC662_3ST_6ch_DIG), 16370 ALC662_3ST_6ch_DIG),
16034 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16035 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16036 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
16037 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L", 16371 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16038 ALC662_3ST_6ch_DIG), 16372 ALC662_3ST_6ch_DIG),
16039 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG), 16373 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
16374 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
16040 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0", 16375 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
16041 ALC662_3ST_6ch_DIG), 16376 ALC662_3ST_6ch_DIG),
16042 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13), 16377 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16043 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13), 16378 ALC663_ASUS_H13),
16044 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
16045 {} 16379 {}
16046}; 16380};
16047 16381
@@ -16361,7 +16695,7 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16361 16695
16362 if (alc880_is_fixed_pin(pin)) { 16696 if (alc880_is_fixed_pin(pin)) {
16363 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin)); 16697 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16364 /* printk("DAC nid=%x\n",nid); */ 16698 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
16365 /* specify the DAC as the extra output */ 16699 /* specify the DAC as the extra output */
16366 if (!spec->multiout.hp_nid) 16700 if (!spec->multiout.hp_nid)
16367 spec->multiout.hp_nid = nid; 16701 spec->multiout.hp_nid = nid;
@@ -16395,7 +16729,7 @@ static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16395static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec, 16729static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16396 const struct auto_pin_cfg *cfg) 16730 const struct auto_pin_cfg *cfg)
16397{ 16731{
16398 struct hda_input_mux *imux = &spec->private_imux; 16732 struct hda_input_mux *imux = &spec->private_imux[0];
16399 int i, err, idx; 16733 int i, err, idx;
16400 16734
16401 for (i = 0; i < AUTO_PIN_LAST; i++) { 16735 for (i = 0; i < AUTO_PIN_LAST; i++) {
@@ -16471,10 +16805,7 @@ static void alc662_auto_init_analog_input(struct hda_codec *codec)
16471 for (i = 0; i < AUTO_PIN_LAST; i++) { 16805 for (i = 0; i < AUTO_PIN_LAST; i++) {
16472 hda_nid_t nid = spec->autocfg.input_pins[i]; 16806 hda_nid_t nid = spec->autocfg.input_pins[i];
16473 if (alc662_is_input_pin(nid)) { 16807 if (alc662_is_input_pin(nid)) {
16474 snd_hda_codec_write(codec, nid, 0, 16808 alc_set_input_pin(codec, nid, i);
16475 AC_VERB_SET_PIN_WIDGET_CONTROL,
16476 (i <= AUTO_PIN_FRONT_MIC ?
16477 PIN_VREF80 : PIN_IN));
16478 if (nid != ALC662_PIN_CD_NID) 16809 if (nid != ALC662_PIN_CD_NID)
16479 snd_hda_codec_write(codec, nid, 0, 16810 snd_hda_codec_write(codec, nid, 0,
16480 AC_VERB_SET_AMP_GAIN_MUTE, 16811 AC_VERB_SET_AMP_GAIN_MUTE,
@@ -16519,14 +16850,14 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
16519 16850
16520 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 16851 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16521 16852
16522 if (spec->autocfg.dig_out_pin) 16853 if (spec->autocfg.dig_outs)
16523 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; 16854 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16524 16855
16525 if (spec->kctls.list) 16856 if (spec->kctls.list)
16526 add_mixer(spec, spec->kctls.list); 16857 add_mixer(spec, spec->kctls.list);
16527 16858
16528 spec->num_mux_defs = 1; 16859 spec->num_mux_defs = 1;
16529 spec->input_mux = &spec->private_imux; 16860 spec->input_mux = &spec->private_imux[0];
16530 16861
16531 add_verb(spec, alc662_auto_init_verbs); 16862 add_verb(spec, alc662_auto_init_verbs);
16532 if (codec->vendor_id == 0x10ec0663) 16863 if (codec->vendor_id == 0x10ec0663)
@@ -16536,7 +16867,6 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
16536 if (err < 0) 16867 if (err < 0)
16537 return err; 16868 return err;
16538 16869
16539 store_pin_configs(codec);
16540 return 1; 16870 return 1;
16541} 16871}
16542 16872
@@ -16588,6 +16918,12 @@ static int patch_alc662(struct hda_codec *codec)
16588 } 16918 }
16589 } 16919 }
16590 16920
16921 err = snd_hda_attach_beep_device(codec, 0x1);
16922 if (err < 0) {
16923 alc_free(codec);
16924 return err;
16925 }
16926
16591 if (board_config != ALC662_AUTO) 16927 if (board_config != ALC662_AUTO)
16592 setup_preset(spec, &alc662_presets[board_config]); 16928 setup_preset(spec, &alc662_presets[board_config]);
16593 16929
@@ -16611,10 +16947,14 @@ static int patch_alc662(struct hda_codec *codec)
16611 spec->adc_nids = alc662_adc_nids; 16947 spec->adc_nids = alc662_adc_nids;
16612 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 16948 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16613 spec->capsrc_nids = alc662_capsrc_nids; 16949 spec->capsrc_nids = alc662_capsrc_nids;
16614 spec->is_mix_capture = 1; 16950 spec->capture_style = CAPT_MIX;
16615 16951
16616 if (!spec->cap_mixer) 16952 if (!spec->cap_mixer)
16617 set_capture_mixer(spec); 16953 set_capture_mixer(spec);
16954 if (codec->vendor_id == 0x10ec0662)
16955 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
16956 else
16957 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
16618 16958
16619 spec->vmaster_nid = 0x02; 16959 spec->vmaster_nid = 0x02;
16620 16960
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 6094344fb223..4da72403fc87 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -43,6 +43,7 @@ enum {
43}; 43};
44 44
45enum { 45enum {
46 STAC_AUTO,
46 STAC_REF, 47 STAC_REF,
47 STAC_9200_OQO, 48 STAC_9200_OQO,
48 STAC_9200_DELL_D21, 49 STAC_9200_DELL_D21,
@@ -62,14 +63,17 @@ enum {
62}; 63};
63 64
64enum { 65enum {
66 STAC_9205_AUTO,
65 STAC_9205_REF, 67 STAC_9205_REF,
66 STAC_9205_DELL_M42, 68 STAC_9205_DELL_M42,
67 STAC_9205_DELL_M43, 69 STAC_9205_DELL_M43,
68 STAC_9205_DELL_M44, 70 STAC_9205_DELL_M44,
71 STAC_9205_EAPD,
69 STAC_9205_MODELS 72 STAC_9205_MODELS
70}; 73};
71 74
72enum { 75enum {
76 STAC_92HD73XX_AUTO,
73 STAC_92HD73XX_NO_JD, /* no jack-detection */ 77 STAC_92HD73XX_NO_JD, /* no jack-detection */
74 STAC_92HD73XX_REF, 78 STAC_92HD73XX_REF,
75 STAC_DELL_M6_AMIC, 79 STAC_DELL_M6_AMIC,
@@ -80,22 +84,27 @@ enum {
80}; 84};
81 85
82enum { 86enum {
87 STAC_92HD83XXX_AUTO,
83 STAC_92HD83XXX_REF, 88 STAC_92HD83XXX_REF,
84 STAC_92HD83XXX_PWR_REF, 89 STAC_92HD83XXX_PWR_REF,
90 STAC_DELL_S14,
85 STAC_92HD83XXX_MODELS 91 STAC_92HD83XXX_MODELS
86}; 92};
87 93
88enum { 94enum {
95 STAC_92HD71BXX_AUTO,
89 STAC_92HD71BXX_REF, 96 STAC_92HD71BXX_REF,
90 STAC_DELL_M4_1, 97 STAC_DELL_M4_1,
91 STAC_DELL_M4_2, 98 STAC_DELL_M4_2,
92 STAC_DELL_M4_3, 99 STAC_DELL_M4_3,
93 STAC_HP_M4, 100 STAC_HP_M4,
94 STAC_HP_DV5, 101 STAC_HP_DV5,
102 STAC_HP_HDX,
95 STAC_92HD71BXX_MODELS 103 STAC_92HD71BXX_MODELS
96}; 104};
97 105
98enum { 106enum {
107 STAC_925x_AUTO,
99 STAC_925x_REF, 108 STAC_925x_REF,
100 STAC_M1, 109 STAC_M1,
101 STAC_M1_2, 110 STAC_M1_2,
@@ -108,6 +117,7 @@ enum {
108}; 117};
109 118
110enum { 119enum {
120 STAC_922X_AUTO,
111 STAC_D945_REF, 121 STAC_D945_REF,
112 STAC_D945GTP3, 122 STAC_D945GTP3,
113 STAC_D945GTP5, 123 STAC_D945GTP5,
@@ -135,6 +145,7 @@ enum {
135}; 145};
136 146
137enum { 147enum {
148 STAC_927X_AUTO,
138 STAC_D965_REF_NO_JD, /* no jack-detection */ 149 STAC_D965_REF_NO_JD, /* no jack-detection */
139 STAC_D965_REF, 150 STAC_D965_REF,
140 STAC_D965_3ST, 151 STAC_D965_3ST,
@@ -144,6 +155,12 @@ enum {
144 STAC_927X_MODELS 155 STAC_927X_MODELS
145}; 156};
146 157
158enum {
159 STAC_9872_AUTO,
160 STAC_9872_VAIO,
161 STAC_9872_MODELS
162};
163
147struct sigmatel_event { 164struct sigmatel_event {
148 hda_nid_t nid; 165 hda_nid_t nid;
149 unsigned char type; 166 unsigned char type;
@@ -167,6 +184,7 @@ struct sigmatel_spec {
167 unsigned int alt_switch: 1; 184 unsigned int alt_switch: 1;
168 unsigned int hp_detect: 1; 185 unsigned int hp_detect: 1;
169 unsigned int spdif_mute: 1; 186 unsigned int spdif_mute: 1;
187 unsigned int check_volume_offset:1;
170 188
171 /* gpio lines */ 189 /* gpio lines */
172 unsigned int eapd_mask; 190 unsigned int eapd_mask;
@@ -179,6 +197,7 @@ struct sigmatel_spec {
179 unsigned int stream_delay; 197 unsigned int stream_delay;
180 198
181 /* analog loopback */ 199 /* analog loopback */
200 struct snd_kcontrol_new *aloopback_ctl;
182 unsigned char aloopback_mask; 201 unsigned char aloopback_mask;
183 unsigned char aloopback_shift; 202 unsigned char aloopback_shift;
184 203
@@ -203,6 +222,8 @@ struct sigmatel_spec {
203 hda_nid_t hp_dacs[5]; 222 hda_nid_t hp_dacs[5];
204 hda_nid_t speaker_dacs[5]; 223 hda_nid_t speaker_dacs[5];
205 224
225 int volume_offset;
226
206 /* capture */ 227 /* capture */
207 hda_nid_t *adc_nids; 228 hda_nid_t *adc_nids;
208 unsigned int num_adcs; 229 unsigned int num_adcs;
@@ -224,7 +245,6 @@ struct sigmatel_spec {
224 /* pin widgets */ 245 /* pin widgets */
225 hda_nid_t *pin_nids; 246 hda_nid_t *pin_nids;
226 unsigned int num_pins; 247 unsigned int num_pins;
227 unsigned int *pin_configs;
228 248
229 /* codec specific stuff */ 249 /* codec specific stuff */
230 struct hda_verb *init; 250 struct hda_verb *init;
@@ -400,6 +420,10 @@ static hda_nid_t stac922x_mux_nids[2] = {
400 0x12, 0x13, 420 0x12, 0x13,
401}; 421};
402 422
423static hda_nid_t stac927x_slave_dig_outs[2] = {
424 0x1f, 0,
425};
426
403static hda_nid_t stac927x_adc_nids[3] = { 427static hda_nid_t stac927x_adc_nids[3] = {
404 0x07, 0x08, 0x09 428 0x07, 0x08, 0x09
405}; 429};
@@ -472,15 +496,21 @@ static hda_nid_t stac92hd73xx_pin_nids[13] = {
472 0x14, 0x22, 0x23 496 0x14, 0x22, 0x23
473}; 497};
474 498
475static hda_nid_t stac92hd83xxx_pin_nids[14] = { 499static hda_nid_t stac92hd83xxx_pin_nids[10] = {
476 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 500 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
477 0x0f, 0x10, 0x11, 0x12, 0x13, 501 0x0f, 0x10, 0x11, 0x1f, 0x20,
478 0x1d, 0x1e, 0x1f, 0x20 502};
503
504#define STAC92HD71BXX_NUM_PINS 13
505static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
506 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
507 0x00, 0x14, 0x18, 0x19, 0x1e,
508 0x1f, 0x20, 0x27
479}; 509};
480static hda_nid_t stac92hd71bxx_pin_nids[11] = { 510static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
481 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 511 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
482 0x0f, 0x14, 0x18, 0x19, 0x1e, 512 0x0f, 0x14, 0x18, 0x19, 0x1e,
483 0x1f, 513 0x1f, 0x20, 0x27
484}; 514};
485 515
486static hda_nid_t stac927x_pin_nids[14] = { 516static hda_nid_t stac927x_pin_nids[14] = {
@@ -842,9 +872,9 @@ static struct hda_verb stac92hd73xx_10ch_core_init[] = {
842}; 872};
843 873
844static struct hda_verb stac92hd83xxx_core_init[] = { 874static struct hda_verb stac92hd83xxx_core_init[] = {
845 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0}, 875 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
846 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0}, 876 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
847 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1}, 877 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
848 878
849 /* power state controls amps */ 879 /* power state controls amps */
850 { 0x01, AC_VERB_SET_EAPD, 1 << 2}, 880 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
@@ -854,26 +884,25 @@ static struct hda_verb stac92hd83xxx_core_init[] = {
854static struct hda_verb stac92hd71bxx_core_init[] = { 884static struct hda_verb stac92hd71bxx_core_init[] = {
855 /* set master volume and direct control */ 885 /* set master volume and direct control */
856 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 886 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
857 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
858 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
859 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
860 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
861 {} 887 {}
862}; 888};
863 889
864#define HD_DISABLE_PORTF 2 890#define HD_DISABLE_PORTF 1
865static struct hda_verb stac92hd71bxx_analog_core_init[] = { 891static struct hda_verb stac92hd71bxx_analog_core_init[] = {
866 /* start of config #1 */ 892 /* start of config #1 */
867 893
868 /* connect port 0f to audio mixer */ 894 /* connect port 0f to audio mixer */
869 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2}, 895 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
870 /* unmute right and left channels for node 0x0f */
871 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
872 /* start of config #2 */ 896 /* start of config #2 */
873 897
874 /* set master volume and direct control */ 898 /* set master volume and direct control */
875 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 899 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
876 /* unmute right and left channels for nodes 0x0a, 0xd */ 900 {}
901};
902
903static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
904 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
905 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
877 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 906 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
878 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 907 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
879 {} 908 {}
@@ -954,16 +983,6 @@ static struct hda_verb stac9205_core_init[] = {
954 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \ 983 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
955 } 984 }
956 985
957#define STAC_INPUT_SOURCE(cnt) \
958 { \
959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
960 .name = "Input Source", \
961 .count = cnt, \
962 .info = stac92xx_mux_enum_info, \
963 .get = stac92xx_mux_enum_get, \
964 .put = stac92xx_mux_enum_put, \
965 }
966
967#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ 986#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
968 { \ 987 { \
969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -978,7 +997,6 @@ static struct hda_verb stac9205_core_init[] = {
978static struct snd_kcontrol_new stac9200_mixer[] = { 997static struct snd_kcontrol_new stac9200_mixer[] = {
979 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), 998 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
980 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), 999 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
981 STAC_INPUT_SOURCE(1),
982 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT), 1000 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
983 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT), 1001 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
984 { } /* end */ 1002 { } /* end */
@@ -1003,8 +1021,6 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1003 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT), 1021 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1004 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT), 1022 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1005 1023
1006 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1007
1008 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), 1024 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1009 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), 1025 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1010 1026
@@ -1014,9 +1030,22 @@ static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1014 { } /* end */ 1030 { } /* end */
1015}; 1031};
1016 1032
1017static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = { 1033static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1034 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1035 {}
1036};
1037
1038static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1018 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4), 1039 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1040 {}
1041};
1019 1042
1043static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1044 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1045 {}
1046};
1047
1048static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1020 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), 1049 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1021 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), 1050 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1022 1051
@@ -1041,8 +1070,6 @@ static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1041}; 1070};
1042 1071
1043static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = { 1072static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1044 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1045
1046 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT), 1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1047 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT), 1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1048 1075
@@ -1094,9 +1121,6 @@ static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1094}; 1121};
1095 1122
1096static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = { 1123static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1097 STAC_INPUT_SOURCE(2),
1098 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1099
1100 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1102 1126
@@ -1122,10 +1146,11 @@ static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1122 { } /* end */ 1146 { } /* end */
1123}; 1147};
1124 1148
1125static struct snd_kcontrol_new stac92hd71bxx_mixer[] = { 1149static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1126 STAC_INPUT_SOURCE(2), 1150 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1127 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2), 1151};
1128 1152
1153static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1129 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1130 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT), 1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1131 1156
@@ -1137,16 +1162,12 @@ static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1137static struct snd_kcontrol_new stac925x_mixer[] = { 1162static struct snd_kcontrol_new stac925x_mixer[] = {
1138 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), 1163 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1139 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), 1164 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1140 STAC_INPUT_SOURCE(1),
1141 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT), 1165 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1142 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT), 1166 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1143 { } /* end */ 1167 { } /* end */
1144}; 1168};
1145 1169
1146static struct snd_kcontrol_new stac9205_mixer[] = { 1170static struct snd_kcontrol_new stac9205_mixer[] = {
1147 STAC_INPUT_SOURCE(2),
1148 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1149
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT), 1171 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT), 1172 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1152 1173
@@ -1155,9 +1176,13 @@ static struct snd_kcontrol_new stac9205_mixer[] = {
1155 { } /* end */ 1176 { } /* end */
1156}; 1177};
1157 1178
1179static struct snd_kcontrol_new stac9205_loopback[] = {
1180 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1181 {}
1182};
1183
1158/* This needs to be generated dynamically based on sequence */ 1184/* This needs to be generated dynamically based on sequence */
1159static struct snd_kcontrol_new stac922x_mixer[] = { 1185static struct snd_kcontrol_new stac922x_mixer[] = {
1160 STAC_INPUT_SOURCE(2),
1161 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT), 1186 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1162 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT), 1187 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1163 1188
@@ -1168,9 +1193,6 @@ static struct snd_kcontrol_new stac922x_mixer[] = {
1168 1193
1169 1194
1170static struct snd_kcontrol_new stac927x_mixer[] = { 1195static struct snd_kcontrol_new stac927x_mixer[] = {
1171 STAC_INPUT_SOURCE(3),
1172 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1173
1174 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT), 1196 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1175 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT), 1197 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1176 1198
@@ -1182,6 +1204,11 @@ static struct snd_kcontrol_new stac927x_mixer[] = {
1182 { } /* end */ 1204 { } /* end */
1183}; 1205};
1184 1206
1207static struct snd_kcontrol_new stac927x_loopback[] = {
1208 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1209 {}
1210};
1211
1185static struct snd_kcontrol_new stac_dmux_mixer = { 1212static struct snd_kcontrol_new stac_dmux_mixer = {
1186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1187 .name = "Digital Input Source", 1214 .name = "Digital Input Source",
@@ -1207,10 +1234,7 @@ static const char *slave_vols[] = {
1207 "LFE Playback Volume", 1234 "LFE Playback Volume",
1208 "Side Playback Volume", 1235 "Side Playback Volume",
1209 "Headphone Playback Volume", 1236 "Headphone Playback Volume",
1210 "Headphone2 Playback Volume",
1211 "Speaker Playback Volume", 1237 "Speaker Playback Volume",
1212 "External Speaker Playback Volume",
1213 "Speaker2 Playback Volume",
1214 NULL 1238 NULL
1215}; 1239};
1216 1240
@@ -1221,10 +1245,7 @@ static const char *slave_sws[] = {
1221 "LFE Playback Switch", 1245 "LFE Playback Switch",
1222 "Side Playback Switch", 1246 "Side Playback Switch",
1223 "Headphone Playback Switch", 1247 "Headphone Playback Switch",
1224 "Headphone2 Playback Switch",
1225 "Speaker Playback Switch", 1248 "Speaker Playback Switch",
1226 "External Speaker Playback Switch",
1227 "Speaker2 Playback Switch",
1228 "IEC958 Playback Switch", 1249 "IEC958 Playback Switch",
1229 NULL 1250 NULL
1230}; 1251};
@@ -1294,6 +1315,8 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1294 unsigned int vmaster_tlv[4]; 1315 unsigned int vmaster_tlv[4];
1295 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0], 1316 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1296 HDA_OUTPUT, vmaster_tlv); 1317 HDA_OUTPUT, vmaster_tlv);
1318 /* correct volume offset */
1319 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1297 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 1320 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1298 vmaster_tlv, slave_vols); 1321 vmaster_tlv, slave_vols);
1299 if (err < 0) 1322 if (err < 0)
@@ -1306,6 +1329,13 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1306 return err; 1329 return err;
1307 } 1330 }
1308 1331
1332 if (spec->aloopback_ctl &&
1333 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1334 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1335 if (err < 0)
1336 return err;
1337 }
1338
1309 stac92xx_free_kctls(codec); /* no longer needed */ 1339 stac92xx_free_kctls(codec); /* no longer needed */
1310 1340
1311 /* create jack input elements */ 1341 /* create jack input elements */
@@ -1490,6 +1520,7 @@ static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1490}; 1520};
1491 1521
1492static const char *stac9200_models[STAC_9200_MODELS] = { 1522static const char *stac9200_models[STAC_9200_MODELS] = {
1523 [STAC_AUTO] = "auto",
1493 [STAC_REF] = "ref", 1524 [STAC_REF] = "ref",
1494 [STAC_9200_OQO] = "oqo", 1525 [STAC_9200_OQO] = "oqo",
1495 [STAC_9200_DELL_D21] = "dell-d21", 1526 [STAC_9200_DELL_D21] = "dell-d21",
@@ -1511,6 +1542,8 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1511 /* SigmaTel reference board */ 1542 /* SigmaTel reference board */
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1513 "DFI LanParty", STAC_REF), 1544 "DFI LanParty", STAC_REF),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1546 "DFI LanParty", STAC_REF),
1514 /* Dell laptops have BIOS problem */ 1547 /* Dell laptops have BIOS problem */
1515 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8, 1548 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1516 "unknown Dell", STAC_9200_DELL_D21), 1549 "unknown Dell", STAC_9200_DELL_D21),
@@ -1633,6 +1666,7 @@ static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1633}; 1666};
1634 1667
1635static const char *stac925x_models[STAC_925x_MODELS] = { 1668static const char *stac925x_models[STAC_925x_MODELS] = {
1669 [STAC_925x_AUTO] = "auto",
1636 [STAC_REF] = "ref", 1670 [STAC_REF] = "ref",
1637 [STAC_M1] = "m1", 1671 [STAC_M1] = "m1",
1638 [STAC_M1_2] = "m1-2", 1672 [STAC_M1_2] = "m1-2",
@@ -1660,6 +1694,7 @@ static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1660static struct snd_pci_quirk stac925x_cfg_tbl[] = { 1694static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1661 /* SigmaTel reference board */ 1695 /* SigmaTel reference board */
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF), 1696 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1663 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF), 1698 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1664 1699
1665 /* Default table for unknown ID */ 1700 /* Default table for unknown ID */
@@ -1691,6 +1726,7 @@ static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1691}; 1726};
1692 1727
1693static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1728static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1729 [STAC_92HD73XX_AUTO] = "auto",
1694 [STAC_92HD73XX_NO_JD] = "no-jd", 1730 [STAC_92HD73XX_NO_JD] = "no-jd",
1695 [STAC_92HD73XX_REF] = "ref", 1731 [STAC_92HD73XX_REF] = "ref",
1696 [STAC_DELL_M6_AMIC] = "dell-m6-amic", 1732 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
@@ -1703,6 +1739,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1703 /* SigmaTel reference board */ 1739 /* SigmaTel reference board */
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1740 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1705 "DFI LanParty", STAC_92HD73XX_REF), 1741 "DFI LanParty", STAC_92HD73XX_REF),
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1743 "DFI LanParty", STAC_92HD73XX_REF),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, 1744 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1707 "Dell Studio 1535", STAC_DELL_M6_DMIC), 1745 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, 1746 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
@@ -1726,52 +1764,68 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1726 {} /* terminator */ 1764 {} /* terminator */
1727}; 1765};
1728 1766
1729static unsigned int ref92hd83xxx_pin_configs[14] = { 1767static unsigned int ref92hd83xxx_pin_configs[10] = {
1730 0x02214030, 0x02211010, 0x02a19020, 0x02170130, 1768 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1731 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, 1769 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1732 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1733 0x01451160, 0x98560170, 1770 0x01451160, 0x98560170,
1734}; 1771};
1735 1772
1773static unsigned int dell_s14_pin_configs[10] = {
1774 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1775 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1776 0x40f000f0, 0x40f000f0,
1777};
1778
1736static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = { 1779static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1737 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs, 1780 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1738 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs, 1781 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1782 [STAC_DELL_S14] = dell_s14_pin_configs,
1739}; 1783};
1740 1784
1741static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { 1785static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1786 [STAC_92HD83XXX_AUTO] = "auto",
1742 [STAC_92HD83XXX_REF] = "ref", 1787 [STAC_92HD83XXX_REF] = "ref",
1743 [STAC_92HD83XXX_PWR_REF] = "mic-ref", 1788 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1789 [STAC_DELL_S14] = "dell-s14",
1744}; 1790};
1745 1791
1746static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { 1792static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1747 /* SigmaTel reference board */ 1793 /* SigmaTel reference board */
1748 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1794 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1749 "DFI LanParty", STAC_92HD83XXX_REF), 1795 "DFI LanParty", STAC_92HD83XXX_REF),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1797 "DFI LanParty", STAC_92HD83XXX_REF),
1798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1799 "unknown Dell", STAC_DELL_S14),
1750 {} /* terminator */ 1800 {} /* terminator */
1751}; 1801};
1752 1802
1753static unsigned int ref92hd71bxx_pin_configs[11] = { 1803static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1754 0x02214030, 0x02a19040, 0x01a19020, 0x01014010, 1804 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1755 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0, 1805 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1756 0x90a000f0, 0x01452050, 0x01452050, 1806 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1807 0x00000000
1757}; 1808};
1758 1809
1759static unsigned int dell_m4_1_pin_configs[11] = { 1810static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1760 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110, 1811 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1761 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0, 1812 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1762 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 1813 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1814 0x00000000
1763}; 1815};
1764 1816
1765static unsigned int dell_m4_2_pin_configs[11] = { 1817static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1766 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, 1818 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1767 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0, 1819 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1768 0x40f000f0, 0x044413b0, 0x044413b0, 1820 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1821 0x00000000
1769}; 1822};
1770 1823
1771static unsigned int dell_m4_3_pin_configs[11] = { 1824static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1772 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110, 1825 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1773 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0, 1826 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1774 0x40f000f0, 0x044413b0, 0x044413b0, 1827 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1828 0x00000000
1775}; 1829};
1776 1830
1777static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = { 1831static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
@@ -1781,35 +1835,38 @@ static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1781 [STAC_DELL_M4_3] = dell_m4_3_pin_configs, 1835 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1782 [STAC_HP_M4] = NULL, 1836 [STAC_HP_M4] = NULL,
1783 [STAC_HP_DV5] = NULL, 1837 [STAC_HP_DV5] = NULL,
1838 [STAC_HP_HDX] = NULL,
1784}; 1839};
1785 1840
1786static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = { 1841static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1842 [STAC_92HD71BXX_AUTO] = "auto",
1787 [STAC_92HD71BXX_REF] = "ref", 1843 [STAC_92HD71BXX_REF] = "ref",
1788 [STAC_DELL_M4_1] = "dell-m4-1", 1844 [STAC_DELL_M4_1] = "dell-m4-1",
1789 [STAC_DELL_M4_2] = "dell-m4-2", 1845 [STAC_DELL_M4_2] = "dell-m4-2",
1790 [STAC_DELL_M4_3] = "dell-m4-3", 1846 [STAC_DELL_M4_3] = "dell-m4-3",
1791 [STAC_HP_M4] = "hp-m4", 1847 [STAC_HP_M4] = "hp-m4",
1792 [STAC_HP_DV5] = "hp-dv5", 1848 [STAC_HP_DV5] = "hp-dv5",
1849 [STAC_HP_HDX] = "hp-hdx",
1793}; 1850};
1794 1851
1795static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { 1852static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1796 /* SigmaTel reference board */ 1853 /* SigmaTel reference board */
1797 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1854 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1798 "DFI LanParty", STAC_92HD71BXX_REF), 1855 "DFI LanParty", STAC_92HD71BXX_REF),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f2, 1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1800 "HP dv5", STAC_HP_M4), 1857 "DFI LanParty", STAC_92HD71BXX_REF),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, 1858 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1802 "HP dv7", STAC_HP_DV5), 1859 "HP", STAC_HP_DV5),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f7, 1860 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1804 "HP dv4", STAC_HP_DV5), 1861 "HP dv4-7", STAC_HP_DV5),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc, 1862 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1806 "HP dv7", STAC_HP_M4), 1863 "HP dv4-7", STAC_HP_DV5),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3600, 1864 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1808 "HP dv5", STAC_HP_DV5), 1865 "HP HDX", STAC_HP_HDX), /* HDX18 */
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603,
1810 "HP dv5", STAC_HP_DV5),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, 1866 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1812 "unknown HP", STAC_HP_M4), 1867 "HP mini 1000", STAC_HP_M4),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1869 "HP HDX", STAC_HP_HDX), /* HDX16 */
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, 1870 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1814 "unknown Dell", STAC_DELL_M4_1), 1871 "unknown Dell", STAC_DELL_M4_1),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, 1872 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
@@ -1961,6 +2018,7 @@ static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1961}; 2018};
1962 2019
1963static const char *stac922x_models[STAC_922X_MODELS] = { 2020static const char *stac922x_models[STAC_922X_MODELS] = {
2021 [STAC_922X_AUTO] = "auto",
1964 [STAC_D945_REF] = "ref", 2022 [STAC_D945_REF] = "ref",
1965 [STAC_D945GTP5] = "5stack", 2023 [STAC_D945GTP5] = "5stack",
1966 [STAC_D945GTP3] = "3stack", 2024 [STAC_D945GTP3] = "3stack",
@@ -1988,6 +2046,8 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1988 /* SigmaTel reference board */ 2046 /* SigmaTel reference board */
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1990 "DFI LanParty", STAC_D945_REF), 2048 "DFI LanParty", STAC_D945_REF),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2050 "DFI LanParty", STAC_D945_REF),
1991 /* Intel 945G based systems */ 2051 /* Intel 945G based systems */
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101, 2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1993 "Intel D945G", STAC_D945GTP3), 2053 "Intel D945G", STAC_D945GTP3),
@@ -2041,6 +2101,9 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2041 "Intel D945P", STAC_D945GTP3), 2101 "Intel D945P", STAC_D945GTP3),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707, 2102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2043 "Intel D945P", STAC_D945GTP5), 2103 "Intel D945P", STAC_D945GTP5),
2104 /* other intel */
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2106 "Intel D945", STAC_D945_REF),
2044 /* other systems */ 2107 /* other systems */
2045 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */ 2108 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2046 SND_PCI_QUIRK(0x8384, 0x7680, 2109 SND_PCI_QUIRK(0x8384, 0x7680,
@@ -2065,31 +2128,7 @@ static struct snd_pci_quirk stac922x_cfg_tbl[] = {
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7, 2128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2066 "Dell XPS M1210", STAC_922X_DELL_M82), 2129 "Dell XPS M1210", STAC_922X_DELL_M82),
2067 /* ECS/PC Chips boards */ 2130 /* ECS/PC Chips boards */
2068 SND_PCI_QUIRK(0x1019, 0x2144, 2131 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2069 "ECS/PC chips", STAC_ECS_202),
2070 SND_PCI_QUIRK(0x1019, 0x2608,
2071 "ECS/PC chips", STAC_ECS_202),
2072 SND_PCI_QUIRK(0x1019, 0x2633,
2073 "ECS/PC chips P17G/1333", STAC_ECS_202),
2074 SND_PCI_QUIRK(0x1019, 0x2811,
2075 "ECS/PC chips", STAC_ECS_202),
2076 SND_PCI_QUIRK(0x1019, 0x2812,
2077 "ECS/PC chips", STAC_ECS_202),
2078 SND_PCI_QUIRK(0x1019, 0x2813,
2079 "ECS/PC chips", STAC_ECS_202),
2080 SND_PCI_QUIRK(0x1019, 0x2814,
2081 "ECS/PC chips", STAC_ECS_202),
2082 SND_PCI_QUIRK(0x1019, 0x2815,
2083 "ECS/PC chips", STAC_ECS_202),
2084 SND_PCI_QUIRK(0x1019, 0x2816,
2085 "ECS/PC chips", STAC_ECS_202),
2086 SND_PCI_QUIRK(0x1019, 0x2817,
2087 "ECS/PC chips", STAC_ECS_202),
2088 SND_PCI_QUIRK(0x1019, 0x2818,
2089 "ECS/PC chips", STAC_ECS_202),
2090 SND_PCI_QUIRK(0x1019, 0x2819,
2091 "ECS/PC chips", STAC_ECS_202),
2092 SND_PCI_QUIRK(0x1019, 0x2820,
2093 "ECS/PC chips", STAC_ECS_202), 2132 "ECS/PC chips", STAC_ECS_202),
2094 {} /* terminator */ 2133 {} /* terminator */
2095}; 2134};
@@ -2132,6 +2171,7 @@ static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2132}; 2171};
2133 2172
2134static const char *stac927x_models[STAC_927X_MODELS] = { 2173static const char *stac927x_models[STAC_927X_MODELS] = {
2174 [STAC_927X_AUTO] = "auto",
2135 [STAC_D965_REF_NO_JD] = "ref-no-jd", 2175 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2136 [STAC_D965_REF] = "ref", 2176 [STAC_D965_REF] = "ref",
2137 [STAC_D965_3ST] = "3stack", 2177 [STAC_D965_3ST] = "3stack",
@@ -2144,26 +2184,16 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2144 /* SigmaTel reference board */ 2184 /* SigmaTel reference board */
2145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2146 "DFI LanParty", STAC_D965_REF), 2186 "DFI LanParty", STAC_D965_REF),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2188 "DFI LanParty", STAC_D965_REF),
2147 /* Intel 946 based systems */ 2189 /* Intel 946 based systems */
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST), 2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2149 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST), 2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2150 /* 965 based 3 stack systems */ 2192 /* 965 based 3 stack systems */
2151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST), 2193 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST), 2194 "Intel D965", STAC_D965_3ST),
2153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST), 2195 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST), 2196 "Intel D965", STAC_D965_3ST),
2155 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2167 /* Dell 3 stack systems */ 2197 /* Dell 3 stack systems */
2168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST), 2198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST), 2199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
@@ -2179,15 +2209,10 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), 2209 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS), 2210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2181 /* 965 based 5 stack systems */ 2211 /* 965 based 5 stack systems */
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST), 2212 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST), 2213 "Intel D965", STAC_D965_5ST),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST), 2214 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST), 2215 "Intel D965", STAC_D965_5ST),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2187 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2189 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2191 {} /* terminator */ 2216 {} /* terminator */
2192}; 2217};
2193 2218
@@ -2240,19 +2265,25 @@ static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2240 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs, 2265 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2241 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs, 2266 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2242 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs, 2267 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2268 [STAC_9205_EAPD] = NULL,
2243}; 2269};
2244 2270
2245static const char *stac9205_models[STAC_9205_MODELS] = { 2271static const char *stac9205_models[STAC_9205_MODELS] = {
2272 [STAC_9205_AUTO] = "auto",
2246 [STAC_9205_REF] = "ref", 2273 [STAC_9205_REF] = "ref",
2247 [STAC_9205_DELL_M42] = "dell-m42", 2274 [STAC_9205_DELL_M42] = "dell-m42",
2248 [STAC_9205_DELL_M43] = "dell-m43", 2275 [STAC_9205_DELL_M43] = "dell-m43",
2249 [STAC_9205_DELL_M44] = "dell-m44", 2276 [STAC_9205_DELL_M44] = "dell-m44",
2277 [STAC_9205_EAPD] = "eapd",
2250}; 2278};
2251 2279
2252static struct snd_pci_quirk stac9205_cfg_tbl[] = { 2280static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2253 /* SigmaTel reference board */ 2281 /* SigmaTel reference board */
2254 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2282 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2255 "DFI LanParty", STAC_9205_REF), 2283 "DFI LanParty", STAC_9205_REF),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2285 "DFI LanParty", STAC_9205_REF),
2286 /* Dell */
2256 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1, 2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2257 "unknown Dell", STAC_9205_DELL_M42), 2288 "unknown Dell", STAC_9205_DELL_M42),
2258 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2, 2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
@@ -2283,101 +2314,24 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2283 "Dell Inspiron", STAC_9205_DELL_M44), 2314 "Dell Inspiron", STAC_9205_DELL_M44),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, 2315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2285 "Dell Vostro 1500", STAC_9205_DELL_M42), 2316 "Dell Vostro 1500", STAC_9205_DELL_M42),
2317 /* Gateway */
2318 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2286 {} /* terminator */ 2319 {} /* terminator */
2287}; 2320};
2288 2321
2289static int stac92xx_save_bios_config_regs(struct hda_codec *codec) 2322static void stac92xx_set_config_regs(struct hda_codec *codec,
2323 unsigned int *pincfgs)
2290{ 2324{
2291 int i; 2325 int i;
2292 struct sigmatel_spec *spec = codec->spec; 2326 struct sigmatel_spec *spec = codec->spec;
2293
2294 kfree(spec->pin_configs);
2295 spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs),
2296 GFP_KERNEL);
2297 if (!spec->pin_configs)
2298 return -ENOMEM;
2299
2300 for (i = 0; i < spec->num_pins; i++) {
2301 hda_nid_t nid = spec->pin_nids[i];
2302 unsigned int pin_cfg;
2303
2304 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2305 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2306 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2307 nid, pin_cfg);
2308 spec->pin_configs[i] = pin_cfg;
2309 }
2310
2311 return 0;
2312}
2313 2327
2314static void stac92xx_set_config_reg(struct hda_codec *codec, 2328 if (!pincfgs)
2315 hda_nid_t pin_nid, unsigned int pin_config) 2329 return;
2316{
2317 int i;
2318 snd_hda_codec_write(codec, pin_nid, 0,
2319 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2320 pin_config & 0x000000ff);
2321 snd_hda_codec_write(codec, pin_nid, 0,
2322 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2323 (pin_config & 0x0000ff00) >> 8);
2324 snd_hda_codec_write(codec, pin_nid, 0,
2325 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2326 (pin_config & 0x00ff0000) >> 16);
2327 snd_hda_codec_write(codec, pin_nid, 0,
2328 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2329 pin_config >> 24);
2330 i = snd_hda_codec_read(codec, pin_nid, 0,
2331 AC_VERB_GET_CONFIG_DEFAULT,
2332 0x00);
2333 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2334 pin_nid, i);
2335}
2336
2337static void stac92xx_set_config_regs(struct hda_codec *codec)
2338{
2339 int i;
2340 struct sigmatel_spec *spec = codec->spec;
2341
2342 if (!spec->pin_configs)
2343 return;
2344 2330
2345 for (i = 0; i < spec->num_pins; i++) 2331 for (i = 0; i < spec->num_pins; i++)
2346 stac92xx_set_config_reg(codec, spec->pin_nids[i], 2332 if (spec->pin_nids[i] && pincfgs[i])
2347 spec->pin_configs[i]); 2333 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2348} 2334 pincfgs[i]);
2349
2350static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins)
2351{
2352 struct sigmatel_spec *spec = codec->spec;
2353
2354 if (!pins)
2355 return stac92xx_save_bios_config_regs(codec);
2356
2357 kfree(spec->pin_configs);
2358 spec->pin_configs = kmemdup(pins,
2359 spec->num_pins * sizeof(*pins),
2360 GFP_KERNEL);
2361 if (!spec->pin_configs)
2362 return -ENOMEM;
2363
2364 stac92xx_set_config_regs(codec);
2365 return 0;
2366}
2367
2368static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid,
2369 unsigned int cfg)
2370{
2371 struct sigmatel_spec *spec = codec->spec;
2372 int i;
2373
2374 for (i = 0; i < spec->num_pins; i++) {
2375 if (spec->pin_nids[i] == nid) {
2376 spec->pin_configs[i] = cfg;
2377 stac92xx_set_config_reg(codec, nid, cfg);
2378 break;
2379 }
2380 }
2381} 2335}
2382 2336
2383/* 2337/*
@@ -2567,7 +2521,7 @@ static int stac92xx_build_pcms(struct hda_codec *codec)
2567 codec->num_pcms++; 2521 codec->num_pcms++;
2568 info++; 2522 info++;
2569 info->name = "STAC92xx Digital"; 2523 info->name = "STAC92xx Digital";
2570 info->pcm_type = HDA_PCM_TYPE_SPDIF; 2524 info->pcm_type = spec->autocfg.dig_out_type[0];
2571 if (spec->multiout.dig_out_nid) { 2525 if (spec->multiout.dig_out_nid) {
2572 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback; 2526 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2573 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; 2527 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
@@ -2759,22 +2713,37 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2759}; 2713};
2760 2714
2761/* add dynamic controls */ 2715/* add dynamic controls */
2762static int stac92xx_add_control_temp(struct sigmatel_spec *spec, 2716static struct snd_kcontrol_new *
2763 struct snd_kcontrol_new *ktemp, 2717stac_control_new(struct sigmatel_spec *spec,
2764 int idx, const char *name, 2718 struct snd_kcontrol_new *ktemp,
2765 unsigned long val) 2719 const char *name)
2766{ 2720{
2767 struct snd_kcontrol_new *knew; 2721 struct snd_kcontrol_new *knew;
2768 2722
2769 snd_array_init(&spec->kctls, sizeof(*knew), 32); 2723 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2770 knew = snd_array_new(&spec->kctls); 2724 knew = snd_array_new(&spec->kctls);
2771 if (!knew) 2725 if (!knew)
2772 return -ENOMEM; 2726 return NULL;
2773 *knew = *ktemp; 2727 *knew = *ktemp;
2774 knew->index = idx;
2775 knew->name = kstrdup(name, GFP_KERNEL); 2728 knew->name = kstrdup(name, GFP_KERNEL);
2776 if (!knew->name) 2729 if (!knew->name) {
2730 /* roolback */
2731 memset(knew, 0, sizeof(*knew));
2732 spec->kctls.alloced--;
2733 return NULL;
2734 }
2735 return knew;
2736}
2737
2738static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2739 struct snd_kcontrol_new *ktemp,
2740 int idx, const char *name,
2741 unsigned long val)
2742{
2743 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2744 if (!knew)
2777 return -ENOMEM; 2745 return -ENOMEM;
2746 knew->index = idx;
2778 knew->private_value = val; 2747 knew->private_value = val;
2779 return 0; 2748 return 0;
2780} 2749}
@@ -2796,6 +2765,29 @@ static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2796 return stac92xx_add_control_idx(spec, type, 0, name, val); 2765 return stac92xx_add_control_idx(spec, type, 0, name, val);
2797} 2766}
2798 2767
2768static struct snd_kcontrol_new stac_input_src_temp = {
2769 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2770 .name = "Input Source",
2771 .info = stac92xx_mux_enum_info,
2772 .get = stac92xx_mux_enum_get,
2773 .put = stac92xx_mux_enum_put,
2774};
2775
2776static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2777{
2778 struct snd_kcontrol_new *knew;
2779 struct hda_input_mux *imux = &spec->private_imux;
2780
2781 if (!spec->num_adcs || imux->num_items <= 1)
2782 return 0; /* no need for input source control */
2783 knew = stac_control_new(spec, &stac_input_src_temp,
2784 stac_input_src_temp.name);
2785 if (!knew)
2786 return -ENOMEM;
2787 knew->count = spec->num_adcs;
2788 return 0;
2789}
2790
2799/* check whether the line-input can be used as line-out */ 2791/* check whether the line-input can be used as line-out */
2800static hda_nid_t check_line_out_switch(struct hda_codec *codec) 2792static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2801{ 2793{
@@ -2826,8 +2818,7 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2826 mic_pin = AUTO_PIN_MIC; 2818 mic_pin = AUTO_PIN_MIC;
2827 for (;;) { 2819 for (;;) {
2828 hda_nid_t nid = cfg->input_pins[mic_pin]; 2820 hda_nid_t nid = cfg->input_pins[mic_pin];
2829 def_conf = snd_hda_codec_read(codec, nid, 0, 2821 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2830 AC_VERB_GET_CONFIG_DEFAULT, 0);
2831 /* some laptops have an internal analog microphone 2822 /* some laptops have an internal analog microphone
2832 * which can't be used as a output */ 2823 * which can't be used as a output */
2833 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { 2824 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
@@ -2895,6 +2886,16 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2895 return conn[j]; 2886 return conn[j];
2896 } 2887 }
2897 } 2888 }
2889 /* if all DACs are already assigned, connect to the primary DAC */
2890 if (conn_len > 1) {
2891 for (j = 0; j < conn_len; j++) {
2892 if (conn[j] == spec->multiout.dac_nids[0]) {
2893 snd_hda_codec_write_cache(codec, nid, 0,
2894 AC_VERB_SET_CONNECT_SEL, j);
2895 break;
2896 }
2897 }
2898 }
2898 return 0; 2899 return 0;
2899} 2900}
2900 2901
@@ -2935,6 +2936,26 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2935 add_spec_dacs(spec, dac); 2936 add_spec_dacs(spec, dac);
2936 } 2937 }
2937 2938
2939 for (i = 0; i < cfg->hp_outs; i++) {
2940 nid = cfg->hp_pins[i];
2941 dac = get_unassigned_dac(codec, nid);
2942 if (dac) {
2943 if (!spec->multiout.hp_nid)
2944 spec->multiout.hp_nid = dac;
2945 else
2946 add_spec_extra_dacs(spec, dac);
2947 }
2948 spec->hp_dacs[i] = dac;
2949 }
2950
2951 for (i = 0; i < cfg->speaker_outs; i++) {
2952 nid = cfg->speaker_pins[i];
2953 dac = get_unassigned_dac(codec, nid);
2954 if (dac)
2955 add_spec_extra_dacs(spec, dac);
2956 spec->speaker_dacs[i] = dac;
2957 }
2958
2938 /* add line-in as output */ 2959 /* add line-in as output */
2939 nid = check_line_out_switch(codec); 2960 nid = check_line_out_switch(codec);
2940 if (nid) { 2961 if (nid) {
@@ -2962,26 +2983,6 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2962 } 2983 }
2963 } 2984 }
2964 2985
2965 for (i = 0; i < cfg->hp_outs; i++) {
2966 nid = cfg->hp_pins[i];
2967 dac = get_unassigned_dac(codec, nid);
2968 if (dac) {
2969 if (!spec->multiout.hp_nid)
2970 spec->multiout.hp_nid = dac;
2971 else
2972 add_spec_extra_dacs(spec, dac);
2973 }
2974 spec->hp_dacs[i] = dac;
2975 }
2976
2977 for (i = 0; i < cfg->speaker_outs; i++) {
2978 nid = cfg->speaker_pins[i];
2979 dac = get_unassigned_dac(codec, nid);
2980 if (dac)
2981 add_spec_extra_dacs(spec, dac);
2982 spec->speaker_dacs[i] = dac;
2983 }
2984
2985 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", 2986 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2986 spec->multiout.num_dacs, 2987 spec->multiout.num_dacs,
2987 spec->multiout.dac_nids[0], 2988 spec->multiout.dac_nids[0],
@@ -2994,24 +2995,47 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2994} 2995}
2995 2996
2996/* create volume control/switch for the given prefx type */ 2997/* create volume control/switch for the given prefx type */
2997static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs) 2998static int create_controls_idx(struct hda_codec *codec, const char *pfx,
2999 int idx, hda_nid_t nid, int chs)
2998{ 3000{
3001 struct sigmatel_spec *spec = codec->spec;
2999 char name[32]; 3002 char name[32];
3000 int err; 3003 int err;
3001 3004
3005 if (!spec->check_volume_offset) {
3006 unsigned int caps, step, nums, db_scale;
3007 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3008 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3009 AC_AMPCAP_STEP_SIZE_SHIFT;
3010 step = (step + 1) * 25; /* in .01dB unit */
3011 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3012 AC_AMPCAP_NUM_STEPS_SHIFT;
3013 db_scale = nums * step;
3014 /* if dB scale is over -64dB, and finer enough,
3015 * let's reduce it to half
3016 */
3017 if (db_scale > 6400 && nums >= 0x1f)
3018 spec->volume_offset = nums / 2;
3019 spec->check_volume_offset = 1;
3020 }
3021
3002 sprintf(name, "%s Playback Volume", pfx); 3022 sprintf(name, "%s Playback Volume", pfx);
3003 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name, 3023 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3004 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); 3024 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3025 spec->volume_offset));
3005 if (err < 0) 3026 if (err < 0)
3006 return err; 3027 return err;
3007 sprintf(name, "%s Playback Switch", pfx); 3028 sprintf(name, "%s Playback Switch", pfx);
3008 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name, 3029 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3009 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT)); 3030 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3010 if (err < 0) 3031 if (err < 0)
3011 return err; 3032 return err;
3012 return 0; 3033 return 0;
3013} 3034}
3014 3035
3036#define create_controls(codec, pfx, nid, chs) \
3037 create_controls_idx(codec, pfx, 0, nid, chs)
3038
3015static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) 3039static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3016{ 3040{
3017 if (spec->multiout.num_dacs > 4) { 3041 if (spec->multiout.num_dacs > 4) {
@@ -3037,40 +3061,32 @@ static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3037 return 1; 3061 return 1;
3038} 3062}
3039 3063
3040static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid) 3064/* Create output controls
3041{ 3065 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3042 int i; 3066 */
3043 3067static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3044 if (spec->autocfg.line_outs != 1) 3068 const hda_nid_t *pins,
3045 return 0; 3069 const hda_nid_t *dac_nids,
3046 if (spec->multiout.hp_nid == nid) 3070 int type)
3047 return 0;
3048 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++)
3049 if (spec->multiout.extra_out_nid[i] == nid)
3050 return 0;
3051 return 1;
3052}
3053
3054/* add playback controls from the parsed DAC table */
3055static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3056 const struct auto_pin_cfg *cfg)
3057{ 3071{
3058 struct sigmatel_spec *spec = codec->spec; 3072 struct sigmatel_spec *spec = codec->spec;
3059 static const char *chname[4] = { 3073 static const char *chname[4] = {
3060 "Front", "Surround", NULL /*CLFE*/, "Side" 3074 "Front", "Surround", NULL /*CLFE*/, "Side"
3061 }; 3075 };
3062 hda_nid_t nid = 0; 3076 hda_nid_t nid;
3063 int i, err; 3077 int i, err;
3064 unsigned int wid_caps; 3078 unsigned int wid_caps;
3065 3079
3066 for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) { 3080 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3067 nid = spec->multiout.dac_nids[i]; 3081 nid = dac_nids[i];
3068 if (i == 2) { 3082 if (!nid)
3083 continue;
3084 if (type != AUTO_PIN_HP_OUT && i == 2) {
3069 /* Center/LFE */ 3085 /* Center/LFE */
3070 err = create_controls(spec, "Center", nid, 1); 3086 err = create_controls(codec, "Center", nid, 1);
3071 if (err < 0) 3087 if (err < 0)
3072 return err; 3088 return err;
3073 err = create_controls(spec, "LFE", nid, 2); 3089 err = create_controls(codec, "LFE", nid, 2);
3074 if (err < 0) 3090 if (err < 0)
3075 return err; 3091 return err;
3076 3092
@@ -3086,23 +3102,47 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3086 } 3102 }
3087 3103
3088 } else { 3104 } else {
3089 const char *name = chname[i]; 3105 const char *name;
3090 /* if it's a single DAC, assign a better name */ 3106 int idx;
3091 if (!i && is_unique_dac(spec, nid)) { 3107 switch (type) {
3092 switch (cfg->line_out_type) { 3108 case AUTO_PIN_HP_OUT:
3093 case AUTO_PIN_HP_OUT: 3109 name = "Headphone";
3094 name = "Headphone"; 3110 idx = i;
3095 break; 3111 break;
3096 case AUTO_PIN_SPEAKER_OUT: 3112 case AUTO_PIN_SPEAKER_OUT:
3097 name = "Speaker"; 3113 name = "Speaker";
3098 break; 3114 idx = i;
3099 } 3115 break;
3116 default:
3117 name = chname[i];
3118 idx = 0;
3119 break;
3100 } 3120 }
3101 err = create_controls(spec, name, nid, 3); 3121 err = create_controls_idx(codec, name, idx, nid, 3);
3102 if (err < 0) 3122 if (err < 0)
3103 return err; 3123 return err;
3124 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3125 wid_caps = get_wcaps(codec, pins[i]);
3126 if (wid_caps & AC_WCAP_UNSOL_CAP)
3127 spec->hp_detect = 1;
3128 }
3104 } 3129 }
3105 } 3130 }
3131 return 0;
3132}
3133
3134/* add playback controls from the parsed DAC table */
3135static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3136 const struct auto_pin_cfg *cfg)
3137{
3138 struct sigmatel_spec *spec = codec->spec;
3139 int err;
3140
3141 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3142 spec->multiout.dac_nids,
3143 cfg->line_out_type);
3144 if (err < 0)
3145 return err;
3106 3146
3107 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { 3147 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3108 err = stac92xx_add_control(spec, 3148 err = stac92xx_add_control(spec,
@@ -3137,40 +3177,18 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3137 struct auto_pin_cfg *cfg) 3177 struct auto_pin_cfg *cfg)
3138{ 3178{
3139 struct sigmatel_spec *spec = codec->spec; 3179 struct sigmatel_spec *spec = codec->spec;
3140 hda_nid_t nid; 3180 int err;
3141 int i, err, nums; 3181
3182 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3183 spec->hp_dacs, AUTO_PIN_HP_OUT);
3184 if (err < 0)
3185 return err;
3186
3187 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3188 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3189 if (err < 0)
3190 return err;
3142 3191
3143 nums = 0;
3144 for (i = 0; i < cfg->hp_outs; i++) {
3145 static const char *pfxs[] = {
3146 "Headphone", "Headphone2", "Headphone3",
3147 };
3148 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
3149 if (wid_caps & AC_WCAP_UNSOL_CAP)
3150 spec->hp_detect = 1;
3151 if (nums >= ARRAY_SIZE(pfxs))
3152 continue;
3153 nid = spec->hp_dacs[i];
3154 if (!nid)
3155 continue;
3156 err = create_controls(spec, pfxs[nums++], nid, 3);
3157 if (err < 0)
3158 return err;
3159 }
3160 nums = 0;
3161 for (i = 0; i < cfg->speaker_outs; i++) {
3162 static const char *pfxs[] = {
3163 "Speaker", "External Speaker", "Speaker2",
3164 };
3165 if (nums >= ARRAY_SIZE(pfxs))
3166 continue;
3167 nid = spec->speaker_dacs[i];
3168 if (!nid)
3169 continue;
3170 err = create_controls(spec, pfxs[nums++], nid, 3);
3171 if (err < 0)
3172 return err;
3173 }
3174 return 0; 3192 return 0;
3175} 3193}
3176 3194
@@ -3379,11 +3397,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3379 unsigned int wcaps; 3397 unsigned int wcaps;
3380 unsigned int def_conf; 3398 unsigned int def_conf;
3381 3399
3382 def_conf = snd_hda_codec_read(codec, 3400 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3383 spec->dmic_nids[i],
3384 0,
3385 AC_VERB_GET_CONFIG_DEFAULT,
3386 0);
3387 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 3401 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3388 continue; 3402 continue;
3389 3403
@@ -3507,6 +3521,7 @@ static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3507static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in) 3521static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3508{ 3522{
3509 struct sigmatel_spec *spec = codec->spec; 3523 struct sigmatel_spec *spec = codec->spec;
3524 int hp_swap = 0;
3510 int err; 3525 int err;
3511 3526
3512 if ((err = snd_hda_parse_pin_def_config(codec, 3527 if ((err = snd_hda_parse_pin_def_config(codec,
@@ -3516,7 +3531,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3516 if (! spec->autocfg.line_outs) 3531 if (! spec->autocfg.line_outs)
3517 return 0; /* can't find valid pin config */ 3532 return 0; /* can't find valid pin config */
3518 3533
3519#if 0 /* FIXME: temporarily disabled */
3520 /* If we have no real line-out pin and multiple hp-outs, HPs should 3534 /* If we have no real line-out pin and multiple hp-outs, HPs should
3521 * be set up as multi-channel outputs. 3535 * be set up as multi-channel outputs.
3522 */ 3536 */
@@ -3535,8 +3549,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3535 spec->autocfg.line_outs = spec->autocfg.hp_outs; 3549 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3536 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; 3550 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3537 spec->autocfg.hp_outs = 0; 3551 spec->autocfg.hp_outs = 0;
3552 hp_swap = 1;
3538 } 3553 }
3539#endif /* FIXME: temporarily disabled */
3540 if (spec->autocfg.mono_out_pin) { 3554 if (spec->autocfg.mono_out_pin) {
3541 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & 3555 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3542 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP); 3556 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
@@ -3629,12 +3643,19 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3629#endif 3643#endif
3630 3644
3631 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); 3645 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3632
3633 if (err < 0) 3646 if (err < 0)
3634 return err; 3647 return err;
3635 3648
3636 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); 3649 /* All output parsing done, now restore the swapped hp pins */
3650 if (hp_swap) {
3651 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3652 sizeof(spec->autocfg.hp_pins));
3653 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3654 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3655 spec->autocfg.line_outs = 0;
3656 }
3637 3657
3658 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3638 if (err < 0) 3659 if (err < 0)
3639 return err; 3660 return err;
3640 3661
@@ -3663,11 +3684,15 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3663 return err; 3684 return err;
3664 } 3685 }
3665 3686
3687 err = stac92xx_add_input_source(spec);
3688 if (err < 0)
3689 return err;
3690
3666 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3691 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3667 if (spec->multiout.max_channels > 2) 3692 if (spec->multiout.max_channels > 2)
3668 spec->surr_switch = 1; 3693 spec->surr_switch = 1;
3669 3694
3670 if (spec->autocfg.dig_out_pin) 3695 if (spec->autocfg.dig_outs)
3671 spec->multiout.dig_out_nid = dig_out; 3696 spec->multiout.dig_out_nid = dig_out;
3672 if (dig_in && spec->autocfg.dig_in_pin) 3697 if (dig_in && spec->autocfg.dig_in_pin)
3673 spec->dig_in_nid = dig_in; 3698 spec->dig_in_nid = dig_in;
@@ -3730,9 +3755,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3730 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { 3755 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3731 hda_nid_t pin = spec->autocfg.line_out_pins[i]; 3756 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3732 unsigned int defcfg; 3757 unsigned int defcfg;
3733 defcfg = snd_hda_codec_read(codec, pin, 0, 3758 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3734 AC_VERB_GET_CONFIG_DEFAULT,
3735 0x00);
3736 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { 3759 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3737 unsigned int wcaps = get_wcaps(codec, pin); 3760 unsigned int wcaps = get_wcaps(codec, pin);
3738 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); 3761 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
@@ -3745,7 +3768,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3745 } 3768 }
3746 3769
3747 if (lfe_pin) { 3770 if (lfe_pin) {
3748 err = create_controls(spec, "LFE", lfe_pin, 1); 3771 err = create_controls(codec, "LFE", lfe_pin, 1);
3749 if (err < 0) 3772 if (err < 0)
3750 return err; 3773 return err;
3751 } 3774 }
@@ -3776,7 +3799,11 @@ static int stac9200_parse_auto_config(struct hda_codec *codec)
3776 return err; 3799 return err;
3777 } 3800 }
3778 3801
3779 if (spec->autocfg.dig_out_pin) 3802 err = stac92xx_add_input_source(spec);
3803 if (err < 0)
3804 return err;
3805
3806 if (spec->autocfg.dig_outs)
3780 spec->multiout.dig_out_nid = 0x05; 3807 spec->multiout.dig_out_nid = 0x05;
3781 if (spec->autocfg.dig_in_pin) 3808 if (spec->autocfg.dig_in_pin)
3782 spec->dig_in_nid = 0x04; 3809 spec->dig_in_nid = 0x04;
@@ -3832,8 +3859,7 @@ static int stac92xx_add_jack(struct hda_codec *codec,
3832#ifdef CONFIG_SND_JACK 3859#ifdef CONFIG_SND_JACK
3833 struct sigmatel_spec *spec = codec->spec; 3860 struct sigmatel_spec *spec = codec->spec;
3834 struct sigmatel_jack *jack; 3861 struct sigmatel_jack *jack;
3835 int def_conf = snd_hda_codec_read(codec, nid, 3862 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
3836 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3837 int connectivity = get_defcfg_connect(def_conf); 3863 int connectivity = get_defcfg_connect(def_conf);
3838 char name[32]; 3864 char name[32];
3839 3865
@@ -3948,6 +3974,36 @@ static void stac92xx_power_down(struct hda_codec *codec)
3948static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, 3974static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
3949 int enable); 3975 int enable);
3950 3976
3977/* override some hints from the hwdep entry */
3978static void stac_store_hints(struct hda_codec *codec)
3979{
3980 struct sigmatel_spec *spec = codec->spec;
3981 const char *p;
3982 int val;
3983
3984 val = snd_hda_get_bool_hint(codec, "hp_detect");
3985 if (val >= 0)
3986 spec->hp_detect = val;
3987 p = snd_hda_get_hint(codec, "gpio_mask");
3988 if (p) {
3989 spec->gpio_mask = simple_strtoul(p, NULL, 0);
3990 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
3991 spec->gpio_mask;
3992 }
3993 p = snd_hda_get_hint(codec, "gpio_dir");
3994 if (p)
3995 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
3996 p = snd_hda_get_hint(codec, "gpio_data");
3997 if (p)
3998 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
3999 p = snd_hda_get_hint(codec, "eapd_mask");
4000 if (p)
4001 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4002 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4003 if (val >= 0)
4004 spec->eapd_switch = val;
4005}
4006
3951static int stac92xx_init(struct hda_codec *codec) 4007static int stac92xx_init(struct hda_codec *codec)
3952{ 4008{
3953 struct sigmatel_spec *spec = codec->spec; 4009 struct sigmatel_spec *spec = codec->spec;
@@ -3964,6 +4020,9 @@ static int stac92xx_init(struct hda_codec *codec)
3964 spec->adc_nids[i], 0, 4020 spec->adc_nids[i], 0,
3965 AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 4021 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3966 4022
4023 /* override some hints */
4024 stac_store_hints(codec);
4025
3967 /* set up GPIO */ 4026 /* set up GPIO */
3968 gpio = spec->gpio_data; 4027 gpio = spec->gpio_data;
3969 /* turn on EAPD statically when spec->eapd_switch isn't set. 4028 /* turn on EAPD statically when spec->eapd_switch isn't set.
@@ -4013,8 +4072,7 @@ static int stac92xx_init(struct hda_codec *codec)
4013 pinctl); 4072 pinctl);
4014 } 4073 }
4015 } 4074 }
4016 conf = snd_hda_codec_read(codec, nid, 0, 4075 conf = snd_hda_codec_get_pincfg(codec, nid);
4017 AC_VERB_GET_CONFIG_DEFAULT, 0);
4018 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { 4076 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4019 enable_pin_detect(codec, nid, 4077 enable_pin_detect(codec, nid,
4020 STAC_INSERT_EVENT); 4078 STAC_INSERT_EVENT);
@@ -4026,8 +4084,8 @@ static int stac92xx_init(struct hda_codec *codec)
4026 for (i = 0; i < spec->num_dmics; i++) 4084 for (i = 0; i < spec->num_dmics; i++)
4027 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i], 4085 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4028 AC_PINCTL_IN_EN); 4086 AC_PINCTL_IN_EN);
4029 if (cfg->dig_out_pin) 4087 if (cfg->dig_out_pins[0])
4030 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin, 4088 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4031 AC_PINCTL_OUT_EN); 4089 AC_PINCTL_OUT_EN);
4032 if (cfg->dig_in_pin) 4090 if (cfg->dig_in_pin)
4033 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin, 4091 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
@@ -4055,8 +4113,7 @@ static int stac92xx_init(struct hda_codec *codec)
4055 stac_toggle_power_map(codec, nid, 1); 4113 stac_toggle_power_map(codec, nid, 1);
4056 continue; 4114 continue;
4057 } 4115 }
4058 def_conf = snd_hda_codec_read(codec, nid, 0, 4116 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4059 AC_VERB_GET_CONFIG_DEFAULT, 0);
4060 def_conf = get_defcfg_connect(def_conf); 4117 def_conf = get_defcfg_connect(def_conf);
4061 /* skip any ports that don't have jacks since presence 4118 /* skip any ports that don't have jacks since presence
4062 * detection is useless */ 4119 * detection is useless */
@@ -4110,7 +4167,6 @@ static void stac92xx_free(struct hda_codec *codec)
4110 if (! spec) 4167 if (! spec)
4111 return; 4168 return;
4112 4169
4113 kfree(spec->pin_configs);
4114 stac92xx_free_jacks(codec); 4170 stac92xx_free_jacks(codec);
4115 snd_array_free(&spec->events); 4171 snd_array_free(&spec->events);
4116 4172
@@ -4121,7 +4177,9 @@ static void stac92xx_free(struct hda_codec *codec)
4121static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, 4177static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4122 unsigned int flag) 4178 unsigned int flag)
4123{ 4179{
4124 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 4180 unsigned int old_ctl, pin_ctl;
4181
4182 pin_ctl = snd_hda_codec_read(codec, nid,
4125 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 4183 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4126 4184
4127 if (pin_ctl & AC_PINCTL_IN_EN) { 4185 if (pin_ctl & AC_PINCTL_IN_EN) {
@@ -4135,14 +4193,17 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4135 return; 4193 return;
4136 } 4194 }
4137 4195
4196 old_ctl = pin_ctl;
4138 /* if setting pin direction bits, clear the current 4197 /* if setting pin direction bits, clear the current
4139 direction bits first */ 4198 direction bits first */
4140 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) 4199 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4141 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); 4200 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4142 4201
4143 snd_hda_codec_write_cache(codec, nid, 0, 4202 pin_ctl |= flag;
4144 AC_VERB_SET_PIN_WIDGET_CONTROL, 4203 if (old_ctl != pin_ctl)
4145 pin_ctl | flag); 4204 snd_hda_codec_write_cache(codec, nid, 0,
4205 AC_VERB_SET_PIN_WIDGET_CONTROL,
4206 pin_ctl);
4146} 4207}
4147 4208
4148static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, 4209static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
@@ -4150,9 +4211,10 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4150{ 4211{
4151 unsigned int pin_ctl = snd_hda_codec_read(codec, nid, 4212 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4152 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); 4213 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4153 snd_hda_codec_write_cache(codec, nid, 0, 4214 if (pin_ctl & flag)
4154 AC_VERB_SET_PIN_WIDGET_CONTROL, 4215 snd_hda_codec_write_cache(codec, nid, 0,
4155 pin_ctl & ~flag); 4216 AC_VERB_SET_PIN_WIDGET_CONTROL,
4217 pin_ctl & ~flag);
4156} 4218}
4157 4219
4158static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) 4220static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
@@ -4415,7 +4477,6 @@ static int stac92xx_resume(struct hda_codec *codec)
4415{ 4477{
4416 struct sigmatel_spec *spec = codec->spec; 4478 struct sigmatel_spec *spec = codec->spec;
4417 4479
4418 stac92xx_set_config_regs(codec);
4419 stac92xx_init(codec); 4480 stac92xx_init(codec);
4420 snd_hda_codec_resume_amp(codec); 4481 snd_hda_codec_resume_amp(codec);
4421 snd_hda_codec_resume_cache(codec); 4482 snd_hda_codec_resume_cache(codec);
@@ -4426,6 +4487,37 @@ static int stac92xx_resume(struct hda_codec *codec)
4426 return 0; 4487 return 0;
4427} 4488}
4428 4489
4490
4491/*
4492 * using power check for controlling mute led of HP HDX notebooks
4493 * check for mute state only on Speakers (nid = 0x10)
4494 *
4495 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4496 * the LED is NOT working properly !
4497 */
4498
4499#ifdef CONFIG_SND_HDA_POWER_SAVE
4500static int stac92xx_hp_hdx_check_power_status(struct hda_codec *codec,
4501 hda_nid_t nid)
4502{
4503 struct sigmatel_spec *spec = codec->spec;
4504
4505 if (nid == 0x10) {
4506 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4507 HDA_AMP_MUTE)
4508 spec->gpio_data &= ~0x08; /* orange */
4509 else
4510 spec->gpio_data |= 0x08; /* white */
4511
4512 stac_gpio_set(codec, spec->gpio_mask,
4513 spec->gpio_dir,
4514 spec->gpio_data);
4515 }
4516
4517 return 0;
4518}
4519#endif
4520
4429static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) 4521static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4430{ 4522{
4431 struct sigmatel_spec *spec = codec->spec; 4523 struct sigmatel_spec *spec = codec->spec;
@@ -4464,16 +4556,11 @@ static int patch_stac9200(struct hda_codec *codec)
4464 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, 4556 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4465 stac9200_models, 4557 stac9200_models,
4466 stac9200_cfg_tbl); 4558 stac9200_cfg_tbl);
4467 if (spec->board_config < 0) { 4559 if (spec->board_config < 0)
4468 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); 4560 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4469 err = stac92xx_save_bios_config_regs(codec); 4561 else
4470 } else 4562 stac92xx_set_config_regs(codec,
4471 err = stac_save_pin_cfgs(codec,
4472 stac9200_brd_tbl[spec->board_config]); 4563 stac9200_brd_tbl[spec->board_config]);
4473 if (err < 0) {
4474 stac92xx_free(codec);
4475 return err;
4476 }
4477 4564
4478 spec->multiout.max_channels = 2; 4565 spec->multiout.max_channels = 2;
4479 spec->multiout.num_dacs = 1; 4566 spec->multiout.num_dacs = 1;
@@ -4541,17 +4628,12 @@ static int patch_stac925x(struct hda_codec *codec)
4541 stac925x_models, 4628 stac925x_models,
4542 stac925x_cfg_tbl); 4629 stac925x_cfg_tbl);
4543 again: 4630 again:
4544 if (spec->board_config < 0) { 4631 if (spec->board_config < 0)
4545 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 4632 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4546 "using BIOS defaults\n"); 4633 "using BIOS defaults\n");
4547 err = stac92xx_save_bios_config_regs(codec); 4634 else
4548 } else 4635 stac92xx_set_config_regs(codec,
4549 err = stac_save_pin_cfgs(codec,
4550 stac925x_brd_tbl[spec->board_config]); 4636 stac925x_brd_tbl[spec->board_config]);
4551 if (err < 0) {
4552 stac92xx_free(codec);
4553 return err;
4554 }
4555 4637
4556 spec->multiout.max_channels = 2; 4638 spec->multiout.max_channels = 2;
4557 spec->multiout.num_dacs = 1; 4639 spec->multiout.num_dacs = 1;
@@ -4629,17 +4711,12 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
4629 stac92hd73xx_models, 4711 stac92hd73xx_models,
4630 stac92hd73xx_cfg_tbl); 4712 stac92hd73xx_cfg_tbl);
4631again: 4713again:
4632 if (spec->board_config < 0) { 4714 if (spec->board_config < 0)
4633 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4715 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4634 " STAC92HD73XX, using BIOS defaults\n"); 4716 " STAC92HD73XX, using BIOS defaults\n");
4635 err = stac92xx_save_bios_config_regs(codec); 4717 else
4636 } else 4718 stac92xx_set_config_regs(codec,
4637 err = stac_save_pin_cfgs(codec,
4638 stac92hd73xx_brd_tbl[spec->board_config]); 4719 stac92hd73xx_brd_tbl[spec->board_config]);
4639 if (err < 0) {
4640 stac92xx_free(codec);
4641 return err;
4642 }
4643 4720
4644 num_dacs = snd_hda_get_connections(codec, 0x0a, 4721 num_dacs = snd_hda_get_connections(codec, 0x0a,
4645 conn, STAC92HD73_DAC_COUNT + 2) - 1; 4722 conn, STAC92HD73_DAC_COUNT + 2) - 1;
@@ -4653,14 +4730,18 @@ again:
4653 case 0x3: /* 6 Channel */ 4730 case 0x3: /* 6 Channel */
4654 spec->mixer = stac92hd73xx_6ch_mixer; 4731 spec->mixer = stac92hd73xx_6ch_mixer;
4655 spec->init = stac92hd73xx_6ch_core_init; 4732 spec->init = stac92hd73xx_6ch_core_init;
4733 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4656 break; 4734 break;
4657 case 0x4: /* 8 Channel */ 4735 case 0x4: /* 8 Channel */
4658 spec->mixer = stac92hd73xx_8ch_mixer; 4736 spec->mixer = stac92hd73xx_8ch_mixer;
4659 spec->init = stac92hd73xx_8ch_core_init; 4737 spec->init = stac92hd73xx_8ch_core_init;
4738 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4660 break; 4739 break;
4661 case 0x5: /* 10 Channel */ 4740 case 0x5: /* 10 Channel */
4662 spec->mixer = stac92hd73xx_10ch_mixer; 4741 spec->mixer = stac92hd73xx_10ch_mixer;
4663 spec->init = stac92hd73xx_10ch_core_init; 4742 spec->init = stac92hd73xx_10ch_core_init;
4743 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4744 break;
4664 } 4745 }
4665 spec->multiout.dac_nids = spec->dac_nids; 4746 spec->multiout.dac_nids = spec->dac_nids;
4666 4747
@@ -4699,18 +4780,18 @@ again:
4699 spec->init = dell_m6_core_init; 4780 spec->init = dell_m6_core_init;
4700 switch (spec->board_config) { 4781 switch (spec->board_config) {
4701 case STAC_DELL_M6_AMIC: /* Analog Mics */ 4782 case STAC_DELL_M6_AMIC: /* Analog Mics */
4702 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); 4783 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4703 spec->num_dmics = 0; 4784 spec->num_dmics = 0;
4704 spec->private_dimux.num_items = 1; 4785 spec->private_dimux.num_items = 1;
4705 break; 4786 break;
4706 case STAC_DELL_M6_DMIC: /* Digital Mics */ 4787 case STAC_DELL_M6_DMIC: /* Digital Mics */
4707 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4788 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4708 spec->num_dmics = 1; 4789 spec->num_dmics = 1;
4709 spec->private_dimux.num_items = 2; 4790 spec->private_dimux.num_items = 2;
4710 break; 4791 break;
4711 case STAC_DELL_M6_BOTH: /* Both */ 4792 case STAC_DELL_M6_BOTH: /* Both */
4712 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); 4793 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
4713 stac92xx_set_config_reg(codec, 0x13, 0x90A60160); 4794 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
4714 spec->num_dmics = 1; 4795 spec->num_dmics = 1;
4715 spec->private_dimux.num_items = 2; 4796 spec->private_dimux.num_items = 2;
4716 break; 4797 break;
@@ -4773,6 +4854,7 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
4773 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1]; 4854 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
4774 int err; 4855 int err;
4775 int num_dacs; 4856 int num_dacs;
4857 hda_nid_t nid;
4776 4858
4777 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4859 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4778 if (spec == NULL) 4860 if (spec == NULL)
@@ -4791,15 +4873,6 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
4791 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); 4873 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4792 spec->multiout.dac_nids = spec->dac_nids; 4874 spec->multiout.dac_nids = spec->dac_nids;
4793 4875
4794
4795 /* set port 0xe to select the last DAC
4796 */
4797 num_dacs = snd_hda_get_connections(codec, 0x0e,
4798 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4799
4800 snd_hda_codec_write_cache(codec, 0xe, 0,
4801 AC_VERB_SET_CONNECT_SEL, num_dacs);
4802
4803 spec->init = stac92hd83xxx_core_init; 4876 spec->init = stac92hd83xxx_core_init;
4804 spec->mixer = stac92hd83xxx_mixer; 4877 spec->mixer = stac92hd83xxx_mixer;
4805 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); 4878 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
@@ -4814,17 +4887,12 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
4814 stac92hd83xxx_models, 4887 stac92hd83xxx_models,
4815 stac92hd83xxx_cfg_tbl); 4888 stac92hd83xxx_cfg_tbl);
4816again: 4889again:
4817 if (spec->board_config < 0) { 4890 if (spec->board_config < 0)
4818 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4891 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4819 " STAC92HD83XXX, using BIOS defaults\n"); 4892 " STAC92HD83XXX, using BIOS defaults\n");
4820 err = stac92xx_save_bios_config_regs(codec); 4893 else
4821 } else 4894 stac92xx_set_config_regs(codec,
4822 err = stac_save_pin_cfgs(codec,
4823 stac92hd83xxx_brd_tbl[spec->board_config]); 4895 stac92hd83xxx_brd_tbl[spec->board_config]);
4824 if (err < 0) {
4825 stac92xx_free(codec);
4826 return err;
4827 }
4828 4896
4829 switch (codec->vendor_id) { 4897 switch (codec->vendor_id) {
4830 case 0x111d7604: 4898 case 0x111d7604:
@@ -4851,6 +4919,23 @@ again:
4851 return err; 4919 return err;
4852 } 4920 }
4853 4921
4922 switch (spec->board_config) {
4923 case STAC_DELL_S14:
4924 nid = 0xf;
4925 break;
4926 default:
4927 nid = 0xe;
4928 break;
4929 }
4930
4931 num_dacs = snd_hda_get_connections(codec, nid,
4932 conn, STAC92HD83_DAC_COUNT + 1) - 1;
4933
4934 /* set port X to select the last DAC
4935 */
4936 snd_hda_codec_write_cache(codec, nid, 0,
4937 AC_VERB_SET_CONNECT_SEL, num_dacs);
4938
4854 codec->patch_ops = stac92xx_patch_ops; 4939 codec->patch_ops = stac92xx_patch_ops;
4855 4940
4856 codec->proc_widget_hook = stac92hd_proc_hook; 4941 codec->proc_widget_hook = stac92hd_proc_hook;
@@ -4858,7 +4943,16 @@ again:
4858 return 0; 4943 return 0;
4859} 4944}
4860 4945
4861static struct hda_input_mux stac92hd71bxx_dmux = { 4946static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
4947 .num_items = 3,
4948 .items = {
4949 { "Analog Inputs", 0x00 },
4950 { "Digital Mic 1", 0x02 },
4951 { "Digital Mic 2", 0x03 },
4952 }
4953};
4954
4955static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
4862 .num_items = 4, 4956 .num_items = 4,
4863 .items = { 4957 .items = {
4864 { "Analog Inputs", 0x00 }, 4958 { "Analog Inputs", 0x00 },
@@ -4868,10 +4962,67 @@ static struct hda_input_mux stac92hd71bxx_dmux = {
4868 } 4962 }
4869}; 4963};
4870 4964
4965/* get the pin connection (fixed, none, etc) */
4966static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4967{
4968 struct sigmatel_spec *spec = codec->spec;
4969 unsigned int cfg;
4970
4971 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4972 return get_defcfg_connect(cfg);
4973}
4974
4975static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
4976 hda_nid_t *nids, int num_nids)
4977{
4978 struct sigmatel_spec *spec = codec->spec;
4979 int idx, num;
4980 unsigned int def_conf;
4981
4982 for (num = 0; num < num_nids; num++) {
4983 for (idx = 0; idx < spec->num_pins; idx++)
4984 if (spec->pin_nids[idx] == nids[num])
4985 break;
4986 if (idx >= spec->num_pins)
4987 break;
4988 def_conf = stac_get_defcfg_connect(codec, idx);
4989 if (def_conf == AC_JACK_PORT_NONE)
4990 break;
4991 }
4992 return num;
4993}
4994
4995static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
4996 hda_nid_t dig0pin)
4997{
4998 struct sigmatel_spec *spec = codec->spec;
4999 int idx;
5000
5001 for (idx = 0; idx < spec->num_pins; idx++)
5002 if (spec->pin_nids[idx] == dig0pin)
5003 break;
5004 if ((idx + 2) >= spec->num_pins)
5005 return 0;
5006
5007 /* dig1pin case */
5008 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5009 return 2;
5010
5011 /* dig0pin + dig2pin case */
5012 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5013 return 2;
5014 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5015 return 1;
5016 else
5017 return 0;
5018}
5019
4871static int patch_stac92hd71bxx(struct hda_codec *codec) 5020static int patch_stac92hd71bxx(struct hda_codec *codec)
4872{ 5021{
4873 struct sigmatel_spec *spec; 5022 struct sigmatel_spec *spec;
5023 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
4874 int err = 0; 5024 int err = 0;
5025 unsigned int ndmic_nids = 0;
4875 5026
4876 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5027 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4877 if (spec == NULL) 5028 if (spec == NULL)
@@ -4879,27 +5030,32 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
4879 5030
4880 codec->spec = spec; 5031 codec->spec = spec;
4881 codec->patch_ops = stac92xx_patch_ops; 5032 codec->patch_ops = stac92xx_patch_ops;
4882 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids); 5033 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5034 switch (codec->vendor_id) {
5035 case 0x111d76b6:
5036 case 0x111d76b7:
5037 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5038 break;
5039 case 0x111d7603:
5040 case 0x111d7608:
5041 /* On 92HD75Bx 0x27 isn't a pin nid */
5042 spec->num_pins--;
5043 /* fallthrough */
5044 default:
5045 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5046 }
4883 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids); 5047 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4884 spec->pin_nids = stac92hd71bxx_pin_nids;
4885 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4886 sizeof(stac92hd71bxx_dmux));
4887 spec->board_config = snd_hda_check_board_config(codec, 5048 spec->board_config = snd_hda_check_board_config(codec,
4888 STAC_92HD71BXX_MODELS, 5049 STAC_92HD71BXX_MODELS,
4889 stac92hd71bxx_models, 5050 stac92hd71bxx_models,
4890 stac92hd71bxx_cfg_tbl); 5051 stac92hd71bxx_cfg_tbl);
4891again: 5052again:
4892 if (spec->board_config < 0) { 5053 if (spec->board_config < 0)
4893 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5054 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4894 " STAC92HD71BXX, using BIOS defaults\n"); 5055 " STAC92HD71BXX, using BIOS defaults\n");
4895 err = stac92xx_save_bios_config_regs(codec); 5056 else
4896 } else 5057 stac92xx_set_config_regs(codec,
4897 err = stac_save_pin_cfgs(codec,
4898 stac92hd71bxx_brd_tbl[spec->board_config]); 5058 stac92hd71bxx_brd_tbl[spec->board_config]);
4899 if (err < 0) {
4900 stac92xx_free(codec);
4901 return err;
4902 }
4903 5059
4904 if (spec->board_config > STAC_92HD71BXX_REF) { 5060 if (spec->board_config > STAC_92HD71BXX_REF) {
4905 /* GPIO0 = EAPD */ 5061 /* GPIO0 = EAPD */
@@ -4908,16 +5064,34 @@ again:
4908 spec->gpio_data = 0x01; 5064 spec->gpio_data = 0x01;
4909 } 5065 }
4910 5066
5067 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5068 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5069
4911 switch (codec->vendor_id) { 5070 switch (codec->vendor_id) {
4912 case 0x111d76b6: /* 4 Port without Analog Mixer */ 5071 case 0x111d76b6: /* 4 Port without Analog Mixer */
4913 case 0x111d76b7: 5072 case 0x111d76b7:
5073 unmute_init++;
5074 /* fallthru */
4914 case 0x111d76b4: /* 6 Port without Analog Mixer */ 5075 case 0x111d76b4: /* 6 Port without Analog Mixer */
4915 case 0x111d76b5: 5076 case 0x111d76b5:
5077 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5078 sizeof(stac92hd71bxx_dmux_nomixer));
4916 spec->mixer = stac92hd71bxx_mixer; 5079 spec->mixer = stac92hd71bxx_mixer;
4917 spec->init = stac92hd71bxx_core_init; 5080 spec->init = stac92hd71bxx_core_init;
4918 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5081 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5082 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5083 stac92hd71bxx_dmic_nids,
5084 STAC92HD71BXX_NUM_DMICS);
5085 if (spec->num_dmics) {
5086 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5087 spec->dinput_mux = &spec->private_dimux;
5088 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5089 }
4919 break; 5090 break;
4920 case 0x111d7608: /* 5 Port with Analog Mixer */ 5091 case 0x111d7608: /* 5 Port with Analog Mixer */
5092 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5093 sizeof(stac92hd71bxx_dmux_amixer));
5094 spec->private_dimux.num_items--;
4921 switch (spec->board_config) { 5095 switch (spec->board_config) {
4922 case STAC_HP_M4: 5096 case STAC_HP_M4:
4923 /* Enable VREF power saving on GPIO1 detect */ 5097 /* Enable VREF power saving on GPIO1 detect */
@@ -4944,7 +5118,15 @@ again:
4944 5118
4945 /* disable VSW */ 5119 /* disable VSW */
4946 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; 5120 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4947 stac_change_pin_config(codec, 0xf, 0x40f000f0); 5121 unmute_init++;
5122 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5123 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5124 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5125 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5126 stac92hd71bxx_dmic_nids,
5127 STAC92HD71BXX_NUM_DMICS - 1);
5128 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5129 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
4948 break; 5130 break;
4949 case 0x111d7603: /* 6 Port with Analog Mixer */ 5131 case 0x111d7603: /* 6 Port with Analog Mixer */
4950 if ((codec->revision_id & 0xf) == 1) 5132 if ((codec->revision_id & 0xf) == 1)
@@ -4954,12 +5136,23 @@ again:
4954 spec->num_pwrs = 0; 5136 spec->num_pwrs = 0;
4955 /* fallthru */ 5137 /* fallthru */
4956 default: 5138 default:
5139 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5140 sizeof(stac92hd71bxx_dmux_amixer));
4957 spec->dinput_mux = &spec->private_dimux; 5141 spec->dinput_mux = &spec->private_dimux;
4958 spec->mixer = stac92hd71bxx_analog_mixer; 5142 spec->mixer = stac92hd71bxx_analog_mixer;
4959 spec->init = stac92hd71bxx_analog_core_init; 5143 spec->init = stac92hd71bxx_analog_core_init;
4960 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5144 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5145 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5146 stac92hd71bxx_dmic_nids,
5147 STAC92HD71BXX_NUM_DMICS);
5148 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5149 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
4961 } 5150 }
4962 5151
5152 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5153 snd_hda_sequence_write_cache(codec, unmute_init);
5154
5155 spec->aloopback_ctl = stac92hd71bxx_loopback;
4963 spec->aloopback_mask = 0x50; 5156 spec->aloopback_mask = 0x50;
4964 spec->aloopback_shift = 0; 5157 spec->aloopback_shift = 0;
4965 5158
@@ -4967,18 +5160,17 @@ again:
4967 spec->digbeep_nid = 0x26; 5160 spec->digbeep_nid = 0x26;
4968 spec->mux_nids = stac92hd71bxx_mux_nids; 5161 spec->mux_nids = stac92hd71bxx_mux_nids;
4969 spec->adc_nids = stac92hd71bxx_adc_nids; 5162 spec->adc_nids = stac92hd71bxx_adc_nids;
4970 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4971 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4972 spec->smux_nids = stac92hd71bxx_smux_nids; 5163 spec->smux_nids = stac92hd71bxx_smux_nids;
4973 spec->pwr_nids = stac92hd71bxx_pwr_nids; 5164 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4974 5165
4975 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); 5166 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4976 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); 5167 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5168 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
4977 5169
4978 switch (spec->board_config) { 5170 switch (spec->board_config) {
4979 case STAC_HP_M4: 5171 case STAC_HP_M4:
4980 /* enable internal microphone */ 5172 /* enable internal microphone */
4981 stac_change_pin_config(codec, 0x0e, 0x01813040); 5173 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
4982 stac92xx_auto_set_pinctl(codec, 0x0e, 5174 stac92xx_auto_set_pinctl(codec, 0x0e,
4983 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); 5175 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4984 /* fallthru */ 5176 /* fallthru */
@@ -4993,19 +5185,36 @@ again:
4993 spec->num_smuxes = 0; 5185 spec->num_smuxes = 0;
4994 spec->num_dmuxes = 1; 5186 spec->num_dmuxes = 1;
4995 break; 5187 break;
4996 default: 5188 case STAC_HP_DV5:
4997 spec->num_dmics = STAC92HD71BXX_NUM_DMICS; 5189 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
4998 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids); 5190 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
4999 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); 5191 break;
5192 case STAC_HP_HDX:
5193 spec->num_dmics = 1;
5194 spec->num_dmuxes = 1;
5195 spec->num_smuxes = 1;
5196 /*
5197 * For controlling MUTE LED on HP HDX16/HDX18 notebooks,
5198 * the CONFIG_SND_HDA_POWER_SAVE is needed to be set.
5199 */
5200#ifdef CONFIG_SND_HDA_POWER_SAVE
5201 /* orange/white mute led on GPIO3, orange=0, white=1 */
5202 spec->gpio_mask |= 0x08;
5203 spec->gpio_dir |= 0x08;
5204 spec->gpio_data |= 0x08; /* set to white */
5205
5206 /* register check_power_status callback. */
5207 codec->patch_ops.check_power_status =
5208 stac92xx_hp_hdx_check_power_status;
5209#endif
5210 break;
5000 }; 5211 };
5001 5212
5002 spec->multiout.dac_nids = spec->dac_nids; 5213 spec->multiout.dac_nids = spec->dac_nids;
5003 if (spec->dinput_mux) 5214 if (spec->dinput_mux)
5004 spec->private_dimux.num_items += 5215 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5005 spec->num_dmics -
5006 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
5007 5216
5008 err = stac92xx_parse_auto_config(codec, 0x21, 0x23); 5217 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5009 if (!err) { 5218 if (!err) {
5010 if (spec->board_config < 0) { 5219 if (spec->board_config < 0) {
5011 printk(KERN_WARNING "hda_codec: No auto-config is " 5220 printk(KERN_WARNING "hda_codec: No auto-config is "
@@ -5080,17 +5289,12 @@ static int patch_stac922x(struct hda_codec *codec)
5080 } 5289 }
5081 5290
5082 again: 5291 again:
5083 if (spec->board_config < 0) { 5292 if (spec->board_config < 0)
5084 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " 5293 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
5085 "using BIOS defaults\n"); 5294 "using BIOS defaults\n");
5086 err = stac92xx_save_bios_config_regs(codec); 5295 else
5087 } else 5296 stac92xx_set_config_regs(codec,
5088 err = stac_save_pin_cfgs(codec,
5089 stac922x_brd_tbl[spec->board_config]); 5297 stac922x_brd_tbl[spec->board_config]);
5090 if (err < 0) {
5091 stac92xx_free(codec);
5092 return err;
5093 }
5094 5298
5095 spec->adc_nids = stac922x_adc_nids; 5299 spec->adc_nids = stac922x_adc_nids;
5096 spec->mux_nids = stac922x_mux_nids; 5300 spec->mux_nids = stac922x_mux_nids;
@@ -5141,24 +5345,19 @@ static int patch_stac927x(struct hda_codec *codec)
5141 return -ENOMEM; 5345 return -ENOMEM;
5142 5346
5143 codec->spec = spec; 5347 codec->spec = spec;
5348 codec->slave_dig_outs = stac927x_slave_dig_outs;
5144 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); 5349 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5145 spec->pin_nids = stac927x_pin_nids; 5350 spec->pin_nids = stac927x_pin_nids;
5146 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, 5351 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5147 stac927x_models, 5352 stac927x_models,
5148 stac927x_cfg_tbl); 5353 stac927x_cfg_tbl);
5149 again: 5354 again:
5150 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) { 5355 if (spec->board_config < 0)
5151 if (spec->board_config < 0) 5356 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
5152 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5357 "STAC927x, using BIOS defaults\n");
5153 "STAC927x, using BIOS defaults\n"); 5358 else
5154 err = stac92xx_save_bios_config_regs(codec); 5359 stac92xx_set_config_regs(codec,
5155 } else
5156 err = stac_save_pin_cfgs(codec,
5157 stac927x_brd_tbl[spec->board_config]); 5360 stac927x_brd_tbl[spec->board_config]);
5158 if (err < 0) {
5159 stac92xx_free(codec);
5160 return err;
5161 }
5162 5361
5163 spec->digbeep_nid = 0x23; 5362 spec->digbeep_nid = 0x23;
5164 spec->adc_nids = stac927x_adc_nids; 5363 spec->adc_nids = stac927x_adc_nids;
@@ -5187,15 +5386,15 @@ static int patch_stac927x(struct hda_codec *codec)
5187 case 0x10280209: 5386 case 0x10280209:
5188 case 0x1028022e: 5387 case 0x1028022e:
5189 /* correct the device field to SPDIF out */ 5388 /* correct the device field to SPDIF out */
5190 stac_change_pin_config(codec, 0x21, 0x01442070); 5389 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5191 break; 5390 break;
5192 }; 5391 };
5193 /* configure the analog microphone on some laptops */ 5392 /* configure the analog microphone on some laptops */
5194 stac_change_pin_config(codec, 0x0c, 0x90a79130); 5393 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5195 /* correct the front output jack as a hp out */ 5394 /* correct the front output jack as a hp out */
5196 stac_change_pin_config(codec, 0x0f, 0x0227011f); 5395 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5197 /* correct the front input jack as a mic */ 5396 /* correct the front input jack as a mic */
5198 stac_change_pin_config(codec, 0x0e, 0x02a79130); 5397 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5199 /* fallthru */ 5398 /* fallthru */
5200 case STAC_DELL_3ST: 5399 case STAC_DELL_3ST:
5201 /* GPIO2 High = Enable EAPD */ 5400 /* GPIO2 High = Enable EAPD */
@@ -5222,6 +5421,7 @@ static int patch_stac927x(struct hda_codec *codec)
5222 } 5421 }
5223 5422
5224 spec->num_pwrs = 0; 5423 spec->num_pwrs = 0;
5424 spec->aloopback_ctl = stac927x_loopback;
5225 spec->aloopback_mask = 0x40; 5425 spec->aloopback_mask = 0x40;
5226 spec->aloopback_shift = 0; 5426 spec->aloopback_shift = 0;
5227 spec->eapd_switch = 1; 5427 spec->eapd_switch = 1;
@@ -5280,16 +5480,11 @@ static int patch_stac9205(struct hda_codec *codec)
5280 stac9205_models, 5480 stac9205_models,
5281 stac9205_cfg_tbl); 5481 stac9205_cfg_tbl);
5282 again: 5482 again:
5283 if (spec->board_config < 0) { 5483 if (spec->board_config < 0)
5284 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); 5484 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
5285 err = stac92xx_save_bios_config_regs(codec); 5485 else
5286 } else 5486 stac92xx_set_config_regs(codec,
5287 err = stac_save_pin_cfgs(codec,
5288 stac9205_brd_tbl[spec->board_config]); 5487 stac9205_brd_tbl[spec->board_config]);
5289 if (err < 0) {
5290 stac92xx_free(codec);
5291 return err;
5292 }
5293 5488
5294 spec->digbeep_nid = 0x23; 5489 spec->digbeep_nid = 0x23;
5295 spec->adc_nids = stac9205_adc_nids; 5490 spec->adc_nids = stac9205_adc_nids;
@@ -5306,17 +5501,20 @@ static int patch_stac9205(struct hda_codec *codec)
5306 5501
5307 spec->init = stac9205_core_init; 5502 spec->init = stac9205_core_init;
5308 spec->mixer = stac9205_mixer; 5503 spec->mixer = stac9205_mixer;
5504 spec->aloopback_ctl = stac9205_loopback;
5309 5505
5310 spec->aloopback_mask = 0x40; 5506 spec->aloopback_mask = 0x40;
5311 spec->aloopback_shift = 0; 5507 spec->aloopback_shift = 0;
5312 spec->eapd_switch = 1; 5508 /* Turn on/off EAPD per HP plugging */
5509 if (spec->board_config != STAC_9205_EAPD)
5510 spec->eapd_switch = 1;
5313 spec->multiout.dac_nids = spec->dac_nids; 5511 spec->multiout.dac_nids = spec->dac_nids;
5314 5512
5315 switch (spec->board_config){ 5513 switch (spec->board_config){
5316 case STAC_9205_DELL_M43: 5514 case STAC_9205_DELL_M43:
5317 /* Enable SPDIF in/out */ 5515 /* Enable SPDIF in/out */
5318 stac_change_pin_config(codec, 0x1f, 0x01441030); 5516 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5319 stac_change_pin_config(codec, 0x20, 0x1c410030); 5517 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5320 5518
5321 /* Enable unsol response for GPIO4/Dock HP connection */ 5519 /* Enable unsol response for GPIO4/Dock HP connection */
5322 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); 5520 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
@@ -5373,223 +5571,87 @@ static int patch_stac9205(struct hda_codec *codec)
5373 * STAC9872 hack 5571 * STAC9872 hack
5374 */ 5572 */
5375 5573
5376/* static config for Sony VAIO FE550G and Sony VAIO AR */ 5574static struct hda_verb stac9872_core_init[] = {
5377static hda_nid_t vaio_dacs[] = { 0x2 };
5378#define VAIO_HP_DAC 0x5
5379static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
5380static hda_nid_t vaio_mux_nids[] = { 0x15 };
5381
5382static struct hda_input_mux vaio_mux = {
5383 .num_items = 3,
5384 .items = {
5385 /* { "HP", 0x0 }, */
5386 { "Mic Jack", 0x1 },
5387 { "Internal Mic", 0x2 },
5388 { "PCM", 0x3 },
5389 }
5390};
5391
5392static struct hda_verb vaio_init[] = {
5393 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5394 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
5395 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5396 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5397 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5398 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5399 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */ 5575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5400 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5401 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5402 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */ 5576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5405 {} 5577 {}
5406}; 5578};
5407 5579
5408static struct hda_verb vaio_ar_init[] = { 5580static struct snd_kcontrol_new stac9872_mixer[] = {
5409 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
5410 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
5411 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
5412 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
5413/* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
5414 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
5415 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5416 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
5417 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
5418/* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
5419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
5420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
5421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5422 {}
5423};
5424
5425static struct snd_kcontrol_new vaio_mixer[] = {
5426 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT),
5427 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT),
5428 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5429 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
5430 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5431 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT), 5581 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5432 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT), 5582 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5433 { 5583 { } /* end */
5434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5435 .name = "Capture Source",
5436 .count = 1,
5437 .info = stac92xx_mux_enum_info,
5438 .get = stac92xx_mux_enum_get,
5439 .put = stac92xx_mux_enum_put,
5440 },
5441 {}
5442}; 5584};
5443 5585
5444static struct snd_kcontrol_new vaio_ar_mixer[] = { 5586static hda_nid_t stac9872_pin_nids[] = {
5445 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x02, 0, HDA_OUTPUT), 5587 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5446 HDA_CODEC_MUTE("Headphone Playback Switch", 0x02, 0, HDA_OUTPUT), 5588 0x11, 0x13, 0x14,
5447 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x05, 0, HDA_OUTPUT),
5448 HDA_CODEC_MUTE("Speaker Playback Switch", 0x05, 0, HDA_OUTPUT),
5449 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5450 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5451 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5452 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5453 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5454 {
5455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5456 .name = "Capture Source",
5457 .count = 1,
5458 .info = stac92xx_mux_enum_info,
5459 .get = stac92xx_mux_enum_get,
5460 .put = stac92xx_mux_enum_put,
5461 },
5462 {}
5463}; 5589};
5464 5590
5465static struct hda_codec_ops stac9872_patch_ops = { 5591static hda_nid_t stac9872_adc_nids[] = {
5466 .build_controls = stac92xx_build_controls, 5592 0x8 /*,0x6*/
5467 .build_pcms = stac92xx_build_pcms,
5468 .init = stac92xx_init,
5469 .free = stac92xx_free,
5470#ifdef SND_HDA_NEEDS_RESUME
5471 .resume = stac92xx_resume,
5472#endif
5473}; 5593};
5474 5594
5475static int stac9872_vaio_init(struct hda_codec *codec) 5595static hda_nid_t stac9872_mux_nids[] = {
5476{ 5596 0x15
5477 int err;
5478
5479 err = stac92xx_init(codec);
5480 if (err < 0)
5481 return err;
5482 if (codec->patch_ops.unsol_event)
5483 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5484 return 0;
5485}
5486
5487static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5488{
5489 if (get_pin_presence(codec, 0x0a)) {
5490 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5491 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5492 } else {
5493 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5494 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5495 }
5496}
5497
5498static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5499{
5500 switch (res >> 26) {
5501 case STAC_HP_EVENT:
5502 stac9872_vaio_hp_detect(codec, res);
5503 break;
5504 }
5505}
5506
5507static struct hda_codec_ops stac9872_vaio_patch_ops = {
5508 .build_controls = stac92xx_build_controls,
5509 .build_pcms = stac92xx_build_pcms,
5510 .init = stac9872_vaio_init,
5511 .free = stac92xx_free,
5512 .unsol_event = stac9872_vaio_unsol_event,
5513#ifdef CONFIG_PM
5514 .resume = stac92xx_resume,
5515#endif
5516}; 5597};
5517 5598
5518enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */ 5599static unsigned int stac9872_vaio_pin_configs[9] = {
5519 CXD9872RD_VAIO, 5600 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5520 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */ 5601 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5521 STAC9872AK_VAIO, 5602 0x90a7013e
5522 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5523 STAC9872K_VAIO,
5524 /* AR Series. id=0x83847664 and subsys=104D1300 */
5525 CXD9872AKD_VAIO,
5526 STAC_9872_MODELS,
5527}; 5603};
5528 5604
5529static const char *stac9872_models[STAC_9872_MODELS] = { 5605static const char *stac9872_models[STAC_9872_MODELS] = {
5530 [CXD9872RD_VAIO] = "vaio", 5606 [STAC_9872_AUTO] = "auto",
5531 [CXD9872AKD_VAIO] = "vaio-ar", 5607 [STAC_9872_VAIO] = "vaio",
5608};
5609
5610static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5611 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5532}; 5612};
5533 5613
5534static struct snd_pci_quirk stac9872_cfg_tbl[] = { 5614static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5535 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO), 5615 {} /* terminator */
5536 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5537 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5538 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5539 {}
5540}; 5616};
5541 5617
5542static int patch_stac9872(struct hda_codec *codec) 5618static int patch_stac9872(struct hda_codec *codec)
5543{ 5619{
5544 struct sigmatel_spec *spec; 5620 struct sigmatel_spec *spec;
5545 int board_config; 5621 int err;
5546 5622
5547 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5548 stac9872_models,
5549 stac9872_cfg_tbl);
5550 if (board_config < 0)
5551 /* unknown config, let generic-parser do its job... */
5552 return snd_hda_parse_generic_codec(codec);
5553
5554 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5623 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5555 if (spec == NULL) 5624 if (spec == NULL)
5556 return -ENOMEM; 5625 return -ENOMEM;
5557
5558 codec->spec = spec; 5626 codec->spec = spec;
5559 switch (board_config) {
5560 case CXD9872RD_VAIO:
5561 case STAC9872AK_VAIO:
5562 case STAC9872K_VAIO:
5563 spec->mixer = vaio_mixer;
5564 spec->init = vaio_init;
5565 spec->multiout.max_channels = 2;
5566 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5567 spec->multiout.dac_nids = vaio_dacs;
5568 spec->multiout.hp_nid = VAIO_HP_DAC;
5569 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5570 spec->adc_nids = vaio_adcs;
5571 spec->num_pwrs = 0;
5572 spec->input_mux = &vaio_mux;
5573 spec->mux_nids = vaio_mux_nids;
5574 codec->patch_ops = stac9872_vaio_patch_ops;
5575 break;
5576
5577 case CXD9872AKD_VAIO:
5578 spec->mixer = vaio_ar_mixer;
5579 spec->init = vaio_ar_init;
5580 spec->multiout.max_channels = 2;
5581 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5582 spec->multiout.dac_nids = vaio_dacs;
5583 spec->multiout.hp_nid = VAIO_HP_DAC;
5584 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5585 spec->num_pwrs = 0;
5586 spec->adc_nids = vaio_adcs;
5587 spec->input_mux = &vaio_mux;
5588 spec->mux_nids = vaio_mux_nids;
5589 codec->patch_ops = stac9872_patch_ops;
5590 break;
5591 }
5592 5627
5628 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5629 stac9872_models,
5630 stac9872_cfg_tbl);
5631 if (spec->board_config < 0)
5632 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, "
5633 "using BIOS defaults\n");
5634 else
5635 stac92xx_set_config_regs(codec,
5636 stac9872_brd_tbl[spec->board_config]);
5637
5638 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5639 spec->pin_nids = stac9872_pin_nids;
5640 spec->multiout.dac_nids = spec->dac_nids;
5641 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5642 spec->adc_nids = stac9872_adc_nids;
5643 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5644 spec->mux_nids = stac9872_mux_nids;
5645 spec->mixer = stac9872_mixer;
5646 spec->init = stac9872_core_init;
5647
5648 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5649 if (err < 0) {
5650 stac92xx_free(codec);
5651 return -EINVAL;
5652 }
5653 spec->input_mux = &spec->private_imux;
5654 codec->patch_ops = stac92xx_patch_ops;
5593 return 0; 5655 return 0;
5594} 5656}
5595 5657
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index c761394cbe84..b25a5cc637d6 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -1308,16 +1308,13 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid)
1308 unsigned int def_conf; 1308 unsigned int def_conf;
1309 unsigned char seqassoc; 1309 unsigned char seqassoc;
1310 1310
1311 def_conf = snd_hda_codec_read(codec, nid, 0, 1311 def_conf = snd_hda_codec_get_pincfg(codec, nid);
1312 AC_VERB_GET_CONFIG_DEFAULT, 0);
1313 seqassoc = (unsigned char) get_defcfg_association(def_conf); 1312 seqassoc = (unsigned char) get_defcfg_association(def_conf);
1314 seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); 1313 seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf);
1315 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) { 1314 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) {
1316 if (seqassoc == 0xff) { 1315 if (seqassoc == 0xff) {
1317 def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); 1316 def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30));
1318 snd_hda_codec_write(codec, nid, 0, 1317 snd_hda_codec_set_pincfg(codec, nid, def_conf);
1319 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1320 def_conf >> 24);
1321 } 1318 }
1322 } 1319 }
1323 1320
@@ -1354,7 +1351,7 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
1354 1351
1355 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 1352 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1356 1353
1357 if (spec->autocfg.dig_out_pin) 1354 if (spec->autocfg.dig_outs)
1358 spec->multiout.dig_out_nid = VT1708_DIGOUT_NID; 1355 spec->multiout.dig_out_nid = VT1708_DIGOUT_NID;
1359 if (spec->autocfg.dig_in_pin) 1356 if (spec->autocfg.dig_in_pin)
1360 spec->dig_in_nid = VT1708_DIGIN_NID; 1357 spec->dig_in_nid = VT1708_DIGIN_NID;
@@ -1827,7 +1824,7 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
1827 1824
1828 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 1825 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1829 1826
1830 if (spec->autocfg.dig_out_pin) 1827 if (spec->autocfg.dig_outs)
1831 spec->multiout.dig_out_nid = VT1709_DIGOUT_NID; 1828 spec->multiout.dig_out_nid = VT1709_DIGOUT_NID;
1832 if (spec->autocfg.dig_in_pin) 1829 if (spec->autocfg.dig_in_pin)
1833 spec->dig_in_nid = VT1709_DIGIN_NID; 1830 spec->dig_in_nid = VT1709_DIGIN_NID;
@@ -2371,7 +2368,7 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
2371 2368
2372 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2369 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2373 2370
2374 if (spec->autocfg.dig_out_pin) 2371 if (spec->autocfg.dig_outs)
2375 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID; 2372 spec->multiout.dig_out_nid = VT1708B_DIGOUT_NID;
2376 if (spec->autocfg.dig_in_pin) 2373 if (spec->autocfg.dig_in_pin)
2377 spec->dig_in_nid = VT1708B_DIGIN_NID; 2374 spec->dig_in_nid = VT1708B_DIGIN_NID;
@@ -2836,7 +2833,7 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec)
2836 2833
2837 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 2834 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2838 2835
2839 if (spec->autocfg.dig_out_pin) 2836 if (spec->autocfg.dig_outs)
2840 spec->multiout.dig_out_nid = VT1708S_DIGOUT_NID; 2837 spec->multiout.dig_out_nid = VT1708S_DIGOUT_NID;
2841 2838
2842 spec->extra_dig_out_nid = 0x15; 2839 spec->extra_dig_out_nid = 0x15;
@@ -3155,7 +3152,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec)
3155 3152
3156 spec->multiout.max_channels = spec->multiout.num_dacs * 2; 3153 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3157 3154
3158 if (spec->autocfg.dig_out_pin) 3155 if (spec->autocfg.dig_outs)
3159 spec->multiout.dig_out_nid = VT1702_DIGOUT_NID; 3156 spec->multiout.dig_out_nid = VT1702_DIGOUT_NID;
3160 3157
3161 spec->extra_dig_out_nid = 0x1B; 3158 spec->extra_dig_out_nid = 0x1B;
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 98c6a8c65d81..18c7c91786bc 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -26,7 +26,7 @@
26 * SPI 0 -> 1st PCM1796 (front) 26 * SPI 0 -> 1st PCM1796 (front)
27 * SPI 1 -> 2nd PCM1796 (surround) 27 * SPI 1 -> 2nd PCM1796 (surround)
28 * SPI 2 -> 3rd PCM1796 (center/LFE) 28 * SPI 2 -> 3rd PCM1796 (center/LFE)
29 * SPI 4 -> 4th PCM1796 (back) 29 * SPI 4 -> 4th PCM1796 (back) and EEPROM self-destruct (do not use!)
30 * 30 *
31 * GPIO 2 -> M0 of CS5381 31 * GPIO 2 -> M0 of CS5381
32 * GPIO 3 -> M1 of CS5381 32 * GPIO 3 -> M1 of CS5381
@@ -207,6 +207,12 @@ static void xonar_gpio_changed(struct oxygen *chip);
207static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec, 207static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec,
208 u8 reg, u8 value) 208 u8 reg, u8 value)
209{ 209{
210 /*
211 * We don't want to do writes on SPI 4 because the EEPROM, which shares
212 * the same pin, might get confused and broken. We'd better take care
213 * that the driver works with the default register values ...
214 */
215#if 0
210 /* maps ALSA channel pair number to SPI output */ 216 /* maps ALSA channel pair number to SPI output */
211 static const u8 codec_map[4] = { 217 static const u8 codec_map[4] = {
212 0, 1, 2, 4 218 0, 1, 2, 4
@@ -217,6 +223,7 @@ static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec,
217 (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) | 223 (codec_map[codec] << OXYGEN_SPI_CODEC_SHIFT) |
218 OXYGEN_SPI_CEN_LATCH_CLOCK_HI, 224 OXYGEN_SPI_CEN_LATCH_CLOCK_HI,
219 (reg << 8) | value); 225 (reg << 8) | value);
226#endif
220} 227}
221 228
222static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec, 229static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec,
@@ -676,7 +683,7 @@ static void xonar_hdav_uart_input(struct oxygen *chip)
676 if (chip->uart_input_count >= 2 && 683 if (chip->uart_input_count >= 2 &&
677 chip->uart_input[chip->uart_input_count - 2] == 'O' && 684 chip->uart_input[chip->uart_input_count - 2] == 'O' &&
678 chip->uart_input[chip->uart_input_count - 1] == 'K') { 685 chip->uart_input[chip->uart_input_count - 1] == 'K') {
679 printk(KERN_DEBUG "message from Xonar HDAV HDMI chip received:"); 686 printk(KERN_DEBUG "message from Xonar HDAV HDMI chip received:\n");
680 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, 687 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
681 chip->uart_input, chip->uart_input_count); 688 chip->uart_input, chip->uart_input_count);
682 chip->uart_input_count = 0; 689 chip->uart_input_count = 0;
@@ -750,6 +757,9 @@ static const DECLARE_TLV_DB_SCALE(cs4362a_db_scale, -12700, 100, 0);
750 757
751static int xonar_d2_control_filter(struct snd_kcontrol_new *template) 758static int xonar_d2_control_filter(struct snd_kcontrol_new *template)
752{ 759{
760 if (!strncmp(template->name, "Master Playback ", 16))
761 /* disable volume/mute because they would require SPI writes */
762 return 1;
753 if (!strncmp(template->name, "CD Capture ", 11)) 763 if (!strncmp(template->name, "CD Capture ", 11))
754 /* CD in is actually connected to the video in pin */ 764 /* CD in is actually connected to the video in pin */
755 template->private_value ^= AC97_CD ^ AC97_VIDEO; 765 template->private_value ^= AC97_CD ^ AC97_VIDEO;
@@ -840,9 +850,8 @@ static const struct oxygen_model model_xonar_d2 = {
840 .dac_volume_min = 0x0f, 850 .dac_volume_min = 0x0f,
841 .dac_volume_max = 0xff, 851 .dac_volume_max = 0xff,
842 .misc_flags = OXYGEN_MISC_MIDI, 852 .misc_flags = OXYGEN_MISC_MIDI,
843 .function_flags = OXYGEN_FUNCTION_SPI | 853 .function_flags = OXYGEN_FUNCTION_SPI,
844 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 854 .dac_i2s_format = OXYGEN_I2S_FORMAT_I2S,
845 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
846 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 855 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
847}; 856};
848 857
@@ -899,6 +908,7 @@ static const struct oxygen_model model_xonar_hdav = {
899 .dac_channels = 8, 908 .dac_channels = 8,
900 .dac_volume_min = 0x0f, 909 .dac_volume_min = 0x0f,
901 .dac_volume_max = 0xff, 910 .dac_volume_max = 0xff,
911 .misc_flags = OXYGEN_MISC_MIDI,
902 .function_flags = OXYGEN_FUNCTION_2WIRE, 912 .function_flags = OXYGEN_FUNCTION_2WIRE,
903 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 913 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
904 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 914 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,