aboutsummaryrefslogtreecommitdiffstats
path: root/src/usb-hid.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2010-02-26 08:57:13 -0500
committerKevin O'Connor <kevin@koconnor.net>2010-02-28 17:26:25 -0500
commit357bdfa26a681d614f04e842f85850fe5848f6fe (patch)
tree3b992d2b421d990cf3fe41ed5401826e3015bdf1 /src/usb-hid.c
parent7fb8ba866e112491feb64b2cf82b762fd9071f89 (diff)
downloadseabios-357bdfa26a681d614f04e842f85850fe5848f6fe.tar.gz
Prefer passing a USB "pipe" structure over a USB endp encoding.
Instead of passing the "u32 endp" encoding of the usb endpoint, allocate a "struct usb_pipe" for each end point and pass that. Allocate a control pipe for every device found. Support freeing the pipes after they are done. Implement pipe allocation and freeing for both UHCI and OHCI controllers. Also, don't define every UHCI qh to include a pipe - create a separate structure "struct uhci_pipe". Also, be sure to clear the USBControllers on reset. Also, convert usb_hub_init to return 0 on success. Also, cleanup some of the USB debug messages to make them more consistent.
Diffstat (limited to 'src/usb-hid.c')
-rw-r--r--src/usb-hid.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/usb-hid.c b/src/usb-hid.c
index ae166860..eae68235 100644
--- a/src/usb-hid.c
+++ b/src/usb-hid.c
@@ -18,7 +18,7 @@ struct usb_pipe *keyboard_pipe VAR16VISIBLE;
****************************************************************/
static int
-set_protocol(u32 endp, u16 val)
+set_protocol(struct usb_pipe *pipe, u16 val)
{
struct usb_ctrlrequest req;
req.bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
@@ -26,11 +26,11 @@ set_protocol(u32 endp, u16 val)
req.wValue = val;
req.wIndex = 0;
req.wLength = 0;
- return send_default_control(endp, &req, NULL);
+ return send_default_control(pipe, &req, NULL);
}
static int
-set_idle(u32 endp, int ms)
+set_idle(struct usb_pipe *pipe, int ms)
{
struct usb_ctrlrequest req;
req.bRequestType = USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE;
@@ -38,21 +38,22 @@ set_idle(u32 endp, int ms)
req.wValue = (ms/4)<<8;
req.wIndex = 0;
req.wLength = 0;
- return send_default_control(endp, &req, NULL);
+ return send_default_control(pipe, &req, NULL);
}
#define KEYREPEATWAITMS 500
#define KEYREPEATMS 33
int
-usb_keyboard_init(u32 endp, struct usb_interface_descriptor *iface, int imax)
+usb_keyboard_init(struct usb_pipe *pipe
+ , struct usb_interface_descriptor *iface, int imax)
{
if (! CONFIG_USB_KEYBOARD)
return -1;
if (keyboard_pipe)
// XXX - this enables the first found keyboard (could be random)
return -1;
- dprintf(2, "usb_keyboard_setup %x\n", endp);
+ dprintf(2, "usb_keyboard_setup %x\n", pipe->endp);
// Find intr in endpoint.
struct usb_endpoint_descriptor *epdesc = findEndPointDesc(
@@ -61,22 +62,22 @@ usb_keyboard_init(u32 endp, struct usb_interface_descriptor *iface, int imax)
dprintf(1, "No keyboard intr in?\n");
return -1;
}
- u32 inendp = mkendpFromDesc(endp, epdesc);
// Enable "boot" protocol.
- int ret = set_protocol(endp, 1);
+ int ret = set_protocol(pipe, 1);
if (ret)
return -1;
// Periodically send reports to enable key repeat.
- ret = set_idle(endp, KEYREPEATMS);
+ ret = set_idle(pipe, KEYREPEATMS);
if (ret)
return -1;
- struct usb_pipe *pipe = alloc_intr_pipe(inendp, epdesc->bInterval);
- if (!pipe)
+ u32 inendp = mkendpFromDesc(pipe, epdesc);
+ keyboard_pipe = alloc_intr_pipe(inendp, epdesc->bInterval);
+ if (!keyboard_pipe)
return -1;
- keyboard_pipe = pipe;
+ dprintf(1, "USB keyboard initialized\n");
return 0;
}