• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/sound/pci/ac97/

Lines Matching defs:ac97

33 static int patch_build_controls(struct snd_ac97 * ac97, const struct snd_kcontrol_new *controls, int count)
38 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&controls[idx], ac97))) < 0)
44 static void reset_tlv(struct snd_ac97 *ac97, const char *name,
52 kctl = snd_ctl_find_id(ac97->bus->card, &sid);
58 static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page)
63 mutex_lock(&ac97->page_mutex);
64 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK;
65 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page);
66 ret = snd_ac97_update_bits(ac97, reg, mask, value);
67 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save);
68 mutex_unlock(&ac97->page_mutex); /* unlock paging */
95 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
97 ucontrol->value.enumerated.item[0] = ac97->indep_surround;
103 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
106 if (indep != ac97->indep_surround) {
107 ac97->indep_surround = indep;
108 if (ac97->build_ops->update_jacks)
109 ac97->build_ops->update_jacks(ac97);
124 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
126 ucontrol->value.enumerated.item[0] = ac97->channel_mode;
132 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
138 if (mode != ac97->channel_mode) {
139 ac97->channel_mode = mode;
140 if (ac97->build_ops->update_jacks)
141 ac97->build_ops->update_jacks(ac97);
186 static inline int is_surround_on(struct snd_ac97 *ac97)
188 return ac97->channel_mode >= 1;
191 static inline int is_clfe_on(struct snd_ac97 *ac97)
193 return ac97->channel_mode >= 2;
197 static inline int is_shared_surrout(struct snd_ac97 *ac97)
199 return !ac97->indep_surround && is_surround_on(ac97);
203 static inline int is_shared_clfeout(struct snd_ac97 *ac97)
205 return !ac97->indep_surround && is_clfe_on(ac97);
209 static inline int is_shared_linein(struct snd_ac97 *ac97)
211 return !ac97->indep_surround && !is_surround_on(ac97);
215 static inline int is_shared_micin(struct snd_ac97 *ac97)
217 return !ac97->indep_surround && !is_clfe_on(ac97);
220 static inline int alc850_is_aux_back_surround(struct snd_ac97 *ac97)
222 return is_surround_on(ac97);
250 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
253 val = ac97->regs[AC97_YMF7X3_3D_MODE_SEL];
264 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
270 return snd_ac97_update(ac97, AC97_YMF7X3_3D_MODE_SEL, val);
301 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
304 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
312 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
318 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0002, val);
321 static int patch_yamaha_ymf7x3_3d(struct snd_ac97 *ac97)
326 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97);
327 err = snd_ctl_add(ac97->bus->card, kctl);
332 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
333 err = snd_ctl_add(ac97->bus->card,
335 ac97));
338 snd_ac97_write_cache(ac97, AC97_YMF7X3_3D_MODE_SEL, 0x0c00);
357 static int patch_yamaha_ymf743_build_spdif(struct snd_ac97 *ac97)
361 err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3);
364 err = patch_build_controls(ac97,
370 snd_ac97_write_cache(ac97, AC97_YMF7X3_DIT_CTRL, 0xa201);
379 static int patch_yamaha_ymf743(struct snd_ac97 *ac97)
381 ac97->build_ops = &patch_yamaha_ymf743_ops;
382 ac97->caps |= AC97_BC_BASS_TREBLE;
383 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
384 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
385 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
408 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
411 val = ac97->regs[AC97_YMF7X3_DIT_CTRL];
418 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
425 return snd_ac97_update_bits(ac97, AC97_YMF7X3_DIT_CTRL, 0x0028, val);
427 snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */
449 static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97)
453 if ((err = patch_build_controls(ac97, snd_ac97_ymf753_controls_spdif, ARRAY_SIZE(snd_ac97_ymf753_controls_spdif))) < 0)
463 static int patch_yamaha_ymf753(struct snd_ac97 * ac97)
472 ac97->build_ops = &patch_yamaha_ymf753_ops;
473 ac97->caps |= AC97_BC_BASS_TREBLE;
474 ac97->caps |= 0x04 << 10; /* Yamaha 3D enhancement */
489 static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97)
498 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm97xx_snd_ac97_controls[i], ac97))) < 0)
501 snd_ac97_write_cache(ac97, AC97_WM97XX_FMIXER_VOL, 0x0808);
509 static int patch_wolfson03(struct snd_ac97 * ac97)
511 ac97->build_ops = &patch_wolfson_wm9703_ops;
524 static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97)
528 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9704_snd_ac97_controls[i], ac97))) < 0)
532 snd_ac97_write_cache(ac97, AC97_WM9704_TEST, 0x0200);
540 static int patch_wolfson04(struct snd_ac97 * ac97)
543 ac97->build_ops = &patch_wolfson_wm9704_ops;
547 static int patch_wolfson05(struct snd_ac97 * ac97)
550 ac97->build_ops = &patch_wolfson_wm9703_ops;
553 ac97->flags |= AC97_HAS_NO_VIDEO | AC97_HAS_NO_AUX;
663 static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97)
668 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm9711_snd_ac97_controls[i], ac97))) < 0)
671 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x0808);
672 snd_ac97_write_cache(ac97, AC97_PCI_SVID, 0x0808);
673 snd_ac97_write_cache(ac97, AC97_VIDEO, 0x0808);
674 snd_ac97_write_cache(ac97, AC97_AUX, 0x0808);
675 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
676 snd_ac97_write_cache(ac97, AC97_CD, 0x0000);
684 static int patch_wolfson11(struct snd_ac97 * ac97)
687 ac97->build_ops = &patch_wolfson_wm9711_ops;
689 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_MIC |
830 static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97)
835 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls_3d[i], ac97))) < 0)
841 static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97)
846 if ((err = snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&wm13_snd_ac97_controls[i], ac97))) < 0)
849 snd_ac97_write_cache(ac97, AC97_PC_BEEP, 0x0808);
850 snd_ac97_write_cache(ac97, AC97_PHONE, 0x0808);
851 snd_ac97_write_cache(ac97, AC97_MIC, 0x0808);
852 snd_ac97_write_cache(ac97, AC97_LINE, 0x00da);
853 snd_ac97_write_cache(ac97, AC97_CD, 0x0808);
854 snd_ac97_write_cache(ac97, AC97_VIDEO, 0xd612);
855 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x1ba0);
860 static void patch_wolfson_wm9713_suspend (struct snd_ac97 * ac97)
862 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xfeff);
863 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xffff);
866 static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97)
868 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
869 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
870 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
883 static int patch_wolfson13(struct snd_ac97 * ac97)
886 ac97->build_ops = &patch_wolfson_wm9713_ops;
888 ac97->flags |= AC97_HAS_NO_REC_GAIN | AC97_STEREO_MUTES | AC97_HAS_NO_PHONE |
891 ac97->scaps &= ~AC97_SCAP_MODEM;
893 snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00);
894 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810);
895 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0x0);
903 static int patch_tritech_tr28028(struct snd_ac97 * ac97)
905 snd_ac97_write_cache(ac97, 0x26, 0x0300);
906 snd_ac97_write_cache(ac97, 0x26, 0x0000);
907 snd_ac97_write_cache(ac97, AC97_SURROUND_MASTER, 0x0000);
908 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x0000);
915 static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97)
920 if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
924 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
928 static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97)
933 if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
937 if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0)
941 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000);
959 static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97)
963 snd_ac97_write_cache(ac97, AC97_SIGMATEL_ANALOG, snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) & ~0x0003);
964 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 1))
965 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[0], 1)) < 0)
967 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_ANALOG, 0))
968 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_controls[1], 1)) < 0)
970 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 2))
971 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_4speaker, 1)) < 0)
973 if (snd_ac97_try_bit(ac97, AC97_SIGMATEL_DAC2INVERT, 3))
974 if ((err = patch_build_controls(ac97, &snd_ac97_sigmatel_phaseinvert, 1)) < 0)
984 static int patch_sigmatel_stac9700(struct snd_ac97 * ac97)
986 ac97->build_ops = &patch_sigmatel_stac9700_ops;
992 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
995 mutex_lock(&ac97->page_mutex);
996 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
997 err = snd_ac97_update_bits(ac97, AC97_SIGMATEL_BIAS2, 0x0010,
999 snd_ac97_write(ac97, AC97_SIGMATEL_BIAS1, 0);
1000 mutex_unlock(&ac97->page_mutex);
1013 static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97)
1018 snd_ac97_remove_ctl(ac97, "PCM Out Path & Mute", NULL);
1020 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Sigmatel Surround Playback");
1021 if ((err = patch_build_controls(ac97, &snd_ac97_stac9708_bias_control, 1)) < 0)
1023 return patch_sigmatel_stac97xx_specific(ac97);
1031 static int patch_sigmatel_stac9708(struct snd_ac97 * ac97)
1035 ac97->build_ops = &patch_sigmatel_stac9708_ops;
1036 ac97->caps |= 0x10; /* HP (sigmatel surround) support */
1038 codec72 = snd_ac97_read(ac97, AC97_SIGMATEL_BIAS2) & 0x8000;
1039 codec6c = snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG);
1042 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1043 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1000);
1044 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1045 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0007);
1047 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1048 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x1001);
1049 snd_ac97_write_cache(ac97, AC97_SIGMATEL_DAC2INVERT, 0x0008);
1053 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1057 static int patch_sigmatel_stac9721(struct snd_ac97 * ac97)
1059 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1060 if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) {
1062 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1063 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x4000);
1064 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1065 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1067 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1071 static int patch_sigmatel_stac9744(struct snd_ac97 * ac97)
1074 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1075 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1076 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1077 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1078 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1079 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1083 static int patch_sigmatel_stac9756(struct snd_ac97 * ac97)
1086 ac97->build_ops = &patch_sigmatel_stac9700_ops;
1087 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC1, 0xabba);
1088 snd_ac97_write_cache(ac97, AC97_SIGMATEL_CIC2, 0x0000); /* is this correct? --jk */
1089 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS1, 0xabba);
1090 snd_ac97_write_cache(ac97, AC97_SIGMATEL_BIAS2, 0x0002);
1091 snd_ac97_write_cache(ac97, AC97_SIGMATEL_MULTICHN, 0x0000);
1111 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1115 val = ac97->regs[AC97_SIGMATEL_OUTSEL] >> shift;
1125 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1135 return ac97_update_bits_page(ac97, AC97_SIGMATEL_OUTSEL,
1155 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1159 val = ac97->regs[AC97_SIGMATEL_INSEL];
1166 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1169 return ac97_update_bits_page(ac97, AC97_SIGMATEL_INSEL, 7 << shift,
1188 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1190 ucontrol->value.enumerated.item[0] = ac97->regs[AC97_SIGMATEL_IOMISC] & 3;
1196 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1198 return ac97_update_bits_page(ac97, AC97_SIGMATEL_IOMISC, 3,
1233 static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97)
1237 err = patch_sigmatel_stac97xx_specific(ac97);
1240 err = patch_build_controls(ac97, snd_ac97_sigmatel_stac9758_controls,
1245 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Front Playback");
1249 snd_ac97_rename_vol_ctl(ac97, "Video Playback", "Surround Mix Playback");
1260 static int patch_sigmatel_stac9758(struct snd_ac97 * ac97)
1284 if (ac97->pci &&
1285 ac97->subsystem_vendor == 0x107b &&
1286 ac97->subsystem_device == 0x0601)
1290 ac97->build_ops = &patch_sigmatel_stac9758_ops;
1291 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, AC97_PAGE_VENDOR);
1293 snd_ac97_write_cache(ac97, regs[i], pregs[i]);
1295 ac97->flags |= AC97_STEREO_MUTES;
1307 static int patch_cirrus_build_spdif(struct snd_ac97 * ac97)
1312 if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0)
1315 if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[0], 1)) < 0)
1317 switch (ac97->id & AC97_ID_CS_MASK) {
1319 if ((err = patch_build_controls(ac97, &snd_ac97_cirrus_controls_spdif[1], 1)) < 0)
1325 snd_ac97_write_cache(ac97, AC97_CSR_SPDIF, 0x0a20);
1333 static int patch_cirrus_spdif(struct snd_ac97 * ac97)
1346 ac97->build_ops = &patch_cirrus_ops;
1347 ac97->flags |= AC97_CS_SPDIF;
1348 ac97->rates[AC97_RATES_SPDIF] &= ~SNDRV_PCM_RATE_32000;
1349 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1350 snd_ac97_write_cache(ac97, AC97_CSR_ACMODE, 0x0080);
1354 static int patch_cirrus_cs4299(struct snd_ac97 * ac97)
1357 ac97->flags |= AC97_HAS_PC_BEEP;
1359 return patch_cirrus_spdif(ac97);
1369 static int patch_conexant_build_spdif(struct snd_ac97 * ac97)
1374 if ((err = patch_build_controls(ac97, &snd_ac97_controls_spdif[0], 3)) < 0)
1377 if ((err = patch_build_controls(ac97, &snd_ac97_conexant_controls_spdif[0], 1)) < 0)
1381 snd_ac97_write_cache(ac97, AC97_CXR_AUDIO_MISC,
1382 snd_ac97_read(ac97, AC97_CXR_AUDIO_MISC) & ~(AC97_CXR_SPDIFEN|AC97_CXR_COPYRGT|AC97_CXR_SPDIF_MASK));
1390 static int patch_conexant(struct snd_ac97 * ac97)
1392 ac97->build_ops = &patch_conexant_ops;
1393 ac97->flags |= AC97_CX_SPDIF;
1394 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
1395 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
1399 static int patch_cx20551(struct snd_ac97 *ac97)
1401 snd_ac97_update_bits(ac97, 0x5c, 0x01, 0x01);
1409 static void ad18xx_resume(struct snd_ac97 *ac97)
1418 if (test_bit(reg, ac97->reg_accessed)) {
1419 snd_ac97_write(ac97, reg, ac97->regs[reg]);
1420 snd_ac97_read(ac97, reg);
1424 if (! (ac97->flags & AC97_AD_MULTI))
1426 snd_ac97_restore_status(ac97);
1430 if (! ac97->spec.ad18xx.id[codec])
1433 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1434 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1435 ac97->bus->ops->write(ac97, AC97_AD_CODEC_CFG, ac97->spec.ad18xx.codec_cfg[codec]);
1438 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1444 if (test_bit(i, ac97->reg_accessed)) {
1448 if (! ac97->spec.ad18xx.id[codec])
1451 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1452 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
1454 ac97->bus->ops->write(ac97, AC97_PCM, ac97->spec.ad18xx.pcmreg[codec]);
1457 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1464 snd_ac97_write(ac97, i, ac97->regs[i]);
1465 snd_ac97_read(ac97, i);
1469 snd_ac97_restore_iec958(ac97);
1472 static void ad1888_resume(struct snd_ac97 *ac97)
1474 ad18xx_resume(ac97);
1475 snd_ac97_write_cache(ac97, AC97_CODEC_CLASS_REV, 0x8080);
1491 static int patch_ad1819(struct snd_ac97 * ac97)
1496 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1497 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x7000); /* select all codecs */
1498 ac97->res_table = ad1819_restbl;
1502 static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, unsigned short mask)
1507 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, mask);
1508 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000); /* ID0C, ID1C, SDIE = off */
1509 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1512 ac97->spec.ad18xx.unchained[idx] = mask;
1513 ac97->spec.ad18xx.id[idx] = val;
1514 ac97->spec.ad18xx.codec_cfg[idx] = 0x0000;
1518 static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits)
1523 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, cfg_bits[idx]);
1524 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0004); // SDIE
1525 val = snd_ac97_read(ac97, AC97_VENDOR_ID2);
1529 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, codec_bits);
1530 ac97->spec.ad18xx.chained[idx] = cfg_bits[idx];
1531 ac97->spec.ad18xx.id[idx] = val;
1532 ac97->spec.ad18xx.codec_cfg[idx] = codec_bits ? codec_bits : 0x0004;
1536 static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int cidx1, int cidx2)
1539 if (ac97->spec.ad18xx.unchained[cidx1] || ac97->spec.ad18xx.chained[cidx1])
1541 if (ac97->spec.ad18xx.unchained[cidx2] || ac97->spec.ad18xx.chained[cidx2])
1546 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
1547 ac97->spec.ad18xx.unchained[unchained_idx]);
1548 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0002); // ID1C
1549 ac97->spec.ad18xx.codec_cfg[unchained_idx] = 0x0002;
1552 patch_ad1881_chained1(ac97, cidx1, 0);
1553 else if (patch_ad1881_chained1(ac97, cidx1, 0x0006)) // SDIE | ID1C
1554 patch_ad1881_chained1(ac97, cidx2, 0);
1555 else if (patch_ad1881_chained1(ac97, cidx2, 0x0006)) // SDIE | ID1C
1556 patch_ad1881_chained1(ac97, cidx1, 0);
1558 patch_ad1881_chained1(ac97, cidx2, 0);
1568 static int patch_ad1881(struct snd_ac97 * ac97)
1581 val = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG);
1582 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, val);
1583 codecs[0] = patch_ad1881_unchained(ac97, 0, (1<<12));
1584 codecs[1] = patch_ad1881_unchained(ac97, 1, (1<<14));
1585 codecs[2] = patch_ad1881_unchained(ac97, 2, (1<<13));
1591 if (ac97->spec.ad18xx.unchained[idx])
1592 patch_ad1881_chained(ac97, idx, cfg_idxs[idx][0], cfg_idxs[idx][1]);
1594 if (ac97->spec.ad18xx.id[1]) {
1595 ac97->flags |= AC97_AD_MULTI;
1596 ac97->scaps |= AC97_SCAP_SURROUND_DAC;
1598 if (ac97->spec.ad18xx.id[2]) {
1599 ac97->flags |= AC97_AD_MULTI;
1600 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC;
1605 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
1608 if (ac97->spec.ad18xx.id[idx])
1612 snd_ac97_write_cache(ac97, AC97_AD_CODEC_CFG, 0x0000);
1613 ac97->spec.ad18xx.codec_cfg[0] =
1614 ac97->spec.ad18xx.codec_cfg[1] =
1615 ac97->spec.ad18xx.codec_cfg[2] = 0x0000;
1618 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID);
1619 if (ac97->spec.ad18xx.id[0]) {
1620 ac97->id &= 0xffff0000;
1621 ac97->id |= ac97->spec.ad18xx.id[0];
1623 ac97->build_ops = &patch_ad1881_build_ops;
1638 static int patch_ad1885_specific(struct snd_ac97 * ac97)
1642 if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0)
1644 reset_tlv(ac97, "Headphone Playback Volume",
1656 static int patch_ad1885(struct snd_ac97 * ac97)
1658 patch_ad1881(ac97);
1663 snd_ac97_write_cache(ac97, AC97_AD_MISC, 0x0404);
1665 ac97->build_ops = &patch_ad1885_build_ops;
1669 static int patch_ad1886_specific(struct snd_ac97 * ac97)
1671 reset_tlv(ac97, "Headphone Playback Volume",
1683 static int patch_ad1886(struct snd_ac97 * ac97)
1685 patch_ad1881(ac97);
1687 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
1688 ac97->build_ops = &patch_ad1886_build_ops;
1809 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1812 val = ac97->regs[AC97_AD_SERIAL_CFG];
1819 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1825 return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val);
1836 static int patch_ad198x_post_spdif(struct snd_ac97 * ac97)
1838 return patch_build_controls(ac97, &snd_ac97_ad198x_spdif_source, 1);
1865 static int check_list(struct snd_ac97 *ac97, const unsigned int *list)
1867 u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device;
1874 static int patch_ad1981a_specific(struct snd_ac97 * ac97)
1876 if (check_list(ac97, ad1981_jacks_blacklist))
1878 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1905 static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97)
1907 if (check_list(ac97, ad1981_jacks_whitelist))
1909 snd_ac97_update_bits(ac97, AC97_AD_JACK_SPDIF, 1<<11, 1<<11);
1912 static int patch_ad1981a(struct snd_ac97 *ac97)
1914 patch_ad1881(ac97);
1915 ac97->build_ops = &patch_ad1981a_build_ops;
1916 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1917 ac97->flags |= AC97_STEREO_MUTES;
1918 check_ad1981_hp_jack_sense(ac97);
1925 static int patch_ad1981b_specific(struct snd_ac97 *ac97)
1929 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
1931 if (check_list(ac97, ad1981_jacks_blacklist))
1933 return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense,
1945 static int patch_ad1981b(struct snd_ac97 *ac97)
1947 patch_ad1881(ac97);
1948 ac97->build_ops = &patch_ad1981b_build_ops;
1949 snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD198X_MSPLT, AC97_AD198X_MSPLT);
1950 ac97->flags |= AC97_STEREO_MUTES;
1951 check_ad1981_hp_jack_sense(ac97);
1959 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1962 val = ac97->regs[AC97_AD_MISC];
1964 if (ac97->spec.ad18xx.lo_as_master)
1972 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
1976 if (ac97->spec.ad18xx.lo_as_master)
1979 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
1998 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2001 val = ac97->regs[AC97_AD_MISC];
2011 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2021 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
2025 static void ad1888_update_jacks(struct snd_ac97 *ac97)
2029 if (!ac97->spec.ad18xx.lo_as_master && is_shared_linein(ac97))
2032 if (is_shared_micin(ac97))
2035 snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val);
2064 static int patch_ad1888_specific(struct snd_ac97 *ac97)
2066 if (!ac97->spec.ad18xx.lo_as_master) {
2068 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2070 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback",
2073 return patch_build_controls(ac97, snd_ac97_ad1888_controls, ARRAY_SIZE(snd_ac97_ad1888_controls));
2085 static int patch_ad1888(struct snd_ac97 * ac97)
2089 patch_ad1881(ac97);
2090 ac97->build_ops = &patch_ad1888_build_ops;
2096 if (ac97->subsystem_vendor == 0x1043 &&
2097 ac97->subsystem_device == 0x1193) /* ASUS A9T laptop */
2098 ac97->spec.ad18xx.lo_as_master = 1;
2100 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2104 if (!ac97->spec.ad18xx.lo_as_master)
2111 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc);
2112 ac97->flags |= AC97_STEREO_MUTES;
2116 static int patch_ad1980_specific(struct snd_ac97 *ac97)
2120 if ((err = patch_ad1888_specific(ac97)) < 0)
2122 return patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1);
2134 static int patch_ad1980(struct snd_ac97 * ac97)
2136 patch_ad1888(ac97);
2137 ac97->build_ops = &patch_ad1980_build_ops;
2160 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2162 val = (ac97->regs[AC97_AD_MISC] & AC97_AD198X_VREF_MASK)
2172 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2179 return snd_ac97_update_bits(ac97, AC97_AD_MISC,
2216 static void ad1985_update_jacks(struct snd_ac97 *ac97)
2218 ad1888_update_jacks(ac97);
2220 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
2221 is_shared_micin(ac97) ? 1 << 9 : 0);
2224 static int patch_ad1985_specific(struct snd_ac97 *ac97)
2229 snd_ac97_rename_vol_ctl(ac97, "Master Playback",
2231 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback");
2233 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
2236 return patch_build_controls(ac97, snd_ac97_ad1985_controls,
2249 static int patch_ad1985(struct snd_ac97 * ac97)
2253 patch_ad1881(ac97);
2254 ac97->build_ops = &patch_ad1985_build_ops;
2255 misc = snd_ac97_read(ac97, AC97_AD_MISC);
2259 snd_ac97_write_cache(ac97, AC97_AD_MISC, misc |
2264 ac97->flags |= AC97_STEREO_MUTES;
2267 ad1985_update_jacks(ac97);
2270 ac97->ext_id = (ac97->ext_id & ~AC97_EI_REV_MASK) | AC97_EI_REV_23;
2279 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2282 val = ac97->regs[AC97_AD_MISC3];
2290 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2293 int sprd = (ac97->regs[AC97_AD_MISC] & AC97_AD1986_SPRD) != 0;
2295 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC3, AC97_AD1986_LOSEL,
2302 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2315 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2318 val = ac97->regs[AC97_AD_MISC];
2326 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2329 int sprd = (ac97->regs[AC97_AD_MISC3] & AC97_AD1986_LOSEL) != 0;
2331 ret0 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SPRD,
2338 ret1 = snd_ac97_update_bits(ac97, AC97_AD_MISC, AC97_AD1986_SOSEL,
2351 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2353 ucontrol->value.integer.value[0] = ac97->spec.ad18xx.swap_mic_linein;
2360 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2363 if (swap != ac97->spec.ad18xx.swap_mic_linein) {
2364 ac97->spec.ad18xx.swap_mic_linein = swap;
2365 if (ac97->build_ops->update_jacks)
2366 ac97->build_ops->update_jacks(ac97);
2376 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2378 unsigned short reg = ac97->regs[AC97_AD_MISC2];
2394 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2428 cret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2432 lret = snd_ac97_update_bits(ac97, AC97_AD_MISC3,
2436 mret = snd_ac97_update_bits(ac97, AC97_AD_MISC2,
2488 static void ad1986_update_jacks(struct snd_ac97 *ac97)
2494 if (!is_surround_on(ac97))
2496 if (!is_clfe_on(ac97))
2500 if (is_shared_linein(ac97))
2502 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2504 snd_ac97_update_bits(ac97, AC97_AD_MISC,
2510 if (is_shared_micin(ac97))
2512 else if (ac97->spec.ad18xx.swap_mic_linein != 0)
2516 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG,
2521 static int patch_ad1986_specific(struct snd_ac97 *ac97)
2525 if ((err = patch_build_controls(ac97, &snd_ac97_ad198x_2cmic, 1)) < 0)
2528 return patch_build_controls(ac97, snd_ac97_ad1986_controls,
2541 static int patch_ad1986(struct snd_ac97 * ac97)
2543 patch_ad1881(ac97);
2544 ac97->build_ops = &patch_ad1986_build_ops;
2545 ac97->flags |= AC97_STEREO_MUTES;
2548 ad1986_update_jacks(ac97);
2556 static int patch_alc203(struct snd_ac97 *ac97)
2558 snd_ac97_update_bits(ac97, 0x7a, 0x400, 0x400);
2565 static void alc650_update_jacks(struct snd_ac97 *ac97)
2570 shared = is_shared_surrout(ac97);
2571 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 9,
2574 shared = is_shared_clfeout(ac97);
2576 snd_ac97_update_bits(ac97, AC97_ALC650_CLOCK, 1 << 12,
2579 snd_ac97_update_bits(ac97, AC97_ALC650_MULTICH, 1 << 10,
2582 snd_ac97_update_bits(ac97, AC97_ALC650_GPIO_STATUS, 0x100,
2613 static int patch_alc650_specific(struct snd_ac97 * ac97)
2617 if ((err = patch_build_controls(ac97, snd_ac97_controls_alc650, ARRAY_SIZE(snd_ac97_controls_alc650))) < 0)
2619 if (ac97->ext_id & AC97_EI_SPDIF) {
2620 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650))) < 0)
2623 if (ac97->id != AC97_ID_ALC650F)
2624 reset_tlv(ac97, "Master Playback Volume",
2634 static int patch_alc650(struct snd_ac97 * ac97)
2638 ac97->build_ops = &patch_alc650_ops;
2641 val = snd_ac97_read(ac97, AC97_ALC650_REVISION) & 0x3f;
2643 ac97->id = 0x414c4720; /* Old version */
2645 ac97->id = 0x414c4721; /* D version */
2647 ac97->id = 0x414c4722; /* E version */
2649 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,
2718 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2722 uinfo->value.enumerated.items = ac97->spec.dev_flags ? 4 : 3;
2726 ac97->spec.dev_flags ?
2734 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2737 val = ac97->regs[AC97_ALC650_MULTICH];
2739 if (ac97->spec.dev_flags && val == 3)
2747 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2749 return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 3 << 12,
2767 static int patch_alc655_specific(struct snd_ac97 * ac97)
2771 if ((err = patch_build_controls(ac97, snd_ac97_controls_alc655, ARRAY_SIZE(snd_ac97_controls_alc655))) < 0)
2773 if (ac97->ext_id & AC97_EI_SPDIF) {
2774 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0)
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 if ((err = patch_build_controls(ac97, snd_ac97_controls_alc850, ARRAY_SIZE(snd_ac97_controls_alc850))) < 0)
2885 if (ac97->ext_id & AC97_EI_SPDIF) {
2886 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc655, ARRAY_SIZE(snd_ac97_spdif_controls_alc655))) < 0)
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);
2936 static void cm9738_update_jacks(struct snd_ac97 *ac97)
2939 snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10,
2940 is_shared_surrout(ac97) ? (1 << 10) : 0);
2949 static int patch_cm9738_specific(struct snd_ac97 * ac97)
2951 return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls));
2959 static int patch_cm9738(struct snd_ac97 * ac97)
2961 ac97->build_ops = &patch_cm9738_ops;
2963 ac97->flags |= AC97_HAS_NO_PCM_VOL;
2964 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
2984 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2987 val = ac97->regs[AC97_CM9739_SPDIF_CTRL];
2994 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
2996 return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL,
3019 static void cm9739_update_jacks(struct snd_ac97 *ac97)
3022 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10,
3023 is_shared_surrout(ac97) ? (1 << 10) : 0);
3025 snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 0x3000,
3026 is_shared_clfeout(ac97) ? 0x1000 : 0x2000);
3034 static int patch_cm9739_specific(struct snd_ac97 * ac97)
3036 return patch_build_controls(ac97, snd_ac97_cm9739_controls, ARRAY_SIZE(snd_ac97_cm9739_controls));
3039 static int patch_cm9739_post_spdif(struct snd_ac97 * ac97)
3041 return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif));
3050 static int patch_cm9739(struct snd_ac97 * ac97)
3054 ac97->build_ops = &patch_cm9739_ops;
3057 ac97->flags |= AC97_HAS_NO_MASTER_VOL | AC97_HAS_NO_PCM_VOL;
3058 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8000);
3059 snd_ac97_write_cache(ac97, AC97_PCM, 0x8000);
3062 val = snd_ac97_read(ac97, AC97_EXTENDED_STATUS);
3065 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3066 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) | 0x01);
3067 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3069 ac97->ext_id &= ~AC97_EI_SPDIF; /* disable extended-id */
3070 ac97->rates[AC97_RATES_SPDIF] = 0;
3082 val = snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) & (1 << 4);
3085 if (! (ac97->ext_id & AC97_EI_SPDIF))
3087 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN, val);
3089 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3090 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3092 if (ac97->pci &&
3093 ac97->subsystem_vendor == 0x1043 &&
3094 ac97->subsystem_device == 0x1843) {
3095 snd_ac97_write_cache(ac97, AC97_CM9739_SPDIF_CTRL,
3096 snd_ac97_read(ac97, AC97_CM9739_SPDIF_CTRL) & ~0x01);
3097 snd_ac97_write_cache(ac97, AC97_CM9739_MULTI_CHAN,
3098 snd_ac97_read(ac97, AC97_CM9739_MULTI_CHAN) | (1 << 14));
3108 static void cm9761_update_jacks(struct snd_ac97 *ac97)
3132 val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
3133 val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
3134 val |= surr_shared[ac97->spec.dev_flags][is_shared_surrout(ac97)];
3135 val |= clfe_shared[ac97->spec.dev_flags][is_shared_clfeout(ac97)];
3137 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
3160 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3162 if (ac97->regs[AC97_CM9761_FUNC] & 0x1)
3164 else if (ac97->regs[AC97_CM9761_SPDIF_CTRL] & 0x2)
3173 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol);
3176 return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1);
3177 snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0);
3178 return snd_ac97_update_bits(ac97, AC97_CM9761_SPDIF_CTRL, 0x2,
3204 static int patch_cm9761_post_spdif(struct snd_ac97 * ac97)
3206 return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif));
3209 static int patch_cm9761_specific(struct snd_ac97 * ac97)
3211 return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls));
3220 static int patch_cm9761(struct snd_ac97 *ac97)
3228 ac97->flags |= /*AC97_HAS_NO_MASTER_VOL |*/ AC97_HAS_NO_PCM_VOL;
3229 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808);
3230 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808);
3232 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B, 2 = model 83 */
3233 if (ac97->id == AC97_ID_CM9761_82) {
3236 val = snd_ac97_read(ac97, AC97_INT_PAGING);
3237 snd_ac97_write_cache(ac97, AC97_INT_PAGING, (val & ~0x0f) | 0x01);
3238 tmp = snd_ac97_read(ac97, 0x60);
3239 ac97->spec.dev_flags = tmp & 1; /* revision B? */
3240 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
3241 } else if (ac97->id == AC97_ID_CM9761_83)
3242 ac97->spec.dev_flags = 2;
3244 ac97->build_ops = &patch_cm9761_ops;
3248 ac97->ext_id |= AC97_EI_SPDIF;
3250 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, 0x05c0);
3252 snd_ac97_write_cache(ac97, AC97_CM9761_SPDIF_CTRL, 0x0001); /* enable spdif-in */
3253 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3273 val = snd_ac97_read(ac97, AC97_CM9761_MULTI_CHAN);
3275 snd_ac97_write_cache(ac97, AC97_CM9761_MULTI_CHAN, val);
3277 snd_ac97_write_cache(ac97, 0x70, 0x0100);
3278 snd_ac97_write_cache(ac97, 0x72, 0x0020);
3298 static int patch_cm9780_specific(struct snd_ac97 *ac97)
3300 return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls));
3308 static int patch_cm9780(struct snd_ac97 *ac97)
3312 ac97->build_ops = &patch_cm9780_ops;
3315 if (ac97->ext_id & AC97_EI_SPDIF) {
3316 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000; /* 48k only */
3317 val = snd_ac97_read(ac97, AC97_CM9780_SPDIF);
3319 snd_ac97_write_cache(ac97, AC97_CM9780_SPDIF, val);
3352 static struct snd_kcontrol *snd_ac97_find_mixer_ctl(struct snd_ac97 *ac97,
3359 return snd_ctl_find_id(ac97->bus->card, &id);
3363 static int snd_ac97_add_vmaster(struct snd_ac97 *ac97, char *name,
3373 err = snd_ctl_add(ac97->bus->card, kctl);
3380 sctl = snd_ac97_find_mixer_ctl(ac97, *s);
3392 static int patch_vt1616_specific(struct snd_ac97 * ac97)
3397 if (snd_ac97_try_bit(ac97, 0x5a, 9))
3398 if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[0], 1)) < 0)
3400 if ((err = patch_build_controls(ac97, &snd_ac97_controls_vt1616[1], ARRAY_SIZE(snd_ac97_controls_vt1616) - 1)) < 0)
3404 kctl = snd_ac97_find_mixer_ctl(ac97, "Master Playback Volume");
3408 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Front Playback");
3410 err = snd_ac97_add_vmaster(ac97, "Master Playback Volume",
3415 err = snd_ac97_add_vmaster(ac97, "Master Playback Switch",
3427 static int patch_vt1616(struct snd_ac97 * ac97)
3429 ac97->build_ops = &patch_vt1616_ops;
3522 static int patch_vt1617a(struct snd_ac97 * ac97)
3530 err = patch_build_controls(ac97, &snd_ac97_controls_vt1617a[0],
3539 val = snd_ac97_read(ac97, 0x5c);
3541 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3543 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3544 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3545 ac97->build_ops = &patch_vt1616_ops;
3738 static int patch_vt1618(struct snd_ac97 *ac97)
3740 return patch_build_controls(ac97, snd_ac97_controls_vt1618,
3746 static void it2646_update_jacks(struct snd_ac97 *ac97)
3749 snd_ac97_update_bits(ac97, 0x76, 1 << 9,
3750 is_shared_surrout(ac97) ? (1<<9) : 0);
3752 snd_ac97_update_bits(ac97, 0x76, 1 << 10,
3753 is_shared_clfeout(ac97) ? (1<<10) : 0);
3767 static int patch_it2646_specific(struct snd_ac97 * ac97)
3770 if ((err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646))) < 0)
3772 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_it2646, ARRAY_SIZE(snd_ac97_spdif_controls_it2646))) < 0)
3782 static int patch_it2646(struct snd_ac97 * ac97)
3784 ac97->build_ops = &patch_it2646_ops;
3786 snd_ac97_write_cache(ac97, 0x5E, 0x0808);
3787 snd_ac97_write_cache(ac97, 0x7A, 0x0808);
3802 static int patch_si3036_specific(struct snd_ac97 * ac97)
3806 if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_si3036[idx], ac97))) < 0)
3815 static int mpatch_si3036(struct snd_ac97 * ac97)
3817 ac97->build_ops = &patch_si3036_ops;
3818 snd_ac97_write_cache(ac97, 0x5c, 0xf210 );
3819 snd_ac97_write_cache(ac97, 0x68, 0);
3847 static int patch_lm4550(struct snd_ac97 *ac97)
3849 ac97->res_table = lm4550_restbl;
3869 static int patch_ucb1400_specific(struct snd_ac97 * ac97)
3873 if ((err = snd_ctl_add(ac97->bus->card, snd_ctl_new1(&snd_ac97_controls_ucb1400[idx], ac97))) < 0)
3882 static int patch_ucb1400(struct snd_ac97 * ac97)
3884 ac97->build_ops = &patch_ucb1400_ops;
3886 snd_ac97_write_cache(ac97, 0x6a, 0x0050);
3887 snd_ac97_write_cache(ac97, 0x6c, 0x0030);