Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f927c8fc authored by James Courtier-Dutton's avatar James Courtier-Dutton Committed by Jaroslav Kysela
Browse files

[ALSA] Implement different capture sources.



EMU10K1/EMU10K2 driver
e.g. When HD Capture source is set to SPDIF,
     setting HD Capture channel to 0 captures from CDROM digital input.
     setting HD Capture channel to 1 captures from SPDIF in.

Signed-off-by: default avatarJames Courtier-Dutton <James@superbug.co.uk>
parent c7025637
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1130,6 +1130,7 @@ struct _snd_emu10k1 {
	emu10k1_voice_t p16v_capture_voice;
	int p16v_device_offset;
	u32 p16v_capture_source;
	u32 p16v_capture_channel;
	emu10k1_pcm_mixer_t pcm_mixer[32];
	emu10k1_pcm_mixer_t efx_pcm_mixer[NUM_EFX_PLAYBACK];
	snd_kcontrol_t *ctl_send_routing;
+61 −1
Original line number Diff line number Diff line
@@ -41,7 +41,13 @@
 *    Integrated with snd-emu10k1 driver.
 *  0.22
 *    Removed #if 0 ... #endif
 *
 *  0.23
 *    Implement different capture rates.
 *  0.24
 *    Implement different capture source channels.
 *    e.g. When HD Capture source is set to SPDIF,
 *    setting HD Capture channel to 0 captures from CDROM digital input.
 *    setting HD Capture channel to 1 captures from SPDIF in.
 *
 *  BUGS:
 *    Some stability problems when unloading the snd-p16v kernel module.
@@ -933,6 +939,56 @@ static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata =
	.get =		snd_p16v_capture_source_get,
	.put =		snd_p16v_capture_source_put
};

static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
{
	static char *texts[4] = { "0", "1", "2", "3",  };

	uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
	uinfo->count = 1;
	uinfo->value.enumerated.items = 4;
	if (uinfo->value.enumerated.item > 3)
                uinfo->value.enumerated.item = 3;
	strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
	return 0;
}

static int snd_p16v_capture_channel_get(snd_kcontrol_t * kcontrol,
					snd_ctl_elem_value_t * ucontrol)
{
	emu10k1_t *emu = snd_kcontrol_chip(kcontrol);

	ucontrol->value.enumerated.item[0] = emu->p16v_capture_channel;
	return 0;
}

static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol,
					snd_ctl_elem_value_t * ucontrol)
{
	emu10k1_t *emu = snd_kcontrol_chip(kcontrol);
	unsigned int val;
	int change = 0;
	u32 tmp;

	val = ucontrol->value.enumerated.item[0] ;
	change = (emu->p16v_capture_channel != val);
	if (change) {
		emu->p16v_capture_channel = val;
		tmp = snd_emu10k1_ptr20_read(emu, CAPTURE_P16V_SOURCE, 0) & 0xfffc;
		snd_emu10k1_ptr20_write(emu, CAPTURE_P16V_SOURCE, 0, tmp | val);
	}
        return change;
}

static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata =
{
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =		"HD Capture channel",
	.info =		snd_p16v_capture_channel_info,
	.get =		snd_p16v_capture_channel_get,
	.put =		snd_p16v_capture_channel_put
};

int snd_p16v_mixer(emu10k1_t *emu)
{
        int err;
@@ -974,6 +1030,10 @@ int snd_p16v_mixer(emu10k1_t *emu)
                return -ENOMEM;
        if ((err = snd_ctl_add(card, kctl)))
                return err;
        if ((kctl = snd_ctl_new1(&snd_p16v_capture_channel, emu)) == NULL)
                return -ENOMEM;
        if ((err = snd_ctl_add(card, kctl)))
                return err;
        return 0;
}