Update of /cvsroot/alsa/alsa-kernel/pci
In directory sc8-pr-cvs1:/tmp/cvs-serv10067/pci

Modified Files:
        als4000.c azt3328.c cmipci.c ens1370.c es1968.c intel8x0.c 
        via82xx.c 
Log Message:
- removed joystick control from the card control API.
  added joystick (or joystick_port) module option instead.
- updated documents for this joystick fix.
- moved resource management for ALS4000 from sb-common header
  to the als4000 local code.


Index: als4000.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/als4000.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- als4000.c   12 Aug 2003 14:10:12 -0000      1.21
+++ als4000.c   14 Oct 2003 13:59:20 -0000      1.22
@@ -63,6 +63,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/gameport.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/rawmidi.h>
@@ -78,14 +79,15 @@
 MODULE_CLASSES("{sound}");
 MODULE_DEVICES("{{Avance Logic,ALS4000}}");
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK 1
+#endif
+
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
-static int joystick_port[SNDRV_CARDS] =
-#ifdef CONFIG_ISA
-       {0x200};        /* enable as default */
-#else
-       {0};    /* disabled */
+#ifdef SUPPORT_JOYSTICK
+static int joystick_port[SNDRV_CARDS];
 #endif
 
 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
@@ -105,6 +107,11 @@
 
 typedef struct {
        unsigned long gcr;
+       struct resource *res_gcr;
+#ifdef SUPPORT_JOYSTICK
+       struct gameport gameport;
+       struct resource *res_joystick;
+#endif
 } snd_card_als4000_t;
 
 static struct pci_device_id snd_als4000_ids[] = {
@@ -523,7 +530,7 @@
 
 /******************************************************************/
 
-static void __devinit snd_als4000_set_addr(unsigned long gcr,
+static void snd_als4000_set_addr(unsigned long gcr,
                                        unsigned int sb,
                                        unsigned int mpu,
                                        unsigned int opl,
@@ -574,6 +581,18 @@
        snd_card_als4000_t * acard = (snd_card_als4000_t *)card->private_data;
        /* make sure that interrupts are disabled */
        snd_als4000_gcr_write_addr( acard->gcr, 0x8c, 0);
+       /* free resources */
+#ifdef SUPPORT_JOYSTICK
+       if (acard->res_joystick) {
+               if (acard->gameport.io)
+                       gameport_unregister_port(&acard->gameport);
+               snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */
+               release_resource(acard->res_joystick);
+               kfree_nocheck(acard->res_joystick);
+       }
+#endif
+       release_resource(acard->res_gcr);
+       kfree_nocheck(acard->res_gcr);
 }
 
 static int __devinit snd_card_als4000_probe(struct pci_dev *pci,
@@ -588,6 +607,7 @@
        opl3_t *opl3;
        unsigned short word;
        int err;
+       int joystick = 0;
 
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
@@ -617,9 +637,6 @@
        pci_write_config_word(pci, PCI_COMMAND, word | PCI_COMMAND_IO);
        pci_set_master(pci);
        
-       /* disable all legacy ISA stuff except for joystick */
-       snd_als4000_set_addr(gcr, 0, 0, 0, joystick_port[dev]);
-       
        card = snd_card_new(index[dev], id[dev], THIS_MODULE, 
                            sizeof( snd_card_als4000_t ) );
        if (card == NULL) {
@@ -630,8 +647,17 @@
 
        acard = (snd_card_als4000_t *)card->private_data;
        acard->gcr = gcr;
+       acard->res_gcr = res_gcr_port;
        card->private_free = snd_card_als4000_free;
 
+       /* disable all legacy ISA stuff except for joystick */
+#ifdef SUPPORT_JOYSTICK
+       if (joystick_port[dev] > 0 &&
+           (acard->res_joystick = request_region(joystick_port[dev], 8, "ALS4000 
gameport")) != NULL)
+               joystick = joystick_port[dev];
+#endif
+       snd_als4000_set_addr(gcr, 0, 0, 0, joystick);
+       
        if ((err = snd_sbdsp_create(card,
                                    gcr + 0x10,
                                    pci->irq,
@@ -640,15 +666,12 @@
                                    -1,
                                    SB_HW_ALS4000,
                                    &chip)) < 0) {
-               release_resource(res_gcr_port);
-               kfree_nocheck(res_gcr_port);
                snd_card_free(card);
                return err;
        }
 
        chip->pci = pci;
        chip->alt_port = gcr;
-       chip->res_alt_port = res_gcr_port;
 
        snd_als4000_configure(chip);
        
@@ -680,6 +703,12 @@
                }
        }
 
+#ifdef SUPPORT_JOYSTICK
+       if (acard->res_joystick) {
+               acard->gameport.io = joystick;
+               gameport_register_port(&acard->gameport);
+       }
+#endif
        strcpy(card->driver, "ALS4000");
        strcpy(card->shortname, "Avance Logic ALS4000");
        sprintf(card->longname, "%s at 0x%lx, irq %i",
@@ -730,7 +759,7 @@
 
 #ifndef MODULE
 
-/* format is: snd-als4000=enable,index,id */
+/* format is: snd-als4000=enable,index,id,joystick_port */
 
 static int __init alsa_card_als4000_setup(char *str)
 {
@@ -740,7 +769,11 @@
                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_id(&str,&id[nr_dev]) == 2
+#ifdef SUPPORT_JOYSTICK
+              && get_option(&str,&joystick_port[nr_dev]) == 2
+#endif
+              );
        nr_dev++;
        return 1;
 }

Index: azt3328.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/azt3328.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- azt3328.c   16 Aug 2003 09:58:29 -0000      1.4
+++ azt3328.c   14 Oct 2003 13:59:20 -0000      1.5
@@ -97,6 +97,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/gameport.h>
 #include <sound/core.h>
 #include <sound/control.h>
 #include <sound/pcm.h>
@@ -113,6 +114,10 @@
 MODULE_CLASSES("{sound}");
 MODULE_DEVICES("{{Aztech,AZF3328}}");
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK 1
+#endif
+
 #define DEBUG_MISC     0
 #define DEBUG_CALLS    0
 #define DEBUG_MIXER    0
@@ -158,8 +163,10 @@
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
+#ifdef SUPPORT_JOYSTICK
 static int joystick[SNDRV_CARDS] =
        {-1};   /* "unset" as default */
+#endif
 
 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(index, "Index value for AZF3328 soundcard.");
@@ -170,9 +177,11 @@
 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(enable, "Enable AZF3328 soundcard.");
 MODULE_PARM_SYNTAX(enable, SNDRV_INDEX_DESC);
+#ifdef SUPPORT_JOYSTICK
 MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(joystick, "Forced joystick port enable for AZF3328 soundcard. (0 = 
force disable)");
 MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED);
+#endif
 
 typedef struct _snd_azf3328 azf3328_t;
 #define chip_t azf3328_t
@@ -190,7 +199,11 @@
        struct resource *res_synth_port;
        unsigned long mixer_port;
        struct resource *res_mixer_port;
-       unsigned long game_port;
+
+#ifdef SUPPORT_JOYSTICK
+       struct gameport gameport;
+       struct resource *res_joystick;
+#endif
 
        struct pci_dev *pci;
        snd_card_t *card;
@@ -1259,6 +1272,16 @@
 
         synchronize_irq(chip->irq);
       __end_hw:
+#ifdef SUPPORT_JOYSTICK
+       if (chip->res_joystick) {
+               gameport_unregister_port(&chip->gameport);
+               /* disable gameport */
+               snd_azf3328_io2_write(chip, IDX_IO2_LEGACY_ADDR,
+                                     snd_azf3328_io2_read(chip, IDX_IO2_LEGACY_ADDR) 
& ~LEGACY_JOY);
+               release_resource(chip->res_joystick);
+               kfree_nocheck(chip->res_joystick);
+       }
+#endif
         if (chip->res_codec_port) {
                release_resource(chip->res_codec_port);
                kfree_nocheck(chip->res_codec_port);
@@ -1419,53 +1442,53 @@
        return 0;
 }
 
+#ifdef SUPPORT_JOYSTICK
 static void __devinit snd_azf3328_config_joystick(azf3328_t *chip, int joystick)
 {
-       int i, detected = 0, activate = 0;
+       int i, activate = 0;
        char *msg = NULL;
        unsigned char val;
 
        if (joystick == -1) /* auto detection/activation */
        {
+               activate = 1;
                for (i=0x200; i <= 0x207; i++)
-                       if (inb(i) != 0xff)
-                               detected = 1; /* other joy found, don't activate */
+                       if (inb(i) != 0xff) {
+                               activate = 0;
+                               break;
+                       }
        }
 
-       if ((joystick == -1) && (detected == 1))
-       {
-               activate = 0;
-               msg = "DISABLED (address occupied by another joystick port)";
-       }
-       else
-       if ((joystick == -1) && (detected == 0))
-       {
-               activate = 1;
-               msg = "ENABLED (via autodetect)";
+       if (activate || joystick == 1) {
+               if ((chip->res_joystick = request_region(0x200, 8, "AZF3328 
gameport")) != NULL) {
+                       chip->gameport.io = 0x200;
+                       activate = 1;
+               } else
+                       activate = 0;
        }
-       else
        if (joystick == 0)
-       {
-               activate = 0;
                msg = "DISABLED (forced)";
-       }
-       else
-       if (joystick == 1)
-       {
-               activate = 1;
+       else if (joystick == 1 && activate)
                msg = "ENABLED (Warning: forced!)";
-       }
+       else if (activate)
+               msg = "ENABLED (via autodetect)";
+       else
+               msg = "DISABLED (address occupied by another joystick port)";
+
        val = inb(chip->io2_port + IDX_IO2_LEGACY_ADDR);
        if (activate)
-           val |= LEGACY_JOY;
+               val |= LEGACY_JOY;
        else
-           val &= ~LEGACY_JOY;
+               val &= ~LEGACY_JOY;
 
        outb(val, chip->io2_port + IDX_IO2_LEGACY_ADDR);
 #ifdef MODULE
        printk("azt3328: Joystick port: %s.\n", msg);
 #endif
+       if (activate)
+               gameport_register_port(&chip->gameport);
 }
+#endif
 
 static int __devinit snd_azf3328_probe(struct pci_dev *pci,
                                          const struct pci_device_id *pci_id)
@@ -1537,7 +1560,9 @@
 "azt3328: Feel free to contact [EMAIL PROTECTED] for bug reports etc.!\n");
 #endif
 
+#ifdef SUPPORT_JOYSTICK
        snd_azf3328_config_joystick(chip, joystick[dev]);
+#endif
 
        pci_set_drvdata(pci, chip);
        dev++;
@@ -1598,7 +1623,7 @@
 
 #ifndef MODULE
 
-/* format is: snd-azf3328=enable,index,id */
+/* format is: snd-azf3328=enable,index,id,joystick */
 
 static int __init alsa_card_azf3328_setup(char *str)
 {
@@ -1610,12 +1635,16 @@
                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_id(&str,&id[nr_dev]) == 2
+#ifdef SUPPORT_JOYSTICK
+              && get_option(&str,&joystick[nr_dev]) == 2
+#endif
+              );
        nr_dev++;
        snd_azf3328_dbgcallleave();
        return 1;
 }
 
-__setup("snd-azf3328=", alsa_card_azf3328_setup);
+__setup("snd-azt3328=", alsa_card_azf3328_setup);
 
 #endif /* ifndef MODULE */

Index: cmipci.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/cmipci.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- cmipci.c    14 Oct 2003 13:08:19 -0000      1.49
+++ cmipci.c    14 Oct 2003 13:59:20 -0000      1.50
@@ -31,6 +31,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/gameport.h>
 #include <sound/core.h>
 #include <sound/info.h>
 #include <sound/control.h>
@@ -52,6 +53,10 @@
                "{C-Media,CMI8338A},"
                "{C-Media,CMI8338B}}");
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK 1
+#endif
+
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable switches */
@@ -60,6 +65,9 @@
 #ifdef DO_SOFT_AC3
 static int soft_ac3[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)]=1};
 #endif
+#ifdef SUPPORT_JOYSTICK
+static int joystick[SNDRV_CARDS];
+#endif
 
 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(index, "Index value for C-Media PCI soundcard.");
@@ -81,6 +89,11 @@
 MODULE_PARM_DESC(soft_ac3, "Sofware-conversion of raw SPDIF packets (model 033 
only).");
 MODULE_PARM_SYNTAX(soft_ac3, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
 #endif
+#ifdef SUPPORT_JOYSTICK
+MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+MODULE_PARM_DESC(joystick, "Enable joystick.");
+MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
+#endif
 
 #ifndef PCI_DEVICE_ID_CMEDIA_CM8738
 #define PCI_DEVICE_ID_CMEDIA_CM8738    0x0111
@@ -339,6 +352,10 @@
 #define CM_EXTENT_MIDI   0x2
 #define CM_EXTENT_SYNTH          0x4
 
+/* fixed legacy joystick address */
+#define CM_JOYSTICK_ADDR       0x200
+  
+
 /*
  * pci ids
  */
@@ -480,6 +497,11 @@
        /* external MIDI */
        snd_rawmidi_t *rmidi;
 
+#ifdef SUPPORT_JOYSTICK
+       struct gameport gameport;
+       struct resource *res_joystick;
+#endif
+
        spinlock_t reg_lock;
 };
 
@@ -2599,7 +2621,7 @@
 DEFINE_BIT_SWITCH_ARG(fourch, CM_REG_MISC_CTRL, CM_N4SPK3D, 0, 0);
 DEFINE_BIT_SWITCH_ARG(line_rear, CM_REG_MIXER1, CM_SPK4, 1, 0);
 DEFINE_BIT_SWITCH_ARG(line_bass, CM_REG_LEGACY_CTRL, CM_LINE_AS_BASS, 0, 0);
-DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0);
+// DEFINE_BIT_SWITCH_ARG(joystick, CM_REG_FUNCTRL1, CM_JYSTK_EN, 0, 0); /* now module 
option */
 DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0, 0);
 
 #define DEFINE_SWITCH(sname, stype, sarg) \
@@ -2693,7 +2715,7 @@
 
 /* card control switches */
 static snd_kcontrol_new_t snd_cmipci_control_switches[] __devinitdata = {
-       DEFINE_CARD_SWITCH("Joystick", joystick),
+       // DEFINE_CARD_SWITCH("Joystick", joystick), /* now module option */
        DEFINE_CARD_SWITCH("Modem", modem),
 };
 
@@ -2901,6 +2923,14 @@
 
                free_irq(cm->irq, (void *)cm);
        }
+#ifdef SUPPORT_JOYSTICK
+       if (cm->res_joystick) {
+               gameport_unregister_port(&cm->gameport);
+               snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
+               release_resource(cm->res_joystick);
+               kfree_nocheck(cm->res_joystick);
+       }
+#endif
        if (cm->res_iobase) {
                release_resource(cm->res_iobase);
                kfree_nocheck(cm->res_iobase);
@@ -3106,6 +3136,15 @@
        snd_cmipci_set_bit(cm, CM_REG_MISC_CTRL, CM_SPDIF48K|CM_SPDF_AC97);
 #endif /* USE_VAR48KRATE */
 
+#ifdef SUPPORT_JOYSTICK
+       if (joystick[dev] &&
+           (cm->res_joystick = request_region(CM_JOYSTICK_ADDR, 8, "CMIPCI 
gameport")) != NULL) {
+               cm->gameport.io = CM_JOYSTICK_ADDR;
+               snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
+               gameport_register_port(&cm->gameport);
+       } else
+               snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN);
+#endif
        *rcmipci = cm;
        return 0;
 
@@ -3214,7 +3253,7 @@
 #ifndef MODULE
 
 /* format is: snd-cmipci=enable,index,id,
-                        mpu_port,fm_port */
+                        mpu_port,fm_port,soft_ac3,joystick */
 
 static int __init alsa_card_cmipci_setup(char *str)
 {
@@ -3226,7 +3265,14 @@
               get_option(&str,&index[nr_dev]) == 2 &&
               get_id(&str,&id[nr_dev]) == 2 &&
               get_option_long(&str,&mpu_port[nr_dev]) == 2 &&
-              get_option_long(&str,&fm_port[nr_dev]) == 2);
+              get_option_long(&str,&fm_port[nr_dev]) == 2
+#ifdef DO_SOFT_AC3
+              && get_option(&str,&soft_ac3[nr_dev]) == 2
+#endif
+#ifdef SUPPORT_JOYSTICK
+              && get_option(&str,&joystick[nr_dev]) == 2
+#endif
+              );
        nr_dev++;
        return 1;
 }

Index: ens1370.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/ens1370.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- ens1370.c   25 Sep 2003 18:55:43 -0000      1.50
+++ ens1370.c   14 Oct 2003 13:59:20 -0000      1.51
@@ -72,9 +72,20 @@
                "{Ectiva,EV1938}}");
 #endif
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK
+#endif
+
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable switches */
+#ifdef SUPPORT_JOYSTICK
+#ifdef CHIP1371
+static int joystick_port[SNDRV_CARDS];
+#else
+static int joystick[SNDRV_CARDS];
+#endif
+#endif
 
 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(index, "Index value for Ensoniq AudioPCI soundcard.");
@@ -85,6 +96,17 @@
 MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(enable, "Enable Ensoniq AudioPCI soundcard.");
 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
+#ifdef SUPPORT_JOYSTICK
+#ifdef CHIP1371
+MODULE_PARM(joystick_port, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+MODULE_PARM_DESC(joystick_port, "Joystick port address.");
+MODULE_PARM_SYNTAX(joystick_port, SNDRV_ENABLED 
",allows:{{0},{0x200},{0x208},{0x210},{0x218}},dialog:list");
+#else
+MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+MODULE_PARM_DESC(joystick, "Enable joystick.");
+MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
+#endif
+#endif /* SUPPORT_JOYSTICK */
 
 #ifndef PCI_DEVICE_ID_ENSONIQ_CT5880
 #define PCI_DEVICE_ID_ENSONIQ_CT5880    0x5880
@@ -416,9 +438,8 @@
        dma_addr_t bugbuf_addr;
 #endif
 
-#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#ifdef SUPPORT_JOYSTICK
        struct gameport gameport;
-       struct semaphore joy_sem;       // gameport configuration semaphore
 #endif
 };
 
@@ -1565,8 +1586,8 @@
 
 #endif /* CHIP1371 */
 
-/* generic control callbacks for ens1370 and for joystick */
-#if defined(CHIP1370) || defined(CONFIG_GAMEPORT) || (defined(MODULE) && 
defined(CONFIG_GAMEPORT_MODULE))
+/* generic control callbacks for ens1370 */
+#ifdef CHIP1370
 #define ENSONIQ_CONTROL(xname, mask) \
 { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = xname, .info = 
snd_ensoniq_control_info, \
   .get = snd_ensoniq_control_get, .put = snd_ensoniq_control_put, \
@@ -1593,7 +1614,6 @@
        return 0;
 }
 
-#ifdef CHIP1370
 static int snd_ensoniq_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * 
ucontrol)
 {
        ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol);
@@ -1611,14 +1631,11 @@
        spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
        return change;
 }
-#endif /* CHIP1370 */
-#endif /* CHIP1370 || GAMEPORT */
 
 /*
  * ENS1370 mixer
  */
 
-#ifdef CHIP1370
 static snd_kcontrol_new_t snd_es1370_controls[2] __devinitdata = {
 ENSONIQ_CONTROL("PCM 0 Output also on Line-In Jack", ES_1370_XCTL0),
 ENSONIQ_CONTROL("Mic +5V bias", ES_1370_XCTL1)
@@ -1660,129 +1677,32 @@
 
 #endif /* CHIP1370 */
 
-/*
- *  General Switches...
- */
-
-#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
-/* MQ: gameport driver connectivity */
-#define ENSONIQ_JOY_CONTROL(xname, mask) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = xname, .info = 
snd_ensoniq_control_info, \
-  .get = snd_ensoniq_control_get, .put = snd_ensoniq_joy_control_put, \
-  .private_value = mask }
-
-static int snd_ensoniq_joy_enable(ensoniq_t *ensoniq)
+#ifdef SUPPORT_JOYSTICK
+static int snd_ensoniq_joystick(ensoniq_t *ensoniq, long port)
 {
-       static unsigned long last_jiffies = 0;
-       unsigned long flags;
-
+       ensoniq->gameport.io = port;
        if (!request_region(ensoniq->gameport.io, 8, "ens137x: gameport")) {
-#define ES___GAMEPORT_LOG_DELAY (30*HZ)
-               // avoid log pollution: limit to 2 infos per minute
-               if (time_after(jiffies, last_jiffies + ES___GAMEPORT_LOG_DELAY)) {
-                       last_jiffies = jiffies;
-                       snd_printk("gameport io port 0x%03x in use", 
ensoniq->gameport.io);
-               }
-               return 0;
+               snd_printk("gameport io port 0x%03x in use", ensoniq->gameport.io);
+               return -EBUSY;
        }
-       spin_lock_irqsave(&ensoniq->reg_lock, flags);
        ensoniq->ctrl |= ES_JYSTK_EN;
+#ifdef CHIP1371
+       ensoniq->ctrl &= ~ES_1371_JOY_ASELM;
+       ensoniq->ctrl |= ES_1371_JOY_ASEL((ensoniq->gameport.io - 0x200) / 8);
+#endif
        outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
-       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
        gameport_register_port(&ensoniq->gameport);
-       return 1;
+       return 0;
 }
 
-static int snd_ensoniq_joy_disable(ensoniq_t *ensoniq)
+static void snd_ensoniq_joystick_free(ensoniq_t *ensoniq)
 {
-       unsigned long flags;
-
        gameport_unregister_port(&ensoniq->gameport);
-       spin_lock_irqsave(&ensoniq->reg_lock, flags);
        ensoniq->ctrl &= ~ES_JYSTK_EN;
        outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
-       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
        release_region(ensoniq->gameport.io, 8);
-       return 1;
-}
-
-static int snd_ensoniq_joy_control_put(snd_kcontrol_t * kcontrol, 
snd_ctl_elem_value_t * ucontrol)
-{
-       ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol);
-       unsigned int nval;
-       int change;
-
-       down(&ensoniq->joy_sem);
-       nval = ucontrol->value.integer.value[0] ? ES_JYSTK_EN : 0;
-       change = (ensoniq->ctrl & ES_JYSTK_EN) != nval; // spinlock shouldn't be 
needed because of joy_sem
-       if (change) {
-               if (nval)       // enable
-                       change = snd_ensoniq_joy_enable(ensoniq);
-               else    change = snd_ensoniq_joy_disable(ensoniq);
-       }
-       up(&ensoniq->joy_sem);
-       return change;
 }
-
-static snd_kcontrol_new_t snd_ensoniq_control_joystick __devinitdata =
-ENSONIQ_JOY_CONTROL("Joystick Enable", ES_JYSTK_EN);
-
-#ifdef CHIP1371
-
-#define ES1371_JOYSTICK_ADDR(xname) \
-{ .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = xname, .info = 
snd_es1371_joystick_addr_info, \
-  .get = snd_es1371_joystick_addr_get, .put = snd_es1371_joystick_addr_put }
-
-static int snd_es1371_joystick_addr_info(snd_kcontrol_t *kcontrol, 
snd_ctl_elem_info_t *uinfo)
-{
-        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
-        uinfo->count = 1;
-        uinfo->value.enumerated.items = 4;
-       if (uinfo->value.enumerated.item >= 4)
-               uinfo->value.enumerated.item = 3;
-       sprintf(uinfo->value.enumerated.name, "port 0x%x", 
(uinfo->value.enumerated.item * 8) + 0x200);
-        return 0;
-}
-
-static int snd_es1371_joystick_addr_get(snd_kcontrol_t * kcontrol, 
snd_ctl_elem_value_t * ucontrol)
-{
-       ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
-       
-       spin_lock_irqsave(&ensoniq->reg_lock, flags);
-       ucontrol->value.enumerated.item[0] = ES_1371_JOY_ASELI(ensoniq->ctrl);
-       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
-       return 0;
-}
-
-static int snd_es1371_joystick_addr_put(snd_kcontrol_t * kcontrol, 
snd_ctl_elem_value_t * ucontrol)
-{
-       ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol);
-       unsigned long flags;
-       unsigned int nval;
-       int change;
-
-       down(&ensoniq->joy_sem);
-       nval = ES_1371_JOY_ASEL(ucontrol->value.integer.value[0]);
-       spin_lock_irqsave(&ensoniq->reg_lock, flags);
-       if (!(change = !(ensoniq->ctrl & ES_JYSTK_EN)))
-               goto no_change; // FIXME: now we allow change only when joystick is 
disabled
-       change = (ensoniq->ctrl & ES_1371_JOY_ASELM) != nval;
-       ensoniq->ctrl &= ~ES_1371_JOY_ASELM;
-       ensoniq->ctrl |= nval;
-       outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL));
-       ensoniq->gameport.io = 0x200 + ES_1371_JOY_ASELI(nval) * 8;
-no_change:
-       spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
-       up(&ensoniq->joy_sem);
-       return change;
-}
-
-static snd_kcontrol_new_t snd_es1371_joystick_addr __devinitdata =
-ES1371_JOYSTICK_ADDR("Joystick Address");
-
-#endif /* CHIP1371 */
-#endif /* CONFIG_GAMEPORT */
+#endif /* SUPPORT_JOYSTICK */
 
 /*
 
@@ -1821,9 +1741,9 @@
 
 static int snd_ensoniq_free(ensoniq_t *ensoniq)
 {
-#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#ifdef SUPPORT_JOYSTICK
        if (ensoniq->ctrl & ES_JYSTK_EN)
-               snd_ensoniq_joy_disable(ensoniq);
+               snd_ensoniq_joystick_free(ensoniq);
 #endif
        if (ensoniq->irq < 0)
                goto __hw_end;
@@ -2019,14 +1939,6 @@
        outb(ensoniq->uartc = 0x00, ES_REG(ensoniq, UART_CONTROL));
        outb(0x00, ES_REG(ensoniq, UART_RES));
        outl(ensoniq->cssr, ES_REG(ensoniq, STATUS));
-#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
-       init_MUTEX(&ensoniq->joy_sem);
-#ifdef CHIP1371
-       snd_ctl_add(card, snd_ctl_new1(&snd_es1371_joystick_addr, ensoniq));
-#endif
-       snd_ctl_add(card, snd_ctl_new1(&snd_ensoniq_control_joystick, ensoniq));
-       ensoniq->gameport.io = 0x200;   // FIXME: is ES1371 configured like this above 
?
-#endif
        synchronize_irq(ensoniq->irq);
 
        if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops)) < 0) {
@@ -2331,6 +2243,21 @@
                snd_card_free(card);
                return err;
        }
+#ifdef SUPPORT_JOYSTICK
+#ifdef CHIP1371
+       switch (joystick_port[dev]) {
+       case 0x200:
+       case 0x208:
+       case 0x210:
+       case 0x218:
+               snd_ensoniq_joystick(ensoniq, joystick_port[dev]);
+               break;
+       }
+#else
+       if (joystick[dev])
+               snd_ensoniq_joystick(ensoniq, 0x200);
+#endif
+#endif /* SUPPORT_JOYSTICK */
        strcpy(card->driver, DRIVER_NAME);
 
        strcpy(card->shortname, "Ensoniq AudioPCI");
@@ -2386,7 +2313,7 @@
 
 #ifndef MODULE
 
-/* format is: snd-ens1370=enable,index,id */
+/* format is: snd-ens1370=enable,index,id,joystick */
 
 static int __init alsa_card_ens137x_setup(char *str)
 {
@@ -2396,7 +2323,15 @@
                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_id(&str,&id[nr_dev]) == 2
+#ifdef SUPPORT_JOYSTICK
+#ifdef CHIP1371
+              && get_option(&str,&joystick_port[nr_dev]) == 2
+#else
+              && get_option(&str,&joystick[nr_dev]) == 2
+#endif
+#endif
+              );
        nr_dev++;
        return 1;
 }

Index: es1968.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/es1968.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- es1968.c    13 Oct 2003 13:42:06 -0000      1.54
+++ es1968.c    14 Oct 2003 13:59:20 -0000      1.55
@@ -101,6 +101,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/gameport.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/mpu401.h>
@@ -121,6 +122,10 @@
                "{ESS,Maestro 1},"
                "{TerraTec,DMX}}");
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK 1
+#endif
+
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 1-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
@@ -130,6 +135,9 @@
 static int clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 static int use_pm[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
 static int enable_mpu[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
+#ifdef SUPPORT_JOYSTICK
+static int joystick[SNDRV_CARDS];
+#endif
 
 MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard.");
@@ -158,6 +166,11 @@
 MODULE_PARM(enable_mpu, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(enable_mpu, "Enable MPU401.  (0 = off, 1 = on, 2 = auto)");
 MODULE_PARM_SYNTAX(enable_mpu, SNDRV_ENABLED "," SNDRV_BOOLEAN_TRUE_DESC);
+#ifdef SUPPORT_JOYSTICK
+MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+MODULE_PARM_DESC(joystick, "Enable joystick.");
+MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
+#endif
 
 
 /* PCI Dev ID's */
@@ -601,6 +614,11 @@
 #ifdef CONFIG_PM
        u16 apu_map[NR_APUS][NR_APU_REGS];
 #endif
+
+#ifdef SUPPORT_JOYSTICK
+       struct gameport gameport;
+       struct resource *res_joystick;
+#endif
 };
 
 static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *regs);
@@ -2477,6 +2495,13 @@
        if (chip->res_io_port)
                snd_es1968_reset(chip);
 
+#ifdef SUPPORT_JOYSTICK
+       if (chip->res_joystick) {
+               gameport_unregister_port(&chip->gameport);
+               release_resource(chip->res_joystick);
+               kfree_nocheck(chip->res_joystick);
+       }
+#endif
        snd_es1968_set_acpi(chip, ACPI_D3);
        chip->master_switch = NULL;
        chip->master_volume = NULL;
@@ -2623,57 +2648,6 @@
 
 
 /*
- * joystick
- */
-
-static int snd_es1968_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t 
*uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
-
-static int snd_es1968_joystick_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t 
*ucontrol)
-{
-       es1968_t *chip = snd_kcontrol_chip(kcontrol);
-       u16 val;
-
-       pci_read_config_word(chip->pci, ESM_LEGACY_AUDIO_CONTROL, &val);
-       ucontrol->value.integer.value[0] = (val & 0x04) ? 1 : 0;
-       return 0;
-}
-
-static int snd_es1968_joystick_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t 
*ucontrol)
-{
-       es1968_t *chip = snd_kcontrol_chip(kcontrol);
-       u16 val, oval;
-
-       pci_read_config_word(chip->pci, ESM_LEGACY_AUDIO_CONTROL, &oval);
-       val = oval & ~0x04;
-       if (ucontrol->value.integer.value[0])
-               val |= 0x04;
-       if (val != oval) {
-               pci_write_config_word(chip->pci, ESM_LEGACY_AUDIO_CONTROL, val);
-               return 1;
-       }
-       return 0;
-}
-
-#define num_controls(ary) (sizeof(ary) / sizeof(snd_kcontrol_new_t))
-
-static snd_kcontrol_new_t snd_es1968_control_switches[] __devinitdata = {
-       {
-               .name = "Joystick",
-               .iface = SNDRV_CTL_ELEM_IFACE_CARD,
-               .info = snd_es1968_joystick_info,
-               .get = snd_es1968_joystick_get,
-               .put = snd_es1968_joystick_put,
-       }
-};
-
-/*
  */
 static int __devinit snd_es1968_probe(struct pci_dev *pci,
                                      const struct pci_device_id *pci_id)
@@ -2755,14 +2729,17 @@
                }
        }
 
-       /* card switches */
-       for (i = 0; i < num_controls(snd_es1968_control_switches); i++) {
-               err = snd_ctl_add(card, snd_ctl_new1(&snd_es1968_control_switches[i], 
chip));
-               if (err < 0) {
-                       snd_card_free(card);
-                       return err;
-               }
+#ifdef SUPPORT_JOYSTICK
+#define JOYSTICK_ADDR  0x200
+       if (joystick[dev] &&
+           (chip->res_joystick = request_region(JOYSTICK_ADDR, 8, "ES1968 gameport")) 
!= NULL) {
+               u16 val;
+               pci_read_config_word(pci, ESM_LEGACY_AUDIO_CONTROL, &val);
+               pci_write_config_word(pci, ESM_LEGACY_AUDIO_CONTROL, val | 0x04);
+               chip->gameport.io = JOYSTICK_ADDR;
+               gameport_register_port(&chip->gameport);
        }
+#endif
 
        snd_es1968_start_irq(chip);
 
@@ -2833,7 +2810,8 @@
                         pcm_substreams_c,
                         clock,
                         use_pm,
-                        enable_mpu
+                        enable_mpu,
+                        joystick
 */
 
 static int __init alsa_card_es1968_setup(char *str)
@@ -2850,7 +2828,11 @@
               get_option(&str,&pcm_substreams_c[nr_dev]) == 2 &&
               get_option(&str,&clock[nr_dev]) == 2 &&
               get_option(&str,&use_pm[nr_dev]) == 2 &&
-              get_option(&str,&enable_mpu[nr_dev]) == 2);
+              get_option(&str,&enable_mpu[nr_dev]) == 2
+#ifdef SUPPORT_JOYSTICK
+              && get_option(&str,&joystick[nr_dev]) == 2
+#endif
+              );
        nr_dev++;
        return 1;
 }

Index: intel8x0.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/intel8x0.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -r1.93 -r1.94
--- intel8x0.c  14 Oct 2003 11:29:03 -0000      1.93
+++ intel8x0.c  14 Oct 2003 13:59:20 -0000      1.94
@@ -33,6 +33,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/gameport.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
@@ -59,7 +60,9 @@
                "{AMD,AMD8111},"
                "{ALI,M5455}}");
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
 #define SUPPORT_JOYSTICK 1
+#endif
 #define SUPPORT_MIDI 1
 
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
@@ -67,12 +70,7 @@
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
 #ifdef SUPPORT_JOYSTICK
-static int joystick_port[SNDRV_CARDS] =
-#ifdef CONFIG_ISA
-       {0x200};        /* enable as default */
-#else
-       {0};    /* disabled */
-#endif
+static int joystick[SNDRV_CARDS];
 #endif
 #ifdef SUPPORT_MIDI
 static int mpu_port[SNDRV_CARDS]; /* disabled */
@@ -91,9 +89,9 @@
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
 MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:0");
 #ifdef SUPPORT_JOYSTICK
-MODULE_PARM(joystick_port, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
-MODULE_PARM_DESC(joystick_port, "Joystick port address for Intel i8x0 soundcard. (0 = 
disabled)");
-MODULE_PARM_SYNTAX(joystick_port, SNDRV_ENABLED ",allows:{{0},{0x200}},dialog:list");
+MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+MODULE_PARM_DESC(joystick, "Enable joystick for Intel i8x0 soundcard.");
+MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC);
 #endif
 #ifdef SUPPORT_MIDI
 MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
@@ -2656,9 +2654,16 @@
  * initialize joystick/midi addresses
  */
 
+#ifdef SUPPORT_JOYSTICK
+/* there is only one available device, so we keep it here */
+static struct pci_dev *ich_gameport_pci;
+static struct gameport ich_gameport = { .io = 0x200 };
+#endif
+
 static int __devinit snd_intel8x0_joystick_probe(struct pci_dev *pci,
                                                 const struct pci_device_id *id)
 {
+       u16 val;
        static int dev;
        if (dev >= SNDRV_CARDS)
                return -ENODEV;
@@ -2667,17 +2672,24 @@
                return -ENOENT;
        }
 
-       if (joystick_port[dev] > 0 || mpu_port[dev] > 0) {
-               u16 val;
-               pci_read_config_word(pci, 0xe6, &val);
-               if (joystick_port[dev] > 0)
+       pci_read_config_word(pci, 0xe6, &val);
+#ifdef SUPPORT_JOYSTICK
+       if (joystick[dev]) {
+               if (! request_region(ich_gameport.io, 8, "ICH gameport")) {
+                       printk(KERN_WARNING "intel8x0: cannot grab gameport 0x%x\n",  
ich_gameport.io);
+                       joystick[dev] = 0;
+               } else {
+                       ich_gameport_pci = pci;
+                       gameport_register_port(&ich_gameport);
                        val |= 0x100;
-               if (mpu_port[dev] == 0x300 || mpu_port[dev] == 0x330)
-                       val |= 0x20;
-               pci_write_config_word(pci, 0xe6, val | 0x100);
-
+               }
+       }
+#endif
+#ifdef SUPPORT_MIDI
+       if (mpu_port[dev] > 0) {
                if (mpu_port[dev] == 0x300 || mpu_port[dev] == 0x330) {
                        u8 b;
+                       val |= 0x20;
                        pci_read_config_byte(pci, 0xe2, &b);
                        if (mpu_port[dev] == 0x300)
                                b |= 0x08;
@@ -2686,9 +2698,27 @@
                        pci_write_config_byte(pci, 0xe2, b);
                }
        }
+#endif
+       pci_write_config_word(pci, 0xe6, val);
        return 0;
 }
 
+static void __devexit snd_intel8x0_joystick_remove(struct pci_dev *pci)
+{
+       u16 val;
+#ifdef SUPPORT_JOYSTICK
+       if (ich_gameport_pci == pci) {
+               gameport_unregister_port(&ich_gameport);
+               release_region(ich_gameport.io, 8);
+               ich_gameport_pci = NULL;
+       }
+#endif
+       /* disable joystick and MIDI */
+       pci_read_config_word(pci, 0xe6, &val);
+       val &= ~0x120;
+       pci_write_config_word(pci, 0xe6, val);
+}
+
 static struct pci_device_id snd_intel8x0_joystick_ids[] = {
        { 0x8086, 0x2410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },    /* 82801AA */
        { 0x8086, 0x2420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },    /* 82901AB */
@@ -2707,6 +2737,7 @@
        .name = "Intel ICH Joystick",
        .id_table = snd_intel8x0_joystick_ids,
        .probe = snd_intel8x0_joystick_probe,
+       .remove = __devexit_p(snd_intel8x0_joystick_remove),
 };
 
 static int have_joystick;
@@ -2749,7 +2780,7 @@
 
 #ifndef MODULE
 
-/* format is: snd-intel8x0=enable,index,id,ac97_clock,mpu_port */
+/* format is: snd-intel8x0=enable,index,id,ac97_clock,mpu_port,joystick */
 
 static int __init alsa_card_intel8x0_setup(char *str)
 {
@@ -2763,6 +2794,9 @@
               get_option(&str,&ac97_clock[nr_dev]) == 2
 #ifdef SUPPORT_MIDI
               && get_option(&str,&mpu_port[nr_dev]) == 2
+#endif
+#ifdef SUPPORT_JOYSTICK
+              && get_option(&str,&joystick[nr_dev]) == 2
 #endif
               );
        nr_dev++;

Index: via82xx.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/via82xx.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- via82xx.c   14 Oct 2003 13:08:20 -0000      1.59
+++ via82xx.c   14 Oct 2003 13:59:20 -0000      1.60
@@ -50,6 +50,7 @@
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
+#include <linux/gameport.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -69,10 +70,17 @@
 MODULE_CLASSES("{sound}");
 MODULE_DEVICES("{{VIA,VT82C686A/B/C,pci},{VIA,VT8233A/C,8235}}");
 
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK 1
+#endif
+
 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;     /* Index 0-MAX */
 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;      /* ID for this card */
 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;     /* Enable this card */
 static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1};
+#ifdef SUPPORT_JOYSTICK
+static int joystick[SNDRV_CARDS];
+#endif
 static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000};
 static int dxs_support[SNDRV_CARDS];
 
@@ -86,8 +94,13 @@
 MODULE_PARM_DESC(enable, "Enable audio part of VIA 82xx bridge.");
 MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
 MODULE_PARM(mpu_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l");
-MODULE_PARM_DESC(mpu_port, "MPU-401 port.");
+MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)");
 MODULE_PARM_SYNTAX(mpu_port, SNDRV_PORT_DESC);
+#ifdef SUPPORT_JOYSTICK
+MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
+MODULE_PARM_DESC(joystick, "Enable joystick. (VT82C686x only)");
+MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLE_DESC "," SNDRV_BOOLEAN_FALSE_DESC);
+#endif
 MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
 MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
 MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000");
@@ -461,6 +474,11 @@
        spinlock_t reg_lock;
        spinlock_t ac97_lock;
        snd_info_entry_t *proc_entry;
+
+#ifdef SUPPORT_JOYSTICK
+       struct gameport gameport;
+       struct resource *res_joystick;
+#endif
 };
 
 static struct pci_device_id snd_via82xx_ids[] = {
@@ -1559,53 +1577,6 @@
 }
 
 /*
- * joystick
- */
-
-static int snd_via82xx_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t 
*uinfo)
-{
-       uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
-       uinfo->count = 1;
-       uinfo->value.integer.min = 0;
-       uinfo->value.integer.max = 1;
-       return 0;
-}
-
-static int snd_via82xx_joystick_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t 
*ucontrol)
-{
-       via82xx_t *chip = snd_kcontrol_chip(kcontrol);
-       u16 val;
-
-       pci_read_config_word(chip->pci, VIA_FUNC_ENABLE, &val);
-       ucontrol->value.integer.value[0] = (val & VIA_FUNC_ENABLE_GAME) ? 1 : 0;
-       return 0;
-}
-
-static int snd_via82xx_joystick_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t 
*ucontrol)
-{
-       via82xx_t *chip = snd_kcontrol_chip(kcontrol);
-       u16 val, oval;
-
-       pci_read_config_word(chip->pci, VIA_FUNC_ENABLE, &oval);
-       val = oval & ~VIA_FUNC_ENABLE_GAME;
-       if (ucontrol->value.integer.value[0])
-               val |= VIA_FUNC_ENABLE_GAME;
-       if (val != oval) {
-               pci_write_config_word(chip->pci, VIA_FUNC_ENABLE, val);
-               return 1;
-       }
-       return 0;
-}
-
-static snd_kcontrol_new_t snd_via82xx_joystick_control __devinitdata = {
-       .name = "Joystick",
-       .iface = SNDRV_CTL_ELEM_IFACE_CARD,
-       .info = snd_via82xx_joystick_info,
-       .get = snd_via82xx_joystick_get,
-       .put = snd_via82xx_joystick_put,
-};
-
-/*
  *
  */
 
@@ -1689,6 +1660,16 @@
                legacy &= ~VIA_FUNC_ENABLE_MIDI;
                mpu_port[dev] = -1;
        }
+
+#ifdef SUPPORT_JOYSTICK
+#define JOYSTICK_ADDR  0x200
+       if (joystick[dev] &&
+           (chip->res_joystick = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport")) 
!= NULL) {
+               legacy |= VIA_FUNC_ENABLE_GAME;
+               chip->gameport.io = JOYSTICK_ADDR;
+       }
+#endif
+
        pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy);
        pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg);
        if (chip->mpu_res) {
@@ -1702,9 +1683,13 @@
                }
                pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy);
        }
-       
-       /* card switches */
-       return snd_ctl_add(chip->card, snd_ctl_new1(&snd_via82xx_joystick_control, 
chip));
+
+#ifdef SUPPORT_JOYSTICK
+       if (chip->res_joystick)
+               gameport_register_port(&chip->gameport);
+#endif
+
+       return 0;
 }
 
 
@@ -1866,6 +1851,13 @@
        if (chip->irq >= 0)
                free_irq(chip->irq, (void *)chip);
        if (chip->chip_type == TYPE_VIA686) {
+#ifdef SUPPORT_JOYSTICK
+               if (chip->res_joystick) {
+                       gameport_unregister_port(&chip->gameport);
+                       release_resource(chip->res_joystick);
+                       kfree_nocheck(chip->res_joystick);
+               }
+#endif
                pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, chip->old_legacy);
                pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, 
chip->old_legacy_cfg);
        }
@@ -2155,7 +2147,7 @@
 #ifndef MODULE
 
 /* format is: snd-via82xx=enable,index,id,
-                         mpu_port,ac97_clock,dxs_support */
+                         mpu_port,joystick,ac97_clock,dxs_support */
 
 static int __init alsa_card_via82xx_setup(char *str)
 {
@@ -2167,6 +2159,9 @@
               get_option(&str,&index[nr_dev]) == 2 &&
               get_id(&str,&id[nr_dev]) == 2 &&
               get_option_long(&str,&mpu_port[nr_dev]) == 2 &&
+#ifdef SUPPORT_JOYSTICK
+              get_option(&str,&joystick[nr_dev]) == 2 &&
+#endif
               get_option(&str,&ac97_clock[nr_dev]) == 2 &&
               get_option(&str,&dxs_support[nr_dev]) == 2);
        nr_dev++;



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to