- is_ad18xx = (ac97->flags & AC97_AD_MULTI);
- if (is_ad18xx) {
- /* restore the AD18xx codec configurations */
- for (codec = 0; codec < 3; codec++) {
- if (! ac97->spec.ad18xx.id[codec])
- continue;
- /* select single codec */
- snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
- ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
- ac97->bus->ops->write(ac97, AC97_AD_CODEC_CFG, ac97->spec.ad18xx.codec_cfg[codec]);
- }
- /* select all codecs */
- snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
- }
-
- /* restore ac97 status */
- for (i = 2; i < 0x7c ; i += 2) {
- if (i == AC97_POWERDOWN || i == AC97_EXTENDED_ID)
- continue;
- /* restore only accessible registers
- * some chip (e.g. nm256) may hang up when unsupported registers
- * are accessed..!
- */
- if (test_bit(i, ac97->reg_accessed)) {
- if (is_ad18xx) {
- /* handle multi codecs for AD18xx */
- if (i == AC97_PCM) {
- for (codec = 0; codec < 3; codec++) {
- if (! ac97->spec.ad18xx.id[codec])
- continue;
- /* select single codec */
- snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000,
- ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]);
- /* update PCM bits */
- ac97->bus->ops->write(ac97, AC97_PCM, ac97->spec.ad18xx.pcmreg[codec]);
- }
- /* select all codecs */
- snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x7000, 0x7000);
- continue;
- } else if (i == AC97_AD_TEST ||
- i == AC97_AD_CODEC_CFG ||
- i == AC97_AD_SERIAL_CFG)
- continue; /* ignore */
- }
- snd_ac97_write(ac97, i, ac97->regs[i]);
- snd_ac97_read(ac97, i);
- }
- }
-
- if (ac97->ext_id & AC97_EI_SPDIF) {
- if (ac97->regs[AC97_EXTENDED_STATUS] & AC97_EA_SPDIF) {
- /* reset spdif status */
- snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0);
- snd_ac97_write(ac97, AC97_EXTENDED_STATUS, ac97->regs[AC97_EXTENDED_STATUS]);
- if (ac97->flags & AC97_CS_SPDIF)
- snd_ac97_write(ac97, AC97_CSR_SPDIF, ac97->regs[AC97_CSR_SPDIF]);
- else
- snd_ac97_write(ac97, AC97_SPDIF, ac97->regs[AC97_SPDIF]);
- snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */
- }