From owner-p4-projects@FreeBSD.ORG Tue Jul 18 07:50:24 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 441E616A4EB; Tue, 18 Jul 2006 07:50:24 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 009F216A4DA for ; Tue, 18 Jul 2006 07:50:24 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAA5A43D45 for ; Tue, 18 Jul 2006 07:50:23 +0000 (GMT) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6I7oNgi016359 for ; Tue, 18 Jul 2006 07:50:23 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6I7oNkc016356 for perforce@freebsd.org; Tue, 18 Jul 2006 07:50:23 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 18 Jul 2006 07:50:23 GMT Message-Id: <200607180750.k6I7oNkc016356@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 101836 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: Tue, 18 Jul 2006 07:50:24 -0000 http://perforce.freebsd.org/chv.cgi?CH=101836 Change 101836 by hselasky@hselasky_mini_itx on 2006/07/18 07:49:44 Folded some long lines. The "ng_ubt" driver now searches for the ISOC config with the largest wMaxPacketSize. Affected files ... .. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c#6 edit .. //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_var.h#5 edit Differences ... ==== //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c#6 (text+ko) ==== @@ -286,7 +286,9 @@ }; /* USB config */ -static const struct usbd_config ubt_config_if_1_full_speed[UBT_IF_1_N_TRANSFER] = { +static const struct usbd_config +ubt_config_if_1_full_speed[UBT_IF_1_N_TRANSFER] = { + [0] = { .type = UE_ISOCHRONOUS, .endpoint = -1, /* any */ @@ -329,7 +331,9 @@ }; /* USB config */ -static const struct usbd_config ubt_config_if_1_high_speed[UBT_IF_1_N_TRANSFER] = { +static const struct usbd_config +ubt_config_if_1_high_speed[UBT_IF_1_N_TRANSFER] = { + [0] = { .type = UE_ISOCHRONOUS, .endpoint = -1, /* any */ @@ -490,6 +494,10 @@ { struct usb_attach_arg *uaa = device_get_ivars(dev); struct ubt_softc *sc = device_get_softc(dev); + const struct usbd_config *isoc_setup; + struct usbd_pipe *pipe; + u_int16_t wMaxPacketSize; + u_int8_t alt_index; u_int8_t i; usbd_set_desc(dev, uaa->device); @@ -556,33 +564,57 @@ (uaa->device, 0, sc->sc_xfer_if_0, ubt_config_if_0, UBT_IF_0_N_TRANSFER, sc, &(sc->sc_mtx), &(sc->sc_mem_wait))) { + device_printf(dev, "Could not allocate transfers " + "for interface 0!\n"); goto detach; } /* - * Interface 1 (search alternate settings) + * Interface 1 + * (search alternate settings, and find + * the descriptor with the largest + * wMaxPacketSize) */ + isoc_setup = + ((usbd_get_speed(uaa->device) == USB_SPEED_HIGH) ? + ubt_config_if_1_high_speed : + ubt_config_if_1_full_speed); - for (i = 0; ; i++) { + wMaxPacketSize = 0; + alt_index = 0; + + for (i = 0; i < 32; i++) { - if (usbreq_set_interface(uaa->device, 1, i)) { + if (usbd_fill_iface_data(uaa->device, 1, i)) { + /* end of alternate settings */ break; } - if(usbd_transfer_setup - (uaa->device, 1, - sc->sc_xfer_if_1, - (usbd_get_speed(uaa->device) == USB_SPEED_HIGH) ? - ubt_config_if_1_high_speed : - ubt_config_if_1_full_speed, UBT_IF_1_N_TRANSFER, - sc, &(sc->sc_mtx), &(sc->sc_mem_wait)) == 0) { - goto found; + pipe = usbd_get_pipe(uaa->device, 1, isoc_setup); + + if (pipe && pipe->edesc) { + + if (UGETW(pipe->edesc->wMaxPacketSize) > wMaxPacketSize) { + wMaxPacketSize = UGETW(pipe->edesc->wMaxPacketSize); + alt_index = i; + } } } - goto detach; + if (usbreq_set_interface(uaa->device, 1, alt_index)) { + device_printf(dev, "Could not set alternate " + "setting %d for interface 1!\n", alt_index); + goto detach; + } - found: + if(usbd_transfer_setup + (uaa->device, 1, + sc->sc_xfer_if_1, isoc_setup, UBT_IF_1_N_TRANSFER, + sc, &(sc->sc_mtx), &(sc->sc_mem_wait))) { + device_printf(dev, "Could not allocate transfers " + "for interface 1!\n"); + goto detach; + } /* create Netgraph node */ ==== //depot/projects/usb/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_var.h#5 (text+ko) ====