Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 3542
b: refs/heads/master
c: c624e92
h: refs/heads/master
v: v3
  • Loading branch information
Dmitry Torokhov committed Jun 1, 2005
1 parent e755e24 commit 504d14c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f0f05a42268a8f3dc9dafbcec8ee67f9f8e5cec4
refs/heads/master: c624e92160e0d503594aff05a1e53fd0aafe41ad
88 changes: 58 additions & 30 deletions trunk/sound/oss/es1370.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,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
Expand Down Expand Up @@ -384,7 +388,10 @@ struct es1370_state {
unsigned char obuf[MIDIOUTBUF];
} midi;

#ifdef SUPPORT_JOYSTICK
struct gameport *gameport;
#endif

struct semaphore sem;
};

Expand Down Expand Up @@ -2553,10 +2560,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;

Expand Down Expand Up @@ -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
* 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;
Expand Down Expand Up @@ -2672,9 +2710,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);
Expand All @@ -2696,10 +2732,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:
Expand All @@ -2718,11 +2750,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);
Expand Down

0 comments on commit 504d14c

Please sign in to comment.