History log of /haiku/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.h
Revision Date Author Comments
# 7b6e6c15 26-Aug-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

FT232x driver: support hardware flow control.

We had everything in place, except we never actually sent the command to
the device.

Note that the other drivers (prolific, etc) as well as pc_serial need to
be updated as well (might do it when I get access to hardware where I
can test the changes).


# 24dba16d 09-May-2013 Jérôme Duval <jerome.duval@gmail.com>

usb_serial: fixes 64 bit warnings


# 5ba5e31f 20-Jul-2012 Alexander von Gluck IV <kallisti5@unixzen.com>

usb_serial: clean up usb device identification

* Update FTDI, KLSI, Prolific, and Silicon drivers to share a
common structural layout for device identification.
* More flexible and cleaner than massive switch case statements.
* Avoids the problem of different chipsets from identical vendors.


# 08c7202f 13-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Add a termios member that stores the config across open/close cycles. This
allows the use of stty to configure the serial device and later using other
commands with these settings still in place.
* Store incoming termios settings when they are set, restore the previous
settings on open and apply the control modes to the device side as well.
* Only send the control to the system side tty cookie again. Doing it for both
cookies was only done to configure the termios, which isn't necessary anymore.
* Remove fallbacks to c_{i|o}speed fields and always use c_cflag & CBAUD for the
single speed setting we have.
* Remove some leftover control line state logic that doesn't apply anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42161 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77a5d93e 13-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Remove the output thread again and write to the device in the write call. To
ensure that we don't block on the tty buffer, we chop up the data into blocks
that are written into the tty and then the buffer is flushed to the device
each time. This resolves the issue that a quick open/write/close would not
actually send the data to the device as it would cancel the transfer before
the output thread had a chance to run.
* Use the tty_close_cookie() call. Doing the close before waiting for the input
thread ensures that it is woken up if it blocked on writing into the tty.
* Correct the type of the USB callback status and only try to clear a halt if
the device was actually stalled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42156 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 36986acb 10-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Finish the port to the new tty module. Back when I left off last time it was
only halfway finished. The way it is supposed to work is that there are two
tty cookies, representing the system and the device side. Reads and writes
coming from the system and going to the device are using the system cookie
while reads and writes coming from the device use the device cookie.
* Move writing to the device into an output thread, similar to how reading from
the device works. This isn't necessarily a good idea and might be moved back
into the write hook again to ensure that writes can be made blocking. Right
now if you just write and then close, the writes will most likely be canceled
before every going out to the device.
* Removed the read and write lock mutex. They aren't necessary as the tty layer
will serialize the reads and writes anyway.
* Made simply copying the data to the write buffer the default implementation of
the OnWrite callback and removed the OnWrite in ACMDevice. The ProlificDevice
didn't provide an OnWrite hook before, so it would've never written anything.
* Break out the baud index to speed mapping into an inline function. Since the
defines might change in termios.h just adding an array is a bit fragile (it
already missed one entry and would've been broken for certain speeds).

This should make usb_serial usable for some (most?) cases. I've tested this with
an Arduino board that uses an FTDI interface. As mentioned above, since writes
currently just write into the tty layer and don't wait for the data to be
flushed, and since close doesn't wait for the output buffers to be drained
either, a simple write and close (as in "echo a > /dev/ports/usb0") will in most
cases cancel the output before it is written to the device. I'm looking into
a few ways to fix that next.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42089 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c5f2df28 03-Jan-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

Switched to use USB_cdc.h definitions.
Expanded search in every configuration, not only first. ELSA USB modem for instance
publish two configurations, the first one being a vendor-specific one for
Windows NT.
ACMDevice now don't assume anymore union functional descriptor is always there.
The data interface index can be found also in Call Management (CM) functional
descriptor.

(Style cleanup pending...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40092 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b994a185 07-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Port of usb_serial to the generic tty module. I don't remember exactly if or how
well this was working, but since it was non-functional on Haiku anyway this
shouldn't hurt.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39762 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 12f32926 12-Jun-2008 François Revol <revol@free.fr>

- change KLSI init the way it's done by the linux driver
- do not count usb headers as part of count returned by write(), else we might end up writing more than the passed amount :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25939 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b07b8e0 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25690 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dbcfdd5c 11-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Correct the way serial devices are deleted. They are either deleted on removal
when they are not open or they are deleted on free when they are already
removed. This should fix the sudden crashes when you unplugged a device that
might not have been fully closed yet.
Also handle the case of removal correctly and don't use the usb_device anymore
after releasing it by returning from the device removed hook. Calls to the
device just return B_DEV_NOT_READY in that case.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24920 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7aa661d4 19-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Rework of the usb_serial driver:
* Refactored everything to C++ with the different devices as subclasses
* Added proper ACM detection with parsing of the ACM descriptors
* Added device transfer error handling and fixed some concurency issues
* Big cleanup to conform to our style guide

This should make at least ACM stable to use. Commiting this over my K850i with
ACM compliant USB modem and UMTS data connection. Note that support for all
other device classes (Prolific, FTDI and KLSI) is untested but should work the
same as before. Note also that since we currently lack a TTY module this will
only build/work for R5 or Dano with the proper TTY headers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23634 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 24dba16d04b9acd835871de8f9066c8874948e54 09-May-2013 Jérôme Duval <jerome.duval@gmail.com>

usb_serial: fixes 64 bit warnings


# 5ba5e31f8a59cb5f3299edd7af256d0fb4db12aa 20-Jul-2012 Alexander von Gluck IV <kallisti5@unixzen.com>

usb_serial: clean up usb device identification

* Update FTDI, KLSI, Prolific, and Silicon drivers to share a
common structural layout for device identification.
* More flexible and cleaner than massive switch case statements.
* Avoids the problem of different chipsets from identical vendors.


# 08c7202f8a3977afe560df956f83ea29e1398607 13-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Add a termios member that stores the config across open/close cycles. This
allows the use of stty to configure the serial device and later using other
commands with these settings still in place.
* Store incoming termios settings when they are set, restore the previous
settings on open and apply the control modes to the device side as well.
* Only send the control to the system side tty cookie again. Doing it for both
cookies was only done to configure the termios, which isn't necessary anymore.
* Remove fallbacks to c_{i|o}speed fields and always use c_cflag & CBAUD for the
single speed setting we have.
* Remove some leftover control line state logic that doesn't apply anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42161 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 77a5d93e961506b3f89b6821210992e1b24a947e 13-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Remove the output thread again and write to the device in the write call. To
ensure that we don't block on the tty buffer, we chop up the data into blocks
that are written into the tty and then the buffer is flushed to the device
each time. This resolves the issue that a quick open/write/close would not
actually send the data to the device as it would cancel the transfer before
the output thread had a chance to run.
* Use the tty_close_cookie() call. Doing the close before waiting for the input
thread ensures that it is woken up if it blocked on writing into the tty.
* Correct the type of the USB callback status and only try to clear a halt if
the device was actually stalled.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42156 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 36986acbbd67c4866976aeb4a6a3e98d953b69c3 10-Jun-2011 Michael Lotz <mmlr@mlotz.ch>

* Finish the port to the new tty module. Back when I left off last time it was
only halfway finished. The way it is supposed to work is that there are two
tty cookies, representing the system and the device side. Reads and writes
coming from the system and going to the device are using the system cookie
while reads and writes coming from the device use the device cookie.
* Move writing to the device into an output thread, similar to how reading from
the device works. This isn't necessarily a good idea and might be moved back
into the write hook again to ensure that writes can be made blocking. Right
now if you just write and then close, the writes will most likely be canceled
before every going out to the device.
* Removed the read and write lock mutex. They aren't necessary as the tty layer
will serialize the reads and writes anyway.
* Made simply copying the data to the write buffer the default implementation of
the OnWrite callback and removed the OnWrite in ACMDevice. The ProlificDevice
didn't provide an OnWrite hook before, so it would've never written anything.
* Break out the baud index to speed mapping into an inline function. Since the
defines might change in termios.h just adding an array is a bit fragile (it
already missed one entry and would've been broken for certain speeds).

This should make usb_serial usable for some (most?) cases. I've tested this with
an Arduino board that uses an FTDI interface. As mentioned above, since writes
currently just write into the tty layer and don't wait for the data to be
flushed, and since close doesn't wait for the output buffers to be drained
either, a simple write and close (as in "echo a > /dev/ports/usb0") will in most
cases cancel the output before it is written to the device. I'm looking into
a few ways to fix that next.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42089 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c5f2df286e21f263432f1deb39b6ccf6a6ff32c0 03-Jan-2011 Philippe Houdoin <philippe.houdoin@gmail.com>

Switched to use USB_cdc.h definitions.
Expanded search in every configuration, not only first. ELSA USB modem for instance
publish two configurations, the first one being a vendor-specific one for
Windows NT.
ACMDevice now don't assume anymore union functional descriptor is always there.
The data interface index can be found also in Call Management (CM) functional
descriptor.

(Style cleanup pending...)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40092 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b994a185080e8f2706d5a153496070f7fe7b4d7e 07-Dec-2010 Michael Lotz <mmlr@mlotz.ch>

Port of usb_serial to the generic tty module. I don't remember exactly if or how
well this was working, but since it was non-functional on Haiku anyway this
shouldn't hurt.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39762 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 12f329261557cff6c769a4cb0c23fe8a55bb2622 12-Jun-2008 François Revol <revol@free.fr>

- change KLSI init the way it's done by the linux driver
- do not count usb headers as part of count returned by write(), else we might end up writing more than the passed amount :)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25939 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2b07b8e0f1a7f1e76f31db24a21a42cbb01d7b9c 28-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Replaced all instances of benaphores in the kernel code by mutexes.
* Removed kernel benaphores.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25690 a95241bf-73f2-0310-859d-f6bbb57e9c96


# dbcfdd5ca72fcd9910b65a9061df902f78b2b3d6 11-Apr-2008 Michael Lotz <mmlr@mlotz.ch>

Correct the way serial devices are deleted. They are either deleted on removal
when they are not open or they are deleted on free when they are already
removed. This should fix the sudden crashes when you unplugged a device that
might not have been fully closed yet.
Also handle the case of removal correctly and don't use the usb_device anymore
after releasing it by returning from the device removed hook. Calls to the
device just return B_DEV_NOT_READY in that case.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24920 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7aa661d403eac10eab21bcd0facf01c2bcc03c24 19-Jan-2008 Michael Lotz <mmlr@mlotz.ch>

Rework of the usb_serial driver:
* Refactored everything to C++ with the different devices as subclasses
* Added proper ACM detection with parsing of the ACM descriptors
* Added device transfer error handling and fixed some concurency issues
* Big cleanup to conform to our style guide

This should make at least ACM stable to use. Commiting this over my K850i with
ACM compliant USB modem and UMTS data connection. Note that support for all
other device classes (Prolific, FTDI and KLSI) is untested but should work the
same as before. Note also that since we currently lack a TTY module this will
only build/work for R5 or Dano with the proper TTY headers.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23634 a95241bf-73f2-0310-859d-f6bbb57e9c96