Updated code style

This commit is contained in:
Christoph Haas 2017-02-28 16:12:37 +01:00
parent 3b760157a1
commit af53672352

View File

@ -49,51 +49,80 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENSE); MODULE_LICENSE(DRIVER_LICENSE);
/**
* Define keycodes
*/
static const unsigned char px_kbd_keycode[256] = { static const unsigned char px_kbd_keycode[256] = {
/* BEGIN 04 */ /* BEGIN 04 */
/* 0-7 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 0-7 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 8-15 */ KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, KEY_LEFTMETA, KEY_RIGHTCTRL, KEY_RIGHTSHIFT, KEY_RIGHTALT, KEY_RESERVED, /* 8-15 */ KEY_LEFTCTRL, KEY_LEFTSHIFT, KEY_LEFTALT, KEY_LEFTMETA, KEY_RIGHTCTRL, KEY_RIGHTSHIFT, KEY_RIGHTALT, KEY_RESERVED,
/* 16-23 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B, KEY_C, KEY_D, /* 16-23 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_A, KEY_B, KEY_C, KEY_D,
/* 24-31 */ KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, /* 24-31 */ KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
/* 32-39 */ KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, /* 32-39 */ KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
/* 40-47 */ KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, /* 40-47 */ KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2,
/* 48-55 */ KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, /* 48-55 */ KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0,
/* 56-63 */ KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE, /* 56-63 */ KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFTBRACE,
/* END 04 */ /* END 04 */
/* BEGIN 05 */ /* BEGIN 05 */
/* 64-71 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 64-71 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 72-79 */ KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, KEY_DOT, /* 72-79 */ KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_BACKSLASH, KEY_SEMICOLON, KEY_APOSTROPHE, KEY_GRAVE, KEY_COMMA, KEY_DOT,
/* 80-87 */ KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, /* 80-87 */ KEY_SLASH, KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
/* 88-95 */ KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_SYSRQ, KEY_SCROLLLOCK, /* 88-95 */ KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_SYSRQ, KEY_SCROLLLOCK,
/* 96-103 */ KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_END, KEY_PAGEDOWN, KEY_RIGHT, /* 96-103 */ KEY_PAUSE, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_END, KEY_PAGEDOWN, KEY_RIGHT,
/* 104-111 */ KEY_LEFT, KEY_DOWN, KEY_UP, KEY_NUMLOCK, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS, /* 104-111 */ KEY_LEFT, KEY_DOWN, KEY_UP, KEY_NUMLOCK, KEY_KPSLASH, KEY_KPASTERISK, KEY_KPMINUS, KEY_KPPLUS,
/* 112-119 */ KEY_KPENTER, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7, /* 112-119 */ KEY_KPENTER, KEY_KP1, KEY_KP2, KEY_KP3, KEY_KP4, KEY_KP5, KEY_KP6, KEY_KP7,
/* 120-127 */ KEY_KP8, KEY_KP9, KEY_KP0, KEY_KPDOT, KEY_102ND, KEY_MENU, KEY_RESERVED, KEY_RESERVED, /* 120-127 */ KEY_KP8, KEY_KP9, KEY_KP0, KEY_KPDOT, KEY_102ND, KEY_MENU, KEY_RESERVED, KEY_RESERVED,
/* END 05 */ /* END 05 */
/* 01 */ /* 01 */
/* 128-135 */ KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_MEDIA, KEY_MUTE, KEY_PAUSE, KEY_PREVIOUSSONG, KEY_PLAYPAUSE, KEY_NEXTSONG, /* 128-135 */ KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_MEDIA, KEY_MUTE, KEY_PAUSE, KEY_PREVIOUSSONG, KEY_PLAYPAUSE, KEY_NEXTSONG,
/* 136-143 */ KEY_MAIL, KEY_HOMEPAGE, KEY_CALC, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 136-143 */ KEY_MAIL, KEY_HOMEPAGE, KEY_CALC, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 144-151 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 144-151 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 152-159 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 152-159 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 160-167 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 160-167 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 168-175 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 168-175 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 176-183 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 176-183 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 184-191 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 184-191 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* BEGIN 06 */ /* BEGIN 06 */
/* 192-199 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 192-199 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 200-207 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 200-207 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 208-215 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 208-215 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 216-223 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 216-223 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 224-231 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_SLASH, /* 224-231 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_SLASH,
/* 232-239 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 232-239 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 240-247 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 240-247 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* 248-255 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, /* 248-255 */ KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, KEY_RESERVED,
/* END 06 */ /* END 06 */
}; };
/**
* struct usb_kbd - state of each attached keyboard
*
* @dev: input device associated with this keyboard
* @usbdev: usb device associated with this keyboard
* @old: data received in the past from the @irq URB representing which
* keys were pressed. By comparing with the current list of keys
* that are pressed, we are able to see key releases.
* @irq: URB for receiving a list of keys that are pressed when a
* new key is pressed or a key that was pressed is released.
* @led: URB for sending LEDs (e.g. numlock, ...)
* @newleds: data that will be sent with the @led URB representing which LEDs
* should be on
* @name: Name of the keyboard. @dev's name field points to this buffer
* @phys: Physical path of the keyboard. @dev's phys field points to this
* buffer
* @new: Buffer for the @irq URB
* @cr: Control request for @led URB
* @leds: Buffer for the @led URB
* @new_dma: DMA address for @irq URB
* @leds_dma: DMA address for @led URB
* @leds_lock: spinlock that protects @leds, @newleds, and @led_urb_submitted
* @led_urb_submitted: indicates whether @led is in progress, i.e. it has been
* submitted and its completion handler has not returned yet
* without resubmitting @led
*/
struct usb_kbd { struct usb_kbd {
struct input_dev *dev; struct input_dev *dev;
struct usb_device *usbdev; struct usb_device *usbdev;
@ -114,133 +143,130 @@ static void usb_kbd_irq(struct urb *urb)
{ {
struct usb_kbd *kbd = urb->context; struct usb_kbd *kbd = urb->context;
int i, j, offset; int i, j, offset;
switch (urb->status) { switch (urb->status) {
case 0: /* success */ case 0: /* success */
break; break;
case -ECONNRESET: /* unlink */ case -ECONNRESET: /* unlink */
case -ENOENT: case -ENOENT:
case -ESHUTDOWN: case -ESHUTDOWN:
return; return;
/* -EPIPE: should clear the halt */ /* -EPIPE: should clear the halt */
default: /* error */ default: /* error */
goto resubmit; goto resubmit;
} }
/* /*
printk("Keyup keycode: "); printk("Keyup keycode: ");
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
printk("%d ", kbd->old[i]); printk("%d ", kbd->old[i]);
printk("\n"); printk("\n");
*/ */
/* /*
// The following lines are for logging keypresses to the // The following lines are for logging keypresses to the
// kernel dmesg facility. Uncomment the following lines // kernel dmesg facility. Uncomment the following lines
// to capture the keycode for any non-functioning keys // to capture the keycode for any non-functioning keys
// and open a new issue on bitbucket.org with the key // and open a new issue on bitbucket.org with the key
// you pressed and the keycode output below. // you pressed and the keycode output below.
printk("Keydown keycode: ");
for (i = 0; i < 8; i++) printk("Keydown keycode: ");
printk("%d ", kbd->new[i]);
for (i = 0; i < 8; i++)
printk("%d ", kbd->new[i]);
printk("\n"); printk("\n");
*/ */
if (kbd->new[0] == 1) { if (kbd->new[0] == 1) {
// volume down // volume down
if (kbd->new[1] == 234 && kbd->old[1] != 234) if (kbd->new[1] == 234 && kbd->old[1] != 234)
input_report_key(kbd->dev, px_kbd_keycode[128], 1); input_report_key(kbd->dev, px_kbd_keycode[128], 1);
if (kbd->old[1] == 234 && kbd->new[1] != 234) if (kbd->old[1] == 234 && kbd->new[1] != 234)
input_report_key(kbd->dev, px_kbd_keycode[128], 0); input_report_key(kbd->dev, px_kbd_keycode[128], 0);
// volume up
if (kbd->new[1] == 233 && kbd->old[1] != 233)
input_report_key(kbd->dev, px_kbd_keycode[129], 1);
if (kbd->old[1] == 233 && kbd->new[1] != 233)
input_report_key(kbd->dev, px_kbd_keycode[129], 0);
// Media
if (kbd->new[1] == 131 && kbd->old[1] != 131)
input_report_key(kbd->dev, px_kbd_keycode[130], 1);
if (kbd->old[1] == 131 && kbd->new[1] != 131)
input_report_key(kbd->dev, px_kbd_keycode[130], 0);
// Mute // volume up
if (kbd->new[1] == 226 && kbd->old[1] != 226) if (kbd->new[1] == 233 && kbd->old[1] != 233)
input_report_key(kbd->dev, px_kbd_keycode[131], 1); input_report_key(kbd->dev, px_kbd_keycode[129], 1);
if (kbd->old[1] == 226 && kbd->new[1] != 226) if (kbd->old[1] == 233 && kbd->new[1] != 233)
input_report_key(kbd->dev, px_kbd_keycode[131], 0); input_report_key(kbd->dev, px_kbd_keycode[129], 0);
// Stop // Media
if (kbd->new[1] == 183 && kbd->old[1] != 183) if (kbd->new[1] == 131 && kbd->old[1] != 131)
input_report_key(kbd->dev, px_kbd_keycode[132], 1); input_report_key(kbd->dev, px_kbd_keycode[130], 1);
if (kbd->old[1] == 183 && kbd->new[1] != 183) if (kbd->old[1] == 131 && kbd->new[1] != 131)
input_report_key(kbd->dev, px_kbd_keycode[132], 0); input_report_key(kbd->dev, px_kbd_keycode[130], 0);
// Prev Song // Mute
if (kbd->new[1] == 182 && kbd->old[1] != 182) if (kbd->new[1] == 226 && kbd->old[1] != 226)
input_report_key(kbd->dev, px_kbd_keycode[133], 1); input_report_key(kbd->dev, px_kbd_keycode[131], 1);
if (kbd->old[1] == 182 && kbd->new[1] != 182) if (kbd->old[1] == 226 && kbd->new[1] != 226)
input_report_key(kbd->dev, px_kbd_keycode[133], 0); input_report_key(kbd->dev, px_kbd_keycode[131], 0);
// Play/Pause // Stop
if (kbd->new[1] == 205 && kbd->old[1] != 205) if (kbd->new[1] == 183 && kbd->old[1] != 183)
input_report_key(kbd->dev, px_kbd_keycode[134], 1); input_report_key(kbd->dev, px_kbd_keycode[132], 1);
if (kbd->old[1] == 205 && kbd->new[1] != 205) if (kbd->old[1] == 183 && kbd->new[1] != 183)
input_report_key(kbd->dev, px_kbd_keycode[134], 0); input_report_key(kbd->dev, px_kbd_keycode[132], 0);
// Next Song // Prev Song
if (kbd->new[1] == 181 && kbd->old[1] != 181) if (kbd->new[1] == 182 && kbd->old[1] != 182)
input_report_key(kbd->dev, px_kbd_keycode[135], 1); input_report_key(kbd->dev, px_kbd_keycode[133], 1);
if (kbd->old[1] == 181 && kbd->new[1] != 181) if (kbd->old[1] == 182 && kbd->new[1] != 182)
input_report_key(kbd->dev, px_kbd_keycode[135], 0); input_report_key(kbd->dev, px_kbd_keycode[133], 0);
// Mail // Play/Pause
if (kbd->new[1] == 138 && kbd->old[1] != 138) if (kbd->new[1] == 205 && kbd->old[1] != 205)
input_report_key(kbd->dev, px_kbd_keycode[136], 1); input_report_key(kbd->dev, px_kbd_keycode[134], 1);
if (kbd->old[1] == 138 && kbd->new[1] != 138) if (kbd->old[1] == 205 && kbd->new[1] != 205)
input_report_key(kbd->dev, px_kbd_keycode[136], 0); input_report_key(kbd->dev, px_kbd_keycode[134], 0);
// Homepage // Next Song
if (kbd->new[1] == 35 && kbd->old[1] != 35) if (kbd->new[1] == 181 && kbd->old[1] != 181)
input_report_key(kbd->dev, px_kbd_keycode[137], 1); input_report_key(kbd->dev, px_kbd_keycode[135], 1);
if (kbd->old[1] == 35 && kbd->new[1] != 35) if (kbd->old[1] == 181 && kbd->new[1] != 181)
input_report_key(kbd->dev, px_kbd_keycode[137], 0); input_report_key(kbd->dev, px_kbd_keycode[135], 0);
// Calc // Mail
if (kbd->new[1] == 146 && kbd->old[1] != 146) if (kbd->new[1] == 138 && kbd->old[1] != 138)
input_report_key(kbd->dev, px_kbd_keycode[138], 1); input_report_key(kbd->dev, px_kbd_keycode[136], 1);
if (kbd->old[1] == 146 && kbd->new[1] != 146) if (kbd->old[1] == 138 && kbd->new[1] != 138)
input_report_key(kbd->dev, px_kbd_keycode[138], 0); input_report_key(kbd->dev, px_kbd_keycode[136], 0);
// Homepage
if (kbd->new[1] == 35 && kbd->old[1] != 35)
input_report_key(kbd->dev, px_kbd_keycode[137], 1);
if (kbd->old[1] == 35 && kbd->new[1] != 35)
input_report_key(kbd->dev, px_kbd_keycode[137], 0);
// Calc
if (kbd->new[1] == 146 && kbd->old[1] != 146)
input_report_key(kbd->dev, px_kbd_keycode[138], 1);
if (kbd->old[1] == 146 && kbd->new[1] != 146)
input_report_key(kbd->dev, px_kbd_keycode[138], 0);
} else if (kbd->new[0] == 4) {
for (j = 1; j < 8; j++) {
offset = j * 8;
for (i = 0; i < 8; i++)
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
}
} else if (kbd->new[0] == 5) {
for (j = 1; j < 8; j++) {
offset = (j * 8) + 64;
for (i = 0; i < 8; i++)
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
}
} else if (kbd->new[0] == 6) {
for (j = 1; j < 8; j++) {
offset = (j * 8) + 192;
for (i = 0; i < 8; i++)
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
}
} }
else if (kbd->new[0] == 4) {
for (j = 1; j < 8; j++) {
offset = j * 8;
for (i = 0; i < 8; i++)
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
}
}
else if (kbd->new[0] == 5) {
for (j = 1; j < 8; j++) {
offset = (j * 8) + 64;
for (i = 0; i < 8; i++)
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
}
}
else if (kbd->new[0] == 6) {
for (j = 1; j < 8; j++) {
offset = (j * 8) + 192;
for (i = 0; i < 8; i++)
input_report_key(kbd->dev, px_kbd_keycode[offset + i], (kbd->new[j] >> i) & 1);
}
}
input_sync(kbd->dev); input_sync(kbd->dev);
memcpy(kbd->old, kbd->new, 8); memcpy(kbd->old, kbd->new, 8);
@ -249,12 +275,11 @@ resubmit:
i = usb_submit_urb (urb, GFP_ATOMIC); i = usb_submit_urb (urb, GFP_ATOMIC);
if (i) if (i)
hid_err(urb->dev, "can't resubmit intr, %s-%s/input0, status %d", hid_err(urb->dev, "can't resubmit intr, %s-%s/input0, status %d",
kbd->usbdev->bus->bus_name, kbd->usbdev->bus->bus_name,
kbd->usbdev->devpath, i); kbd->usbdev->devpath, i);
} }
static int usb_kbd_event(struct input_dev *dev, unsigned int type, static int usb_kbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
unsigned int code, int value)
{ {
struct usb_kbd *kbd = input_get_drvdata(dev); struct usb_kbd *kbd = input_get_drvdata(dev);
@ -262,8 +287,8 @@ static int usb_kbd_event(struct input_dev *dev, unsigned int type,
return -1; return -1;
kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) | kbd->newleds = (!!test_bit(LED_KANA, dev->led) << 3) | (!!test_bit(LED_COMPOSE, dev->led) << 3) |
(!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) | (!!test_bit(LED_SCROLLL, dev->led) << 2) | (!!test_bit(LED_CAPSL, dev->led) << 1) |
(!!test_bit(LED_NUML, dev->led)); (!!test_bit(LED_NUML, dev->led));
if (kbd->led->status == -EINPROGRESS) if (kbd->led->status == -EINPROGRESS)
return 0; return 0;
@ -285,7 +310,7 @@ static void usb_kbd_led(struct urb *urb)
if (urb->status) if (urb->status)
hid_warn(urb->dev, "led urb status %d received\n", hid_warn(urb->dev, "led urb status %d received\n",
urb->status); urb->status);
if (*(kbd->leds) == kbd->newleds) if (*(kbd->leds) == kbd->newleds)
return; return;
@ -340,8 +365,7 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
usb_free_coherent(dev, 1, kbd->leds, kbd->leds_dma); usb_free_coherent(dev, 1, kbd->leds, kbd->leds_dma);
} }
static int usb_kbd_probe(struct usb_interface *iface, static int usb_kbd_probe(struct usb_interface *iface, const struct usb_device_id *id)
const struct usb_device_id *id)
{ {
struct usb_device *dev = interface_to_usbdev(iface); struct usb_device *dev = interface_to_usbdev(iface);
struct usb_host_interface *interface; struct usb_host_interface *interface;
@ -350,7 +374,7 @@ static int usb_kbd_probe(struct usb_interface *iface,
struct input_dev *input_dev; struct input_dev *input_dev;
int i, pipe, maxp; int i, pipe, maxp;
int error = -ENOMEM; int error = -ENOMEM;
interface = iface->cur_altsetting; interface = iface->cur_altsetting;
if (interface->desc.bNumEndpoints != 1) if (interface->desc.bNumEndpoints != 1)
@ -384,10 +408,10 @@ static int usb_kbd_probe(struct usb_interface *iface,
if (!strlen(kbd->name)) if (!strlen(kbd->name))
snprintf(kbd->name, sizeof(kbd->name), snprintf(kbd->name, sizeof(kbd->name),
"USB HIDBP Keyboard %04x:%04x", "USB HIDBP Keyboard %04x:%04x",
le16_to_cpu(dev->descriptor.idVendor), le16_to_cpu(dev->descriptor.idVendor),
le16_to_cpu(dev->descriptor.idProduct)); le16_to_cpu(dev->descriptor.idProduct));
printk("<1>perixxkbd: detected %s\n", kbd->name); printk("<1>perixxkbd: detected %s\n", kbd->name);
usb_make_path(dev, kbd->phys, sizeof(kbd->phys)); usb_make_path(dev, kbd->phys, sizeof(kbd->phys));
@ -401,14 +425,14 @@ static int usb_kbd_probe(struct usb_interface *iface,
input_set_drvdata(input_dev, kbd); input_set_drvdata(input_dev, kbd);
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) |
BIT_MASK(EV_REP); BIT_MASK(EV_REP);
input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) | input_dev->ledbit[0] = BIT_MASK(LED_NUML) | BIT_MASK(LED_CAPSL) |
BIT_MASK(LED_SCROLLL) | BIT_MASK(LED_COMPOSE) | BIT_MASK(LED_SCROLLL) | BIT_MASK(LED_COMPOSE) |
BIT_MASK(LED_KANA); BIT_MASK(LED_KANA);
for (i = 0; i < 255; i++) for (i = 0; i < 255; i++)
set_bit(px_kbd_keycode[i], input_dev->keybit); set_bit(px_kbd_keycode[i], input_dev->keybit);
clear_bit(0, input_dev->keybit); clear_bit(0, input_dev->keybit);
input_dev->event = usb_kbd_event; input_dev->event = usb_kbd_event;
@ -416,8 +440,8 @@ static int usb_kbd_probe(struct usb_interface *iface,
input_dev->close = usb_kbd_close; input_dev->close = usb_kbd_close;
usb_fill_int_urb(kbd->irq, dev, pipe, usb_fill_int_urb(kbd->irq, dev, pipe,
kbd->new, (maxp > 8 ? 8 : maxp), kbd->new, (maxp > 8 ? 8 : maxp),
usb_kbd_irq, kbd, endpoint->bInterval); usb_kbd_irq, kbd, endpoint->bInterval);
kbd->irq->transfer_dma = kbd->new_dma; kbd->irq->transfer_dma = kbd->new_dma;
kbd->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; kbd->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
@ -429,8 +453,8 @@ static int usb_kbd_probe(struct usb_interface *iface,
kbd->cr->wLength = cpu_to_le16(1); kbd->cr->wLength = cpu_to_le16(1);
usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0), usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0),
(void *) kbd->cr, kbd->leds, 1, (void *) kbd->cr, kbd->leds, 1,
usb_kbd_led, kbd); usb_kbd_led, kbd);
kbd->led->transfer_dma = kbd->leds_dma; kbd->led->transfer_dma = kbd->leds_dma;
kbd->led->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; kbd->led->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
@ -465,7 +489,7 @@ static void usb_kbd_disconnect(struct usb_interface *intf)
static struct usb_device_id usb_kbd_id_table [] = { static struct usb_device_id usb_kbd_id_table [] = {
{ USB_DEVICE(ML_VENDOR_ID, ML_PRODUCT_ID) }, { USB_DEVICE(ML_VENDOR_ID, ML_PRODUCT_ID) },
{ } /* Terminating entry */ { } /* Terminating entry */
}; };
MODULE_DEVICE_TABLE (usb, usb_kbd_id_table); MODULE_DEVICE_TABLE (usb, usb_kbd_id_table);
@ -482,7 +506,7 @@ static int __init usb_kbd_init(void)
int result = usb_register(&usb_kbd_driver); int result = usb_register(&usb_kbd_driver);
if (result == 0) if (result == 0)
printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
DRIVER_DESC "\n"); DRIVER_DESC "\n");
return result; return result;
} }