Re: snd_uaudio with libusb ?
On 9/29/07, Chuck T. [EMAIL PROTECTED] 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. 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. Xiaofan ___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: snd_uaudio with libusb ?
In message: [EMAIL PROTECTED] Xiaofan Chen [EMAIL PROTECTED] writes: : On 9/29/07, Chuck T. [EMAIL PROTECTED] 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. : : 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. You can only do a subset of the ugen operations with /dev/usb, but maybe it would be enough. I believe that the control messages are on the list of things that you can do, however... Warner ___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
RE: snd_uaudio with libusb ?
On 9/29/07, Chuck T. [EMAIL PROTECTED] 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; } _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
RE: snd_uaudio with libusb ?
On 9/29/07, Chuck T. [EMAIL PROTECTED] 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-ussource=wlmailtagline___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: snd_uaudio with libusb ?
On 9/29/07, Chuck T. [EMAIL PROTECTED] wrote: if(dev != NULL) { if((udev = usb_open(dev)) != NULL) { Ret = 0; } Hmm, you do not set USB configurations. I know this might be good for Linux but this will not work under Windows. Not so sure about FreeBSD. I have tested some codes under Linux/Windows and I will do the tests for FreeBSD. I already tested pk2 and Piklab for PICkit 2 under FreeBSD with the help from people here. I always set configurations and calim interfaces (interrupt transfer for PICKit 2 -- HID device). http://forum.microchip.com/tm.aspx?m=106426 Not so sure about control transfer. I think you do not need to claim the interface. Regards, Xiaofan ___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
snd_uaudio with libusb ?
I have a Linux application that talks to an USB audio dongle that I'm trying to port to FreeBSD. I have no problem with the audio portion, but I'm also trying to use libusb to access the GPIO bits on the chip. If I don't load snd_uaudio /dev/ugen shows up and libusb works fine and I can access the GPIO. However when the sound driver is loaded ugen doesn't bind to the device so libusb can't talk to it. I need simultaneous access to the GPIO and audio functions, either or isn't acceptable. The GPIO bits I need are not supported by HID so that's not an option. Can anyone suggest a solution? Thanks! _ Explore the seven wonders of the world http://search.msn.com/results.aspx?q=7+wonders+worldmkt=en-USform=QBRE___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: snd_uaudio with libusb ?
On 9/29/07, Chuck T. [EMAIL PROTECTED] wrote: I have a Linux application that talks to an USB audio dongle that I'm trying to port to FreeBSD. I have no problem with the audio portion, but I'm also trying to use libusb to access the GPIO bits on the chip. What is the Linux application? How does the Linux work with the audio and GPIO working at the same time? As far as I know, Linux in libusb needs to unbind the kernel driver using the non-portable usb_detach_kernel_driver_np function in order to have access to the usb device --to set the configuration and claim the interface. 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). Ok I am now under FreeBSD and the following is the output from a USB composite device (audio and genric). I have the firmware burnt but I have not built the full USB soundcard. http://home.comcast.net/~armag1234/soundcard.html ===[mcuee] ~/Desktop/build/pyusb-0.4.1/samples # sudo ./usbenum.py Device: /dev/ugen0 Device class: 0 Device sub class: 0 Device protocol: 0 Max packet size: 8 idVendor: 4660 idProduct: 15 Device Version: 00.00 Configuration: 1 Total length: 133 selfPowered: 0 remoteWakeup: 0 maxPower: 200 Interface: 0 Alternate Setting: 0 Interface class: 1 Interface sub class: 1 Interface protocol: 0 Interface: 1 Alternate Setting: 0 Interface class: 1 Interface sub class: 2 Interface protocol: 0 Alternate Setting: 1 Interface class: 1 Interface sub class: 2 Interface protocol: 0 Endpoint: 0x2 Type: 1 Max packet size: 96 Interval: 2 Interface: 2 Alternate Setting: 0 Interface class: 0 Interface sub class: 0 Interface protocol: 0 Endpoint: 0x1 Type: 3 Max packet size: 64 Interval: 1 Endpoint: 0x81 Type: 3 Max packet size: 64 Interval: 1 ===[mcuee] ~ # sudo ls -la /dev/ugen* crw-r--r-- 1 root operator0, 118 Sep 29 09:18 /dev/ugen0 crw-r--r-- 1 root operator0, 117 Sep 29 09:18 /dev/ugen0.1 So it seems that ugen only binds the first interface for this USB composite device. Not so sure if there is a method to bind the other interfaces. I am also not so sure if libusb will work in this case. I am not that experienced with FreeBSD USB. Sorry no real help here. A bit strange that this USB soundcard is not recognized under FreeBSD. I am using an old version of HPS USB stack. Xiaofan http://mcuee.blogspot.com ___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]
RE: snd_uaudio with libusb ?
On 9/29/07, Chuck T. [EMAIL PROTECTED] wrote: I have a Linux application that talks to an USB audio dongle that I'm trying to port to FreeBSD. I have no problem with the audio portion, but I'm also trying to use libusb to access the GPIO bits on the chip. What is the Linux application? How does the Linux work with the audio and GPIO working at the same time? As far as I know, Linux in libusb needs to unbind the kernel driver using the non-portable usb_detach_kernel_driver_np function in order to have access to the usb device --to set the configuration and claim the interface. It's an (as yet unreleased) ham radio VoIP program called thelinkbox. It connects ham radio repeater systems together using the Internet (http:cqinet.sf.net). Eventually it will support multiple radio ports which is the reason for using USB audio dongles rather than audio cards. The GPIO bits are connected to the push to talk (PTT) of the transmitter. Other GPIO bits are used to interface to an DTMF decoder used to send commands to the computer from the radio. 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. Ok I am now under FreeBSD and the following is the output from a USB composite device (audio and genric). I have the firmware burnt but I have not built the full USB soundcard. http://home.comcast.net/~armag1234/soundcard.html ===[mcuee] ~/Desktop/build/pyusb-0.4.1/samples # sudo ./usbenum.py Device: /dev/ugen0 Device class: 0 Device sub class: 0 Device protocol: 0 Max packet size: 8 idVendor: 4660 idProduct: 15 Device Version: 00.00 Configuration: 1 Total length: 133 selfPowered: 0 remoteWakeup: 0 maxPower: 200 Interface: 0 Alternate Setting: 0 Interface class: 1 Interface sub class: 1 Interface protocol: 0 Interface: 1 Alternate Setting: 0 Interface class: 1 Interface sub class: 2 Interface protocol: 0 Alternate Setting: 1 Interface class: 1 Interface sub class: 2 Interface protocol: 0 Endpoint: 0x2 Type: 1 Max packet size: 96 Interval: 2 Interface: 2 Alternate Setting: 0 Interface class: 0 Interface sub class: 0 Interface protocol: 0 Endpoint: 0x1 Type: 3 Max packet size: 64 Interval: 1 Endpoint: 0x81 Type: 3 Max packet size: 64 Interval: 1 ===[mcuee] ~ # sudo ls -la /dev/ugen* crw-r--r-- 1 root operator0, 118 Sep 29 09:18 /dev/ugen0 crw-r--r-- 1 root operator0, 117 Sep 29 09:18 /dev/ugen0.1 So it seems that ugen only binds the first interface for this USB composite device. Not so sure if there is a method to bind the other interfaces. I am also not so sure if libusb will work in this case. I am not that experienced with FreeBSD USB. Sorry no real help here. Thanks for responding anyway! _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE___ freebsd-usb@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-usb To unsubscribe, send any mail to [EMAIL PROTECTED]