USB HID: Patch for Cherry CyMotion Linux keyboard
PATCH 1/2 USB HID: Patch for Cherry CyMotion Linux keyboard
For those who haven't seen it the Cherry CyMotion Linux keyboard is a decent quality keyboard with the Windows specific keys replaced with Linux keys. It's got a nice little picture of Tux on it too. The supplied patches aren't suitable for current kernels so I've bashed their patches into a suitable form.
The special case in hid_get_class_descriptor() (which necessitated moving that function after the #defines for vendor and device ID) is lifted directly from the code Cherry supply. I'm not certain that's the best place for it but I don't know the USB HID architecture well enough to know what else to do with it. Suggestions welcome.
drivers/usb/input/hid-core.c +34 -16
@@ -1291,22 +1291,6 @@return 0 ; } -static int hid_get_class_descriptor (struct usb_device *dev,int ifnum, -unsigned char type,void *buf,int size) -{ -int result, retries =4 ; - -memset (buf,0 ,size);// Make sure we parse really received data - -do { - result =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ), -USB_REQ_GET_DESCRIPTOR ,USB_RECIP_INTERFACE |USB_DIR_IN , - (type <<8 ), ifnum, buf, size,HZ *USB_CTRL_GET_TIMEOUT ); - retries--; - }while (result < size && retries); -return result; -} -int hid_open (struct hid_device *hid) {if (hid->open++)
@@ -1494,6 +1478,9 @@#define USB_VENDOR_ID_DELORME 0x1163#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 +#define USB_VENDOR_ID_CHERRY 0x046a +#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 + static struct hid_blacklist { __u16 idVendor; __u16 idProduct;
@@ -1589,6 +1576,37 @@ { 0, 0 } }; +static int hid_get_class_descriptor (struct usb_device *dev,int ifnum, +unsigned char type,void *buf,int size) +{ +int result, retries =4 ; +char *p = (char *)buf; + +memset (buf,0 ,size);// Make sure we parse really received data + +do { + result =usb_control_msg (dev,usb_rcvctrlpipe (dev,0 ), +USB_REQ_GET_DESCRIPTOR ,USB_RECIP_INTERFACE |USB_DIR_IN , + (type <<8 ), ifnum, buf, size,HZ *USB_CTRL_GET_TIMEOUT ); + retries--; + }while (result < size && retries); + +// wn_hack: patch wrong descriptor for this device +// hardware sends wrong descriptor +// AA, 20050418: should this test be skipped altogether if result < size? +if (dev->descriptor.idVendor ==USB_VENDOR_ID_CHERRY + && dev->descriptor.idProduct ==USB_DEVICE_ID_CHERRY_CYMOTION + && result >12 + && p[11 ] ==0x3c + && p[12 ] ==0x02 ) { + printk(KERN_DEBUG __FILE__ " : modifying descriptor for Cherry CyMotion keyboard \n"); + p[11 ] = p[16 ] =0xff ; + p[12 ] = p[17 ] =0x03 ; + } + +return result; +} + static int hid_alloc_buffers(struct usb_device *dev, struct hid_device
*hid)
{
if (!(hid->inbuf = usb_buffer_alloc(dev, HID_BUFFER_SIZE,SLAB_ATOMIC, &hid->inbuf_dma)))
Signature · 1 line
Andy Armstrong, hexten.net
PATCH 2/2 USB HID: Patch for Cherry CyMotion Linux keyboard
And here are the changes to support the extra keys...
drivers/usb/input/hid-input.c +6 -0
@@ -270,6 +270,12 @@case 0x227 :map_key_clear (KEY_REFRESH );break ;case 0x22a :map_key_clear (KEY_BOOKMARKS );break ;case 0x238 :map_rel (REL_HWHEEL );break ; +case 0x233 :map_key_clear (KEY_SCROLLUP );break ; +case 0x234 :map_key_clear (KEY_SCROLLDOWN );break ; +case 0x301 :map_key_clear (KEY_PROG1 );break ; +case 0x302 :map_key_clear (KEY_PROG2 );break ; +case 0x303 :map_key_clear (KEY_PROG3 );break ; +case 0x279 :map_key_clear (KEY_AGAIN );
break;
default: goto unknown;
}
break;
Signature · 1 line
Andy Armstrong, hexten.net
Quoted 5 lines · Andy Armstrong
For those who haven't seen it the Cherry CyMotion Linux keyboard is a decent quality keyboard with the Windows specific keys replaced with Linux keys. It's got a nice little picture of Tux on it too. The supplied patches aren't suitable for current kernels so I've bashed their patches into a suitable form.
Your patches are line-wrapped, and the tabs were stripped out :(
Care to redo them, add a signed-off-by: line and send them to the linux-usb-devel mailing list and CC: the hid maintainer?
thanks,
greg k-h
Quoted 1 line · Greg KH
Your patches are line-wrapped, and the tabs were stripped out :(
Ah poop - sorry about that. I'm using the Mac mail client which managed to give me the impression it was going to send them clean.
Quoted 2 lines
Care to redo them, add a signed-off-by: line and send them to the linux-usb-devel mailing list and CC: the hid maintainer?
Yes, shall do, thanks.
Signature · 1 line
Andy Armstrong, hexten.net
Quoted 2 lines · Greg KH
Care to redo them, add a signed-off-by: line and send them to the linux-usb-devel mailing list and CC: the hid maintainer?
All done. Sorry for the inconvenience.
Signature · 1 line
Andy Armstrong, hexten.net