Lines Matching defs: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 mutex_lock(&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);
62 mutex_unlock(&ac97->page_mutex); /* unlock paging */
78 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
80 ucontrol->value.enumerated.item[0] = ac97->indep_surround;
86 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
89 if (indep != ac97->indep_surround) {
90 ac97->indep_surround = indep;
91 if (ac97->build_ops->update_jacks)
92 ac97->build_ops->update_jacks(ac97);
107 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
109 ucontrol->value.enumerated.item[0] = ac97->channel_mode;
115 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
121 if (mode != ac97->channel_mode) {
122 ac97->channel_mode = mode;
123 if (ac97->build_ops->update_jacks)
124 ac97->build_ops->update_jacks(ac97);
169 static inline int is_surround_on(struct snd_ac97 *ac97)
171 return ac97->channel_mode >= 1;
174 static inline int is_clfe_on(struct snd_ac97 *ac97)
176 return ac97->channel_mode >= 2;
180 static inline int is_shared_surrout(struct snd_ac97 *ac97)
182 return !ac97->indep_surround && is_surround_on(ac97);
186 static inline int is_shared_clfeout(struct snd_ac97 *ac97)
188 return !ac97->indep_surround && is_clfe_on(ac97);
192 static inline int is_shared_linein(struct snd_ac97 *ac97)
194 return !ac97->indep_surround && !is_surround_on(ac97);
198 static inline int is_shared_micin(struct snd_ac97 *ac97)
200 return !ac97->indep_surround && !is_clfe_on(ac97);
203 static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
205 return is_surround_on(ac97);
227 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
230 val = ac97->regs[AC97_YMF7X3_3D_MODE_SEL];
241 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
247 return snd_ac97_update(ac97, AC97_YMF7X3_3D_MODE_SEL, val);
272 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
275 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
283 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
289 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val);
292 static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97)
297 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
298 err = snd_ctl_add(ac97->bus->card, kctl);
303 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
304 err = snd_ctl_add(ac97->bus->card,
306 ac97));
309 snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00);
328 static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97)
332 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
335 err = patch_build_controls(ac97,
341 snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201);
350 static int patch_yamaha_ymf743(struct snd_ac97 *ac97)
352 ac97->build_ops = &patch_yamaha_ymf743_ops;
353 ac97->caps |= AC97_BC_BASS_TREBLE;
354 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
355 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
356 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
373 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
376 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
383 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
390 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0028, val);
392 snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */
414 static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97)
418 err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif));
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 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97));
468 snd_ac97_write_cache(ac97, AC97_WM97XX_FMIXER_VOL, 0x0808);
476 static int patch_wolfson03(struct snd_ac97 * ac97)
478 ac97->build_ops = &patch_wolfson_wm9703_ops;
491 static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97)
495 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97));
500 snd_ac97_write_cache(ac97, AC97_WM9704_TEST, 0x0200);
508 static int patch_wolfson04(struct snd_ac97 * ac97)
511 ac97->build_ops = &patch_wolfson_wm9704_ops;
515 static int patch_wolfson05(struct snd_ac97 * ac97)
518 ac97->build_ops = &patch_wolfson_wm9703_ops;
521 ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
631 static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97)
636 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97));
640 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808);
641 snd_ac97_write_cache(ac97, AC97_PCI_SVID, 0x0808);
642 snd_ac97_write_cache(ac97, AC97_VIDEO, 0x0808);
643 snd_ac97_write_cache(ac97, AC97_AUX, 0x0808);
644 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
645 snd_ac97_write_cache(ac97, AC97_CD, 0x0000);
653 static int patch_wolfson11(struct snd_ac97 * ac97)
656 ac97->build_ops = &patch_wolfson_wm9711_ops;
658 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_MIC |
799 static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97)
804 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97));
811 static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97)
816 err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97));
820 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
821 snd_ac97_write_cache(ac97, AC97_PHONE, 0x0808);
822 snd_ac97_write_cache(ac97, AC97_MIC, 0x0808);
823 snd_ac97_write_cache(ac97, AC97_LINE, 0x00da);
824 snd_ac97_write_cache(ac97, AC97_CD, 0x0808);
825 snd_ac97_write_cache(ac97, AC97_VIDEO, 0xd612);
826 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x1ba0);
831 static void patch_wolfson_wm9713_suspend (struct snd_ac97 * ac97)
833 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xfeff);
834 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xffff);
837 static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97)
839 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
840 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
841 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
854 static int patch_wolfson13(struct snd_ac97 * ac97)
857 ac97->build_ops = &patch_wolfson_wm9713_ops;
859 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_PHONE |
862 ac97->scaps &= ~AC97_SCAP_MODEM;
864 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
865 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
866 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
874 static int patch_tritech_tr28028(struct snd_ac97 * ac97)
876 snd_ac97_write_cache(ac97, 0x26, 0x0300);
877 snd_ac97_write_cache(ac97, 0x26, 0x0000);
878 snd_ac97_write_cache(ac97, AC97_SURROUND_MASTER, 0x0000);
879 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x0000);
886 static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97)
891 err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97));
896 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
900 static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97)
905 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
906 err = snd_ctl_add(ac97->bus->card, kctl);
911 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
912 err = snd_ctl_add(ac97->bus->card, kctl);
917 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
935 static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97)
939 snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003);
940 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1)) {
941 err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1);
945 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0)) {
946 err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1);
950 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2)) {
951 err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1);
955 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3)) {
956 err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1);
968 static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
970 ac97->build_ops = &patch_sigmatel_stac9700_ops;
976 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
979 mutex_lock(&ac97->page_mutex);
980 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
981 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
983 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
984 mutex_unlock(&ac97->page_mutex);
997 static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
1002 snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
1004 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
1005 err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1);
1008 return patch_sigmatel_stac97xx_specific(ac97);
1016 static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
1020 ac97->build_ops = &patch_sigmatel_stac9708_ops;
1021 ac97->caps |= 0x10; /* HP (sigmatel surround) support */
1023 codec72 = snd_ac97_read(ac97, AC97_SIGMATEL_BIAS2) & 0x8000;
1024 codec6c = snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG);
1027 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1028 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1000);
1029 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1030 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0007);
1032 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1033 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1001);
1034 snd_ac97_write_cache(ac97, AC97_SIGMATEL_DAC2INVERT, 0x0008);
1038 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1042 static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1044 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1045 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
1047 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1048 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x4000);
1049 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1050 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1052 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1056 static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1059 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1060 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1061 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1062 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1063 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1064 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1068 static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1071 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1072 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1073 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1074 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1075 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1076 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1091 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1095 val = ac97->regs[AC97_SIGMATEL_OUTSEL] >> shift;
1105 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1115 return ac97_update_bits_page(ac97, AC97_SIGMATEL_OUTSEL,
1130 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1134 val = ac97->regs[AC97_SIGMATEL_INSEL];
1141 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1144 return ac97_update_bits_page(ac97, AC97_SIGMATEL_INSEL, 7 << shift,
1159 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1161 ucontrol->value.enumerated.item[0] = ac97->regs[AC97_SIGMATEL_IOMISC] & 3;
1167 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1169 return ac97_update_bits_page(ac97, AC97_SIGMATEL_IOMISC, 3,
1204 static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97)
1208 err = patch_sigmatel_stac97xx_specific(ac97);
1211 err = patch_build_controls(ac97, snd_ac97_sigmatel_stac9758_controls,
1216 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Front Playback");
1220 snd_ac97_rename_vol_ctl(ac97, "Video Playback", "Surround Mix Playback");
1231 static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1255 if (ac97->pci &&
1256 ac97->subsystem_vendor == 0x107b &&
1257 ac97->subsystem_device == 0x0601)
1261 ac97->build_ops = &patch_sigmatel_stac9758_ops;
1263 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
1265 snd_ac97_write_cache(ac97, regs[i], pregs[i]);
1267 ac97->flags |= AC97_STEREO_MUTES;
1279 static int patch_cirrus_build_spdif(struct snd_ac97 * ac97)
1284 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
1288 err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1);
1291 switch (ac97->id & AC97_ID_CS_MASK) {
1293 err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1);
1300 snd_ac97_write_cache(ac97, AC97_CSR_SPDIF, 0x0a20);
1308 static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1321 ac97->build_ops = &patch_cirrus_ops;
1322 ac97->flags |= AC97_CS_SPDIF;
1323 ac97->rates[AC97_RATES_SPDIF] &= ~SNDRV_PCM_RATE_32000;
1324 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1325 snd_ac97_write_cache(ac97, AC97_CSR_ACMODE, 0x0080);
1329 static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1332 ac97->flags |= AC97_HAS_PC_BEEP;
1334 return patch_cirrus_spdif(ac97);
1344 static int patch_conexant_build_spdif(struct snd_ac97 * ac97)
1349 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
1353 err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1);
1358 snd_ac97_write_cache(ac97, AC97_CXR_AUDIO_MISC,
1359 snd_ac97_read(ac97, AC97_CXR_AUDIO_MISC) & ~(AC97_CXR_SPDIFEN|AC97_CXR_COPYRGT|AC97_CXR_SPDIF_MASK));
1367 static int patch_conexant(struct snd_ac97 * ac97)
1369 ac97->build_ops = &patch_conexant_ops;
1370 ac97->flags |= AC97_CX_SPDIF;
1371 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1372 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
1376 static int patch_cx20551(struct snd_ac97 *ac97)
1378 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1386 static void ad18xx_resume(struct snd_ac97 *ac97)
1395 if (test_bit(reg, ac97->reg_accessed)) {
1396 snd_ac97_write(ac97, reg, ac97->regs[reg]);
1397 snd_ac97_read(ac97, reg);
1401 if (! (ac97->flags & AC97_AD_MULTI))
1403 snd_ac97_restore_status(ac97);
1407 if (! ac97->spec.ad18xx.id[codec])
1410 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1411 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1412 ac97->bus->ops->write(ac97, AC97_AD_CODEC_CFG, ac97->spec.ad18xx.codec_cfg[codec]);
1415 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1421 if (test_bit(i, ac97->reg_accessed)) {
1425 if (! ac97->spec.ad18xx.id[codec])
1428 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1429 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1431 ac97->bus->ops->write(ac97, AC97_PCM, ac97->spec.ad18xx.pcmreg[codec]);
1434 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1441 snd_ac97_write(ac97, i, ac97->regs[i]);
1442 snd_ac97_read(ac97, i);
1446 snd_ac97_restore_iec958(ac97);
1449 static void ad1888_resume(struct snd_ac97 *ac97)
1451 ad18xx_resume(ac97);
1452 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x8080);
1468 static int patch_ad1819(struct snd_ac97 * ac97)
1473 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1474 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
1475 ac97->res_table = ad1819_restbl;
1479 static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, unsigned short mask)
1484 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, mask);
1485 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000); /* ID0C, ID1C, SDIE = off */
1486 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1489 ac97->spec.ad18xx.unchained[idx] = mask;
1490 ac97->spec.ad18xx.id[idx] = val;
1491 ac97->spec.ad18xx.codec_cfg[idx] = 0x0000;
1495 static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits)
1500 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]);
1501 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0004); // SDIE
1502 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1506 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, codec_bits);
1507 ac97->spec.ad18xx.chained[idx] = cfg_bits[idx];
1508 ac97->spec.ad18xx.id[idx] = val;
1509 ac97->spec.ad18xx.codec_cfg[idx] = codec_bits ? codec_bits : 0x0004;
1513 static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int cidx1, int cidx2)
1516 if (ac97->spec.ad18xx.unchained[cidx1] || ac97->spec.ad18xx.chained[cidx1])
1518 if (ac97->spec.ad18xx.unchained[cidx2] || ac97->spec.ad18xx.chained[cidx2])
1523 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1524 ac97->spec.ad18xx.unchained[unchained_idx]);
1525 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0002); // ID1C
1526 ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002;
1529 patch_ad1881_chained1(ac97, cidx1, 0);
1530 else if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C
1531 patch_ad1881_chained1(ac97, cidx2, 0);
1532 else if (patch_ad1881_chained1(ac97, cidx2, 0x0006)) // SDIE | ID1C
1533 patch_ad1881_chained1(ac97, cidx1, 0);
1535 patch_ad1881_chained1(ac97, cidx2, 0);
1545 static int patch_ad1881(struct snd_ac97 * ac97)
1558 val = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1559 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, val);
1560 codecs[0] = patch_ad1881_unchained(ac97, 0, (1<<12));
1561 codecs[1] = patch_ad1881_unchained(ac97, 1, (1<<14));
1562 codecs[2] = patch_ad1881_unchained(ac97, 2, (1<<13));
1568 if (ac97->spec.ad18xx.unchained[idx])
1569 patch_ad1881_chained(ac97, idx, cfg_idxs[idx][0], cfg_idxs[idx][1]);
1571 if (ac97->spec.ad18xx.id[1]) {
1572 ac97->flags |= AC97_AD_MULTI;
1573 ac97->scaps |= AC97_SCAP_SURROUND_DAC;
1575 if (ac97->spec.ad18xx.id[2]) {
1576 ac97->flags |= AC97_AD_MULTI;
1577 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC;
1582 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1585 if (ac97->spec.ad18xx.id[idx])
1589 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000);
1590 ac97->spec.ad18xx.codec_cfg[0] =
1591 ac97->spec.ad18xx.codec_cfg[1] =
1592 ac97->spec.ad18xx.codec_cfg[2] = 0x0000;
1595 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID);
1596 if (ac97->spec.ad18xx.id[0]) {
1597 ac97->id &= 0xffff0000;
1598 ac97->id |= ac97->spec.ad18xx.id[0];
1600 ac97->build_ops = &patch_ad1881_build_ops;
1615 static int patch_ad1885_specific(struct snd_ac97 * ac97)
1619 err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885));
1622 reset_tlv(ac97, "Headphone Playback Volume",
1634 static int patch_ad1885(struct snd_ac97 * ac97)
1636 patch_ad1881(ac97);
1641 snd_ac97_write_cache(ac97, AC97_AD_MISC, 0x0404);
1643 ac97->build_ops = &patch_ad1885_build_ops;
1647 static int patch_ad1886_specific(struct snd_ac97 * ac97)
1649 reset_tlv(ac97, "Headphone Playback Volume",
1661 static int patch_ad1886(struct snd_ac97 * ac97)
1663 patch_ad1881(ac97);
1666 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
1667 ac97->build_ops = &patch_ad1886_build_ops;
1782 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1785 val = ac97->regs[AC97_AD_SERIAL_CFG];
1792 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1798 return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val);
1809 static int patch_ad198x_post_spdif(struct snd_ac97 * ac97)
1811 return patch_build_controls(ac97, &snd_ac97_ad198x_spdif_source, 1);
1838 static int check_list(struct snd_ac97 *ac97, const unsigned int *list)
1840 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device;
1847 static int patch_ad1981a_specific(struct snd_ac97 * ac97)
1849 if (check_list(ac97, ad1981_jacks_denylist))
1851 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1879 static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1881 if (check_list(ac97, ad1981_jacks_allowlist))
1883 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1886 static int patch_ad1981a(struct snd_ac97 *ac97)
1888 patch_ad1881(ac97);
1889 ac97->build_ops = &patch_ad1981a_build_ops;
1890 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1891 ac97->flags |= AC97_STEREO_MUTES;
1892 check_ad1981_hp_jack_sense(ac97);
1899 static int patch_ad1981b_specific(struct snd_ac97 *ac97)
1903 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
1906 if (check_list(ac97, ad1981_jacks_denylist))
1908 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1920 static int patch_ad1981b(struct snd_ac97 *ac97)
1922 patch_ad1881(ac97);
1923 ac97->build_ops = &patch_ad1981b_build_ops;
1924 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1925 ac97->flags |= AC97_STEREO_MUTES;
1926 check_ad1981_hp_jack_sense(ac97);
1934 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1937 val = ac97->regs[AC97_AD_MISC];
1939 if (ac97->spec.ad18xx.lo_as_master)
1947 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1951 if (ac97->spec.ad18xx.lo_as_master)
1954 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1967 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1970 val = ac97->regs[AC97_AD_MISC];
1980 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1990 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1994 static void ad1888_update_jacks(struct snd_ac97 *ac97)
1998 if (!ac97->spec.ad18xx.lo_as_master && is_shared_linein(ac97))
2001 if (is_shared_micin(ac97))
2004 snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val);
2033 static int patch_ad1888_specific(struct snd_ac97 *ac97)
2035 if (!ac97->spec.ad18xx.lo_as_master) {
2037 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2039 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback",
2042 return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
2054 static int patch_ad1888(struct snd_ac97 * ac97)
2058 patch_ad1881(ac97);
2059 ac97->build_ops = &patch_ad1888_build_ops;
2065 if (ac97->subsystem_vendor == 0x1043 &&
2066 ac97->subsystem_device == 0x1193) /* ASUS A9T laptop */
2067 ac97->spec.ad18xx.lo_as_master = 1;
2069 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2073 if (!ac97->spec.ad18xx.lo_as_master)
2080 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc);
2081 ac97->flags |= AC97_STEREO_MUTES;
2085 static int patch_ad1980_specific(struct snd_ac97 *ac97)
2089 err = patch_ad1888_specific(ac97);
2092 return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2104 static int patch_ad1980(struct snd_ac97 * ac97)
2106 patch_ad1888(ac97);
2107 ac97->build_ops = &patch_ad1980_build_ops;
2125 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2127 val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
2137 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2144 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
2181 static void ad1985_update_jacks(struct snd_ac97 *ac97)
2183 ad1888_update_jacks(ac97);
2185 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
2186 is_shared_micin(ac97) ? 1 << 9 : 0);
2189 static int patch_ad1985_specific(struct snd_ac97 *ac97)
2194 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2196 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
2198 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2202 return patch_build_controls(ac97, snd_ac97_ad1985_controls,
2215 static int patch_ad1985(struct snd_ac97 * ac97)
2219 patch_ad1881(ac97);
2220 ac97->build_ops = &patch_ad1985_build_ops;
2221 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2225 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
2230 ac97->flags |= AC97_STEREO_MUTES;
2233 ad1985_update_jacks(ac97);
2236 ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
2245 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2248 val = ac97->regs[AC97_AD_MISC3];
2256 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2259 int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
2261 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
2268 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2281 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2284 val = ac97->regs[AC97_AD_MISC];
2292 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2295 int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
2297 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
2304 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2317 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2319 ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
2326 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2329 if (swap != ac97->spec.ad18xx.swap_mic_linein) {
2330 ac97->spec.ad18xx.swap_mic_linein = swap;
2331 if (ac97->build_ops->update_jacks)
2332 ac97->build_ops->update_jacks(ac97);
2342 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2344 unsigned short reg = ac97->regs[AC97_AD_MISC2];
2360 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2394 cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2398 lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
2402 mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2454 static void ad1986_update_jacks(struct snd_ac97 *ac97)
2460 if (!is_surround_on(ac97))
2462 if (!is_clfe_on(ac97))
2466 if (is_shared_linein(ac97))
2468 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2470 snd_ac97_update_bits(ac97, AC97_AD_MISC,
2476 if (is_shared_micin(ac97))
2478 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2482 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
2487 static int patch_ad1986_specific(struct snd_ac97 *ac97)
2491 err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2495 return patch_build_controls(ac97, snd_ac97_ad1986_controls,
2508 static int patch_ad1986(struct snd_ac97 * ac97)
2510 patch_ad1881(ac97);
2511 ac97->build_ops = &patch_ad1986_build_ops;
2512 ac97->flags |= AC97_STEREO_MUTES;
2515 ad1986_update_jacks(ac97);
2523 static int patch_alc203(struct snd_ac97 *ac97)
2525 snd_ac97_update_bits(ac97, 0x7a, 0x400, 0x400);
2532 static void alc650_update_jacks(struct snd_ac97 *ac97)
2537 shared = is_shared_surrout(ac97);
2538 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
2541 shared = is_shared_clfeout(ac97);
2543 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2546 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10,
2549 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100,
2556 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2557 struct snd_pcm_chmap *map = ac97->chmaps[SNDRV_PCM_STREAM_PLAYBACK];
2610 static int patch_alc650_specific(struct snd_ac97 * ac97)
2614 err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650));
2617 if (ac97->ext_id & AC97_EI_SPDIF) {
2618 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650));
2622 if (ac97->id != AC97_ID_ALC650F)
2623 reset_tlv(ac97, "Master Playback Volume",
2633 static int patch_alc650(struct snd_ac97 * ac97)
2637 ac97->build_ops = &patch_alc650_ops;
2640 val = snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f;
2642 ac97->id = 0x414c4720; /* Old version */
2644 ac97->id = 0x414c4721; /* D version */
2646 ac97->id = 0x414c4722; /* E version */
2648 ac97->id = 0x414c4723; /* F version */
2652 ac97->spec.dev_flags = (ac97->id == 0x414c4722 ||
2653 ac97->id == 0x414c4723);
2656 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2657 snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x8000);
2660 val = snd_ac97_read(ac97, AC97_ALC650_CLOCK);
2662 if (ac97->spec.dev_flags &&
2664 ! (ac97->subsystem_vendor == 0x1043 &&
2665 ac97->subsystem_device == 0x1103))
2669 snd_ac97_write_cache(ac97, AC97_ALC650_CLOCK, val);
2676 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 0);
2680 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_SETUP,
2681 snd_ac97_read(ac97, AC97_ALC650_GPIO_SETUP) | 0x01);
2682 snd_ac97_write_cache(ac97, AC97_ALC650_GPIO_STATUS,
2683 (snd_ac97_read(ac97, AC97_ALC650_GPIO_STATUS) | 0x100) & ~0x10);
2686 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2687 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2691 static void alc655_update_jacks(struct snd_ac97 *ac97)
2696 shared = is_shared_surrout(ac97);
2697 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 9,
2700 shared = is_shared_clfeout(ac97);
2702 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2704 ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 1 << 10,
2722 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2724 if (ac97->spec.dev_flags)
2732 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2735 val = ac97->regs[AC97_ALC650_MULTICH];
2737 if (ac97->spec.dev_flags && val == 3)
2745 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2747 return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 3 << 12,
2765 static int patch_alc655_specific(struct snd_ac97 * ac97)
2769 err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655));
2772 if (ac97->ext_id & AC97_EI_SPDIF) {
2773 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655));
2785 static int patch_alc655(struct snd_ac97 * ac97)
2789 if (ac97->id == AC97_ID_ALC658) {
2790 ac97->spec.dev_flags = 1; /* ALC658 */
2791 if ((snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f) == 2) {
2792 ac97->id = AC97_ID_ALC658D;
2793 ac97->spec.dev_flags = 2;
2797 ac97->build_ops = &patch_alc655_ops;
2800 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2803 val = snd_ac97_read(ac97, 0x7a); /* misc control */
2804 if (ac97->spec.dev_flags) /* ALC658 */
2807 if (ac97->subsystem_vendor == 0x1462 &&
2808 (ac97->subsystem_device == 0x0131 || /* MSI S270 laptop */
2809 ac97->subsystem_device == 0x0161 || /* LG K1 Express */
2810 ac97->subsystem_device == 0x0351 || /* MSI L725 laptop */
2811 ac97->subsystem_device == 0x0471 || /* MSI L720 laptop */
2812 ac97->subsystem_device == 0x0061)) /* MSI S250 laptop */
2817 ac97->ext_id |= AC97_EI_SPDIF;
2820 snd_ac97_write_cache(ac97, 0x7a, val);
2826 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2829 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2830 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2833 if (ac97->id == AC97_ID_ALC658D)
2834 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800);
2844 static void alc850_update_jacks(struct snd_ac97 *ac97)
2850 shared = is_shared_surrout(ac97);
2852 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<4)|(1<<5),
2855 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 12,
2858 shared = is_shared_clfeout(ac97);
2860 snd_ac97_update_bits(ac97, AC97_ALC850_MISC1, (1<<12)|(1<<13),
2863 snd_ac97_update_bits(ac97, AC97_ALC850_JACK_SELECT, 7 << 4,
2866 aux_is_back_surround = alc850_is_aux_back_surround(ac97);
2868 snd_ac97_update_bits(ac97, AC97_ALC850_MULTICH, 1 << 10,
2879 static int patch_alc850_specific(struct snd_ac97 *ac97)
2883 err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850));
2886 if (ac97->ext_id & AC97_EI_SPDIF) {
2887 err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655));
2899 static int patch_alc850(struct snd_ac97 *ac97)
2901 ac97->build_ops = &patch_alc850_ops;
2903 ac97->spec.dev_flags = 0; /* for IEC958 playback route - ALC655 compatible */
2904 ac97->flags |= AC97_HAS_8CH;
2907 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
2916 snd_ac97_write_cache(ac97, AC97_ALC650_MULTICH, 1<<15);
2920 snd_ac97_write_cache(ac97, 0x7a, (1<<1)|(1<<4)|(0<<5)|(1<<6)|
2925 snd_ac97_write_cache(ac97, 0x76, (0<<0)|(0<<2)|(1<<4)|(1<<7)|(2<<8)|
2929 snd_ac97_write_cache(ac97, AC97_ALC650_SURR_DAC_VOL, 0x0808);
2930 snd_ac97_write_cache(ac97, AC97_ALC650_LFE_DAC_VOL, 0x0808);
2934 static int patch_aztech_azf3328_specific(struct snd_ac97 *ac97)
2937 snd_ac97_find_mixer_ctl(ac97, "3D Control - Center");
2939 snd_ac97_find_mixer_ctl(ac97, "3D Control - Depth");
2948 snd_ac97_rename_vol_ctl(ac97,
2958 snd_ac97_rename_vol_ctl(ac97,
2961 snd_ac97_rename_vol_ctl(ac97,
2972 static int patch_aztech_azf3328(struct snd_ac97 *ac97)
2974 ac97->build_ops = &patch_aztech_azf3328_ops;
2981 static void cm9738_update_jacks(struct snd_ac97 *ac97)
2984 snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
2985 is_shared_surrout(ac97) ? (1 << 10) : 0);
2994 static int patch_cm9738_specific(struct snd_ac97 * ac97)
2996 return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls));
3004 static int patch_cm9738(struct snd_ac97 * ac97)
3006 ac97->build_ops = &patch_cm9738_ops;
3009 ac97->flags |= AC97_HAS_NO_PCM_VOL;
3010 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3024 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3027 val = ac97->regs[AC97_CM9739_SPDIF_CTRL];
3034 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3036 return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL,
3059 static void cm9739_update_jacks(struct snd_ac97 *ac97)
3062 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
3063 is_shared_surrout(ac97) ? (1 << 10) : 0);
3065 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
3066 is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
3074 static int patch_cm9739_specific(struct snd_ac97 * ac97)
3076 return patch_build_controls(ac97, snd_ac97_cm9739_controls, ARRAY_SIZE(snd_ac97_cm9739_controls));
3079 static int patch_cm9739_post_spdif(struct snd_ac97 * ac97)
3081 return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif));
3090 static int patch_cm9739(struct snd_ac97 * ac97)
3094 ac97->build_ops = &patch_cm9739_ops;
3097 ac97->flags |= AC97_HAS_NO_MASTER_VOL | AC97_HAS_NO_PCM_VOL;
3098 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8000);
3099 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3102 val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
3105 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3106 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) | 0x01);
3107 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3109 ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */
3110 ac97->rates[AC97_RATES_SPDIF] = 0;
3122 val = snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) & (1 << 4);
3125 if (! (ac97->ext_id & AC97_EI_SPDIF))
3127 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN, val);
3130 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3131 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3133 if (ac97->pci &&
3134 ac97->subsystem_vendor == 0x1043 &&
3135 ac97->subsystem_device == 0x1843) {
3136 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3137 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) & ~0x01);
3138 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN,
3139 snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) | (1 << 14));
3149 static void cm9761_update_jacks(struct snd_ac97 *ac97)
3176 val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
3177 val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
3178 val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
3179 val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
3181 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
3198 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3200 if (ac97->regs[AC97_CM9761_FUNC] & 0x1)
3202 else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2)
3211 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3214 return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1);
3215 snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0);
3216 return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2,
3244 static int patch_cm9761_post_spdif(struct snd_ac97 * ac97)
3246 return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif));
3249 static int patch_cm9761_specific(struct snd_ac97 * ac97)
3251 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
3260 static int patch_cm9761(struct snd_ac97 *ac97)
3268 ac97->flags |= /*AC97_HAS_NO_MASTER_VOL |*/ AC97_HAS_NO_PCM_VOL;
3269 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808);
3270 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808);
3272 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B, 2 = model 83 */
3273 if (ac97->id == AC97_ID_CM9761_82) {
3276 val = snd_ac97_read(ac97, AC97_INT_PAGING);
3277 snd_ac97_write_cache(ac97, AC97_INT_PAGING, (val & ~0x0f) | 0x01);
3278 tmp = snd_ac97_read(ac97, 0x60);
3279 ac97->spec.dev_flags = tmp & 1; /* revision B? */
3280 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
3281 } else if (ac97->id == AC97_ID_CM9761_83)
3282 ac97->spec.dev_flags = 2;
3284 ac97->build_ops = &patch_cm9761_ops;
3288 ac97->ext_id |= AC97_EI_SPDIF;
3290 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
3292 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */
3293 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3314 if (ac97->spec.dev_flags)
3319 val = snd_ac97_read(ac97, AC97_CM9761_MULTI_CHAN);
3321 snd_ac97_write_cache(ac97, AC97_CM9761_MULTI_CHAN, val);
3324 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3325 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3347 static int patch_cm9780_specific(struct snd_ac97 *ac97)
3349 return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
3357 static int patch_cm9780(struct snd_ac97 *ac97)
3361 ac97->build_ops = &patch_cm9780_ops;
3364 if (ac97->ext_id & AC97_EI_SPDIF) {
3365 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3366 val = snd_ac97_read(ac97, AC97_CM9780_SPDIF);
3368 snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val);
3381 static int patch_vt1613_specific(struct snd_ac97 *ac97)
3383 return patch_build_controls(ac97, &snd_ac97_controls_vt1613[0],
3391 static int patch_vt1613(struct snd_ac97 *ac97)
3393 ac97->build_ops = &patch_vt1613_ops;
3395 ac97->flags |= AC97_HAS_NO_VIDEO;
3396 ac97->caps |= AC97_BC_HEADPHONE;
3428 static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
3431 return snd_ctl_find_id_mixer(ac97->bus->card, name);
3435 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3445 err = snd_ctl_add(ac97->bus->card, kctl);
3449 return snd_ctl_add_followers(ac97->bus->card, kctl, followers);
3452 static int patch_vt1616_specific(struct snd_ac97 * ac97)
3457 if (snd_ac97_try_bit(ac97, 0x5a, 9)) {
3458 err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1);
3462 err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1);
3467 kctl = snd_ac97_find_mixer_ctl(ac97, "Master Playback Volume");
3471 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
3473 err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
3478 err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
3490 static int patch_vt1616(struct snd_ac97 * ac97)
3492 ac97->build_ops = &patch_vt1616_ops;
3586 static int patch_vt1617a(struct snd_ac97 * ac97)
3594 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3603 val = snd_ac97_read(ac97, 0x5c);
3605 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3607 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3608 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3609 ac97->build_ops = &patch_vt1616_ops;
3801 static int patch_vt1618(struct snd_ac97 *ac97)
3803 return patch_build_controls(ac97, snd_ac97_controls_vt1618,
3809 static void it2646_update_jacks(struct snd_ac97 *ac97)
3812 snd_ac97_update_bits(ac97, 0x76, 1 << 9,
3813 is_shared_surrout(ac97) ? (1<<9) : 0);
3815 snd_ac97_update_bits(ac97, 0x76, 1 << 10,
3816 is_shared_clfeout(ac97) ? (1<<10) : 0);
3830 static int patch_it2646_specific(struct snd_ac97 * ac97)
3833 err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646));
3836 err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646));
3847 static int patch_it2646(struct snd_ac97 * ac97)
3849 ac97->build_ops = &patch_it2646_ops;
3851 snd_ac97_write_cache(ac97, 0x5E, 0x0808);
3852 snd_ac97_write_cache(ac97, 0x7A, 0x0808);
3867 static int patch_si3036_specific(struct snd_ac97 * ac97)
3871 err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97));
3882 static int mpatch_si3036(struct snd_ac97 * ac97)
3884 ac97->build_ops = &patch_si3036_ops;
3885 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
3886 snd_ac97_write_cache(ac97, 0x68, 0);
3914 static int patch_lm4550(struct snd_ac97 *ac97)
3916 ac97->res_table = lm4550_restbl;