Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Apr 2010 16:43:19 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        freebsd-usb@freebsd.org
Subject:   Re: Syncronous Interrupt Transfer
Message-ID:  <201004071643.19291.hselasky@c2i.net>
In-Reply-To: <4BBC9172.9010607@telting.org>

index | next in thread | previous in thread | raw e-mail

On Wednesday 07 April 2010 16:06:42 Chris Telting wrote:
> Just learning the USB API.
> 
> Can someone point me to a driver to use as an example of a synchronous
> call?  Do
> I need to use a mutex?

Hi,

Currently only control endpoints have a synchronous API to do requests of any 
size. You can pass NULL for mutex, which basically means no mutex will be 
dropped during sleeping periods.

BULK/INTERRUPT/ISOCHRONOUS are all asynchronous. However, in user-space, 
libusb provides synchronous functions to read and write data.

> I have a device that that does the equivalent of control transfers over
> an interrupt pipe.
> So I need to send data, get status, send more data, get status again,
> and then finally start
> retrieving data; all using interrupt transfers.  Been going over the
> drivers in the kernel
> and they are all looking to be doing async or synchronous back through
> user mode.

Probably we could make some convenience wrappers to do synchronous transfers 
in the kernel. Else you need to make your own condition variable and sleep on 
that until the USB transfer completes or fails.

If you think that a synchronous API for USB in the kernel is generally useful, 
send me a patch and I'll commit it. Most drivers only use synchronous control 
transfers.

--HPS


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004071643.19291.hselasky>