Sending data packets to USB bulk endpoint

John-Mark Gurney jmg at funkthat.com
Thu Mar 26 00:24:06 UTC 2020


Wall, Stephen wrote this message on Wed, Mar 25, 2020 at 01:53 +0000:
> I posted this on the FreeBSD Drivers forum, got no response, so I'm trying here.
> 
> I am working on a driver to support a Silicon Labs I2S to USB bridge. Besides the audio portion, the chip supports a bulk endpoint which uses a documented packet format to read & control 16 GPIO pins, and to pass messages to & from an I2C bus. I have not previously worked with USB, or FreeBSD drivers. I'm been handed a partially complete codebase - the audio stream works - and I'm trying to get the GPIO controls working. My intent is to use ioctl() calls to read and set the pins.
> 
> Creating an entry in /dev and the associated character device structure for the GPIO control is pretty straightforward. Where I'm getting stuck is trying to figure out how to get the messages I am creating in the driver down to the bulk endpoint - the USB driver code is a bit overwhelming to a newcomer, and I can't seem to find a function that fits "send this block of data to this endpoint". The only way I've seen for interacting with bulk endpoints is to write a driver based on usb_fifo_methods rather than cdevsw (per "FreeBSD Device Drivers", chapter 15), which does not seem to fit what I'm trying to do.
> 
> I would appreciate any pointers experienced driver developers could give me to get where I'm trying to go with this - either the name of the function I'm looking for, or some other was to get that functionality.

Is there a specific reason you want a native kernel driver instead of
using something like libusb + cuse4bsd?

Also, have you looked at usbdi(9)?  It looks like it contains the
information on how to setup a transfer w/ the buffer, and use that.

https://www.freebsd.org/cgi/man.cgi?query=usbdi&manpath=FreeBSD+12.1-RELEASE+and+Ports

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-drivers mailing list