[driver-discuss] Usb driver for bluetooth dongle

Colin Zou Colin.Zou at Sun.COM
Sat Feb 24 01:35:33 PST 2007


Zimmer Sébastien wrote:

> Hi,
> 
> for my master thesis, I have to write a light bluetooth stack whose 
> stream driver has to be written too. So I implemented it and I am almost 
> done (I think :)), but I have some problems left.
> 
> I took a look at the linux source code to understand how I could write 
> the driver and in that implementation, the driver poll the interrupt, 
> bulk and isochronous pipes. I tried to do the same on solaris with no 
> success so far.
>
For how to use solaris usb interfaces, You can refer to other solaris usb client 
driver code in opensolaris.org.

> It's my understanding that the bluetooth protocol doesn't send an event 
> on the interrupt pipe when a data packet arrives on the bulk pipe, 
> that's why I need polling on the bulk pipe.
> 

It is OK to issue a bulk transfer req with timeout value equal to zero, this req 
will then stay there until a data packet arrive. You can refer to the following 
code:
http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/io/usb/clients/usbser/usbser_keyspan/keyspan_pipe.c

	br = usb_alloc_bulk_req(ksp->ks_dip, len, USB_FLAGS_SLEEP);
	br->bulk_len = len;

	/* No timeout, just wait for data */
	br->bulk_timeout = 0;         <<<<<<<<<<<
	br->bulk_client_private = cb_arg;
	br->bulk_attributes = USB_ATTRS_SHORT_XFER_OK | USB_ATTRS_AUTOCLEARING;
...

> The problem is that I fail to setup the polling on the bulk pipe (and 
> isoc pipe) while there is no problem for the intr pipe. I used the same 
> code for both (not the same but close enough).
> 
> The code for the interrupt polling (this is done first):
> intr_req = usb_alloc_intr_req(budp->bud_dip, 0, USB_FLAGS_SLEEP);
> intr_req->intr_client_private = (usb_opaque_t) budp;
> intr_req->intr_attributes = USB_ATTRS_SHORT_XFER_OK | 
> USB_ATTRS_AUTOCLEARING;
> intr_req->intr_len = budp->bud_pipe_states[INTR_IDX].ps_ep.wMaxPacketSize;
> intr_req->intr_cb = bud_poll_intr_pipe_cb;
> intr_req->intr_exc_cb = bud_poll_intr_pipe_exc_cb;
> 
> rval = usb_pipe_intr_xfer(budp->bud_pipe_states[INTR_IDX].ps_ph, 
> intr_req, USB_FLAGS_SLEEP)
> if (rval != USB_SUCCESS) { ...
> 
> The code for the bulk polling (this is done right after the interrupt 
> request):
> bulk_req = usb_alloc_bulk_req(budp->bud_dip, 0, USB_FLAGS_SLEEP);
> bulk_req->bulk_client_private = (usb_opaque_t) budp;
> bulk_req->bulk_attributes = USB_ATTRS_SHORT_XFER_OK | 
> USB_ATTRS_AUTOCLEARING;
> bulk_req->bulk_len = 
> budp->bud_pipe_states[BULK_IN_IDX].ps_ep.wMaxPacketSize;
> bulk_req->bulk_cb = bud_poll_bulk_pipe_cb;
> bulk_req->bulk_exc_cb = bud_poll_bulk_pipe_exc_cb;
> 
> rval = usb_pipe_bulk_xfer(budp->bud_pipe_states[BULK_IN_IDX].ps_ph, 
> bulk_req, USB_FLAGS_SLEEP)
> if (rval != USB_SUCCESS) { ...
> 
> I test the code with a small program whose actions are to open the pipe 
> and do some ioctl. The program blocks on the opening of the pipe until I 
> unplug the device (Ctrl+C doesn't work). In that case the error code in 
> the kernel log is USB_FAILURE.
> 
If your program blocks on pipe open, then it is better to check the pipe open 
code, not the code above. Please also check the manpage of usb_pipe_open.

> If I tried to remove the USB_FLAGS_SLEEP from the xfer function, I have 
> the error: USB_INVALID_REQUEST.
> 
> 
> Do you guys have any ideas why I can't start the polling on the bulk pipe ?
> 
> Thank you very much for any information you can provide me,
> Zimmer Sébastien
> 
> 
> _______________________________________________
> driver-discuss mailing list
> driver-discuss at opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/driver-discuss




More information about the driver-discuss mailing list