marqs85 / db9_gpio_rpi

8 stars 10 forks source link

Saturn controller delay too low #7

Open DrEggman399 opened 4 years ago

DrEggman399 commented 4 years ago

I used this driver in conjunction with RetroPie 4.5.1, but was receiving phantom inputs on Data 0 and Data 1 lines (see the readme and https://gamesx.com/controldata/saturn.htm for details).

After investigating my wiring and recompiling from source multiple times, I fixed the issue by changing DB9_SATURN_DELAY to 7 matching the analog controller and recompiling from source.

I'm not sure it warrants a PR as I'm not sure if this is just me or if someone else can confirm.

If you're doing it within Retropie:

1) use the gui to install the gamecon drivers 2) shift+f4 to open the terminal 3) sudo dkms remove db9_gpio_rpi/1.2-k $(uname -r) [version was 1.2 at time of writing] 3) cd /usr/src/db9_gpio_rpi-1.2 4) sudo nano db9_gpio_rpi.c 5) change the line #define DB9_SATURN_DELAY 1 to #define DB9_SATURN_DELAY 7 as necessary, save file 6) sudo dkms install db9_gpio_rpi/1.2 and reboot.

Hopefully this helps others with this obscure issue as I could not find anything online about this.

marqs85 commented 4 years ago

The driver delays were tested with original RPi model and set to smallest working values to minimize performance impact of the driver. Perhaps udelay implementation in RPi kernel back then was very conservative (i.e. resulting delay being much higher than requested), and nowadays it's probably more accurate. That would explain why some users have recently bumped into these kind of issues with db9_gpio_rpi and gamecon_gpio_rpi. It'd be also worth checking how udelay implementation takes DVFS, overclocking etc. into account, if at all.