From owner-p4-projects@FreeBSD.ORG Sun Jun 14 13:18:40 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 532681065688; Sun, 14 Jun 2009 13:18:40 +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 1360A106567D for ; Sun, 14 Jun 2009 13:18:40 +0000 (UTC) (envelope-from syl@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id DB30B8FC1C for ; Sun, 14 Jun 2009 13:18:39 +0000 (UTC) (envelope-from syl@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 n5EDIdEK018890 for ; Sun, 14 Jun 2009 13:18:39 GMT (envelope-from syl@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n5EDIdFU018888 for perforce@freebsd.org; Sun, 14 Jun 2009 13:18:39 GMT (envelope-from syl@FreeBSD.org) Date: Sun, 14 Jun 2009 13:18:39 GMT Message-Id: <200906141318.n5EDIdFU018888@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to syl@FreeBSD.org using -f From: Sylvestre Gallon To: Perforce Change Reviews Cc: Subject: PERFORCE change 164338 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, 14 Jun 2009 13:18:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=164338 Change 164338 by syl@syl_atuin on 2009/06/14 13:17:49 - Implement libusb_get_buffsize helper. - Implement libusb_get_maxframe helper. - Update transfer code. - Call libusb20_tr_start at the end of libusb_submit(). Affected files ... .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#29 edit .. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#10 edit Differences ... ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#29 (text+ko) ==== @@ -709,6 +709,77 @@ pthread_mutex_unlock(&libusb20_lock); } +static int +libusb_get_buffsize(struct libusb20_device *pdev, libusb_transfer *xfer) +{ + int ret; + int usb_speed; + + usb_speed = libusb20_dev_get_speed(pdev); + + switch (xfer->type) { + case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: + switch (usb_speed) { + case LIBUSB20_SPEED_LOW: + case LIBUSB20_SPEED_FULL: + ret = 60 * 1; + break ; + default : + ret = 60 * 8; + break ; + } + break ; + default: + ret = 1; + break ; + } + + return ret; +} + +static int +libusb_get_maxframe(struct libusb20_device *pdev, libusb_transfer *xfer) +{ + int ret; + int usb_speed; + + usb_speed = libusb20_dev_get_speed(pdev); + + switch (xfer->type) { + case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS: + ret = 0; + break ; + case LIBUSB_TRANSFER_TYPE_CONTROL: + switch (usb_speed) { + case LIBUSB20_SPEED_LOW: + ret = 8; + break ; + case LIBUSB20_SPEED_FULL: + ret = 64; + break ; + case LIBUSB20_SPEED_HIGH: + ret = 64; + break ; + } + break ; + default : + switch (usb_speed) { + case LIBUSB20_SPEED_LOW: + ret = 256; + break ; + case LIBUSB20_SPEED_FULL: + ret = 4096; + break ; + case LIBUSB20_SPEED_HIGH: + ret = 16384; + break ; + } + break ; + } + + return ret; +} + int libusb_submit_transfer(struct libusb_transfer *xfer) { @@ -719,6 +790,8 @@ struct libusb_context *ctx; struct timespec cur_ts; struct timeval *cur_tv; + int maxframe; + int buffsize; int num_frame; int ret; int i; @@ -777,8 +850,12 @@ xfer->os_priv = usb20_xfer; pthread_mutex_lock(&libusb20_lock); - ret = libusb20_tr_open(usb20_xfer, xfer->length, - MAX(2, xfer->num_iso_packets), xfer->endpoint); + + buffsize = libusb_get_buffsize(pdev, xfer); + maxframe = libusb_get_maxframe(pdev, xfer); + + ret = libusb20_tr_open(usb20_xfer, buffsize, + maxframe, xfer->endpoint); if (ret != 0) { pthread_mutex_unlock(&libusb20_lock); @@ -812,6 +889,7 @@ libusb20_tr_set_callback(usb20_xfer, libusb10_proxy); libusb20_tr_submit(usb20_xfer); + libusb20_tr_start(usb20_xfer); pthread_mutex_unlock(&libusb20_lock); return (0); ==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_io.c#10 (text+ko) ====