Re: usb:gadget:hid:Add BOOT mode support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 18 May 2015, Golmer Palmer wrote:

> Alan Stern <stern@...> writes:
> 
> > 
> > On Fri, 15 May 2015, Golmer Palmer wrote:
> > 
> > > Felipe Balbi <balbi <at> ...> writes:
> > > 
> > > > > I suggest that someone responsible of this framework implement 
> this 
> > > > > change.
> > > > > I feel it be easy to do, and I hope s/he can do it soon.
> > > > 
> > > > you can implement it too and send a patch to us. Patches are 
> always
> > > > welcome.
> > > > 
> > > > regards
> > > 
> > > 
> > 
> > Why don't you ask the person who wrote the driver originally (CC'ed)?
> > 
> > Alan Stern
> > 
> 
> Hi Alan,
> 
> I feel that this person ins't at time maintaining this source code.

You seem to be right, since his email address doesn't work any more.

> I'm suposing that this mailing list is readed by very competent people 
> that can implement this "simple" change. I hope someone likes to fix 
> that problem...

I took a look at the driver.  The change you seem to be asking for is
not simple at all.

The problem is that the f_hid driver doesn't support either the Report
or Boot protocols.  Instead, it relies on a user program to generate or
consume the reports that get sent to/from the host.  Currently the
driver has no way to inform the user program about which protocol to
use, and the program has no way to tell the driver when the protocol 
is changed.

Your original email message said:

> The problem is that several Keyboard and Mouse implementations using this 
> framework are in fact fully compatible with BOOT mode.

As far as I can tell, an implementation can support either the Report
or Boot protocol, but not both.  The problem is that when you use a
keyboard or mouse during boot-up, the BIOS will want to use the Boot
protocol, and once the boot-up is complete, the operating system will
want to switch to the Report protocol.

The patch below adds support for Get Protocol and Set Protocol, but
only for one protocol at a time (switching is not supported).  Does
this do what you want?

Alan Stern



Index: usb-4.0/drivers/usb/gadget/function/f_hid.c
===================================================================
--- usb-4.0.orig/drivers/usb/gadget/function/f_hid.c
+++ usb-4.0/drivers/usb/gadget/function/f_hid.c
@@ -418,7 +418,12 @@ static int hidg_setup(struct usb_functio
 	case ((USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
 		  | HID_REQ_GET_PROTOCOL):
 		VDBG(cdev, "get_protocol\n");
-		goto stall;
+		length = min_t(unsigned, length, 1);
+		if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT)
+			((u8 *) req->buf)[0] = 0;	/* Boot protocol */
+		else
+			((u8 *) req->buf)[0] = 1;	/* Report protocol */
+		goto respond;
 		break;
 
 	case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
@@ -430,6 +435,14 @@ static int hidg_setup(struct usb_functio
 	case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8
 		  | HID_REQ_SET_PROTOCOL):
 		VDBG(cdev, "set_protocol\n");
+		length = 0;
+		if (hidg->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT) {
+			if (value == 0)		/* Boot protocol */
+				goto respond;
+		} else {
+			if (value == 1)		/* Report protocol */
+				goto respond;
+		}
 		goto stall;
 		break;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux