Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Aug 2013 06:04:54 GMT
From:      Anton Afanasyev <aasoft@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/181133: [patch] enabled support of wacom tablets connected via a serial port
Message-ID:  <201308080604.r7864sZA046329@oldred.freebsd.org>
Resent-Message-ID: <201308080610.r786A00x083380@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         181133
>Category:       ports
>Synopsis:       [patch] enabled support of wacom tablets connected via a serial port
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 08 06:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Anton Afanasyev
>Release:        FreeBSD 9.2-BETA2 r253720 amd64
>Organization:
>Environment:
FreeBSD MACIHNENAMEHERE 9.2-BETA2 FreeBSD 9.2-BETA2 #0 r253720: Sat Jul 27 16:50:40 PDT 2013 root@worldmaker:/usr/obj/usr/src/sys/KERNNAMEHERE amd64
>Description:
The current version of the port did not include support for serial (ISDV4) tablets, such as the ones built into Thinkpad x200 and the like. The original code does support them, so after removing several linuxisms they work on FreeBSd too.
Additionally, the isdv4-serial-debugger application is now built and installed into the system (again, it was disabled in the current version of the port because of linuxisms).

NOTE: This patch can easily be applied on top of ports/175876 once that is committed.
Also note that I haven't tried updating to a newer version of xf86-input-wacom (0.22.1 at the time of writing) since there are quite a few makefile changes, and I am not well-versed in makefiles.
>How-To-Repeat:
Try building the current version of the port and find that X server does not detect a serial wacom table (provided you have one).

Then do:

$ cd ports/x11-drivers/input-wacom
$ svn patch --strip 1 /path/to/input-wacom-serial.diff

And then the tablet should be detected by X.
>Fix:


Patch attached with submission follows:

Index: files/patch-src-Makefile.in
===================================================================
--- files/patch-src-Makefile.in	(revision 324375)
+++ files/patch-src-Makefile.in	(working copy)
@@ -1,40 +0,0 @@
---- src/Makefile.in.orig
-+++ src/Makefile.in
-@@ -97,7 +97,7 @@ am__base_list = \
- am__installdirs = "$(DESTDIR)$(@DRIVER_NAME@_drv_ladir)"
- LTLIBRARIES = $(@DRIVER_NAME@_drv_la_LTLIBRARIES)
- @DRIVER_NAME@_drv_la_LIBADD =
--am__objects_1 = xf86Wacom.lo wcmCommon.lo wcmConfig.lo wcmISDV4.lo \
-+am__objects_1 = xf86Wacom.lo wcmCommon.lo wcmConfig.lo \
- 	wcmFilter.lo wcmUSB.lo wcmXCommand.lo wcmValidateDevice.lo \
- 	wcmTouchFilter.lo
- am_@DRIVER_NAME@_drv_la_OBJECTS = $(am__objects_1)
-@@ -291,7 +291,6 @@ DRIVER_SOURCES = \
- 	$(top_srcdir)/src/xf86Wacom.h \
- 	$(top_srcdir)/src/wcmCommon.c \
- 	$(top_srcdir)/src/wcmConfig.c \
--	$(top_srcdir)/src/wcmISDV4.c \
- 	$(top_srcdir)/src/wcmFilter.c \
- 	$(top_srcdir)/src/wcmFilter.h \
- 	$(top_srcdir)/src/xf86WacomDefs.h \
-@@ -383,7 +382,6 @@ distclean-compile:
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmCommon.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmConfig.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmFilter.Plo@am__quote@
--@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmISDV4.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmTouchFilter.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmUSB.Plo@am__quote@
- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcmValidateDevice.Plo@am__quote@
-@@ -467,12 +465,7 @@ wcmConfig.lo: $(top_srcdir)/src/wcmConfi
- @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wcmConfig.lo `test -f '$(top_srcdir)/src/wcmConfig.c' || echo '$(srcdir)/'`$(top_srcdir)/src/wcmConfig.c
- 
--wcmISDV4.lo: $(top_srcdir)/src/wcmISDV4.c
--@am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wcmISDV4.lo -MD -MP -MF $(DEPDIR)/wcmISDV4.Tpo -c -o wcmISDV4.lo `test -f '$(top_srcdir)/src/wcmISDV4.c' || echo '$(srcdir)/'`$(top_srcdir)/src/wcmISDV4.c
--@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/wcmISDV4.Tpo $(DEPDIR)/wcmISDV4.Plo
--@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='$(top_srcdir)/src/wcmISDV4.c' object='wcmISDV4.lo' libtool=yes @AMDEPBACKSLASH@
- @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
--@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o wcmISDV4.lo `test -f '$(top_srcdir)/src/wcmISDV4.c' || echo '$(srcdir)/'`$(top_srcdir)/src/wcmISDV4.c
- 
- wcmFilter.lo: $(top_srcdir)/src/wcmFilter.c
- @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT wcmFilter.lo -MD -MP -MF $(DEPDIR)/wcmFilter.Tpo -c -o wcmFilter.lo `test -f '$(top_srcdir)/src/wcmFilter.c' || echo '$(srcdir)/'`$(top_srcdir)/src/wcmFilter.c
Index: files/patch-src-wcmConfig.c
===================================================================
--- files/patch-src-wcmConfig.c	(revision 324375)
+++ files/patch-src-wcmConfig.c	(working copy)
@@ -1,16 +0,0 @@
---- src/wcmConfig.c.orig
-+++ src/wcmConfig.c
-@@ -373,9 +373,12 @@ wcmDetectDeviceClass(const InputInfoPtr 
- 		return TRUE;
- 
- 	/* Bluetooth is also considered as USB */
-+#if 0
- 	if (gWacomISDV4Device.Detect(pInfo))
- 		common->wcmDevCls = &gWacomISDV4Device;
--	else if (gWacomUSBDevice.Detect(pInfo))
-+	else
-+#endif
-+	if (gWacomUSBDevice.Detect(pInfo))
- 		common->wcmDevCls = &gWacomUSBDevice;
- 	else
- 		xf86Msg(X_ERROR, "%s: cannot identify device class.\n", pInfo->name);
Index: files/patch-src-wcmISDV4.c
===================================================================
--- files/patch-src-wcmISDV4.c	(revision 0)
+++ files/patch-src-wcmISDV4.c	(working copy)
@@ -0,0 +1,123 @@
+--- src/wcmISDV4.c.orig	2013-08-07 16:41:16.844274271 -0700
++++ src/wcmISDV4.c	2013-08-07 19:38:52.321272814 -0700
+@@ -24,11 +24,10 @@
+ #include "xf86Wacom.h"
+ #include <xf86_OSproc.h>
+ #include "wcmFilter.h"
+-#include <linux/serial.h>
+ #include "isdv4.h"
++#include <termios.h>
+ #include <unistd.h>
+ #include <fcntl.h>
+-#include <libudev.h>
+ 
+ #define RESET_RELATIVE(ds) do { (ds).relwheel = 0; } while (0)
+ 
+@@ -192,11 +191,11 @@
+ 
+ static Bool isdv4Detect(InputInfoPtr pInfo)
+ {
+-	struct serial_struct ser;
++	struct termios termAttr;
+ 	int rc;
+ 
+-	rc = ioctl(pInfo->fd, TIOCGSERIAL, &ser);
+-	if (rc == -1)
++	rc = tcgetattr( pInfo->fd, &termAttr );
++	if( rc != 0 )
+ 		return FALSE;
+ 
+ 	return TRUE;
+@@ -935,67 +934,6 @@
+ };
+ 
+ /**
+- * Query the model number from the sysfs /sys/.../device/id file and return
+- * the matching model and the ID for the model we found.
+- *
+- * @param pInfo Used for debugging purposes only.
+- * @param fd File descriptor to the serial device.
+- * @param[out] id On success, returns the numeric ID for this device
+- * according to the model-specific matching pattern.
+- *
+- * @return The model description for the matching device or NULL if no
+- * matching one could be found.
+- */
+-static ISDV4ModelDesc*
+-model_from_sysfs(const InputInfoPtr pInfo, int fd, int *id)
+-{
+-	WacomDevicePtr priv = pInfo->private;
+-	ISDV4ModelDesc* model = NULL;
+-	struct udev *udev = NULL;
+-	struct udev_device *device = NULL;
+-	struct stat st;
+-	char *sysfs_path = NULL;
+-	FILE *file = NULL;
+-
+-	fstat(fd, &st);
+-
+-	udev = udev_new();
+-	device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
+-
+-	if (!device)
+-		goto out;
+-
+-	if (asprintf(&sysfs_path, "%s/device/id",
+-		     udev_device_get_syspath(device)) == -1)
+-		goto out;
+-
+-	DBG(8, priv, "sysfs path: %s\n", sysfs_path);
+-
+-	file = fopen(sysfs_path, "r");
+-	if (!file)
+-		goto out;
+-
+-	model = isdv4_models;
+-
+-	while(model->pattern && fscanf(file, model->pattern, id) <= 0)
+-		model++;
+-
+-	if (!model->pattern)
+-		model = NULL;
+-
+-	DBG(8, priv, "sysfs check found %s:%d\n",
+-	    (model) ? model->pattern : "<unknown>", *id);
+-
+-out:
+-	udev_device_unref(device);
+-	udev_unref(udev);
+-	if (file)
+-		fclose(file);
+-	free(sysfs_path);
+-	return model;
+-}
+-
+-/**
+  * Query the device's fd for the key bits and the tablet ID. Returns the ID
+  * on success. If the model vendor is unknown, we assume a penabled device
+  * (0x90). If the model vendor is known but the model itself is unknown, the
+@@ -1010,22 +948,18 @@
+ {
+ 	int id = 0;
+ 	int tablet_id = 0x90;
+-	struct serial_struct tmp;
++	struct termios tmp;
+ 	WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
+ 	WacomCommonPtr  common = priv->common;
+ 	ISDV4ModelDesc *model = isdv4_models;
+ 
+-	if (ioctl(pInfo->fd, TIOCGSERIAL, &tmp) < 0)
++	if( tcgetattr( pInfo->fd, &tmp ) != 0 )
+ 		return 0;
+ 
+ 	/* check device name for ID first */
+ 	while (model->pattern && sscanf(pInfo->name, model->pattern, &id) < 1)
+ 		model++;
+ 
+-	/* grab id from sysfs/.../device/id */
+-	if (!model->pattern)
+-		model = model_from_sysfs(pInfo, pInfo->fd, &id);
+-
+ 	memset(common->wcmKeys, 0, sizeof(common->wcmKeys));
+ 
+ 	/* default to penabled */
Index: files/patch-tools-Makefile.in
===================================================================
--- files/patch-tools-Makefile.in	(revision 324375)
+++ files/patch-tools-Makefile.in	(working copy)
@@ -1,11 +0,0 @@
---- tools/Makefile.in.orig
-+++ tools/Makefile.in
-@@ -54,6 +54,6 @@ PRE_UNINSTALL = :
- POST_UNINSTALL = :
- build_triplet = @build@
- host_triplet = @host@
--bin_PROGRAMS = xsetwacom$(EXEEXT) isdv4-serial-debugger$(EXEEXT)
-+bin_PROGRAMS = xsetwacom$(EXEEXT) 
- @UNITTESTS_TRUE@check_PROGRAMS = xsetwacom-test$(EXEEXT)
- subdir = tools
- DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
Index: files/patch-tools-isdv4-serial-debugger.c
===================================================================
--- files/patch-tools-isdv4-serial-debugger.c	(revision 0)
+++ files/patch-tools-isdv4-serial-debugger.c	(working copy)
@@ -0,0 +1,33 @@
+--- tools/isdv4-serial-debugger.c.orig	2013-08-07 16:41:16.826271564 -0700
++++ tools/isdv4-serial-debugger.c	2013-08-07 20:39:14.513272146 -0700
+@@ -25,7 +25,6 @@
+ 
+ #include <errno.h>
+ #include <fcntl.h>
+-#include <linux/serial.h>
+ #include <getopt.h>
+ #include <poll.h>
+ #include <stdio.h>
+@@ -71,7 +70,6 @@
+ static int open_device(char *path)
+ {
+ 	int fd, rc;
+-	struct serial_struct ser;
+ 	struct termios t;
+ 
+ 	TRACE("Opening device '%s'.\n", path);
+@@ -80,14 +78,6 @@
+ 	if (fd < 1)
+ 		perror("Failed to open device file.");
+ 
+-	if (ioctl(fd, TIOCGSERIAL, &ser) == -1)
+-	{
+-		fprintf(stderr, "Not a serial device?");
+-		close(fd);
+-		fd = -1;
+-		goto out;
+-	}
+-
+ 	rc = tcgetattr(fd, &t);
+ 	if (rc == -1)
+ 	{
Index: pkg-plist
===================================================================
--- pkg-plist	(revision 324375)
+++ pkg-plist	(working copy)
@@ -1,5 +1,6 @@
 bin/xsetwacom
 %%XINPUTMODDIR%%/wacom_drv.so
+%%XINPUTMODDIR%%/isdv4-serial-debugger
 @dirrmtry %%XINPUTMODDIR%%
 @cwd %%KMODDIR%%
 %%UWACOMKLD%%


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308080604.r7864sZA046329>