WIP: add usb keyboard driver
RFC 1/1 WIP: add usb keyboard driver
The driver doesn't work with some "multimedia" keyboards.
This driver contains code ported from u-boot.
--- drivers/input/Kconfig | 7 + drivers/input/Makefile | 1 + drivers/input/usb_kbd.c | 340 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 drivers/input/usb_kbd.c
drivers/input/Kconfig +7 -0
@@ -46,4 +46,11 @@ config KEYBOARD_TWL6030 help Say Y here if you want to use TWL6030 power button as a key. +config KEYBOARD_USB + bool "USB keyboard" + depends on USB_HOST + select POLLER + help + This driver implements support for usb keyboard. + endmenu
drivers/input/Makefile +1 -0
@@ -1,3 +1,4 @@ +obj-$(CONFIG_KEYBOARD_USB) += usb_kbd.o obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
drivers/input/usb_kbd.c new file +340 -0
340 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Excellent! This makes the framebuffer console support complete :)
I have not much to say, the driver looks ok to me. I'll test it once I find time. Some smally comments inline.
drivers/input/usb_kbd.c
Quoted 1 line · Peter Mamonov
drivers/input/usb_kbd.c +0
-0
Please add some copyright header and don't forget to put references in it where you got the code from.
Quoted 9 lines
drivers/input/usb_kbd.c +9
-0+if (pressed ==1 ) { +if (scancode ==NUM_LOCK ) { + data->flags ^=USB_KBD_NUMLOCK ; +return 1 ; + } + +if (scancode ==CAPS_LOCK ) { + data->flags ^=USB_KBD_CAPSLOCK ; +return 1 ;
drivers/input/usb_kbd.c line 164
Quoted 10 lines
drivers/input/usb_kbd.c +10
-0+ } +if (scancode ==SCROLL_LOCK ) { + data->flags ^=USB_KBD_SCROLLLOCK ; +return 1 ; + } + } + +/* Report keycode if any */ +if (keycode) { +pr_debug ("%s: key pressed: '%c'\n" , __FUNCTION__, keycode);
Please use __func__ rather than __FUNCTION__
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 1 line · On Thu, 10 Sep 2015 09:38:15 +0200 Sascha Hauer <[email protected]> wrote:
Excellent! This makes the framebuffer console support complete :)
I'm sorry to dissapoint you, but this implementation of the usb keyboard driver seems to be wrong. The driver employs the get_report request to poll the keyboard state via the control endpoint, however the "Device Class Definition for Human Interface Devices (HID)" states the following:
"This request is not intended to be used for polling the device state on a regular basis. [...] The Interrupt In pipe should be used for recurring Input reports."
I guess this is the source of the problems with some keyboards: 2 of 4 keyboards I've tested changed their state only on key down, but not on key up.
So, according the standard, we need to poll a keyboard via interrupt endpoint. However, current implementation of EHCI driver doesn't support interrupt transactions: submit_int_msg() in ehci-hcd.c is a stub. I'll try to implement it.
Peter
Quoted 33 lines
I have not much to say, the driver looks ok to me. I'll test it once I find time. Some smally comments inline.
drivers/input/usb_kbd.c
Quoted 1 line · Peter Mamonov
drivers/input/usb_kbd.c +0
-0Please add some copyright header and don't forget to put references in it where you got the code from.
Quoted 19 lines
drivers/input/usb_kbd.c +19
-0+if (pressed ==1 ) { +if (scancode ==NUM_LOCK ) { + data->flags ^=USB_KBD_NUMLOCK ; +return 1 ; + } + +if (scancode ==CAPS_LOCK ) { + data->flags ^=USB_KBD_CAPSLOCK ; +return 1 ; + } +if (scancode ==SCROLL_LOCK ) { + data->flags ^=USB_KBD_SCROLLLOCK ; +return 1 ; + } + } + +/* Report keycode if any */ +if (keycode) { + pr_debug("%s: key pressed: '%c'\n", __FUNCTION__,Quoted 1 line
keycode);
Please use
__func__rather than__FUNCTION__
Quoted 2 lines
Sascha
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 14 lines · Peter Mamonov
Quoted 1 line · On Thu, 10 Sep 2015 09:38:15 +0200 Sascha Hauer <[email protected]> wrote:
Excellent! This makes the framebuffer console support complete :)
I'm sorry to dissapoint you, but this implementation of the usb keyboard driver seems to be wrong. The driver employs the
get_reportrequest to poll the keyboard state via the control endpoint, however the "Device Class Definition for Human Interface Devices (HID)" states the following:
"This request is not intended to be used for polling the device state on a regular basis. [...] The Interrupt In pipe should be used for recurring Input reports."
Quoted 3 lines
I guess this is the source of the problems with some keyboards: 2 of 4 keyboards I've tested changed their state only on key down, but not on key up.
Yes, same here. The first keyboard I tested ended up with this behaviour, the second worked.
Quoted 5 lines
So, according the standard, we need to poll a keyboard via interrupt endpoint. However, current implementation of EHCI driver doesn't support interrupt transactions:
submit_int_msg()inehci-hcd.cis a stub. I'll try to implement it.
U-Boot has an implementation for it, should be possible to adopt the corresponding code.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 23 lines · On Thu, 10 Sep 2015 19:21:11 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 14 lines · Peter Mamonov
Quoted 1 line · On Thu, 10 Sep 2015 09:38:15 +0200 Sascha Hauer <[email protected]> wrote:
Excellent! This makes the framebuffer console support complete :)
I'm sorry to dissapoint you, but this implementation of the usb keyboard driver seems to be wrong. The driver employs the
get_reportrequest to poll the keyboard state via the control endpoint, however the "Device Class Definition for Human Interface Devices (HID)" states the following:
"This request is not intended to be used for polling the device state on a regular basis. [...] The Interrupt In pipe should be used for recurring Input reports."Quoted 3 lines
I guess this is the source of the problems with some keyboards: 2 of 4 keyboards I've tested changed their state only on key down, but not on key up.
Yes, same here. The first keyboard I tested ended up with this behaviour, the second worked.
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
So, according the standard, we need to poll a keyboard via interrupt endpoint. However, current implementation of EHCI driver doesn't support interrupt transactions:
submit_int_msg()inehci-hcd.cis a stub. I'll try to implement it.U-Boot has an implementation for it, should be possible to adopt the corresponding code.
I've ported missing functionality from the u-boot and switched to polling via interrupt endpoint. After that all keyboards work fine. Will clean up the code and post the patches.
Peter
Quoted 3 lines
Sascha
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox