Lines Matching full: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,
46 kctl = snd_ctl_find_id_mixer(ac97->bus->card, name);
52 static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page)
57 guard(mutex)(&ac97->page_mutex);
58 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
59 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
60 ret = snd_ac97_update_bits(ac97, reg, mask, value);
61 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
77 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
79 ucontrol->value.enumerated.item[0] = ac97->indep_surround;
85 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
88 if (indep != ac97->indep_surround) {
89 ac97->indep_surround = indep;
90 if (ac97->build_ops->update_jacks)
91 ac97->build_ops->update_jacks(ac97);
106 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
108 ucontrol->value.enumerated.item[0] = ac97->channel_mode;
114 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
120 if (mode != ac97->channel_mode) {
121 ac97->channel_mode = mode;
122 if (ac97->build_ops->update_jacks)
123 ac97->build_ops->update_jacks(ac97);
168 static inline int is_surround_on(struct snd_ac97 *ac97)
170 return ac97->channel_mode >= 1;
173 static inline int is_clfe_on(struct snd_ac97 *ac97)
175 return ac97->channel_mode >= 2;
179 static inline int is_shared_surrout(struct snd_ac97 *ac97)
181 return !ac97->indep_surround && is_surround_on(ac97);
185 static inline int is_shared_clfeout(struct snd_ac97 *ac97)
187 return !ac97->indep_surround && is_clfe_on(ac97);
191 static inline int is_shared_linein(struct snd_ac97 *ac97)
193 return !ac97->indep_surround && !is_surround_on(ac97);
197 static inline int is_shared_micin(struct snd_ac97 *ac97)
199 return !ac97->indep_surround && !is_clfe_on(ac97);
202 static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
204 return is_surround_on(ac97);
226 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
229 val = ac97->regs[AC97_YMF7X3_3D_MODE_SEL];
240 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
246 return snd_ac97_update(ac97, AC97_YMF7X3_3D_MODE_SEL, val);
271 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
274 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
282 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
288 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val);
291 static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97)
296 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
297 err = snd_ctl_add(ac97->bus->card, kctl);
302 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
303 err = snd_ctl_add(ac97->bus->card,
305 ac97));
308 snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00);
327 static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97)
331 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
334 err = patch_build_controls(ac97,
340 snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201);
349 static int patch_yamaha_ymf743(struct snd_ac97 *ac97)
351 ac97->build_ops = &patch_yamaha_ymf743_ops;
352 ac97->caps |= AC97_BC_BASS_TREBLE;
353 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
354 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
355 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
372 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
375 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
382 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
389 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0028, val);
391 snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */
413 static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97)
417 err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif));
428 static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
437 ac97->build_ops = &patch_yamaha_ymf753_ops;
438 ac97->caps |= AC97_BC_BASS_TREBLE;
439 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
454 static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97)
463 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97));
467 snd_ac97_write_cache(ac97, AC97_WM97XX_FMIXER_VOL, 0x0808);
475 static int patch_wolfson03(struct snd_ac97 * ac97)
477 ac97->build_ops = &patch_wolfson_wm9703_ops;
490 static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97)
494 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97));
499 snd_ac97_write_cache(ac97, AC97_WM9704_TEST, 0x0200);
507 static int patch_wolfson04(struct snd_ac97 * ac97)
510 ac97->build_ops = &patch_wolfson_wm9704_ops;
514 static int patch_wolfson05(struct snd_ac97 * ac97)
517 ac97->build_ops = &patch_wolfson_wm9703_ops;
520 ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
630 static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97)
635 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97));
639 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808);
640 snd_ac97_write_cache(ac97, AC97_PCI_SVID, 0x0808);
641 snd_ac97_write_cache(ac97, AC97_VIDEO, 0x0808);
642 snd_ac97_write_cache(ac97, AC97_AUX, 0x0808);
643 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
644 snd_ac97_write_cache(ac97, AC97_CD, 0x0000);
652 static int patch_wolfson11(struct snd_ac97 * ac97)
655 ac97->build_ops = &patch_wolfson_wm9711_ops;
657 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_MIC |
798 static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97)
803 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97));
810 static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97)
815 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97));
819 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
820 snd_ac97_write_cache(ac97, AC97_PHONE, 0x0808);
821 snd_ac97_write_cache(ac97, AC97_MIC, 0x0808);
822 snd_ac97_write_cache(ac97, AC97_LINE, 0x00da);
823 snd_ac97_write_cache(ac97, AC97_CD, 0x0808);
824 snd_ac97_write_cache(ac97, AC97_VIDEO, 0xd612);
825 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x1ba0);
830 static void patch_wolfson_wm9713_suspend (struct snd_ac97 * ac97)
832 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xfeff);
833 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xffff);
836 static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97)
838 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
839 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
840 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
853 static int patch_wolfson13(struct snd_ac97 * ac97)
856 ac97->build_ops = &patch_wolfson_wm9713_ops;
858 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_PHONE |
861 ac97->scaps &= ~AC97_SCAP_MODEM;
863 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
864 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
865 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
873 static int patch_tritech_tr28028(struct snd_ac97 * ac97)
875 snd_ac97_write_cache(ac97, 0x26, 0x0300);
876 snd_ac97_write_cache(ac97, 0x26, 0x0000);
877 snd_ac97_write_cache(ac97, AC97_SURROUND_MASTER, 0x0000);
878 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x0000);
885 static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97)
890 err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97));
895 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
899 static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97)
904 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
905 err = snd_ctl_add(ac97->bus->card, kctl);
910 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
911 err = snd_ctl_add(ac97->bus->card, kctl);
916 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
934 static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97)
938 snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003);
939 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) {
940 err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1);
944 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) {
945 err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1);
949 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) {
950 err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1);
954 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) {
955 err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1);
967 static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
969 ac97->build_ops = &patch_sigmatel_stac9700_ops;
975 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
978 guard(mutex)(&ac97->page_mutex);
979 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
980 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
982 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
995 static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
1000 snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
1002 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
1003 err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1);
1006 return patch_sigmatel_stac97xx_specific(ac97);
1014 static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
1018 ac97->build_ops = &patch_sigmatel_stac9708_ops;
1019 ac97->caps |= 0x10; /* HP (sigmatel surround) support */
1021 codec72 = snd_ac97_read(ac97, AC97_SIGMATEL_BIAS2) & 0x8000;
1022 codec6c = snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG);
1025 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1026 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1000);
1027 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1028 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0007);
1030 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1031 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1001);
1032 snd_ac97_write_cache(ac97, AC97_SIGMATEL_DAC2INVERT, 0x0008);
1036 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1040 static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1042 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1043 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
1045 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1046 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x4000);
1047 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1048 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1050 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1054 static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1057 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1058 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1059 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1060 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1061 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1062 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1066 static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1069 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1070 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1071 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1072 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1073 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1074 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1089 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1093 val = ac97->regs[AC97_SIGMATEL_OUTSEL] >> shift;
1103 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1113 return ac97_update_bits_page(ac97, AC97_SIGMATEL_OUTSEL,
1128 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1132 val = ac97->regs[AC97_SIGMATEL_INSEL];
1139 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1142 return ac97_update_bits_page(ac97, AC97_SIGMATEL_INSEL, 7 << shift,
1157 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1159 ucontrol->value.enumerated.item[0] = ac97->regs[AC97_SIGMATEL_IOMISC] & 3;
1165 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1167 return ac97_update_bits_page(ac97, AC97_SIGMATEL_IOMISC, 3,
1202 static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97)
1206 err = patch_sigmatel_stac97xx_specific(ac97);
1209 err = patch_build_controls(ac97, snd_ac97_sigmatel_stac9758_controls,
1214 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Front Playback");
1218 snd_ac97_rename_vol_ctl(ac97, "Video Playback", "Surround Mix Playback");
1229 static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1253 if (ac97->pci &&
1254 ac97->subsystem_vendor == 0x107b &&
1255 ac97->subsystem_device == 0x0601)
1259 ac97->build_ops = &patch_sigmatel_stac9758_ops;
1261 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
1263 snd_ac97_write_cache(ac97, regs[i], pregs[i]);
1265 ac97->flags |= AC97_STEREO_MUTES;
1274 AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA", AC97_CSR_ACMODE, 0, 3, 0)
1277 static int patch_cirrus_build_spdif(struct snd_ac97 * ac97)
1282 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
1286 err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1);
1289 switch (ac97->id & AC97_ID_CS_MASK) {
1291 err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1);
1298 snd_ac97_write_cache(ac97, AC97_CSR_SPDIF, 0x0a20);
1306 static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1312 - sp/dif control register is 0x68. differs from AC97:
1315 - only 44.1/48k [00 = 48, 01=44,1] (AC97 is 00=44.1, 10=48)
1319 ac97->build_ops = &patch_cirrus_ops;
1320 ac97->flags |= AC97_CS_SPDIF;
1321 ac97->rates[AC97_RATES_SPDIF] &= ~SNDRV_PCM_RATE_32000;
1322 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1323 snd_ac97_write_cache(ac97, AC97_CSR_ACMODE, 0x0080);
1327 static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1330 ac97->flags |= AC97_HAS_PC_BEEP;
1332 return patch_cirrus_spdif(ac97);
1342 static int patch_conexant_build_spdif(struct snd_ac97 * ac97)
1347 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
1351 err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1);
1356 snd_ac97_write_cache(ac97, AC97_CXR_AUDIO_MISC,
1357 snd_ac97_read(ac97, AC97_CXR_AUDIO_MISC) & ~(AC97_CXR_SPDIFEN|AC97_CXR_COPYRGT|AC97_CXR_SPDIF_MASK));
1365 static int patch_conexant(struct snd_ac97 * ac97)
1367 ac97->build_ops = &patch_conexant_ops;
1368 ac97->flags |= AC97_CX_SPDIF;
1369 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1370 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
1374 static int patch_cx20551(struct snd_ac97 *ac97)
1376 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1384 static void ad18xx_resume(struct snd_ac97 *ac97)
1393 if (test_bit(reg, ac97->reg_accessed)) {
1394 snd_ac97_write(ac97, reg, ac97->regs[reg]);
1395 snd_ac97_read(ac97, reg);
1399 if (! (ac97->flags & AC97_AD_MULTI))
1401 snd_ac97_restore_status(ac97);
1405 if (! ac97->spec.ad18xx.id[codec])
1408 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1409 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1410 ac97->bus->ops->write(ac97, AC97_AD_CODEC_CFG, ac97->spec.ad18xx.codec_cfg[codec]);
1413 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1419 if (test_bit(i, ac97->reg_accessed)) {
1423 if (! ac97->spec.ad18xx.id[codec])
1426 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1427 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1429 ac97->bus->ops->write(ac97, AC97_PCM, ac97->spec.ad18xx.pcmreg[codec]);
1432 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1439 snd_ac97_write(ac97, i, ac97->regs[i]);
1440 snd_ac97_read(ac97, i);
1444 snd_ac97_restore_iec958(ac97);
1447 static void ad1888_resume(struct snd_ac97 *ac97)
1449 ad18xx_resume(ac97);
1450 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x8080);
1466 static int patch_ad1819(struct snd_ac97 * ac97)
1471 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1472 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
1473 ac97->res_table = ad1819_restbl;
1477 static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, unsigned short mask)
1482 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, mask);
1483 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000); /* ID0C, ID1C, SDIE = off */
1484 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1487 ac97->spec.ad18xx.unchained[idx] = mask;
1488 ac97->spec.ad18xx.id[idx] = val;
1489 ac97->spec.ad18xx.codec_cfg[idx] = 0x0000;
1493 static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits)
1498 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]);
1499 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0004); // SDIE
1500 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1504 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, codec_bits);
1505 ac97->spec.ad18xx.chained[idx] = cfg_bits[idx];
1506 ac97->spec.ad18xx.id[idx] = val;
1507 ac97->spec.ad18xx.codec_cfg[idx] = codec_bits ? codec_bits : 0x0004;
1511 static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int cidx1, int cidx2)
1514 if (ac97->spec.ad18xx.unchained[cidx1] || ac97->spec.ad18xx.chained[cidx1])
1516 if (ac97->spec.ad18xx.unchained[cidx2] || ac97->spec.ad18xx.chained[cidx2])
1521 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1522 ac97->spec.ad18xx.unchained[unchained_idx]);
1523 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0002); // ID1C
1524 ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002;
1527 patch_ad1881_chained1(ac97, cidx1, 0);
1528 else if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C
1529 patch_ad1881_chained1(ac97, cidx2, 0);
1530 else if (patch_ad1881_chained1(ac97, cidx2, 0x0006)) // SDIE | ID1C
1531 patch_ad1881_chained1(ac97, cidx1, 0);
1533 patch_ad1881_chained1(ac97, cidx2, 0);
1543 static int patch_ad1881(struct snd_ac97 * ac97)
1556 val = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1557 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, val);
1558 codecs[0] = patch_ad1881_unchained(ac97, 0, (1<<12));
1559 codecs[1] = patch_ad1881_unchained(ac97, 1, (1<<14));
1560 codecs[2] = patch_ad1881_unchained(ac97, 2, (1<<13));
1566 if (ac97->spec.ad18xx.unchained[idx])
1567 patch_ad1881_chained(ac97, idx, cfg_idxs[idx][0], cfg_idxs[idx][1]);
1569 if (ac97->spec.ad18xx.id[1]) {
1570 ac97->flags |= AC97_AD_MULTI;
1571 ac97->scaps |= AC97_SCAP_SURROUND_DAC;
1573 if (ac97->spec.ad18xx.id[2]) {
1574 ac97->flags |= AC97_AD_MULTI;
1575 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC;
1580 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1583 if (ac97->spec.ad18xx.id[idx])
1587 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000);
1588 ac97->spec.ad18xx.codec_cfg[0] =
1589 ac97->spec.ad18xx.codec_cfg[1] =
1590 ac97->spec.ad18xx.codec_cfg[2] = 0x0000;
1593 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID);
1594 if (ac97->spec.ad18xx.id[0]) {
1595 ac97->id &= 0xffff0000;
1596 ac97->id |= ac97->spec.ad18xx.id[0];
1598 ac97->build_ops = &patch_ad1881_build_ops;
1613 static int patch_ad1885_specific(struct snd_ac97 * ac97)
1617 err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885));
1620 reset_tlv(ac97, "Headphone Playback Volume",
1632 static int patch_ad1885(struct snd_ac97 * ac97)
1634 patch_ad1881(ac97);
1639 snd_ac97_write_cache(ac97, AC97_AD_MISC, 0x0404);
1641 ac97->build_ops = &patch_ad1885_build_ops;
1645 static int patch_ad1886_specific(struct snd_ac97 * ac97)
1647 reset_tlv(ac97, "Headphone Playback Volume",
1659 static int patch_ad1886(struct snd_ac97 * ac97)
1661 patch_ad1881(ac97);
1664 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
1665 ac97->build_ops = &patch_ad1886_build_ops;
1690 #define AC97_AD198X_AC97NC 0x4000 /* AC97 no compatible mode */
1714 #define AC97_AD1986_AC97NC 0x4000 /* AC97 no compatible mode (r/o 1) */
1780 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1783 val = ac97->regs[AC97_AD_SERIAL_CFG];
1790 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1796 return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val);
1807 static int patch_ad198x_post_spdif(struct snd_ac97 * ac97)
1809 return patch_build_controls(ac97, &snd_ac97_ad198x_spdif_source, 1);
1836 static int check_list(struct snd_ac97 *ac97, const unsigned int *list)
1838 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device;
1845 static int patch_ad1981a_specific(struct snd_ac97 * ac97)
1847 if (check_list(ac97, ad1981_jacks_denylist))
1849 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1877 static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1879 if (check_list(ac97, ad1981_jacks_allowlist))
1881 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1884 static int patch_ad1981a(struct snd_ac97 *ac97)
1886 patch_ad1881(ac97);
1887 ac97->build_ops = &patch_ad1981a_build_ops;
1888 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1889 ac97->flags |= AC97_STEREO_MUTES;
1890 check_ad1981_hp_jack_sense(ac97);
1897 static int patch_ad1981b_specific(struct snd_ac97 *ac97)
1901 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
1904 if (check_list(ac97, ad1981_jacks_denylist))
1906 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1918 static int patch_ad1981b(struct snd_ac97 *ac97)
1920 patch_ad1881(ac97);
1921 ac97->build_ops = &patch_ad1981b_build_ops;
1922 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1923 ac97->flags |= AC97_STEREO_MUTES;
1924 check_ad1981_hp_jack_sense(ac97);
1932 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1935 val = ac97->regs[AC97_AD_MISC];
1937 if (ac97->spec.ad18xx.lo_as_master)
1945 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1949 if (ac97->spec.ad18xx.lo_as_master)
1952 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1965 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1968 val = ac97->regs[AC97_AD_MISC];
1978 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1988 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1992 static void ad1888_update_jacks(struct snd_ac97 *ac97)
1996 if (!ac97->spec.ad18xx.lo_as_master && is_shared_linein(ac97))
1999 if (is_shared_micin(ac97))
2002 snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val);
2031 static int patch_ad1888_specific(struct snd_ac97 *ac97)
2033 if (!ac97->spec.ad18xx.lo_as_master) {
2035 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2037 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback",
2040 return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
2052 static int patch_ad1888(struct snd_ac97 * ac97)
2056 patch_ad1881(ac97);
2057 ac97->build_ops = &patch_ad1888_build_ops;
2063 if (ac97->subsystem_vendor == 0x1043 &&
2064 ac97->subsystem_device == 0x1193) /* ASUS A9T laptop */
2065 ac97->spec.ad18xx.lo_as_master = 1;
2067 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2071 if (!ac97->spec.ad18xx.lo_as_master)
2078 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc);
2079 ac97->flags |= AC97_STEREO_MUTES;
2083 static int patch_ad1980_specific(struct snd_ac97 *ac97)
2087 err = patch_ad1888_specific(ac97);
2090 return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2102 static int patch_ad1980(struct snd_ac97 * ac97)
2104 patch_ad1888(ac97);
2105 ac97->build_ops = &patch_ad1980_build_ops;
2123 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2125 val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
2135 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2142 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
2179 static void ad1985_update_jacks(struct snd_ac97 *ac97)
2181 ad1888_update_jacks(ac97);
2183 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
2184 is_shared_micin(ac97) ? 1 << 9 : 0);
2187 static int patch_ad1985_specific(struct snd_ac97 *ac97)
2192 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2194 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
2196 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2200 return patch_build_controls(ac97, snd_ac97_ad1985_controls,
2213 static int patch_ad1985(struct snd_ac97 * ac97)
2217 patch_ad1881(ac97);
2218 ac97->build_ops = &patch_ad1985_build_ops;
2219 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2223 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
2228 ac97->flags |= AC97_STEREO_MUTES;
2231 ad1985_update_jacks(ac97);
2234 ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
2243 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2246 val = ac97->regs[AC97_AD_MISC3];
2254 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2257 int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
2259 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
2266 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2279 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2282 val = ac97->regs[AC97_AD_MISC];
2290 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2293 int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
2295 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
2302 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2315 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2317 ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
2324 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2327 if (swap != ac97->spec.ad18xx.swap_mic_linein) {
2328 ac97->spec.ad18xx.swap_mic_linein = swap;
2329 if (ac97->build_ops->update_jacks)
2330 ac97->build_ops->update_jacks(ac97);
2340 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2342 unsigned short reg = ac97->regs[AC97_AD_MISC2];
2358 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2392 cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2396 lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
2400 mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2452 static void ad1986_update_jacks(struct snd_ac97 *ac97)
2458 if (!is_surround_on(ac97))
2460 if (!is_clfe_on(ac97))
2464 if (is_shared_linein(ac97))
2466 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2468 snd_ac97_update_bits(ac97, AC97_AD_MISC,
2474 if (is_shared_micin(ac97))
2476 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2480 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
2485 static int patch_ad1986_specific(struct snd_ac97 *ac97)
2489 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2493 return patch_build_controls(ac97, snd_ac97_ad1986_controls,
2506 static int patch_ad1986(struct snd_ac97 * ac97)
2508 patch_ad1881(ac97);
2509 ac97->build_ops = &patch_ad1986_build_ops;
2510 ac97->flags |= AC97_STEREO_MUTES;
2513 ad1986_update_jacks(ac97);
2521 static int patch_alc203(struct snd_ac97 *ac97)
2523 snd_ac97_update_bits(ac97, 0x7a, 0x400, 0x400);
2530 static void alc650_update_jacks(struct snd_ac97 *ac97)
2535 shared = is_shared_surrout(ac97);
2536 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
2539 shared = is_shared_clfeout(ac97);
2541 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2544 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10,
2547 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100,
2554 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2555 struct snd_pcm_chmap *map = ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK];
2608 static int patch_alc650_specific(struct snd_ac97 * ac97)
2612 err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650));
2615 if (ac97->ext_id & AC97_EI_SPDIF) {
2616 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650));
2620 if (ac97->id != AC97_ID_ALC650F)
2621 reset_tlv(ac97, "Master Playback Volume",
2631 static int patch_alc650(struct snd_ac97 * ac97)
2635 ac97->build_ops = &patch_alc650_ops;
2638 val = snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f;
2640 ac97->id = 0x414c4720; /* Old version */
2642 ac97->id = 0x414c4721; /* D version */
2644 ac97->id = 0x414c4722; /* E version */
2646 ac97->id = 0x414c4723; /* F version */
2650 ac97->spec.dev_flags = (ac97->id == 0x414c4722 ||
2651 ac97->id == 0x414c4723);
2654 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2655 snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x8000);
2658 val = snd_ac97_read(ac97, AC97_ALC650_CLOCK);
2660 if (ac97->spec.dev_flags &&
2662 ! (ac97->subsystem_vendor == 0x1043 &&
2663 ac97->subsystem_device == 0x1103))
2667 snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, val);
2674 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 0);
2678 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_SETUP,
2679 snd_ac97_read(ac97, AC97_ALC650_GPIO_SETUP) | 0x01);
2680 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2681 (snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x100) & ~0x10);
2684 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2685 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2689 static void alc655_update_jacks(struct snd_ac97 *ac97)
2694 shared = is_shared_surrout(ac97);
2695 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
2698 shared = is_shared_clfeout(ac97);
2700 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2702 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10,
2720 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2722 if (ac97->spec.dev_flags)
2730 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2733 val = ac97->regs[AC97_ALC650_MULTICH];
2735 if (ac97->spec.dev_flags && val == 3)
2743 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2745 return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 3 << 12,
2763 static int patch_alc655_specific(struct snd_ac97 * ac97)
2767 err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655));
2770 if (ac97->ext_id & AC97_EI_SPDIF) {
2771 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655));
2783 static int patch_alc655(struct snd_ac97 * ac97)
2787 if (ac97->id == AC97_ID_ALC658) {
2788 ac97->spec.dev_flags = 1; /* ALC658 */
2789 if ((snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f) == 2) {
2790 ac97->id = AC97_ID_ALC658D;
2791 ac97->spec.dev_flags = 2;
2795 ac97->build_ops = &patch_alc655_ops;
2798 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2801 val = snd_ac97_read(ac97, 0x7a); /* misc control */
2802 if (ac97->spec.dev_flags) /* ALC658 */
2805 if (ac97->subsystem_vendor == 0x1462 &&
2806 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2807 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2808 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2809 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2810 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2815 ac97->ext_id |= AC97_EI_SPDIF;
2818 snd_ac97_write_cache(ac97, 0x7a, val);
2824 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2827 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2828 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2831 if (ac97->id == AC97_ID_ALC658D)
2832 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800);
2842 static void alc850_update_jacks(struct snd_ac97 *ac97)
2848 shared = is_shared_surrout(ac97);
2850 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
2853 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
2856 shared = is_shared_clfeout(ac97);
2858 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
2861 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2864 aux_is_back_surround = alc850_is_aux_back_surround(ac97);
2866 snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
2877 static int patch_alc850_specific(struct snd_ac97 *ac97)
2881 err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850));
2884 if (ac97->ext_id & AC97_EI_SPDIF) {
2885 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655));
2897 static int patch_alc850(struct snd_ac97 *ac97)
2899 ac97->build_ops = &patch_alc850_ops;
2901 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
2902 ac97->flags |= AC97_HAS_8CH;
2905 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2914 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2918 snd_ac97_write_cache(ac97, 0x7a, (1<<1)|(1<<4)|(0<<5)|(1<<6)|
2923 snd_ac97_write_cache(ac97, 0x76, (0<<0)|(0<<2)|(1<<4)|(1<<7)|(2<<8)|
2927 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2928 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2932 static int patch_aztech_azf3328_specific(struct snd_ac97 *ac97)
2935 snd_ac97_find_mixer_ctl(ac97, "3D Control - Center");
2937 snd_ac97_find_mixer_ctl(ac97, "3D Control - Depth");
2940 * 3D register is different from AC97 standard layout
2946 snd_ac97_rename_vol_ctl(ac97,
2956 snd_ac97_rename_vol_ctl(ac97,
2959 snd_ac97_rename_vol_ctl(ac97,
2970 static int patch_aztech_azf3328(struct snd_ac97 *ac97)
2972 ac97->build_ops = &patch_aztech_azf3328_ops;
2979 static void cm9738_update_jacks(struct snd_ac97 *ac97)
2982 snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
2983 is_shared_surrout(ac97) ? (1 << 10) : 0);
2992 static int patch_cm9738_specific(struct snd_ac97 * ac97)
2994 return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls));
3002 static int patch_cm9738(struct snd_ac97 * ac97)
3004 ac97->build_ops = &patch_cm9738_ops;
3007 ac97->flags |= AC97_HAS_NO_PCM_VOL;
3008 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3022 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3025 val = ac97->regs[AC97_CM9739_SPDIF_CTRL];
3032 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3034 return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL,
3057 static void cm9739_update_jacks(struct snd_ac97 *ac97)
3060 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
3061 is_shared_surrout(ac97) ? (1 << 10) : 0);
3063 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
3064 is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
3072 static int patch_cm9739_specific(struct snd_ac97 * ac97)
3074 return patch_build_controls(ac97, snd_ac97_cm9739_controls, ARRAY_SIZE(snd_ac97_cm9739_controls));
3077 static int patch_cm9739_post_spdif(struct snd_ac97 * ac97)
3079 return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif));
3088 static int patch_cm9739(struct snd_ac97 * ac97)
3092 ac97->build_ops = &patch_cm9739_ops;
3095 ac97->flags |= AC97_HAS_NO_MASTER_VOL | AC97_HAS_NO_PCM_VOL;
3096 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8000);
3097 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3100 val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
3103 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3104 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) | 0x01);
3105 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3107 ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */
3108 ac97->rates[AC97_RATES_SPDIF] = 0;
3120 val = snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) & (1 << 4);
3123 if (! (ac97->ext_id & AC97_EI_SPDIF))
3125 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN, val);
3128 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3129 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3131 if (ac97->pci &&
3132 ac97->subsystem_vendor == 0x1043 &&
3133 ac97->subsystem_device == 0x1843) {
3134 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3135 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) & ~0x01);
3136 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN,
3137 snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) | (1 << 14));
3147 static void cm9761_update_jacks(struct snd_ac97 *ac97)
3174 val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
3175 val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
3176 val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
3177 val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
3179 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
3196 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3198 if (ac97->regs[AC97_CM9761_FUNC] & 0x1)
3200 else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2)
3209 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3212 return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1);
3213 snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0);
3214 return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2,
3242 static int patch_cm9761_post_spdif(struct snd_ac97 * ac97)
3244 return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif));
3247 static int patch_cm9761_specific(struct snd_ac97 * ac97)
3249 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
3258 static int patch_cm9761(struct snd_ac97 *ac97)
3266 ac97->flags |= /*AC97_HAS_NO_MASTER_VOL |*/ AC97_HAS_NO_PCM_VOL;
3267 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808);
3268 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808);
3270 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B, 2 = model 83 */
3271 if (ac97->id == AC97_ID_CM9761_82) {
3274 val = snd_ac97_read(ac97, AC97_INT_PAGING);
3275 snd_ac97_write_cache(ac97, AC97_INT_PAGING, (val & ~0x0f) | 0x01);
3276 tmp = snd_ac97_read(ac97, 0x60);
3277 ac97->spec.dev_flags = tmp & 1; /* revision B? */
3278 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
3279 } else if (ac97->id == AC97_ID_CM9761_83)
3280 ac97->spec.dev_flags = 2;
3282 ac97->build_ops = &patch_cm9761_ops;
3286 ac97->ext_id |= AC97_EI_SPDIF;
3288 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
3290 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */
3291 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3312 if (ac97->spec.dev_flags)
3317 val = snd_ac97_read(ac97, AC97_CM9761_MULTI_CHAN);
3319 snd_ac97_write_cache(ac97, AC97_CM9761_MULTI_CHAN, val);
3322 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3323 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3345 static int patch_cm9780_specific(struct snd_ac97 *ac97)
3347 return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
3355 static int patch_cm9780(struct snd_ac97 *ac97)
3359 ac97->build_ops = &patch_cm9780_ops;
3362 if (ac97->ext_id & AC97_EI_SPDIF) {
3363 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3364 val = snd_ac97_read(ac97, AC97_CM9780_SPDIF);
3366 snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val);
3379 static int patch_vt1613_specific(struct snd_ac97 *ac97)
3381 return patch_build_controls(ac97, &snd_ac97_controls_vt1613[0],
3389 static int patch_vt1613(struct snd_ac97 *ac97)
3391 ac97->build_ops = &patch_vt1613_ops;
3393 ac97->flags |= AC97_HAS_NO_VIDEO;
3394 ac97->caps |= AC97_BC_HEADPHONE;
3426 static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
3429 return snd_ctl_find_id_mixer(ac97->bus->card, name);
3433 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3443 err = snd_ctl_add(ac97->bus->card, kctl);
3447 return snd_ctl_add_followers(ac97->bus->card, kctl, followers);
3450 static int patch_vt1616_specific(struct snd_ac97 * ac97)
3455 if (snd_ac97_try_bit(ac97, 0x5a, 9)) {
3456 err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1);
3460 err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1);
3465 kctl = snd_ac97_find_mixer_ctl(ac97, "Master Playback Volume");
3469 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
3471 err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
3476 err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
3488 static int patch_vt1616(struct snd_ac97 * ac97)
3490 ac97->build_ops = &patch_vt1616_ops;
3584 static int patch_vt1617a(struct snd_ac97 * ac97)
3592 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3601 val = snd_ac97_read(ac97, 0x5c);
3603 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3605 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3606 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3607 ac97->build_ops = &patch_vt1616_ops;
3612 /* VIA VT1618 8 CHANNEL AC97 CODEC
3798 static int patch_vt1618(struct snd_ac97 *ac97)
3800 return patch_build_controls(ac97, snd_ac97_controls_vt1618,
3806 static void it2646_update_jacks(struct snd_ac97 *ac97)
3809 snd_ac97_update_bits(ac97, 0x76, 1 << 9,
3810 is_shared_surrout(ac97) ? (1<<9) : 0);
3812 snd_ac97_update_bits(ac97, 0x76, 1 << 10,
3813 is_shared_clfeout(ac97) ? (1<<10) : 0);
3827 static int patch_it2646_specific(struct snd_ac97 * ac97)
3830 err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646));
3833 err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646));
3844 static int patch_it2646(struct snd_ac97 * ac97)
3846 ac97->build_ops = &patch_it2646_ops;
3848 snd_ac97_write_cache(ac97, 0x5E, 0x0808);
3849 snd_ac97_write_cache(ac97, 0x7A, 0x0808);
3864 static int patch_si3036_specific(struct snd_ac97 * ac97)
3868 err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97));
3879 static int mpatch_si3036(struct snd_ac97 * ac97)
3881 ac97->build_ops = &patch_si3036_ops;
3882 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
3883 snd_ac97_write_cache(ac97, 0x68, 0);
3911 static int patch_lm4550(struct snd_ac97 *ac97)
3913 ac97->res_table = lm4550_restbl;