]> err.no Git - linux-2.6/commitdiff
[ALSA] Implement different capture sources.
authorJames Courtier-Dutton <James@superbug.co.uk>
Sat, 7 May 2005 13:34:13 +0000 (15:34 +0200)
committerJaroslav Kysela <perex@suse.cz>
Sun, 29 May 2005 08:06:16 +0000 (10:06 +0200)
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: James Courtier-Dutton <James@superbug.co.uk>
include/sound/emu10k1.h
sound/pci/emu10k1/p16v.c

index 23dabbceb4b78fa7a38355506dd1417a4b3c8f98..c50b91958ff985c4d2028d3edbef9bc1cec5e28e 100644 (file)
@@ -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;
index 13f7e62ee56b384dc1471c197a8c1d6c4faa7b38..93dff4c6b233bc88a9e47cf9f14551285bb273a6 100644 (file)
  *    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;
 }