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 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97))) < 0)
39 static void reset_tlv(struct snd_ac97 *ac97, const char *name,
47 kctl = snd_ctl_find_id(ac97->bus->card, &sid);
53 static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page)
58 mutex_lock(&ac97->page_mutex);
59 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
60 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
61 ret = snd_ac97_update_bits(ac97, reg, mask, value);
62 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
63 mutex_unlock(&ac97->page_mutex); /* unlock paging */
79 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
81 ucontrol->value.enumerated.item[0] = ac97->indep_surround;
87 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
90 if (indep != ac97->indep_surround) {
91 ac97->indep_surround = indep;
92 if (ac97->build_ops->update_jacks)
93 ac97->build_ops->update_jacks(ac97);
108 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
110 ucontrol->value.enumerated.item[0] = ac97->channel_mode;
116 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
122 if (mode != ac97->channel_mode) {
123 ac97->channel_mode = mode;
124 if (ac97->build_ops->update_jacks)
125 ac97->build_ops->update_jacks(ac97);
170 static inline int is_surround_on(struct snd_ac97 *ac97)
172 return ac97->channel_mode >= 1;
175 static inline int is_clfe_on(struct snd_ac97 *ac97)
177 return ac97->channel_mode >= 2;
181 static inline int is_shared_surrout(struct snd_ac97 *ac97)
183 return !ac97->indep_surround && is_surround_on(ac97);
187 static inline int is_shared_clfeout(struct snd_ac97 *ac97)
189 return !ac97->indep_surround && is_clfe_on(ac97);
193 static inline int is_shared_linein(struct snd_ac97 *ac97)
195 return !ac97->indep_surround && !is_surround_on(ac97);
199 static inline int is_shared_micin(struct snd_ac97 *ac97)
201 return !ac97->indep_surround && !is_clfe_on(ac97);
204 static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
206 return is_surround_on(ac97);
228 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
231 val = ac97->regs[AC97_YMF7X3_3D_MODE_SEL];
242 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
248 return snd_ac97_update(ac97, AC97_YMF7X3_3D_MODE_SEL, val);
273 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
276 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
284 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
290 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val);
293 static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97)
298 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
299 err = snd_ctl_add(ac97->bus->card, kctl);
304 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
305 err = snd_ctl_add(ac97->bus->card,
307 ac97));
310 snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00);
329 static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97)
333 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
336 err = patch_build_controls(ac97,
342 snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201);
351 static int patch_yamaha_ymf743(struct snd_ac97 *ac97)
353 ac97->build_ops = &patch_yamaha_ymf743_ops;
354 ac97->caps |= AC97_BC_BASS_TREBLE;
355 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
356 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
357 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
374 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
377 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
384 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
391 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0028, val);
393 snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */
415 static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97)
419 if ((err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif))) < 0)
429 static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
438 ac97->build_ops = &patch_yamaha_ymf753_ops;
439 ac97->caps |= AC97_BC_BASS_TREBLE;
440 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
455 static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97)
464 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0)
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 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97))) < 0)
498 snd_ac97_write_cache(ac97, AC97_WM9704_TEST, 0x0200);
506 static int patch_wolfson04(struct snd_ac97 * ac97)
509 ac97->build_ops = &patch_wolfson_wm9704_ops;
513 static int patch_wolfson05(struct snd_ac97 * ac97)
516 ac97->build_ops = &patch_wolfson_wm9703_ops;
519 ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
629 static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97)
634 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97))) < 0)
637 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808);
638 snd_ac97_write_cache(ac97, AC97_PCI_SVID, 0x0808);
639 snd_ac97_write_cache(ac97, AC97_VIDEO, 0x0808);
640 snd_ac97_write_cache(ac97, AC97_AUX, 0x0808);
641 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
642 snd_ac97_write_cache(ac97, AC97_CD, 0x0000);
650 static int patch_wolfson11(struct snd_ac97 * ac97)
653 ac97->build_ops = &patch_wolfson_wm9711_ops;
655 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_MIC |
796 static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97)
801 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97))) < 0)
807 static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97)
812 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97))) < 0)
815 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
816 snd_ac97_write_cache(ac97, AC97_PHONE, 0x0808);
817 snd_ac97_write_cache(ac97, AC97_MIC, 0x0808);
818 snd_ac97_write_cache(ac97, AC97_LINE, 0x00da);
819 snd_ac97_write_cache(ac97, AC97_CD, 0x0808);
820 snd_ac97_write_cache(ac97, AC97_VIDEO, 0xd612);
821 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x1ba0);
826 static void patch_wolfson_wm9713_suspend (struct snd_ac97 * ac97)
828 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xfeff);
829 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xffff);
832 static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97)
834 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
835 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
836 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
849 static int patch_wolfson13(struct snd_ac97 * ac97)
852 ac97->build_ops = &patch_wolfson_wm9713_ops;
854 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_PHONE |
857 ac97->scaps &= ~AC97_SCAP_MODEM;
859 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
860 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
861 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
869 static int patch_tritech_tr28028(struct snd_ac97 * ac97)
871 snd_ac97_write_cache(ac97, 0x26, 0x0300);
872 snd_ac97_write_cache(ac97, 0x26, 0x0000);
873 snd_ac97_write_cache(ac97, AC97_SURROUND_MASTER, 0x0000);
874 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x0000);
881 static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97)
886 if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
890 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
894 static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97)
899 if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
903 if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
907 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
925 static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97)
929 snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003);
930 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1))
931 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1)) < 0)
933 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0))
934 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1)) < 0)
936 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2))
937 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1)) < 0)
939 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3))
940 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1)) < 0)
950 static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
952 ac97->build_ops = &patch_sigmatel_stac9700_ops;
958 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
961 mutex_lock(&ac97->page_mutex);
962 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
963 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
965 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
966 mutex_unlock(&ac97->page_mutex);
979 static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
984 snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
986 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
987 if ((err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1)) < 0)
989 return patch_sigmatel_stac97xx_specific(ac97);
997 static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
1001 ac97->build_ops = &patch_sigmatel_stac9708_ops;
1002 ac97->caps |= 0x10; /* HP (sigmatel surround) support */
1004 codec72 = snd_ac97_read(ac97, AC97_SIGMATEL_BIAS2) & 0x8000;
1005 codec6c = snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG);
1008 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1009 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1000);
1010 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1011 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0007);
1013 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1014 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1001);
1015 snd_ac97_write_cache(ac97, AC97_SIGMATEL_DAC2INVERT, 0x0008);
1019 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1023 static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1025 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1026 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
1028 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1029 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x4000);
1030 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1031 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1033 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1037 static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1040 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1041 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1042 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1043 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1044 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1045 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1049 static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1052 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1053 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1054 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1055 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1056 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1057 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1072 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1076 val = ac97->regs[AC97_SIGMATEL_OUTSEL] >> shift;
1086 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1096 return ac97_update_bits_page(ac97, AC97_SIGMATEL_OUTSEL,
1111 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1115 val = ac97->regs[AC97_SIGMATEL_INSEL];
1122 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1125 return ac97_update_bits_page(ac97, AC97_SIGMATEL_INSEL, 7 << shift,
1140 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1142 ucontrol->value.enumerated.item[0] = ac97->regs[AC97_SIGMATEL_IOMISC] & 3;
1148 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1150 return ac97_update_bits_page(ac97, AC97_SIGMATEL_IOMISC, 3,
1185 static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97)
1189 err = patch_sigmatel_stac97xx_specific(ac97);
1192 err = patch_build_controls(ac97, snd_ac97_sigmatel_stac9758_controls,
1197 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Front Playback");
1201 snd_ac97_rename_vol_ctl(ac97, "Video Playback", "Surround Mix Playback");
1212 static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1236 if (ac97->pci &&
1237 ac97->subsystem_vendor == 0x107b &&
1238 ac97->subsystem_device == 0x0601)
1242 ac97->build_ops = &patch_sigmatel_stac9758_ops;
1244 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
1246 snd_ac97_write_cache(ac97, regs[i], pregs[i]);
1248 ac97->flags |= AC97_STEREO_MUTES;
1260 static int patch_cirrus_build_spdif(struct snd_ac97 * ac97)
1265 if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0)
1268 if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1)) < 0)
1270 switch (ac97->id & AC97_ID_CS_MASK) {
1272 if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1)) < 0)
1278 snd_ac97_write_cache(ac97, AC97_CSR_SPDIF, 0x0a20);
1286 static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1299 ac97->build_ops = &patch_cirrus_ops;
1300 ac97->flags |= AC97_CS_SPDIF;
1301 ac97->rates[AC97_RATES_SPDIF] &= ~SNDRV_PCM_RATE_32000;
1302 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1303 snd_ac97_write_cache(ac97, AC97_CSR_ACMODE, 0x0080);
1307 static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1310 ac97->flags |= AC97_HAS_PC_BEEP;
1312 return patch_cirrus_spdif(ac97);
1322 static int patch_conexant_build_spdif(struct snd_ac97 * ac97)
1327 if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0)
1330 if ((err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1)) < 0)
1334 snd_ac97_write_cache(ac97, AC97_CXR_AUDIO_MISC,
1335 snd_ac97_read(ac97, AC97_CXR_AUDIO_MISC) & ~(AC97_CXR_SPDIFEN|AC97_CXR_COPYRGT|AC97_CXR_SPDIF_MASK));
1343 static int patch_conexant(struct snd_ac97 * ac97)
1345 ac97->build_ops = &patch_conexant_ops;
1346 ac97->flags |= AC97_CX_SPDIF;
1347 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1348 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
1352 static int patch_cx20551(struct snd_ac97 *ac97)
1354 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1362 static void ad18xx_resume(struct snd_ac97 *ac97)
1371 if (test_bit(reg, ac97->reg_accessed)) {
1372 snd_ac97_write(ac97, reg, ac97->regs[reg]);
1373 snd_ac97_read(ac97, reg);
1377 if (! (ac97->flags & AC97_AD_MULTI))
1379 snd_ac97_restore_status(ac97);
1383 if (! ac97->spec.ad18xx.id[codec])
1386 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1387 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1388 ac97->bus->ops->write(ac97, AC97_AD_CODEC_CFG, ac97->spec.ad18xx.codec_cfg[codec]);
1391 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1397 if (test_bit(i, ac97->reg_accessed)) {
1401 if (! ac97->spec.ad18xx.id[codec])
1404 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1405 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1407 ac97->bus->ops->write(ac97, AC97_PCM, ac97->spec.ad18xx.pcmreg[codec]);
1410 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1417 snd_ac97_write(ac97, i, ac97->regs[i]);
1418 snd_ac97_read(ac97, i);
1422 snd_ac97_restore_iec958(ac97);
1425 static void ad1888_resume(struct snd_ac97 *ac97)
1427 ad18xx_resume(ac97);
1428 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x8080);
1444 static int patch_ad1819(struct snd_ac97 * ac97)
1449 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1450 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
1451 ac97->res_table = ad1819_restbl;
1455 static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, unsigned short mask)
1460 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, mask);
1461 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000); /* ID0C, ID1C, SDIE = off */
1462 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1465 ac97->spec.ad18xx.unchained[idx] = mask;
1466 ac97->spec.ad18xx.id[idx] = val;
1467 ac97->spec.ad18xx.codec_cfg[idx] = 0x0000;
1471 static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits)
1476 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]);
1477 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0004); // SDIE
1478 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1482 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, codec_bits);
1483 ac97->spec.ad18xx.chained[idx] = cfg_bits[idx];
1484 ac97->spec.ad18xx.id[idx] = val;
1485 ac97->spec.ad18xx.codec_cfg[idx] = codec_bits ? codec_bits : 0x0004;
1489 static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int cidx1, int cidx2)
1492 if (ac97->spec.ad18xx.unchained[cidx1] || ac97->spec.ad18xx.chained[cidx1])
1494 if (ac97->spec.ad18xx.unchained[cidx2] || ac97->spec.ad18xx.chained[cidx2])
1499 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1500 ac97->spec.ad18xx.unchained[unchained_idx]);
1501 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0002); // ID1C
1502 ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002;
1505 patch_ad1881_chained1(ac97, cidx1, 0);
1506 else if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C
1507 patch_ad1881_chained1(ac97, cidx2, 0);
1508 else if (patch_ad1881_chained1(ac97, cidx2, 0x0006)) // SDIE | ID1C
1509 patch_ad1881_chained1(ac97, cidx1, 0);
1511 patch_ad1881_chained1(ac97, cidx2, 0);
1521 static int patch_ad1881(struct snd_ac97 * ac97)
1534 val = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1535 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, val);
1536 codecs[0] = patch_ad1881_unchained(ac97, 0, (1<<12));
1537 codecs[1] = patch_ad1881_unchained(ac97, 1, (1<<14));
1538 codecs[2] = patch_ad1881_unchained(ac97, 2, (1<<13));
1544 if (ac97->spec.ad18xx.unchained[idx])
1545 patch_ad1881_chained(ac97, idx, cfg_idxs[idx][0], cfg_idxs[idx][1]);
1547 if (ac97->spec.ad18xx.id[1]) {
1548 ac97->flags |= AC97_AD_MULTI;
1549 ac97->scaps |= AC97_SCAP_SURROUND_DAC;
1551 if (ac97->spec.ad18xx.id[2]) {
1552 ac97->flags |= AC97_AD_MULTI;
1553 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC;
1558 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1561 if (ac97->spec.ad18xx.id[idx])
1565 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000);
1566 ac97->spec.ad18xx.codec_cfg[0] =
1567 ac97->spec.ad18xx.codec_cfg[1] =
1568 ac97->spec.ad18xx.codec_cfg[2] = 0x0000;
1571 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID);
1572 if (ac97->spec.ad18xx.id[0]) {
1573 ac97->id &= 0xffff0000;
1574 ac97->id |= ac97->spec.ad18xx.id[0];
1576 ac97->build_ops = &patch_ad1881_build_ops;
1591 static int patch_ad1885_specific(struct snd_ac97 * ac97)
1595 if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0)
1597 reset_tlv(ac97, "Headphone Playback Volume",
1609 static int patch_ad1885(struct snd_ac97 * ac97)
1611 patch_ad1881(ac97);
1616 snd_ac97_write_cache(ac97, AC97_AD_MISC, 0x0404);
1618 ac97->build_ops = &patch_ad1885_build_ops;
1622 static int patch_ad1886_specific(struct snd_ac97 * ac97)
1624 reset_tlv(ac97, "Headphone Playback Volume",
1636 static int patch_ad1886(struct snd_ac97 * ac97)
1638 patch_ad1881(ac97);
1641 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
1642 ac97->build_ops = &patch_ad1886_build_ops;
1757 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1760 val = ac97->regs[AC97_AD_SERIAL_CFG];
1767 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1773 return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val);
1784 static int patch_ad198x_post_spdif(struct snd_ac97 * ac97)
1786 return patch_build_controls(ac97, &snd_ac97_ad198x_spdif_source, 1);
1813 static int check_list(struct snd_ac97 *ac97, const unsigned int *list)
1815 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device;
1822 static int patch_ad1981a_specific(struct snd_ac97 * ac97)
1824 if (check_list(ac97, ad1981_jacks_denylist))
1826 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1854 static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1856 if (check_list(ac97, ad1981_jacks_allowlist))
1858 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1861 static int patch_ad1981a(struct snd_ac97 *ac97)
1863 patch_ad1881(ac97);
1864 ac97->build_ops = &patch_ad1981a_build_ops;
1865 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1866 ac97->flags |= AC97_STEREO_MUTES;
1867 check_ad1981_hp_jack_sense(ac97);
1874 static int patch_ad1981b_specific(struct snd_ac97 *ac97)
1878 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
1880 if (check_list(ac97, ad1981_jacks_denylist))
1882 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1894 static int patch_ad1981b(struct snd_ac97 *ac97)
1896 patch_ad1881(ac97);
1897 ac97->build_ops = &patch_ad1981b_build_ops;
1898 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1899 ac97->flags |= AC97_STEREO_MUTES;
1900 check_ad1981_hp_jack_sense(ac97);
1908 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1911 val = ac97->regs[AC97_AD_MISC];
1913 if (ac97->spec.ad18xx.lo_as_master)
1921 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1925 if (ac97->spec.ad18xx.lo_as_master)
1928 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1941 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1944 val = ac97->regs[AC97_AD_MISC];
1954 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1964 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1968 static void ad1888_update_jacks(struct snd_ac97 *ac97)
1972 if (!ac97->spec.ad18xx.lo_as_master && is_shared_linein(ac97))
1975 if (is_shared_micin(ac97))
1978 snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val);
2007 static int patch_ad1888_specific(struct snd_ac97 *ac97)
2009 if (!ac97->spec.ad18xx.lo_as_master) {
2011 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2013 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback",
2016 return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
2028 static int patch_ad1888(struct snd_ac97 * ac97)
2032 patch_ad1881(ac97);
2033 ac97->build_ops = &patch_ad1888_build_ops;
2039 if (ac97->subsystem_vendor == 0x1043 &&
2040 ac97->subsystem_device == 0x1193) /* ASUS A9T laptop */
2041 ac97->spec.ad18xx.lo_as_master = 1;
2043 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2047 if (!ac97->spec.ad18xx.lo_as_master)
2054 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc);
2055 ac97->flags |= AC97_STEREO_MUTES;
2059 static int patch_ad1980_specific(struct snd_ac97 *ac97)
2063 if ((err = patch_ad1888_specific(ac97)) < 0)
2065 return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2077 static int patch_ad1980(struct snd_ac97 * ac97)
2079 patch_ad1888(ac97);
2080 ac97->build_ops = &patch_ad1980_build_ops;
2098 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2100 val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
2110 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2117 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
2154 static void ad1985_update_jacks(struct snd_ac97 *ac97)
2156 ad1888_update_jacks(ac97);
2158 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
2159 is_shared_micin(ac97) ? 1 << 9 : 0);
2162 static int patch_ad1985_specific(struct snd_ac97 *ac97)
2167 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2169 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
2171 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
2174 return patch_build_controls(ac97, snd_ac97_ad1985_controls,
2187 static int patch_ad1985(struct snd_ac97 * ac97)
2191 patch_ad1881(ac97);
2192 ac97->build_ops = &patch_ad1985_build_ops;
2193 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2197 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
2202 ac97->flags |= AC97_STEREO_MUTES;
2205 ad1985_update_jacks(ac97);
2208 ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
2217 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2220 val = ac97->regs[AC97_AD_MISC3];
2228 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2231 int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
2233 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
2240 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2253 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2256 val = ac97->regs[AC97_AD_MISC];
2264 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2267 int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
2269 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
2276 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2289 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2291 ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
2298 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2301 if (swap != ac97->spec.ad18xx.swap_mic_linein) {
2302 ac97->spec.ad18xx.swap_mic_linein = swap;
2303 if (ac97->build_ops->update_jacks)
2304 ac97->build_ops->update_jacks(ac97);
2314 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2316 unsigned short reg = ac97->regs[AC97_AD_MISC2];
2332 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2366 cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2370 lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
2374 mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2426 static void ad1986_update_jacks(struct snd_ac97 *ac97)
2432 if (!is_surround_on(ac97))
2434 if (!is_clfe_on(ac97))
2438 if (is_shared_linein(ac97))
2440 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2442 snd_ac97_update_bits(ac97, AC97_AD_MISC,
2448 if (is_shared_micin(ac97))
2450 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2454 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
2459 static int patch_ad1986_specific(struct snd_ac97 *ac97)
2463 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
2466 return patch_build_controls(ac97, snd_ac97_ad1986_controls,
2479 static int patch_ad1986(struct snd_ac97 * ac97)
2481 patch_ad1881(ac97);
2482 ac97->build_ops = &patch_ad1986_build_ops;
2483 ac97->flags |= AC97_STEREO_MUTES;
2486 ad1986_update_jacks(ac97);
2494 static int patch_alc203(struct snd_ac97 *ac97)
2496 snd_ac97_update_bits(ac97, 0x7a, 0x400, 0x400);
2503 static void alc650_update_jacks(struct snd_ac97 *ac97)
2508 shared = is_shared_surrout(ac97);
2509 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
2512 shared = is_shared_clfeout(ac97);
2514 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2517 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10,
2520 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100,
2527 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2528 struct snd_pcm_chmap *map = ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK];
2581 static int patch_alc650_specific(struct snd_ac97 * ac97)
2585 if ((err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650))) < 0)
2587 if (ac97->ext_id & AC97_EI_SPDIF) {
2588 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650))) < 0)
2591 if (ac97->id != AC97_ID_ALC650F)
2592 reset_tlv(ac97, "Master Playback Volume",
2602 static int patch_alc650(struct snd_ac97 * ac97)
2606 ac97->build_ops = &patch_alc650_ops;
2609 val = snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f;
2611 ac97->id = 0x414c4720; /* Old version */
2613 ac97->id = 0x414c4721; /* D version */
2615 ac97->id = 0x414c4722; /* E version */
2617 ac97->id = 0x414c4723; /* F version */
2621 ac97->spec.dev_flags = (ac97->id == 0x414c4722 ||
2622 ac97->id == 0x414c4723);
2625 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2626 snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x8000);
2629 val = snd_ac97_read(ac97, AC97_ALC650_CLOCK);
2631 if (ac97->spec.dev_flags &&
2633 ! (ac97->subsystem_vendor == 0x1043 &&
2634 ac97->subsystem_device == 0x1103))
2638 snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, val);
2645 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 0);
2649 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_SETUP,
2650 snd_ac97_read(ac97, AC97_ALC650_GPIO_SETUP) | 0x01);
2651 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2652 (snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x100) & ~0x10);
2655 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2656 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2660 static void alc655_update_jacks(struct snd_ac97 *ac97)
2665 shared = is_shared_surrout(ac97);
2666 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
2669 shared = is_shared_clfeout(ac97);
2671 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2673 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10,
2691 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2693 if (ac97->spec.dev_flags)
2701 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2704 val = ac97->regs[AC97_ALC650_MULTICH];
2706 if (ac97->spec.dev_flags && val == 3)
2714 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2716 return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 3 << 12,
2734 static int patch_alc655_specific(struct snd_ac97 * ac97)
2738 if ((err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655))) < 0)
2740 if (ac97->ext_id & AC97_EI_SPDIF) {
2741 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0)
2752 static int patch_alc655(struct snd_ac97 * ac97)
2756 if (ac97->id == AC97_ID_ALC658) {
2757 ac97->spec.dev_flags = 1; /* ALC658 */
2758 if ((snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f) == 2) {
2759 ac97->id = AC97_ID_ALC658D;
2760 ac97->spec.dev_flags = 2;
2764 ac97->build_ops = &patch_alc655_ops;
2767 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2770 val = snd_ac97_read(ac97, 0x7a); /* misc control */
2771 if (ac97->spec.dev_flags) /* ALC658 */
2774 if (ac97->subsystem_vendor == 0x1462 &&
2775 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2776 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2777 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2778 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2779 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2784 ac97->ext_id |= AC97_EI_SPDIF;
2787 snd_ac97_write_cache(ac97, 0x7a, val);
2793 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2796 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2797 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2800 if (ac97->id == AC97_ID_ALC658D)
2801 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800);
2811 static void alc850_update_jacks(struct snd_ac97 *ac97)
2817 shared = is_shared_surrout(ac97);
2819 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
2822 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
2825 shared = is_shared_clfeout(ac97);
2827 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
2830 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2833 aux_is_back_surround = alc850_is_aux_back_surround(ac97);
2835 snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
2846 static int patch_alc850_specific(struct snd_ac97 *ac97)
2850 if ((err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850))) < 0)
2852 if (ac97->ext_id & AC97_EI_SPDIF) {
2853 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0)
2864 static int patch_alc850(struct snd_ac97 *ac97)
2866 ac97->build_ops = &patch_alc850_ops;
2868 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
2869 ac97->flags |= AC97_HAS_8CH;
2872 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2881 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2885 snd_ac97_write_cache(ac97, 0x7a, (1<<1)|(1<<4)|(0<<5)|(1<<6)|
2890 snd_ac97_write_cache(ac97, 0x76, (0<<0)|(0<<2)|(1<<4)|(1<<7)|(2<<8)|
2894 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2895 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2899 static int patch_aztech_azf3328_specific(struct snd_ac97 *ac97)
2902 snd_ac97_find_mixer_ctl(ac97, "3D Control - Center");
2904 snd_ac97_find_mixer_ctl(ac97, "3D Control - Depth");
2913 snd_ac97_rename_vol_ctl(ac97,
2923 snd_ac97_rename_vol_ctl(ac97,
2926 snd_ac97_rename_vol_ctl(ac97,
2937 static int patch_aztech_azf3328(struct snd_ac97 *ac97)
2939 ac97->build_ops = &patch_aztech_azf3328_ops;
2946 static void cm9738_update_jacks(struct snd_ac97 *ac97)
2949 snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
2950 is_shared_surrout(ac97) ? (1 << 10) : 0);
2959 static int patch_cm9738_specific(struct snd_ac97 * ac97)
2961 return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls));
2969 static int patch_cm9738(struct snd_ac97 * ac97)
2971 ac97->build_ops = &patch_cm9738_ops;
2974 ac97->flags |= AC97_HAS_NO_PCM_VOL;
2975 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
2989 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2992 val = ac97->regs[AC97_CM9739_SPDIF_CTRL];
2999 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3001 return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL,
3024 static void cm9739_update_jacks(struct snd_ac97 *ac97)
3027 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
3028 is_shared_surrout(ac97) ? (1 << 10) : 0);
3030 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
3031 is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
3039 static int patch_cm9739_specific(struct snd_ac97 * ac97)
3041 return patch_build_controls(ac97, snd_ac97_cm9739_controls, ARRAY_SIZE(snd_ac97_cm9739_controls));
3044 static int patch_cm9739_post_spdif(struct snd_ac97 * ac97)
3046 return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif));
3055 static int patch_cm9739(struct snd_ac97 * ac97)
3059 ac97->build_ops = &patch_cm9739_ops;
3062 ac97->flags |= AC97_HAS_NO_MASTER_VOL | AC97_HAS_NO_PCM_VOL;
3063 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8000);
3064 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3067 val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
3070 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3071 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) | 0x01);
3072 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3074 ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */
3075 ac97->rates[AC97_RATES_SPDIF] = 0;
3087 val = snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) & (1 << 4);
3090 if (! (ac97->ext_id & AC97_EI_SPDIF))
3092 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN, val);
3095 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3096 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3098 if (ac97->pci &&
3099 ac97->subsystem_vendor == 0x1043 &&
3100 ac97->subsystem_device == 0x1843) {
3101 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3102 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) & ~0x01);
3103 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN,
3104 snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) | (1 << 14));
3114 static void cm9761_update_jacks(struct snd_ac97 *ac97)
3141 val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
3142 val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
3143 val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
3144 val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
3146 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
3163 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3165 if (ac97->regs[AC97_CM9761_FUNC] & 0x1)
3167 else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2)
3176 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3179 return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1);
3180 snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0);
3181 return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2,
3209 static int patch_cm9761_post_spdif(struct snd_ac97 * ac97)
3211 return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif));
3214 static int patch_cm9761_specific(struct snd_ac97 * ac97)
3216 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
3225 static int patch_cm9761(struct snd_ac97 *ac97)
3233 ac97->flags |= /*AC97_HAS_NO_MASTER_VOL |*/ AC97_HAS_NO_PCM_VOL;
3234 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808);
3235 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808);
3237 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B, 2 = model 83 */
3238 if (ac97->id == AC97_ID_CM9761_82) {
3241 val = snd_ac97_read(ac97, AC97_INT_PAGING);
3242 snd_ac97_write_cache(ac97, AC97_INT_PAGING, (val & ~0x0f) | 0x01);
3243 tmp = snd_ac97_read(ac97, 0x60);
3244 ac97->spec.dev_flags = tmp & 1; /* revision B? */
3245 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
3246 } else if (ac97->id == AC97_ID_CM9761_83)
3247 ac97->spec.dev_flags = 2;
3249 ac97->build_ops = &patch_cm9761_ops;
3253 ac97->ext_id |= AC97_EI_SPDIF;
3255 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
3257 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */
3258 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3279 if (ac97->spec.dev_flags)
3284 val = snd_ac97_read(ac97, AC97_CM9761_MULTI_CHAN);
3286 snd_ac97_write_cache(ac97, AC97_CM9761_MULTI_CHAN, val);
3289 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3290 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3312 static int patch_cm9780_specific(struct snd_ac97 *ac97)
3314 return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
3322 static int patch_cm9780(struct snd_ac97 *ac97)
3326 ac97->build_ops = &patch_cm9780_ops;
3329 if (ac97->ext_id & AC97_EI_SPDIF) {
3330 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3331 val = snd_ac97_read(ac97, AC97_CM9780_SPDIF);
3333 snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val);
3346 static int patch_vt1613_specific(struct snd_ac97 *ac97)
3348 return patch_build_controls(ac97, &snd_ac97_controls_vt1613[0],
3356 static int patch_vt1613(struct snd_ac97 *ac97)
3358 ac97->build_ops = &patch_vt1613_ops;
3360 ac97->flags |= AC97_HAS_NO_VIDEO;
3361 ac97->caps |= AC97_BC_HEADPHONE;
3393 static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
3400 return snd_ctl_find_id(ac97->bus->card, &id);
3404 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3415 err = snd_ctl_add(ac97->bus->card, kctl);
3422 sctl = snd_ac97_find_mixer_ctl(ac97, *s);
3424 dev_dbg(ac97->bus->card->dev,
3435 static int patch_vt1616_specific(struct snd_ac97 * ac97)
3440 if (snd_ac97_try_bit(ac97, 0x5a, 9))
3441 if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1)) < 0)
3443 if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1)) < 0)
3447 kctl = snd_ac97_find_mixer_ctl(ac97, "Master Playback Volume");
3451 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
3453 err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
3458 err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
3470 static int patch_vt1616(struct snd_ac97 * ac97)
3472 ac97->build_ops = &patch_vt1616_ops;
3566 static int patch_vt1617a(struct snd_ac97 * ac97)
3574 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3583 val = snd_ac97_read(ac97, 0x5c);
3585 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3587 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3588 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3589 ac97->build_ops = &patch_vt1616_ops;
3781 static int patch_vt1618(struct snd_ac97 *ac97)
3783 return patch_build_controls(ac97, snd_ac97_controls_vt1618,
3789 static void it2646_update_jacks(struct snd_ac97 *ac97)
3792 snd_ac97_update_bits(ac97, 0x76, 1 << 9,
3793 is_shared_surrout(ac97) ? (1<<9) : 0);
3795 snd_ac97_update_bits(ac97, 0x76, 1 << 10,
3796 is_shared_clfeout(ac97) ? (1<<10) : 0);
3810 static int patch_it2646_specific(struct snd_ac97 * ac97)
3813 if ((err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646))) < 0)
3815 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646))) < 0)
3825 static int patch_it2646(struct snd_ac97 * ac97)
3827 ac97->build_ops = &patch_it2646_ops;
3829 snd_ac97_write_cache(ac97, 0x5E, 0x0808);
3830 snd_ac97_write_cache(ac97, 0x7A, 0x0808);
3845 static int patch_si3036_specific(struct snd_ac97 * ac97)
3849 if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97))) < 0)
3858 static int mpatch_si3036(struct snd_ac97 * ac97)
3860 ac97->build_ops = &patch_si3036_ops;
3861 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
3862 snd_ac97_write_cache(ac97, 0x68, 0);
3890 static int patch_lm4550(struct snd_ac97 *ac97)
3892 ac97->res_table = lm4550_restbl;
3912 static int patch_ucb1400_specific(struct snd_ac97 * ac97)
3916 if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97))) < 0)
3925 static int patch_ucb1400(struct snd_ac97 * ac97)
3927 ac97->build_ops = &patch_ucb1400_ops;
3929 snd_ac97_write_cache(ac97, 0x6a, 0x0050);
3930 snd_ac97_write_cache(ac97, 0x6c, 0x0030);