From owner-p4-projects@FreeBSD.ORG Sun Sep 23 14:59:52 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B84F216A421; Sun, 23 Sep 2007 14:59:52 +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 75AAF16A417 for ; Sun, 23 Sep 2007 14:59:52 +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 56BDF13C43E for ; Sun, 23 Sep 2007 14:59:52 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8NExlMq088200 for ; Sun, 23 Sep 2007 14:59:47 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8NExlNn088197 for perforce@freebsd.org; Sun, 23 Sep 2007 14:59:47 GMT (envelope-from hselasky@FreeBSD.org) Date: Sun, 23 Sep 2007 14:59:47 GMT Message-Id: <200709231459.l8NExlNn088197@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 126736 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: Sun, 23 Sep 2007 14:59:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=126736 Change 126736 by hselasky@hselasky_laptop001 on 2007/09/23 14:59:13 FYI; The comments follow the P4 diff from top to bottom. - remove redundant inclusion of "sys/vnode.h" - after the change to always USB DMA buffers the "ums" driver needs a temporary buffer for scratching and decoding information, hence the HID library does not understand DMA buffers yet. See "sc_temp[]". - some space to tab conversion sneaked in two places, sorry. - actlen of USB control transfers is now 16-bit unsigned. - print a warning if the USB interrupt data is larger than "max_frame_size". - the "USB_CDEV_FLAG_FWD_SHORT" flag is redundant and has been removed. - UMS uses "usb_cdev_put_data_linear()" hence it does not understand DMA buffers ... Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ums.c#21 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ums.c#21 (text+ko) ==== @@ -50,7 +50,6 @@ #include #include #include -#include #include #include @@ -109,6 +108,7 @@ u_int8_t sc_buttons; u_int8_t sc_iid; + uint8_t sc_temp[64]; }; static void @@ -170,7 +170,7 @@ { struct ums_softc *sc = xfer->priv_sc; struct usbd_mbuf *m; - u_int8_t *buf = xfer->buffer; + uint8_t *buf = sc->sc_temp; u_int16_t len = xfer->actlen; int32_t buttons = 0; int32_t dx; @@ -183,6 +183,19 @@ tr_transferred: DPRINTF(5, "sc=%p actlen=%d\n", sc, len); + + if (len > sizeof(sc->sc_temp)) { + DPRINTF(5, "truncating large packet to %d bytes\n", + sizeof(sc->sc_temp)); + len = sizeof(sc->sc_temp); + } + + if (len == 0) { + goto tr_setup; + } + + usbd_copy_out(xfer->frbuffers + 0, 0, buf, len); + DPRINTF(5, "data = %02x %02x %02x %02x " "%02x %02x %02x %02x\n", (len > 0) ? buf[0] : 0, (len > 1) ? buf[1] : 0, @@ -190,10 +203,6 @@ (len > 4) ? buf[4] : 0, (len > 5) ? buf[5] : 0, (len > 6) ? buf[6] : 0, (len > 7) ? buf[7] : 0); - if (len == 0) { - goto tr_setup; - } - /* * The M$ Wireless Intellimouse 2.0 sends 1 extra leading byte * of data compared to most USB mice. This byte frequently @@ -276,11 +285,11 @@ (dx == 0) && (dy == 0) && (dz == 0) && (dt == 0) && (buttons == 0)) { - __callout_reset(&(sc->sc_callout), hz / 20, + __callout_reset(&(sc->sc_callout), hz / 20, &ums_put_queue_timeout, sc); } else { - __callout_stop(&(sc->sc_callout)); + __callout_stop(&(sc->sc_callout)); ums_put_queue(sc, dx, dy, dz, dt, buttons); } @@ -293,7 +302,8 @@ USBD_IF_POLL(&(sc->sc_cdev.sc_rdq_free), m); if (m) { - usbd_start_hardware(xfer); + xfer->frlengths[0] = xfer->max_data_length; + usbd_start_hardware(xfer); } } return; @@ -313,7 +323,7 @@ .type = UE_INTERRUPT, .endpoint = UE_ADDR_ANY, .direction = UE_DIR_IN, - .flags = (USBD_PIPE_BOF|USBD_SHORT_XFER_OK), + .flags = { .pipe_bof = 1, .short_xfer_ok = 1, }, .bufsize = 0, /* use wMaxPacketSize */ .callback = &ums_intr_callback, }, @@ -335,8 +345,8 @@ struct usb_attach_arg *uaa = device_get_ivars(dev); usb_interface_descriptor_t *id; void *d_ptr; - int32_t d_len; int32_t error = 0; + uint16_t d_len; DPRINTF(10, "\n"); @@ -353,8 +363,10 @@ return UMATCH_NONE; } - error = usbreq_read_report_desc(uaa->device, uaa->iface_index, - &d_ptr, &d_len, M_TEMP); + error = hid_read_report_desc_from_usb + (uaa->device, &usb_global_lock, + &d_ptr, &d_len, M_TEMP, uaa->iface_index); + if (error) { return UMATCH_NONE; } @@ -372,10 +384,10 @@ void *d_ptr = NULL; const char * p_buf[2]; int32_t unit = device_get_unit(dev); - int32_t d_len; int32_t isize; u_int32_t flags; int32_t err; + uint16_t d_len; u_int8_t i; char buf_1[16]; @@ -396,8 +408,10 @@ goto detach; } - err = usbreq_read_report_desc(uaa->device, uaa->iface_index, - &d_ptr, &d_len, M_TEMP); + err = hid_read_report_desc_from_usb + (uaa->device, &usb_global_lock, &d_ptr, + &d_len, M_TEMP, uaa->iface_index); + if (err) { device_printf(dev, "error reading report description\n"); goto detach; @@ -486,10 +500,10 @@ sc->sc_loc_btn[2].pos = 10; } - if (isize > sc->sc_xfer[0]->length) { + if (isize > sc->sc_xfer[0]->max_frame_size) { DPRINTF(0, "WARNING: report size, %d bytes, is larger " "than interrupt size, %d bytes!\n", - isize, sc->sc_xfer[0]->length); + isize, sc->sc_xfer[0]->max_frame_size); } /* announce information about the mouse */ @@ -553,8 +567,7 @@ sc->sc_cdev.sc_stop_read = &ums_stop_read; sc->sc_cdev.sc_open = &ums_open; sc->sc_cdev.sc_ioctl = &ums_ioctl; - sc->sc_cdev.sc_flags |= (USB_CDEV_FLAG_FWD_SHORT| - USB_CDEV_FLAG_WAKEUP_RD_IMMED| + sc->sc_cdev.sc_flags |= (USB_CDEV_FLAG_WAKEUP_RD_IMMED| USB_CDEV_FLAG_WAKEUP_WR_IMMED); err = usb_cdev_attach(&(sc->sc_cdev), sc, &(sc->sc_mtx), p_buf, @@ -647,7 +660,7 @@ buf[7] = (((~buttons) >> 3) & MOUSE_SYS_EXTBUTTONS); } - usb_cdev_put_data(&(sc->sc_cdev), buf, + usb_cdev_put_data_linear(&(sc->sc_cdev), buf, sc->sc_mode.packetsize, 1); } else {