X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Foss%2Fes1370.c;h=ae55c536613a004995e561e9c5baa380d84e09eb;hb=134734d875a0a48d994ef20b9905209b4b8b6f75;hp=df8f0e334ffcecd858c9c85a683cffbb4d2d9c61;hpb=433e2af4175021d339b067f6e7ee0a4e4c4f7e2d;p=linux-2.6.git diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c index df8f0e334..ae55c5366 100644 --- a/sound/oss/es1370.c +++ b/sound/oss/es1370.c @@ -156,11 +156,16 @@ #include #include #include +#include #include #include #include +#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) +#define SUPPORT_JOYSTICK +#endif + /* --------------------------------------------------------------------- */ #undef OSS_DOCUMENTED_MIXER_SEMANTICS @@ -384,7 +389,10 @@ struct es1370_state { unsigned char obuf[MIDIOUTBUF]; } midi; - struct gameport gameport; +#ifdef SUPPORT_JOYSTICK + struct gameport *gameport; +#endif + struct semaphore sem; }; @@ -2525,9 +2533,9 @@ static int micbias[NR_DEVICE]; static unsigned int devindex; -MODULE_PARM(lineout, "1-" __MODULE_STRING(NR_DEVICE) "i"); +module_param_array(lineout, bool, NULL, 0); MODULE_PARM_DESC(lineout, "if 1 the LINE input is converted to LINE out"); -MODULE_PARM(micbias, "1-" __MODULE_STRING(NR_DEVICE) "i"); +module_param_array(micbias, bool, NULL, 0); MODULE_PARM_DESC(micbias, "sets the +5V bias for an electret microphone"); MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu"); @@ -2540,7 +2548,7 @@ MODULE_LICENSE("GPL"); static struct initvol { int mixch; int vol; -} initvol[] __initdata = { +} initvol[] __devinitdata = { { SOUND_MIXER_WRITE_VOLUME, 0x4040 }, { SOUND_MIXER_WRITE_PCM, 0x4040 }, { SOUND_MIXER_WRITE_SYNTH, 0x4040 }, @@ -2553,6 +2561,52 @@ static struct initvol { { SOUND_MIXER_WRITE_OGAIN, 0x4040 } }; +#ifdef SUPPORT_JOYSTICK + +static int __devinit es1370_register_gameport(struct es1370_state *s) +{ + struct gameport *gp; + + if (!request_region(0x200, JOY_EXTENT, "es1370")) { + printk(KERN_ERR "es1370: joystick io port 0x200 in use\n"); + return -EBUSY; + } + + s->gameport = gp = gameport_allocate_port(); + if (!gp) { + printk(KERN_ERR "es1370: can not allocate memory for gameport\n"); + release_region(0x200, JOY_EXTENT); + return -ENOMEM; + } + + gameport_set_name(gp, "ESS1370"); + gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev)); + gp->dev.parent = &s->dev->dev; + gp->io = 0x200; + + s->ctrl |= CTRL_JYSTK_EN; + outl(s->ctrl, s->io + ES1370_REG_CONTROL); + + gameport_register_port(gp); + + return 0; +} + +static inline void es1370_unregister_gameport(struct es1370_state *s) +{ + if (s->gameport) { + int gpio = s->gameport->io; + gameport_unregister_port(s->gameport); + release_region(gpio, JOY_EXTENT); + + } +} + +#else +static inline int es1370_register_gameport(struct es1370_state *s) { return -ENOSYS; } +static inline void es1370_unregister_gameport(struct es1370_state *s) { } +#endif /* SUPPORT_JOYSTICK */ + static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) { struct es1370_state *s; @@ -2568,7 +2622,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic return -ENODEV; if (pcidev->irq == 0) return -ENODEV; - i = pci_set_dma_mask(pcidev, 0xffffffff); + i = pci_set_dma_mask(pcidev, DMA_32BIT_MASK); if (i) { printk(KERN_WARNING "es1370: architecture does not support 32bit PCI busmaster DMA\n"); return i; @@ -2604,23 +2658,14 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic /* note: setting CTRL_SERR_DIS is reported to break * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL); - s->gameport.io = 0; - if (!request_region(0x200, JOY_EXTENT, "es1370")) - printk(KERN_ERR "es1370: joystick io port 0x200 in use\n"); - else { - s->ctrl |= CTRL_JYSTK_EN; - s->gameport.io = 0x200; - } if (lineout[devindex]) s->ctrl |= CTRL_XCTL0; if (micbias[devindex]) s->ctrl |= CTRL_XCTL1; s->sctrl = 0; - printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n" - KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n", - s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off", - (s->ctrl & CTRL_XCTL0) ? "out" : "in", - (s->ctrl & CTRL_XCTL1) ? "1" : "0"); + printk(KERN_INFO "es1370: adapter at io %#lx irq %u, line %s, mic impedance %s\n", + s->io, s->irq, (s->ctrl & CTRL_XCTL0) ? "out" : "in", + (s->ctrl & CTRL_XCTL1) ? "1" : "0"); /* register devices */ if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { ret = s->dev_audio; @@ -2665,9 +2710,8 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic mixer_ioctl(s, initvol[i].mixch, (unsigned long)&val); } set_fs(fs); - /* register gameport */ - if (s->gameport.io) - gameport_register_port(&s->gameport); + + es1370_register_gameport(s); /* store it in the driver field */ pci_set_drvdata(pcidev, s); @@ -2689,8 +2733,6 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic err_dev1: printk(KERN_ERR "es1370: cannot register misc device\n"); free_irq(s->irq, s); - if (s->gameport.io) - release_region(s->gameport.io, JOY_EXTENT); err_irq: release_region(s->io, ES1370_EXTENT); err_region: @@ -2709,10 +2751,7 @@ static void __devexit es1370_remove(struct pci_dev *dev) outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ synchronize_irq(s->irq); free_irq(s->irq, s); - if (s->gameport.io) { - gameport_unregister_port(&s->gameport); - release_region(s->gameport.io, JOY_EXTENT); - } + es1370_unregister_gameport(s); release_region(s->io, ES1370_EXTENT); unregister_sound_dsp(s->dev_audio); unregister_sound_mixer(s->dev_mixer); @@ -2740,7 +2779,7 @@ static struct pci_driver es1370_driver = { static int __init init_es1370(void) { printk(KERN_INFO "es1370: version v0.38 time " __TIME__ " " __DATE__ "\n"); - return pci_module_init(&es1370_driver); + return pci_register_driver(&es1370_driver); } static void __exit cleanup_es1370(void)