aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106/ca0106_mixer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ca0106/ca0106_mixer.c')
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c76
1 files changed, 69 insertions, 7 deletions
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 97bed1b0899d..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>
@@ -113,7 +115,7 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol,
113 } else { 115 } else {
114 /* Analog */ 116 /* Analog */
115 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf); 117 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
116 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000b0000); 118 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000);
117 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, 119 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0,
118 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000); 120 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000);
119 mask = inl(emu->port + GPIO) | 0x101; 121 mask = inl(emu->port + GPIO) | 0x101;
@@ -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;
@@ -437,7 +498,7 @@ static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe =
437static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = 498static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown =
438{ 499{
439 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
440 .name = "Analog Unknown Volume", 501 .name = "Analog Side Volume",
441 .info = snd_ca0106_volume_info, 502 .info = snd_ca0106_volume_info,
442 .get = snd_ca0106_volume_get_analog_unknown, 503 .get = snd_ca0106_volume_get_analog_unknown,
443 .put = snd_ca0106_volume_put_analog_unknown 504 .put = snd_ca0106_volume_put_analog_unknown
@@ -620,10 +681,11 @@ 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;
623 if ((kctl = ctl_find(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT))) != NULL) { 684 if (emu->details->i2c_adc == 1) {
624 /* already defined by ac97, remove it */ 685 if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL)
625 /* FIXME: or do we need both controls? */ 686 return -ENOMEM;
626 remove_ctl(card, SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT)); 687 if ((err = snd_ctl_add(card, kctl)))
688 return err;
627 } 689 }
628 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) 690 if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL)
629 return -ENOMEM; 691 return -ENOMEM;