Difference between revisions of "Old school (non-usb) joystick in Ubuntu 11.10"

From Finninday
Jump to: navigation, search
 
Line 238: Line 238:
 
  http://forums.gentoo.org/viewtopic-t-539758.html
 
  http://forums.gentoo.org/viewtopic-t-539758.html
  
Through trial and error, I've found that adding "joystick_port=1" to the snd-cmipci line in /etc/modprobe.d/alsa-base.conf will cause a device to appear in /sys/bus/gameport:
+
I've found that adding "joystick_port=1" to the snd-cmipci line in /etc/modprobe.d/alsa-base.conf will cause a device to appear in /sys/bus/gameport after a reboot:
 
<pre>
 
<pre>
 
root@merkli:/sys/bus/gameport# tree
 
root@merkli:/sys/bus/gameport# tree
Line 251: Line 251:
  
 
But it still won't make anything show up in dmesg.  "modprobe joydump" will get the diagnostic to show up in dmesg.
 
But it still won't make anything show up in dmesg.  "modprobe joydump" will get the diagnostic to show up in dmesg.
 +
 +
I still need to figure out what combination of modules will make that device useful.  I'm not sure if I should be trying to use that device in /sys/bus/gameport or if I should be using /dev/input/js0.

Latest revision as of 05:46, 5 December 2011

We got a used joystick with a d-sub connector and I'm trying to make it work with Ubuntu 11.10.

I had to buy a sound card that had a game port. I got a Diamond XS51 sound card that shows up like this in lspci:

01:07.0 Multimedia audio controller: C-Media Electronics Inc CM8738 (rev 10)
	Subsystem: C-Media Electronics Inc CMI8738/C3DX PCI Audio Device
	Flags: bus master, medium devsel, latency 32, IRQ 16
	I/O ports at c000 [size=256]
	Capabilities: [c0] Power Management version 2
	Kernel driver in use: C-Media PCI
	Kernel modules: snd-cmipci

I now have these modules installed:

Module                  Size  Used by
analog                 17399  0 
sidewinder             21041  0 
ns558                  12654  0 
snd_cmipci             35513  2 
gameport               15060  5 analog,sidewinder,ns558,snd_cmipci
snd_opl3_lib           18863  1 snd_cmipci
snd_mpu401_uart        13865  1 snd_cmipci
nfs                   297750  0 
lockd                  78804  1 nfs
fscache                50674  1 nfs
auth_rpcgss            39545  1 nfs
nfs_acl                12771  1 nfs
sunrpc                205330  7 nfs,lockd,auth_rpcgss,nfs_acl
rfcomm                 38408  0 
bnep                   17923  2 
bluetooth             148839  8 rfcomm,bnep
pci_stub               12550  1 
vboxpci                22882  0 
vboxnetadp             13328  0 
vboxnetflt             27211  0 
vboxdrv               251814  3 vboxpci,vboxnetadp,vboxnetflt
autofs4                27924  6 
vesafb                 13489  1 
nvidia              10390874  40 
snd_intel8x0           33318  2 
snd_ac97_codec        106082  1 snd_intel8x0
snd_usb_audio         100880  0 
ac97_bus               12642  1 snd_ac97_codec
snd_pcm                80468  4 snd_cmipci,snd_intel8x0,snd_ac97_codec,snd_usb_audio
snd_hwdep              13276  2 snd_opl3_lib,snd_usb_audio
snd_usbmidi_lib        24558  1 snd_usb_audio
snd_seq_midi           13132  0 
joydev                 17393  0 
snd_rawmidi            25241  3 snd_mpu401_uart,snd_usbmidi_lib,snd_seq_midi
snd_seq_midi_event     14475  1 snd_seq_midi
uvcvideo               67271  0 
videodev               85626  1 uvcvideo
snd_seq                51567  2 snd_seq_midi,snd_seq_midi_event
snd_timer              28932  3 snd_opl3_lib,snd_pcm,snd_seq
snd_seq_device         14172  4 snd_opl3_lib,snd_seq_midi,snd_rawmidi,snd_seq
binfmt_misc            17292  1 
snd                    55902  21 snd_cmipci,snd_opl3_lib,snd_mpu401_uart,snd_intel8x0,snd_ac97_codec,snd_usb_audio,snd_pcm,snd_hwdep,snd_usbmidi_lib,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
soundcore              12600  1 snd
snd_page_alloc         14115  2 snd_intel8x0,snd_pcm
ppdev                  12849  0 
shpchp                 32356  0 
serio_raw              12990  0 
i2c_nforce2            12906  0 
parport_pc             32114  1 
lp                     17455  0 
parport                40930  3 ppdev,parport_pc,lp
usbhid                 41905  0 
hid                    77367  1 usbhid
forcedeth              58103  0 
pata_amd               13753  2 
floppy                 60310  0 

Sound works on the new sound card. That didn't take any effort. But I can't get the joystick to be visible.

I've tried jstest, which seems to misidentify the device:

root@merkli:~# jstest /dev/input/js0
Driver version is 2.1.0.
Joystick (Chicony USB Gaming Keyboard Pro) has 0 axes ()
and 11 buttons (BtnX, BtnY, BtnZ, BtnTL, BtnTR, BtnTL2, BtnTR2, BtnSelect, BtnStart, BtnMode, BtnThumbL).
Testing ... (interrupt to exit)
Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 1Buttons:  0:off  1:off  2:off  3:off  4:off  5:off  6:off  7:off  8:off  9:off 10:off ^C

It isn't USB and it isn't a keyboard. It might be Chicony... the joystick doesn't have any brand or model written on it. And the joystick might not be working. But I think it is unlikely that all the switches and pots in it would all fail together.

It is much more likely that I don't know which device or module is required.

This post mentions asound.state:

http://osdir.com/ml/linux.alsa.user/2002-07/msg00248.html

Do I have to do something to asound.state? I don't see anything in there related to joysticks at the moment.

This post looks helpful:

http://ubuntuforums.org/showthread.php?t=1145181

I'll try joydump.

That gives me this in dmesg:

[1030086.907845] joydump: ,------------------ START ----------------.
[1030086.907854] joydump: | Dumping:      pci0000:01:07.0/gameport0 |
[1030086.907858] joydump: | Speed:                        59659 kHz |
[1030087.850311] joydump: >------------------ DATA -----------------<
[1030087.850315] joydump: | index:   0 delta:   0 us data: 11111111 |
[1030087.850322] joydump: `------------------- END -----------------'

So what device is associated with pci0000:01:07.0/gameport0? Probably not the /dev/input/js0 that I've been talking to.

/proc/ioports contains this:

0201-0201 : CMIPCI gameport

lspci reports the address 01:07.0 as associated with the audio card.

Looking through /sys/dev/char, I see these promising entries:

lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:2 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/midiC1D0
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:3 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/pcmC1D2p
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:33 -> ../../devices/virtual/sound/timer
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:4 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/pcmC1D2c
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:5 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/pcmC1D1p
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:6 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/pcmC1D0p
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:7 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/pcmC1D0c
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:8 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/hwC1D0
lrwxrwxrwx 1 root root 0 2011-12-03 16:45 116:9 -> ../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/sound/card1/controlC1

They all include a reference to 10:07.0.

Poking around in those directories, I found this directory:

/sys/devices/pci0000:00/0000:00:08.0/0000:01:07.0/gameport0

and it contains this:

root@merkli:/sys/devices/pci0000:00/0000:00:08.0/0000:01:07.0/gameport0# ls -l
total 0
-r--r--r-- 1 root root 4096 2011-12-03 16:45 description
lrwxrwxrwx 1 root root    0 2011-12-03 16:45 driver -> ../../../../../bus/gameport/drivers/joydump
--w------- 1 root root 4096 2011-12-03 16:45 drvctl
drwxr-xr-x 2 root root    0 2011-12-03 16:45 power
lrwxrwxrwx 1 root root    0 2011-12-03 16:45 subsystem -> ../../../../../bus/gameport
-rw-r--r-- 1 root root 4096 2011-12-03 16:45 uevent
root@merkli:/sys/devices/pci0000:00/0000:00:08.0/0000:01:07.0/gameport0# cat description 
C-Media Gameport

I think I'm getting warm.

Those links into /sys/bus/gameport are interesting. When I go there I see all the drivers that I've tried to load to make this work:

root@merkli:/sys/bus/gameport# tree
.
├── devices
│   └── gameport0 -> ../../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/gameport0
├── drivers
│   ├── adc
│   │   ├── bind
│   │   ├── description
│   │   ├── module -> ../../../../module/a3d
│   │   ├── uevent
│   │   └── unbind
│   ├── analog
│   │   ├── bind
│   │   ├── description
│   │   ├── module -> ../../../../module/analog
│   │   ├── uevent
│   │   └── unbind
│   ├── joydump
│   │   ├── bind
│   │   ├── description
│   │   ├── gameport0 -> ../../../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/gameport0
│   │   ├── module -> ../../../../module/joydump
│   │   ├── uevent
│   │   └── unbind
│   └── sidewinder
│       ├── bind
│       ├── description
│       ├── module -> ../../../../module/sidewinder
│       ├── uevent
│       └── unbind
├── drivers_autoprobe
├── drivers_probe
└── uevent

12 directories, 19 files

When I try to use jstest with that device, I get much closer, but not quite success:

root@merkli:/sys/bus/gameport/devices# jstest /sys/bus/gameport/devices/gameport0
Driver version is 0.8.0.
jstest is not fully compatible with your kernel. Unable to retrieve button map!
Joystick (Unknown) has 2 axes and 2 buttons.
Testing ... (interrupt to exit)

jstest: error reading: Is a directory

It sees the device! It sees 2 axes and 2 buttons!

Here is a little bit more from dmesg:

[166023.854108] C-Media PCI 0000:01:07.0: PCI INT A disabled
[166125.541549] C-Media PCI 0000:01:07.0: PCI INT A -> Link[APC1] -> GSI 16 (level, high) -> IRQ 16
[166125.560829] gameport gameport0: C-Media Gameport is pci0000:01:07.0/gameport0, io 0x201, speed 59659kHz
[180000.000039] [Hardware Error]: Machine check events logged
[748827.792033] hrtimer: interrupt took 32679 ns
[1030086.907845] joydump: ,------------------ START ----------------.
[1030086.907854] joydump: | Dumping:      pci0000:01:07.0/gameport0 |
[1030086.907858] joydump: | Speed:                        59659 kHz |
[1030087.850311] joydump: >------------------ DATA -----------------<
[1030087.850315] joydump: | index:   0 delta:   0 us data: 11111111 |
[1030087.850322] joydump: `------------------- END -----------------'

And here is a helpful and discouraging post:

http://ubuntuforums.org/showthread.php?t=1145181

And here is another:

http://forums.funtoo.org/viewtopic.php?id=763

At first boot, dmesg has nothing about gameport and my /sys/bus/gameport is empty:

root@merkli:/sys/bus/gameport# tree
.
├── devices
├── drivers
├── drivers_autoprobe
├── drivers_probe
└── uevent

This post looks helpful.

http://forums.gentoo.org/viewtopic-t-539758.html

I've found that adding "joystick_port=1" to the snd-cmipci line in /etc/modprobe.d/alsa-base.conf will cause a device to appear in /sys/bus/gameport after a reboot:

root@merkli:/sys/bus/gameport# tree
.
├── devices
│   └── gameport0 -> ../../../devices/pci0000:00/0000:00:08.0/0000:01:07.0/gameport0
├── drivers
├── drivers_autoprobe
├── drivers_probe
└── uevent

But it still won't make anything show up in dmesg. "modprobe joydump" will get the diagnostic to show up in dmesg.

I still need to figure out what combination of modules will make that device useful. I'm not sure if I should be trying to use that device in /sys/bus/gameport or if I should be using /dev/input/js0.