UDEV is being used to obtain the path to the model-id file in the sys filesystem, but as this is available via /sys/dev/char/<major>:<minor> the UDEV code can be pretty much replaced by a single line sprintf. Autoconf has been modified to allow --enable-udev to be passed to configure (default is to use UDEV if it's available).
Signed-off-by: Colum Paget <colum.pa...@googlemail.com> --- configure.ac | 15 +++++++++++--- src/wcmISDV4.c | 44 ++++++++++++++++++++++++++++++++++++++++ tools/isdv4-serial-inputattach.c | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 669d88e..9208ac6 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([xf86-input-wacom], - [0.32.0], + [0.32.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xf86-input-wacom]) AC_CONFIG_MACRO_DIR([m4]) @@ -32,7 +32,7 @@ AC_CONFIG_HEADERS([config.h]) # Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip]) -AM_MAINTAINER_MODE([enable]) +AM_MAINTAINER_MODE([disable]) AC_USE_SYSTEM_EXTENSIONS # Initialize libtool @@ -57,8 +57,16 @@ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.7.0] $XPROTOS) # Obtain compiler/linker options for the xsetwacom tool PKG_CHECK_MODULES(X11, x11 xi xrandr xinerama $XPROTOS) + +AC_ARG_ENABLE(udev, + AS_HELP_STRING([--enable-udev],[use udev (default=auto)]),[USE_UDEV=$enableval], [USE_UDEV=auto]) + + +if test "$USE_UDEV" != "no" +then # Obtain compiler/linker options for libudev used by ISDV4 code -PKG_CHECK_MODULES(UDEV, libudev) +PKG_CHECK_MODULES([UDEV], [libudev], [AC_DEFINE(HAVE_UDEV)], [AC_DEFINE(NO_UDEV)]) +fi # X Server SDK location is required to install wacom header files # This location is also relayed in the xorg-wacom.pc file @@ -162,6 +170,7 @@ SYSTEMD_UNIT_DIR=${unitdir} AC_SUBST(SYSTEMD_UNIT_DIR) AM_CONDITIONAL(HAVE_SYSTEMD_UNIT_DIR, [test "x$SYSTEMD_UNIT_DIR" != "xno"]) + AC_ARG_WITH(udev-rules-dir, AS_HELP_STRING([--with-udev-rules-dir=DIR], [Directory where udev expects its rules files diff --git a/src/wcmISDV4.c b/src/wcmISDV4.c index 95001a1..2cbf65b 100644 --- a/src/wcmISDV4.c +++ b/src/wcmISDV4.c @@ -28,7 +28,9 @@ #include "isdv4.h" #include <unistd.h> #include <fcntl.h> +#ifdef HAVE_UDEV #include <libudev.h> +#endif #include <sys/types.h> #include <sys/stat.h> @@ -975,6 +977,8 @@ static Bool get_keys_vendor_tablet_id(char *name, WacomCommonPtr common) * @param buf[out] preallocated buffer to return the result in. * @param buf_size: size of preallocated buffer */ + +#ifdef HAVE_UDEV static Bool get_sysfs_id(InputInfoPtr pInfo, char *buf, int buf_size) { WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; @@ -1017,6 +1021,46 @@ out: return ret; } +#else +//Alternative for systems lacking udev +static Bool get_sysfs_id(InputInfoPtr pInfo, char *buf, int buf_size) +{ + WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; + struct stat st; + char *sysfs_path = NULL; + FILE *file = NULL; + Bool ret = FALSE; + int bytes_read; + + // Stat the file descriptor to get st_rdev, which holds major/minor + //device numbers. Use this to look up device id (identifies model) + // /sys/dev/<major>:<minor> + + if (fstat(pInfo->fd, &st) > -1) + { + asprintf(&sysfs_path,"/sys/dev/%d:%d/device/id",major(st.st_rdev), minor(st.st_rdev)); + + DBG(8, priv, "sysfs path: %s\n", sysfs_path); + + file = fopen(sysfs_path, "r"); + if (file) + { + bytes_read = fread(buf, 1, buf_size - 1, file); + if (bytes_read > 0) + { + buf[bytes_read] = '\0'; + ret = TRUE; + } + fclose(file); + } + } + + free(sysfs_path); + + return ret; +} +#endif + /** * Query the device's fd for the key bits and the tablet ID. Returns the ID diff --git a/tools/isdv4-serial-inputattach.c b/tools/isdv4-serial-inputattach.c index 711f6ed..7a55b79 100644 --- a/tools/isdv4-serial-inputattach.c +++ b/tools/isdv4-serial-inputattach.c @@ -23,7 +23,9 @@ #endif #include <linux/serio.h> +#ifdef HAVE_UDEV #include <libudev.h> +#endif #include <getopt.h> #include <stdio.h> @@ -80,6 +82,7 @@ static int bind_kernel_driver(int fd) return 0; } +#ifdef HAVE_UDEV static unsigned int get_baud_rate(int fd) { struct stat st; @@ -116,6 +119,42 @@ static unsigned int get_baud_rate(int fd) return baudrate; } +#else +//Alternative for systems lacking udev +static unsigned int get_baud_rate(int fd) +{ + struct stat st; + unsigned int baudrate = 19200; + int id, bytes_read; + char *sysfs_path=NULL, *buf=NULL; + FILE *file; + + if (fstat(fd, &st) == -1) return 0; + asprintf(&sysfs_path,"/sys/dev/%d:%d/device/id",major(st.st_rdev), minor(st.st_rdev)); + + file = fopen(sysfs_path, "r"); + if (file) + { + buf=calloc(256, sizeof(char)); + bytes_read = fread(buf, 1, 255, file); + if (bytes_read > 0) + { + /* Devices up to WACf007 are 19200, newer devices are 38400. FUJ + devices are all 19200 */ + if (strncmp(buf, "WACf", 4) == 0) + { + if (strtol(buf+4,NULL,10) > 7) baudrate = 38400; + } + } + fclose(file); + } + + free(sysfs_path); + free(buf); + return baudrate; +} +#endif + static void sighandler(int signum) { -- 1.9.rc0 ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140 _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel