aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106/ca0106_mixer.c
diff options
context:
space:
mode:
authorJames Courtier-Dutton <James@superbug.co.uk>2005-05-27 17:28:27 -0400
committerJaroslav Kysela <perex@suse.cz>2005-06-22 06:27:09 -0400
commited144f3cdcf8f9b9280e04ca1a831c85a8fbb488 (patch)
treeb0c988b01ff94555cb393a30d04f85daefda8be2 /sound/pci/ca0106/ca0106_mixer.c
parent7199acdc74dc16d2e75f83b8c65301ad19c40ef3 (diff)
[ALSA] Add Mic capture support.
CA0106 driver Notes: This adds a new mixer item to switch between Mic and Line-in. Signed-off-by: James Courtier-Dutton <James@superbug.co.uk>
Diffstat (limited to 'sound/pci/ca0106/ca0106_mixer.c')
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c69
1 files changed, 68 insertions, 1 deletions
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 48e248608244..0e5e9ce0ff28 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> 2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit 3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
4 * Version: 0.0.16 4 * Version: 0.0.17
5 * 5 *
6 * FEATURES currently supported: 6 * FEATURES currently supported:
7 * See ca0106_main.c for features. 7 * See ca0106_main.c for features.
@@ -37,6 +37,8 @@
37 * Separated ca0106.c into separate functional .c files. 37 * Separated ca0106.c into separate functional .c files.
38 * 0.0.16 38 * 0.0.16
39 * Modified Copyright message. 39 * Modified Copyright message.
40 * 0.0.17
41 * Implement Mic and Line in Capture.
40 * 42 *
41 * This code was initally based on code from ALSA's emu10k1x.c which is: 43 * This code was initally based on code from ALSA's emu10k1x.c which is:
42 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> 44 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
@@ -183,6 +185,65 @@ static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata =
183 .put = snd_ca0106_capture_source_put 185 .put = snd_ca0106_capture_source_put
184}; 186};
185 187
188static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
189{
190 static char *texts[2] = { "Line in", "Mic in" };
191
192 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
193 uinfo->count = 1;
194 uinfo->value.enumerated.items = 2;
195 if (uinfo->value.enumerated.item > 1)
196 uinfo->value.enumerated.item = 1;
197 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
198 return 0;
199}
200
201static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol,
202 snd_ctl_elem_value_t * ucontrol)
203{
204 ca0106_t *emu = snd_kcontrol_chip(kcontrol);
205
206 ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in;
207 return 0;
208}
209
210static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol,
211 snd_ctl_elem_value_t * ucontrol)
212{
213 ca0106_t *emu = snd_kcontrol_chip(kcontrol);
214 unsigned int val;
215 int change = 0;
216 u32 tmp;
217
218 val = ucontrol->value.enumerated.item[0] ;
219 change = (emu->capture_mic_line_in != val);
220 if (change) {
221 emu->capture_mic_line_in = val;
222 if (val) {
223 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */
224 tmp = inl(emu->port+GPIO) & ~0x400;
225 tmp = tmp | 0x400;
226 outl(tmp, emu->port+GPIO);
227 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC);
228 } else {
229 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */
230 tmp = inl(emu->port+GPIO) & ~0x400;
231 outl(tmp, emu->port+GPIO);
232 snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN);
233 }
234 }
235 return change;
236}
237
238static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata =
239{
240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
241 .name = "Mic/Line in Capture",
242 .info = snd_ca0106_capture_mic_line_in_info,
243 .get = snd_ca0106_capture_mic_line_in_get,
244 .put = snd_ca0106_capture_mic_line_in_put
245};
246
186static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) 247static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
187{ 248{
188 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; 249 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
@@ -620,6 +681,12 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu)
620 return -ENOMEM; 681 return -ENOMEM;
621 if ((err = snd_ctl_add(card, kctl))) 682 if ((err = snd_ctl_add(card, kctl)))
622 return err; 683 return err;
684 if (emu->details->i2c_adc == 1) {
685 if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL)
686 return -ENOMEM;
687 if ((err = snd_ctl_add(card, kctl)))
688 return err;
689 }
623 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) 690 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL)
624 return -ENOMEM; 691 return -ENOMEM;
625 if ((err = snd_ctl_add(card, kctl))) 692 if ((err = snd_ctl_add(card, kctl)))