Lines Matching +full:mic1 +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
161 { 0x54524123, 0xffffffff, "TR28602", NULL, NULL }, // only guess --jk [TR28023 = eMicro EM28023 (…
197 ((ac97->scaps & AC97_SCAP_POWER_SAVE) && power_save)
203 dev_err((ac97)->bus->card->dev, fmt, ##args)
205 dev_warn((ac97)->bus->card->dev, fmt, ##args)
207 dev_dbg((ac97)->bus->card->dev, fmt, ##args)
216 switch (ac97->id) { in snd_ac97_valid_reg()
238 case AC97_ID_AD1886A: /* AD1886A - !!verify!! --jk */ in snd_ac97_valid_reg()
239 case AC97_ID_AD1887: /* AD1887 - !!verify!! --jk */ in snd_ac97_valid_reg()
260 * snd_ac97_write - write a value on the given register
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()
286 * snd_ac97_read - read a value from the given register
300 return ac97->bus->ops->read(ac97, reg); in snd_ac97_read()
303 /* read a register - return the cached value if already read */
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()
316 * snd_ac97_write_cache - write a value on the given register and update the cache
322 * cache. The cached values are used for the cached-read and the
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()
339 * snd_ac97_update - update the value on the given register
355 return -EINVAL; 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()
370 * snd_ac97_update_bits - update the bits on the given register
373 * @mask: the bit-mask to change
376 * Updates the masked-bits on the given register only when the value
387 return -EINVAL; in snd_ac97_update_bits()
388 mutex_lock(&ac97->reg_mutex); in snd_ac97_update_bits()
390 mutex_unlock(&ac97->reg_mutex); in snd_ac97_update_bits()
396 /* no lock version - see snd_ac97_update_bits() */
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()
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()
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()
449 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; in snd_ac97_info_enum_double()
451 return snd_ctl_enum_info(uinfo, e->shift_l == e->shift_r ? 1 : 2, in snd_ac97_info_enum_double()
452 e->mask, e->texts); in snd_ac97_info_enum_double()
459 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; in snd_ac97_get_enum_double()
462 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) in snd_ac97_get_enum_double()
464 val = snd_ac97_read_cache(ac97, e->reg); in snd_ac97_get_enum_double()
465 ucontrol->value.enumerated.item[0] = (val >> e->shift_l) & (bitmask - 1); in snd_ac97_get_enum_double()
466 if (e->shift_l != e->shift_r) in snd_ac97_get_enum_double()
467 ucontrol->value.enumerated.item[1] = (val >> e->shift_r) & (bitmask - 1); in snd_ac97_get_enum_double()
476 struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; in snd_ac97_put_enum_double()
480 for (bitmask = 1; bitmask < e->mask; bitmask <<= 1) in snd_ac97_put_enum_double()
482 if (ucontrol->value.enumerated.item[0] > e->mask - 1) in snd_ac97_put_enum_double()
483 return -EINVAL; in snd_ac97_put_enum_double()
484 val = ucontrol->value.enumerated.item[0] << e->shift_l; in snd_ac97_put_enum_double()
485 mask = (bitmask - 1) << e->shift_l; in snd_ac97_put_enum_double()
486 if (e->shift_l != e->shift_r) { in snd_ac97_put_enum_double()
487 if (ucontrol->value.enumerated.item[1] > e->mask - 1) in snd_ac97_put_enum_double()
488 return -EINVAL; in snd_ac97_put_enum_double()
489 val |= ucontrol->value.enumerated.item[1] << e->shift_r; in snd_ac97_put_enum_double()
490 mask |= (bitmask - 1) << e->shift_r; in snd_ac97_put_enum_double()
492 return snd_ac97_update_bits(ac97, e->reg, mask, val); in snd_ac97_put_enum_double()
498 int page_save = -1; in snd_ac97_page_save()
499 if ((kcontrol->private_value & (1<<25)) && in snd_ac97_page_save()
500 (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23 && in snd_ac97_page_save()
502 unsigned short page = (kcontrol->private_value >> 26) & 0x0f; in snd_ac97_page_save()
503 mutex_lock(&ac97->page_mutex); /* lock paging */ in snd_ac97_page_save()
514 mutex_unlock(&ac97->page_mutex); /* unlock paging */ in snd_ac97_page_restore()
522 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_info_volsw()
523 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_info_volsw()
524 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_info_volsw()
526 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ac97_info_volsw()
527 uinfo->count = shift == rshift ? 1 : 2; in snd_ac97_info_volsw()
528 uinfo->value.integer.min = 0; in snd_ac97_info_volsw()
529 uinfo->value.integer.max = mask; in snd_ac97_info_volsw()
537 int reg = kcontrol->private_value & 0xff; in snd_ac97_get_volsw()
538 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_get_volsw()
539 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_get_volsw()
540 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_get_volsw()
541 int invert = (kcontrol->private_value >> 24) & 0x01; 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()
549 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; in snd_ac97_get_volsw()
551 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; in snd_ac97_get_volsw()
561 int reg = kcontrol->private_value & 0xff; in snd_ac97_put_volsw()
562 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_put_volsw()
563 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_put_volsw()
564 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_put_volsw()
565 int invert = (kcontrol->private_value >> 24) & 0x01; in snd_ac97_put_volsw()
570 val = (ucontrol->value.integer.value[0] & mask); in snd_ac97_put_volsw()
572 val = mask - val; in snd_ac97_put_volsw()
576 val2 = (ucontrol->value.integer.value[1] & mask); in snd_ac97_put_volsw()
578 val2 = mask - val2; in snd_ac97_put_volsw()
585 /* check analog mixer power-down */ in snd_ac97_put_volsw()
587 (kcontrol->private_value & (1<<30))) { 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()
599 AC97_SINGLE("Tone Control - Bass", AC97_MASTER_TONE, 8, 15, 1),
600 AC97_SINGLE("Tone Control - Treble", AC97_MASTER_TONE, 0, 15, 1)
615 static const char* std_mic[] = {"Mic1", "Mic2"};
648 AC97_SINGLE("3D Control - Switch", AC97_GENERAL_PURPOSE, 13, 1, 0),
656 AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0),
657 AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0)
674 AC97_SINGLE("Off-hook Switch", AC97_GPIO_STATUS, 0, 1, 0),
681 kctl->private_value = AC97_SINGLE_VALUE(AC97_POWERDOWN, 15, 1, 0); in set_inv_eapd()
683 ac97->scaps |= AC97_SCAP_INV_EAPD; in set_inv_eapd()
688 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_ac97_spdif_mask_info()
689 uinfo->count = 1; in snd_ac97_spdif_mask_info()
695 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_ac97_spdif_cmask_get()
699 ucontrol->value.iec958.status[1] = IEC958_AES1_CON_CATEGORY | in snd_ac97_spdif_cmask_get()
701 ucontrol->value.iec958.status[3] = IEC958_AES3_CON_FS; in snd_ac97_spdif_cmask_get()
708 ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | in snd_ac97_spdif_pmask_get()
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()
735 new = val = ucontrol->value.iec958.status[0] & (IEC958_AES0_PROFESSIONAL|IEC958_AES0_NONAUDIO); in snd_ac97_spdif_default_put()
736 if (ucontrol->value.iec958.status[0] & IEC958_AES0_PROFESSIONAL) { in snd_ac97_spdif_default_put()
737 new |= ucontrol->value.iec958.status[0] & (IEC958_AES0_PRO_FS|IEC958_AES0_PRO_EMPHASIS_5015); in snd_ac97_spdif_default_put()
747 …new |= ucontrol->value.iec958.status[0] & (IEC958_AES0_CON_EMPHASIS_5015|IEC958_AES0_CON_NOT_COPYR… in snd_ac97_spdif_default_put()
748 …new |= ((ucontrol->value.iec958.status[1] & (IEC958_AES1_CON_CATEGORY|IEC958_AES1_CON_ORIGINAL)) <… in snd_ac97_spdif_default_put()
749 new |= ((ucontrol->value.iec958.status[3] & IEC958_AES3_CON_FS) << 24); in snd_ac97_spdif_default_put()
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()
775 } else if (ac97->flags & AC97_CX_SPDIF) { in snd_ac97_spdif_default_put()
782 } else if (ac97->id == AC97_ID_YMF743) { in snd_ac97_spdif_default_put()
797 mutex_unlock(&ac97->reg_mutex); in snd_ac97_spdif_default_put()
805 int reg = kcontrol->private_value & 0xff; in snd_ac97_put_spsa()
806 int shift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_put_spsa()
807 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_put_spsa()
808 // int invert = (kcontrol->private_value >> 24) & 0xff; in snd_ac97_put_spsa()
812 value = (ucontrol->value.integer.value[0] & mask); in snd_ac97_put_spsa()
814 mutex_lock(&ac97->reg_mutex); 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",
874 int mask = (kcontrol->private_value >> 16) & 0x0f; in snd_ac97_ad18xx_pcm_info_bits()
875 int lshift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_ad18xx_pcm_info_bits()
876 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_ad18xx_pcm_info_bits()
878 uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ac97_ad18xx_pcm_info_bits()
879 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) in snd_ac97_ad18xx_pcm_info_bits()
880 uinfo->count = 2; in snd_ac97_ad18xx_pcm_info_bits()
882 uinfo->count = 1; in snd_ac97_ad18xx_pcm_info_bits()
883 uinfo->value.integer.min = 0; in snd_ac97_ad18xx_pcm_info_bits()
884 uinfo->value.integer.max = mask; in snd_ac97_ad18xx_pcm_info_bits()
891 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_get_bits()
892 int lshift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_ad18xx_pcm_get_bits()
893 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_ad18xx_pcm_get_bits()
894 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_ad18xx_pcm_get_bits()
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()
905 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_put_bits()
906 int lshift = (kcontrol->private_value >> 8) & 0x0f; in snd_ac97_ad18xx_pcm_put_bits()
907 int rshift = (kcontrol->private_value >> 12) & 0x0f; in snd_ac97_ad18xx_pcm_put_bits()
908 int mask = (kcontrol->private_value >> 16) & 0xff; in snd_ac97_ad18xx_pcm_put_bits()
911 val = (mask - (ucontrol->value.integer.value[0] & mask)) << lshift; in snd_ac97_ad18xx_pcm_put_bits()
913 if (lshift != rshift && (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_ad18xx_pcm_put_bits()
914 val |= (mask - (ucontrol->value.integer.value[1] & mask)) << rshift; in snd_ac97_ad18xx_pcm_put_bits()
927 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_ac97_ad18xx_pcm_info_volume()
928 uinfo->count = 2; in snd_ac97_ad18xx_pcm_info_volume()
929 uinfo->value.integer.min = 0; in snd_ac97_ad18xx_pcm_info_volume()
930 uinfo->value.integer.max = 31; in snd_ac97_ad18xx_pcm_info_volume()
937 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_get_volume()
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()
949 int codec = kcontrol->private_value & 3; in snd_ac97_ad18xx_pcm_put_volume()
952 val1 = 31 - (ucontrol->value.integer.value[0] & 31); in snd_ac97_ad18xx_pcm_put_volume()
953 val2 = 31 - (ucontrol->value.integer.value[1] & 31); in snd_ac97_ad18xx_pcm_put_volume()
987 kfree(bus->pcms); in snd_ac97_bus_free()
988 if (bus->private_free) in snd_ac97_bus_free()
989 bus->private_free(bus); in snd_ac97_bus_free()
997 struct snd_ac97_bus *bus = device->device_data; in snd_ac97_bus_dev_free()
1005 cancel_delayed_work_sync(&ac97->power_work); 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()
1019 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_free()
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()
1041 /* if nonzero - fixed and we can't set it */ 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()
1063 /* nothing seems to be here - mute flag is not set */ in snd_ac97_try_volume_mix()
1081 if (ac97->res_table) { in check_volume_resolution()
1083 for (tbl = ac97->res_table; tbl->reg; tbl++) { in check_volume_resolution()
1084 if (tbl->reg == reg) { in check_volume_resolution()
1085 *lo_max = tbl->bits & 0xff; in check_volume_resolution()
1086 *hi_max = (tbl->bits >> 8) & 0xff; in check_volume_resolution()
1148 return x - 0x71 + 'A'; in printable()
1159 template.index = ac97->num; in snd_ac97_cnew()
1179 if (check_stereo || (ac97->flags & AC97_STEREO_MUTES)) { in snd_ac97_cmute_new_stereo()
1190 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1196 tmp.index = ac97->num; in snd_ac97_cmute_new_stereo()
1210 static const DECLARE_TLV_DB_SCALE(db_scale_4bit, -4500, 300, 0);
1211 static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
1212 static const DECLARE_TLV_DB_SCALE(db_scale_6bit, -9450, 150, 0);
1213 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0);
1228 kctl->tlv.p = tlv; in set_tlv_db_scale()
1230 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; in set_tlv_db_scale()
1247 tmp.index = ac97->num; in snd_ac97_cvol_new()
1252 tmp.index = ac97->num; in snd_ac97_cvol_new()
1256 return -ENOMEM; in snd_ac97_cvol_new()
1273 * create a mute-switch and a volume for normal stereo/mono controls
1313 struct snd_card *card = ac97->bus->card; in snd_ac97_mixer_build()
1322 if (ac97->flags & AC97_HAS_NO_MASTER_VOL) in snd_ac97_mixer_build()
1332 ac97->regs[AC97_CENTER_LFE_MASTER] = AC97_MUTE_MASK_STEREO; in snd_ac97_mixer_build()
1336 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1344 kctl->private_value &= ~(0xff << 16); in snd_ac97_mixer_build()
1345 kctl->private_value |= (int)max << 16; 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()
1352 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1360 kctl->private_value &= ~(0xff << 16); in snd_ac97_mixer_build()
1361 kctl->private_value |= (int)max << 16; 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()
1368 && !(ac97->flags & AC97_AD_MULTI)) { in snd_ac97_mixer_build()
1394 if (!(ac97->flags & AC97_HAS_NO_TONE)) { 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()
1403 kctl->private_value &= ~(0xff << 16); in snd_ac97_mixer_build()
1404 kctl->private_value |= 7 << 16; 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()
1431 if (!(ac97->flags & AC97_HAS_NO_PHONE)) { in snd_ac97_mixer_build()
1441 if (!(ac97->flags & AC97_HAS_NO_MIC)) { in snd_ac97_mixer_build()
1462 if (!(ac97->flags & AC97_HAS_NO_CD)) { in snd_ac97_mixer_build()
1472 if (!(ac97->flags & AC97_HAS_NO_VIDEO)) { in snd_ac97_mixer_build()
1482 if (!(ac97->flags & AC97_HAS_NO_AUX)) { 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()
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()
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()
1531 ac97->spec.ad18xx.pcmreg[2] = 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()
1549 if (!(ac97->flags & AC97_HAS_NO_REC_GAIN)) { in snd_ac97_mixer_build()
1587 if (ac97->caps & AC97_BC_SIM_STEREO) { in snd_ac97_mixer_build()
1601 if (ac97->caps & AC97_BC_LOUDNESS) { 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()
1645 kctl->private_value = AC97_3D_CONTROL | (9 << 8) | (7 << 16); in snd_ac97_mixer_build()
1651 kctl->private_value = AC97_3D_CONTROL | (1 << 8) | (7 << 16); in snd_ac97_mixer_build()
1658 /* Hack for ASUS P5P800-VM, which does not indicate S/PDIF capability */ 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()
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()
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()
1697 return -ENOMEM; in snd_ac97_mixer_build()
1698 if (ac97->scaps & AC97_SCAP_INV_EAPD) in snd_ac97_mixer_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()
1744 tmp = ((unsigned int)rate * ac97->bus->clock) / 48000; in snd_ac97_test_rate()
1757 if (ac97->bus->no_vra) { in snd_ac97_determine_rates()
1759 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1766 if ((ac97->ext_id & AC97_EI_DRA) && reg == AC97_PCM_FRONT_DAC_RATE) in snd_ac97_determine_rates()
1769 /* test a non-standard rate */ in snd_ac97_determine_rates()
1787 if ((ac97->flags & AC97_DOUBLE_RATE) && in snd_ac97_determine_rates()
1837 for (pid = table; pid->id; pid++) in look_for_codec_id()
1838 if (pid->id == (id & pid->mask)) in look_for_codec_id()
1855 strcpy(name, pid->name); in snd_ac97_get_name()
1856 if (ac97 && pid->patch) { in snd_ac97_get_name()
1857 if ((modem && (pid->flags & AC97_MODEM_PATCH)) || in snd_ac97_get_name()
1858 (! modem && ! (pid->flags & AC97_MODEM_PATCH))) in snd_ac97_get_name()
1859 pid->patch(ac97); in snd_ac97_get_name()
1865 strcat(name, pid->name); in snd_ac97_get_name()
1866 if (pid->mask != 0xffffffff) in snd_ac97_get_name()
1867 sprintf(name + strlen(name), " rev %d", id & ~pid->mask); in snd_ac97_get_name()
1868 if (ac97 && pid->patch) { in snd_ac97_get_name()
1869 if ((modem && (pid->flags & AC97_MODEM_PATCH)) || in snd_ac97_get_name()
1870 (! modem && ! (pid->flags & AC97_MODEM_PATCH))) in snd_ac97_get_name()
1871 pid->patch(ac97); in snd_ac97_get_name()
1878 * snd_ac97_get_short_name - retrieve codec name
1887 for (pid = snd_ac97_codec_ids; pid->id; pid++) in snd_ac97_get_short_name()
1888 if (pid->id == (ac97->id & pid->mask)) in snd_ac97_get_short_name()
1889 return pid->name; in snd_ac97_get_short_name()
1916 if (ac97->scaps & AC97_SCAP_DETECT_BY_VENDOR) { in ac97_reset_wait()
1917 /* probably only Xbox issue - all registers are read as zero */ in ac97_reset_wait()
1932 return -ENODEV; in ac97_reset_wait()
1936 * snd_ac97_bus - create an AC97 bus component
1950 * ``(*rbus)->clock`` manually.
1952 * The AC97 bus instance is registered as a low-level device, so you don't
1968 return -EINVAL; in snd_ac97_bus()
1971 return -ENOMEM; in snd_ac97_bus()
1972 bus->card = card; in snd_ac97_bus()
1973 bus->num = num; in snd_ac97_bus()
1974 bus->ops = ops; in snd_ac97_bus()
1975 bus->private_data = private_data; in snd_ac97_bus()
1976 bus->clock = 48000; in snd_ac97_bus()
1977 spin_lock_init(&bus->bus_lock); in snd_ac97_bus()
1999 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_register()
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()
2008 err = device_register(&ac97->dev); 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()
2021 struct snd_ac97 *ac97 = device->device_data; in snd_ac97_dev_disconnect()
2022 if (ac97->dev.bus) in snd_ac97_dev_disconnect()
2023 device_unregister(&ac97->dev); in snd_ac97_dev_disconnect()
2039 * snd_ac97_mixer - create an Codec97 component
2052 * The ac97 instance is registered as a low-level device, so you don't
2073 return -EINVAL; in snd_ac97_mixer()
2075 if (snd_BUG_ON(template->num >= 4)) in snd_ac97_mixer()
2076 return -EINVAL; in snd_ac97_mixer()
2077 if (bus->codec[template->num]) in snd_ac97_mixer()
2078 return -EBUSY; in snd_ac97_mixer()
2080 card = bus->card; in snd_ac97_mixer()
2083 return -ENOMEM; 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()
2105 if (bus->ops->reset) { 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()
2114 if (pid && (pid->flags & AC97_DEFAULT_POWER_OFF)) in snd_ac97_mixer()
2119 if (!(ac97->scaps & AC97_SCAP_SKIP_AUDIO)) in snd_ac97_mixer()
2121 if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_mixer()
2123 if (bus->ops->wait) 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()
2136 ac97_warn(ac97, "AC'97 %d does not respond - RESET\n", in snd_ac97_mixer()
2137 ac97->num); in snd_ac97_mixer()
2138 /* proceed anyway - it's often non-critical */ 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()
2148 ac97->num, ac97->id); in snd_ac97_mixer()
2150 return -EIO; 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()
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()
2181 if (!(ac97->scaps & (AC97_SCAP_SKIP_AUDIO|AC97_SCAP_SKIP_MODEM))) in snd_ac97_mixer()
2184 ac97->num); in snd_ac97_mixer()
2186 return -EACCES; in snd_ac97_mixer()
2189 if (bus->ops->reset) // FIXME: always skipping? in snd_ac97_mixer()
2196 if (! (ac97->flags & AC97_DEFAULT_POWER_OFF)) { in snd_ac97_mixer()
2210 "AC'97 %d analog subsections not ready\n", ac97->num); in snd_ac97_mixer()
2220 if (ac97->ext_mid & AC97_MEI_LINE1) { in snd_ac97_mixer()
2224 if (ac97->ext_mid & AC97_MEI_LINE2) { in snd_ac97_mixer()
2228 if (ac97->ext_mid & AC97_MEI_HANDSET) { in snd_ac97_mixer()
2244 ac97->num, 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()
2255 reg |= ac97->ext_id & 0x01c0; /* LDAC/SDAC/CDAC */ in snd_ac97_mixer()
2256 if (! bus->no_vra) in snd_ac97_mixer()
2257 reg |= ac97->ext_id & 0x0009; /* VRA/VRM */ in snd_ac97_mixer()
2260 if ((ac97->ext_id & AC97_EI_DRA) && bus->dra) { in snd_ac97_mixer()
2265 ac97->flags |= AC97_DOUBLE_RATE; 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()
2296 if (bus->ops->init) 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()
2305 if (card->mixername[0] == '\0') { in snd_ac97_mixer()
2306 strcpy(card->mixername, name); in snd_ac97_mixer()
2308 if (strlen(card->mixername) + 1 + strlen(name) + 1 <= sizeof(card->mixername)) { in snd_ac97_mixer()
2309 strcat(card->mixername, ","); in snd_ac97_mixer()
2310 strcat(card->mixername, name); in snd_ac97_mixer()
2313 sprintf(comp, "AC97a:%08x", ac97->id); in snd_ac97_mixer()
2321 return -ENOMEM; in snd_ac97_mixer()
2326 if (card->mixername[0] == '\0') { in snd_ac97_mixer()
2327 strcpy(card->mixername, name); in snd_ac97_mixer()
2329 if (strlen(card->mixername) + 1 + strlen(name) + 1 <= sizeof(card->mixername)) { in snd_ac97_mixer()
2330 strcat(card->mixername, ","); in snd_ac97_mixer()
2331 strcat(card->mixername, name); in snd_ac97_mixer()
2334 sprintf(comp, "AC97m:%08x", ac97->id); in snd_ac97_mixer()
2342 return -ENOMEM; in snd_ac97_mixer()
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()
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()
2399 /* AC-link powerdown, internal Clk disable */ in snd_ac97_powerdown()
2428 * snd_ac97_update_power - update the powerdown register
2431 * @powerup: non-zero when power up the part
2451 ac97->power_up |= (1 << i); in snd_ac97_update_power()
2453 ac97->power_up &= ~(1 << i); in snd_ac97_update_power()
2460 /* adjust power-down bits after two seconds delay 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()
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()
2490 power_up = ac97->power_up; in update_power_regs()
2493 if (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2) { in update_power_regs()
2494 /* needs power-up analog mix and vref */ in update_power_regs()
2511 if (! (ac97->regs[AC97_POWERDOWN] & AC97_PD_PR2)) { in update_power_regs()
2524 * snd_ac97_suspend - General suspend function for AC97 codec
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()
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()
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()
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()
2584 * snd_ac97_resume - General resume function for AC97 codec
2597 if (ac97->bus->ops->reset) { in snd_ac97_resume()
2598 ac97->bus->ops->reset(ac97); 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()
2606 else if (!(ac97->scaps & AC97_SCAP_SKIP_MODEM)) in snd_ac97_resume()
2613 snd_ac97_write(ac97, AC97_POWERDOWN, ac97->regs[AC97_POWERDOWN]); in snd_ac97_resume()
2615 ac97->bus->ops->write(ac97, AC97_MASTER, 0x8101); in snd_ac97_resume()
2623 ac97->bus->ops->write(ac97, AC97_MASTER, AC97_MUTE_MASK_MONO); 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()
2655 static void set_ctl_name(char *dst, const char *src, const char *suffix) in set_ctl_name() argument
2660 if (snprintf(dst, msize, "%s %s", src, suffix) >= msize) in set_ctl_name()
2662 src, suffix, dst); in set_ctl_name()
2664 if (strscpy(dst, src, msize) < 0) in set_ctl_name()
2666 src, dst); in set_ctl_name()
2678 return snd_ctl_remove_id(ac97->bus->card, &id); in snd_ac97_remove_ctl()
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()
2702 return -ENOENT; in snd_ac97_rename_ctl()
2705 /* rename both Volume and Switch controls - don't check the return value */
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()
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()
2731 return -ENOENT; in snd_ac97_swap_ctl()
2740 unsigned long priv_saved = kcontrol->private_value; in bind_hp_volsw_put()
2741 kcontrol->private_value = (kcontrol->private_value & ~0xff) | AC97_HEADPHONE; in bind_hp_volsw_put()
2743 kcontrol->private_value = priv_saved; in bind_hp_volsw_put()
2754 return -ENOENT; in tune_hp_only()
2755 msw->put = bind_hp_volsw_put; in tune_hp_only()
2756 mvol->put = bind_hp_volsw_put; in tune_hp_only()
2767 return -ENOENT; in tune_hp_only()
2779 return -ENOENT; in tune_swap_hp()
2780 snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Line-Out Playback"); in tune_swap_hp()
2790 return -ENOENT; in tune_swap_surround()
2798 if ((ac97->id & 0xffffff00) != 0x41445300) { in tune_ad_sharing()
2800 return -EINVAL; in tune_ad_sharing()
2811 /* ac97 tune: set up ALC jack-select */
2814 if ((ac97->id & 0xffffff00) != 0x414c4700) { in tune_alc_jack()
2817 return -EINVAL; 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()
2823 return snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_alc_jack_detect, ac97)); in tune_alc_jack()
2831 return -ENOENT; in tune_inv_eapd()
2841 int shift = (kcontrol->private_value >> 8) & 0x0f; in master_mute_sw_put()
2842 int rshift = (kcontrol->private_value >> 12) & 0x0f; in master_mute_sw_put()
2849 (ac97->regs[AC97_MASTER] & mask) == mask ? in master_mute_sw_put()
2860 return -ENOENT; in tune_mute_led()
2861 msw->put = master_mute_sw_put; in tune_mute_led()
2867 ac97->scaps |= AC97_SCAP_EAPD_LED; in tune_mute_led()
2877 int shift = (kcontrol->private_value >> 8) & 0x0f; in hp_master_mute_sw_put()
2878 int rshift = (kcontrol->private_value >> 12) & 0x0f; in hp_master_mute_sw_put()
2885 (ac97->regs[AC97_MASTER] & mask) == mask ? in hp_master_mute_sw_put()
2896 return -ENOENT; in tune_hp_mute_led()
2897 msw->put = hp_master_mute_sw_put; in tune_hp_mute_led()
2898 mvol->put = bind_hp_volsw_put; in tune_hp_mute_led()
2932 return -EINVAL; in apply_quirk()
2946 if (q->name && ! strcmp(typestr, q->name)) in apply_quirk_str()
2952 return -EINVAL; in apply_quirk_str()
2956 * snd_ac97_tune_hardware - tune up the hardware
2959 * @override: explicit quirk value (overrides the list if non-NULL)
2962 * headphone (true line-out) control as "Master".
2963 * The quirk-list must be terminated with a zero-filled entry.
2974 if (override && strcmp(override, "-1") && strcmp(override, "default")) { in snd_ac97_tune_hardware()
2983 return -EINVAL; in snd_ac97_tune_hardware()
2985 for (; quirk->subvendor; quirk++) { 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()
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()
2999 quirk->type, quirk->name, result); in snd_ac97_tune_hardware()