Re: USB device with multiple interfaces, sample code anyone?

2006-06-01 Thread M. Warner Losh
In message: <[EMAIL PROTECTED]>
Volker <[EMAIL PROTECTED]> writes:
: Hi hackers,
: 
: I'm trying to correctly implement a driver for an USB device which
: has multiple (serial) interfaces (at least 3). Each interface should
: be seen by the kernel as a tty device entry /dev(/cuaU* or /dev/ttyU*).
: 
: After reading the usb kernel sources I'm not quite sure how to deal
: with that. As the device entry is being created in ucom.c
: (ucom_attach calls ttycreate) I'm not quite sure which code is
: responsible for scanning (enumerating) and correctly attaching to
: the usb device interfaces or if there's just a wrong enumeration
: return code.
: 
: I haven't found any usb code which deals with more than 1 interface
: per usb device (except sound/pcm/uaudio but while doing a quick read
: of that code I do not understand much of uaudio).
: 
: Does any of the hackers have a piece of sample code on how to scan
: usb device interfaces and attach a device file entry (/dev/) to it?
: Or any pseudo-code or graphical explanation on how the usb code is
: actually doing device enumeration?

Either you are going to have to attach multiple ucom devices, or
manage the tty layer yourself.  enumeration is something that's device
specific, but the freebsd side is just adding mutiple devices.  I
think that the ucom stuff right now isn't a 'real' device, so there
might be dragons there.

Warner
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: USB device with multiple interfaces, sample code anyone?

2006-05-30 Thread Bernd Walter
On Mon, May 29, 2006 at 05:01:39PM +0200, Volker wrote:
> Hi hackers,
> 
> I'm trying to correctly implement a driver for an USB device which
> has multiple (serial) interfaces (at least 3). Each interface should
> be seen by the kernel as a tty device entry /dev(/cuaU* or /dev/ttyU*).

You either build a device driver managing the whole device and create
multiple ttys in a single device instance.
uftdi(4) is an example for this, which supports single and twin channel
USB-devices.

Or you build a driver matching a single interface which attaches in
multiple instances.
ubser is a single interface driver, it creates multiple ttys on a
single interface however.
Although real hardware don't exist with multiple interfaces the driver
would allow it.
http://www.bwct.de/modbus/ubmb-0.3.tgz is a very simple interface
level driver which was already used for multiple interfaces.
It attaches once for each device and create a single device for each
instance.  But it is not a tty driver.

> After reading the usb kernel sources I'm not quite sure how to deal
> with that. As the device entry is being created in ucom.c
> (ucom_attach calls ttycreate) I'm not quite sure which code is
> responsible for scanning (enumerating) and correctly attaching to
> the usb device interfaces or if there's just a wrong enumeration
> return code.

This is done in usbd_probe_and_attach().
Forst the whole device is offered and if no driver claims it each
single interface is offered.

> I haven't found any usb code which deals with more than 1 interface
> per usb device (except sound/pcm/uaudio but while doing a quick read
> of that code I do not understand much of uaudio).

Normaly a driver only handles a single instance and attaches multiple
times.

-- 
B.Walterhttp://www.bwct.de  http://www.fizon.de
[EMAIL PROTECTED]   [EMAIL PROTECTED][EMAIL PROTECTED]
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


USB device with multiple interfaces, sample code anyone?

2006-05-29 Thread Volker
Hi hackers,

I'm trying to correctly implement a driver for an USB device which
has multiple (serial) interfaces (at least 3). Each interface should
be seen by the kernel as a tty device entry /dev(/cuaU* or /dev/ttyU*).

After reading the usb kernel sources I'm not quite sure how to deal
with that. As the device entry is being created in ucom.c
(ucom_attach calls ttycreate) I'm not quite sure which code is
responsible for scanning (enumerating) and correctly attaching to
the usb device interfaces or if there's just a wrong enumeration
return code.

I haven't found any usb code which deals with more than 1 interface
per usb device (except sound/pcm/uaudio but while doing a quick read
of that code I do not understand much of uaudio).

Does any of the hackers have a piece of sample code on how to scan
usb device interfaces and attach a device file entry (/dev/) to it?
Or any pseudo-code or graphical explanation on how the usb code is
actually doing device enumeration?

Thanks,

Volker
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"