aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-27 17:47:31 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-27 17:47:31 -0400
commit3e0777b8fa96f7073ed5d13d3bc1d573b766bef9 (patch)
tree3849e8457dd8f038ab7da025c708e275b43ea9c1 /sound
parenta94130e00038ebeb2f66901a4a4a9e05a03051c1 (diff)
parente5119885f00874453e837e3407014b73de2f4741 (diff)
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/dtor/input.git manually
Some manual fixups required due to clashes with the PF_FREEZE cleanups.
Diffstat (limited to 'sound')
-rw-r--r--sound/oss/Kconfig2
-rw-r--r--sound/oss/es1370.c88
-rw-r--r--sound/oss/es1371.c95
-rw-r--r--sound/oss/esssolo1.c26
-rw-r--r--sound/oss/mad16.c30
-rw-r--r--sound/oss/sonicvibes.c25
-rw-r--r--sound/oss/trident.c37
-rw-r--r--sound/pci/cs4281.c5
8 files changed, 211 insertions, 97 deletions
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index 3b1fafc8f4f5..7bd95ceab7cc 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -52,7 +52,7 @@ config SOUND_CMPCI_MIDI
52 52
53config SOUND_CMPCI_JOYSTICK 53config SOUND_CMPCI_JOYSTICK
54 bool "Enable joystick" 54 bool "Enable joystick"
55 depends on SOUND_CMPCI && X86 55 depends on SOUND_CMPCI && X86 && (GAMEPORT=y || SOUND_CMPCI=GAMEPORT)
56 help 56 help
57 Say Y here in order to enable the joystick port on a sound card using 57 Say Y here in order to enable the joystick port on a sound card using
58 the CMI8338 or the CMI8738 chipset. You need to config the 58 the CMI8338 or the CMI8738 chipset. You need to config the
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c
index 886f61c1c34a..8538085086e7 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -162,6 +162,10 @@
162#include <asm/page.h> 162#include <asm/page.h>
163#include <asm/uaccess.h> 163#include <asm/uaccess.h>
164 164
165#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
166#define SUPPORT_JOYSTICK
167#endif
168
165/* --------------------------------------------------------------------- */ 169/* --------------------------------------------------------------------- */
166 170
167#undef OSS_DOCUMENTED_MIXER_SEMANTICS 171#undef OSS_DOCUMENTED_MIXER_SEMANTICS
@@ -385,7 +389,10 @@ struct es1370_state {
385 unsigned char obuf[MIDIOUTBUF]; 389 unsigned char obuf[MIDIOUTBUF];
386 } midi; 390 } midi;
387 391
392#ifdef SUPPORT_JOYSTICK
388 struct gameport *gameport; 393 struct gameport *gameport;
394#endif
395
389 struct semaphore sem; 396 struct semaphore sem;
390}; 397};
391 398
@@ -2554,10 +2561,55 @@ static struct initvol {
2554 { SOUND_MIXER_WRITE_OGAIN, 0x4040 } 2561 { SOUND_MIXER_WRITE_OGAIN, 0x4040 }
2555}; 2562};
2556 2563
2564#ifdef SUPPORT_JOYSTICK
2565
2566static int __devinit es1370_register_gameport(struct es1370_state *s)
2567{
2568 struct gameport *gp;
2569
2570 if (!request_region(0x200, JOY_EXTENT, "es1370")) {
2571 printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
2572 return -EBUSY;
2573 }
2574
2575 s->gameport = gp = gameport_allocate_port();
2576 if (!gp) {
2577 printk(KERN_ERR "es1370: can not allocate memory for gameport\n");
2578 release_region(0x200, JOY_EXTENT);
2579 return -ENOMEM;
2580 }
2581
2582 gameport_set_name(gp, "ESS1370");
2583 gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev));
2584 gp->dev.parent = &s->dev->dev;
2585 gp->io = 0x200;
2586
2587 s->ctrl |= CTRL_JYSTK_EN;
2588 outl(s->ctrl, s->io + ES1370_REG_CONTROL);
2589
2590 gameport_register_port(gp);
2591
2592 return 0;
2593}
2594
2595static inline void es1370_unregister_gameport(struct es1370_state *s)
2596{
2597 if (s->gameport) {
2598 int gpio = s->gameport->io;
2599 gameport_unregister_port(s->gameport);
2600 release_region(gpio, JOY_EXTENT);
2601
2602 }
2603}
2604
2605#else
2606static inline int es1370_register_gameport(struct es1370_state *s) { return -ENOSYS; }
2607static inline void es1370_unregister_gameport(struct es1370_state *s) { }
2608#endif /* SUPPORT_JOYSTICK */
2609
2557static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2610static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
2558{ 2611{
2559 struct es1370_state *s; 2612 struct es1370_state *s;
2560 struct gameport *gp = NULL;
2561 mm_segment_t fs; 2613 mm_segment_t fs;
2562 int i, val, ret; 2614 int i, val, ret;
2563 2615
@@ -2606,28 +2658,14 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2606 /* note: setting CTRL_SERR_DIS is reported to break 2658 /* note: setting CTRL_SERR_DIS is reported to break
2607 * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ 2659 * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */
2608 s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL); 2660 s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL);
2609 if (!request_region(0x200, JOY_EXTENT, "es1370")) {
2610 printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
2611 } else if (!(s->gameport = gp = gameport_allocate_port())) {
2612 printk(KERN_ERR "es1370: can not allocate memory for gameport\n");
2613 release_region(0x200, JOY_EXTENT);
2614 } else {
2615 gameport_set_name(gp, "ESS1370");
2616 gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev));
2617 gp->dev.parent = &s->dev->dev;
2618 gp->io = 0x200;
2619 s->ctrl |= CTRL_JYSTK_EN;
2620 }
2621 if (lineout[devindex]) 2661 if (lineout[devindex])
2622 s->ctrl |= CTRL_XCTL0; 2662 s->ctrl |= CTRL_XCTL0;
2623 if (micbias[devindex]) 2663 if (micbias[devindex])
2624 s->ctrl |= CTRL_XCTL1; 2664 s->ctrl |= CTRL_XCTL1;
2625 s->sctrl = 0; 2665 s->sctrl = 0;
2626 printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n" 2666 printk(KERN_INFO "es1370: adapter at io %#lx irq %u, line %s, mic impedance %s\n",
2627 KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n", 2667 s->io, s->irq, (s->ctrl & CTRL_XCTL0) ? "out" : "in",
2628 s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off", 2668 (s->ctrl & CTRL_XCTL1) ? "1" : "0");
2629 (s->ctrl & CTRL_XCTL0) ? "out" : "in",
2630 (s->ctrl & CTRL_XCTL1) ? "1" : "0");
2631 /* register devices */ 2669 /* register devices */
2632 if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { 2670 if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) {
2633 ret = s->dev_audio; 2671 ret = s->dev_audio;
@@ -2673,9 +2711,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2673 } 2711 }
2674 set_fs(fs); 2712 set_fs(fs);
2675 2713
2676 /* register gameport */ 2714 es1370_register_gameport(s);
2677 if (gp)
2678 gameport_register_port(gp);
2679 2715
2680 /* store it in the driver field */ 2716 /* store it in the driver field */
2681 pci_set_drvdata(pcidev, s); 2717 pci_set_drvdata(pcidev, s);
@@ -2697,10 +2733,6 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2697 err_dev1: 2733 err_dev1:
2698 printk(KERN_ERR "es1370: cannot register misc device\n"); 2734 printk(KERN_ERR "es1370: cannot register misc device\n");
2699 free_irq(s->irq, s); 2735 free_irq(s->irq, s);
2700 if (s->gameport) {
2701 release_region(s->gameport->io, JOY_EXTENT);
2702 gameport_free_port(s->gameport);
2703 }
2704 err_irq: 2736 err_irq:
2705 release_region(s->io, ES1370_EXTENT); 2737 release_region(s->io, ES1370_EXTENT);
2706 err_region: 2738 err_region:
@@ -2719,11 +2751,7 @@ static void __devexit es1370_remove(struct pci_dev *dev)
2719 outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ 2751 outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */
2720 synchronize_irq(s->irq); 2752 synchronize_irq(s->irq);
2721 free_irq(s->irq, s); 2753 free_irq(s->irq, s);
2722 if (s->gameport) { 2754 es1370_unregister_gameport(s);
2723 int gpio = s->gameport->io;
2724 gameport_unregister_port(s->gameport);
2725 release_region(gpio, JOY_EXTENT);
2726 }
2727 release_region(s->io, ES1370_EXTENT); 2755 release_region(s->io, ES1370_EXTENT);
2728 unregister_sound_dsp(s->dev_audio); 2756 unregister_sound_dsp(s->dev_audio);
2729 unregister_sound_mixer(s->dev_mixer); 2757 unregister_sound_mixer(s->dev_mixer);
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index 9266b777387b..12a56d5ab498 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -134,6 +134,10 @@
134#include <asm/page.h> 134#include <asm/page.h>
135#include <asm/uaccess.h> 135#include <asm/uaccess.h>
136 136
137#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
138#define SUPPORT_JOYSTICK
139#endif
140
137/* --------------------------------------------------------------------- */ 141/* --------------------------------------------------------------------- */
138 142
139#undef OSS_DOCUMENTED_MIXER_SEMANTICS 143#undef OSS_DOCUMENTED_MIXER_SEMANTICS
@@ -454,7 +458,10 @@ struct es1371_state {
454 unsigned char obuf[MIDIOUTBUF]; 458 unsigned char obuf[MIDIOUTBUF];
455 } midi; 459 } midi;
456 460
461#ifdef SUPPORT_JOYSTICK
457 struct gameport *gameport; 462 struct gameport *gameport;
463#endif
464
458 struct semaphore sem; 465 struct semaphore sem;
459}; 466};
460 467
@@ -2787,12 +2794,63 @@ static struct
2787 { PCI_ANY_ID, PCI_ANY_ID } 2794 { PCI_ANY_ID, PCI_ANY_ID }
2788}; 2795};
2789 2796
2797#ifdef SUPPORT_JOYSTICK
2798
2799static int __devinit es1371_register_gameport(struct es1371_state *s)
2800{
2801 struct gameport *gp;
2802 int gpio;
2803
2804 for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08)
2805 if (request_region(gpio, JOY_EXTENT, "es1371"))
2806 break;
2807
2808 if (gpio < 0x200) {
2809 printk(KERN_ERR PFX "no free joystick address found\n");
2810 return -EBUSY;
2811 }
2812
2813 s->gameport = gp = gameport_allocate_port();
2814 if (!gp) {
2815 printk(KERN_ERR PFX "can not allocate memory for gameport\n");
2816 release_region(gpio, JOY_EXTENT);
2817 return -ENOMEM;
2818 }
2819
2820 gameport_set_name(gp, "ESS1371 Gameport");
2821 gameport_set_phys(gp, "isa%04x/gameport0", gpio);
2822 gp->dev.parent = &s->dev->dev;
2823 gp->io = gpio;
2824
2825 s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT);
2826 outl(s->ctrl, s->io + ES1371_REG_CONTROL);
2827
2828 gameport_register_port(gp);
2829
2830 return 0;
2831}
2832
2833static inline void es1371_unregister_gameport(struct es1371_state *s)
2834{
2835 if (s->gameport) {
2836 int gpio = s->gameport->io;
2837 gameport_unregister_port(s->gameport);
2838 release_region(gpio, JOY_EXTENT);
2839
2840 }
2841}
2842
2843#else
2844static inline int es1371_register_gameport(struct es1371_state *s) { return -ENOSYS; }
2845static inline void es1371_unregister_gameport(struct es1371_state *s) { }
2846#endif /* SUPPORT_JOYSTICK */
2847
2848
2790static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2849static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
2791{ 2850{
2792 struct es1371_state *s; 2851 struct es1371_state *s;
2793 struct gameport *gp;
2794 mm_segment_t fs; 2852 mm_segment_t fs;
2795 int i, gpio, val, res = -1; 2853 int i, val, res = -1;
2796 int idx; 2854 int idx;
2797 unsigned long tmo; 2855 unsigned long tmo;
2798 signed long tmo2; 2856 signed long tmo2;
@@ -2883,23 +2941,6 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
2883 } 2941 }
2884 } 2942 }
2885 2943
2886 for (gpio = 0x218; gpio >= 0x200; gpio -= 0x08)
2887 if (request_region(gpio, JOY_EXTENT, "es1371"))
2888 break;
2889
2890 if (gpio < 0x200) {
2891 printk(KERN_ERR PFX "no free joystick address found\n");
2892 } else if (!(s->gameport = gp = gameport_allocate_port())) {
2893 printk(KERN_ERR PFX "can not allocate memory for gameport\n");
2894 release_region(gpio, JOY_EXTENT);
2895 } else {
2896 gameport_set_name(gp, "ESS1371 Gameport");
2897 gameport_set_phys(gp, "isa%04x/gameport0", gpio);
2898 gp->dev.parent = &s->dev->dev;
2899 gp->io = gpio;
2900 s->ctrl |= CTRL_JYSTK_EN | (((gpio >> 3) & CTRL_JOY_MASK) << CTRL_JOY_SHIFT);
2901 }
2902
2903 s->sctrl = 0; 2944 s->sctrl = 0;
2904 cssr = 0; 2945 cssr = 0;
2905 s->spdif_volume = -1; 2946 s->spdif_volume = -1;
@@ -2969,9 +3010,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
2969 /* turn on S/PDIF output driver if requested */ 3010 /* turn on S/PDIF output driver if requested */
2970 outl(cssr, s->io+ES1371_REG_STATUS); 3011 outl(cssr, s->io+ES1371_REG_STATUS);
2971 3012
2972 /* register gameport */ 3013 es1371_register_gameport(s);
2973 if (s->gameport)
2974 gameport_register_port(s->gameport);
2975 3014
2976 /* store it in the driver field */ 3015 /* store it in the driver field */
2977 pci_set_drvdata(pcidev, s); 3016 pci_set_drvdata(pcidev, s);
@@ -2980,13 +3019,9 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
2980 /* increment devindex */ 3019 /* increment devindex */
2981 if (devindex < NR_DEVICE-1) 3020 if (devindex < NR_DEVICE-1)
2982 devindex++; 3021 devindex++;
2983 return 0; 3022 return 0;
2984 3023
2985 err_gp: 3024 err_gp:
2986 if (s->gameport) {
2987 release_region(s->gameport->io, JOY_EXTENT);
2988 gameport_free_port(s->gameport);
2989 }
2990#ifdef ES1371_DEBUG 3025#ifdef ES1371_DEBUG
2991 if (s->ps) 3026 if (s->ps)
2992 remove_proc_entry("es1371", NULL); 3027 remove_proc_entry("es1371", NULL);
@@ -3025,11 +3060,7 @@ static void __devexit es1371_remove(struct pci_dev *dev)
3025 outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */ 3060 outl(0, s->io+ES1371_REG_SERIAL_CONTROL); /* clear serial interrupts */
3026 synchronize_irq(s->irq); 3061 synchronize_irq(s->irq);
3027 free_irq(s->irq, s); 3062 free_irq(s->irq, s);
3028 if (s->gameport) { 3063 es1371_unregister_gameport(s);
3029 int gpio = s->gameport->io;
3030 gameport_unregister_port(s->gameport);
3031 release_region(gpio, JOY_EXTENT);
3032 }
3033 release_region(s->io, ES1371_EXTENT); 3064 release_region(s->io, ES1371_EXTENT);
3034 unregister_sound_dsp(s->dev_audio); 3065 unregister_sound_dsp(s->dev_audio);
3035 unregister_sound_mixer(s->codec->dev_mixer); 3066 unregister_sound_mixer(s->codec->dev_mixer);
diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
index fb09065d07c8..a4ecab2f0522 100644
--- a/sound/oss/esssolo1.c
+++ b/sound/oss/esssolo1.c
@@ -150,6 +150,10 @@
150 150
151#define FMODE_DMFM 0x10 151#define FMODE_DMFM 0x10
152 152
153#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
154#define SUPPORT_JOYSTICK 1
155#endif
156
153static struct pci_driver solo1_driver; 157static struct pci_driver solo1_driver;
154 158
155/* --------------------------------------------------------------------- */ 159/* --------------------------------------------------------------------- */
@@ -227,7 +231,9 @@ struct solo1_state {
227 unsigned char obuf[MIDIOUTBUF]; 231 unsigned char obuf[MIDIOUTBUF];
228 } midi; 232 } midi;
229 233
234#if SUPPORT_JOYSTICK
230 struct gameport *gameport; 235 struct gameport *gameport;
236#endif
231}; 237};
232 238
233/* --------------------------------------------------------------------- */ 239/* --------------------------------------------------------------------- */
@@ -2281,6 +2287,7 @@ solo1_resume(struct pci_dev *pci_dev) {
2281 return 0; 2287 return 0;
2282} 2288}
2283 2289
2290#ifdef SUPPORT_JOYSTICK
2284static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port) 2291static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port)
2285{ 2292{
2286 struct gameport *gp; 2293 struct gameport *gp;
@@ -2307,6 +2314,19 @@ static int __devinit solo1_register_gameport(struct solo1_state *s, int io_port)
2307 return 0; 2314 return 0;
2308} 2315}
2309 2316
2317static inline void solo1_unregister_gameport(struct solo1_state *s)
2318{
2319 if (s->gameport) {
2320 int gpio = s->gameport->io;
2321 gameport_unregister_port(s->gameport);
2322 release_region(gpio, GAMEPORT_EXTENT);
2323 }
2324}
2325#else
2326static inline int solo1_register_gameport(struct solo1_state *s, int io_port) { return -ENOSYS; }
2327static inline void solo1_unregister_gameport(struct solo1_state *s) { }
2328#endif /* SUPPORT_JOYSTICK */
2329
2310static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2330static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
2311{ 2331{
2312 struct solo1_state *s; 2332 struct solo1_state *s;
@@ -2438,11 +2458,7 @@ static void __devexit solo1_remove(struct pci_dev *dev)
2438 synchronize_irq(s->irq); 2458 synchronize_irq(s->irq);
2439 pci_write_config_word(s->dev, 0x60, 0); /* turn off DDMA controller address space */ 2459 pci_write_config_word(s->dev, 0x60, 0); /* turn off DDMA controller address space */
2440 free_irq(s->irq, s); 2460 free_irq(s->irq, s);
2441 if (s->gameport) { 2461 solo1_unregister_gameport(s);
2442 int gpio = s->gameport->io;
2443 gameport_unregister_port(s->gameport);
2444 release_region(gpio, GAMEPORT_EXTENT);
2445 }
2446 release_region(s->iobase, IOBASE_EXTENT); 2462 release_region(s->iobase, IOBASE_EXTENT);
2447 release_region(s->sbbase+FMSYNTH_EXTENT, SBBASE_EXTENT-FMSYNTH_EXTENT); 2463 release_region(s->sbbase+FMSYNTH_EXTENT, SBBASE_EXTENT-FMSYNTH_EXTENT);
2448 release_region(s->ddmabase, DDMABASE_EXTENT); 2464 release_region(s->ddmabase, DDMABASE_EXTENT);
diff --git a/sound/oss/mad16.c b/sound/oss/mad16.c
index a7067f169919..aa3c50db66c4 100644
--- a/sound/oss/mad16.c
+++ b/sound/oss/mad16.c
@@ -50,9 +50,12 @@
50#include "sb.h" 50#include "sb.h"
51#include "mpu401.h" 51#include "mpu401.h"
52 52
53#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
54#define SUPPORT_JOYSTICK 1
55#endif
56
53static int mad16_conf; 57static int mad16_conf;
54static int mad16_cdsel; 58static int mad16_cdsel;
55static struct gameport *gameport;
56static DEFINE_SPINLOCK(lock); 59static DEFINE_SPINLOCK(lock);
57 60
58#define C928 1 61#define C928 1
@@ -902,6 +905,10 @@ static int __initdata irq_map[16] =
902 -1, -1, -1, -1 905 -1, -1, -1, -1
903}; 906};
904 907
908#ifdef SUPPORT_JOYSTICK
909
910static struct gameport *gameport;
911
905static int __devinit mad16_register_gameport(int io_port) 912static int __devinit mad16_register_gameport(int io_port)
906{ 913{
907 if (!request_region(io_port, 1, "mad16 gameport")) { 914 if (!request_region(io_port, 1, "mad16 gameport")) {
@@ -925,6 +932,20 @@ static int __devinit mad16_register_gameport(int io_port)
925 return 0; 932 return 0;
926} 933}
927 934
935static inline void mad16_unregister_gameport(void)
936{
937 if (gameport) {
938 /* the gameport was initialized so we must free it up */
939 gameport_unregister_port(gameport);
940 gameport = NULL;
941 release_region(0x201, 1);
942 }
943}
944#else
945static inline int mad16_register_gameport(int io_port) { return -ENOSYS; }
946static inline void mad16_unregister_gameport(void) { }
947#endif
948
928static int __devinit init_mad16(void) 949static int __devinit init_mad16(void)
929{ 950{
930 int dmatype = 0; 951 int dmatype = 0;
@@ -1060,12 +1081,7 @@ static void __exit cleanup_mad16(void)
1060{ 1081{
1061 if (found_mpu) 1082 if (found_mpu)
1062 unload_mad16_mpu(&cfg_mpu); 1083 unload_mad16_mpu(&cfg_mpu);
1063 if (gameport) { 1084 mad16_unregister_gameport();
1064 /* the gameport was initialized so we must free it up */
1065 gameport_unregister_port(gameport);
1066 gameport = NULL;
1067 release_region(0x201, 1);
1068 }
1069 unload_mad16(&cfg); 1085 unload_mad16(&cfg);
1070 release_region(MC0_PORT, 12); 1086 release_region(MC0_PORT, 12);
1071} 1087}
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index 06047e7979af..17d0e461f8d8 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -122,6 +122,9 @@
122 122
123#include "dm.h" 123#include "dm.h"
124 124
125#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
126#define SUPPORT_JOYSTICK 1
127#endif
125 128
126/* --------------------------------------------------------------------- */ 129/* --------------------------------------------------------------------- */
127 130
@@ -365,7 +368,9 @@ struct sv_state {
365 unsigned char obuf[MIDIOUTBUF]; 368 unsigned char obuf[MIDIOUTBUF];
366 } midi; 369 } midi;
367 370
371#if SUPPORT_JOYSTICK
368 struct gameport *gameport; 372 struct gameport *gameport;
373#endif
369}; 374};
370 375
371/* --------------------------------------------------------------------- */ 376/* --------------------------------------------------------------------- */
@@ -2485,6 +2490,7 @@ static struct initvol {
2485#define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \ 2490#define RSRCISIOREGION(dev,num) (pci_resource_start((dev), (num)) != 0 && \
2486 (pci_resource_flags((dev), (num)) & IORESOURCE_IO)) 2491 (pci_resource_flags((dev), (num)) & IORESOURCE_IO))
2487 2492
2493#ifdef SUPPORT_JOYSTICK
2488static int __devinit sv_register_gameport(struct sv_state *s, int io_port) 2494static int __devinit sv_register_gameport(struct sv_state *s, int io_port)
2489{ 2495{
2490 struct gameport *gp; 2496 struct gameport *gp;
@@ -2511,6 +2517,19 @@ static int __devinit sv_register_gameport(struct sv_state *s, int io_port)
2511 return 0; 2517 return 0;
2512} 2518}
2513 2519
2520static inline void sv_unregister_gameport(struct sv_state *s)
2521{
2522 if (s->gameport) {
2523 int gpio = s->gameport->io;
2524 gameport_unregister_port(s->gameport);
2525 release_region(gpio, SV_EXTENT_GAME);
2526 }
2527}
2528#else
2529static inline int sv_register_gameport(struct sv_state *s, int io_port) { return -ENOSYS; }
2530static inline void sv_unregister_gameport(struct sv_state *s) { }
2531#endif /* SUPPORT_JOYSTICK */
2532
2514static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2533static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
2515{ 2534{
2516 static char __devinitdata sv_ddma_name[] = "S3 Inc. SonicVibes DDMA Controller"; 2535 static char __devinitdata sv_ddma_name[] = "S3 Inc. SonicVibes DDMA Controller";
@@ -2711,11 +2730,7 @@ static void __devexit sv_remove(struct pci_dev *dev)
2711 /*outb(0, s->iodmaa + SV_DMA_RESET);*/ 2730 /*outb(0, s->iodmaa + SV_DMA_RESET);*/
2712 /*outb(0, s->iodmac + SV_DMA_RESET);*/ 2731 /*outb(0, s->iodmac + SV_DMA_RESET);*/
2713 free_irq(s->irq, s); 2732 free_irq(s->irq, s);
2714 if (s->gameport) { 2733 sv_unregister_gameport(s);
2715 int gpio = s->gameport->io;
2716 gameport_unregister_port(s->gameport);
2717 release_region(gpio, SV_EXTENT_GAME);
2718 }
2719 release_region(s->iodmac, SV_EXTENT_DMA); 2734 release_region(s->iodmac, SV_EXTENT_DMA);
2720 release_region(s->iodmaa, SV_EXTENT_DMA); 2735 release_region(s->iodmaa, SV_EXTENT_DMA);
2721 release_region(s->ioenh, SV_EXTENT_ENH); 2736 release_region(s->ioenh, SV_EXTENT_ENH);
diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index 47537f0a5b05..5f0ad6bb43b9 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -228,6 +228,10 @@
228 228
229#define DRIVER_VERSION "0.14.10j-2.6" 229#define DRIVER_VERSION "0.14.10j-2.6"
230 230
231#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
232#define SUPPORT_JOYSTICK 1
233#endif
234
231/* magic numbers to protect our data structures */ 235/* magic numbers to protect our data structures */
232#define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */ 236#define TRIDENT_CARD_MAGIC 0x5072696E /* "Prin" */
233#define TRIDENT_STATE_MAGIC 0x63657373 /* "cess" */ 237#define TRIDENT_STATE_MAGIC 0x63657373 /* "cess" */
@@ -4252,24 +4256,25 @@ trident_ac97_init(struct trident_card *card)
4252 return num_ac97 + 1; 4256 return num_ac97 + 1;
4253} 4257}
4254 4258
4259#ifdef SUPPORT_JOYSTICK
4255/* Gameport functions for the cards ADC gameport */ 4260/* Gameport functions for the cards ADC gameport */
4256 4261
4257static unsigned char 4262static unsigned char trident_game_read(struct gameport *gameport)
4258trident_game_read(struct gameport *gameport)
4259{ 4263{
4260 struct trident_card *card = gameport->port_data; 4264 struct trident_card *card = gameport->port_data;
4265
4261 return inb(TRID_REG(card, T4D_GAME_LEG)); 4266 return inb(TRID_REG(card, T4D_GAME_LEG));
4262} 4267}
4263 4268
4264static void 4269static void trident_game_trigger(struct gameport *gameport)
4265trident_game_trigger(struct gameport *gameport)
4266{ 4270{
4267 struct trident_card *card = gameport->port_data; 4271 struct trident_card *card = gameport->port_data;
4272
4268 outb(0xff, TRID_REG(card, T4D_GAME_LEG)); 4273 outb(0xff, TRID_REG(card, T4D_GAME_LEG));
4269} 4274}
4270 4275
4271static int 4276static int trident_game_cooked_read(struct gameport *gameport,
4272trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons) 4277 int *axes, int *buttons)
4273{ 4278{
4274 struct trident_card *card = gameport->port_data; 4279 struct trident_card *card = gameport->port_data;
4275 int i; 4280 int i;
@@ -4285,8 +4290,7 @@ trident_game_cooked_read(struct gameport *gameport, int *axes, int *buttons)
4285 return 0; 4290 return 0;
4286} 4291}
4287 4292
4288static int 4293static int trident_game_open(struct gameport *gameport, int mode)
4289trident_game_open(struct gameport *gameport, int mode)
4290{ 4294{
4291 struct trident_card *card = gameport->port_data; 4295 struct trident_card *card = gameport->port_data;
4292 4296
@@ -4305,8 +4309,7 @@ trident_game_open(struct gameport *gameport, int mode)
4305 return 0; 4309 return 0;
4306} 4310}
4307 4311
4308static int __devinit 4312static int __devinit trident_register_gameport(struct trident_card *card)
4309trident_register_gameport(struct trident_card *card)
4310{ 4313{
4311 struct gameport *gp; 4314 struct gameport *gp;
4312 4315
@@ -4330,6 +4333,17 @@ trident_register_gameport(struct trident_card *card)
4330 return 0; 4333 return 0;
4331} 4334}
4332 4335
4336static inline void trident_unregister_gameport(struct trident_card *card)
4337{
4338 if (card->gameport)
4339 gameport_unregister_port(card->gameport);
4340}
4341
4342#else
4343static inline int trident_register_gameport(struct trident_card *card) { return -ENOSYS; }
4344static inline void trident_unregister_gameport(struct trident_card *card) { }
4345#endif /* SUPPORT_JOYSTICK */
4346
4333/* install the driver, we do not allocate hardware channel nor DMA buffer */ 4347/* install the driver, we do not allocate hardware channel nor DMA buffer */
4334/* now, they are defered until "ACCESS" time (in prog_dmabuf called by */ 4348/* now, they are defered until "ACCESS" time (in prog_dmabuf called by */
4335/* open/read/write/ioctl/mmap) */ 4349/* open/read/write/ioctl/mmap) */
@@ -4569,8 +4583,7 @@ trident_remove(struct pci_dev *pci_dev)
4569 } 4583 }
4570 4584
4571 /* Unregister gameport */ 4585 /* Unregister gameport */
4572 if (card->gameport) 4586 trident_unregister_gameport(card);
4573 gameport_unregister_port(card->gameport);
4574 4587
4575 /* Kill interrupts, and SP/DIF */ 4588 /* Kill interrupts, and SP/DIF */
4576 trident_disable_loop_interrupts(card); 4589 trident_disable_loop_interrupts(card);
diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c
index b6e1854e9389..eb3c52b03af3 100644
--- a/sound/pci/cs4281.c
+++ b/sound/pci/cs4281.c
@@ -1338,11 +1338,6 @@ static inline int snd_cs4281_create_gameport(cs4281_t *chip) { return -ENOSYS; }
1338static inline void snd_cs4281_free_gameport(cs4281_t *chip) { } 1338static inline void snd_cs4281_free_gameport(cs4281_t *chip) { }
1339#endif /* CONFIG_GAMEPORT || (MODULE && CONFIG_GAMEPORT_MODULE) */ 1339#endif /* CONFIG_GAMEPORT || (MODULE && CONFIG_GAMEPORT_MODULE) */
1340 1340
1341
1342/*
1343
1344 */
1345
1346static int snd_cs4281_free(cs4281_t *chip) 1341static int snd_cs4281_free(cs4281_t *chip)
1347{ 1342{
1348 snd_cs4281_free_gameport(chip); 1343 snd_cs4281_free_gameport(chip);