Lines Matching +full:mic2 +full:- +full:src
1 // SPDX-License-Identifier: GPL-2.0-or-later
38 MODULE_PARM_DESC(power_save, "Automatic power-saving timeout "
62 * currently used by the AC97 emulation of the almost-AC97 PCI168 card.
65 { 0x434d4900, 0xffffff00, "C-Media Electronics", NULL, NULL },
139 { 0x43585430, 0xffffffff, "Cx20468-31", patch_conexant, NULL },
152 { 0x4e534300, 0xffffffff, "LM4540,43,45,46,48", NULL, NULL }, // only guess --jk
162 { 0x54524123, 0xffffffff, "TR28602", NULL, NULL }, // only guess --jk [TR28023 = eMicro EM28023 (…
198 ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save)
204 dev_err((ac97)->bus->card->dev, fmt, ##args)
206 dev_warn((ac97)->bus->card->dev, fmt, ##args)
208 dev_dbg((ac97)->bus->card->dev, fmt, ##args)
217 switch (ac97->id) { in snd_ac97_valid_reg()
239 case AC97_ID_AD1886A: /* AD1886A - !!verify!! --jk */ in snd_ac97_valid_reg()
240 case AC97_ID_AD1887: /* AD1887 - !!verify!! --jk */ in snd_ac97_valid_reg()
261 * snd_ac97_write - write a value on the given register
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()
287 * snd_ac97_read - read a value from the given register
301 return ac97->bus->ops->read(ac97, reg); in snd_ac97_read()
304 /* read a register - return the cached value if already read */
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()
309 // set_bit(reg, ac97->reg_accessed); in snd_ac97_read_cache()
311 return ac97->regs[reg]; in snd_ac97_read_cache()
317 * snd_ac97_write_cache - write a value on the given register and update the cache
323 * cache. The cached values are used for the cached-read and the
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()
340 * snd_ac97_update - update the value on the given register
356 return -EINVAL; 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()
371 * snd_ac97_update_bits - update the bits on the given register
374 * @mask: the bit-mask to change
377 * Updates the masked-bits on the given register only when the value
388 return -EINVAL; in snd_ac97_update_bits()
389 mutex_lock(&ac97->reg_mutex); in snd_ac97_update_bits()
391 mutex_unlock(&ac97->reg_mutex); in snd_ac97_update_bits()
397 /* no lock version - see snd_ac97_update_bits() */
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()
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()
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()
450 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; in snd_ac97_info_enum_double()
452 return snd_ctl_enum_info(uinfo, e->shift_l == e->shift_r ? 1 : 2, in snd_ac97_info_enum_double()
453 e->mask, e->texts); in snd_ac97_info_enum_double()
460 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; in snd_ac97_get_enum_double()
463 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) in snd_ac97_get_enum_double()
465 val = snd_ac97_read_cache(ac97, e->reg); in snd_ac97_get_enum_double()
466 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); in snd_ac97_get_enum_double()
467 if (e->shift_l != e->shift_r) in snd_ac97_get_enum_double()
468 ucontrol->value.enumerated.item[1] = (val >> e->shift_r) & (bitmask - 1); in snd_ac97_get_enum_double()
477 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; in snd_ac97_put_enum_double()
481 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) in snd_ac97_put_enum_double()
483 if (ucontrol->value.enumerated.item[0] > e->mask - 1) in snd_ac97_put_enum_double()
484 return -EINVAL; in snd_ac97_put_enum_double()
485 val = ucontrol->value.enumerated.item[0] << e->shift_l; in snd_ac97_put_enum_double()
486 mask = (bitmask - 1) << e->shift_l; in snd_ac97_put_enum_double()
487 if (e->shift_l != e->shift_r) { in snd_ac97_put_enum_double()
488 if (ucontrol->value.enumerated.item[1] > e->mask - 1) in snd_ac97_put_enum_double()
489 return -EINVAL; in snd_ac97_put_enum_double()
490 val |= ucontrol->value.enumerated.item[1] << e->shift_r; in snd_ac97_put_enum_double()
491 mask |= (bitmask - 1) << e->shift_r; in snd_ac97_put_enum_double()
493 return snd_ac97_update_bits(ac97, e->reg, mask, val); in snd_ac97_put_enum_double()
499 int page_save = -1; in snd_ac97_page_save()
500 if ((kcontrol->private_value & (1<<25)) && in snd_ac97_page_save()
501 (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && in snd_ac97_page_save()
503 unsigned short page = (kcontrol->private_value >> 26) & 0x0f; in snd_ac97_page_save()
504 mutex_lock(&ac97->page_mutex); /* lock paging */ in snd_ac97_page_save()
515 mutex_unlock(&ac97->page_mutex); /* unlock paging */ in snd_ac97_page_restore()
523 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_info_volsw()
524 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_info_volsw()
525 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_info_volsw()
527 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ac97_info_volsw()
528 uinfo->count = shift == rshift ? 1 : 2; in snd_ac97_info_volsw()
529 uinfo->value.integer.min = 0; in snd_ac97_info_volsw()
530 uinfo->value.integer.max = mask; in snd_ac97_info_volsw()
538 int reg = kcontrol->private_value & 0xff; in snd_ac97_get_volsw()
539 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_get_volsw()
540 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_get_volsw()
541 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_get_volsw()
542 int invert = (kcontrol->private_value >> 24) & 0x01; 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()
550 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_ac97_get_volsw()
552 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_ac97_get_volsw()
562 int reg = kcontrol->private_value & 0xff; in snd_ac97_put_volsw()
563 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_put_volsw()
564 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_put_volsw()
565 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_put_volsw()
566 int invert = (kcontrol->private_value >> 24) & 0x01; in snd_ac97_put_volsw()
571 val = (ucontrol->value.integer.value[0] & mask); in snd_ac97_put_volsw()
573 val = mask - val; in snd_ac97_put_volsw()
577 val2 = (ucontrol->value.integer.value[1] & mask); in snd_ac97_put_volsw()
579 val2 = mask - val2; in snd_ac97_put_volsw()
586 /* check analog mixer power-down */ in snd_ac97_put_volsw()
588 (kcontrol->private_value & (1<<30))) { 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()
600 AC97_SINGLE("Tone Control - Bass", AC97_MASTER_TONE, 8, 15, 1),
601 AC97_SINGLE("Tone Control - Treble", AC97_MASTER_TONE, 0, 15, 1)
616 static const char* std_mic[] = {"Mic1", "Mic2"};
649 AC97_SINGLE("3D Control - Switch", AC97_GENERAL_PURPOSE, 13, 1, 0),
657 AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0),
658 AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0)
675 AC97_SINGLE("Off-hook Switch", AC97_GPIO_STATUS, 0, 1, 0),
682 kctl->private_value = AC97_SINGLE_VALUE(AC97_POWERDOWN, 15, 1, 0); in set_inv_eapd()
684 ac97->scaps |= AC97_SCAP_INV_EAPD; in set_inv_eapd()
689 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_ac97_spdif_mask_info()
690 uinfo->count = 1; in snd_ac97_spdif_mask_info()
696 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_ac97_spdif_cmask_get()
700 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY | in snd_ac97_spdif_cmask_get()
702 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS; in snd_ac97_spdif_cmask_get()
709 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_ac97_spdif_pmask_get()
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()
736 new = val = ucontrol->value.iec958.status[0] & (IEC958_AES0_PROFESSIONAL|IEC958_AES0_NONAUDIO); in snd_ac97_spdif_default_put()
737 if (ucontrol->value.iec958.status[0] & IEC958_AES0_PROFESSIONAL) { in snd_ac97_spdif_default_put()
738 new |= ucontrol->value.iec958.status[0] & (IEC958_AES0_PRO_FS|IEC958_AES0_PRO_EMPHASIS_5015); in snd_ac97_spdif_default_put()
748 …new |= ucontrol->value.iec958.status[0] & (IEC958_AES0_CON_EMPHASIS_5015|IEC958_AES0_CON_NOT_COPYR… in snd_ac97_spdif_default_put()
749 …new |= ((ucontrol->value.iec958.status[1] & (IEC958_AES1_CON_CATEGORY|IEC958_AES1_CON_ORIGINAL)) <… in snd_ac97_spdif_default_put()
750 new |= ((ucontrol->value.iec958.status[3] & IEC958_AES3_CON_FS) << 24); in snd_ac97_spdif_default_put()
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()
776 } else if (ac97->flags & AC97_CX_SPDIF) { in snd_ac97_spdif_default_put()
783 } else if (ac97->id == AC97_ID_YMF743) { in snd_ac97_spdif_default_put()
798 mutex_unlock(&ac97->reg_mutex); in snd_ac97_spdif_default_put()
806 int reg = kcontrol->private_value & 0xff; in snd_ac97_put_spsa()
807 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_put_spsa()
808 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_put_spsa()
809 // int invert = (kcontrol->private_value >> 24) & 0xff; in snd_ac97_put_spsa()
813 value = (ucontrol->value.integer.value[0] & mask); in snd_ac97_put_spsa()
815 mutex_lock(&ac97->reg_mutex); in snd_ac97_put_spsa()
829 mutex_unlock(&ac97->reg_mutex); in snd_ac97_put_spsa()
859 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA",
875 int mask = (kcontrol->private_value >> 16) & 0x0f; in snd_ac97_ad18xx_pcm_info_bits()
876 int lshift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_ad18xx_pcm_info_bits()
877 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_ad18xx_pcm_info_bits()
879 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ac97_ad18xx_pcm_info_bits()
880 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) in snd_ac97_ad18xx_pcm_info_bits()
881 uinfo->count = 2; in snd_ac97_ad18xx_pcm_info_bits()
883 uinfo->count = 1; in snd_ac97_ad18xx_pcm_info_bits()
884 uinfo->value.integer.min = 0; in snd_ac97_ad18xx_pcm_info_bits()
885 uinfo->value.integer.max = mask; in snd_ac97_ad18xx_pcm_info_bits()
892 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_get_bits()
893 int lshift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_ad18xx_pcm_get_bits()
894 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_ad18xx_pcm_get_bits()
895 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_ad18xx_pcm_get_bits()
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()
906 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_put_bits()
907 int lshift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_ad18xx_pcm_put_bits()
908 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_ad18xx_pcm_put_bits()
909 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_ad18xx_pcm_put_bits()
912 val = (mask - (ucontrol->value.integer.value[0] & mask)) << lshift; in snd_ac97_ad18xx_pcm_put_bits()
914 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_ad18xx_pcm_put_bits()
915 val |= (mask - (ucontrol->value.integer.value[1] & mask)) << rshift; in snd_ac97_ad18xx_pcm_put_bits()
928 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ac97_ad18xx_pcm_info_volume()
929 uinfo->count = 2; in snd_ac97_ad18xx_pcm_info_volume()
930 uinfo->value.integer.min = 0; in snd_ac97_ad18xx_pcm_info_volume()
931 uinfo->value.integer.max = 31; in snd_ac97_ad18xx_pcm_info_volume()
938 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_get_volume()
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()
950 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_put_volume()
953 val1 = 31 - (ucontrol->value.integer.value[0] & 31); in snd_ac97_ad18xx_pcm_put_volume()
954 val2 = 31 - (ucontrol->value.integer.value[1] & 31); in snd_ac97_ad18xx_pcm_put_volume()
988 kfree(bus->pcms); in snd_ac97_bus_free()
989 if (bus->private_free) in snd_ac97_bus_free()
990 bus->private_free(bus); in snd_ac97_bus_free()
998 struct snd_ac97_bus *bus = device->device_data; in snd_ac97_bus_dev_free()
1006 cancel_delayed_work_sync(&ac97->power_work); 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()
1020 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_free()
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()
1042 /* if nonzero - fixed and we can't set it */ 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()
1064 /* nothing seems to be here - mute flag is not set */ in snd_ac97_try_volume_mix()
1082 if (ac97->res_table) { in check_volume_resolution()
1084 for (tbl = ac97->res_table; tbl->reg; tbl++) { in check_volume_resolution()
1085 if (tbl->reg == reg) { in check_volume_resolution()
1086 *lo_max = tbl->bits & 0xff; in check_volume_resolution()
1087 *hi_max = (tbl->bits >> 8) & 0xff; in check_volume_resolution()
1149 return x - 0x71 + 'A'; in printable()
1160 template.index = ac97->num; in snd_ac97_cnew()
1180 if (check_stereo || (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_cmute_new_stereo()
1191 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1197 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1211 static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
1212 static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
1213 static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
1214 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
1229 kctl->tlv.p = tlv; in set_tlv_db_scale()
1231 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; in set_tlv_db_scale()
1248 tmp.index = ac97->num; in snd_ac97_cvol_new()
1253 tmp.index = ac97->num; in snd_ac97_cvol_new()
1257 return -ENOMEM; in snd_ac97_cvol_new()
1274 * create a mute-switch and a volume for normal stereo/mono controls
1314 struct snd_card *card = ac97->bus->card; in snd_ac97_mixer_build()
1323 if (ac97->flags & AC97_HAS_NO_MASTER_VOL) in snd_ac97_mixer_build()
1333 ac97->regs[AC97_CENTER_LFE_MASTER] = AC97_MUTE_MASK_STEREO; in snd_ac97_mixer_build()
1337 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1345 kctl->private_value &= ~(0xff << 16); in snd_ac97_mixer_build()
1346 kctl->private_value |= (int)max << 16; 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()
1353 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1361 kctl->private_value &= ~(0xff << 16); in snd_ac97_mixer_build()
1362 kctl->private_value |= (int)max << 16; 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()
1369 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1395 if (!(ac97->flags & AC97_HAS_NO_TONE)) { 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()
1404 kctl->private_value &= ~(0xff << 16); in snd_ac97_mixer_build()
1405 kctl->private_value |= 7 << 16; 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()
1432 if (!(ac97->flags & AC97_HAS_NO_PHONE)) { in snd_ac97_mixer_build()
1442 if (!(ac97->flags & AC97_HAS_NO_MIC)) { in snd_ac97_mixer_build()
1463 if (!(ac97->flags & AC97_HAS_NO_CD)) { in snd_ac97_mixer_build()
1473 if (!(ac97->flags & AC97_HAS_NO_VIDEO)) { in snd_ac97_mixer_build()
1483 if (!(ac97->flags & AC97_HAS_NO_AUX)) { 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()
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()
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()
1532 ac97->spec.ad18xx.pcmreg[2] = 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()
1550 if (!(ac97->flags & AC97_HAS_NO_REC_GAIN)) { in snd_ac97_mixer_build()
1588 if (ac97->caps & AC97_BC_SIM_STEREO) { in snd_ac97_mixer_build()
1602 if (ac97->caps & AC97_BC_LOUDNESS) { 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()
1646 kctl->private_value = AC97_3D_CONTROL | (9 << 8) | (7 << 16); in snd_ac97_mixer_build()
1652 kctl->private_value = AC97_3D_CONTROL | (1 << 8) | (7 << 16); in snd_ac97_mixer_build()
1659 /* Hack for ASUS P5P800-VM, which does not indicate S/PDIF capability */ 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()
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()
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()
1698 return -ENOMEM; in snd_ac97_mixer_build()
1699 if (ac97->scaps & AC97_SCAP_INV_EAPD) in snd_ac97_mixer_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()
1745 tmp = ((unsigned int)rate * ac97->bus->clock) / 48000; in snd_ac97_test_rate()
1758 if (ac97->bus->no_vra) { in snd_ac97_determine_rates()
1760 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1767 if ((ac97->ext_id & AC97_EI_DRA) && reg == AC97_PCM_FRONT_DAC_RATE) in snd_ac97_determine_rates()
1770 /* test a non-standard rate */ in snd_ac97_determine_rates()
1788 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1838 for (pid = table; pid->id; pid++) in look_for_codec_id()
1839 if (pid->id == (id & pid->mask)) in look_for_codec_id()
1856 strcpy(name, pid->name); in snd_ac97_get_name()
1857 if (ac97 && pid->patch) { in snd_ac97_get_name()
1858 if ((modem && (pid->flags & AC97_MODEM_PATCH)) || in snd_ac97_get_name()
1859 (! modem && ! (pid->flags & AC97_MODEM_PATCH))) in snd_ac97_get_name()
1860 pid->patch(ac97); in snd_ac97_get_name()
1866 strcat(name, pid->name); in snd_ac97_get_name()
1867 if (pid->mask != 0xffffffff) in snd_ac97_get_name()
1868 sprintf(name + strlen(name), " rev %d", id & ~pid->mask); in snd_ac97_get_name()
1869 if (ac97 && pid->patch) { in snd_ac97_get_name()
1870 if ((modem && (pid->flags & AC97_MODEM_PATCH)) || in snd_ac97_get_name()
1871 (! modem && ! (pid->flags & AC97_MODEM_PATCH))) in snd_ac97_get_name()
1872 pid->patch(ac97); in snd_ac97_get_name()
1879 * snd_ac97_get_short_name - retrieve codec name
1888 for (pid = snd_ac97_codec_ids; pid->id; pid++) in snd_ac97_get_short_name()
1889 if (pid->id == (ac97->id & pid->mask)) in snd_ac97_get_short_name()
1890 return pid->name; in snd_ac97_get_short_name()
1917 if (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) { in ac97_reset_wait()
1918 /* probably only Xbox issue - all registers are read as zero */ in ac97_reset_wait()
1933 return -ENODEV; in ac97_reset_wait()
1937 * snd_ac97_bus - create an AC97 bus component
1951 * ``(*rbus)->clock`` manually.
1953 * The AC97 bus instance is registered as a low-level device, so you don't
1969 return -EINVAL; in snd_ac97_bus()
1972 return -ENOMEM; in snd_ac97_bus()
1973 bus->card = card; in snd_ac97_bus()
1974 bus->num = num; in snd_ac97_bus()
1975 bus->ops = ops; in snd_ac97_bus()
1976 bus->private_data = private_data; in snd_ac97_bus()
1977 bus->clock = 48000; in snd_ac97_bus()
1978 spin_lock_init(&bus->bus_lock); in snd_ac97_bus()
2000 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_register()
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()
2009 err = device_register(&ac97->dev); 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()
2023 if (ac97->dev.bus) in snd_ac97_dev_disconnect()
2024 device_unregister(&ac97->dev); in snd_ac97_dev_disconnect()
2040 * snd_ac97_mixer - create an Codec97 component
2053 * The ac97 instance is registered as a low-level device, so you don't
2076 return -EINVAL; in snd_ac97_mixer()
2077 if (snd_BUG_ON(template->num >= 4)) in snd_ac97_mixer()
2078 return -EINVAL; in snd_ac97_mixer()
2079 if (bus->codec[template->num]) in snd_ac97_mixer()
2080 return -EBUSY; in snd_ac97_mixer()
2082 card = bus->card; in snd_ac97_mixer()
2085 return -ENOMEM; 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()
2107 if (bus->ops->reset) { 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()
2116 if (pid && (pid->flags & AC97_DEFAULT_POWER_OFF)) in snd_ac97_mixer()
2121 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) in snd_ac97_mixer()
2123 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_mixer()
2125 if (bus->ops->wait) 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()
2138 ac97_warn(ac97, "AC'97 %d does not respond - RESET\n", in snd_ac97_mixer()
2139 ac97->num); in snd_ac97_mixer()
2140 /* proceed anyway - it's often non-critical */ 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()
2150 ac97->num, ac97->id); in snd_ac97_mixer()
2152 return -EIO; 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()
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()
2183 if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM))) in snd_ac97_mixer()
2186 ac97->num); in snd_ac97_mixer()
2188 return -EACCES; in snd_ac97_mixer()
2191 if (bus->ops->reset) // FIXME: always skipping? in snd_ac97_mixer()
2198 if (! (ac97->flags & AC97_DEFAULT_POWER_OFF)) { in snd_ac97_mixer()
2212 "AC'97 %d analog subsections not ready\n", ac97->num); in snd_ac97_mixer()
2222 if (ac97->ext_mid & AC97_MEI_LINE1) { in snd_ac97_mixer()
2226 if (ac97->ext_mid & AC97_MEI_LINE2) { in snd_ac97_mixer()
2230 if (ac97->ext_mid & AC97_MEI_HANDSET) { in snd_ac97_mixer()
2246 ac97->num, 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()
2257 reg |= ac97->ext_id & 0x01c0; /* LDAC/SDAC/CDAC */ in snd_ac97_mixer()
2258 if (! bus->no_vra) in snd_ac97_mixer()
2259 reg |= ac97->ext_id & 0x0009; /* VRA/VRM */ in snd_ac97_mixer()
2262 if ((ac97->ext_id & AC97_EI_DRA) && bus->dra) { in snd_ac97_mixer()
2267 ac97->flags |= AC97_DOUBLE_RATE; 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()
2282 …ac97->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()
2298 if (bus->ops->init) 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()
2307 if (card->mixername[0] == '\0') { in snd_ac97_mixer()
2308 strcpy(card->mixername, name); in snd_ac97_mixer()
2310 if (strlen(card->mixername) + 1 + strlen(name) + 1 <= sizeof(card->mixername)) { in snd_ac97_mixer()
2311 strcat(card->mixername, ","); in snd_ac97_mixer()
2312 strcat(card->mixername, name); in snd_ac97_mixer()
2315 sprintf(comp, "AC97a:%08x", ac97->id); in snd_ac97_mixer()
2323 return -ENOMEM; in snd_ac97_mixer()
2328 if (card->mixername[0] == '\0') { in snd_ac97_mixer()
2329 strcpy(card->mixername, name); in snd_ac97_mixer()
2331 if (strlen(card->mixername) + 1 + strlen(name) + 1 <= sizeof(card->mixername)) { in snd_ac97_mixer()
2332 strcat(card->mixername, ","); in snd_ac97_mixer()
2333 strcat(card->mixername, name); in snd_ac97_mixer()
2336 sprintf(comp, "AC97m:%08x", ac97->id); in snd_ac97_mixer()
2344 return -ENOMEM; in snd_ac97_mixer()
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()
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()
2401 /* AC-link powerdown, internal Clk disable */ in snd_ac97_powerdown()
2430 * snd_ac97_update_power - update the powerdown register
2433 * @powerup: non-zero when power up the part
2453 ac97->power_up |= (1 << i); in snd_ac97_update_power()
2455 ac97->power_up &= ~(1 << i); in snd_ac97_update_power()
2462 /* adjust power-down bits after two seconds delay 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()
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()
2492 power_up = ac97->power_up; in update_power_regs()
2495 if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) { in update_power_regs()
2496 /* needs power-up analog mix and vref */ in update_power_regs()
2513 if (! (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2)) { in update_power_regs()
2526 * snd_ac97_suspend - General suspend function for AC97 codec
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()
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()
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()
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()
2586 * snd_ac97_resume - General resume function for AC97 codec
2599 if (ac97->bus->ops->reset) { in snd_ac97_resume()
2600 ac97->bus->ops->reset(ac97); 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()
2608 else if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_resume()
2615 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]); in snd_ac97_resume()
2617 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101); in snd_ac97_resume()
2625 ac97->bus->ops->write(ac97, AC97_MASTER, AC97_MUTE_MASK_MONO); 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()
2657 static void set_ctl_name(char *dst, const char *src, const char *suffix) in set_ctl_name() argument
2662 if (snprintf(dst, msize, "%s %s", src, suffix) >= msize) in set_ctl_name()
2664 src, suffix, dst); in set_ctl_name()
2666 if (strscpy(dst, src, msize) < 0) in set_ctl_name()
2668 src, dst); in set_ctl_name()
2680 return snd_ctl_remove_id(ac97->bus->card, &id); in snd_ac97_remove_ctl()
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()
2704 return -ENOENT; in snd_ac97_rename_ctl()
2707 /* rename both Volume and Switch controls - don't check the return value */
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()
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()
2733 return -ENOENT; in snd_ac97_swap_ctl()
2742 unsigned long priv_saved = kcontrol->private_value; in bind_hp_volsw_put()
2743 kcontrol->private_value = (kcontrol->private_value & ~0xff) | AC97_HEADPHONE; in bind_hp_volsw_put()
2745 kcontrol->private_value = priv_saved; in bind_hp_volsw_put()
2756 return -ENOENT; in tune_hp_only()
2757 msw->put = bind_hp_volsw_put; in tune_hp_only()
2758 mvol->put = bind_hp_volsw_put; in tune_hp_only()
2769 return -ENOENT; in tune_hp_only()
2781 return -ENOENT; in tune_swap_hp()
2782 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Line-Out Playback"); in tune_swap_hp()
2792 return -ENOENT; in tune_swap_surround()
2800 if ((ac97->id & 0xffffff00) != 0x41445300) { in tune_ad_sharing()
2802 return -EINVAL; in tune_ad_sharing()
2813 /* ac97 tune: set up ALC jack-select */
2816 if ((ac97->id & 0xffffff00) != 0x414c4700) { in tune_alc_jack()
2819 return -EINVAL; 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()
2825 return snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_alc_jack_detect, ac97)); in tune_alc_jack()
2833 return -ENOENT; in tune_inv_eapd()
2843 int shift = (kcontrol->private_value >> 8) & 0x0f; in master_mute_sw_put()
2844 int rshift = (kcontrol->private_value >> 12) & 0x0f; in master_mute_sw_put()
2851 (ac97->regs[AC97_MASTER] & mask) == mask ? in master_mute_sw_put()
2862 return -ENOENT; in tune_mute_led()
2863 msw->put = master_mute_sw_put; in tune_mute_led()
2869 ac97->scaps |= AC97_SCAP_EAPD_LED; in tune_mute_led()
2879 int shift = (kcontrol->private_value >> 8) & 0x0f; in hp_master_mute_sw_put()
2880 int rshift = (kcontrol->private_value >> 12) & 0x0f; in hp_master_mute_sw_put()
2887 (ac97->regs[AC97_MASTER] & mask) == mask ? in hp_master_mute_sw_put()
2898 return -ENOENT; in tune_hp_mute_led()
2899 msw->put = hp_master_mute_sw_put; in tune_hp_mute_led()
2900 mvol->put = bind_hp_volsw_put; in tune_hp_mute_led()
2934 return -EINVAL; in apply_quirk()
2948 if (q->name && ! strcmp(typestr, q->name)) in apply_quirk_str()
2954 return -EINVAL; in apply_quirk_str()
2958 * snd_ac97_tune_hardware - tune up the hardware
2961 * @override: explicit quirk value (overrides the list if non-NULL)
2964 * headphone (true line-out) control as "Master".
2965 * The quirk-list must be terminated with a zero-filled entry.
2976 if (override && strcmp(override, "-1") && strcmp(override, "default")) { in snd_ac97_tune_hardware()
2985 return -EINVAL; in snd_ac97_tune_hardware()
2987 for (; quirk->subvendor; quirk++) { 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()
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()
3001 quirk->type, quirk->name, result); in snd_ac97_tune_hardware()