USB: Add functionality to poll the USB keyboard via control EP
PATCH 1/1 USB: Add functionality to poll the USB keyboard via control EP
This allows the keyboard to avoid requests via Interrupt Endpoint altogether and run all requests via Control Endpoint. This uses the Get_Report request.
--- common/usb_kbd.c | 63 ++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 49 insertions(+), 14 deletions(-)
common/usb_kbd.c +49 -14
@@ -96,6 +96,25 @@ static unsigned char usb_kbd_numkey_shifted[] = {'+' ,'{' ,'}' ,'|' ,'~' ,':' ,'"' ,'~' ,'<' ,'>' ,'?' }; +static int usb_kbd_irq_worker (struct usb_device *dev); + +/****************************************************************** +* Interrupt polling +******************************************************************/ +static inline void usb_kbd_poll_for_event (struct usb_device *dev) +{ +#if defined(CONFIG_SYS_USB_EVENT_POLL ) +usb_event_poll (); +usb_kbd_irq_worker (dev); +#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP ) +struct usb_interface *iface; + iface = &dev->config.if_desc[0 ]; +usb_get_report (dev, iface->desc.bInterfaceNumber, +1 ,1 , new,sizeof (new)); +usb_kbd_irq_worker (dev); +#endif +} +/****************************************************************** * Queue handling ******************************************************************/
@@ -120,9 +139,14 @@ static void usb_kbd_put_queue(char data)/* test if a character is in the queue */ static int usb_kbd_testc (void ) { -#ifdef CONFIG_SYS_USB_EVENT_POLL -usb_event_poll (); -#endif +struct stdio_dev *dev; +struct usb_device *usb_kbd_dev; + + dev =stdio_get_by_name ("usbkbd" ); + usb_kbd_dev = (struct usb_device *)dev->priv; + +usb_kbd_poll_for_event (usb_kbd_dev); +if (usb_in_pointer==usb_out_pointer)return (0 );/* no data */ else
@@ -132,11 +156,16 @@ static int usb_kbd_testc(void)static int usb_kbd_getc (void ) {char c; -while (usb_in_pointer==usb_out_pointer) { -#ifdef CONFIG_SYS_USB_EVENT_POLL -usb_event_poll (); -#endif - } + +struct stdio_dev *dev; +struct usb_device *usb_kbd_dev; + + dev =stdio_get_by_name ("usbkbd" ); + usb_kbd_dev = (struct usb_device *)dev->priv; + +while (usb_in_pointer==usb_out_pointer) +usb_kbd_poll_for_event (usb_kbd_dev); +if ((usb_out_pointer+1 )==USB_KBD_BUFFER_LEN ) usb_out_pointer=0 ;else
@@ -308,15 +337,10 @@ static int usb_kbd_translate(unsigned char scancode,unsigned char modifier,int p }/* Interrupt service routine */ -static int usb_kbd_irq (struct usb_device *dev) +static int usb_kbd_irq_worker (struct usb_device *dev) {int i,res; -if ((dev->irq_status!=0 )||(dev->irq_act_len!=8 )) - { -USB_KBD_PRINTF ("usb_keyboard Error %lX, len %d\n" ,dev->irq_status,dev->irq_act_len); -return 1 ; - } res=0 ;switch (new[0 ]) {
@@ -345,6 +369,17 @@ static int usb_kbd_irq(struct usb_device *dev)return 1 ;/* install IRQ Handler again */ } +static int usb_kbd_irq (struct usb_device *dev) +{ +if ((dev->irq_status !=0 ) || (dev->irq_act_len !=8 )) + { +USB_KBD_PRINTF ("usb_keyboard Error %lX, len %d\n" ,dev->irq_status,dev->irq_act_len); +return 1 ; + } + +return usb_kbd_irq_worker (dev); +} +/* probes the USB device dev for keyboard type */ static int usb_kbd_probe (struct usb_device *dev,unsigned int ifnum) {
Signature · 1 line
1.7.5.4
PATCH v2 1/1 USB: Add functionality to poll the USB keyboard via control EP
This allows the keyboard to avoid requests via Interrupt Endpoint altogether and run all requests via Control Endpoint. This uses the Get_Report request.
--- common/usb_kbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 50 insertions(+), 14 deletions(-)
V2: Add missing condition to ignore repetitive events when polling via EP0
common/usb_kbd.c +50 -14
@@ -96,6 +96,26 @@ static unsigned char usb_kbd_numkey_shifted[] = {'+' ,'{' ,'}' ,'|' ,'~' ,':' ,'"' ,'~' ,'<' ,'>' ,'?' }; +static int usb_kbd_irq_worker (struct usb_device *dev); + +/****************************************************************** +* Interrupt polling +******************************************************************/ +static inline void usb_kbd_poll_for_event (struct usb_device *dev) +{ +#if defined(CONFIG_SYS_USB_EVENT_POLL ) +usb_event_poll (); +usb_kbd_irq_worker (dev); +#elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP ) +struct usb_interface *iface; + iface = &dev->config.if_desc[0 ]; +usb_get_report (dev, iface->desc.bInterfaceNumber, +1 ,1 , new,sizeof (new)); +if (memcmp (old, new,sizeof (new))) +usb_kbd_irq_worker (dev); +#endif +} +/****************************************************************** * Queue handling ******************************************************************/
@@ -120,9 +140,14 @@ static void usb_kbd_put_queue(char data)/* test if a character is in the queue */ static int usb_kbd_testc (void ) { -#ifdef CONFIG_SYS_USB_EVENT_POLL -usb_event_poll (); -#endif +struct stdio_dev *dev; +struct usb_device *usb_kbd_dev; + + dev =stdio_get_by_name ("usbkbd" ); + usb_kbd_dev = (struct usb_device *)dev->priv; + +usb_kbd_poll_for_event (usb_kbd_dev); +if (usb_in_pointer==usb_out_pointer)return (0 );/* no data */ else
@@ -132,11 +157,16 @@ static int usb_kbd_testc(void)static int usb_kbd_getc (void ) {char c; -while (usb_in_pointer==usb_out_pointer) { -#ifdef CONFIG_SYS_USB_EVENT_POLL -usb_event_poll (); -#endif - } + +struct stdio_dev *dev; +struct usb_device *usb_kbd_dev; + + dev =stdio_get_by_name ("usbkbd" ); + usb_kbd_dev = (struct usb_device *)dev->priv; + +while (usb_in_pointer==usb_out_pointer) +usb_kbd_poll_for_event (usb_kbd_dev); +if ((usb_out_pointer+1 )==USB_KBD_BUFFER_LEN ) usb_out_pointer=0 ;else
@@ -308,15 +338,10 @@ static int usb_kbd_translate(unsigned char scancode,unsigned char modifier,int p }/* Interrupt service routine */ -static int usb_kbd_irq (struct usb_device *dev) +static int usb_kbd_irq_worker (struct usb_device *dev) {int i,res; -if ((dev->irq_status!=0 )||(dev->irq_act_len!=8 )) - { -USB_KBD_PRINTF ("usb_keyboard Error %lX, len %d\n" ,dev->irq_status,dev->irq_act_len); -return 1 ; - } res=0 ;switch (new[0 ]) {
@@ -345,6 +370,17 @@ static int usb_kbd_irq(struct usb_device *dev)return 1 ;/* install IRQ Handler again */ } +static int usb_kbd_irq (struct usb_device *dev) +{ +if ((dev->irq_status !=0 ) || (dev->irq_act_len !=8 )) + { +USB_KBD_PRINTF ("usb_keyboard Error %lX, len %d\n" ,dev->irq_status,dev->irq_act_len); +return 1 ; + } + +return usb_kbd_irq_worker (dev); +} +/* probes the USB device dev for keyboard type */ static int usb_kbd_probe (struct usb_device *dev,unsigned int ifnum) {
Signature · 1 line
1.7.5.4
PATCH v2 1/1 USB: Add functionality to poll the USB keyboard via control EP
Dear Marek Vasut,
Quoted 10 lines · In message <[email protected]> you wrote:
This allows the keyboard to avoid requests via Interrupt Endpoint altogether and run all requests via Control Endpoint. This uses the
Get_Reportrequest.Signed-off-by Marek Vasut <[email protected]>Cc Remy Bohmer <[email protected]>--- common/usb_kbd.c | 64 ++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 50 insertions(+), 14 deletions(-)V2: Add missing condition to ignore repetitive events when polling via EP0
Checkpatch says:
total: 5 errors, 1 warnings, 97 lines checked
Please clean up and resubmit. Thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The following statement is not true. The previous statement is true.
PATCH v2 1/1 USB: Add functionality to poll the USB keyboard via control EP
Dear Wolfgang Denk,
Quoted 20 lines
Dear Marek Vasut,
Quoted 6 lines · In message <[email protected]> you wrote:
This allows the keyboard to avoid requests via Interrupt Endpoint altogether and run all requests via Control Endpoint. This uses the
Get_Reportrequest.Signed-off-by Marek Vasut <[email protected]>Cc Remy Bohmer <[email protected]>Quoted 8 lines
---
common/usb_kbd.c | 64++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 50 insertions(+), 14 deletions(-)
V2: Add missing condition to ignore repetitive events when polling via EP0
Checkpatch says:
Quoted 7 lines
total: 5 errors, 1 warnings, 97 lines checked
Please clean up and resubmit. Thanks.
Best regards,
Wolfgang Denk
Please see my previous comment about the state of usbkbd.c. The warnings are from original code that was moved around.
I'd prefer to submit further usbkbd cleanup patch.
Cheers
PATCH v2 1/1 USB: Add functionality to poll the USB keyboard via control EP
Dear Marek Vasut,
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 4 lines
Checkpatch says:
total: 5 errors, 1 warnings, 97 lines checked
...
Quoted 4 lines
Please see my previous comment about the state of
usbkbd.c. The warnings are from original code that was moved around.I'd prefer to submit further usbkbd cleanup patch.
If Remy accepts it...
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de When in doubt, mumble; when in trouble, delegate; when in charge, ponder. -- James H. Boren
PATCH v2 1/1 USB: Add functionality to poll the USB keyboard via control EP
Hi,
2011/10/7 Wolfgang Denk <[email protected]>:
Quoted 6 lines
Dear Marek Vasut,
Quoted 3 lines · In message <[email protected]> you wrote:
Quoted 3 lines
Checkpatch says:
Quoted 8 lines
Quoted 1 line
Quoted 1 line
total: 5 errors, 1 warnings, 97 lines checked
...
Quoted 4 lines
Please see my previous comment about the state of
usbkbd.c. The warnings are from original code that was moved around.I'd prefer to submit further usbkbd cleanup patch.
If Remy accepts it...
Find with me.
Remy
PATCH v2 1/1 USB: Add functionality to poll the USB keyboard via control EP
In reply to Wolfgang DenkHi,
2011/10/6 Wolfgang Denk <[email protected]>:
Quoted 13 lines
Dear Marek Vasut,
Quoted 10 lines · In message <[email protected]> you wrote:
This allows the keyboard to avoid requests via Interrupt Endpoint altogether and run all requests via Control Endpoint. This uses the
Get_Reportrequest.Signed-off-by Marek Vasut <[email protected]>Cc Remy Bohmer <[email protected]>---
?common/usb_kbd.c | ? 64 ++++++++++++++++++++++++++++++++++++++++++----------- ?1 files changed, 50 insertions(+), 14 deletions(-)V2: Add missing condition to ignore repetitive events when polling via EP0
Applied to u-boot-usb
Kind regards,
Remy