Lines Matching refs:ac97

49 	int (*patch)(struct snd_ac97 *ac97);
50 int (*mpatch)(struct snd_ac97 *ac97);
195 static void update_power_regs(struct snd_ac97 *ac97);
197 #define ac97_is_power_save_mode(ac97) \ argument
198 ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save)
200 #define ac97_is_power_save_mode(ac97) 0 argument
203 #define ac97_err(ac97, fmt, args...) \ argument
204 dev_err((ac97)->bus->card->dev, fmt, ##args)
205 #define ac97_warn(ac97, fmt, args...) \ argument
206 dev_warn((ac97)->bus->card->dev, fmt, ##args)
207 #define ac97_dbg(ac97, fmt, args...) \ argument
208 dev_dbg((ac97)->bus->card->dev, fmt, ##args)
214 static int snd_ac97_valid_reg(struct snd_ac97 *ac97, unsigned short reg) in snd_ac97_valid_reg() argument
217 switch (ac97->id) { in snd_ac97_valid_reg()
272 void snd_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) in snd_ac97_write() argument
274 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_write()
276 if ((ac97->id & 0xffffff00) == AC97_ID_ALC100) { in snd_ac97_write()
279 ac97->bus->ops->write(ac97, AC97_RESET, 0); /* reset audio codec */ in snd_ac97_write()
281 ac97->bus->ops->write(ac97, reg, value); in snd_ac97_write()
297 unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg) in snd_ac97_read() argument
299 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_read()
301 return ac97->bus->ops->read(ac97, reg); in snd_ac97_read()
305 static inline unsigned short snd_ac97_read_cache(struct snd_ac97 *ac97, unsigned short reg) in snd_ac97_read_cache() argument
307 if (! test_bit(reg, ac97->reg_accessed)) { in snd_ac97_read_cache()
308 ac97->regs[reg] = ac97->bus->ops->read(ac97, reg); in snd_ac97_read_cache()
311 return ac97->regs[reg]; in snd_ac97_read_cache()
326 void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) in snd_ac97_write_cache() argument
328 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_write_cache()
330 mutex_lock(&ac97->reg_mutex); in snd_ac97_write_cache()
331 ac97->regs[reg] = value; in snd_ac97_write_cache()
332 ac97->bus->ops->write(ac97, reg, value); in snd_ac97_write_cache()
333 set_bit(reg, ac97->reg_accessed); in snd_ac97_write_cache()
334 mutex_unlock(&ac97->reg_mutex); in snd_ac97_write_cache()
351 int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) in snd_ac97_update() argument
355 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_update()
357 mutex_lock(&ac97->reg_mutex); in snd_ac97_update()
358 change = ac97->regs[reg] != value; in snd_ac97_update()
360 ac97->regs[reg] = value; in snd_ac97_update()
361 ac97->bus->ops->write(ac97, reg, value); in snd_ac97_update()
363 set_bit(reg, ac97->reg_accessed); in snd_ac97_update()
364 mutex_unlock(&ac97->reg_mutex); in snd_ac97_update()
383 int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned s… in snd_ac97_update_bits() argument
387 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_update_bits()
389 mutex_lock(&ac97->reg_mutex); in snd_ac97_update_bits()
390 change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); in snd_ac97_update_bits()
391 mutex_unlock(&ac97->reg_mutex); in snd_ac97_update_bits()
398 int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, in snd_ac97_update_bits_nolock() argument
404 old = snd_ac97_read_cache(ac97, reg); in snd_ac97_update_bits_nolock()
408 ac97->regs[reg] = new; in snd_ac97_update_bits_nolock()
409 ac97->bus->ops->write(ac97, reg, new); in snd_ac97_update_bits_nolock()
411 set_bit(reg, ac97->reg_accessed); in snd_ac97_update_bits_nolock()
415 static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, unsigned short mask, u… in snd_ac97_ad18xx_update_pcm_bits() argument
420 mutex_lock(&ac97->page_mutex); in snd_ac97_ad18xx_update_pcm_bits()
421 old = ac97->spec.ad18xx.pcmreg[codec]; in snd_ac97_ad18xx_update_pcm_bits()
425 mutex_lock(&ac97->reg_mutex); in snd_ac97_ad18xx_update_pcm_bits()
426 cfg = snd_ac97_read_cache(ac97, AC97_AD_SERIAL_CFG); in snd_ac97_ad18xx_update_pcm_bits()
427 ac97->spec.ad18xx.pcmreg[codec] = new; in snd_ac97_ad18xx_update_pcm_bits()
429 ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, in snd_ac97_ad18xx_update_pcm_bits()
431 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]); in snd_ac97_ad18xx_update_pcm_bits()
433 ac97->bus->ops->write(ac97, AC97_PCM, new); in snd_ac97_ad18xx_update_pcm_bits()
435 ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, in snd_ac97_ad18xx_update_pcm_bits()
437 mutex_unlock(&ac97->reg_mutex); in snd_ac97_ad18xx_update_pcm_bits()
439 mutex_unlock(&ac97->page_mutex); in snd_ac97_ad18xx_update_pcm_bits()
459 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_get_enum_double() local
465 val = snd_ac97_read_cache(ac97, e->reg); in snd_ac97_get_enum_double()
476 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_put_enum_double() local
493 return snd_ac97_update_bits(ac97, e->reg, mask, val); in snd_ac97_put_enum_double()
497 static int snd_ac97_page_save(struct snd_ac97 *ac97, int reg, struct snd_kcontrol *kcontrol) in snd_ac97_page_save() argument
501 (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && in snd_ac97_page_save()
504 mutex_lock(&ac97->page_mutex); /* lock paging */ in snd_ac97_page_save()
505 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK; in snd_ac97_page_save()
506 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page); in snd_ac97_page_save()
511 static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save) in snd_ac97_page_restore() argument
514 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); in snd_ac97_page_restore()
515 mutex_unlock(&ac97->page_mutex); /* unlock paging */ in snd_ac97_page_restore()
537 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_get_volsw() local
545 page_save = snd_ac97_page_save(ac97, reg, kcontrol); in snd_ac97_get_volsw()
546 ucontrol->value.integer.value[0] = (snd_ac97_read_cache(ac97, reg) >> shift) & mask; in snd_ac97_get_volsw()
548 ucontrol->value.integer.value[1] = (snd_ac97_read_cache(ac97, reg) >> rshift) & mask; in snd_ac97_get_volsw()
554 snd_ac97_page_restore(ac97, page_save); in snd_ac97_get_volsw()
561 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_put_volsw() local
570 page_save = snd_ac97_page_save(ac97, reg, kcontrol); in snd_ac97_put_volsw()
583 err = snd_ac97_update_bits(ac97, reg, val_mask, val); in snd_ac97_put_volsw()
584 snd_ac97_page_restore(ac97, page_save); in snd_ac97_put_volsw()
590 ac97->power_up &= ~(1 << (reg>>1)); in snd_ac97_put_volsw()
592 ac97->power_up |= 1 << (reg>>1); in snd_ac97_put_volsw()
593 update_power_regs(ac97); in snd_ac97_put_volsw()
680 static void set_inv_eapd(struct snd_ac97 *ac97, struct snd_kcontrol *kctl) in set_inv_eapd() argument
683 snd_ac97_update_bits(ac97, AC97_POWERDOWN, (1<<15), (1<<15)); /* EAPD up */ in set_inv_eapd()
684 ac97->scaps |= AC97_SCAP_INV_EAPD; in set_inv_eapd()
718 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_spdif_default_get() local
720 mutex_lock(&ac97->reg_mutex); in snd_ac97_spdif_default_get()
721 ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff; in snd_ac97_spdif_default_get()
722 ucontrol->value.iec958.status[1] = (ac97->spdif_status >> 8) & 0xff; in snd_ac97_spdif_default_get()
723 ucontrol->value.iec958.status[2] = (ac97->spdif_status >> 16) & 0xff; in snd_ac97_spdif_default_get()
724 ucontrol->value.iec958.status[3] = (ac97->spdif_status >> 24) & 0xff; in snd_ac97_spdif_default_get()
725 mutex_unlock(&ac97->reg_mutex); in snd_ac97_spdif_default_get()
731 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_spdif_default_put() local
764 mutex_lock(&ac97->reg_mutex); in snd_ac97_spdif_default_put()
765 change = ac97->spdif_status != new; in snd_ac97_spdif_default_put()
766 ac97->spdif_status = new; in snd_ac97_spdif_default_put()
768 if (ac97->flags & AC97_CS_SPDIF) { in snd_ac97_spdif_default_put()
775 change |= snd_ac97_update_bits_nolock(ac97, AC97_CSR_SPDIF, 0x3fff, ((val & 0xcfff) | (x << 12))); in snd_ac97_spdif_default_put()
776 } else if (ac97->flags & AC97_CX_SPDIF) { in snd_ac97_spdif_default_put()
780 change |= snd_ac97_update_bits_nolock(ac97, AC97_CXR_AUDIO_MISC, in snd_ac97_spdif_default_put()
783 } else if (ac97->id == AC97_ID_YMF743) { in snd_ac97_spdif_default_put()
784 change |= snd_ac97_update_bits_nolock(ac97, in snd_ac97_spdif_default_put()
790 unsigned short extst = snd_ac97_read_cache(ac97, AC97_EXTENDED_STATUS); in snd_ac97_spdif_default_put()
791 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */ in snd_ac97_spdif_default_put()
793 change |= snd_ac97_update_bits_nolock(ac97, AC97_SPDIF, 0x3fff, val); in snd_ac97_spdif_default_put()
795 …snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on … in snd_ac97_spdif_default_put()
798 mutex_unlock(&ac97->reg_mutex); in snd_ac97_spdif_default_put()
805 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_put_spsa() local
815 mutex_lock(&ac97->reg_mutex); in snd_ac97_put_spsa()
818 old = snd_ac97_read_cache(ac97, reg); in snd_ac97_put_spsa()
823 unsigned short extst = snd_ac97_read_cache(ac97, AC97_EXTENDED_STATUS); in snd_ac97_put_spsa()
824 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */ in snd_ac97_put_spsa()
825 change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); in snd_ac97_put_spsa()
827 …snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on … in snd_ac97_put_spsa()
829 mutex_unlock(&ac97->reg_mutex); in snd_ac97_put_spsa()
874 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_info_bits() local
880 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) in snd_ac97_ad18xx_pcm_info_bits()
891 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_get_bits() local
897 ucontrol->value.integer.value[0] = mask - ((ac97->spec.ad18xx.pcmreg[codec] >> lshift) & mask); in snd_ac97_ad18xx_pcm_get_bits()
898 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) in snd_ac97_ad18xx_pcm_get_bits()
899 ucontrol->value.integer.value[1] = mask - ((ac97->spec.ad18xx.pcmreg[codec] >> rshift) & mask); in snd_ac97_ad18xx_pcm_get_bits()
905 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_put_bits() local
914 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_ad18xx_pcm_put_bits()
918 return snd_ac97_ad18xx_update_pcm_bits(ac97, codec, valmask, val); in snd_ac97_ad18xx_pcm_put_bits()
937 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_get_volume() local
940 mutex_lock(&ac97->page_mutex); in snd_ac97_ad18xx_pcm_get_volume()
941 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); in snd_ac97_ad18xx_pcm_get_volume()
942 ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); in snd_ac97_ad18xx_pcm_get_volume()
943 mutex_unlock(&ac97->page_mutex); in snd_ac97_ad18xx_pcm_get_volume()
949 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_put_volume() local
955 return snd_ac97_ad18xx_update_pcm_bits(ac97, codec, 0x1f1f, (val1 << 8) | val2); in snd_ac97_ad18xx_pcm_put_volume()
982 static void snd_ac97_powerdown(struct snd_ac97 *ac97);
1002 static int snd_ac97_free(struct snd_ac97 *ac97) in snd_ac97_free() argument
1004 if (ac97) { in snd_ac97_free()
1006 cancel_delayed_work_sync(&ac97->power_work); in snd_ac97_free()
1008 snd_ac97_proc_done(ac97); in snd_ac97_free()
1009 if (ac97->bus) in snd_ac97_free()
1010 ac97->bus->codec[ac97->num] = NULL; in snd_ac97_free()
1011 if (ac97->private_free) in snd_ac97_free()
1012 ac97->private_free(ac97); in snd_ac97_free()
1013 kfree(ac97); in snd_ac97_free()
1020 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_free() local
1021 snd_ac97_powerdown(ac97); /* for avoiding click noises during shut down */ in snd_ac97_dev_free()
1022 return snd_ac97_free(ac97); in snd_ac97_dev_free()
1025 static int snd_ac97_try_volume_mix(struct snd_ac97 * ac97, int reg) in snd_ac97_try_volume_mix() argument
1029 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_try_volume_mix()
1034 return ac97->caps & AC97_BC_BASS_TREBLE ? 1 : 0; in snd_ac97_try_volume_mix()
1036 return ac97->caps & AC97_BC_HEADPHONE ? 1 : 0; in snd_ac97_try_volume_mix()
1038 return ac97->caps & AC97_BC_DEDICATED_MIC ? 1 : 0; in snd_ac97_try_volume_mix()
1040 if (ac97->caps & AC97_BC_3D_TECH_ID_MASK) { in snd_ac97_try_volume_mix()
1041 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1047 if ((ac97->ext_id & AC97_EI_CDAC) == 0) in snd_ac97_try_volume_mix()
1051 if ((ac97->ext_id & AC97_EI_LDAC) == 0) in snd_ac97_try_volume_mix()
1057 if ((ac97->ext_id & AC97_EI_SDAC) == 0) in snd_ac97_try_volume_mix()
1062 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1066 snd_ac97_write_cache(ac97, reg, val | mask); in snd_ac97_try_volume_mix()
1067 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1068 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1075 static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned char *lo_max, unsigned… in check_volume_resolution() argument
1082 if (ac97->res_table) { in check_volume_resolution()
1084 for (tbl = ac97->res_table; tbl->reg; tbl++) { in check_volume_resolution()
1097 ac97, reg, in check_volume_resolution()
1104 val = snd_ac97_read(ac97, reg); in check_volume_resolution()
1105 val = snd_ac97_read(ac97, reg); in check_volume_resolution()
1115 static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) in snd_ac97_try_bit() argument
1120 orig = snd_ac97_read(ac97, reg); in snd_ac97_try_bit()
1122 snd_ac97_write(ac97, reg, val); in snd_ac97_try_bit()
1123 res = snd_ac97_read(ac97, reg); in snd_ac97_try_bit()
1124 snd_ac97_write_cache(ac97, reg, orig); in snd_ac97_try_bit()
1129 static void snd_ac97_change_volume_params2(struct snd_ac97 * ac97, int reg, int shift, unsigned cha… in snd_ac97_change_volume_params2() argument
1135 snd_ac97_write(ac97, reg, val); in snd_ac97_change_volume_params2()
1136 val1 = snd_ac97_read(ac97, reg); in snd_ac97_change_volume_params2()
1141 snd_ac97_write_cache(ac97, reg, AC97_MUTE_MASK_STEREO); in snd_ac97_change_volume_params2()
1156 struct snd_ac97 * ac97) in snd_ac97_cnew() argument
1160 template.index = ac97->num; in snd_ac97_cnew()
1161 return snd_ctl_new1(&template, ac97); in snd_ac97_cnew()
1169 struct snd_ac97 *ac97) in snd_ac97_cmute_new_stereo() argument
1175 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_cmute_new_stereo()
1179 val = snd_ac97_read(ac97, reg); in snd_ac97_cmute_new_stereo()
1180 if (check_stereo || (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_cmute_new_stereo()
1183 snd_ac97_write(ac97, reg, val1); in snd_ac97_cmute_new_stereo()
1184 if (val1 == snd_ac97_read(ac97, reg)) in snd_ac97_cmute_new_stereo()
1191 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1192 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cmute_new_stereo()
1197 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1198 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cmute_new_stereo()
1204 snd_ac97_write_cache(ac97, reg, val | mute_mask); in snd_ac97_cmute_new_stereo()
1238 unsigned int hi_max, struct snd_ac97 *ac97) in snd_ac97_cvol_new() argument
1243 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_cvol_new()
1248 tmp.index = ac97->num; in snd_ac97_cvol_new()
1249 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cvol_new()
1253 tmp.index = ac97->num; in snd_ac97_cvol_new()
1254 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cvol_new()
1266 ac97, reg, in snd_ac97_cvol_new()
1267 (snd_ac97_read(ac97, reg) & AC97_MUTE_MASK_STEREO) in snd_ac97_cvol_new()
1278 struct snd_ac97 *ac97) in snd_ac97_cmix_new_stereo() argument
1284 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_cmix_new_stereo()
1287 if (snd_ac97_try_bit(ac97, reg, 15)) { in snd_ac97_cmix_new_stereo()
1291 ac97); in snd_ac97_cmix_new_stereo()
1295 check_volume_resolution(ac97, reg, &lo_max, &hi_max); in snd_ac97_cmix_new_stereo()
1298 err = snd_ac97_cvol_new(card, name, reg, lo_max, hi_max, ac97); in snd_ac97_cmix_new_stereo()
1305 #define snd_ac97_cmix_new(card, pfx, reg, acheck, ac97) \ argument
1306 snd_ac97_cmix_new_stereo(card, pfx, reg, 0, acheck, ac97)
1307 #define snd_ac97_cmute_new(card, name, reg, acheck, ac97) \ argument
1308 snd_ac97_cmute_new_stereo(card, name, reg, 0, acheck, ac97)
1310 static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97);
1312 static int snd_ac97_mixer_build(struct snd_ac97 * ac97) in snd_ac97_mixer_build() argument
1314 struct snd_card *card = ac97->bus->card; in snd_ac97_mixer_build()
1322 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER)) { in snd_ac97_mixer_build()
1323 if (ac97->flags & AC97_HAS_NO_MASTER_VOL) in snd_ac97_mixer_build()
1325 AC97_MASTER, 0, ac97); in snd_ac97_mixer_build()
1328 AC97_MASTER, 0, ac97); in snd_ac97_mixer_build()
1333 ac97->regs[AC97_CENTER_LFE_MASTER] = AC97_MUTE_MASK_STEREO; in snd_ac97_mixer_build()
1336 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER)) in snd_ac97_mixer_build()
1337 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1338 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_center[0], ac97)); in snd_ac97_mixer_build()
1341 err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_center[1], ac97)); in snd_ac97_mixer_build()
1344 snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 0, &max); in snd_ac97_mixer_build()
1348 snd_ac97_write_cache(ac97, AC97_CENTER_LFE_MASTER, ac97->regs[AC97_CENTER_LFE_MASTER] | max); in snd_ac97_mixer_build()
1352 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER+1)) in snd_ac97_mixer_build()
1353 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1354 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_lfe[0], ac97)); in snd_ac97_mixer_build()
1357 err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_lfe[1], ac97)); in snd_ac97_mixer_build()
1360 snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 8, &max); in snd_ac97_mixer_build()
1364 snd_ac97_write_cache(ac97, AC97_CENTER_LFE_MASTER, ac97->regs[AC97_CENTER_LFE_MASTER] | max << 8); in snd_ac97_mixer_build()
1368 if ((snd_ac97_try_volume_mix(ac97, AC97_SURROUND_MASTER)) in snd_ac97_mixer_build()
1369 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1373 ac97); in snd_ac97_mixer_build()
1379 if (snd_ac97_try_volume_mix(ac97, AC97_HEADPHONE)) { in snd_ac97_mixer_build()
1381 AC97_HEADPHONE, 0, ac97); in snd_ac97_mixer_build()
1387 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_MONO)) { in snd_ac97_mixer_build()
1389 AC97_MASTER_MONO, 0, ac97); in snd_ac97_mixer_build()
1395 if (!(ac97->flags & AC97_HAS_NO_TONE)) { in snd_ac97_mixer_build()
1396 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_TONE)) { in snd_ac97_mixer_build()
1398 kctl = snd_ac97_cnew(&snd_ac97_controls_tone[idx], ac97); in snd_ac97_mixer_build()
1402 if (ac97->id == AC97_ID_YMF743 || in snd_ac97_mixer_build()
1403 ac97->id == AC97_ID_YMF753) { in snd_ac97_mixer_build()
1408 snd_ac97_write_cache(ac97, AC97_MASTER_TONE, 0x0f0f); in snd_ac97_mixer_build()
1413 if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && in snd_ac97_mixer_build()
1414 ((ac97->flags & AC97_HAS_PC_BEEP) || in snd_ac97_mixer_build()
1415 snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) { in snd_ac97_mixer_build()
1417 kctl = snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97); in snd_ac97_mixer_build()
1424 ac97, in snd_ac97_mixer_build()
1426 (snd_ac97_read(ac97, AC97_PC_BEEP) in snd_ac97_mixer_build()
1432 if (!(ac97->flags & AC97_HAS_NO_PHONE)) { in snd_ac97_mixer_build()
1433 if (snd_ac97_try_volume_mix(ac97, AC97_PHONE)) { in snd_ac97_mixer_build()
1435 AC97_PHONE, 1, ac97); in snd_ac97_mixer_build()
1442 if (!(ac97->flags & AC97_HAS_NO_MIC)) { in snd_ac97_mixer_build()
1443 if (snd_ac97_try_volume_mix(ac97, AC97_MIC)) { in snd_ac97_mixer_build()
1445 AC97_MIC, 1, ac97); in snd_ac97_mixer_build()
1448 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_boost, ac97)); in snd_ac97_mixer_build()
1455 if (snd_ac97_try_volume_mix(ac97, AC97_LINE)) { in snd_ac97_mixer_build()
1457 AC97_LINE, 1, ac97); in snd_ac97_mixer_build()
1463 if (!(ac97->flags & AC97_HAS_NO_CD)) { in snd_ac97_mixer_build()
1464 if (snd_ac97_try_volume_mix(ac97, AC97_CD)) { in snd_ac97_mixer_build()
1466 AC97_CD, 1, ac97); in snd_ac97_mixer_build()
1473 if (!(ac97->flags & AC97_HAS_NO_VIDEO)) { in snd_ac97_mixer_build()
1474 if (snd_ac97_try_volume_mix(ac97, AC97_VIDEO)) { in snd_ac97_mixer_build()
1476 AC97_VIDEO, 1, ac97); in snd_ac97_mixer_build()
1483 if (!(ac97->flags & AC97_HAS_NO_AUX)) { in snd_ac97_mixer_build()
1484 if (snd_ac97_try_volume_mix(ac97, AC97_AUX)) { in snd_ac97_mixer_build()
1486 AC97_AUX, 1, ac97); in snd_ac97_mixer_build()
1493 if (ac97->flags & AC97_AD_MULTI) { in snd_ac97_mixer_build()
1495 if (ac97->flags & AC97_STEREO_MUTES) in snd_ac97_mixer_build()
1500 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_pcm[idx], ac97); in snd_ac97_mixer_build()
1506 ac97->spec.ad18xx.pcmreg[0] = init_val; in snd_ac97_mixer_build()
1507 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) { in snd_ac97_mixer_build()
1509 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_surround[idx], ac97); in snd_ac97_mixer_build()
1515 ac97->spec.ad18xx.pcmreg[1] = init_val; in snd_ac97_mixer_build()
1517 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) { in snd_ac97_mixer_build()
1519 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_center[idx], ac97); in snd_ac97_mixer_build()
1526 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_lfe[idx], ac97); in snd_ac97_mixer_build()
1532 ac97->spec.ad18xx.pcmreg[2] = init_val; in snd_ac97_mixer_build()
1534 snd_ac97_write_cache(ac97, AC97_PCM, init_val); in snd_ac97_mixer_build()
1536 if (!(ac97->flags & AC97_HAS_NO_STD_PCM)) { in snd_ac97_mixer_build()
1537 if (ac97->flags & AC97_HAS_NO_PCM_VOL) in snd_ac97_mixer_build()
1540 AC97_PCM, 0, ac97); in snd_ac97_mixer_build()
1543 AC97_PCM, 0, ac97); in snd_ac97_mixer_build()
1550 if (!(ac97->flags & AC97_HAS_NO_REC_GAIN)) { in snd_ac97_mixer_build()
1551 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_src, ac97)); in snd_ac97_mixer_build()
1554 if (snd_ac97_try_bit(ac97, AC97_REC_GAIN, 15)) { in snd_ac97_mixer_build()
1556 AC97_REC_GAIN, 0, ac97); in snd_ac97_mixer_build()
1560 kctl = snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97); in snd_ac97_mixer_build()
1565 snd_ac97_write_cache(ac97, AC97_REC_SEL, 0x0000); in snd_ac97_mixer_build()
1566 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x0000); in snd_ac97_mixer_build()
1569 if (snd_ac97_try_volume_mix(ac97, AC97_REC_GAIN_MIC)) { in snd_ac97_mixer_build()
1571 kctl = snd_ac97_cnew(&snd_ac97_controls_mic_capture[idx], ac97); in snd_ac97_mixer_build()
1577 snd_ac97_write_cache(ac97, AC97_REC_GAIN_MIC, 0x0000); in snd_ac97_mixer_build()
1581 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 15)) { in snd_ac97_mixer_build()
1582 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_PCM_OUT], ac97)); in snd_ac97_mixer_build()
1588 if (ac97->caps & AC97_BC_SIM_STEREO) { in snd_ac97_mixer_build()
1589 …nd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT], ac97)); in snd_ac97_mixer_build()
1595 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 13)) { in snd_ac97_mixer_build()
1596 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_3D], ac97)); in snd_ac97_mixer_build()
1602 if (ac97->caps & AC97_BC_LOUDNESS) { in snd_ac97_mixer_build()
1603 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS], ac97)); in snd_ac97_mixer_build()
1609 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 9)) { in snd_ac97_mixer_build()
1610 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MONO], ac97)); in snd_ac97_mixer_build()
1616 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 8)) { in snd_ac97_mixer_build()
1617 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MIC], ac97)); in snd_ac97_mixer_build()
1623 if (enable_loopback && snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 7)) { in snd_ac97_mixer_build()
1624 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOOPBACK], ac97)); in snd_ac97_mixer_build()
1629 snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, ~AC97_GP_DRSS_MASK, 0x0000); in snd_ac97_mixer_build()
1632 if (ac97->build_ops->build_3d) { in snd_ac97_mixer_build()
1633 ac97->build_ops->build_3d(ac97); in snd_ac97_mixer_build()
1635 if (snd_ac97_try_volume_mix(ac97, AC97_3D_CONTROL)) { in snd_ac97_mixer_build()
1638 snd_ac97_write(ac97, AC97_3D_CONTROL, val); in snd_ac97_mixer_build()
1639 val = snd_ac97_read(ac97, AC97_3D_CONTROL); in snd_ac97_mixer_build()
1641 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); in snd_ac97_mixer_build()
1647 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[1], ac97); in snd_ac97_mixer_build()
1653 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); in snd_ac97_mixer_build()
1660 if (ac97->subsystem_vendor == 0x1043 && in snd_ac97_mixer_build()
1661 ac97->subsystem_device == 0x810f) in snd_ac97_mixer_build()
1662 ac97->ext_id |= AC97_EI_SPDIF; in snd_ac97_mixer_build()
1664 if ((ac97->ext_id & AC97_EI_SPDIF) && !(ac97->scaps & AC97_SCAP_NO_SPDIF)) { in snd_ac97_mixer_build()
1665 if (ac97->build_ops->build_spdif) { in snd_ac97_mixer_build()
1666 err = ac97->build_ops->build_spdif(ac97); in snd_ac97_mixer_build()
1671 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_spdif[idx], ac97)); in snd_ac97_mixer_build()
1675 if (ac97->build_ops->build_post_spdif) { in snd_ac97_mixer_build()
1676 err = ac97->build_ops->build_post_spdif(ac97); in snd_ac97_mixer_build()
1682 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x2a20); in snd_ac97_mixer_build()
1683 ac97->rates[AC97_RATES_SPDIF] = snd_ac97_determine_spdif_rates(ac97); in snd_ac97_mixer_build()
1685 ac97->spdif_status = SNDRV_PCM_DEFAULT_CON_SPDIF; in snd_ac97_mixer_build()
1689 if (ac97->build_ops->build_specific) { in snd_ac97_mixer_build()
1690 err = ac97->build_ops->build_specific(ac97); in snd_ac97_mixer_build()
1695 if (snd_ac97_try_bit(ac97, AC97_POWERDOWN, 15)) { in snd_ac97_mixer_build()
1696 kctl = snd_ac97_cnew(&snd_ac97_control_eapd, ac97); in snd_ac97_mixer_build()
1699 if (ac97->scaps & AC97_SCAP_INV_EAPD) in snd_ac97_mixer_build()
1700 set_inv_eapd(ac97, kctl); in snd_ac97_mixer_build()
1709 static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97) in snd_ac97_modem_build() argument
1717 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); in snd_ac97_modem_build()
1718 snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH)); in snd_ac97_modem_build()
1719 snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff); in snd_ac97_modem_build()
1720 snd_ac97_write(ac97, AC97_GPIO_WAKEUP, 0x0); in snd_ac97_modem_build()
1721 snd_ac97_write(ac97, AC97_MISC_AFE, 0x0); in snd_ac97_modem_build()
1725 err = snd_ctl_add(card, snd_ctl_new1(&snd_ac97_controls_modem_switches[idx], ac97)); in snd_ac97_modem_build()
1731 if (ac97->build_ops->build_specific) { in snd_ac97_modem_build()
1732 err = ac97->build_ops->build_specific(ac97); in snd_ac97_modem_build()
1740 static int snd_ac97_test_rate(struct snd_ac97 *ac97, int reg, int shadow_reg, int rate) in snd_ac97_test_rate() argument
1745 tmp = ((unsigned int)rate * ac97->bus->clock) / 48000; in snd_ac97_test_rate()
1746 snd_ac97_write_cache(ac97, reg, tmp & 0xffff); in snd_ac97_test_rate()
1748 snd_ac97_write_cache(ac97, shadow_reg, tmp & 0xffff); in snd_ac97_test_rate()
1749 val = snd_ac97_read(ac97, reg); in snd_ac97_test_rate()
1753 static void snd_ac97_determine_rates(struct snd_ac97 *ac97, int reg, int shadow_reg, unsigned int *… in snd_ac97_determine_rates() argument
1758 if (ac97->bus->no_vra) { in snd_ac97_determine_rates()
1760 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1766 saved = snd_ac97_read(ac97, reg); in snd_ac97_determine_rates()
1767 if ((ac97->ext_id & AC97_EI_DRA) && reg == AC97_PCM_FRONT_DAC_RATE) in snd_ac97_determine_rates()
1768 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, in snd_ac97_determine_rates()
1771 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 11000)) in snd_ac97_determine_rates()
1774 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 8000)) in snd_ac97_determine_rates()
1776 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 11025)) in snd_ac97_determine_rates()
1778 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 16000)) in snd_ac97_determine_rates()
1780 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 22050)) in snd_ac97_determine_rates()
1782 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 32000)) in snd_ac97_determine_rates()
1784 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 44100)) in snd_ac97_determine_rates()
1786 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 48000)) in snd_ac97_determine_rates()
1788 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1791 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, in snd_ac97_determine_rates()
1793 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 64000 / 2)) in snd_ac97_determine_rates()
1795 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 88200 / 2)) in snd_ac97_determine_rates()
1797 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 96000 / 2)) in snd_ac97_determine_rates()
1800 if (!snd_ac97_test_rate(ac97, reg, shadow_reg, 76100 / 2)) in snd_ac97_determine_rates()
1802 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, in snd_ac97_determine_rates()
1806 snd_ac97_write_cache(ac97, reg, saved); in snd_ac97_determine_rates()
1808 snd_ac97_write_cache(ac97, shadow_reg, saved); in snd_ac97_determine_rates()
1813 static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97) in snd_ac97_determine_spdif_rates() argument
1825 snd_ac97_update_bits(ac97, AC97_SPDIF, AC97_SC_SPSR_MASK, ctl_bits[i]); in snd_ac97_determine_spdif_rates()
1826 if ((snd_ac97_read(ac97, AC97_SPDIF) & AC97_SC_SPSR_MASK) == ctl_bits[i]) in snd_ac97_determine_spdif_rates()
1844 void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem) in snd_ac97_get_name() argument
1857 if (ac97 && pid->patch) { in snd_ac97_get_name()
1860 pid->patch(ac97); in snd_ac97_get_name()
1869 if (ac97 && pid->patch) { in snd_ac97_get_name()
1872 pid->patch(ac97); in snd_ac97_get_name()
1884 const char *snd_ac97_get_short_name(struct snd_ac97 *ac97) in snd_ac97_get_short_name() argument
1889 if (pid->id == (ac97->id & pid->mask)) in snd_ac97_get_short_name()
1899 static int ac97_reset_wait(struct snd_ac97 *ac97, int timeout, int with_modem) in ac97_reset_wait() argument
1908 snd_ac97_read(ac97, AC97_RESET); in ac97_reset_wait()
1909 snd_ac97_read(ac97, AC97_VENDOR_ID1); in ac97_reset_wait()
1910 snd_ac97_read(ac97, AC97_VENDOR_ID2); in ac97_reset_wait()
1913 val = snd_ac97_read(ac97, AC97_EXTENDED_MID); in ac97_reset_wait()
1917 if (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) { in ac97_reset_wait()
1919 val = snd_ac97_read(ac97, AC97_VENDOR_ID1); in ac97_reset_wait()
1927 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05); in ac97_reset_wait()
1928 if ((snd_ac97_read(ac97, AC97_REC_GAIN) & 0x7fff) == 0x0a05) in ac97_reset_wait()
2000 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_register() local
2003 ac97->dev.bus = &ac97_bus_type; in snd_ac97_dev_register()
2004 ac97->dev.parent = ac97->bus->card->dev; in snd_ac97_dev_register()
2005 ac97->dev.release = ac97_device_release; in snd_ac97_dev_register()
2006 dev_set_name(&ac97->dev, "%d-%d:%s", in snd_ac97_dev_register()
2007 ac97->bus->card->number, ac97->num, in snd_ac97_dev_register()
2008 snd_ac97_get_short_name(ac97)); in snd_ac97_dev_register()
2009 err = device_register(&ac97->dev); in snd_ac97_dev_register()
2011 ac97_err(ac97, "Can't register ac97 bus\n"); in snd_ac97_dev_register()
2012 put_device(&ac97->dev); in snd_ac97_dev_register()
2013 ac97->dev.bus = NULL; in snd_ac97_dev_register()
2022 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_disconnect() local
2023 if (ac97->dev.bus) in snd_ac97_dev_disconnect()
2024 device_unregister(&ac97->dev); in snd_ac97_dev_disconnect()
2061 struct snd_ac97 *ac97; in snd_ac97_mixer() local
2083 ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL); in snd_ac97_mixer()
2084 if (ac97 == NULL) in snd_ac97_mixer()
2086 ac97->private_data = template->private_data; in snd_ac97_mixer()
2087 ac97->private_free = template->private_free; in snd_ac97_mixer()
2088 ac97->bus = bus; in snd_ac97_mixer()
2089 ac97->pci = template->pci; in snd_ac97_mixer()
2090 ac97->num = template->num; in snd_ac97_mixer()
2091 ac97->addr = template->addr; in snd_ac97_mixer()
2092 ac97->scaps = template->scaps; in snd_ac97_mixer()
2093 ac97->res_table = template->res_table; in snd_ac97_mixer()
2094 bus->codec[ac97->num] = ac97; in snd_ac97_mixer()
2095 mutex_init(&ac97->reg_mutex); in snd_ac97_mixer()
2096 mutex_init(&ac97->page_mutex); in snd_ac97_mixer()
2098 INIT_DELAYED_WORK(&ac97->power_work, do_update_power); in snd_ac97_mixer()
2102 if (ac97->pci) { in snd_ac97_mixer()
2103 pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_VENDOR_ID, &ac97->subsystem_vendor); in snd_ac97_mixer()
2104 pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_ID, &ac97->subsystem_device); in snd_ac97_mixer()
2108 bus->ops->reset(ac97); in snd_ac97_mixer()
2112 ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16; in snd_ac97_mixer()
2113 ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2); in snd_ac97_mixer()
2114 if (ac97->id && ac97->id != (unsigned int)-1) { in snd_ac97_mixer()
2115 pid = look_for_codec_id(snd_ac97_codec_ids, ac97->id); in snd_ac97_mixer()
2121 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) in snd_ac97_mixer()
2122 snd_ac97_write(ac97, AC97_RESET, 0); in snd_ac97_mixer()
2123 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_mixer()
2124 snd_ac97_write(ac97, AC97_EXTENDED_MID, 0); in snd_ac97_mixer()
2126 bus->ops->wait(ac97); in snd_ac97_mixer()
2129 if (ac97->scaps & AC97_SCAP_SKIP_AUDIO) in snd_ac97_mixer()
2130 err = ac97_reset_wait(ac97, msecs_to_jiffies(500), 1); in snd_ac97_mixer()
2132 err = ac97_reset_wait(ac97, msecs_to_jiffies(500), 0); in snd_ac97_mixer()
2134 err = ac97_reset_wait(ac97, in snd_ac97_mixer()
2138 ac97_warn(ac97, "AC'97 %d does not respond - RESET\n", in snd_ac97_mixer()
2139 ac97->num); in snd_ac97_mixer()
2144 ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16; in snd_ac97_mixer()
2145 ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2); in snd_ac97_mixer()
2146 if (! (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) && in snd_ac97_mixer()
2147 (ac97->id == 0x00000000 || ac97->id == 0xffffffff)) { in snd_ac97_mixer()
2148 ac97_err(ac97, in snd_ac97_mixer()
2150 ac97->num, ac97->id); in snd_ac97_mixer()
2151 snd_ac97_free(ac97); in snd_ac97_mixer()
2154 pid = look_for_codec_id(snd_ac97_codec_ids, ac97->id); in snd_ac97_mixer()
2156 ac97->flags |= pid->flags; in snd_ac97_mixer()
2159 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO) && !(ac97->scaps & AC97_SCAP_AUDIO)) { in snd_ac97_mixer()
2161 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a06); in snd_ac97_mixer()
2162 err = snd_ac97_read(ac97, AC97_REC_GAIN); in snd_ac97_mixer()
2164 ac97->scaps |= AC97_SCAP_AUDIO; in snd_ac97_mixer()
2166 if (ac97->scaps & AC97_SCAP_AUDIO) { in snd_ac97_mixer()
2167 ac97->caps = snd_ac97_read(ac97, AC97_RESET); in snd_ac97_mixer()
2168 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID); in snd_ac97_mixer()
2169 if (ac97->ext_id == 0xffff) /* invalid combination */ in snd_ac97_mixer()
2170 ac97->ext_id = 0; in snd_ac97_mixer()
2174 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM) && !(ac97->scaps & AC97_SCAP_MODEM)) { in snd_ac97_mixer()
2175 ac97->ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID); in snd_ac97_mixer()
2176 if (ac97->ext_mid == 0xffff) /* invalid combination */ in snd_ac97_mixer()
2177 ac97->ext_mid = 0; in snd_ac97_mixer()
2178 if (ac97->ext_mid & 1) in snd_ac97_mixer()
2179 ac97->scaps |= AC97_SCAP_MODEM; in snd_ac97_mixer()
2182 if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) { in snd_ac97_mixer()
2183 if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM))) in snd_ac97_mixer()
2184 ac97_err(ac97, in snd_ac97_mixer()
2186 ac97->num); in snd_ac97_mixer()
2187 snd_ac97_free(ac97); in snd_ac97_mixer()
2195 if (ac97_is_audio(ac97)) { in snd_ac97_mixer()
2197 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0); in snd_ac97_mixer()
2198 if (! (ac97->flags & AC97_DEFAULT_POWER_OFF)) { in snd_ac97_mixer()
2199 snd_ac97_write_cache(ac97, AC97_RESET, 0); /* reset to defaults */ in snd_ac97_mixer()
2201 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0); in snd_ac97_mixer()
2204 snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0); in snd_ac97_mixer()
2207 if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f) in snd_ac97_mixer()
2211 ac97_warn(ac97, in snd_ac97_mixer()
2212 "AC'97 %d analog subsections not ready\n", ac97->num); in snd_ac97_mixer()
2216 if (ac97_is_modem(ac97)) { in snd_ac97_mixer()
2222 if (ac97->ext_mid & AC97_MEI_LINE1) { in snd_ac97_mixer()
2223 snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 8000); in snd_ac97_mixer()
2226 if (ac97->ext_mid & AC97_MEI_LINE2) { in snd_ac97_mixer()
2227 snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 8000); in snd_ac97_mixer()
2230 if (ac97->ext_mid & AC97_MEI_HANDSET) { in snd_ac97_mixer()
2231 snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 8000); in snd_ac97_mixer()
2234 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0); in snd_ac97_mixer()
2237 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0); in snd_ac97_mixer()
2240 if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp) in snd_ac97_mixer()
2244 ac97_warn(ac97, in snd_ac97_mixer()
2246 ac97->num, in snd_ac97_mixer()
2247 snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS)); in snd_ac97_mixer()
2251 if (ac97_is_audio(ac97)) in snd_ac97_mixer()
2252 ac97->addr = (ac97->ext_id & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT; in snd_ac97_mixer()
2254 ac97->addr = (ac97->ext_mid & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT; in snd_ac97_mixer()
2255 if (ac97->ext_id & 0x01c9) { /* L/R, MIC, SDAC, LDAC VRA support */ in snd_ac97_mixer()
2256 reg = snd_ac97_read(ac97, AC97_EXTENDED_STATUS); in snd_ac97_mixer()
2257 reg |= ac97->ext_id & 0x01c0; /* LDAC/SDAC/CDAC */ in snd_ac97_mixer()
2259 reg |= ac97->ext_id & 0x0009; /* VRA/VRM */ in snd_ac97_mixer()
2260 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, reg); in snd_ac97_mixer()
2262 if ((ac97->ext_id & AC97_EI_DRA) && bus->dra) { in snd_ac97_mixer()
2265 snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, AC97_GP_DRSS_MASK, AC97_GP_DRSS_78); in snd_ac97_mixer()
2266 if ((snd_ac97_read(ac97, AC97_GENERAL_PURPOSE) & AC97_GP_DRSS_MASK) == AC97_GP_DRSS_78) in snd_ac97_mixer()
2267 ac97->flags |= AC97_DOUBLE_RATE; in snd_ac97_mixer()
2269 snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, AC97_GP_DRSS_MASK, 0); in snd_ac97_mixer()
2271 if (ac97->ext_id & AC97_EI_VRA) { /* VRA support */ in snd_ac97_mixer()
2272 snd_ac97_determine_rates(ac97, AC97_PCM_FRONT_DAC_RATE, 0, &ac97->rates[AC97_RATES_FRONT_DAC]); in snd_ac97_mixer()
2273 snd_ac97_determine_rates(ac97, AC97_PCM_LR_ADC_RATE, 0, &ac97->rates[AC97_RATES_ADC]); in snd_ac97_mixer()
2275 ac97->rates[AC97_RATES_FRONT_DAC] = SNDRV_PCM_RATE_48000; in snd_ac97_mixer()
2276 if (ac97->flags & AC97_DOUBLE_RATE) in snd_ac97_mixer()
2277 ac97->rates[AC97_RATES_FRONT_DAC] |= SNDRV_PCM_RATE_96000; in snd_ac97_mixer()
2278 ac97->rates[AC97_RATES_ADC] = SNDRV_PCM_RATE_48000; in snd_ac97_mixer()
2280 if (ac97->ext_id & AC97_EI_SPDIF) { in snd_ac97_mixer()
2282ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_32000; in snd_ac97_mixer()
2284 if (ac97->ext_id & AC97_EI_VRM) { /* MIC VRA support */ in snd_ac97_mixer()
2285 snd_ac97_determine_rates(ac97, AC97_PCM_MIC_ADC_RATE, 0, &ac97->rates[AC97_RATES_MIC_ADC]); in snd_ac97_mixer()
2287 ac97->rates[AC97_RATES_MIC_ADC] = SNDRV_PCM_RATE_48000; in snd_ac97_mixer()
2289 if (ac97->ext_id & AC97_EI_SDAC) { /* SDAC support */ in snd_ac97_mixer()
2290 …snd_ac97_determine_rates(ac97, AC97_PCM_SURR_DAC_RATE, AC97_PCM_FRONT_DAC_RATE, &ac97->rates[AC97_… in snd_ac97_mixer()
2291 ac97->scaps |= AC97_SCAP_SURROUND_DAC; in snd_ac97_mixer()
2293 if (ac97->ext_id & AC97_EI_LDAC) { /* LDAC support */ in snd_ac97_mixer()
2294 …snd_ac97_determine_rates(ac97, AC97_PCM_LFE_DAC_RATE, AC97_PCM_FRONT_DAC_RATE, &ac97->rates[AC97_R… in snd_ac97_mixer()
2295 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC; in snd_ac97_mixer()
2299 bus->ops->init(ac97); in snd_ac97_mixer()
2300 snd_ac97_get_name(ac97, ac97->id, name, !ac97_is_audio(ac97)); in snd_ac97_mixer()
2301 …snd_ac97_get_name(NULL, ac97->id, name, !ac97_is_audio(ac97)); // ac97->id might be changed in th… in snd_ac97_mixer()
2302 if (! ac97->build_ops) in snd_ac97_mixer()
2303 ac97->build_ops = &null_build_ops; in snd_ac97_mixer()
2305 if (ac97_is_audio(ac97)) { in snd_ac97_mixer()
2315 sprintf(comp, "AC97a:%08x", ac97->id); in snd_ac97_mixer()
2318 snd_ac97_free(ac97); in snd_ac97_mixer()
2321 if (snd_ac97_mixer_build(ac97) < 0) { in snd_ac97_mixer()
2322 snd_ac97_free(ac97); in snd_ac97_mixer()
2326 if (ac97_is_modem(ac97)) { in snd_ac97_mixer()
2336 sprintf(comp, "AC97m:%08x", ac97->id); in snd_ac97_mixer()
2339 snd_ac97_free(ac97); in snd_ac97_mixer()
2342 if (snd_ac97_modem_build(card, ac97) < 0) { in snd_ac97_mixer()
2343 snd_ac97_free(ac97); in snd_ac97_mixer()
2347 if (ac97_is_audio(ac97)) in snd_ac97_mixer()
2348 update_power_regs(ac97); in snd_ac97_mixer()
2349 snd_ac97_proc_init(ac97); in snd_ac97_mixer()
2350 err = snd_device_new(card, SNDRV_DEV_CODEC, ac97, &ops); in snd_ac97_mixer()
2352 snd_ac97_free(ac97); in snd_ac97_mixer()
2355 *rac97 = ac97; in snd_ac97_mixer()
2367 static void snd_ac97_powerdown(struct snd_ac97 *ac97) in snd_ac97_powerdown() argument
2371 if (ac97_is_audio(ac97)) { in snd_ac97_powerdown()
2373 snd_ac97_write(ac97, AC97_MASTER, 0x9f9f); in snd_ac97_powerdown()
2374 snd_ac97_write(ac97, AC97_HEADPHONE, 0x9f9f); in snd_ac97_powerdown()
2378 power = ac97->regs[AC97_EXTENDED_STATUS]; in snd_ac97_powerdown()
2379 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) in snd_ac97_powerdown()
2381 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) in snd_ac97_powerdown()
2384 snd_ac97_write(ac97, AC97_EXTENDED_STATUS, power); in snd_ac97_powerdown()
2387 if (ac97->scaps & AC97_SCAP_INV_EAPD) in snd_ac97_powerdown()
2388 power = ac97->regs[AC97_POWERDOWN] & ~AC97_PD_EAPD; in snd_ac97_powerdown()
2389 else if (! (ac97->scaps & AC97_SCAP_EAPD_LED)) in snd_ac97_powerdown()
2390 power = ac97->regs[AC97_POWERDOWN] | AC97_PD_EAPD; in snd_ac97_powerdown()
2393 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2396 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2397 if (ac97_is_power_save_mode(ac97)) { in snd_ac97_powerdown()
2399 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2404 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2439 int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup) in snd_ac97_update_power() argument
2443 if (! ac97) in snd_ac97_update_power()
2453 ac97->power_up |= (1 << i); in snd_ac97_update_power()
2455 ac97->power_up &= ~(1 << i); in snd_ac97_update_power()
2461 if (ac97_is_power_save_mode(ac97) && !powerup) in snd_ac97_update_power()
2466 schedule_delayed_work(&ac97->power_work, in snd_ac97_update_power()
2469 cancel_delayed_work(&ac97->power_work); in snd_ac97_update_power()
2470 update_power_regs(ac97); in snd_ac97_update_power()
2479 static void update_power_regs(struct snd_ac97 *ac97) in update_power_regs() argument
2486 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) in update_power_regs()
2488 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) in update_power_regs()
2491 if (ac97_is_power_save_mode(ac97)) in update_power_regs()
2492 power_up = ac97->power_up; in update_power_regs()
2495 if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) { in update_power_regs()
2497 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2500 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2509 snd_ac97_update_bits(ac97, power_regs[i].power_reg, in update_power_regs()
2513 if (! (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2)) { in update_power_regs()
2515 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2517 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2531 void snd_ac97_suspend(struct snd_ac97 *ac97) in snd_ac97_suspend() argument
2533 if (! ac97) in snd_ac97_suspend()
2535 if (ac97->build_ops->suspend) in snd_ac97_suspend()
2536 ac97->build_ops->suspend(ac97); in snd_ac97_suspend()
2538 cancel_delayed_work_sync(&ac97->power_work); in snd_ac97_suspend()
2540 snd_ac97_powerdown(ac97); in snd_ac97_suspend()
2548 static void snd_ac97_restore_status(struct snd_ac97 *ac97) in snd_ac97_restore_status() argument
2559 if (test_bit(i, ac97->reg_accessed)) { in snd_ac97_restore_status()
2560 snd_ac97_write(ac97, i, ac97->regs[i]); in snd_ac97_restore_status()
2561 snd_ac97_read(ac97, i); in snd_ac97_restore_status()
2569 static void snd_ac97_restore_iec958(struct snd_ac97 *ac97) in snd_ac97_restore_iec958() argument
2571 if (ac97->ext_id & AC97_EI_SPDIF) { in snd_ac97_restore_iec958()
2572 if (ac97->regs[AC97_EXTENDED_STATUS] & AC97_EA_SPDIF) { in snd_ac97_restore_iec958()
2574 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); in snd_ac97_restore_iec958()
2575 snd_ac97_write(ac97, AC97_EXTENDED_STATUS, ac97->regs[AC97_EXTENDED_STATUS]); in snd_ac97_restore_iec958()
2576 if (ac97->flags & AC97_CS_SPDIF) in snd_ac97_restore_iec958()
2577 snd_ac97_write(ac97, AC97_CSR_SPDIF, ac97->regs[AC97_CSR_SPDIF]); in snd_ac97_restore_iec958()
2579 snd_ac97_write(ac97, AC97_SPDIF, ac97->regs[AC97_SPDIF]); in snd_ac97_restore_iec958()
2580 …snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ in snd_ac97_restore_iec958()
2592 void snd_ac97_resume(struct snd_ac97 *ac97) in snd_ac97_resume() argument
2596 if (! ac97) in snd_ac97_resume()
2599 if (ac97->bus->ops->reset) { in snd_ac97_resume()
2600 ac97->bus->ops->reset(ac97); in snd_ac97_resume()
2604 snd_ac97_write(ac97, AC97_POWERDOWN, 0); in snd_ac97_resume()
2605 if (! (ac97->flags & AC97_DEFAULT_POWER_OFF)) { in snd_ac97_resume()
2606 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) in snd_ac97_resume()
2607 snd_ac97_write(ac97, AC97_RESET, 0); in snd_ac97_resume()
2608 else if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_resume()
2609 snd_ac97_write(ac97, AC97_EXTENDED_MID, 0); in snd_ac97_resume()
2611 snd_ac97_write(ac97, AC97_POWERDOWN, 0); in snd_ac97_resume()
2613 snd_ac97_write(ac97, AC97_GENERAL_PURPOSE, 0); in snd_ac97_resume()
2615 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]); in snd_ac97_resume()
2616 if (ac97_is_audio(ac97)) { in snd_ac97_resume()
2617 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101); in snd_ac97_resume()
2620 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101) in snd_ac97_resume()
2625 ac97->bus->ops->write(ac97, AC97_MASTER, AC97_MUTE_MASK_MONO); in snd_ac97_resume()
2626 if (snd_ac97_read(ac97, AC97_MASTER) != AC97_MUTE_MASK_MONO) in snd_ac97_resume()
2631 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID); in snd_ac97_resume()
2639 if (ac97->bus->ops->init) in snd_ac97_resume()
2640 ac97->bus->ops->init(ac97); in snd_ac97_resume()
2642 if (ac97->build_ops->resume) in snd_ac97_resume()
2643 ac97->build_ops->resume(ac97); in snd_ac97_resume()
2645 snd_ac97_restore_status(ac97); in snd_ac97_resume()
2646 snd_ac97_restore_iec958(ac97); in snd_ac97_resume()
2673 static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, in snd_ac97_remove_ctl() argument
2680 return snd_ctl_remove_id(ac97->bus->card, &id); in snd_ac97_remove_ctl()
2683 static struct snd_kcontrol *ctl_find(struct snd_ac97 *ac97, const char *name, const char *suffix) in ctl_find() argument
2689 return snd_ctl_find_id(ac97->bus->card, &sid); in ctl_find()
2693 static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, in snd_ac97_rename_ctl() argument
2696 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); in snd_ac97_rename_ctl()
2701 snd_ctl_rename(ac97->bus->card, kctl, name); in snd_ac97_rename_ctl()
2708 static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, in snd_ac97_rename_vol_ctl() argument
2711 snd_ac97_rename_ctl(ac97, src, dst, "Switch"); in snd_ac97_rename_vol_ctl()
2712 snd_ac97_rename_ctl(ac97, src, dst, "Volume"); in snd_ac97_rename_vol_ctl()
2716 static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, in snd_ac97_swap_ctl() argument
2722 kctl1 = ctl_find(ac97, s1, suffix); in snd_ac97_swap_ctl()
2723 kctl2 = ctl_find(ac97, s2, suffix); in snd_ac97_swap_ctl()
2726 snd_ctl_rename(ac97->bus->card, kctl1, name); in snd_ac97_swap_ctl()
2729 snd_ctl_rename(ac97->bus->card, kctl2, name); in snd_ac97_swap_ctl()
2751 static int tune_hp_only(struct snd_ac97 *ac97) in tune_hp_only() argument
2753 struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); in tune_hp_only()
2754 struct snd_kcontrol *mvol = ctl_find(ac97, "Master Playback Volume", NULL); in tune_hp_only()
2759 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch"); in tune_hp_only()
2760 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume"); in tune_hp_only()
2766 static int tune_hp_only(struct snd_ac97 *ac97) in tune_hp_only() argument
2768 if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL) in tune_hp_only()
2770 snd_ac97_remove_ctl(ac97, "Master Playback", "Switch"); in tune_hp_only()
2771 snd_ac97_remove_ctl(ac97, "Master Playback", "Volume"); in tune_hp_only()
2772 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); in tune_hp_only()
2778 static int tune_swap_hp(struct snd_ac97 *ac97) in tune_swap_hp() argument
2780 if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL) in tune_swap_hp()
2782 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Line-Out Playback"); in tune_swap_hp()
2783 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); in tune_swap_hp()
2788 static int tune_swap_surround(struct snd_ac97 *ac97) in tune_swap_surround() argument
2790 if (snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Switch") || in tune_swap_surround()
2791 snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Volume")) in tune_swap_surround()
2797 static int tune_ad_sharing(struct snd_ac97 *ac97) in tune_ad_sharing() argument
2800 if ((ac97->id & 0xffffff00) != 0x41445300) { in tune_ad_sharing()
2801 ac97_err(ac97, "ac97_quirk AD_SHARING is only for AD codecs\n"); in tune_ad_sharing()
2805 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG); in tune_ad_sharing()
2806 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x0200); in tune_ad_sharing()
2814 static int tune_alc_jack(struct snd_ac97 *ac97) in tune_alc_jack() argument
2816 if ((ac97->id & 0xffffff00) != 0x414c4700) { in tune_alc_jack()
2817 ac97_err(ac97, in tune_alc_jack()
2821 snd_ac97_update_bits(ac97, 0x7a, 0x20, 0x20); /* select jack detect function */ in tune_alc_jack()
2822 snd_ac97_update_bits(ac97, 0x7a, 0x01, 0x01); /* Line-out auto mute */ in tune_alc_jack()
2823 if (ac97->id == AC97_ID_ALC658D) in tune_alc_jack()
2824 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800); in tune_alc_jack()
2825 return snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_alc_jack_detect, ac97)); in tune_alc_jack()
2829 static int tune_inv_eapd(struct snd_ac97 *ac97) in tune_inv_eapd() argument
2831 struct snd_kcontrol *kctl = ctl_find(ac97, "External Amplifier", NULL); in tune_inv_eapd()
2834 set_inv_eapd(ac97, kctl); in tune_inv_eapd()
2842 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in master_mute_sw_put() local
2850 snd_ac97_update_bits(ac97, AC97_POWERDOWN, AC97_PD_EAPD, in master_mute_sw_put()
2851 (ac97->regs[AC97_MASTER] & mask) == mask ? in master_mute_sw_put()
2858 static int tune_mute_led(struct snd_ac97 *ac97) in tune_mute_led() argument
2860 struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); in tune_mute_led()
2864 snd_ac97_remove_ctl(ac97, "External Amplifier", NULL); in tune_mute_led()
2866 ac97, AC97_POWERDOWN, in tune_mute_led()
2869 ac97->scaps |= AC97_SCAP_EAPD_LED; in tune_mute_led()
2878 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in hp_master_mute_sw_put() local
2886 snd_ac97_update_bits(ac97, AC97_POWERDOWN, AC97_PD_EAPD, in hp_master_mute_sw_put()
2887 (ac97->regs[AC97_MASTER] & mask) == mask ? in hp_master_mute_sw_put()
2893 static int tune_hp_mute_led(struct snd_ac97 *ac97) in tune_hp_mute_led() argument
2895 struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); in tune_hp_mute_led()
2896 struct snd_kcontrol *mvol = ctl_find(ac97, "Master Playback Volume", NULL); in tune_hp_mute_led()
2901 snd_ac97_remove_ctl(ac97, "External Amplifier", NULL); in tune_hp_mute_led()
2902 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch"); in tune_hp_mute_led()
2903 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume"); in tune_hp_mute_led()
2905 ac97, AC97_POWERDOWN, in tune_hp_mute_led()
2929 static int apply_quirk(struct snd_ac97 *ac97, int type) in apply_quirk() argument
2936 return applicable_quirks[type].func(ac97); in apply_quirk()
2941 static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr) in apply_quirk_str() argument
2949 return apply_quirk(ac97, i); in apply_quirk_str()
2953 return apply_quirk(ac97, (int)simple_strtoul(typestr, NULL, 10)); in apply_quirk_str()
2970 int snd_ac97_tune_hardware(struct snd_ac97 *ac97, in snd_ac97_tune_hardware() argument
2977 result = apply_quirk_str(ac97, override); in snd_ac97_tune_hardware()
2979 ac97_err(ac97, "applying quirk type %s failed (%d)\n", in snd_ac97_tune_hardware()
2988 if (quirk->subvendor != ac97->subsystem_vendor) in snd_ac97_tune_hardware()
2990 if ((! quirk->mask && quirk->subdevice == ac97->subsystem_device) || in snd_ac97_tune_hardware()
2991 quirk->subdevice == (quirk->mask & ac97->subsystem_device)) { in snd_ac97_tune_hardware()
2992 if (quirk->codec_id && quirk->codec_id != ac97->id) in snd_ac97_tune_hardware()
2994 ac97_dbg(ac97, "ac97 quirk for %s (%04x:%04x)\n", in snd_ac97_tune_hardware()
2995 quirk->name, ac97->subsystem_vendor, in snd_ac97_tune_hardware()
2996 ac97->subsystem_device); in snd_ac97_tune_hardware()
2997 result = apply_quirk(ac97, quirk->type); in snd_ac97_tune_hardware()
2999 ac97_err(ac97, in snd_ac97_tune_hardware()