summaryrefslogtreecommitdiffstats
path: root/sound/oss/es1370.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-06-27 22:50:10 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-06-27 22:50:10 -0400
commitaa8f6dfd355021b4dd8b74b0588fd6fd8f21b79f (patch)
tree57ca3e27227695acbd97408eabb0f967726c3b51 /sound/oss/es1370.c
parentf45727d52d1581e9ff4df9d1a12a60789ad2d1eb (diff)
parent245ac8738b0b840552d56b842e70e750d65911cc (diff)
downloadop-kernel-dev-aa8f6dfd355021b4dd8b74b0588fd6fd8f21b79f.zip
op-kernel-dev-aa8f6dfd355021b4dd8b74b0588fd6fd8f21b79f.tar.gz
Merge /spare/repo/netdev-2.6 branch 'ieee80211'
Diffstat (limited to 'sound/oss/es1370.c')
-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 886f61c..8538085 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -162,6 +162,10 @@
#include <asm/page.h>
#include <asm/uaccess.h>
+#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE))
+#define SUPPORT_JOYSTICK
+#endif
+
/* --------------------------------------------------------------------- */
#undef OSS_DOCUMENTED_MIXER_SEMANTICS
@@ -385,7 +389,10 @@ struct es1370_state {
unsigned char obuf[MIDIOUTBUF];
} midi;
+#ifdef SUPPORT_JOYSTICK
struct gameport *gameport;
+#endif
+
struct semaphore sem;
};
@@ -2554,10 +2561,55 @@ 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;
- struct gameport *gp = NULL;
mm_segment_t fs;
int i, val, ret;
@@ -2606,28 +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);
- 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])
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;
@@ -2673,9 +2711,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
}
set_fs(fs);
- /* register gameport */
- if (gp)
- gameport_register_port(gp);
+ es1370_register_gameport(s);
/* store it in the driver field */
pci_set_drvdata(pcidev, s);
@@ -2697,10 +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) {
- release_region(s->gameport->io, JOY_EXTENT);
- gameport_free_port(s->gameport);
- }
err_irq:
release_region(s->io, ES1370_EXTENT);
err_region:
@@ -2719,11 +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) {
- int gpio = s->gameport->io;
- gameport_unregister_port(s->gameport);
- release_region(gpio, JOY_EXTENT);
- }
+ es1370_unregister_gameport(s);
release_region(s->io, ES1370_EXTENT);
unregister_sound_dsp(s->dev_audio);
unregister_sound_mixer(s->dev_mixer);
OpenPOWER on IntegriCloud