[vox-tech] es1371 and why I love open source

Gabriel Rosa vox-tech@lists.lugod.org
Sat, 15 Dec 2001 06:07:25 -0800 (PST)


hey all,

I have an es1371 based sound card (sb128, i believe), and my 2.4.x joystick
ride has been kinda bumpy. Some kernels would detect the joystick port, others
wouldn't.

I really like having a working joystick so I can play emulated games :)

So tonight I decided that I was gonna get it working again. I inserted the
es1371 module, and noticed that it read

es1371: features: joystick 0x0

that's not right. I knew my port was somewhere in the 0x2** range.
If I gave it joystick=0x200, My machine would freeze right away when trying
to load the joystick module. (0x200 was the previous value I remembered).

So I looked in /usr/src/linux/drivers/sound/es1371.c, and note that the 0x2**
range is not really the address, but the offset. Ok, so far nothing
spectacular, just an understanding that my machine hangs because I try to
use the soundcard like a joystick ;)

So after some tinkering and printk'ing some values out, I realize that since
I wasn't giving a joystick offset, the es1371 driver was skipping right over
the joystick code. In reality, (after a bit of looking around) I believe that
it only tries to autodetect if there are more than 1 game ports.
(also, the code has a catch for 0x200, since it seems to be a common offset
for the gameport).  Otherwise, it doesn't even turn the port on.

Luckily, I'm staring right at the code, and I think i understand it ok. So
I added an else clause to the gameport init code that probes 0x200-0x218 (the
documented offset range), and then printk's the probed value.

A prayer to the penguin god, a 'rmmod es1371' and a 'insmod 1371' later
and I'm looking at:

es1371: found chip, vendor id 0x1274 device id 0x1371 revision 0x07
es1371: debug -> found 0x218.
ac97_codec: AC97 Audio codec, id: 0x8384:0x7608 (SigmaTel STAC9708)
es1371: found es1371 rev 7 at io 0xe400 irq 5
es1371: features: joystick 0x218

Aha, so my port must have slid over to 0x218, probably due to some small
change somewhere else that initialized my hardware differently.

Anyway, so I got it working.

What really makes me sing is that something didn't work, yet because I wanted
it to work, and I had the guts to go in and change stuff, so it now works.

now, if i were running windos and my joystick didn't work, what are the
chances that:

o. the driver would be open sources
 o. if not, that i would know who the author was
  o. i would have the author's email addr.
   o. he would be awake at 4am
    o. he would be willing to change things for me
     o. he would give me a binary to test every 15mins until it worked

i don't think so :)

-Gabe has free time after finals, many games to finish