svn commit: r193313 - head/lib/libusb
Andrew Thompson
thompsa at FreeBSD.org
Tue Jun 2 17:27:52 UTC 2009
Author: thompsa
Date: Tue Jun 2 17:27:51 2009
New Revision: 193313
URL: http://svn.freebsd.org/changeset/base/193313
Log:
Add libusb20_tr_get_length to get the transfer length.
Submitted by: Hans Petter Selasky
Modified:
head/lib/libusb/libusb.3
head/lib/libusb/libusb20.c
head/lib/libusb/libusb20.h
Modified: head/lib/libusb/libusb.3
==============================================================================
--- head/lib/libusb/libusb.3 Tue Jun 2 16:57:27 2009 (r193312)
+++ head/lib/libusb/libusb.3 Tue Jun 2 17:27:51 2009 (r193313)
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 21, 2009
+.Dd May 28, 2009
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -78,6 +78,8 @@ USB access library (libusb -lusb)
.Fn libusb20_tr_set_callback "struct libusb20_transfer *xfer" "libusb20_tr_callback_t *cb"
.Ft void
.Fn libusb20_tr_set_flags "struct libusb20_transfer *xfer" "uint8_t flags"
+.Ft uint32_t
+.Fn libusb20_tr_get_length "struct libusb20_transfer *xfer" "uint16_t fr_index"
.Ft void
.Fn libusb20_tr_set_length "struct libusb20_transfer *xfer" "uint32_t length" "uint16_t fr_index"
.Ft void
@@ -183,6 +185,10 @@ USB access library (libusb -lusb)
.Ft int
.Fn libusb20_be_remove_dev_quirk "struct libusb20_backend *pbe" "struct libusb20_quirk *pq"
.Ft struct libusb20_backend *
+.Fn libusb20_be_alloc_default "void"
+.Ft struct libusb20_backend *
+.Fn libusb20_be_alloc_freebsd "void"
+.Ft struct libusb20_backend *
.Fn libusb20_be_alloc_linux "void"
.Ft struct libusb20_device *
.Fn libusb20_be_device_foreach "struct libusb20_backend *pbe" "struct libusb20_device *pdev"
@@ -227,7 +233,7 @@ Non-zero return values indicate a LIBUSB
.Pp
.
.Fn libusb20_tr_open
-will allocate kernel resources like
+will allocate kernel buffer resources according to
.Fa max_buf_size
and
.Fa max_frame_count
@@ -235,6 +241,18 @@ associated with an USB
.Fa pxfer
and bind the transfer to the specified
.Fa ep_no .
+.Fa max_buf_size
+is the minimum buffer size which the data transport layer has to support.
+If
+.Fa max_buf_size
+is zero, the
+.Nm
+library will use wMaxPacketSize to compute the buffer size.
+This can be useful for isochronous transfers.
+The actual buffer size can be greater than
+.Fa max_buf_size
+and is returned by
+.Fn libusb20_tr_get_max_total_length .
.
This function returns zero upon success.
.
@@ -367,8 +385,14 @@ Will do a clear-stall before starting th
.
.Pp
.
+.Fn libusb20_tr_get_length
+returns the length of the given USB frame by index.
+After an USB transfer is complete the USB frame length will get updated to the actual transferred length.
+.
+.Pp
+.
.Fn libusb20_tr_set_length
-sets the length of a given USB transfer and frame index.
+sets the length of the given USB frame by index.
.
.Pp
.
@@ -750,7 +774,7 @@ function will wait until a pending USB t
the given USB device.
.
A timeout value can be specified which is passed on to the
-.Xr 2 poll
+.Xr poll 2
function.
.
.Sh USB BACKEND OPERATIONS
@@ -829,6 +853,10 @@ returned.
If the given quirk does not exist LIBUSB20_ERROR_NOT_FOUND is
returned.
.
+.Pp
+.
+.Fn libusb20_be_alloc_default
+.Fn libusb20_be_alloc_freebsd
.Fn libusb20_be_alloc_linux
These functions are used to allocate a specific USB backend or the
operating system default USB backend. Allocating a backend is a way to
Modified: head/lib/libusb/libusb20.c
==============================================================================
--- head/lib/libusb/libusb20.c Tue Jun 2 16:57:27 2009 (r193312)
+++ head/lib/libusb/libusb20.c Tue Jun 2 17:27:51 2009 (r193313)
@@ -319,6 +319,12 @@ libusb20_tr_set_flags(struct libusb20_tr
return;
}
+uint32_t
+libusb20_tr_get_length(struct libusb20_transfer *xfer, uint16_t frIndex)
+{
+ return (xfer->pLength[frIndex]);
+}
+
void
libusb20_tr_set_length(struct libusb20_transfer *xfer, uint32_t length, uint16_t frIndex)
{
Modified: head/lib/libusb/libusb20.h
==============================================================================
--- head/lib/libusb/libusb20.h Tue Jun 2 16:57:27 2009 (r193312)
+++ head/lib/libusb/libusb20.h Tue Jun 2 17:27:51 2009 (r193313)
@@ -216,6 +216,7 @@ void libusb20_tr_drain(struct libusb20_t
void libusb20_tr_set_buffer(struct libusb20_transfer *xfer, void *buffer, uint16_t fr_index);
void libusb20_tr_set_callback(struct libusb20_transfer *xfer, libusb20_tr_callback_t *cb);
void libusb20_tr_set_flags(struct libusb20_transfer *xfer, uint8_t flags);
+uint32_t libusb20_tr_get_length(struct libusb20_transfer *xfer, uint16_t fr_index);
void libusb20_tr_set_length(struct libusb20_transfer *xfer, uint32_t length, uint16_t fr_index);
void libusb20_tr_set_priv_sc0(struct libusb20_transfer *xfer, void *sc0);
void libusb20_tr_set_priv_sc1(struct libusb20_transfer *xfer, void *sc1);
More information about the svn-src-all
mailing list