diff options
author | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2020-10-27 15:04:55 +0000 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-11-04 07:22:37 +0100 |
commit | a79f86cdbe9ccd5c3be76a9c6288d07a7716cb12 (patch) | |
tree | b41a495fd92c98794d31772a2e9ba248fcda59b3 /hw/usb/dev-serial.c | |
parent | 66007a95674d4b8e616245541faad6cdf5e9f70d (diff) |
dev-serial: add support for setting data_bits in QEMUSerialSetParams
Also implement the behaviour reported in Linux's ftdi_sio.c whereby if an invalid
data_bits value is provided then the hardware defaults to using 8.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20201027150456.24606-8-mark.cave-ayland@ilande.co.uk
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb/dev-serial.c')
-rw-r--r-- | hw/usb/dev-serial.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index b9e308dca1..e42ce36295 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -308,6 +308,23 @@ static void usb_serial_handle_control(USBDevice *dev, USBPacket *p, break; } case VendorDeviceOutRequest | FTDI_SET_DATA: + switch (value & 0xff) { + case 7: + s->params.data_bits = 7; + break; + case 8: + s->params.data_bits = 8; + break; + default: + /* + * According to a comment in Linux's ftdi_sio.c original FTDI + * chips fall back to 8 data bits for unsupported data_bits + */ + trace_usb_serial_unsupported_data_bits(bus->busnr, dev->addr, + value & 0xff); + s->params.data_bits = 8; + } + switch (value & FTDI_PARITY) { case 0: s->params.parity = 'N'; |