PERFORCE change 162182 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sat May 16 21:21:11 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=162182
Change 162182 by hselasky at hselasky_laptop001 on 2009/05/16 21:20:10
USB input:
- Fix leds for keyboards which require an ID byte for
the HID output structures.
Reported by: Christoph Langguth
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/input/ukbd.c#8 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/input/ukbd.c#8 (text+ko) ====
@@ -166,7 +166,8 @@
uint8_t sc_leds; /* store for async led requests */
uint8_t sc_iface_index;
uint8_t sc_iface_no;
- uint8_t sc_hid_id;
+ uint8_t sc_kbd_id;
+ uint8_t sc_led_id;
};
#define KEY_ERROR 0x01
@@ -498,10 +499,10 @@
goto tr_setup;
}
- if (sc->sc_hid_id != 0) {
+ if (sc->sc_kbd_id != 0) {
/* check and remove HID ID byte */
usb2_copy_out(xfer->frbuffers, 0, &id, 1);
- if (id != sc->sc_hid_id) {
+ if (id != sc->sc_kbd_id) {
DPRINTF("wrong HID ID\n");
goto tr_setup;
}
@@ -589,7 +590,7 @@
ukbd_set_leds_callback(struct usb2_xfer *xfer)
{
struct usb2_device_request req;
- uint8_t buf[1];
+ uint8_t buf[2];
struct ukbd_softc *sc = xfer->priv_sc;
switch (USB_GET_STATE(xfer)) {
@@ -603,15 +604,24 @@
USETW2(req.wValue, UHID_OUTPUT_REPORT, 0);
req.wIndex[0] = sc->sc_iface_no;
req.wIndex[1] = 0;
- USETW(req.wLength, 1);
+ req.wLength[1] = 0;
- buf[0] = sc->sc_leds;
+ /* check if we need to prefix an ID byte */
+ if (sc->sc_led_id != 0) {
+ req.wLength[0] = 2;
+ buf[0] = sc->sc_led_id;
+ buf[1] = sc->sc_leds;
+ } else {
+ req.wLength[0] = 1;
+ buf[0] = sc->sc_leds;
+ buf[1] = 0;
+ }
usb2_copy_in(xfer->frbuffers, 0, &req, sizeof(req));
usb2_copy_in(xfer->frbuffers + 1, 0, buf, sizeof(buf));
xfer->frlengths[0] = sizeof(req);
- xfer->frlengths[1] = sizeof(buf);
+ xfer->frlengths[1] = req.wLength[0];
xfer->nframes = 2;
usb2_start_hardware(xfer);
}
@@ -638,7 +648,7 @@
.type = UE_CONTROL,
.endpoint = 0x00, /* Control pipe */
.direction = UE_DIR_ANY,
- .bufsize = sizeof(struct usb2_device_request) + 1,
+ .bufsize = sizeof(struct usb2_device_request) + 8,
.callback = &ukbd_set_leds_callback,
.timeout = 1000, /* 1 second */
},
@@ -737,14 +747,14 @@
if (hid_locate(hid_ptr, hid_len,
HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT),
hid_input, 0, &sc->sc_loc_apple_eject, &flags,
- &sc->sc_hid_id)) {
+ &sc->sc_kbd_id)) {
if (flags & HIO_VARIABLE)
sc->sc_flags |= UKBD_FLAG_APPLE_EJECT |
UKBD_FLAG_APPLE_SWAP;
if (hid_locate(hid_ptr, hid_len,
HID_USAGE2(0xFFFF, 0x0003),
hid_input, 0, &sc->sc_loc_apple_fn, &flags,
- &sc->sc_hid_id)) {
+ &sc->sc_kbd_id)) {
if (flags & HIO_VARIABLE)
sc->sc_flags |= UKBD_FLAG_APPLE_FN |
UKBD_FLAG_APPLE_SWAP;
@@ -755,8 +765,12 @@
* keyboard data
*/
hid_report_size(hid_ptr, hid_len,
- hid_input, &sc->sc_hid_id);
+ hid_input, &sc->sc_kbd_id);
}
+
+ /* investigate if we need an ID-byte for the leds */
+ hid_report_size(hid_ptr, hid_len, hid_output, &sc->sc_led_id);
+
free(hid_ptr, M_TEMP);
}
More information about the p4-projects
mailing list