vserver 1.9.5.x5
[linux-2.6.git] / sound / pci / emu10k1 / emu10k1.c
index 16943f5..20165ab 100644 (file)
@@ -2,6 +2,9 @@
  *  The driver for the EMU10K1 (SB Live!) based soundcards
  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  *
+ *  Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk>
+ *      Added support for Audigy 2 Value.
+ *
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
  *   along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
+ * 
  */
 
 #include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/time.h>
+#include <linux/moduleparam.h>
 #include <sound/core.h>
 #include <sound/emu10k1.h>
-#define SNDRV_GET_ID
 #include <sound/initval.h>
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
 MODULE_DESCRIPTION("EMU10K1");
 MODULE_LICENSE("GPL");
-MODULE_CLASSES("{sound}");
-MODULE_DEVICES("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
+MODULE_SUPPORTED_DEVICE("{{Creative Labs,SB Live!/PCI512/E-mu APS},"
               "{Creative Labs,SB Audigy}}");
 
 #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE))
@@ -50,43 +53,46 @@ static int max_synth_voices[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 64};
 static int max_buffer_size[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
 static int enable_ir[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 
-MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(index, int, NULL, 0444);
 MODULE_PARM_DESC(index, "Index value for the EMU10K1 soundcard.");
-MODULE_PARM_SYNTAX(index, SNDRV_INDEX_DESC);
-MODULE_PARM(id, "1-" __MODULE_STRING(SNDRV_CARDS) "s");
+module_param_array(id, charp, NULL, 0444);
 MODULE_PARM_DESC(id, "ID string for the EMU10K1 soundcard.");
-MODULE_PARM_SYNTAX(id, SNDRV_ID_DESC);
-MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(enable, bool, NULL, 0444);
 MODULE_PARM_DESC(enable, "Enable the EMU10K1 soundcard.");
-MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
-MODULE_PARM(extin, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(extin, int, NULL, 0444);
 MODULE_PARM_DESC(extin, "Available external inputs for FX8010. Zero=default.");
-MODULE_PARM_SYNTAX(extin, SNDRV_ENABLED "allows:{{0,0x0ffff}},base:16");
-MODULE_PARM(extout, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(extout, int, NULL, 0444);
 MODULE_PARM_DESC(extout, "Available external outputs for FX8010. Zero=default.");
-MODULE_PARM_SYNTAX(extout, SNDRV_ENABLED "allows:{{0,0x0ffff}},base:16");
-MODULE_PARM(seq_ports, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(seq_ports, int, NULL, 0444);
 MODULE_PARM_DESC(seq_ports, "Allocated sequencer ports for internal synthesizer.");
-MODULE_PARM_SYNTAX(seq_ports, SNDRV_ENABLED "allows:{{0,32}}");
-MODULE_PARM(max_synth_voices, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(max_synth_voices, int, NULL, 0444);
 MODULE_PARM_DESC(max_synth_voices, "Maximum number of voices for WaveTable.");
-MODULE_PARM_SYNTAX(max_synth_voices, SNDRV_ENABLED);
-MODULE_PARM(max_buffer_size, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(max_buffer_size, int, NULL, 0444);
 MODULE_PARM_DESC(max_buffer_size, "Maximum sample buffer size in MB.");
-MODULE_PARM_SYNTAX(max_buffer_size, SNDRV_ENABLED);
-MODULE_PARM(enable_ir, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+module_param_array(enable_ir, bool, NULL, 0444);
 MODULE_PARM_DESC(enable_ir, "Enable IR.");
-MODULE_PARM_SYNTAX(enable_ir, SNDRV_ENABLE_DESC);
 
+/*
+ * Class 0401: 1102:0008 (rev 00) Subsystem: 1102:1001 -> Audigy2 Value  Model:SB0400
+ */
 static struct pci_device_id snd_emu10k1_ids[] = {
        { 0x1102, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },    /* EMU10K1 */
-#if 0 /* FIXME: not working! */
-       { 0x1102, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },    /* Dell OEM version (EMU10K1) */
-#endif
        { 0x1102, 0x0004, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },    /* Audigy */
+       { 0x1102, 0x0008, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },    /* Audigy 2 Value SB0400 */
        { 0, }
 };
 
+/*
+ * Audigy 2 Value notes:
+ * A_IOCFG Input (GPIO)
+ * 0x400  = Front analog jack plugged in. (Green socket)
+ * 0x1000 = Read analog jack plugged in. (Black socket)
+ * 0x2000 = Center/LFE analog jack plugged in. (Orange socket)
+ * A_IOCFG Output (GPIO)
+ * 0x60 = Sound out of front Left.
+ * Win sets it to 0xXX61
+ */
+
 MODULE_DEVICE_TABLE(pci, snd_emu10k1_ids);
 
 static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
@@ -133,14 +139,16 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
                snd_card_free(card);
                return err;
        }               
-       if ((err = snd_emu10k1_fx8010_pcm(emu, 3, NULL)) < 0) {
+       if ((err = snd_emu10k1_mixer(emu)) < 0) {
                snd_card_free(card);
                return err;
-       }               
-       if ((err = snd_emu10k1_mixer(emu)) < 0) {
+       }
+       
+       if ((err = snd_emu10k1_timer(emu, 0)) < 0) {
                snd_card_free(card);
                return err;
        }
+
        if (emu->audigy) {
                if ((err = snd_emu10k1_audigy_midi(emu)) < 0) {
                        snd_card_free(card);
@@ -172,7 +180,10 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
        }
 #endif
  
-       if (emu->audigy && (emu->revision == 4) ) {
+       if (emu->audigy && (emu->serial == 0x10011102) ) {
+               strcpy(card->driver, "Audigy2");
+               strcpy(card->shortname, "Sound Blaster Audigy2_Value");
+       } else if (emu->audigy && (emu->revision == 4) ) {
                strcpy(card->driver, "Audigy2");
                strcpy(card->shortname, "Sound Blaster Audigy2");
        } else if (emu->audigy) {
@@ -185,7 +196,7 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci,
                strcpy(card->driver, "EMU10K1");
                strcpy(card->shortname, "Sound Blaster Live!");
        }
-       sprintf(card->longname, "%s (rev.%d) at 0x%lx, irq %i", card->shortname, emu->revision, emu->port, emu->irq);
+       sprintf(card->longname, "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i", card->shortname, emu->revision, emu->serial, emu->port, emu->irq);
 
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
@@ -211,15 +222,7 @@ static struct pci_driver driver = {
 
 static int __init alsa_card_emu10k1_init(void)
 {
-       int err;
-
-       if ((err = pci_module_init(&driver)) < 0) {
-#ifdef MODULE
-               printk(KERN_ERR "EMU10K1/Audigy soundcard not found or device busy\n");
-#endif
-               return err;
-       }
-       return 0;
+       return pci_module_init(&driver);
 }
 
 static void __exit alsa_card_emu10k1_exit(void)
@@ -229,27 +232,3 @@ static void __exit alsa_card_emu10k1_exit(void)
 
 module_init(alsa_card_emu10k1_init)
 module_exit(alsa_card_emu10k1_exit)
-
-#ifndef MODULE
-
-/* format is: snd-emu10k1=enable,index,id,
-                         seq_ports,max_synth_voices */
-
-static int __init alsa_card_emu10k1_setup(char *str)
-{
-       static unsigned __initdata nr_dev = 0;
-
-       if (nr_dev >= SNDRV_CARDS)
-               return 0;
-       (void)(get_option(&str,&enable[nr_dev]) == 2 &&
-              get_option(&str,&index[nr_dev]) == 2 &&
-              get_id(&str,&id[nr_dev]) == 2 &&
-              get_option(&str,&seq_ports[nr_dev]) == 2 &&
-              get_option(&str,&max_synth_voices[nr_dev]) == 2);
-       nr_dev++;
-       return 1;
-}
-
-__setup("snd-emu10k1=", alsa_card_emu10k1_setup);
-
-#endif /* ifndef MODULE */