snd_uaudio with libusb ?
Chuck T.
freebsdfan at hotmail.com
Sat Sep 29 07:42:16 PDT 2007
> On 9/29/07, Chuck T. <freebsdfan at hotmail.com> wrote:
> >
> > >I think your device is a USB composite USB device with two
> > >interfaces (one for USB audio and the other for GPIO). How
> > >do you control the GPIO under Linux (by control transfer
> > >or interrupt/bulk transfer)? If the Linux application indeed
> > >works at the same time as the USB audio, then Linux
> > >does bind different driver to different interfaces (one for
> > >the usb audio interface and no driver for the GPIO interface).
> >
> > I talk to the GPIO bits via vendor specific requests to the control pipe.
> > I do a usb_open() when my application loads and never close it. When I need
> > to set a GPIO bit I use usb_control_msg(). I've never "looked under the
> > covers" to see why it works, but it does.
> >
>
> So this works under Linux but not FreeBSD. Maybe this is just a limitation
> of libusb under FreeBSD. Anyway, it is said that libusb is just a thin
> wrapper on top of USB. You may want to use the lower level api instead.
Yes I believe that is the case. I'm hoping there is a simple fix that will allow
me to use libusb for OS portability. I don't want to have to write OS specific
code if I can avoid it. I've been using FreeBSD since the 1.0 and I really
want my app to run on FreeBSD but frankly 90% of the users will probably
be running on Linux anyway.
> I confess I do not know further (like how to bind ugen to individual interfaces
> and use IOCTL to perform usb transfer). But if post some codes,
> others may be able to help you.
Sure. I doubt it will help as the problem is related to libusb but here's my code:
static usb_dev_handle *udev = NULL;
void UsbKeyRadio(int bKey)
{
int ret;
char Buf[2] = {0xff,0xff};
if(bKey) {
// Set PTT bit low
Buf[0] = 0;
}
else {
// Set PTT bit high
Buf[0] = 0x20;
}
ret = usb_control_msg(udev,USB_TYPE_VENDOR,WRITE_GPIO,0,0,Buf,2,1000);
if(ret != 2) {
LOG_ERROR(("%s#%d: usb_control_msg returned %d (%s)\n",__FUNCTION__,
__LINE__,ret,Err2String(errno)));
}
}
int UsbInit(void)
{
struct usb_bus *bus;
struct usb_device *dev = NULL;
int Ret = ERR_USB_DEV_OPEN; // assume the worse
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus && dev == NULL; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next) {
if(dev->descriptor.idVendor == 0x074d &&
dev->descriptor.idProduct == 0x3556)
{
break;
}
else if(dev->descriptor.idVendor == 0x077d &&
dev->descriptor.idProduct == 0x07af)
{
break;
}
}
}
if(dev != NULL) {
if((udev = usb_open(dev)) != NULL) {
Ret = 0;
}
}
else {
LOG_ERROR(("%s: USB device not found\n",__FUNCTION__));
}
return Ret;
}
_________________________________________________________________
Connect to the next generation of MSN Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
More information about the freebsd-usb
mailing list