Lines Matching refs:ac97
18 static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
20 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
28 static int patch_build_controls(struct snd_ac97 * ac97, const struct snd_kcontrol_new *controls, int count)
33 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97));
41 static void reset_tlv(struct snd_ac97 *ac97, const char *name,
49 kctl = snd_ctl_find_id(ac97->bus->card, &sid);
55 static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page)
60 mutex_lock(&ac97->page_mutex);
61 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
62 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
63 ret = snd_ac97_update_bits(ac97, reg, mask, value);
64 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
65 mutex_unlock(&ac97->page_mutex); /* unlock paging */
81 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
83 ucontrol->value.enumerated.item[0] = ac97->indep_surround;
89 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
92 if (indep != ac97->indep_surround) {
93 ac97->indep_surround = indep;
94 if (ac97->build_ops->update_jacks)
95 ac97->build_ops->update_jacks(ac97);
110 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
112 ucontrol->value.enumerated.item[0] = ac97->channel_mode;
118 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
124 if (mode != ac97->channel_mode) {
125 ac97->channel_mode = mode;
126 if (ac97->build_ops->update_jacks)
127 ac97->build_ops->update_jacks(ac97);
172 static inline int is_surround_on(struct snd_ac97 *ac97)
174 return ac97->channel_mode >= 1;
177 static inline int is_clfe_on(struct snd_ac97 *ac97)
179 return ac97->channel_mode >= 2;
183 static inline int is_shared_surrout(struct snd_ac97 *ac97)
185 return !ac97->indep_surround && is_surround_on(ac97);
189 static inline int is_shared_clfeout(struct snd_ac97 *ac97)
191 return !ac97->indep_surround && is_clfe_on(ac97);
195 static inline int is_shared_linein(struct snd_ac97 *ac97)
197 return !ac97->indep_surround && !is_surround_on(ac97);
201 static inline int is_shared_micin(struct snd_ac97 *ac97)
203 return !ac97->indep_surround && !is_clfe_on(ac97);
206 static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
208 return is_surround_on(ac97);
230 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
233 val = ac97->regs[AC97_YMF7X3_3D_MODE_SEL];
244 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
250 return snd_ac97_update(ac97, AC97_YMF7X3_3D_MODE_SEL, val);
275 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
278 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
286 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
292 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val);
295 static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97)
300 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
301 err = snd_ctl_add(ac97->bus->card, kctl);
306 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
307 err = snd_ctl_add(ac97->bus->card,
309 ac97));
312 snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00);
331 static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97)
335 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
338 err = patch_build_controls(ac97,
344 snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201);
353 static int patch_yamaha_ymf743(struct snd_ac97 *ac97)
355 ac97->build_ops = &patch_yamaha_ymf743_ops;
356 ac97->caps |= AC97_BC_BASS_TREBLE;
357 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
358 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
359 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
376 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
379 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
386 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
393 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0028, val);
395 snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */
417 static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97)
421 err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif));
432 static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
441 ac97->build_ops = &patch_yamaha_ymf753_ops;
442 ac97->caps |= AC97_BC_BASS_TREBLE;
443 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
458 static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97)
467 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97));
471 snd_ac97_write_cache(ac97, AC97_WM97XX_FMIXER_VOL, 0x0808);
479 static int patch_wolfson03(struct snd_ac97 * ac97)
481 ac97->build_ops = &patch_wolfson_wm9703_ops;
494 static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97)
498 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97));
503 snd_ac97_write_cache(ac97, AC97_WM9704_TEST, 0x0200);
511 static int patch_wolfson04(struct snd_ac97 * ac97)
514 ac97->build_ops = &patch_wolfson_wm9704_ops;
518 static int patch_wolfson05(struct snd_ac97 * ac97)
521 ac97->build_ops = &patch_wolfson_wm9703_ops;
524 ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
634 static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97)
639 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97));
643 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808);
644 snd_ac97_write_cache(ac97, AC97_PCI_SVID, 0x0808);
645 snd_ac97_write_cache(ac97, AC97_VIDEO, 0x0808);
646 snd_ac97_write_cache(ac97, AC97_AUX, 0x0808);
647 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
648 snd_ac97_write_cache(ac97, AC97_CD, 0x0000);
656 static int patch_wolfson11(struct snd_ac97 * ac97)
659 ac97->build_ops = &patch_wolfson_wm9711_ops;
661 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_MIC |
802 static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97)
807 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97));
814 static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97)
819 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97));
823 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
824 snd_ac97_write_cache(ac97, AC97_PHONE, 0x0808);
825 snd_ac97_write_cache(ac97, AC97_MIC, 0x0808);
826 snd_ac97_write_cache(ac97, AC97_LINE, 0x00da);
827 snd_ac97_write_cache(ac97, AC97_CD, 0x0808);
828 snd_ac97_write_cache(ac97, AC97_VIDEO, 0xd612);
829 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x1ba0);
834 static void patch_wolfson_wm9713_suspend (struct snd_ac97 * ac97)
836 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xfeff);
837 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xffff);
840 static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97)
842 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
843 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
844 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
857 static int patch_wolfson13(struct snd_ac97 * ac97)
860 ac97->build_ops = &patch_wolfson_wm9713_ops;
862 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_PHONE |
865 ac97->scaps &= ~AC97_SCAP_MODEM;
867 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
868 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
869 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
877 static int patch_tritech_tr28028(struct snd_ac97 * ac97)
879 snd_ac97_write_cache(ac97, 0x26, 0x0300);
880 snd_ac97_write_cache(ac97, 0x26, 0x0000);
881 snd_ac97_write_cache(ac97, AC97_SURROUND_MASTER, 0x0000);
882 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x0000);
889 static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97)
894 err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97));
899 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
903 static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97)
908 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
909 err = snd_ctl_add(ac97->bus->card, kctl);
914 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
915 err = snd_ctl_add(ac97->bus->card, kctl);
920 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
938 static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97)
942 snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003);
943 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) {
944 err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1);
948 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) {
949 err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1);
953 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) {
954 err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1);
958 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) {
959 err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1);
971 static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
973 ac97->build_ops = &patch_sigmatel_stac9700_ops;
979 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
982 mutex_lock(&ac97->page_mutex);
983 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
984 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
986 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
987 mutex_unlock(&ac97->page_mutex);
1000 static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
1005 snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
1007 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
1008 err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1);
1011 return patch_sigmatel_stac97xx_specific(ac97);
1019 static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
1023 ac97->build_ops = &patch_sigmatel_stac9708_ops;
1024 ac97->caps |= 0x10; /* HP (sigmatel surround) support */
1026 codec72 = snd_ac97_read(ac97, AC97_SIGMATEL_BIAS2) & 0x8000;
1027 codec6c = snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG);
1030 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1031 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1000);
1032 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1033 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0007);
1035 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1036 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1001);
1037 snd_ac97_write_cache(ac97, AC97_SIGMATEL_DAC2INVERT, 0x0008);
1041 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1045 static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1047 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1048 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
1050 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1051 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x4000);
1052 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1053 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1055 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1059 static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1062 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1063 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1064 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1065 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1066 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1067 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1071 static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1074 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1075 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1076 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1077 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1078 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1079 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1094 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1098 val = ac97->regs[AC97_SIGMATEL_OUTSEL] >> shift;
1108 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1118 return ac97_update_bits_page(ac97, AC97_SIGMATEL_OUTSEL,
1133 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1137 val = ac97->regs[AC97_SIGMATEL_INSEL];
1144 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1147 return ac97_update_bits_page(ac97, AC97_SIGMATEL_INSEL, 7 << shift,
1162 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1164 ucontrol->value.enumerated.item[0] = ac97->regs[AC97_SIGMATEL_IOMISC] & 3;
1170 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1172 return ac97_update_bits_page(ac97, AC97_SIGMATEL_IOMISC, 3,
1207 static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97)
1211 err = patch_sigmatel_stac97xx_specific(ac97);
1214 err = patch_build_controls(ac97, snd_ac97_sigmatel_stac9758_controls,
1219 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Front Playback");
1223 snd_ac97_rename_vol_ctl(ac97, "Video Playback", "Surround Mix Playback");
1234 static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1258 if (ac97->pci &&
1259 ac97->subsystem_vendor == 0x107b &&
1260 ac97->subsystem_device == 0x0601)
1264 ac97->build_ops = &patch_sigmatel_stac9758_ops;
1266 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
1268 snd_ac97_write_cache(ac97, regs[i], pregs[i]);
1270 ac97->flags |= AC97_STEREO_MUTES;
1282 static int patch_cirrus_build_spdif(struct snd_ac97 * ac97)
1287 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
1291 err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1);
1294 switch (ac97->id & AC97_ID_CS_MASK) {
1296 err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1);
1303 snd_ac97_write_cache(ac97, AC97_CSR_SPDIF, 0x0a20);
1311 static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1324 ac97->build_ops = &patch_cirrus_ops;
1325 ac97->flags |= AC97_CS_SPDIF;
1326 ac97->rates[AC97_RATES_SPDIF] &= ~SNDRV_PCM_RATE_32000;
1327 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1328 snd_ac97_write_cache(ac97, AC97_CSR_ACMODE, 0x0080);
1332 static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1335 ac97->flags |= AC97_HAS_PC_BEEP;
1337 return patch_cirrus_spdif(ac97);
1347 static int patch_conexant_build_spdif(struct snd_ac97 * ac97)
1352 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
1356 err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1);
1361 snd_ac97_write_cache(ac97, AC97_CXR_AUDIO_MISC,
1362 snd_ac97_read(ac97, AC97_CXR_AUDIO_MISC) & ~(AC97_CXR_SPDIFEN|AC97_CXR_COPYRGT|AC97_CXR_SPDIF_MASK));
1370 static int patch_conexant(struct snd_ac97 * ac97)
1372 ac97->build_ops = &patch_conexant_ops;
1373 ac97->flags |= AC97_CX_SPDIF;
1374 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1375 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
1379 static int patch_cx20551(struct snd_ac97 *ac97)
1381 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1389 static void ad18xx_resume(struct snd_ac97 *ac97)
1398 if (test_bit(reg, ac97->reg_accessed)) {
1399 snd_ac97_write(ac97, reg, ac97->regs[reg]);
1400 snd_ac97_read(ac97, reg);
1404 if (! (ac97->flags & AC97_AD_MULTI))
1406 snd_ac97_restore_status(ac97);
1410 if (! ac97->spec.ad18xx.id[codec])
1413 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1414 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1415 ac97->bus->ops->write(ac97, AC97_AD_CODEC_CFG, ac97->spec.ad18xx.codec_cfg[codec]);
1418 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1424 if (test_bit(i, ac97->reg_accessed)) {
1428 if (! ac97->spec.ad18xx.id[codec])
1431 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1432 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1434 ac97->bus->ops->write(ac97, AC97_PCM, ac97->spec.ad18xx.pcmreg[codec]);
1437 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1444 snd_ac97_write(ac97, i, ac97->regs[i]);
1445 snd_ac97_read(ac97, i);
1449 snd_ac97_restore_iec958(ac97);
1452 static void ad1888_resume(struct snd_ac97 *ac97)
1454 ad18xx_resume(ac97);
1455 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x8080);
1471 static int patch_ad1819(struct snd_ac97 * ac97)
1476 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1477 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
1478 ac97->res_table = ad1819_restbl;
1482 static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, unsigned short mask)
1487 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, mask);
1488 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000); /* ID0C, ID1C, SDIE = off */
1489 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1492 ac97->spec.ad18xx.unchained[idx] = mask;
1493 ac97->spec.ad18xx.id[idx] = val;
1494 ac97->spec.ad18xx.codec_cfg[idx] = 0x0000;
1498 static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits)
1503 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]);
1504 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0004); // SDIE
1505 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1509 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, codec_bits);
1510 ac97->spec.ad18xx.chained[idx] = cfg_bits[idx];
1511 ac97->spec.ad18xx.id[idx] = val;
1512 ac97->spec.ad18xx.codec_cfg[idx] = codec_bits ? codec_bits : 0x0004;
1516 static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int cidx1, int cidx2)
1519 if (ac97->spec.ad18xx.unchained[cidx1] || ac97->spec.ad18xx.chained[cidx1])
1521 if (ac97->spec.ad18xx.unchained[cidx2] || ac97->spec.ad18xx.chained[cidx2])
1526 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1527 ac97->spec.ad18xx.unchained[unchained_idx]);
1528 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0002); // ID1C
1529 ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002;
1532 patch_ad1881_chained1(ac97, cidx1, 0);
1533 else if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C
1534 patch_ad1881_chained1(ac97, cidx2, 0);
1535 else if (patch_ad1881_chained1(ac97, cidx2, 0x0006)) // SDIE | ID1C
1536 patch_ad1881_chained1(ac97, cidx1, 0);
1538 patch_ad1881_chained1(ac97, cidx2, 0);
1548 static int patch_ad1881(struct snd_ac97 * ac97)
1561 val = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1562 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, val);
1563 codecs[0] = patch_ad1881_unchained(ac97, 0, (1<<12));
1564 codecs[1] = patch_ad1881_unchained(ac97, 1, (1<<14));
1565 codecs[2] = patch_ad1881_unchained(ac97, 2, (1<<13));
1571 if (ac97->spec.ad18xx.unchained[idx])
1572 patch_ad1881_chained(ac97, idx, cfg_idxs[idx][0], cfg_idxs[idx][1]);
1574 if (ac97->spec.ad18xx.id[1]) {
1575 ac97->flags |= AC97_AD_MULTI;
1576 ac97->scaps |= AC97_SCAP_SURROUND_DAC;
1578 if (ac97->spec.ad18xx.id[2]) {
1579 ac97->flags |= AC97_AD_MULTI;
1580 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC;
1585 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1588 if (ac97->spec.ad18xx.id[idx])
1592 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000);
1593 ac97->spec.ad18xx.codec_cfg[0] =
1594 ac97->spec.ad18xx.codec_cfg[1] =
1595 ac97->spec.ad18xx.codec_cfg[2] = 0x0000;
1598 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID);
1599 if (ac97->spec.ad18xx.id[0]) {
1600 ac97->id &= 0xffff0000;
1601 ac97->id |= ac97->spec.ad18xx.id[0];
1603 ac97->build_ops = &patch_ad1881_build_ops;
1618 static int patch_ad1885_specific(struct snd_ac97 * ac97)
1622 err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885));
1625 reset_tlv(ac97, "Headphone Playback Volume",
1637 static int patch_ad1885(struct snd_ac97 * ac97)
1639 patch_ad1881(ac97);
1644 snd_ac97_write_cache(ac97, AC97_AD_MISC, 0x0404);
1646 ac97->build_ops = &patch_ad1885_build_ops;
1650 static int patch_ad1886_specific(struct snd_ac97 * ac97)
1652 reset_tlv(ac97, "Headphone Playback Volume",
1664 static int patch_ad1886(struct snd_ac97 * ac97)
1666 patch_ad1881(ac97);
1669 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
1670 ac97->build_ops = &patch_ad1886_build_ops;
1785 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1788 val = ac97->regs[AC97_AD_SERIAL_CFG];
1795 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1801 return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val);
1812 static int patch_ad198x_post_spdif(struct snd_ac97 * ac97)
1814 return patch_build_controls(ac97, &snd_ac97_ad198x_spdif_source, 1);
1841 static int check_list(struct snd_ac97 *ac97, const unsigned int *list)
1843 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device;
1850 static int patch_ad1981a_specific(struct snd_ac97 * ac97)
1852 if (check_list(ac97, ad1981_jacks_denylist))
1854 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1882 static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1884 if (check_list(ac97, ad1981_jacks_allowlist))
1886 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1889 static int patch_ad1981a(struct snd_ac97 *ac97)
1891 patch_ad1881(ac97);
1892 ac97->build_ops = &patch_ad1981a_build_ops;
1893 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1894 ac97->flags |= AC97_STEREO_MUTES;
1895 check_ad1981_hp_jack_sense(ac97);
1902 static int patch_ad1981b_specific(struct snd_ac97 *ac97)
1906 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
1909 if (check_list(ac97, ad1981_jacks_denylist))
1911 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1923 static int patch_ad1981b(struct snd_ac97 *ac97)
1925 patch_ad1881(ac97);
1926 ac97->build_ops = &patch_ad1981b_build_ops;
1927 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1928 ac97->flags |= AC97_STEREO_MUTES;
1929 check_ad1981_hp_jack_sense(ac97);
1937 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1940 val = ac97->regs[AC97_AD_MISC];
1942 if (ac97->spec.ad18xx.lo_as_master)
1950 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1954 if (ac97->spec.ad18xx.lo_as_master)
1957 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1970 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1973 val = ac97->regs[AC97_AD_MISC];
1983 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1993 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1997 static void ad1888_update_jacks(struct snd_ac97 *ac97)
2001 if (!ac97->spec.ad18xx.lo_as_master && is_shared_linein(ac97))
2004 if (is_shared_micin(ac97))
2007 snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val);
2036 static int patch_ad1888_specific(struct snd_ac97 *ac97)
2038 if (!ac97->spec.ad18xx.lo_as_master) {
2040 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2042 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback",
2045 return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
2057 static int patch_ad1888(struct snd_ac97 * ac97)
2061 patch_ad1881(ac97);
2062 ac97->build_ops = &patch_ad1888_build_ops;
2068 if (ac97->subsystem_vendor == 0x1043 &&
2069 ac97->subsystem_device == 0x1193) /* ASUS A9T laptop */
2070 ac97->spec.ad18xx.lo_as_master = 1;
2072 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2076 if (!ac97->spec.ad18xx.lo_as_master)
2083 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc);
2084 ac97->flags |= AC97_STEREO_MUTES;
2088 static int patch_ad1980_specific(struct snd_ac97 *ac97)
2092 err = patch_ad1888_specific(ac97);
2095 return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2107 static int patch_ad1980(struct snd_ac97 * ac97)
2109 patch_ad1888(ac97);
2110 ac97->build_ops = &patch_ad1980_build_ops;
2128 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2130 val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
2140 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2147 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
2184 static void ad1985_update_jacks(struct snd_ac97 *ac97)
2186 ad1888_update_jacks(ac97);
2188 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
2189 is_shared_micin(ac97) ? 1 << 9 : 0);
2192 static int patch_ad1985_specific(struct snd_ac97 *ac97)
2197 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2199 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
2201 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2205 return patch_build_controls(ac97, snd_ac97_ad1985_controls,
2218 static int patch_ad1985(struct snd_ac97 * ac97)
2222 patch_ad1881(ac97);
2223 ac97->build_ops = &patch_ad1985_build_ops;
2224 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2228 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
2233 ac97->flags |= AC97_STEREO_MUTES;
2236 ad1985_update_jacks(ac97);
2239 ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
2248 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2251 val = ac97->regs[AC97_AD_MISC3];
2259 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2262 int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
2264 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
2271 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2284 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2287 val = ac97->regs[AC97_AD_MISC];
2295 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2298 int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
2300 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
2307 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2320 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2322 ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
2329 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2332 if (swap != ac97->spec.ad18xx.swap_mic_linein) {
2333 ac97->spec.ad18xx.swap_mic_linein = swap;
2334 if (ac97->build_ops->update_jacks)
2335 ac97->build_ops->update_jacks(ac97);
2345 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2347 unsigned short reg = ac97->regs[AC97_AD_MISC2];
2363 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2397 cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2401 lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
2405 mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2457 static void ad1986_update_jacks(struct snd_ac97 *ac97)
2463 if (!is_surround_on(ac97))
2465 if (!is_clfe_on(ac97))
2469 if (is_shared_linein(ac97))
2471 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2473 snd_ac97_update_bits(ac97, AC97_AD_MISC,
2479 if (is_shared_micin(ac97))
2481 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2485 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
2490 static int patch_ad1986_specific(struct snd_ac97 *ac97)
2494 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2498 return patch_build_controls(ac97, snd_ac97_ad1986_controls,
2511 static int patch_ad1986(struct snd_ac97 * ac97)
2513 patch_ad1881(ac97);
2514 ac97->build_ops = &patch_ad1986_build_ops;
2515 ac97->flags |= AC97_STEREO_MUTES;
2518 ad1986_update_jacks(ac97);
2526 static int patch_alc203(struct snd_ac97 *ac97)
2528 snd_ac97_update_bits(ac97, 0x7a, 0x400, 0x400);
2535 static void alc650_update_jacks(struct snd_ac97 *ac97)
2540 shared = is_shared_surrout(ac97);
2541 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
2544 shared = is_shared_clfeout(ac97);
2546 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2549 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10,
2552 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100,
2559 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2560 struct snd_pcm_chmap *map = ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK];
2613 static int patch_alc650_specific(struct snd_ac97 * ac97)
2617 err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650));
2620 if (ac97->ext_id & AC97_EI_SPDIF) {
2621 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650));
2625 if (ac97->id != AC97_ID_ALC650F)
2626 reset_tlv(ac97, "Master Playback Volume",
2636 static int patch_alc650(struct snd_ac97 * ac97)
2640 ac97->build_ops = &patch_alc650_ops;
2643 val = snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f;
2645 ac97->id = 0x414c4720; /* Old version */
2647 ac97->id = 0x414c4721; /* D version */
2649 ac97->id = 0x414c4722; /* E version */
2651 ac97->id = 0x414c4723; /* F version */
2655 ac97->spec.dev_flags = (ac97->id == 0x414c4722 ||
2656 ac97->id == 0x414c4723);
2659 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2660 snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x8000);
2663 val = snd_ac97_read(ac97, AC97_ALC650_CLOCK);
2665 if (ac97->spec.dev_flags &&
2667 ! (ac97->subsystem_vendor == 0x1043 &&
2668 ac97->subsystem_device == 0x1103))
2672 snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, val);
2679 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 0);
2683 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_SETUP,
2684 snd_ac97_read(ac97, AC97_ALC650_GPIO_SETUP) | 0x01);
2685 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2686 (snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x100) & ~0x10);
2689 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2690 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2694 static void alc655_update_jacks(struct snd_ac97 *ac97)
2699 shared = is_shared_surrout(ac97);
2700 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
2703 shared = is_shared_clfeout(ac97);
2705 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2707 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10,
2725 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2727 if (ac97->spec.dev_flags)
2735 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2738 val = ac97->regs[AC97_ALC650_MULTICH];
2740 if (ac97->spec.dev_flags && val == 3)
2748 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2750 return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 3 << 12,
2768 static int patch_alc655_specific(struct snd_ac97 * ac97)
2772 err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655));
2775 if (ac97->ext_id & AC97_EI_SPDIF) {
2776 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655));
2788 static int patch_alc655(struct snd_ac97 * ac97)
2792 if (ac97->id == AC97_ID_ALC658) {
2793 ac97->spec.dev_flags = 1; /* ALC658 */
2794 if ((snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f) == 2) {
2795 ac97->id = AC97_ID_ALC658D;
2796 ac97->spec.dev_flags = 2;
2800 ac97->build_ops = &patch_alc655_ops;
2803 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2806 val = snd_ac97_read(ac97, 0x7a); /* misc control */
2807 if (ac97->spec.dev_flags) /* ALC658 */
2810 if (ac97->subsystem_vendor == 0x1462 &&
2811 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2812 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2813 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2814 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2815 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2820 ac97->ext_id |= AC97_EI_SPDIF;
2823 snd_ac97_write_cache(ac97, 0x7a, val);
2829 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2832 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2833 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2836 if (ac97->id == AC97_ID_ALC658D)
2837 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800);
2847 static void alc850_update_jacks(struct snd_ac97 *ac97)
2853 shared = is_shared_surrout(ac97);
2855 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
2858 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
2861 shared = is_shared_clfeout(ac97);
2863 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
2866 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2869 aux_is_back_surround = alc850_is_aux_back_surround(ac97);
2871 snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
2882 static int patch_alc850_specific(struct snd_ac97 *ac97)
2886 err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850));
2889 if (ac97->ext_id & AC97_EI_SPDIF) {
2890 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655));
2902 static int patch_alc850(struct snd_ac97 *ac97)
2904 ac97->build_ops = &patch_alc850_ops;
2906 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
2907 ac97->flags |= AC97_HAS_8CH;
2910 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2919 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2923 snd_ac97_write_cache(ac97, 0x7a, (1<<1)|(1<<4)|(0<<5)|(1<<6)|
2928 snd_ac97_write_cache(ac97, 0x76, (0<<0)|(0<<2)|(1<<4)|(1<<7)|(2<<8)|
2932 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2933 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2937 static int patch_aztech_azf3328_specific(struct snd_ac97 *ac97)
2940 snd_ac97_find_mixer_ctl(ac97, "3D Control - Center");
2942 snd_ac97_find_mixer_ctl(ac97, "3D Control - Depth");
2951 snd_ac97_rename_vol_ctl(ac97,
2961 snd_ac97_rename_vol_ctl(ac97,
2964 snd_ac97_rename_vol_ctl(ac97,
2975 static int patch_aztech_azf3328(struct snd_ac97 *ac97)
2977 ac97->build_ops = &patch_aztech_azf3328_ops;
2984 static void cm9738_update_jacks(struct snd_ac97 *ac97)
2987 snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
2988 is_shared_surrout(ac97) ? (1 << 10) : 0);
2997 static int patch_cm9738_specific(struct snd_ac97 * ac97)
2999 return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls));
3007 static int patch_cm9738(struct snd_ac97 * ac97)
3009 ac97->build_ops = &patch_cm9738_ops;
3012 ac97->flags |= AC97_HAS_NO_PCM_VOL;
3013 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3027 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3030 val = ac97->regs[AC97_CM9739_SPDIF_CTRL];
3037 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3039 return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL,
3062 static void cm9739_update_jacks(struct snd_ac97 *ac97)
3065 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
3066 is_shared_surrout(ac97) ? (1 << 10) : 0);
3068 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
3069 is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
3077 static int patch_cm9739_specific(struct snd_ac97 * ac97)
3079 return patch_build_controls(ac97, snd_ac97_cm9739_controls, ARRAY_SIZE(snd_ac97_cm9739_controls));
3082 static int patch_cm9739_post_spdif(struct snd_ac97 * ac97)
3084 return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif));
3093 static int patch_cm9739(struct snd_ac97 * ac97)
3097 ac97->build_ops = &patch_cm9739_ops;
3100 ac97->flags |= AC97_HAS_NO_MASTER_VOL | AC97_HAS_NO_PCM_VOL;
3101 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8000);
3102 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3105 val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
3108 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3109 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) | 0x01);
3110 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3112 ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */
3113 ac97->rates[AC97_RATES_SPDIF] = 0;
3125 val = snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) & (1 << 4);
3128 if (! (ac97->ext_id & AC97_EI_SPDIF))
3130 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN, val);
3133 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3134 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3136 if (ac97->pci &&
3137 ac97->subsystem_vendor == 0x1043 &&
3138 ac97->subsystem_device == 0x1843) {
3139 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3140 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) & ~0x01);
3141 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN,
3142 snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) | (1 << 14));
3152 static void cm9761_update_jacks(struct snd_ac97 *ac97)
3179 val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
3180 val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
3181 val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
3182 val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
3184 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
3201 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3203 if (ac97->regs[AC97_CM9761_FUNC] & 0x1)
3205 else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2)
3214 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3217 return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1);
3218 snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0);
3219 return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2,
3247 static int patch_cm9761_post_spdif(struct snd_ac97 * ac97)
3249 return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif));
3252 static int patch_cm9761_specific(struct snd_ac97 * ac97)
3254 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
3263 static int patch_cm9761(struct snd_ac97 *ac97)
3271 ac97->flags |= /*AC97_HAS_NO_MASTER_VOL |*/ AC97_HAS_NO_PCM_VOL;
3272 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808);
3273 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808);
3275 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B, 2 = model 83 */
3276 if (ac97->id == AC97_ID_CM9761_82) {
3279 val = snd_ac97_read(ac97, AC97_INT_PAGING);
3280 snd_ac97_write_cache(ac97, AC97_INT_PAGING, (val & ~0x0f) | 0x01);
3281 tmp = snd_ac97_read(ac97, 0x60);
3282 ac97->spec.dev_flags = tmp & 1; /* revision B? */
3283 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
3284 } else if (ac97->id == AC97_ID_CM9761_83)
3285 ac97->spec.dev_flags = 2;
3287 ac97->build_ops = &patch_cm9761_ops;
3291 ac97->ext_id |= AC97_EI_SPDIF;
3293 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
3295 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */
3296 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3317 if (ac97->spec.dev_flags)
3322 val = snd_ac97_read(ac97, AC97_CM9761_MULTI_CHAN);
3324 snd_ac97_write_cache(ac97, AC97_CM9761_MULTI_CHAN, val);
3327 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3328 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3350 static int patch_cm9780_specific(struct snd_ac97 *ac97)
3352 return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
3360 static int patch_cm9780(struct snd_ac97 *ac97)
3364 ac97->build_ops = &patch_cm9780_ops;
3367 if (ac97->ext_id & AC97_EI_SPDIF) {
3368 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3369 val = snd_ac97_read(ac97, AC97_CM9780_SPDIF);
3371 snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val);
3384 static int patch_vt1613_specific(struct snd_ac97 *ac97)
3386 return patch_build_controls(ac97, &snd_ac97_controls_vt1613[0],
3394 static int patch_vt1613(struct snd_ac97 *ac97)
3396 ac97->build_ops = &patch_vt1613_ops;
3398 ac97->flags |= AC97_HAS_NO_VIDEO;
3399 ac97->caps |= AC97_BC_HEADPHONE;
3431 static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
3434 return snd_ctl_find_id_mixer(ac97->bus->card, name);
3438 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3448 err = snd_ctl_add(ac97->bus->card, kctl);
3452 return snd_ctl_add_followers(ac97->bus->card, kctl, followers);
3455 static int patch_vt1616_specific(struct snd_ac97 * ac97)
3460 if (snd_ac97_try_bit(ac97, 0x5a, 9)) {
3461 err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1);
3465 err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1);
3470 kctl = snd_ac97_find_mixer_ctl(ac97, "Master Playback Volume");
3474 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
3476 err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
3481 err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
3493 static int patch_vt1616(struct snd_ac97 * ac97)
3495 ac97->build_ops = &patch_vt1616_ops;
3589 static int patch_vt1617a(struct snd_ac97 * ac97)
3597 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3606 val = snd_ac97_read(ac97, 0x5c);
3608 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3610 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3611 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3612 ac97->build_ops = &patch_vt1616_ops;
3804 static int patch_vt1618(struct snd_ac97 *ac97)
3806 return patch_build_controls(ac97, snd_ac97_controls_vt1618,
3812 static void it2646_update_jacks(struct snd_ac97 *ac97)
3815 snd_ac97_update_bits(ac97, 0x76, 1 << 9,
3816 is_shared_surrout(ac97) ? (1<<9) : 0);
3818 snd_ac97_update_bits(ac97, 0x76, 1 << 10,
3819 is_shared_clfeout(ac97) ? (1<<10) : 0);
3833 static int patch_it2646_specific(struct snd_ac97 * ac97)
3836 err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646));
3839 err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646));
3850 static int patch_it2646(struct snd_ac97 * ac97)
3852 ac97->build_ops = &patch_it2646_ops;
3854 snd_ac97_write_cache(ac97, 0x5E, 0x0808);
3855 snd_ac97_write_cache(ac97, 0x7A, 0x0808);
3870 static int patch_si3036_specific(struct snd_ac97 * ac97)
3874 err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97));
3885 static int mpatch_si3036(struct snd_ac97 * ac97)
3887 ac97->build_ops = &patch_si3036_ops;
3888 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
3889 snd_ac97_write_cache(ac97, 0x68, 0);
3917 static int patch_lm4550(struct snd_ac97 *ac97)
3919 ac97->res_table = lm4550_restbl;