From owner-freebsd-usb@FreeBSD.ORG Sat Sep 29 14:42:16 2007 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4674816A4C5 for ; Sat, 29 Sep 2007 14:42:16 +0000 (UTC) (envelope-from freebsdfan@hotmail.com) Received: from bay0-omc1-s10.bay0.hotmail.com (bay0-omc1-s10.bay0.hotmail.com [65.54.246.82]) by mx1.freebsd.org (Postfix) with ESMTP id 2CBD313C447 for ; Sat, 29 Sep 2007 14:42:16 +0000 (UTC) (envelope-from freebsdfan@hotmail.com) Received: from BAY116-W36 ([64.4.38.136]) by bay0-omc1-s10.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 29 Sep 2007 07:42:16 -0700 Message-ID: X-Originating-IP: [68.225.241.11] From: Chuck T. To: Xiaofan Chen Date: Sat, 29 Sep 2007 07:42:16 -0700 Importance: Normal In-Reply-To: References: MIME-Version: 1.0 X-OriginalArrivalTime: 29 Sep 2007 14:42:16.0290 (UTC) FILETIME=[EE1F1420:01C802A6] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-usb@freebsd.org Subject: RE: snd_uaudio with libusb ? X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Sep 2007 14:42:16 -0000 > On 9/29/07, Chuck T. 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 pip= e. > > 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 th= e > > covers" to see why it works, but it does. > > >=20 > So this works under Linux but not FreeBSD. Maybe this is just a limitatio= n > 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 spec= ific 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 inte= rfaces > 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 =3D NULL; void UsbKeyRadio(int bKey) { int ret; char Buf[2] =3D {0xff,0xff}; if(bKey) { // Set PTT bit low Buf[0] =3D 0; } else { // Set PTT bit high Buf[0] =3D 0x20; } ret =3D usb_control_msg(udev,USB_TYPE_VENDOR,WRITE_GPIO,0,0,Buf,2,1000); if(ret !=3D 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 =3D NULL; int Ret =3D ERR_USB_DEV_OPEN; // assume the worse usb_init(); usb_find_busses(); usb_find_devices(); for (bus =3D usb_busses; bus && dev =3D=3D NULL; bus =3D bus->next) { for (dev =3D bus->devices; dev; dev =3D dev->next) { if(dev->descriptor.idVendor =3D=3D 0x074d &&=20 dev->descriptor.idProduct =3D=3D 0x3556) { break; } else if(dev->descriptor.idVendor =3D=3D 0x077d &&=20 dev->descriptor.idProduct =3D=3D 0x07af) { break; } } } if(dev !=3D NULL) { if((udev =3D usb_open(dev)) !=3D NULL) { Ret =3D 0; } } else { LOG_ERROR(("%s: USB device not found\n",__FUNCTION__)); } return Ret; } _________________________________________________________________ Connect to the next generation of MSN Messenger=A0 http://imagine-msn.com/messenger/launch80/default.aspx?locale=3Den-us&sourc= e=3Dwlmailtagline=