On Tue, Mar 09, 2004 at 09:58:00PM -0800, David Mosberger wrote:

> Pavlik,
> 
> Here is a small patch relative to 2.6.4-rc2 that does three things:
> 
>  - In hid_init_reports(), establish a idle-period of 1ms before
>    initiating the Get_Request() requests.  It appears there are buggy
>    keyboards (such as the BTC keyboard) where setting the idle period
>    affects not just the Interrupt In pipe, but the control pipe's
>    Get_Requests as well.  I _believe_ this should be harmless to
>    properly operating HID devices, but I can't know for sure.

This is interesting, but sort of makes sense. I'm also considering to
make the idle timer be nonzero during normal operation to get rid of
non-stopping autorepeat when an USB input transfer fails for some reason.

> One question: isn't HID supposed to switch to protocol 1 for keyboards
> supporting the boot protocol?  My reading of the specs is that, yes,
> it should, but I couldn't find any place in the driver where this is
> done.

It's supposed to do that only in case it's planning to use the limited
HID-BP protocol.

> Anyhow, if the patch looks good, please apply.
> 
>       --david
> 
> ===== drivers/usb/input/hid-core.c 1.72 vs edited =====
> --- 1.72/drivers/usb/input/hid-core.c Wed Jan 28 23:12:59 2004
> +++ edited/drivers/usb/input/hid-core.c       Tue Mar  9 21:19:16 2004
> @@ -1086,7 +1086,9 @@
>       hid->cr->wIndex = cpu_to_le16(hid->ifnum);
>       hid->cr->wLength = cpu_to_le16(hid->urbctrl->transfer_buffer_length);
>  
> -     dbg("submitting ctrl urb");
> +     dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u",
> +         hid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report",
> +         hid->cr->wValue, hid->cr->wIndex, hid->cr->wLength);
>  
>       if (usb_submit_urb(hid->urbctrl, GFP_ATOMIC)) {
>               err("usb_submit_urb(ctrl) failed");
> @@ -1265,6 +1267,23 @@
>       int len;
>       int err, ret;
>  
> +     /*
> +      * The Set_Idle request is supposed to affect only the
> +      * "Interrupt In" pipe. Unfortunately, buggy devices such as
> +      * the BTC keyboard (ID 046e:5303) the request also affects
> +      * Get_Report requests on the control pipe.  In the worst
> +      * case, if the device was put on idle for an indefinite
> +      * amount of time (as we do below) and there are no input
> +      * events to report, the Get_Report requests will just hang
> +      * until we get a USB timeout.  To avoid this, we temporarily
> +      * establish a minimal idle time of 1ms.  This shouldn't hurt
> +      * bugfree devices and will cause a worst-case extra delay of
> +      * 1ms for buggy ones.
> +      */
> +     usb_control_msg(hid->dev, usb_sndctrlpipe(hid->dev, 0),
> +                     HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, (1 << 
> 8),
> +                     hid->ifnum, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);
> +
>       report_enum = hid->report_enum + HID_INPUT_REPORT;
>       list = report_enum->report_list.next;
>       while (list != &report_enum->report_list) {
> @@ -1301,7 +1320,7 @@
>               if (len > hid->urbin->transfer_buffer_length)
>                       hid->urbin->transfer_buffer_length = len < HID_BUFFER_SIZE ? 
> len : HID_BUFFER_SIZE;
>               usb_control_msg(hid->dev, usb_sndctrlpipe(hid->dev, 0),
> -                     0x0a, USB_TYPE_CLASS | USB_RECIP_INTERFACE, report->id,
> +                     HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, 
> report->id,
>                       hid->ifnum, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);
>               list = list->next;
>       }
> 

-- 
Vojtech Pavlik
SuSE Labs, SuSE CR


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to