ref: 0918ce10dc7b3e39506b8c4177e68a7b3233f5a9
parent: d0485d345db63b0ee82301251339e72d6093107d
author: ment <[email protected]>
date: Mon Jun 27 18:15:50 EDT 2011
usb/kb: reset led state on boot
--- a/sys/src/cmd/usb/kb/hid.h
+++ b/sys/src/cmd/usb/kb/hid.h
@@ -10,6 +10,8 @@
KbdCSP = 0x010103, /* keyboard.boot.hid */
/* Requests */
+ Getreport = 0x01,
+ Setreport = 0x09,
Getproto = 0x03,
Setproto = 0x0b,
@@ -16,6 +18,9 @@
/* protocols for SET_PROTO request */
Bootproto = 0,
Reportproto = 1,
+
+ /* protocols for SET_REPORT request */
+ Reportout = 0x0200,
};
enum {
--- a/sys/src/cmd/usb/kb/kb.c
+++ b/sys/src/cmd/usb/kb/kb.c
@@ -124,6 +124,12 @@
return usbcmd(f->dev, r, Setproto, Bootproto, id, nil, 0);
}
+static int
+setleds(KDev* f, int eid, uchar leds)
+{
+ return usbcmd(f->dev, Rh2d|Rclass|Riface, Setreport, Reportout, 0, &leds, 1);
+}
+
/*
* Try to recover from a babble error. A port reset is the only way out.
* BUG: we should be careful not to reset a bundle with several devices.
@@ -537,7 +543,10 @@
kd->ep = nil;
return;
}
-
+ if(setleds(kd, ep->id, 0) < 0){
+ fprint(2, "kb: %s: setleds: %r\n", d->dir);
+ return;
+ }
incref(d);
proccreate(f, kd, Stack);
}