aboutsummaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-01-14 03:41:02 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-01-14 03:41:02 +0000
commita795421883395256c09e48829898bb3875866f30 (patch)
tree9c62cef3791320e4f9e1d0d1986051ebd9f1ed5f /vl.c
parentfd56059fb612090f5fab049d44e39760ac8fe523 (diff)
USB-to-serial device (Samuel Thibault).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3914 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/vl.c b/vl.c
index fc6fbf9a60..4875519df7 100644
--- a/vl.c
+++ b/vl.c
@@ -2240,45 +2240,33 @@ static void tty_serial_init(int fd, int speed,
#endif
tcgetattr (fd, &tty);
- switch(speed) {
- case 50:
+#define MARGIN 1.1
+ if (speed <= 50 * MARGIN)
spd = B50;
- break;
- case 75:
+ else if (speed <= 75 * MARGIN)
spd = B75;
- break;
- case 300:
+ else if (speed <= 300 * MARGIN)
spd = B300;
- break;
- case 600:
+ else if (speed <= 600 * MARGIN)
spd = B600;
- break;
- case 1200:
+ else if (speed <= 1200 * MARGIN)
spd = B1200;
- break;
- case 2400:
+ else if (speed <= 2400 * MARGIN)
spd = B2400;
- break;
- case 4800:
+ else if (speed <= 4800 * MARGIN)
spd = B4800;
- break;
- case 9600:
+ else if (speed <= 9600 * MARGIN)
spd = B9600;
- break;
- case 19200:
+ else if (speed <= 19200 * MARGIN)
spd = B19200;
- break;
- case 38400:
+ else if (speed <= 38400 * MARGIN)
spd = B38400;
- break;
- case 57600:
+ else if (speed <= 57600 * MARGIN)
spd = B57600;
- break;
- default:
- case 115200:
+ else if (speed <= 115200 * MARGIN)
+ spd = B115200;
+ else
spd = B115200;
- break;
- }
cfsetispeed(&tty, spd);
cfsetospeed(&tty, spd);
@@ -5223,6 +5211,8 @@ static int usb_device_add(const char *devname)
dev = usb_msd_init(p);
} else if (!strcmp(devname, "wacom-tablet")) {
dev = usb_wacom_init();
+ } else if (strstart(devname, "serial:", &p)) {
+ dev = usb_serial_init(p);
} else {
return -1;
}