Skip to contentSkip to conversation

USB: move keyboard polling from EHCI driver into kbd driver

PATCH New Allen Martin 2 participants 2 messages Dec 16, 2011 – Dec 17, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: move keyboard polling from EHCI driver into kbd driver

This removes dependency on global variable "new" from EHCI driver with CONFIG_SYS_USB_EVENT_POLL turned on and gets USB keyboard working with EHCI driver again.

---
 common/usb_kbd.c            |   18 +++++++++++++++++-
 drivers/usb/host/ehci-hcd.c |   30 ------------------------------
 2 files changed, 17 insertions(+), 31 deletions(-)
common/usb_kbd.c +17 -1
index 75107c9..e94bb7e 100644
@@ -313,7 +313,23 @@ static int usb_kbd_irq(struct usb_device *dev)
 static inline void usb_kbd_poll_for_event(struct usb_device *dev)
 {
 #if	defined(CONFIG_SYS_USB_EVENT_POLL)
-	usb_event_poll();
+	struct usb_interface *iface;
+	struct usb_endpoint_descriptor *ep;
+	struct usb_kbd_pdata *data;
+	int pipe;
+	int maxp;
+
+	/* Get the pointer to USB Keyboard device pointer */
+	data = dev->privptr;
+	iface = &dev->config.if_desc[0];
+	ep = &iface->ep_desc[0];
+	pipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
+
+	/* Submit a interrupt transfer request */
+	maxp = usb_maxpacket(dev, pipe);
+	usb_submit_int_msg(dev, pipe, &data->new[0],
+			maxp > 8 ? 8 : maxp, ep->bInterval);
+
 	usb_kbd_irq_worker(dev);
 #elif	defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
 	struct usb_interface *iface;
drivers/usb/host/ehci-hcd.c +0 -30
index db10316..94a5eed 100644
@@ -26,10 +26,6 @@
 #include <asm/io.h>
 #include <malloc.h>
 #include <watchdog.h>
-#ifdef CONFIG_USB_KEYBOARD
-#include <stdio_dev.h>
-extern unsigned char new[];
-#endif
 
 #include "ehci.h"
 
@@ -946,29 +942,3 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 	return ehci_submit_async(dev, pipe, buffer, length, NULL);
 }
 
-#ifdef CONFIG_SYS_USB_EVENT_POLL
-/*
- * This function polls for USB keyboard data.
- */
-void usb_event_poll()
-{
-	struct stdio_dev *dev;
-	struct usb_device *usb_kbd_dev;
-	struct usb_interface *iface;
-	struct usb_endpoint_descriptor *ep;
-	int pipe;
-	int maxp;
-
-	/* Get the pointer to USB Keyboard device pointer */
-	dev = stdio_get_by_name("usbkbd");
-	usb_kbd_dev = (struct usb_device *)dev->priv;
-	iface = &usb_kbd_dev->config.if_desc[0];
-	ep = &iface->ep_desc[0];
-	pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress);
-
-	/* Submit a interrupt transfer request */
-	maxp = usb_maxpacket(usb_kbd_dev, pipe);
-	usb_submit_int_msg(usb_kbd_dev, pipe, &new[0],
-			maxp > 8 ? 8 : maxp, ep->bInterval);
-}
-#endif /* CONFIG_SYS_USB_EVENT_POLL */
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 USB: move keyboard polling from EHCI driver into kbd driver

Hi,

2011/12/16 Allen Martin <[email protected]>:

Quoted 74 lines

This removes dependency on global variable "new" from EHCI driver with CONFIG_SYS_USB_EVENT_POLL turned on and gets USB keyboard working with EHCI driver again.

---
?common/usb_kbd.c ? ? ? ? ? ?| ? 18 +++++++++++++++++- ?drivers/usb/host/ehci-hcd.c | ? 30 ------------------------------ ?2 files changed, 17 insertions(+), 31 deletions(-)

common/usb_kbd.c +17 -1
index 75107c9..e94bb7e 100644
@@ -313,7 +313,23 @@ static int usb_kbd_irq(struct usb_device *dev)
 ?static inline void usb_kbd_poll_for_event(struct usb_device *dev)
 ?{
 ?#if ? ?defined(CONFIG_SYS_USB_EVENT_POLL)
- ? ? ? usb_event_poll();
+ ? ? ? struct usb_interface *iface;
+ ? ? ? struct usb_endpoint_descriptor *ep;
+ ? ? ? struct usb_kbd_pdata *data;
+ ? ? ? int pipe;
+ ? ? ? int maxp;
+
+ ? ? ? /* Get the pointer to USB Keyboard device pointer */
+ ? ? ? data = dev->privptr;
+ ? ? ? iface = &dev->config.if_desc[0];
+ ? ? ? ep = &iface->ep_desc[0];
+ ? ? ? pipe = usb_rcvintpipe(dev, ep->bEndpointAddress);
+
+ ? ? ? /* Submit a interrupt transfer request */
+ ? ? ? maxp = usb_maxpacket(dev, pipe);
+ ? ? ? usb_submit_int_msg(dev, pipe, &data->new[0],
+ ? ? ? ? ? ? ? ? ? ? ? maxp > 8 ? 8 : maxp, ep->bInterval);
+
 ? ? ? ?usb_kbd_irq_worker(dev);
 ?#elif ?defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP)
 ? ? ? ?struct usb_interface *iface;
drivers/usb/host/ehci-hcd.c +0 -0
index db10316..94a5eed 100644
@@ -26,10 +26,6 @@

?#include <asm/io.h>
?#include <malloc.h>
?#include <watchdog.h>

drivers/usb/host/ehci-hcd.c +0 -4
-#ifdef CONFIG_USB_KEYBOARD
-#include <stdio_dev.h>
-extern unsigned char new[];
-#endif

?#include "ehci.h"

drivers/usb/host/ehci-hcd.c +0 -16
@@ -946,29 +942,3 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 ? ? ? ?return ehci_submit_async(dev, pipe, buffer, length, NULL);
 ?}
 
-#ifdef CONFIG_SYS_USB_EVENT_POLL
-/*
- * This function polls for USB keyboard data.
- */
-void usb_event_poll()
-{
- ? ? ? struct stdio_dev *dev;
- ? ? ? struct usb_device *usb_kbd_dev;
- ? ? ? struct usb_interface *iface;
- ? ? ? struct usb_endpoint_descriptor *ep;
- ? ? ? int pipe;
- ? ? ? int maxp;
-
- ? ? ? /* Get the pointer to USB Keyboard device pointer */
- ? ? ? dev = stdio_get_by_name("usbkbd");
- ? ? ? usb_kbd_dev = (struct usb_device *)dev->priv;

drivers/usb/host/ehci-hcd.c submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, · line 974

Quoted 10 lines
drivers/usb/host/ehci-hcd.c +0 -10
- ? ? ? iface = &usb_kbd_dev->config.if_desc[0];
- ? ? ? ep = &iface->ep_desc[0];
- ? ? ? pipe = usb_rcvintpipe(usb_kbd_dev, ep->bEndpointAddress);
-
- ? ? ? /* Submit a interrupt transfer request */
- ? ? ? maxp = usb_maxpacket(usb_kbd_dev, pipe);
- ? ? ? usb_submit_int_msg(usb_kbd_dev, pipe, &new[0],
- ? ? ? ? ? ? ? ? ? ? ? maxp > 8 ? 8 : maxp, ep->bInterval);
-}
-#endif /* CONFIG_SYS_USB_EVENT_POLL */

The usb_event_poll() is implemented in more drivers. This is not only limited to the EHCI driver.
Please update the other drivers as well.

drivers/usb/musb/musb_hcd.c:1274:void usb_event_poll() drivers/usb/host/r8a66597-hcd.c:911:void usb_event_poll(void) drivers/usb/host/ohci-hcd.c:1775:void usb_event_poll(void) include/usb.h:152:void usb_event_poll(void);

Kind regards,

Remy