提交 c624e921 编写于 作者: D Dmitry Torokhov

Input: ES1370 (OSS) - do not carry around gameport code if gameport

       core support is disabled.
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 f0f05a42
...@@ -161,6 +161,10 @@ ...@@ -161,6 +161,10 @@
#include <asm/page.h> #include <asm/page.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
#define SUPPORT_JOYSTICK
#endif
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
#undef OSS_DOCUMENTED_MIXER_SEMANTICS #undef OSS_DOCUMENTED_MIXER_SEMANTICS
...@@ -384,7 +388,10 @@ struct es1370_state { ...@@ -384,7 +388,10 @@ struct es1370_state {
unsigned char obuf[MIDIOUTBUF]; unsigned char obuf[MIDIOUTBUF];
} midi; } midi;
#ifdef SUPPORT_JOYSTICK
struct gameport *gameport; struct gameport *gameport;
#endif
struct semaphore sem; struct semaphore sem;
}; };
...@@ -2553,10 +2560,55 @@ static struct initvol { ...@@ -2553,10 +2560,55 @@ static struct initvol {
{ SOUND_MIXER_WRITE_OGAIN, 0x4040 } { 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) static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
{ {
struct es1370_state *s; struct es1370_state *s;
struct gameport *gp = NULL;
mm_segment_t fs; mm_segment_t fs;
int i, val, ret; int i, val, ret;
...@@ -2605,28 +2657,14 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic ...@@ -2605,28 +2657,14 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
/* note: setting CTRL_SERR_DIS is reported to break /* note: setting CTRL_SERR_DIS is reported to break
* mic bias setting (by Kim.Berts@fisub.mail.abb.com) */ * 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->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL);
if (!request_region(0x200, JOY_EXTENT, "es1370")) {
printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
} else if (!(s->gameport = gp = gameport_allocate_port())) {
printk(KERN_ERR "es1370: can not allocate memory for gameport\n");
release_region(0x200, JOY_EXTENT);
} else {
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;
}
if (lineout[devindex]) if (lineout[devindex])
s->ctrl |= CTRL_XCTL0; s->ctrl |= CTRL_XCTL0;
if (micbias[devindex]) if (micbias[devindex])
s->ctrl |= CTRL_XCTL1; s->ctrl |= CTRL_XCTL1;
s->sctrl = 0; s->sctrl = 0;
printk(KERN_INFO "es1370: found adapter at io %#lx irq %u\n" printk(KERN_INFO "es1370: adapter at io %#lx irq %u, line %s, mic impedance %s\n",
KERN_INFO "es1370: features: joystick %s, line %s, mic impedance %s\n", s->io, s->irq, (s->ctrl & CTRL_XCTL0) ? "out" : "in",
s->io, s->irq, (s->ctrl & CTRL_JYSTK_EN) ? "on" : "off", (s->ctrl & CTRL_XCTL1) ? "1" : "0");
(s->ctrl & CTRL_XCTL0) ? "out" : "in",
(s->ctrl & CTRL_XCTL1) ? "1" : "0");
/* register devices */ /* register devices */
if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) { if ((s->dev_audio = register_sound_dsp(&es1370_audio_fops, -1)) < 0) {
ret = s->dev_audio; ret = s->dev_audio;
...@@ -2672,9 +2710,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic ...@@ -2672,9 +2710,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
} }
set_fs(fs); set_fs(fs);
/* register gameport */ es1370_register_gameport(s);
if (gp)
gameport_register_port(gp);
/* store it in the driver field */ /* store it in the driver field */
pci_set_drvdata(pcidev, s); pci_set_drvdata(pcidev, s);
...@@ -2696,10 +2732,6 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic ...@@ -2696,10 +2732,6 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
err_dev1: err_dev1:
printk(KERN_ERR "es1370: cannot register misc device\n"); printk(KERN_ERR "es1370: cannot register misc device\n");
free_irq(s->irq, s); free_irq(s->irq, s);
if (s->gameport) {
release_region(s->gameport->io, JOY_EXTENT);
gameport_free_port(s->gameport);
}
err_irq: err_irq:
release_region(s->io, ES1370_EXTENT); release_region(s->io, ES1370_EXTENT);
err_region: err_region:
...@@ -2718,11 +2750,7 @@ static void __devexit es1370_remove(struct pci_dev *dev) ...@@ -2718,11 +2750,7 @@ static void __devexit es1370_remove(struct pci_dev *dev)
outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */ outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */
synchronize_irq(s->irq); synchronize_irq(s->irq);
free_irq(s->irq, s); free_irq(s->irq, s);
if (s->gameport) { es1370_unregister_gameport(s);
int gpio = s->gameport->io;
gameport_unregister_port(s->gameport);
release_region(gpio, JOY_EXTENT);
}
release_region(s->io, ES1370_EXTENT); release_region(s->io, ES1370_EXTENT);
unregister_sound_dsp(s->dev_audio); unregister_sound_dsp(s->dev_audio);
unregister_sound_mixer(s->dev_mixer); unregister_sound_mixer(s->dev_mixer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册