From ad55f78a0795e3741cafd9f06f438922279befd2 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Thu, 25 Mar 2010 13:50:26 +0000 Subject: Commit a HID fix by gevaerts that prevent the HID driver to call usb_drv_send_nonblocking while the previous transfer has not finished because the current stack doesn't support transfer queueing. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25329 a1c6a512-1295-4272-9138-f99709370657 --- firmware/usbstack/usb_hid.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c index 4c76ff6db6..213f97180e 100644 --- a/firmware/usbstack/usb_hid.c +++ b/firmware/usbstack/usb_hid.c @@ -180,6 +180,7 @@ static int cur_buf_prepare; static int cur_buf_send; static bool active = false; +static bool currently_sending = false; static int ep_in; static int usb_interface; @@ -595,6 +596,7 @@ void usb_hid_init_connection(void) logf("hid: init connection"); active = true; + currently_sending = false; } /* called by usb_core_init() */ @@ -611,12 +613,14 @@ void usb_hid_init(void) cur_buf_send = 0; active = true; + currently_sending = false; } void usb_hid_disconnect(void) { logf("hid: disconnect"); active = false; + currently_sending = false; } /* called by usb_core_transfer_complete() */ @@ -627,6 +631,7 @@ void usb_hid_transfer_complete(int ep, int dir, int status, int length) (void)status; (void)length; + logf("HID: transfer complete: %d %d %d %d",ep,dir,status,length); switch (dir) { case USB_DIR_OUT: @@ -638,6 +643,7 @@ void usb_hid_transfer_complete(int ep, int dir, int status, int length) send_buffer_len[cur_buf_send] = 0; HID_BUF_INC(cur_buf_send); + currently_sending = false; usb_hid_try_send_drv(); break; } @@ -787,7 +793,15 @@ static void usb_hid_try_send_drv(void) if (!length) return; + if (currently_sending) + { + logf("HID: Already sending"); + return; + } + + logf("HID: Sending %d bytes",length); rc = usb_drv_send_nonblocking(ep_in, send_buffer[cur_buf_send], length); + currently_sending = true; if (rc) { send_buffer_len[cur_buf_send] = 0; -- cgit v1.2.3