2 * Driver for Digigram VXpocket soundcards
6 * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
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.
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.
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
23 #include <sound/driver.h>
24 #include <sound/core.h>
25 #include <sound/control.h>
28 #define chip_t vx_core_t
30 #define MIC_LEVEL_MIN 0
31 #define MIC_LEVEL_MAX 8
34 * mic level control (for VXPocket)
36 static int vx_mic_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
38 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
40 uinfo->value.integer.min = 0;
41 uinfo->value.integer.max = MIC_LEVEL_MAX;
45 static int vx_mic_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
47 vx_core_t *_chip = snd_kcontrol_chip(kcontrol);
48 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
49 ucontrol->value.integer.value[0] = chip->mic_level;
53 static int vx_mic_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
55 vx_core_t *_chip = snd_kcontrol_chip(kcontrol);
56 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
57 down(&_chip->mixer_mutex);
58 if (chip->mic_level != ucontrol->value.integer.value[0]) {
59 vx_set_mic_level(_chip, ucontrol->value.integer.value[0]);
60 chip->mic_level = ucontrol->value.integer.value[0];
61 up(&_chip->mixer_mutex);
64 up(&_chip->mixer_mutex);
68 static snd_kcontrol_new_t vx_control_mic_level = {
69 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
70 .name = "Mic Capture Volume",
71 .info = vx_mic_level_info,
72 .get = vx_mic_level_get,
73 .put = vx_mic_level_put,
77 * mic boost level control (for VXP440)
79 static int vx_mic_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
81 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
83 uinfo->value.integer.min = 0;
84 uinfo->value.integer.max = 1;
88 static int vx_mic_boost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
90 vx_core_t *_chip = snd_kcontrol_chip(kcontrol);
91 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
92 ucontrol->value.integer.value[0] = chip->mic_level;
96 static int vx_mic_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
98 vx_core_t *_chip = snd_kcontrol_chip(kcontrol);
99 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
100 down(&_chip->mixer_mutex);
101 if (chip->mic_level != ucontrol->value.integer.value[0]) {
102 vx_set_mic_boost(_chip, ucontrol->value.integer.value[0]);
103 chip->mic_level = ucontrol->value.integer.value[0];
104 up(&_chip->mixer_mutex);
107 up(&_chip->mixer_mutex);
111 static snd_kcontrol_new_t vx_control_mic_boost = {
112 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
114 .info = vx_mic_boost_info,
115 .get = vx_mic_boost_get,
116 .put = vx_mic_boost_put,
120 int vxp_add_mic_controls(vx_core_t *_chip)
122 struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
125 /* mute input levels */
127 switch (_chip->type) {
128 case VX_TYPE_VXPOCKET:
129 vx_set_mic_level(_chip, 0);
132 vx_set_mic_boost(_chip, 0);
137 switch (_chip->type) {
138 case VX_TYPE_VXPOCKET:
139 if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_level, chip))) < 0)
143 if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_boost, chip))) < 0)