Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
0004  *  Universal interface for Audio Codec '97
0005  *
0006  *  For more details look to AC '97 component specification revision 2.2
0007  *  by Intel Corporation (http://developer.intel.com).
0008  */
0009 
0010 #define AC97_SINGLE_VALUE(reg,shift,mask,invert) \
0011     ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \
0012      ((invert) << 24))
0013 #define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \
0014     (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
0015 #define AC97_SINGLE(xname, reg, shift, mask, invert) \
0016 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0017   .info = snd_ac97_info_volsw,      \
0018   .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
0019   .private_value =  AC97_SINGLE_VALUE(reg, shift, mask, invert) }
0020 #define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page)     \
0021 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0022   .info = snd_ac97_info_volsw,      \
0023   .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
0024   .private_value =  AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
0025 #define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
0026 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
0027   .info = snd_ac97_info_volsw,      \
0028   .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
0029   .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
0030 
0031 /* enum control */
0032 struct ac97_enum {
0033     unsigned char reg;
0034     unsigned char shift_l;
0035     unsigned char shift_r;
0036     unsigned short mask;
0037     const char * const *texts;
0038 };
0039 
0040 #define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
0041 { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
0042   .mask = xmask, .texts = xtexts }
0043 #define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
0044     AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
0045 #define AC97_ENUM(xname, xenum) \
0046 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
0047   .info = snd_ac97_info_enum_double,            \
0048   .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
0049   .private_value = (unsigned long)&xenum }
0050 
0051 /* ac97_codec.c */
0052 static const struct snd_kcontrol_new snd_ac97_controls_3d[];
0053 static const struct snd_kcontrol_new snd_ac97_controls_spdif[];
0054 static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
0055                       struct snd_ac97 * ac97);
0056 static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
0057                    struct snd_ctl_elem_info *uinfo);
0058 static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
0059                   struct snd_ctl_elem_value *ucontrol);
0060 static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
0061                   struct snd_ctl_elem_value *ucontrol);
0062 static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
0063 static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
0064                    const char *suffix);
0065 static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
0066                    const char *dst, const char *suffix);
0067 static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
0068                  const char *s2, const char *suffix);
0069 static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
0070                     const char *dst);
0071 #ifdef CONFIG_PM
0072 static void snd_ac97_restore_status(struct snd_ac97 *ac97);
0073 static void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
0074 #endif
0075 static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
0076                      struct snd_ctl_elem_info *uinfo);
0077 static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
0078                     struct snd_ctl_elem_value *ucontrol);
0079 static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
0080                     struct snd_ctl_elem_value *ucontrol);