aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-06-01 03:39:00 -0400
committerDmitry Torokhov <dtor_core@ameritech.net>2005-06-01 03:39:00 -0400
commitc624e92160e0d503594aff05a1e53fd0aafe41ad (patch)
treeb3d4f5fa556fc1a44ddf0e2dd403425ab1f3ec6b /sound/oss
parentf0f05a42268a8f3dc9dafbcec8ee67f9f8e5cec4 (diff)
Input: ES1370 (OSS) - do not carry around gameport code if gameport
core support is disabled. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'sound/oss')
-rw-r--r--sound/oss/es1370.c88
1 files changed, 58 insertions, 30 deletions
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c
index 056091cff266..563a52fbdd39 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -161,6 +161,10 @@
161#include <asm/page.h> 161#include <asm/page.h>
162#include <asm/uaccess.h> 162#include <asm/uaccess.h>
163 163
164#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
165#define SUPPORT_JOYSTICK
166#endif
167
164/* --------------------------------------------------------------------- */ 168/* --------------------------------------------------------------------- */
165 169
166#undef OSS_DOCUMENTED_MIXER_SEMANTICS 170#undef OSS_DOCUMENTED_MIXER_SEMANTICS
@@ -384,7 +388,10 @@ struct es1370_state {
384 unsigned char obuf[MIDIOUTBUF]; 388 unsigned char obuf[MIDIOUTBUF];
385 } midi; 389 } midi;
386 390
391#ifdef SUPPORT_JOYSTICK
387 struct gameport *gameport; 392 struct gameport *gameport;
393#endif
394
388 struct semaphore sem; 395 struct semaphore sem;
389}; 396};
390 397
@@ -2553,10 +2560,55 @@ static struct initvol {
2553 { SOUND_MIXER_WRITE_OGAIN, 0x4040 } 2560 { SOUND_MIXER_WRITE_OGAIN, 0x4040 }
2554}; 2561};
2555 2562
2563#ifdef SUPPORT_JOYSTICK
2564
2565static int __devinit es1370_register_gameport(struct es1370_state *s)
2566{
2567 struct gameport *gp;
2568
2569 if (!request_region(0x200, JOY_EXTENT, "es1370")) {
2570 printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
2571 return -EBUSY;
2572 }
2573
2574 s->gameport = gp = gameport_allocate_port();
2575 if (!gp) {
2576 printk(KERN_ERR "es1370: can not allocate memory for gameport\n");
2577 release_region(0x200, JOY_EXTENT);
2578 return -ENOMEM;
2579 }
2580
2581 gameport_set_name(gp, "ESS1370");
2582 gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev));
2583 gp->dev.parent = &s->dev->dev;
2584 gp->io = 0x200;
2585
2586 s->ctrl |= CTRL_JYSTK_EN;
2587 outl(s->ctrl, s->io + ES1370_REG_CONTROL);
2588
2589 gameport_register_port(gp);
2590
2591 return 0;
2592}
2593
2594static inline void es1370_unregister_gameport(struct es1370_state *s)
2595{
2596 if (s->gameport) {
2597 int gpio = s->gameport->io;
2598 gameport_unregister_port(s->gameport);
2599 release_region(gpio, JOY_EXTENT);
2600
2601 }
2602}
2603
2604#else
2605static inline int es1370_register_gameport(struct es1370_state *s) { return -ENOSYS; }
2606static inline void es1370_unregister_gameport(struct es1370_state *s) { }
2607#endif /* SUPPORT_JOYSTICK */
2608
2556static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) 2609static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
2557{ 2610{
2558 struct es1370_state *s; 2611 struct es1370_state *s;
2559 struct gameport *gp = NULL;
2560 mm_segment_t fs; 2612 mm_segment_t fs;
2561 int i, val, ret; 2613 int i, val, ret;
2562 2614
@@ -2605,28 +2657,14 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2605 /* note: setting CTRL_SERR_DIS is reported to break 2657 /* note: setting CTRL_SERR_DIS is reported to break
2606 * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ 2658 * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */
2607 s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL); 2659 s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL);
2608 if (!request_region(0x200, JOY_EXTENT, "es1370")) {
2609 printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
2610 } else if (!(s->gameport = gp = gameport_allocate_port())) {
2611 printk(KERN_ERR "es1370: can not allocate memory for gameport\n");
2612 release_region(0x200, JOY_EXTENT);
2613 } else {
2614 gameport_set_name(gp, "ESS1370");
2615 gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev));
2616 gp->dev.parent = &s->dev->dev;
2617 gp->io = 0x200;
2618 s->ctrl |= CTRL_JYSTK_EN;
2619 }
2620 if (lineout[devindex]) 2660 if (lineout[devindex])
2621 s->ctrl |= CTRL_XCTL0; 2661 s->ctrl |= CTRL_XCTL0;
2622 if (micbias[devindex]) 2662 if (micbias[devindex])
2623 s->ctrl |= CTRL_XCTL1; 2663 s->ctrl |= CTRL_XCTL1;
2624 s->sctrl = 0; 2664 s->sctrl = 0;
2625 printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n" 2665 printk(KERN_INFO "es1370: adapter at io %#lx irq %u, line %s, mic impedance %s\n",
2626 KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n", 2666 s->io, s->irq, (s->ctrl & CTRL_XCTL0) ? "out" : "in",
2627 s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off", 2667 (s->ctrl & CTRL_XCTL1) ? "1" : "0");
2628 (s->ctrl & CTRL_XCTL0) ? "out" : "in",
2629 (s->ctrl & CTRL_XCTL1) ? "1" : "0");
2630 /* register devices */ 2668 /* register devices */
2631 if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { 2669 if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) {
2632 ret = s->dev_audio; 2670 ret = s->dev_audio;
@@ -2672,9 +2710,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2672 } 2710 }
2673 set_fs(fs); 2711 set_fs(fs);
2674 2712
2675 /* register gameport */ 2713 es1370_register_gameport(s);
2676 if (gp)
2677 gameport_register_port(gp);
2678 2714
2679 /* store it in the driver field */ 2715 /* store it in the driver field */
2680 pci_set_drvdata(pcidev, s); 2716 pci_set_drvdata(pcidev, s);
@@ -2696,10 +2732,6 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
2696 err_dev1: 2732 err_dev1:
2697 printk(KERN_ERR "es1370: cannot register misc device\n"); 2733 printk(KERN_ERR "es1370: cannot register misc device\n");
2698 free_irq(s->irq, s); 2734 free_irq(s->irq, s);
2699 if (s->gameport) {
2700 release_region(s->gameport->io, JOY_EXTENT);
2701 gameport_free_port(s->gameport);
2702 }
2703 err_irq: 2735 err_irq:
2704 release_region(s->io, ES1370_EXTENT); 2736 release_region(s->io, ES1370_EXTENT);
2705 err_region: 2737 err_region:
@@ -2718,11 +2750,7 @@ static void __devexit es1370_remove(struct pci_dev *dev)
2718 outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ 2750 outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */
2719 synchronize_irq(s->irq); 2751 synchronize_irq(s->irq);
2720 free_irq(s->irq, s); 2752 free_irq(s->irq, s);
2721 if (s->gameport) { 2753 es1370_unregister_gameport(s);
2722 int gpio = s->gameport->io;
2723 gameport_unregister_port(s->gameport);
2724 release_region(gpio, JOY_EXTENT);
2725 }
2726 release_region(s->io, ES1370_EXTENT); 2754 release_region(s->io, ES1370_EXTENT);
2727 unregister_sound_dsp(s->dev_audio); 2755 unregister_sound_dsp(s->dev_audio);
2728 unregister_sound_mixer(s->dev_mixer); 2756 unregister_sound_mixer(s->dev_mixer);