From owner-p4-projects@FreeBSD.ORG Sat May 16 21:21:11 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B405D106566C; Sat, 16 May 2009 21:21:10 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 739A8106564A for ; Sat, 16 May 2009 21:21:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 59BA58FC18 for ; Sat, 16 May 2009 21:21:10 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GLLA0O086484 for ; Sat, 16 May 2009 21:21:10 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n4GLLADt086482 for perforce@freebsd.org; Sat, 16 May 2009 21:21:10 GMT (envelope-from hselasky@FreeBSD.org) Date: Sat, 16 May 2009 21:21:10 GMT Message-Id: <200905162121.n4GLLADt086482@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 162182 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 21:21:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=162182 Change 162182 by hselasky@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); }