|
|
View Full Version : Building USB HID modules for 2.4.19-rmk7
hudson 03-31-2007, 04:29 PM EDIT: evkb-0.2 Application (http://www.mobileread.com/forums/showthread.php?t=10214&page=2&pp=15) You can use your USB keyboard with your iLiad with this application!
I've downloaded the linux-2.4.19-rmk7-pxz2-irex1 kernel sources and patches from the iRex website. The kernel sources appear to have the patch already installed, so it is not necessary to reapply it. There is no .config file included in the tar file (and 2.4 doesn't support /proc/config.gz), so I made some guesses and built input, hid, evdev and keybdev as modules (abbreviated .config):
CONFIG_ARM=y
CONFIG_ARCH_PXA=y
CONFIG_MACH_PXA_IREX_ER0100=y
CONFIG_INPUT=m
CONFIG_INPUT_KEYBDEV=m
CONFIG_INPUT_MOUSEDEV=m
CONFIG_INPUT_MOUSEDEV_SCREEN_X=768
CONFIG_INPUT_MOUSEDEV_SCREEN_Y=1024
CONFIG_INPUT_JOYDEV=m
CONFIG_INPUT_EVDEV=m
CONFIG_USB=y
CONFIG_USB_DEVICEFS=y
CONFIG_USB_HID=m
CONFIG_USB_HIDINPUT=y
CONFIG_USB_HIDDEV=y
CONFIG_USB_KBD=m
CONFIG_USB_MOUSE=m
CONFIG_USB_WACOM=m
I'm able to load them and it detects the USB keyboard/mouse on the port and I can disconnect/reconnect them without problems, but once I hit a single key it hangs the device hard. If I do not load keybdev, I can try to read /dev/input/mouse0 or /dev/input/event[01], but I never see any events in any of them. If I load the old BP usb keyboard/mouse modules (usbkbd.o) I do not see any results, either, but at least it doesn't hang.
dmesg output, although I don't have any after the hang:
usb.c: registered new driver hiddev
usb.c: registered new driver hid
input0: USB HID v1.00 Keyboard [0d3d:0001] on usb1:2.0
input1: USB HID v1.00 Mouse [0d3d:0001] on usb1:2.1
hid-core.c: v1.8.1 Andreas Gal, Vojtech Pavlik <vojtech@suse.cz>
hid-core.c: USB HID support drivers
hudson 03-31-2007, 11:18 PM Following up on my own query, I realized that cat was line buffering the output from the event device file, so I instead I wrote an event decoder that generates synthetic X events via the Xtest extension (attached). You should be able to drop this into /mnt/free/documents or wherever and have an icon to launch the USB keyboard interface. Plug in the keyboard before running so that /dev/input/event0 is already allocated. It may be possible to rebuild the kdrive tinyX server to use the evdev interface (or it may already be enabled). Either of those would allow the use of a USB keyboard without any problems.
The keyboard appears to be correct when I use the usbkbd.c modules, but the mouse is as if the data[] array in the usb_mouse.c usb_mouse_irq() function is shifted by one array position. That doesn't explain the crash with the full HID driver, but I'm less inclined to hunt it down now that I have it working.
In the tarfile is the full source, as well as a pre-compiled version with the pre-compiled kernel modules for the 2.4.19-rmk7 kernel used in the iRex 2.9.1 firmware. No guarantees that it will work for you, but it works great for me with the mrxvt application.
Antartica 04-01-2007, 03:01 AM No guarantees that it will work for you, but it works great for me with the mrxvt application.
So, is it working using the module and your evdev-XTEST conversion app?
If so, those are great news :-))).
henkvdg 04-01-2007, 07:46 AM Hudson, it works for me too!
Thank you very much!
hudson 04-01-2007, 07:52 AM So, is it working using the module and your evdev-XTEST conversion app?
It is working with the keyboard and fairly useful. I can run vi in the mrxvt application and use the iLiad as a very interesting text editor. I suspect that emacs could be compiled as well with little difficulty other than memory usage and the lack of any swap device.
The mouse device is still hosed. The data reaching the usb device driver just doesn't make sense. Here is the interrupt routine from 2.4.19:
static void usb_mouse_irq(struct urb *urb)
{
struct usb_mouse *mouse = urb->context;
signed char *data = mouse->data;
struct input_dev *dev = &mouse->dev;
if (urb->status) return;
input_report_key(dev, BTN_LEFT, data[0] & 0x01);
input_report_key(dev, BTN_RIGHT, data[0] & 0x02);
input_report_key(dev, BTN_MIDDLE, data[0] & 0x04);
input_report_key(dev, BTN_SIDE, data[0] & 0x08);
input_report_key(dev, BTN_EXTRA, data[0] & 0x10);
input_report_rel(dev, REL_X, data[1]);
input_report_rel(dev, REL_Y, data[2]);
input_report_rel(dev, REL_WHEEL, data[3]);
}
The data[] array should contain the button bitmap, the relative X, relative Y and relative wheel data (in that order). What I see is that data[0] is always 1, data[1] is the bitmap, data[2] is the X motion and data[3] is the Y motion. If I hack the routine to use 'data = mouse->data + 1' everything looks good, including the wheel and buttons.
It wouldn't be too much work to add mouse support to the evkb program. Does the window manager support displaying a mouse cursor?
Robert Marquard 04-01-2007, 08:39 AM Is that a standard mouse or a mouse-keyboard combo? It could be the ReportID then.
hudson 04-01-2007, 10:04 AM Is that a standard mouse or a mouse-keyboard combo? It could be the ReportID then.
It's through a combined PS/2 keyboard/mouse to USB converter with my trusty 1991 Model-M and a random mouse from some other system. I don't have a true USB mouse to test with.
Looking into the future, 2.6.19 uses the same logic for parsing the mouse->data[] in drivers/usb/input/usbmouse.c:usb_mouse_irq(), so the problem may be with the USB converter. I'll see if I can find a real mouse to test with, as well as a folding USB keyboard for travel.
Robert Marquard 04-02-2007, 01:12 AM So the device uses PS/2 devices (mouse and keyboard) as input devices and represents a mouse/keyboard composite HID device to the OS. It is definitely possible to have such a device use ReportIDs. USB on Linux is still immature even for 2.6. I would suspect either a bug in the 2.4 kernel or a bug in the device. ReportID 1 for the mouse data is suspicious. I would have expected 2.
Matthijs 04-02-2007, 01:48 AM For configs: see arch/arm/def-configs/irex*
so, to compile use:
make irex_config
make oldconfig
make dep
make zImage
Edit: so "make irex_config" installs the iRex .config file, which you can then edit.
hudson 04-02-2007, 07:18 AM For configs: see arch/arm/def-configs/irex*
That's very useful, thanks!
For anyone else who wants to build their own USB HID kernel modules, here is a diff between the official .config and my .config. Mostly I've just added the input core and USB HID modules, as well as a few other little things to make my life easier (like the NFS client and loopback filesystems).
Adam B. 04-02-2007, 07:36 AM Great work! With a full keyboard, the iLiad could really be a great platform for always-available productivity applications. It has the potential to be so much more than just a document reader.
Matthijs 04-02-2007, 07:51 AM Not to spoil the fun, but:
The problem with this will probably be that even though you have HID modules, you cannot modprobe them and make it work without reflashing a kernel (which you cannot do at this point, since you're not on 2.9.5)...
See also Scotty's efforts to get a keyboard working.
hudson 04-02-2007, 07:58 AM Not to spoil the fun, but:
The problem with this will probably be that even though you have HID modules, you cannot modprobe them and make it work without reflashing a kernel
I'm not sure what the problem is -- it works great for me. I've been able to use insmod to load the HID modules and route the events to the X server via the Xtest extension. The application that I posted sets up everything with the kernel modules and runs the event redirector in the background.
Matthijs 04-02-2007, 08:37 AM Ah, ok. In that case: ignore my message. From when Scotty tried it, I though I recalled that a new kernel would be needed. Apparently not.
(And I didn't read you first two posts well enough :blush: )
Nice job!
henkvdg 04-02-2007, 08:51 AM I'm not sure what the problem is -- it works great for me. I've been able to use insmod to load the HID modules and route the events to the X server via the Xtest extension. The application that I posted sets up everything with the kernel modules and runs the event redirector in the background.
As I found out, the keyboard works if it is fist connected before the application is started. When removed and reconnected, the application has to be started again to use the keyboard. Not every key of my keyboard is recognized correctly, so it seems the right keyboard description file has to be used.
I could use the keyboard for the terminal program, but not for changing the name or comments with a file, by using the label icon.
So at least a little bit extra will be needed to use this possibility tot the max.
hudson 04-02-2007, 09:29 AM As I found out, the keyboard works if it is fist connected before the application is started. When removed and reconnected, the application has to be started again to use the keyboard.
The first version of the event redirector was really simple and didn't handle the /dev/input/event0 file going away (or not being present). I've made it loop now until the device file is available and sleep for 5 seconds after it goes away before trying again. This allows you to start it and plug/unplug the keyboard at anytime. I've also added the xev program and a command line event-dump to help debug other problems and input devices.
To install the easiest method is:
bzcat evkb-0.2.tar.bz2 | ssh root@10.0.0.200 tar -C /mnt/free/documents -xvf -
Not every key of my keyboard is recognized correctly, so it seems the right keyboard description file has to be used.
I've only tried it with rxvt so far with a US charset keyboard. My evkb program doesn't have any keyboard map -- the mapping is a simple 'Xkeycode = scancode + 8', which works for most of the normal keys with a US keymap. <linux/input.h> has the scancodes and if you run 'xmodmap -pk' it will print the keycodes and the keysyms that they map to.
Is it possible to configure the keyboard in azerty?
(The combination Maj + Alt. doesn't work :s )
hudson 08-20-2007, 07:00 PM It's not possible to reconfigure it as it is currently implemented -- you would need to produce your own table mapping of the keycodes to scancodes and write a lookup function for the loop. The xev program (included in the tar file) can be used to help track down the mappings.
To install the easiest method is:
bzcat evkb-0.2.tar.bz2 | ssh root@10.0.0.200 tar -C /mnt/free/documents -xvf -
So, I can't just copy the file to MMC card? Please, for somebody with very limited computer skills (I can get stuff to work for what I need, but programming is beyond me), what would dummy steps for installing this program be?
Thanks!
EDIT:
Ok, I tried to unzip it and it worked fine :).
kissyfish 02-09-2008, 07:32 PM I cannot get the KB (the Targus Universal USB folding keyboard) mentioned in another thread to work on my iliad. I have download the .bz file, unzipped on my mac, copied it into the /install folder on my cf card, pit it in the iliad, and clicked on it's icon inb the iliad, but so far, no dice. I was trying to test it with either gargoyle, or the todo program which Adam B ported.
Is this a problem with the compatibility with the apps, or am I being quite dumb and missing something obvious>
Many thanks in advance for your patience. I
wallcraft 02-09-2008, 11:17 PM I tested it with a standard USB keyboard:
In ContentLister, select USB Keyboard
Plug in the keyboard
Use the keyboard's up and down arrow keys and return to navigate contentlister
If the above works, then the keyboard is being recognized. The next step is to try it in your favorite applications. I tried my keyboard with mrxvt and FBReader - and both worked.
kissyfish 02-10-2008, 07:32 PM I tested it with a standard USB keyboard:
In ContentLister, select USB Keyboard
Plug in the keyboard
Use the keyboard's up and down arrow keys and return to navigate contentlister
If the above works, then the keyboard is being recognized. The next step is to try it in your favorite applications. I tried my keyboard with mrxvt and FBReader - and both worked.
It still does not appear to be working...
Do I have to do something to the USB to realize if it is in a master or slave position...
I will keep plugging away.
If I can get this thing working, it will have solved pretty much every problem I wanted to address with the iliad.
Thanks to all of you for your hard work.
I am going to try to rebrush up on some linux programming/porting.
Take care all,
Jim
kissyfish 03-18-2008, 12:12 PM It still does not appear to be working...
Do I have to do something to the USB to realize if it is in a master or slave position...
I will keep plugging away.
If I can get this thing working, it will have solved pretty much every problem I wanted to address with the iliad.
Thanks to all of you for your hard work.
I am going to try to rebrush up on some linux programming/porting.
Take care all,
Jim
Still no luck, I have been able to hook it up to my laptop, and it works well, but for some reason it just will not do anything with the iliad.
I am on the latest firmware version, is there anything I need to do because of that?
Jim
Redfox 04-11-2008, 01:02 AM :thanks:
Great little app - works "out of the box" with my Samsung slimline keyboard, and I can even send text from my Alphasmart Neo into vi :)
kissyfish 05-02-2008, 10:24 AM I am still having no luck with the keyboard, I have tested it with a laptop, and the keyboard appears to be working well, so now I am suspicious of my USB port on the iliad.
Anyone know a way to test it?
Mambo 05-03-2008, 01:26 PM I have tested this utility and it is working fine straight out of the box with generic keyboards. It does not work, however, with my wireless RF keyboard (keysonic). I think you should try with several different keyboards (maybe in your office if you can't test at home) to exclude the possibility that the problem is with your iLiad.
|