]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Driver for Digigram VXpocket soundcards | |
3 | * | |
4 | * VX-pocket mixer | |
5 | * | |
6 | * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
22 | ||
23 | #include <sound/driver.h> | |
24 | #include <sound/core.h> | |
25 | #include <sound/control.h> | |
d0ae4847 | 26 | #include <sound/tlv.h> |
1da177e4 LT |
27 | #include "vxpocket.h" |
28 | ||
29 | #define MIC_LEVEL_MIN 0 | |
30 | #define MIC_LEVEL_MAX 8 | |
31 | ||
32 | /* | |
33 | * mic level control (for VXPocket) | |
34 | */ | |
af26367f | 35 | static int vx_mic_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4 LT |
36 | { |
37 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | |
38 | uinfo->count = 1; | |
39 | uinfo->value.integer.min = 0; | |
40 | uinfo->value.integer.max = MIC_LEVEL_MAX; | |
41 | return 0; | |
42 | } | |
43 | ||
af26367f | 44 | static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 | 45 | { |
af26367f | 46 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
1da177e4 LT |
47 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; |
48 | ucontrol->value.integer.value[0] = chip->mic_level; | |
49 | return 0; | |
50 | } | |
51 | ||
af26367f | 52 | static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 | 53 | { |
af26367f | 54 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
1da177e4 | 55 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; |
12aa7579 | 56 | mutex_lock(&_chip->mixer_mutex); |
1da177e4 LT |
57 | if (chip->mic_level != ucontrol->value.integer.value[0]) { |
58 | vx_set_mic_level(_chip, ucontrol->value.integer.value[0]); | |
59 | chip->mic_level = ucontrol->value.integer.value[0]; | |
12aa7579 | 60 | mutex_unlock(&_chip->mixer_mutex); |
1da177e4 LT |
61 | return 1; |
62 | } | |
12aa7579 | 63 | mutex_unlock(&_chip->mixer_mutex); |
1da177e4 LT |
64 | return 0; |
65 | } | |
66 | ||
0cb29ea0 | 67 | static const DECLARE_TLV_DB_SCALE(db_scale_mic, -21, 3, 0); |
d0ae4847 | 68 | |
af26367f | 69 | static struct snd_kcontrol_new vx_control_mic_level = { |
1da177e4 | 70 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
d0ae4847 TI |
71 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
72 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), | |
1da177e4 LT |
73 | .name = "Mic Capture Volume", |
74 | .info = vx_mic_level_info, | |
75 | .get = vx_mic_level_get, | |
76 | .put = vx_mic_level_put, | |
d0ae4847 | 77 | .tlv = { .p = db_scale_mic }, |
1da177e4 LT |
78 | }; |
79 | ||
80 | /* | |
81 | * mic boost level control (for VXP440) | |
82 | */ | |
af26367f | 83 | static int vx_mic_boost_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) |
1da177e4 LT |
84 | { |
85 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | |
86 | uinfo->count = 1; | |
87 | uinfo->value.integer.min = 0; | |
88 | uinfo->value.integer.max = 1; | |
89 | return 0; | |
90 | } | |
91 | ||
af26367f | 92 | static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 | 93 | { |
af26367f | 94 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
1da177e4 LT |
95 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; |
96 | ucontrol->value.integer.value[0] = chip->mic_level; | |
97 | return 0; | |
98 | } | |
99 | ||
af26367f | 100 | static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
1da177e4 | 101 | { |
af26367f | 102 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
1da177e4 | 103 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; |
12aa7579 | 104 | mutex_lock(&_chip->mixer_mutex); |
1da177e4 LT |
105 | if (chip->mic_level != ucontrol->value.integer.value[0]) { |
106 | vx_set_mic_boost(_chip, ucontrol->value.integer.value[0]); | |
107 | chip->mic_level = ucontrol->value.integer.value[0]; | |
12aa7579 | 108 | mutex_unlock(&_chip->mixer_mutex); |
1da177e4 LT |
109 | return 1; |
110 | } | |
12aa7579 | 111 | mutex_unlock(&_chip->mixer_mutex); |
1da177e4 LT |
112 | return 0; |
113 | } | |
114 | ||
af26367f | 115 | static struct snd_kcontrol_new vx_control_mic_boost = { |
1da177e4 LT |
116 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
117 | .name = "Mic Boost", | |
118 | .info = vx_mic_boost_info, | |
119 | .get = vx_mic_boost_get, | |
120 | .put = vx_mic_boost_put, | |
121 | }; | |
122 | ||
123 | ||
af26367f | 124 | int vxp_add_mic_controls(struct vx_core *_chip) |
1da177e4 LT |
125 | { |
126 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | |
127 | int err; | |
128 | ||
129 | /* mute input levels */ | |
130 | chip->mic_level = 0; | |
131 | switch (_chip->type) { | |
132 | case VX_TYPE_VXPOCKET: | |
133 | vx_set_mic_level(_chip, 0); | |
134 | break; | |
135 | case VX_TYPE_VXP440: | |
136 | vx_set_mic_boost(_chip, 0); | |
137 | break; | |
138 | } | |
139 | ||
140 | /* mic level */ | |
141 | switch (_chip->type) { | |
142 | case VX_TYPE_VXPOCKET: | |
143 | if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_level, chip))) < 0) | |
144 | return err; | |
145 | break; | |
146 | case VX_TYPE_VXP440: | |
147 | if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_boost, chip))) < 0) | |
148 | return err; | |
149 | break; | |
150 | } | |
151 | ||
152 | return 0; | |
153 | } | |
154 |