PERFORCE change 164338 for review

Sylvestre Gallon syl at FreeBSD.org
Sun Jun 14 13:18:41 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164338

Change 164338 by syl at 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) ====



More information about the p4-projects mailing list