Diff markup
1 /* 1 /*
2 * Copyright (c) by Jaroslav Kysela <perex@pe 2 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
3 * Universal interface for Audio Codec '97 3 * Universal interface for Audio Codec '97
4 * 4 *
5 * For more details look to AC '97 component 5 * For more details look to AC '97 component specification revision 2.2
6 * by Intel Corporation (http://developer.int 6 * by Intel Corporation (http://developer.intel.com).
7 * 7 *
8 * 8 *
9 * This program is free software; you can re 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Pub 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either vers 11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version. 12 * (at your option) any later version.
13 * 13 *
14 * This program is distributed in the hope t 14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even th 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICUL 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more detai 17 * GNU General Public License for more details.
18 * 18 *
19 * You should have received a copy of the GN 19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * 22 *
23 */ 23 */
24 24
25 #define AC97_SINGLE_VALUE(reg,shift,mask,inver 25 #define AC97_SINGLE_VALUE(reg,shift,mask,invert) \
26 ((reg) | ((shift) << 8) | ((shift) << 26 ((reg) | ((shift) << 8) | ((shift) << 12) | ((mask) << 16) | \
27 ((invert) << 24)) 27 ((invert) << 24))
28 #define AC97_PAGE_SINGLE_VALUE(reg,shift,mask, 28 #define AC97_PAGE_SINGLE_VALUE(reg,shift,mask,invert,page) \
29 (AC97_SINGLE_VALUE(reg,shift,mask,inve 29 (AC97_SINGLE_VALUE(reg,shift,mask,invert) | (1<<25) | ((page) << 26))
30 #define AC97_SINGLE(xname, reg, shift, mask, i 30 #define AC97_SINGLE(xname, reg, shift, mask, invert) \
31 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 31 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
32 .info = snd_ac97_info_volsw, \ 32 .info = snd_ac97_info_volsw, \
33 .get = snd_ac97_get_volsw, .put = snd_ac97_p 33 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
34 .private_value = AC97_SINGLE_VALUE(reg, shi 34 .private_value = AC97_SINGLE_VALUE(reg, shift, mask, invert) }
35 #define AC97_PAGE_SINGLE(xname, reg, shift, ma 35 #define AC97_PAGE_SINGLE(xname, reg, shift, mask, invert, page) \
36 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 36 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
37 .info = snd_ac97_info_volsw, \ 37 .info = snd_ac97_info_volsw, \
38 .get = snd_ac97_get_volsw, .put = snd_ac97_p 38 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
39 .private_value = AC97_PAGE_SINGLE_VALUE(reg 39 .private_value = AC97_PAGE_SINGLE_VALUE(reg, shift, mask, invert, page) }
40 #define AC97_DOUBLE(xname, reg, shift_left, sh 40 #define AC97_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \
41 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 41 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
42 .info = snd_ac97_info_volsw, \ 42 .info = snd_ac97_info_volsw, \
43 .get = snd_ac97_get_volsw, .put = snd_ac97_p 43 .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \
44 .private_value = (reg) | ((shift_left) << 8) 44 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) }
45 45
46 /* enum control */ 46 /* enum control */
47 struct ac97_enum { 47 struct ac97_enum {
48 unsigned char reg; 48 unsigned char reg;
49 unsigned char shift_l; 49 unsigned char shift_l;
50 unsigned char shift_r; 50 unsigned char shift_r;
51 unsigned short mask; 51 unsigned short mask;
52 const char **texts; 52 const char **texts;
53 }; 53 };
54 54
55 #define AC97_ENUM_DOUBLE(xreg, xshift_l, xshif 55 #define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
56 { .reg = xreg, .shift_l = xshift_l, .shift_r = 56 { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
57 .mask = xmask, .texts = xtexts } 57 .mask = xmask, .texts = xtexts }
58 #define AC97_ENUM_SINGLE(xreg, xshift, xmask, 58 #define AC97_ENUM_SINGLE(xreg, xshift, xmask, xtexts) \
59 AC97_ENUM_DOUBLE(xreg, xshift, xshift, 59 AC97_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xtexts)
60 #define AC97_ENUM(xname, xenum) \ 60 #define AC97_ENUM(xname, xenum) \
61 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 61 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
62 .info = snd_ac97_info_enum_double, 62 .info = snd_ac97_info_enum_double, \
63 .get = snd_ac97_get_enum_double, .put = snd_ 63 .get = snd_ac97_get_enum_double, .put = snd_ac97_put_enum_double, \
64 .private_value = (unsigned long)&xenum } 64 .private_value = (unsigned long)&xenum }
65 65
66 /* ac97_codec.c */ 66 /* ac97_codec.c */
67 static const struct snd_kcontrol_new snd_ac97_ 67 static const struct snd_kcontrol_new snd_ac97_controls_3d[];
68 static const struct snd_kcontrol_new snd_ac97_ 68 static const struct snd_kcontrol_new snd_ac97_controls_spdif[];
69 static struct snd_kcontrol *snd_ac97_cnew(cons 69 static struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template,
70 stru 70 struct snd_ac97 * ac97);
71 static int snd_ac97_info_volsw(struct snd_kcon 71 static int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol,
72 struct snd_ctl_ 72 struct snd_ctl_elem_info *uinfo);
73 static int snd_ac97_get_volsw(struct snd_kcont 73 static int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol,
74 struct snd_ctl_e 74 struct snd_ctl_elem_value *ucontrol);
75 static int snd_ac97_put_volsw(struct snd_kcont 75 static int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol,
76 struct snd_ctl_e 76 struct snd_ctl_elem_value *ucontrol);
77 static int snd_ac97_try_bit(struct snd_ac97 * 77 static int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit);
78 static int snd_ac97_remove_ctl(struct snd_ac97 78 static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name,
79 const char *suf 79 const char *suffix);
80 static int snd_ac97_rename_ctl(struct snd_ac97 80 static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src,
81 const char *dst 81 const char *dst, const char *suffix);
82 static int snd_ac97_swap_ctl(struct snd_ac97 * 82 static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1,
83 const char *s2, c 83 const char *s2, const char *suffix);
84 static void snd_ac97_rename_vol_ctl(struct snd 84 static void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src,
85 const char 85 const char *dst);
86 #ifdef CONFIG_PM 86 #ifdef CONFIG_PM
87 static void snd_ac97_restore_status(struct snd 87 static void snd_ac97_restore_status(struct snd_ac97 *ac97);
88 static void snd_ac97_restore_iec958(struct snd 88 static void snd_ac97_restore_iec958(struct snd_ac97 *ac97);
89 #endif 89 #endif
90 static int snd_ac97_info_enum_double(struct sn 90 static int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol,
91 struct sn 91 struct snd_ctl_elem_info *uinfo);
92 static int snd_ac97_get_enum_double(struct snd 92 static int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol,
93 struct snd 93 struct snd_ctl_elem_value *ucontrol);
94 static int snd_ac97_put_enum_double(struct snd 94 static int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol,
95 struct snd 95 struct snd_ctl_elem_value *ucontrol);
96 96
|
This page was automatically generated by the
LXR engine.
|