Skip to content

Instantly share code, notes, and snippets.

@heftig
Created July 20, 2010 00:02
Show Gist options
  • Save heftig/482239 to your computer and use it in GitHub Desktop.
Save heftig/482239 to your computer and use it in GitHub Desktop.
commit b3d0b8e94f9eeceaddfe88d2730c5e4ee31d3a62
Author: Jan Steffens <jan.steffens@gmail.com>
Date: Tue Jul 20 01:23:35 2010
Make 19200 the default baud rate for 0x90 TPCs
diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c
index ea33c18..de18e77 100644
--- a/src/wcmISDV4.c
+++ b/src/wcmISDV4.c
@@ -206,12 +206,17 @@ static Bool isdv4ParseOptions(LocalDevicePtr local)
wcmISDV4Data *isdv4data;
int baud;
- baud = xf86SetIntOption(local->options, "BaudRate", 38400);
+ /* Determine default baud rate */
+ baud = (common->tablet_id == 0x90)? 19200 : 38400;
+
+ baud = xf86SetIntOption(local->options, "BaudRate", baud);
switch (baud)
{
case 38400:
case 19200:
+ /* xf86OpenSerial() takes the baud rate from the options */
+ xf86ReplaceIntOption(local->options, "BaudRate", baud);
break;
default:
xf86Msg(X_ERROR, "%s: Illegal speed value "
@@ -248,7 +253,7 @@ static Bool isdv4Init(LocalDevicePtr local, char* id, float *version)
DBG(1, priv, "initializing ISDV4 tablet\n");
- /* Initial baudrate is 38400 */
+ /* Set baudrate */
if (xf86SetSerialSpeed(local->fd, isdv4data->baudrate) < 0)
return !Success;
@@ -335,19 +340,31 @@ static int isdv4GetRanges(LocalDevicePtr local)
if (isdv4data->initialized++)
return ret;
+ /* Set baudrate to default */
+ if (xf86SetSerialSpeed(local->fd, isdv4data->baudrate) < 0)
+ return !Success;
+
/* Send query command to the tablet */
ret = isdv4Query(local, ISDV4_QUERY, data);
- if (ret != Success && isdv4data->baudrate != 19200)
+ if (ret != Success)
{
- /* device may be 19200 */
- if (xf86SetSerialSpeed(local->fd, 19200) < 0)
+ int baud;
+
+ /* Try with the other baudrate */
+ baud = (isdv4data->baudrate == 38400)? 19200 : 38400;
+
+ xf86Msg(X_WARNING, "%s: Query failed with %d baud. Trying %d.\n",
+ local->name, isdv4data->baudrate, baud);
+
+ if (xf86SetSerialSpeed(local->fd, baud) < 0)
return !Success;
+
ret = isdv4Query(local, ISDV4_QUERY, data);
if (ret == Success) {
- isdv4data->baudrate = 19200;
+ isdv4data->baudrate = baud;
/* xf86OpenSerial() takes the baud rate from the options */
- xf86ReplaceIntOption(local->options, "BaudRate", 19200);
+ xf86ReplaceIntOption(local->options, "BaudRate", baud);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment