Commit ed144f3c authored by James Courtier-Dutton's avatar James Courtier-Dutton Committed by Jaroslav Kysela

[ALSA] Add Mic capture support.

CA0106 driver
Notes: This adds a new mixer item to switch between Mic and Line-in.
Signed-off-by: default avatarJames Courtier-Dutton <James@superbug.co.uk>
parent 7199acdc
...@@ -589,6 +589,7 @@ struct snd_ca0106 { ...@@ -589,6 +589,7 @@ struct snd_ca0106 {
u32 spdif_bits[4]; /* s/pdif out setup */ u32 spdif_bits[4]; /* s/pdif out setup */
int spdif_enable; int spdif_enable;
int capture_source; int capture_source;
int capture_mic_line_in;
struct snd_dma_buffer buffer; struct snd_dma_buffer buffer;
}; };
......
/* /*
* Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
* Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
* Version: 0.0.16 * Version: 0.0.17
* *
* FEATURES currently supported: * FEATURES currently supported:
* See ca0106_main.c for features. * See ca0106_main.c for features.
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
* Separated ca0106.c into separate functional .c files. * Separated ca0106.c into separate functional .c files.
* 0.0.16 * 0.0.16
* Modified Copyright message. * Modified Copyright message.
* 0.0.17
* Implement Mic and Line in Capture.
* *
* This code was initally based on code from ALSA's emu10k1x.c which is: * This code was initally based on code from ALSA's emu10k1x.c which is:
* Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
...@@ -183,6 +185,65 @@ static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata = ...@@ -183,6 +185,65 @@ static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata =
.put = snd_ca0106_capture_source_put .put = snd_ca0106_capture_source_put
}; };
static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
{
static char *texts[2] = { "Line in", "Mic in" };
uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
uinfo->count = 1;
uinfo->value.enumerated.items = 2;
if (uinfo->value.enumerated.item > 1)
uinfo->value.enumerated.item = 1;
strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
return 0;
}
static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
ca0106_t *emu = snd_kcontrol_chip(kcontrol);
ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in;
return 0;
}
static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol,
snd_ctl_elem_value_t * ucontrol)
{
ca0106_t *emu = snd_kcontrol_chip(kcontrol);
unsigned int val;
int change = 0;
u32 tmp;
val = ucontrol->value.enumerated.item[0] ;
change = (emu->capture_mic_line_in != val);
if (change) {
emu->capture_mic_line_in = val;
if (val) {
snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */
tmp = inl(emu->port+GPIO) & ~0x400;
tmp = tmp | 0x400;
outl(tmp, emu->port+GPIO);
snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC);
} else {
snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_PHONE); /* Mute input */
tmp = inl(emu->port+GPIO) & ~0x400;
outl(tmp, emu->port+GPIO);
snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN);
}
}
return change;
}
static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata =
{
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "Mic/Line in Capture",
.info = snd_ca0106_capture_mic_line_in_info,
.get = snd_ca0106_capture_mic_line_in_get,
.put = snd_ca0106_capture_mic_line_in_put
};
static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
{ {
uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
...@@ -620,6 +681,12 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu) ...@@ -620,6 +681,12 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu)
return -ENOMEM; return -ENOMEM;
if ((err = snd_ctl_add(card, kctl))) if ((err = snd_ctl_add(card, kctl)))
return err; return err;
if (emu->details->i2c_adc == 1) {
if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL)
return -ENOMEM;
if ((err = snd_ctl_add(card, kctl)))
return err;
}
if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL)
return -ENOMEM; return -ENOMEM;
if ((err = snd_ctl_add(card, kctl))) if ((err = snd_ctl_add(card, kctl)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment