Lines Matching full:ac97
33 MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control");
49 int (*patch)(struct snd_ac97 *ac97);
50 int (*mpatch)(struct snd_ac97 *ac97);
62 * currently used by the AC97 emulation of the almost-AC97 PCI168 card.
194 static void update_power_regs(struct snd_ac97 *ac97);
196 #define ac97_is_power_save_mode(ac97) \ argument
197 ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save)
199 #define ac97_is_power_save_mode(ac97) 0 argument
202 #define ac97_err(ac97, fmt, args...) \ argument
203 dev_err((ac97)->bus->card->dev, fmt, ##args)
204 #define ac97_warn(ac97, fmt, args...) \ argument
205 dev_warn((ac97)->bus->card->dev, fmt, ##args)
206 #define ac97_dbg(ac97, fmt, args...) \ argument
207 dev_dbg((ac97)->bus->card->dev, fmt, ##args)
213 static int snd_ac97_valid_reg(struct snd_ac97 *ac97, unsigned short reg) in snd_ac97_valid_reg() argument
216 switch (ac97->id) { in snd_ac97_valid_reg()
261 * @ac97: the ac97 instance
271 void snd_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) in snd_ac97_write() argument
273 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_write()
275 if ((ac97->id & 0xffffff00) == AC97_ID_ALC100) { in snd_ac97_write()
278 ac97->bus->ops->write(ac97, AC97_RESET, 0); /* reset audio codec */ in snd_ac97_write()
280 ac97->bus->ops->write(ac97, reg, value); in snd_ac97_write()
288 * @ac97: the ac97 instance
296 unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg) in snd_ac97_read() argument
298 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_read()
300 return ac97->bus->ops->read(ac97, reg); in snd_ac97_read()
304 static inline unsigned short snd_ac97_read_cache(struct snd_ac97 *ac97, unsigned short reg) in snd_ac97_read_cache() argument
306 if (! test_bit(reg, ac97->reg_accessed)) { in snd_ac97_read_cache()
307 ac97->regs[reg] = ac97->bus->ops->read(ac97, reg); in snd_ac97_read_cache()
308 // set_bit(reg, ac97->reg_accessed); in snd_ac97_read_cache()
310 return ac97->regs[reg]; in snd_ac97_read_cache()
317 * @ac97: the ac97 instance
325 void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) in snd_ac97_write_cache() argument
327 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_write_cache()
329 mutex_lock(&ac97->reg_mutex); in snd_ac97_write_cache()
330 ac97->regs[reg] = value; in snd_ac97_write_cache()
331 ac97->bus->ops->write(ac97, reg, value); in snd_ac97_write_cache()
332 set_bit(reg, ac97->reg_accessed); in snd_ac97_write_cache()
333 mutex_unlock(&ac97->reg_mutex); in snd_ac97_write_cache()
340 * @ac97: the ac97 instance
350 int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) in snd_ac97_update() argument
354 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_update()
356 mutex_lock(&ac97->reg_mutex); in snd_ac97_update()
357 change = ac97->regs[reg] != value; in snd_ac97_update()
359 ac97->regs[reg] = value; in snd_ac97_update()
360 ac97->bus->ops->write(ac97, reg, value); in snd_ac97_update()
362 set_bit(reg, ac97->reg_accessed); in snd_ac97_update()
363 mutex_unlock(&ac97->reg_mutex); in snd_ac97_update()
371 * @ac97: the ac97 instance
382 int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned s… in snd_ac97_update_bits() argument
386 if (!snd_ac97_valid_reg(ac97, reg)) in snd_ac97_update_bits()
388 mutex_lock(&ac97->reg_mutex); in snd_ac97_update_bits()
389 change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); in snd_ac97_update_bits()
390 mutex_unlock(&ac97->reg_mutex); in snd_ac97_update_bits()
397 int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, in snd_ac97_update_bits_nolock() argument
403 old = snd_ac97_read_cache(ac97, reg); in snd_ac97_update_bits_nolock()
407 ac97->regs[reg] = new; in snd_ac97_update_bits_nolock()
408 ac97->bus->ops->write(ac97, reg, new); in snd_ac97_update_bits_nolock()
410 set_bit(reg, ac97->reg_accessed); in snd_ac97_update_bits_nolock()
414 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
419 mutex_lock(&ac97->page_mutex); in snd_ac97_ad18xx_update_pcm_bits()
420 old = ac97->spec.ad18xx.pcmreg[codec]; in snd_ac97_ad18xx_update_pcm_bits()
424 mutex_lock(&ac97->reg_mutex); in snd_ac97_ad18xx_update_pcm_bits()
425 cfg = snd_ac97_read_cache(ac97, AC97_AD_SERIAL_CFG); in snd_ac97_ad18xx_update_pcm_bits()
426 ac97->spec.ad18xx.pcmreg[codec] = new; in snd_ac97_ad18xx_update_pcm_bits()
428 ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, in snd_ac97_ad18xx_update_pcm_bits()
430 ac97->spec.ad18xx.unchained[codec] | ac97->spec.ad18xx.chained[codec]); in snd_ac97_ad18xx_update_pcm_bits()
432 ac97->bus->ops->write(ac97, AC97_PCM, new); in snd_ac97_ad18xx_update_pcm_bits()
434 ac97->bus->ops->write(ac97, AC97_AD_SERIAL_CFG, in snd_ac97_ad18xx_update_pcm_bits()
436 mutex_unlock(&ac97->reg_mutex); in snd_ac97_ad18xx_update_pcm_bits()
438 mutex_unlock(&ac97->page_mutex); in snd_ac97_ad18xx_update_pcm_bits()
458 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_get_enum_double() local
464 val = snd_ac97_read_cache(ac97, e->reg); in snd_ac97_get_enum_double()
475 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_put_enum_double() local
492 return snd_ac97_update_bits(ac97, e->reg, mask, val); in snd_ac97_put_enum_double()
495 /* save/restore ac97 v2.3 paging */
496 static int snd_ac97_page_save(struct snd_ac97 *ac97, int reg, struct snd_kcontrol *kcontrol) in snd_ac97_page_save() argument
500 (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && in snd_ac97_page_save()
503 mutex_lock(&ac97->page_mutex); /* lock paging */ in snd_ac97_page_save()
504 page_save = snd_ac97_read(ac97, AC97_INT_PAGING) & AC97_PAGE_MASK; in snd_ac97_page_save()
505 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page); in snd_ac97_page_save()
510 static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save) in snd_ac97_page_restore() argument
513 snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); in snd_ac97_page_restore()
514 mutex_unlock(&ac97->page_mutex); /* unlock paging */ in snd_ac97_page_restore()
536 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_get_volsw() local
544 page_save = snd_ac97_page_save(ac97, reg, kcontrol); in snd_ac97_get_volsw()
545 ucontrol->value.integer.value[0] = (snd_ac97_read_cache(ac97, reg) >> shift) & mask; in snd_ac97_get_volsw()
547 ucontrol->value.integer.value[1] = (snd_ac97_read_cache(ac97, reg) >> rshift) & mask; in snd_ac97_get_volsw()
553 snd_ac97_page_restore(ac97, page_save); in snd_ac97_get_volsw()
560 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_put_volsw() local
569 page_save = snd_ac97_page_save(ac97, reg, kcontrol); in snd_ac97_put_volsw()
582 err = snd_ac97_update_bits(ac97, reg, val_mask, val); in snd_ac97_put_volsw()
583 snd_ac97_page_restore(ac97, page_save); in snd_ac97_put_volsw()
589 ac97->power_up &= ~(1 << (reg>>1)); in snd_ac97_put_volsw()
591 ac97->power_up |= 1 << (reg>>1); in snd_ac97_put_volsw()
592 update_power_regs(ac97); in snd_ac97_put_volsw()
679 static void set_inv_eapd(struct snd_ac97 *ac97, struct snd_kcontrol *kctl) in set_inv_eapd() argument
682 snd_ac97_update_bits(ac97, AC97_POWERDOWN, (1<<15), (1<<15)); /* EAPD up */ in set_inv_eapd()
683 ac97->scaps |= AC97_SCAP_INV_EAPD; in set_inv_eapd()
717 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_spdif_default_get() local
719 mutex_lock(&ac97->reg_mutex); in snd_ac97_spdif_default_get()
720 ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff; in snd_ac97_spdif_default_get()
721 ucontrol->value.iec958.status[1] = (ac97->spdif_status >> 8) & 0xff; in snd_ac97_spdif_default_get()
722 ucontrol->value.iec958.status[2] = (ac97->spdif_status >> 16) & 0xff; in snd_ac97_spdif_default_get()
723 ucontrol->value.iec958.status[3] = (ac97->spdif_status >> 24) & 0xff; in snd_ac97_spdif_default_get()
724 mutex_unlock(&ac97->reg_mutex); in snd_ac97_spdif_default_get()
730 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_spdif_default_put() local
763 mutex_lock(&ac97->reg_mutex); in snd_ac97_spdif_default_put()
764 change = ac97->spdif_status != new; in snd_ac97_spdif_default_put()
765 ac97->spdif_status = new; in snd_ac97_spdif_default_put()
767 if (ac97->flags & AC97_CS_SPDIF) { in snd_ac97_spdif_default_put()
774 change |= snd_ac97_update_bits_nolock(ac97, AC97_CSR_SPDIF, 0x3fff, ((val & 0xcfff) | (x << 12))); in snd_ac97_spdif_default_put()
775 } else if (ac97->flags & AC97_CX_SPDIF) { in snd_ac97_spdif_default_put()
779 change |= snd_ac97_update_bits_nolock(ac97, AC97_CXR_AUDIO_MISC, in snd_ac97_spdif_default_put()
782 } else if (ac97->id == AC97_ID_YMF743) { in snd_ac97_spdif_default_put()
783 change |= snd_ac97_update_bits_nolock(ac97, in snd_ac97_spdif_default_put()
789 unsigned short extst = snd_ac97_read_cache(ac97, AC97_EXTENDED_STATUS); in snd_ac97_spdif_default_put()
790 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */ in snd_ac97_spdif_default_put()
792 change |= snd_ac97_update_bits_nolock(ac97, AC97_SPDIF, 0x3fff, val); in snd_ac97_spdif_default_put()
794 …snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on … in snd_ac97_spdif_default_put()
797 mutex_unlock(&ac97->reg_mutex); in snd_ac97_spdif_default_put()
804 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_put_spsa() local
814 mutex_lock(&ac97->reg_mutex); in snd_ac97_put_spsa()
817 old = snd_ac97_read_cache(ac97, reg); in snd_ac97_put_spsa()
822 unsigned short extst = snd_ac97_read_cache(ac97, AC97_EXTENDED_STATUS); in snd_ac97_put_spsa()
823 snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); /* turn off */ in snd_ac97_put_spsa()
824 change = snd_ac97_update_bits_nolock(ac97, reg, mask, value); in snd_ac97_put_spsa()
826 …snd_ac97_update_bits_nolock(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on … in snd_ac97_put_spsa()
828 mutex_unlock(&ac97->reg_mutex); in snd_ac97_put_spsa()
858 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",
873 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_info_bits() local
879 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) in snd_ac97_ad18xx_pcm_info_bits()
890 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_get_bits() local
896 ucontrol->value.integer.value[0] = mask - ((ac97->spec.ad18xx.pcmreg[codec] >> lshift) & mask); in snd_ac97_ad18xx_pcm_get_bits()
897 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) in snd_ac97_ad18xx_pcm_get_bits()
898 ucontrol->value.integer.value[1] = mask - ((ac97->spec.ad18xx.pcmreg[codec] >> rshift) & mask); in snd_ac97_ad18xx_pcm_get_bits()
904 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_put_bits() local
913 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_ad18xx_pcm_put_bits()
917 return snd_ac97_ad18xx_update_pcm_bits(ac97, codec, valmask, val); in snd_ac97_ad18xx_pcm_put_bits()
936 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_get_volume() local
939 mutex_lock(&ac97->page_mutex); in snd_ac97_ad18xx_pcm_get_volume()
940 ucontrol->value.integer.value[0] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 8) & 31); in snd_ac97_ad18xx_pcm_get_volume()
941 ucontrol->value.integer.value[1] = 31 - ((ac97->spec.ad18xx.pcmreg[codec] >> 0) & 31); in snd_ac97_ad18xx_pcm_get_volume()
942 mutex_unlock(&ac97->page_mutex); in snd_ac97_ad18xx_pcm_get_volume()
948 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in snd_ac97_ad18xx_pcm_put_volume() local
954 return snd_ac97_ad18xx_update_pcm_bits(ac97, codec, 0x1f1f, (val1 << 8) | val2); in snd_ac97_ad18xx_pcm_put_volume()
981 static void snd_ac97_powerdown(struct snd_ac97 *ac97);
1001 static int snd_ac97_free(struct snd_ac97 *ac97) in snd_ac97_free() argument
1003 if (ac97) { in snd_ac97_free()
1005 cancel_delayed_work_sync(&ac97->power_work); in snd_ac97_free()
1007 snd_ac97_proc_done(ac97); in snd_ac97_free()
1008 if (ac97->bus) in snd_ac97_free()
1009 ac97->bus->codec[ac97->num] = NULL; in snd_ac97_free()
1010 if (ac97->private_free) in snd_ac97_free()
1011 ac97->private_free(ac97); in snd_ac97_free()
1012 kfree(ac97); in snd_ac97_free()
1019 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_free() local
1020 snd_ac97_powerdown(ac97); /* for avoiding click noises during shut down */ in snd_ac97_dev_free()
1021 return snd_ac97_free(ac97); in snd_ac97_dev_free()
1024 static int snd_ac97_try_volume_mix(struct snd_ac97 * ac97, int reg) in snd_ac97_try_volume_mix() argument
1028 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_try_volume_mix()
1033 return ac97->caps & AC97_BC_BASS_TREBLE ? 1 : 0; in snd_ac97_try_volume_mix()
1035 return ac97->caps & AC97_BC_HEADPHONE ? 1 : 0; in snd_ac97_try_volume_mix()
1037 return ac97->caps & AC97_BC_DEDICATED_MIC ? 1 : 0; in snd_ac97_try_volume_mix()
1039 if (ac97->caps & AC97_BC_3D_TECH_ID_MASK) { in snd_ac97_try_volume_mix()
1040 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1046 if ((ac97->ext_id & AC97_EI_CDAC) == 0) in snd_ac97_try_volume_mix()
1050 if ((ac97->ext_id & AC97_EI_LDAC) == 0) in snd_ac97_try_volume_mix()
1056 if ((ac97->ext_id & AC97_EI_SDAC) == 0) in snd_ac97_try_volume_mix()
1061 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1065 snd_ac97_write_cache(ac97, reg, val | mask); in snd_ac97_try_volume_mix()
1066 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1067 val = snd_ac97_read(ac97, reg); in snd_ac97_try_volume_mix()
1074 static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned char *lo_max, unsigned… in check_volume_resolution() argument
1081 if (ac97->res_table) { in check_volume_resolution()
1083 for (tbl = ac97->res_table; tbl->reg; tbl++) { in check_volume_resolution()
1096 ac97, reg, in check_volume_resolution()
1099 /* Do the read twice due to buffers on some ac97 codecs. in check_volume_resolution()
1103 val = snd_ac97_read(ac97, reg); in check_volume_resolution()
1104 val = snd_ac97_read(ac97, reg); in check_volume_resolution()
1114 static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) in snd_ac97_try_bit() argument
1119 orig = snd_ac97_read(ac97, reg); in snd_ac97_try_bit()
1121 snd_ac97_write(ac97, reg, val); in snd_ac97_try_bit()
1122 res = snd_ac97_read(ac97, reg); in snd_ac97_try_bit()
1123 snd_ac97_write_cache(ac97, reg, orig); in snd_ac97_try_bit()
1128 static void snd_ac97_change_volume_params2(struct snd_ac97 * ac97, int reg, int shift, unsigned cha… in snd_ac97_change_volume_params2() argument
1134 snd_ac97_write(ac97, reg, val); in snd_ac97_change_volume_params2()
1135 val1 = snd_ac97_read(ac97, reg); in snd_ac97_change_volume_params2()
1140 snd_ac97_write_cache(ac97, reg, AC97_MUTE_MASK_STEREO); in snd_ac97_change_volume_params2()
1155 struct snd_ac97 * ac97) in snd_ac97_cnew() argument
1159 template.index = ac97->num; in snd_ac97_cnew()
1160 return snd_ctl_new1(&template, ac97); in snd_ac97_cnew()
1168 struct snd_ac97 *ac97) in snd_ac97_cmute_new_stereo() argument
1174 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_cmute_new_stereo()
1178 val = snd_ac97_read(ac97, reg); in snd_ac97_cmute_new_stereo()
1179 if (check_stereo || (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_cmute_new_stereo()
1182 snd_ac97_write(ac97, reg, val1); in snd_ac97_cmute_new_stereo()
1183 if (val1 == snd_ac97_read(ac97, reg)) in snd_ac97_cmute_new_stereo()
1190 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1191 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cmute_new_stereo()
1196 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1197 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cmute_new_stereo()
1203 snd_ac97_write_cache(ac97, reg, val | mute_mask); in snd_ac97_cmute_new_stereo()
1237 unsigned int hi_max, struct snd_ac97 *ac97) in snd_ac97_cvol_new() argument
1242 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_cvol_new()
1247 tmp.index = ac97->num; in snd_ac97_cvol_new()
1248 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cvol_new()
1252 tmp.index = ac97->num; in snd_ac97_cvol_new()
1253 kctl = snd_ctl_new1(&tmp, ac97); in snd_ac97_cvol_new()
1265 ac97, reg, in snd_ac97_cvol_new()
1266 (snd_ac97_read(ac97, reg) & AC97_MUTE_MASK_STEREO) in snd_ac97_cvol_new()
1277 struct snd_ac97 *ac97) in snd_ac97_cmix_new_stereo() argument
1283 if (! snd_ac97_valid_reg(ac97, reg)) in snd_ac97_cmix_new_stereo()
1286 if (snd_ac97_try_bit(ac97, reg, 15)) { in snd_ac97_cmix_new_stereo()
1290 ac97); in snd_ac97_cmix_new_stereo()
1294 check_volume_resolution(ac97, reg, &lo_max, &hi_max); in snd_ac97_cmix_new_stereo()
1297 err = snd_ac97_cvol_new(card, name, reg, lo_max, hi_max, ac97); in snd_ac97_cmix_new_stereo()
1304 #define snd_ac97_cmix_new(card, pfx, reg, acheck, ac97) \ argument
1305 snd_ac97_cmix_new_stereo(card, pfx, reg, 0, acheck, ac97)
1306 #define snd_ac97_cmute_new(card, name, reg, acheck, ac97) \ argument
1307 snd_ac97_cmute_new_stereo(card, name, reg, 0, acheck, ac97)
1309 static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97);
1311 static int snd_ac97_mixer_build(struct snd_ac97 * ac97) in snd_ac97_mixer_build() argument
1313 struct snd_card *card = ac97->bus->card; in snd_ac97_mixer_build()
1321 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER)) { in snd_ac97_mixer_build()
1322 if (ac97->flags & AC97_HAS_NO_MASTER_VOL) in snd_ac97_mixer_build()
1324 AC97_MASTER, 0, ac97); in snd_ac97_mixer_build()
1327 AC97_MASTER, 0, ac97); in snd_ac97_mixer_build()
1332 ac97->regs[AC97_CENTER_LFE_MASTER] = AC97_MUTE_MASK_STEREO; in snd_ac97_mixer_build()
1335 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER)) in snd_ac97_mixer_build()
1336 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1337 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_center[0], ac97)); in snd_ac97_mixer_build()
1340 err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_center[1], ac97)); in snd_ac97_mixer_build()
1343 snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 0, &max); in snd_ac97_mixer_build()
1347 snd_ac97_write_cache(ac97, AC97_CENTER_LFE_MASTER, ac97->regs[AC97_CENTER_LFE_MASTER] | max); in snd_ac97_mixer_build()
1351 if ((snd_ac97_try_volume_mix(ac97, AC97_CENTER_LFE_MASTER+1)) in snd_ac97_mixer_build()
1352 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1353 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_lfe[0], ac97)); in snd_ac97_mixer_build()
1356 err = snd_ctl_add(card, kctl = snd_ac97_cnew(&snd_ac97_controls_lfe[1], ac97)); in snd_ac97_mixer_build()
1359 snd_ac97_change_volume_params2(ac97, AC97_CENTER_LFE_MASTER, 8, &max); in snd_ac97_mixer_build()
1363 snd_ac97_write_cache(ac97, AC97_CENTER_LFE_MASTER, ac97->regs[AC97_CENTER_LFE_MASTER] | max << 8); in snd_ac97_mixer_build()
1367 if ((snd_ac97_try_volume_mix(ac97, AC97_SURROUND_MASTER)) in snd_ac97_mixer_build()
1368 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1372 ac97); in snd_ac97_mixer_build()
1378 if (snd_ac97_try_volume_mix(ac97, AC97_HEADPHONE)) { in snd_ac97_mixer_build()
1380 AC97_HEADPHONE, 0, ac97); in snd_ac97_mixer_build()
1386 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_MONO)) { in snd_ac97_mixer_build()
1388 AC97_MASTER_MONO, 0, ac97); in snd_ac97_mixer_build()
1394 if (!(ac97->flags & AC97_HAS_NO_TONE)) { in snd_ac97_mixer_build()
1395 if (snd_ac97_try_volume_mix(ac97, AC97_MASTER_TONE)) { in snd_ac97_mixer_build()
1397 kctl = snd_ac97_cnew(&snd_ac97_controls_tone[idx], ac97); in snd_ac97_mixer_build()
1401 if (ac97->id == AC97_ID_YMF743 || in snd_ac97_mixer_build()
1402 ac97->id == AC97_ID_YMF753) { in snd_ac97_mixer_build()
1407 snd_ac97_write_cache(ac97, AC97_MASTER_TONE, 0x0f0f); in snd_ac97_mixer_build()
1412 if (!(ac97->flags & AC97_HAS_NO_PC_BEEP) && in snd_ac97_mixer_build()
1413 ((ac97->flags & AC97_HAS_PC_BEEP) || in snd_ac97_mixer_build()
1414 snd_ac97_try_volume_mix(ac97, AC97_PC_BEEP))) { in snd_ac97_mixer_build()
1416 kctl = snd_ac97_cnew(&snd_ac97_controls_pc_beep[idx], ac97); in snd_ac97_mixer_build()
1423 ac97, in snd_ac97_mixer_build()
1425 (snd_ac97_read(ac97, AC97_PC_BEEP) in snd_ac97_mixer_build()
1431 if (!(ac97->flags & AC97_HAS_NO_PHONE)) { in snd_ac97_mixer_build()
1432 if (snd_ac97_try_volume_mix(ac97, AC97_PHONE)) { in snd_ac97_mixer_build()
1434 AC97_PHONE, 1, ac97); in snd_ac97_mixer_build()
1441 if (!(ac97->flags & AC97_HAS_NO_MIC)) { in snd_ac97_mixer_build()
1442 if (snd_ac97_try_volume_mix(ac97, AC97_MIC)) { in snd_ac97_mixer_build()
1444 AC97_MIC, 1, ac97); in snd_ac97_mixer_build()
1447 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_mic_boost, ac97)); in snd_ac97_mixer_build()
1454 if (snd_ac97_try_volume_mix(ac97, AC97_LINE)) { in snd_ac97_mixer_build()
1456 AC97_LINE, 1, ac97); in snd_ac97_mixer_build()
1462 if (!(ac97->flags & AC97_HAS_NO_CD)) { in snd_ac97_mixer_build()
1463 if (snd_ac97_try_volume_mix(ac97, AC97_CD)) { in snd_ac97_mixer_build()
1465 AC97_CD, 1, ac97); in snd_ac97_mixer_build()
1472 if (!(ac97->flags & AC97_HAS_NO_VIDEO)) { in snd_ac97_mixer_build()
1473 if (snd_ac97_try_volume_mix(ac97, AC97_VIDEO)) { in snd_ac97_mixer_build()
1475 AC97_VIDEO, 1, ac97); in snd_ac97_mixer_build()
1482 if (!(ac97->flags & AC97_HAS_NO_AUX)) { in snd_ac97_mixer_build()
1483 if (snd_ac97_try_volume_mix(ac97, AC97_AUX)) { in snd_ac97_mixer_build()
1485 AC97_AUX, 1, ac97); in snd_ac97_mixer_build()
1492 if (ac97->flags & AC97_AD_MULTI) { in snd_ac97_mixer_build()
1494 if (ac97->flags & AC97_STEREO_MUTES) in snd_ac97_mixer_build()
1499 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_pcm[idx], ac97); in snd_ac97_mixer_build()
1505 ac97->spec.ad18xx.pcmreg[0] = init_val; in snd_ac97_mixer_build()
1506 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) { in snd_ac97_mixer_build()
1508 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_surround[idx], ac97); in snd_ac97_mixer_build()
1514 ac97->spec.ad18xx.pcmreg[1] = init_val; in snd_ac97_mixer_build()
1516 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) { in snd_ac97_mixer_build()
1518 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_center[idx], ac97); in snd_ac97_mixer_build()
1525 kctl = snd_ac97_cnew(&snd_ac97_controls_ad18xx_lfe[idx], ac97); in snd_ac97_mixer_build()
1531 ac97->spec.ad18xx.pcmreg[2] = init_val; in snd_ac97_mixer_build()
1533 snd_ac97_write_cache(ac97, AC97_PCM, init_val); in snd_ac97_mixer_build()
1535 if (!(ac97->flags & AC97_HAS_NO_STD_PCM)) { in snd_ac97_mixer_build()
1536 if (ac97->flags & AC97_HAS_NO_PCM_VOL) in snd_ac97_mixer_build()
1539 AC97_PCM, 0, ac97); in snd_ac97_mixer_build()
1542 AC97_PCM, 0, ac97); in snd_ac97_mixer_build()
1549 if (!(ac97->flags & AC97_HAS_NO_REC_GAIN)) { in snd_ac97_mixer_build()
1550 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_control_capture_src, ac97)); in snd_ac97_mixer_build()
1553 if (snd_ac97_try_bit(ac97, AC97_REC_GAIN, 15)) { in snd_ac97_mixer_build()
1555 AC97_REC_GAIN, 0, ac97); in snd_ac97_mixer_build()
1559 kctl = snd_ac97_cnew(&snd_ac97_control_capture_vol, ac97); in snd_ac97_mixer_build()
1564 snd_ac97_write_cache(ac97, AC97_REC_SEL, 0x0000); in snd_ac97_mixer_build()
1565 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x0000); in snd_ac97_mixer_build()
1568 if (snd_ac97_try_volume_mix(ac97, AC97_REC_GAIN_MIC)) { in snd_ac97_mixer_build()
1570 kctl = snd_ac97_cnew(&snd_ac97_controls_mic_capture[idx], ac97); in snd_ac97_mixer_build()
1576 snd_ac97_write_cache(ac97, AC97_REC_GAIN_MIC, 0x0000); in snd_ac97_mixer_build()
1580 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 15)) { in snd_ac97_mixer_build()
1581 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_PCM_OUT], ac97)); in snd_ac97_mixer_build()
1587 if (ac97->caps & AC97_BC_SIM_STEREO) { in snd_ac97_mixer_build()
1588 …nd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_STEREO_ENHANCEMENT], ac97)); in snd_ac97_mixer_build()
1594 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 13)) { in snd_ac97_mixer_build()
1595 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_3D], ac97)); in snd_ac97_mixer_build()
1601 if (ac97->caps & AC97_BC_LOUDNESS) { in snd_ac97_mixer_build()
1602 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOUDNESS], ac97)); in snd_ac97_mixer_build()
1608 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 9)) { in snd_ac97_mixer_build()
1609 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MONO], ac97)); in snd_ac97_mixer_build()
1615 if (snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 8)) { in snd_ac97_mixer_build()
1616 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_MIC], ac97)); in snd_ac97_mixer_build()
1622 if (enable_loopback && snd_ac97_try_bit(ac97, AC97_GENERAL_PURPOSE, 7)) { in snd_ac97_mixer_build()
1623 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_general[AC97_GENERAL_LOOPBACK], ac97)); in snd_ac97_mixer_build()
1628 snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, ~AC97_GP_DRSS_MASK, 0x0000); in snd_ac97_mixer_build()
1631 if (ac97->build_ops->build_3d) { in snd_ac97_mixer_build()
1632 ac97->build_ops->build_3d(ac97); in snd_ac97_mixer_build()
1634 if (snd_ac97_try_volume_mix(ac97, AC97_3D_CONTROL)) { in snd_ac97_mixer_build()
1637 snd_ac97_write(ac97, AC97_3D_CONTROL, val); in snd_ac97_mixer_build()
1638 val = snd_ac97_read(ac97, AC97_3D_CONTROL); in snd_ac97_mixer_build()
1640 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97); in snd_ac97_mixer_build()
1646 kctl = snd_ac97_cnew(&snd_ac97_controls_3d[1], ac97); in snd_ac97_mixer_build()
1652 snd_ac97_write_cache(ac97, AC97_3D_CONTROL, 0x0000); in snd_ac97_mixer_build()
1659 if (ac97->subsystem_vendor == 0x1043 && in snd_ac97_mixer_build()
1660 ac97->subsystem_device == 0x810f) in snd_ac97_mixer_build()
1661 ac97->ext_id |= AC97_EI_SPDIF; in snd_ac97_mixer_build()
1663 if ((ac97->ext_id & AC97_EI_SPDIF) && !(ac97->scaps & AC97_SCAP_NO_SPDIF)) { in snd_ac97_mixer_build()
1664 if (ac97->build_ops->build_spdif) { in snd_ac97_mixer_build()
1665 err = ac97->build_ops->build_spdif(ac97); in snd_ac97_mixer_build()
1670 err = snd_ctl_add(card, snd_ac97_cnew(&snd_ac97_controls_spdif[idx], ac97)); in snd_ac97_mixer_build()
1674 if (ac97->build_ops->build_post_spdif) { in snd_ac97_mixer_build()
1675 err = ac97->build_ops->build_post_spdif(ac97); in snd_ac97_mixer_build()
1681 snd_ac97_write_cache(ac97, AC97_SPDIF, 0x2a20); in snd_ac97_mixer_build()
1682 ac97->rates[AC97_RATES_SPDIF] = snd_ac97_determine_spdif_rates(ac97); in snd_ac97_mixer_build()
1684 ac97->spdif_status = SNDRV_PCM_DEFAULT_CON_SPDIF; in snd_ac97_mixer_build()
1688 if (ac97->build_ops->build_specific) { in snd_ac97_mixer_build()
1689 err = ac97->build_ops->build_specific(ac97); in snd_ac97_mixer_build()
1694 if (snd_ac97_try_bit(ac97, AC97_POWERDOWN, 15)) { in snd_ac97_mixer_build()
1695 kctl = snd_ac97_cnew(&snd_ac97_control_eapd, ac97); in snd_ac97_mixer_build()
1698 if (ac97->scaps & AC97_SCAP_INV_EAPD) in snd_ac97_mixer_build()
1699 set_inv_eapd(ac97, kctl); in snd_ac97_mixer_build()
1708 static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97) in snd_ac97_modem_build() argument
1713 ac97_dbg(ac97, "AC97_GPIO_CFG = %x\n", in snd_ac97_modem_build()
1714 snd_ac97_read(ac97,AC97_GPIO_CFG)); in snd_ac97_modem_build()
1716 snd_ac97_write(ac97, AC97_GPIO_CFG, 0xffff & ~(AC97_GPIO_LINE1_OH)); in snd_ac97_modem_build()
1717 snd_ac97_write(ac97, AC97_GPIO_POLARITY, 0xffff & ~(AC97_GPIO_LINE1_OH)); in snd_ac97_modem_build()
1718 snd_ac97_write(ac97, AC97_GPIO_STICKY, 0xffff); in snd_ac97_modem_build()
1719 snd_ac97_write(ac97, AC97_GPIO_WAKEUP, 0x0); in snd_ac97_modem_build()
1720 snd_ac97_write(ac97, AC97_MISC_AFE, 0x0); in snd_ac97_modem_build()
1724 err = snd_ctl_add(card, snd_ctl_new1(&snd_ac97_controls_modem_switches[idx], ac97)); in snd_ac97_modem_build()
1730 if (ac97->build_ops->build_specific) { in snd_ac97_modem_build()
1731 err = ac97->build_ops->build_specific(ac97); in snd_ac97_modem_build()
1739 static int snd_ac97_test_rate(struct snd_ac97 *ac97, int reg, int shadow_reg, int rate) in snd_ac97_test_rate() argument
1744 tmp = ((unsigned int)rate * ac97->bus->clock) / 48000; in snd_ac97_test_rate()
1745 snd_ac97_write_cache(ac97, reg, tmp & 0xffff); in snd_ac97_test_rate()
1747 snd_ac97_write_cache(ac97, shadow_reg, tmp & 0xffff); in snd_ac97_test_rate()
1748 val = snd_ac97_read(ac97, reg); in snd_ac97_test_rate()
1752 static void snd_ac97_determine_rates(struct snd_ac97 *ac97, int reg, int shadow_reg, unsigned int *… in snd_ac97_determine_rates() argument
1757 if (ac97->bus->no_vra) { in snd_ac97_determine_rates()
1759 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1765 saved = snd_ac97_read(ac97, reg); in snd_ac97_determine_rates()
1766 if ((ac97->ext_id & AC97_EI_DRA) && reg == AC97_PCM_FRONT_DAC_RATE) in snd_ac97_determine_rates()
1767 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, in snd_ac97_determine_rates()
1770 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 11000)) in snd_ac97_determine_rates()
1773 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 8000)) in snd_ac97_determine_rates()
1775 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 11025)) in snd_ac97_determine_rates()
1777 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 16000)) in snd_ac97_determine_rates()
1779 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 22050)) in snd_ac97_determine_rates()
1781 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 32000)) in snd_ac97_determine_rates()
1783 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 44100)) in snd_ac97_determine_rates()
1785 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 48000)) in snd_ac97_determine_rates()
1787 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1790 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, in snd_ac97_determine_rates()
1792 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 64000 / 2)) in snd_ac97_determine_rates()
1794 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 88200 / 2)) in snd_ac97_determine_rates()
1796 if (snd_ac97_test_rate(ac97, reg, shadow_reg, 96000 / 2)) in snd_ac97_determine_rates()
1799 if (!snd_ac97_test_rate(ac97, reg, shadow_reg, 76100 / 2)) in snd_ac97_determine_rates()
1801 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, in snd_ac97_determine_rates()
1805 snd_ac97_write_cache(ac97, reg, saved); in snd_ac97_determine_rates()
1807 snd_ac97_write_cache(ac97, shadow_reg, saved); in snd_ac97_determine_rates()
1812 static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97) in snd_ac97_determine_spdif_rates() argument
1824 snd_ac97_update_bits(ac97, AC97_SPDIF, AC97_SC_SPSR_MASK, ctl_bits[i]); in snd_ac97_determine_spdif_rates()
1825 if ((snd_ac97_read(ac97, AC97_SPDIF) & AC97_SC_SPSR_MASK) == ctl_bits[i]) in snd_ac97_determine_spdif_rates()
1843 void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem) in snd_ac97_get_name() argument
1856 if (ac97 && pid->patch) { in snd_ac97_get_name()
1859 pid->patch(ac97); in snd_ac97_get_name()
1868 if (ac97 && pid->patch) { in snd_ac97_get_name()
1871 pid->patch(ac97); in snd_ac97_get_name()
1879 * @ac97: the codec instance
1883 const char *snd_ac97_get_short_name(struct snd_ac97 *ac97) in snd_ac97_get_short_name() argument
1888 if (pid->id == (ac97->id & pid->mask)) in snd_ac97_get_short_name()
1898 static int ac97_reset_wait(struct snd_ac97 *ac97, int timeout, int with_modem) in ac97_reset_wait() argument
1907 snd_ac97_read(ac97, AC97_RESET); in ac97_reset_wait()
1908 snd_ac97_read(ac97, AC97_VENDOR_ID1); in ac97_reset_wait()
1909 snd_ac97_read(ac97, AC97_VENDOR_ID2); in ac97_reset_wait()
1912 val = snd_ac97_read(ac97, AC97_EXTENDED_MID); in ac97_reset_wait()
1916 if (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) { in ac97_reset_wait()
1918 val = snd_ac97_read(ac97, AC97_VENDOR_ID1); in ac97_reset_wait()
1926 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a05); in ac97_reset_wait()
1927 if ((snd_ac97_read(ac97, AC97_REC_GAIN) & 0x7fff) == 0x0a05) in ac97_reset_wait()
1936 * snd_ac97_bus - create an AC97 bus component
1941 * @rbus: the pointer to store the new AC97 bus instance.
1943 * Creates an AC97 bus component. An struct snd_ac97_bus instance is newly
1952 * The AC97 bus instance is registered as a low-level device, so you don't
1996 /* register ac97 codec to bus */
1999 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_register() local
2002 ac97->dev.bus = &ac97_bus_type; in snd_ac97_dev_register()
2003 ac97->dev.parent = ac97->bus->card->dev; in snd_ac97_dev_register()
2004 ac97->dev.release = ac97_device_release; in snd_ac97_dev_register()
2005 dev_set_name(&ac97->dev, "%d-%d:%s", in snd_ac97_dev_register()
2006 ac97->bus->card->number, ac97->num, in snd_ac97_dev_register()
2007 snd_ac97_get_short_name(ac97)); in snd_ac97_dev_register()
2008 err = device_register(&ac97->dev); in snd_ac97_dev_register()
2010 ac97_err(ac97, "Can't register ac97 bus\n"); in snd_ac97_dev_register()
2011 put_device(&ac97->dev); in snd_ac97_dev_register()
2012 ac97->dev.bus = NULL; in snd_ac97_dev_register()
2018 /* disconnect ac97 codec */
2021 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_disconnect() local
2022 if (ac97->dev.bus) in snd_ac97_dev_disconnect()
2023 device_unregister(&ac97->dev); in snd_ac97_dev_disconnect()
2040 * @bus: the AC97 bus which codec is attached to
2041 * @template: the template of ac97, including index, callbacks and
2043 * @rac97: the pointer to store the new ac97 instance.
2052 * The ac97 instance is registered as a low-level device, so you don't
2060 struct snd_ac97 *ac97; in snd_ac97_mixer() local
2081 ac97 = kzalloc(sizeof(*ac97), GFP_KERNEL); in snd_ac97_mixer()
2082 if (ac97 == NULL) in snd_ac97_mixer()
2084 ac97->private_data = template->private_data; in snd_ac97_mixer()
2085 ac97->private_free = template->private_free; in snd_ac97_mixer()
2086 ac97->bus = bus; in snd_ac97_mixer()
2087 ac97->pci = template->pci; in snd_ac97_mixer()
2088 ac97->num = template->num; in snd_ac97_mixer()
2089 ac97->addr = template->addr; in snd_ac97_mixer()
2090 ac97->scaps = template->scaps; in snd_ac97_mixer()
2091 ac97->res_table = template->res_table; in snd_ac97_mixer()
2092 bus->codec[ac97->num] = ac97; in snd_ac97_mixer()
2093 mutex_init(&ac97->reg_mutex); in snd_ac97_mixer()
2094 mutex_init(&ac97->page_mutex); in snd_ac97_mixer()
2096 INIT_DELAYED_WORK(&ac97->power_work, do_update_power); in snd_ac97_mixer()
2100 if (ac97->pci) { in snd_ac97_mixer()
2101 pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_VENDOR_ID, &ac97->subsystem_vendor); in snd_ac97_mixer()
2102 pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_ID, &ac97->subsystem_device); in snd_ac97_mixer()
2106 bus->ops->reset(ac97); in snd_ac97_mixer()
2110 ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16; in snd_ac97_mixer()
2111 ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2); in snd_ac97_mixer()
2112 if (ac97->id && ac97->id != (unsigned int)-1) { in snd_ac97_mixer()
2113 pid = look_for_codec_id(snd_ac97_codec_ids, ac97->id); in snd_ac97_mixer()
2119 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) in snd_ac97_mixer()
2120 snd_ac97_write(ac97, AC97_RESET, 0); in snd_ac97_mixer()
2121 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_mixer()
2122 snd_ac97_write(ac97, AC97_EXTENDED_MID, 0); in snd_ac97_mixer()
2124 bus->ops->wait(ac97); in snd_ac97_mixer()
2127 if (ac97->scaps & AC97_SCAP_SKIP_AUDIO) in snd_ac97_mixer()
2128 err = ac97_reset_wait(ac97, msecs_to_jiffies(500), 1); in snd_ac97_mixer()
2130 err = ac97_reset_wait(ac97, msecs_to_jiffies(500), 0); in snd_ac97_mixer()
2132 err = ac97_reset_wait(ac97, in snd_ac97_mixer()
2136 ac97_warn(ac97, "AC'97 %d does not respond - RESET\n", in snd_ac97_mixer()
2137 ac97->num); in snd_ac97_mixer()
2142 ac97->id = snd_ac97_read(ac97, AC97_VENDOR_ID1) << 16; in snd_ac97_mixer()
2143 ac97->id |= snd_ac97_read(ac97, AC97_VENDOR_ID2); in snd_ac97_mixer()
2144 if (! (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) && in snd_ac97_mixer()
2145 (ac97->id == 0x00000000 || ac97->id == 0xffffffff)) { in snd_ac97_mixer()
2146 ac97_err(ac97, in snd_ac97_mixer()
2148 ac97->num, ac97->id); in snd_ac97_mixer()
2149 snd_ac97_free(ac97); in snd_ac97_mixer()
2152 pid = look_for_codec_id(snd_ac97_codec_ids, ac97->id); in snd_ac97_mixer()
2154 ac97->flags |= pid->flags; in snd_ac97_mixer()
2157 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO) && !(ac97->scaps & AC97_SCAP_AUDIO)) { in snd_ac97_mixer()
2159 snd_ac97_write_cache(ac97, AC97_REC_GAIN, 0x8a06); in snd_ac97_mixer()
2160 err = snd_ac97_read(ac97, AC97_REC_GAIN); in snd_ac97_mixer()
2162 ac97->scaps |= AC97_SCAP_AUDIO; in snd_ac97_mixer()
2164 if (ac97->scaps & AC97_SCAP_AUDIO) { in snd_ac97_mixer()
2165 ac97->caps = snd_ac97_read(ac97, AC97_RESET); in snd_ac97_mixer()
2166 ac97->ext_id = snd_ac97_read(ac97, AC97_EXTENDED_ID); in snd_ac97_mixer()
2167 if (ac97->ext_id == 0xffff) /* invalid combination */ in snd_ac97_mixer()
2168 ac97->ext_id = 0; in snd_ac97_mixer()
2172 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM) && !(ac97->scaps & AC97_SCAP_MODEM)) { in snd_ac97_mixer()
2173 ac97->ext_mid = snd_ac97_read(ac97, AC97_EXTENDED_MID); in snd_ac97_mixer()
2174 if (ac97->ext_mid == 0xffff) /* invalid combination */ in snd_ac97_mixer()
2175 ac97->ext_mid = 0; in snd_ac97_mixer()
2176 if (ac97->ext_mid & 1) in snd_ac97_mixer()
2177 ac97->scaps |= AC97_SCAP_MODEM; in snd_ac97_mixer()
2180 if (!ac97_is_audio(ac97) && !ac97_is_modem(ac97)) { in snd_ac97_mixer()
2181 if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM))) in snd_ac97_mixer()
2182 ac97_err(ac97, in snd_ac97_mixer()
2184 ac97->num); in snd_ac97_mixer()
2185 snd_ac97_free(ac97); in snd_ac97_mixer()
2193 if (ac97_is_audio(ac97)) { in snd_ac97_mixer()
2195 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0); in snd_ac97_mixer()
2196 if (! (ac97->flags & AC97_DEFAULT_POWER_OFF)) { in snd_ac97_mixer()
2197 snd_ac97_write_cache(ac97, AC97_RESET, 0); /* reset to defaults */ in snd_ac97_mixer()
2199 snd_ac97_write_cache(ac97, AC97_POWERDOWN, 0); in snd_ac97_mixer()
2202 snd_ac97_write_cache(ac97, AC97_GENERAL_PURPOSE, 0); in snd_ac97_mixer()
2205 if ((snd_ac97_read(ac97, AC97_POWERDOWN) & 0x0f) == 0x0f) in snd_ac97_mixer()
2209 ac97_warn(ac97, in snd_ac97_mixer()
2210 "AC'97 %d analog subsections not ready\n", ac97->num); in snd_ac97_mixer()
2214 if (ac97_is_modem(ac97)) { in snd_ac97_mixer()
2220 if (ac97->ext_mid & AC97_MEI_LINE1) { in snd_ac97_mixer()
2221 snd_ac97_write_cache(ac97, AC97_LINE1_RATE, 8000); in snd_ac97_mixer()
2224 if (ac97->ext_mid & AC97_MEI_LINE2) { in snd_ac97_mixer()
2225 snd_ac97_write_cache(ac97, AC97_LINE2_RATE, 8000); in snd_ac97_mixer()
2228 if (ac97->ext_mid & AC97_MEI_HANDSET) { in snd_ac97_mixer()
2229 snd_ac97_write_cache(ac97, AC97_HANDSET_RATE, 8000); in snd_ac97_mixer()
2232 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0); in snd_ac97_mixer()
2235 snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0); in snd_ac97_mixer()
2238 if ((snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS) & tmp) == tmp) in snd_ac97_mixer()
2242 ac97_warn(ac97, in snd_ac97_mixer()
2244 ac97->num, in snd_ac97_mixer()
2245 snd_ac97_read(ac97, AC97_EXTENDED_MSTATUS)); in snd_ac97_mixer()
2249 if (ac97_is_audio(ac97)) in snd_ac97_mixer()
2250 ac97->addr = (ac97->ext_id & AC97_EI_ADDR_MASK) >> AC97_EI_ADDR_SHIFT; in snd_ac97_mixer()
2252 ac97->addr = (ac97->ext_mid & AC97_MEI_ADDR_MASK) >> AC97_MEI_ADDR_SHIFT; in snd_ac97_mixer()
2253 if (ac97->ext_id & 0x01c9) { /* L/R, MIC, SDAC, LDAC VRA support */ in snd_ac97_mixer()
2254 reg = snd_ac97_read(ac97, AC97_EXTENDED_STATUS); in snd_ac97_mixer()
2255 reg |= ac97->ext_id & 0x01c0; /* LDAC/SDAC/CDAC */ in snd_ac97_mixer()
2257 reg |= ac97->ext_id & 0x0009; /* VRA/VRM */ in snd_ac97_mixer()
2258 snd_ac97_write_cache(ac97, AC97_EXTENDED_STATUS, reg); in snd_ac97_mixer()
2260 if ((ac97->ext_id & AC97_EI_DRA) && bus->dra) { in snd_ac97_mixer()
2263 snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, AC97_GP_DRSS_MASK, AC97_GP_DRSS_78); in snd_ac97_mixer()
2264 if ((snd_ac97_read(ac97, AC97_GENERAL_PURPOSE) & AC97_GP_DRSS_MASK) == AC97_GP_DRSS_78) in snd_ac97_mixer()
2265 ac97->flags |= AC97_DOUBLE_RATE; in snd_ac97_mixer()
2267 snd_ac97_update_bits(ac97, AC97_GENERAL_PURPOSE, AC97_GP_DRSS_MASK, 0); in snd_ac97_mixer()
2269 if (ac97->ext_id & AC97_EI_VRA) { /* VRA support */ in snd_ac97_mixer()
2270 snd_ac97_determine_rates(ac97, AC97_PCM_FRONT_DAC_RATE, 0, &ac97->rates[AC97_RATES_FRONT_DAC]); in snd_ac97_mixer()
2271 snd_ac97_determine_rates(ac97, AC97_PCM_LR_ADC_RATE, 0, &ac97->rates[AC97_RATES_ADC]); in snd_ac97_mixer()
2273 ac97->rates[AC97_RATES_FRONT_DAC] = SNDRV_PCM_RATE_48000; in snd_ac97_mixer()
2274 if (ac97->flags & AC97_DOUBLE_RATE) in snd_ac97_mixer()
2275 ac97->rates[AC97_RATES_FRONT_DAC] |= SNDRV_PCM_RATE_96000; in snd_ac97_mixer()
2276 ac97->rates[AC97_RATES_ADC] = SNDRV_PCM_RATE_48000; in snd_ac97_mixer()
2278 if (ac97->ext_id & AC97_EI_SPDIF) { in snd_ac97_mixer()
2280 …ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_32000; in snd_ac97_mixer()
2282 if (ac97->ext_id & AC97_EI_VRM) { /* MIC VRA support */ in snd_ac97_mixer()
2283 snd_ac97_determine_rates(ac97, AC97_PCM_MIC_ADC_RATE, 0, &ac97->rates[AC97_RATES_MIC_ADC]); in snd_ac97_mixer()
2285 ac97->rates[AC97_RATES_MIC_ADC] = SNDRV_PCM_RATE_48000; in snd_ac97_mixer()
2287 if (ac97->ext_id & AC97_EI_SDAC) { /* SDAC support */ in snd_ac97_mixer()
2288 …snd_ac97_determine_rates(ac97, AC97_PCM_SURR_DAC_RATE, AC97_PCM_FRONT_DAC_RATE, &ac97->rates[AC97_… in snd_ac97_mixer()
2289 ac97->scaps |= AC97_SCAP_SURROUND_DAC; in snd_ac97_mixer()
2291 if (ac97->ext_id & AC97_EI_LDAC) { /* LDAC support */ in snd_ac97_mixer()
2292 …snd_ac97_determine_rates(ac97, AC97_PCM_LFE_DAC_RATE, AC97_PCM_FRONT_DAC_RATE, &ac97->rates[AC97_R… in snd_ac97_mixer()
2293 ac97->scaps |= AC97_SCAP_CENTER_LFE_DAC; in snd_ac97_mixer()
2297 bus->ops->init(ac97); in snd_ac97_mixer()
2298 snd_ac97_get_name(ac97, ac97->id, name, !ac97_is_audio(ac97)); in snd_ac97_mixer()
2299 …snd_ac97_get_name(NULL, ac97->id, name, !ac97_is_audio(ac97)); // ac97->id might be changed in th… in snd_ac97_mixer()
2300 if (! ac97->build_ops) in snd_ac97_mixer()
2301 ac97->build_ops = &null_build_ops; in snd_ac97_mixer()
2303 if (ac97_is_audio(ac97)) { in snd_ac97_mixer()
2313 sprintf(comp, "AC97a:%08x", ac97->id); in snd_ac97_mixer()
2316 snd_ac97_free(ac97); in snd_ac97_mixer()
2319 if (snd_ac97_mixer_build(ac97) < 0) { in snd_ac97_mixer()
2320 snd_ac97_free(ac97); in snd_ac97_mixer()
2324 if (ac97_is_modem(ac97)) { in snd_ac97_mixer()
2334 sprintf(comp, "AC97m:%08x", ac97->id); in snd_ac97_mixer()
2337 snd_ac97_free(ac97); in snd_ac97_mixer()
2340 if (snd_ac97_modem_build(card, ac97) < 0) { in snd_ac97_mixer()
2341 snd_ac97_free(ac97); in snd_ac97_mixer()
2345 if (ac97_is_audio(ac97)) in snd_ac97_mixer()
2346 update_power_regs(ac97); in snd_ac97_mixer()
2347 snd_ac97_proc_init(ac97); in snd_ac97_mixer()
2348 err = snd_device_new(card, SNDRV_DEV_CODEC, ac97, &ops); in snd_ac97_mixer()
2350 snd_ac97_free(ac97); in snd_ac97_mixer()
2353 *rac97 = ac97; in snd_ac97_mixer()
2365 static void snd_ac97_powerdown(struct snd_ac97 *ac97) in snd_ac97_powerdown() argument
2369 if (ac97_is_audio(ac97)) { in snd_ac97_powerdown()
2371 snd_ac97_write(ac97, AC97_MASTER, 0x9f9f); in snd_ac97_powerdown()
2372 snd_ac97_write(ac97, AC97_HEADPHONE, 0x9f9f); in snd_ac97_powerdown()
2376 power = ac97->regs[AC97_EXTENDED_STATUS]; in snd_ac97_powerdown()
2377 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) in snd_ac97_powerdown()
2379 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) in snd_ac97_powerdown()
2382 snd_ac97_write(ac97, AC97_EXTENDED_STATUS, power); in snd_ac97_powerdown()
2385 if (ac97->scaps & AC97_SCAP_INV_EAPD) in snd_ac97_powerdown()
2386 power = ac97->regs[AC97_POWERDOWN] & ~AC97_PD_EAPD; in snd_ac97_powerdown()
2387 else if (! (ac97->scaps & AC97_SCAP_EAPD_LED)) in snd_ac97_powerdown()
2388 power = ac97->regs[AC97_POWERDOWN] | AC97_PD_EAPD; in snd_ac97_powerdown()
2391 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2394 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2395 if (ac97_is_power_save_mode(ac97)) { in snd_ac97_powerdown()
2397 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2402 snd_ac97_write(ac97, AC97_POWERDOWN, power); in snd_ac97_powerdown()
2429 * @ac97: the codec instance
2433 * Update the AC97 powerdown register bits of the given part.
2437 int snd_ac97_update_power(struct snd_ac97 *ac97, int reg, int powerup) in snd_ac97_update_power() argument
2441 if (! ac97) in snd_ac97_update_power()
2451 ac97->power_up |= (1 << i); in snd_ac97_update_power()
2453 ac97->power_up &= ~(1 << i); in snd_ac97_update_power()
2459 if (ac97_is_power_save_mode(ac97) && !powerup) in snd_ac97_update_power()
2464 schedule_delayed_work(&ac97->power_work, in snd_ac97_update_power()
2467 cancel_delayed_work(&ac97->power_work); in snd_ac97_update_power()
2468 update_power_regs(ac97); in snd_ac97_update_power()
2477 static void update_power_regs(struct snd_ac97 *ac97) in update_power_regs() argument
2484 if (ac97->scaps & AC97_SCAP_SURROUND_DAC) in update_power_regs()
2486 if (ac97->scaps & AC97_SCAP_CENTER_LFE_DAC) in update_power_regs()
2489 if (ac97_is_power_save_mode(ac97)) in update_power_regs()
2490 power_up = ac97->power_up; in update_power_regs()
2493 if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) { in update_power_regs()
2495 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2498 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2507 snd_ac97_update_bits(ac97, power_regs[i].power_reg, in update_power_regs()
2511 if (! (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2)) { in update_power_regs()
2513 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2515 snd_ac97_update_bits(ac97, AC97_POWERDOWN, in update_power_regs()
2524 * snd_ac97_suspend - General suspend function for AC97 codec
2525 * @ac97: the ac97 instance
2529 void snd_ac97_suspend(struct snd_ac97 *ac97) in snd_ac97_suspend() argument
2531 if (! ac97) in snd_ac97_suspend()
2533 if (ac97->build_ops->suspend) in snd_ac97_suspend()
2534 ac97->build_ops->suspend(ac97); in snd_ac97_suspend()
2536 cancel_delayed_work_sync(&ac97->power_work); in snd_ac97_suspend()
2538 snd_ac97_powerdown(ac97); in snd_ac97_suspend()
2544 * restore ac97 status
2546 static void snd_ac97_restore_status(struct snd_ac97 *ac97) in snd_ac97_restore_status() argument
2557 if (test_bit(i, ac97->reg_accessed)) { in snd_ac97_restore_status()
2558 snd_ac97_write(ac97, i, ac97->regs[i]); in snd_ac97_restore_status()
2559 snd_ac97_read(ac97, i); in snd_ac97_restore_status()
2567 static void snd_ac97_restore_iec958(struct snd_ac97 *ac97) in snd_ac97_restore_iec958() argument
2569 if (ac97->ext_id & AC97_EI_SPDIF) { in snd_ac97_restore_iec958()
2570 if (ac97->regs[AC97_EXTENDED_STATUS] & AC97_EA_SPDIF) { in snd_ac97_restore_iec958()
2572 snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, 0); in snd_ac97_restore_iec958()
2573 snd_ac97_write(ac97, AC97_EXTENDED_STATUS, ac97->regs[AC97_EXTENDED_STATUS]); in snd_ac97_restore_iec958()
2574 if (ac97->flags & AC97_CS_SPDIF) in snd_ac97_restore_iec958()
2575 snd_ac97_write(ac97, AC97_CSR_SPDIF, ac97->regs[AC97_CSR_SPDIF]); in snd_ac97_restore_iec958()
2577 snd_ac97_write(ac97, AC97_SPDIF, ac97->regs[AC97_SPDIF]); in snd_ac97_restore_iec958()
2578 …snd_ac97_update_bits(ac97, AC97_EXTENDED_STATUS, AC97_EA_SPDIF, AC97_EA_SPDIF); /* turn on again */ in snd_ac97_restore_iec958()
2584 * snd_ac97_resume - General resume function for AC97 codec
2585 * @ac97: the ac97 instance
2590 void snd_ac97_resume(struct snd_ac97 *ac97) in snd_ac97_resume() argument
2594 if (! ac97) in snd_ac97_resume()
2597 if (ac97->bus->ops->reset) { in snd_ac97_resume()
2598 ac97->bus->ops->reset(ac97); in snd_ac97_resume()
2602 snd_ac97_write(ac97, AC97_POWERDOWN, 0); in snd_ac97_resume()
2603 if (! (ac97->flags & AC97_DEFAULT_POWER_OFF)) { in snd_ac97_resume()
2604 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) in snd_ac97_resume()
2605 snd_ac97_write(ac97, AC97_RESET, 0); in snd_ac97_resume()
2606 else if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_resume()
2607 snd_ac97_write(ac97, AC97_EXTENDED_MID, 0); in snd_ac97_resume()
2609 snd_ac97_write(ac97, AC97_POWERDOWN, 0); in snd_ac97_resume()
2611 snd_ac97_write(ac97, AC97_GENERAL_PURPOSE, 0); in snd_ac97_resume()
2613 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]); in snd_ac97_resume()
2614 if (ac97_is_audio(ac97)) { in snd_ac97_resume()
2615 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101); in snd_ac97_resume()
2618 if (snd_ac97_read(ac97, AC97_MASTER) == 0x8101) in snd_ac97_resume()
2623 ac97->bus->ops->write(ac97, AC97_MASTER, AC97_MUTE_MASK_MONO); in snd_ac97_resume()
2624 if (snd_ac97_read(ac97, AC97_MASTER) != AC97_MUTE_MASK_MONO) in snd_ac97_resume()
2629 unsigned short val = snd_ac97_read(ac97, AC97_EXTENDED_MID); in snd_ac97_resume()
2637 if (ac97->bus->ops->init) in snd_ac97_resume()
2638 ac97->bus->ops->init(ac97); in snd_ac97_resume()
2640 if (ac97->build_ops->resume) in snd_ac97_resume()
2641 ac97->build_ops->resume(ac97); in snd_ac97_resume()
2643 snd_ac97_restore_status(ac97); in snd_ac97_resume()
2644 snd_ac97_restore_iec958(ac97); in snd_ac97_resume()
2661 pr_warn("ALSA: AC97 control name '%s %s' truncated to '%s'\n", in set_ctl_name()
2665 pr_warn("ALSA: AC97 control name '%s' truncated to '%s'\n", in set_ctl_name()
2671 static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, in snd_ac97_remove_ctl() argument
2678 return snd_ctl_remove_id(ac97->bus->card, &id); in snd_ac97_remove_ctl()
2681 static struct snd_kcontrol *ctl_find(struct snd_ac97 *ac97, const char *name, const char *suffix) in ctl_find() argument
2687 return snd_ctl_find_id(ac97->bus->card, &sid); in ctl_find()
2691 static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, in snd_ac97_rename_ctl() argument
2694 struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); in snd_ac97_rename_ctl()
2699 snd_ctl_rename(ac97->bus->card, kctl, name); in snd_ac97_rename_ctl()
2706 static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, in snd_ac97_rename_vol_ctl() argument
2709 snd_ac97_rename_ctl(ac97, src, dst, "Switch"); in snd_ac97_rename_vol_ctl()
2710 snd_ac97_rename_ctl(ac97, src, dst, "Volume"); in snd_ac97_rename_vol_ctl()
2714 static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, in snd_ac97_swap_ctl() argument
2720 kctl1 = ctl_find(ac97, s1, suffix); in snd_ac97_swap_ctl()
2721 kctl2 = ctl_find(ac97, s2, suffix); in snd_ac97_swap_ctl()
2724 snd_ctl_rename(ac97->bus->card, kctl1, name); in snd_ac97_swap_ctl()
2727 snd_ctl_rename(ac97->bus->card, kctl2, name); in snd_ac97_swap_ctl()
2748 /* ac97 tune: bind Master and Headphone controls */
2749 static int tune_hp_only(struct snd_ac97 *ac97) in tune_hp_only() argument
2751 struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); in tune_hp_only()
2752 struct snd_kcontrol *mvol = ctl_find(ac97, "Master Playback Volume", NULL); in tune_hp_only()
2757 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch"); in tune_hp_only()
2758 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume"); in tune_hp_only()
2763 /* ac97 tune: use Headphone control as master */
2764 static int tune_hp_only(struct snd_ac97 *ac97) in tune_hp_only() argument
2766 if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL) in tune_hp_only()
2768 snd_ac97_remove_ctl(ac97, "Master Playback", "Switch"); in tune_hp_only()
2769 snd_ac97_remove_ctl(ac97, "Master Playback", "Volume"); in tune_hp_only()
2770 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); in tune_hp_only()
2775 /* ac97 tune: swap Headphone and Master controls */
2776 static int tune_swap_hp(struct snd_ac97 *ac97) in tune_swap_hp() argument
2778 if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL) in tune_swap_hp()
2780 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Line-Out Playback"); in tune_swap_hp()
2781 snd_ac97_rename_vol_ctl(ac97, "Headphone Playback", "Master Playback"); in tune_swap_hp()
2785 /* ac97 tune: swap Surround and Master controls */
2786 static int tune_swap_surround(struct snd_ac97 *ac97) in tune_swap_surround() argument
2788 if (snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Switch") || in tune_swap_surround()
2789 snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Volume")) in tune_swap_surround()
2794 /* ac97 tune: set up mic sharing for AD codecs */
2795 static int tune_ad_sharing(struct snd_ac97 *ac97) in tune_ad_sharing() argument
2798 if ((ac97->id & 0xffffff00) != 0x41445300) { in tune_ad_sharing()
2799 ac97_err(ac97, "ac97_quirk AD_SHARING is only for AD codecs\n"); in tune_ad_sharing()
2803 scfg = snd_ac97_read(ac97, AC97_AD_SERIAL_CFG); in tune_ad_sharing()
2804 snd_ac97_write_cache(ac97, AC97_AD_SERIAL_CFG, scfg | 0x0200); in tune_ad_sharing()
2811 /* ac97 tune: set up ALC jack-select */
2812 static int tune_alc_jack(struct snd_ac97 *ac97) in tune_alc_jack() argument
2814 if ((ac97->id & 0xffffff00) != 0x414c4700) { in tune_alc_jack()
2815 ac97_err(ac97, in tune_alc_jack()
2819 snd_ac97_update_bits(ac97, 0x7a, 0x20, 0x20); /* select jack detect function */ in tune_alc_jack()
2820 snd_ac97_update_bits(ac97, 0x7a, 0x01, 0x01); /* Line-out auto mute */ in tune_alc_jack()
2821 if (ac97->id == AC97_ID_ALC658D) in tune_alc_jack()
2822 snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800); in tune_alc_jack()
2823 return snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_alc_jack_detect, ac97)); in tune_alc_jack()
2826 /* ac97 tune: inversed EAPD bit */
2827 static int tune_inv_eapd(struct snd_ac97 *ac97) in tune_inv_eapd() argument
2829 struct snd_kcontrol *kctl = ctl_find(ac97, "External Amplifier", NULL); in tune_inv_eapd()
2832 set_inv_eapd(ac97, kctl); in tune_inv_eapd()
2840 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in master_mute_sw_put() local
2848 snd_ac97_update_bits(ac97, AC97_POWERDOWN, AC97_PD_EAPD, in master_mute_sw_put()
2849 (ac97->regs[AC97_MASTER] & mask) == mask ? in master_mute_sw_put()
2855 /* ac97 tune: EAPD controls mute LED bound with the master mute */
2856 static int tune_mute_led(struct snd_ac97 *ac97) in tune_mute_led() argument
2858 struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); in tune_mute_led()
2862 snd_ac97_remove_ctl(ac97, "External Amplifier", NULL); in tune_mute_led()
2864 ac97, AC97_POWERDOWN, in tune_mute_led()
2867 ac97->scaps |= AC97_SCAP_EAPD_LED; in tune_mute_led()
2876 struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); in hp_master_mute_sw_put() local
2884 snd_ac97_update_bits(ac97, AC97_POWERDOWN, AC97_PD_EAPD, in hp_master_mute_sw_put()
2885 (ac97->regs[AC97_MASTER] & mask) == mask ? in hp_master_mute_sw_put()
2891 static int tune_hp_mute_led(struct snd_ac97 *ac97) in tune_hp_mute_led() argument
2893 struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); in tune_hp_mute_led()
2894 struct snd_kcontrol *mvol = ctl_find(ac97, "Master Playback Volume", NULL); in tune_hp_mute_led()
2899 snd_ac97_remove_ctl(ac97, "External Amplifier", NULL); in tune_hp_mute_led()
2900 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch"); in tune_hp_mute_led()
2901 snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume"); in tune_hp_mute_led()
2903 ac97, AC97_POWERDOWN, in tune_hp_mute_led()
2927 static int apply_quirk(struct snd_ac97 *ac97, int type) in apply_quirk() argument
2934 return applicable_quirks[type].func(ac97); in apply_quirk()
2939 static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr) in apply_quirk_str() argument
2947 return apply_quirk(ac97, i); in apply_quirk_str()
2951 return apply_quirk(ac97, (int)simple_strtoul(typestr, NULL, 10)); in apply_quirk_str()
2957 * @ac97: the ac97 instance
2968 int snd_ac97_tune_hardware(struct snd_ac97 *ac97, in snd_ac97_tune_hardware() argument
2975 result = apply_quirk_str(ac97, override); in snd_ac97_tune_hardware()
2977 ac97_err(ac97, "applying quirk type %s failed (%d)\n", in snd_ac97_tune_hardware()
2986 if (quirk->subvendor != ac97->subsystem_vendor) in snd_ac97_tune_hardware()
2988 if ((! quirk->mask && quirk->subdevice == ac97->subsystem_device) || in snd_ac97_tune_hardware()
2989 quirk->subdevice == (quirk->mask & ac97->subsystem_device)) { in snd_ac97_tune_hardware()
2990 if (quirk->codec_id && quirk->codec_id != ac97->id) in snd_ac97_tune_hardware()
2992 ac97_dbg(ac97, "ac97 quirk for %s (%04x:%04x)\n", in snd_ac97_tune_hardware()
2993 quirk->name, ac97->subsystem_vendor, in snd_ac97_tune_hardware()
2994 ac97->subsystem_device); in snd_ac97_tune_hardware()
2995 result = apply_quirk(ac97, quirk->type); in snd_ac97_tune_hardware()
2997 ac97_err(ac97, in snd_ac97_tune_hardware()