This patch changes isdv4Query to just execute the query passed in and do some additional sanity checking. If it fails, return the failure to the caller isdv4GetRanges().
isdv4GetRanges() can then change the baud rate and re-query if required. If the query at 19200 succeeds, skip the touch query. All touch devices have 38400. Signed-off-by: Peter Hutterer <[email protected]> --- src/wcmISDV4.c | 52 +++++++++++++++++++++------------------------------- 1 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c index 666f89d..ff129e5 100644 --- a/src/wcmISDV4.c +++ b/src/wcmISDV4.c @@ -269,9 +269,9 @@ static Bool isdv4Init(LocalDevicePtr local, char* id, float *version) static int isdv4Query(LocalDevicePtr local, const char* query, char* data) { +#ifdef DEBUG WacomDevicePtr priv = (WacomDevicePtr)local->private; - WacomCommonPtr common = priv->common; - wcmISDV4Data *isdv4data = common->private; +#endif DBG(1, priv, "Querying ISDV4 tablet\n"); @@ -284,37 +284,15 @@ static int isdv4Query(LocalDevicePtr local, const char* query, char* data) /* Read the control data */ if (!wcmWaitForTablet(local, data, ISDV4_PKGLEN_TPCCTL)) - { - /* Try 19200 if it is not a touch query */ - if (isdv4data->baudrate != 19200 && strcmp(query, ISDV4_TOUCH_QUERY)) - { - isdv4data->baudrate = 19200; - if (xf86SetSerialSpeed(local->fd, isdv4data->baudrate) < 0) - return !Success; - return isdv4Query(local, query, data); - } - else - return !Success; - } + return !Success; /* Control data bit check */ if ( !(data[0] & 0x40) ) { - /* Try 19200 if it is not a touch query */ - if (isdv4data->baudrate != 19200 && strcmp(query, ISDV4_TOUCH_QUERY)) - { - isdv4data->baudrate = 19200; - if (xf86SetSerialSpeed(local->fd, isdv4data->baudrate) < 0) - return !Success; - return isdv4Query(local, query, data); - } - else - { - /* Reread the control data since it may fail the first time */ - wcmWaitForTablet(local, data, ISDV4_PKGLEN_TPCCTL); - if ( !(data[0] & 0x40) ) - return !Success; - } + /* Reread the control data since it may fail the first time */ + wcmWaitForTablet(local, data, ISDV4_PKGLEN_TPCCTL); + if ( !(data[0] & 0x40) ) + return !Success; } return Success; @@ -359,6 +337,18 @@ static int isdv4GetRanges(LocalDevicePtr local) /* Send query command to the tablet */ ret = isdv4Query(local, ISDV4_QUERY, data); + if (ret != Success && isdv4data->baudrate != 19200) + { + /* device may be 19200 */ + if (xf86SetSerialSpeed(local->fd, 19200) < 0) + return !Success; + ret = isdv4Query(local, ISDV4_QUERY, data); + + if (ret == Success) + isdv4data->baudrate = 19200; + + } + if (ret == Success) { ISDV4QueryReply reply; @@ -401,8 +391,8 @@ static int isdv4GetRanges(LocalDevicePtr local) } /* Touch might be supported. Send a touch query command */ - isdv4data->baudrate = 38400; - if (isdv4Query(local, ISDV4_TOUCH_QUERY, data) == Success) + if (isdv4data->baudrate == 38400 && + isdv4Query(local, ISDV4_TOUCH_QUERY, data) == Success) { ISDV4TouchQueryReply reply; int rc; -- 1.7.1 ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
