summaryrefslogtreecommitdiffstats
path: root/patches
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2009-11-10 15:55:12 +0100
committerMichael Olbrich <m.olbrich@pengutronix.de>2009-11-10 15:55:12 +0100
commit03bc91da8a62fe21973a2bfdf2f7e1010a7e8388 (patch)
tree53832547c2155bc4e0967f16e6e0e1396d1ea86d /patches
parent5a4c53a0ef45cd1cd5bb5cef5ebdd51b91d7cc30 (diff)
downloadptxdist-03bc91da8a62fe21973a2bfdf2f7e1010a7e8388.tar.gz
ptxdist-03bc91da8a62fe21973a2bfdf2f7e1010a7e8388.tar.xz
[tslib] cleanup + patch for eGalax
added install_alternative for /etc/ts.conf Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'patches')
-rw-r--r--patches/tslib-1.0/egalax.diff540
-rw-r--r--patches/tslib-1.0/series1
2 files changed, 541 insertions, 0 deletions
diff --git a/patches/tslib-1.0/egalax.diff b/patches/tslib-1.0/egalax.diff
new file mode 100644
index 000000000..c1ec8c815
--- /dev/null
+++ b/patches/tslib-1.0/egalax.diff
@@ -0,0 +1,540 @@
+diff -Naur tslib/configure.ac tslib-1.0-mine/configure.ac
+--- tslib/configure.ac 2009-03-24 19:02:37.000000000 +0100
++++ tslib-1.0-mine/configure.ac 2009-06-30 13:52:00.000000000 +0200
+@@ -171,6 +171,24 @@
+ AC_MSG_RESULT($input_module)
+ AM_CONDITIONAL(ENABLE_INPUT_MODULE, test "$input_module" = "yes")
+
++AC_MSG_CHECKING([whether galax module is requested])
++AC_ARG_ENABLE(galax,
++ AS_HELP_STRING([--enable-galax],
++ [Enable building of HID USB eGalax raw module (Linux /dev/hiddevN support) (default=yes)]),
++ [galax_module=$enableval],
++ [galax_module=yes])
++AC_MSG_RESULT($galax_module)
++AM_CONDITIONAL(ENABLE_GALAX_MODULE, test "$galax_module" = "yes")
++
++AC_MSG_CHECKING([whether touchkit module is requested])
++AC_ARG_ENABLE(touchkit,
++ AS_HELP_STRING([--enable-touchkit],
++ [Enable building of serial TouchKit raw module (Linux /dev/ttySX support) (default=yes)]),
++ [touchkit_module=$enableval],
++ [touchkit_module=yes])
++AC_MSG_RESULT($touchkit_module)
++AM_CONDITIONAL(ENABLE_TOUCHKIT_MODULE, test "$touchkit_module" = "yes")
++
+ AC_MSG_CHECKING([where to place modules])
+ AC_ARG_WITH(plugindir,
+ AS_HELP_STRING([--with-plugindir=ARG],
+diff -Naur tslib/plugins/galax-raw.c tslib-1.0-mine/plugins/galax-raw.c
+--- tslib/plugins/galax-raw.c 1970-01-01 01:00:00.000000000 +0100
++++ tslib-1.0-mine/plugins/galax-raw.c 2009-05-19 15:27:32.000000000 +0200
+@@ -0,0 +1,296 @@
++/*
++ * tslib/plugins/galax-raw.c
++ *
++ * Inspired from input-raw.c
++ * 2009.05 Fred Salabartan
++ *
++ * This file is placed under the LGPL. Please see the file
++ * COPYING for more details.
++ *
++ * Plugin for "eGalax Inc. Touch" (using usbhid driver)
++ * (Vendor=0eef Product=0001 Version=0112)
++ */
++
++#include "config.h"
++
++#include <errno.h>
++#include <stdio.h>
++#include <limits.h>
++
++#include <stdlib.h>
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#include <sys/time.h>
++#include <sys/types.h>
++
++#include <linux/input.h>
++#ifndef EV_SYN /* 2.4 kernel headers */
++# define EV_SYN 0x00
++#endif
++#ifndef EV_CNT
++# define EV_CNT (EV_MAX+1)
++#endif
++#ifndef ABS_CNT
++# define ABS_CNT (ABS_MAX+1)
++#endif
++#ifndef KEY_CNT
++# define KEY_CNT (KEY_MAX+1)
++#endif
++
++#include "tslib-private.h"
++
++enum {
++ GRAB_EVENTS_NO = 0,
++ GRAB_EVENTS_WANTED = 1,
++ GRAB_EVENTS_ACTIVE = 2,
++
++ SANE_INIT = 0,
++ SANE_OK = 1,
++ SANE_ERROR = 2,
++
++ BITS_PER_BYTE = 8,
++ BITS_PER_LONG = (sizeof(long) * BITS_PER_BYTE)
++};
++
++#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
++#define BIT(nr) (1UL << (nr))
++#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
++#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
++//#define BITS_PER_LONG (sizeof(long) * BITS_PER_BYTE)
++#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG)
++
++
++struct tslib_galax {
++ struct tslib_module_info module;
++
++ int current_x;
++ int current_y;
++ int current_pressure;
++
++ int sane_fd; // 0=not init, 1=ok, -1=error
++ int grab_events;
++};
++
++
++
++
++static int ts_galax_check_fd (struct tslib_galax *i)
++{
++ struct tsdev *ts = i->module.dev;
++ int version;
++ long evbit[BITS_TO_LONGS(EV_CNT)];
++ long absbit[BITS_TO_LONGS(ABS_CNT)];
++ long keybit[BITS_TO_LONGS(KEY_CNT)];
++ struct input_id infos;
++
++ if (ioctl(ts->fd, EVIOCGVERSION, &version) < 0) {
++ fprintf (stderr, "tslib: not a valid input device\n");
++ return SANE_ERROR;
++ }
++
++ if (version != EV_VERSION) {
++ fprintf (stderr, "tslib: bad event protocol version (lib vs device)\n");
++ return SANE_ERROR;
++ }
++
++ if ((ioctl(ts->fd, EVIOCGID, &infos) < 0)) {
++ fprintf (stderr, "tslib: warning, can not read device identifier\n");
++ } else if (infos.bustype != 3 || infos.vendor != 0x0EEF || infos.product != 0x0001 || infos.version != 0x0112) {
++ fprintf (stderr, "tslib: this is not an eGalax touchscreen (3,0x0EEF,1,0x0112)\n"
++ "Your device: bus=%d, vendor=0x%X, product=0x%X, version=0x%X\n",
++ infos.bustype, infos.vendor, infos.product, infos.version);
++ return SANE_ERROR;
++ }
++
++ if ((ioctl(ts->fd, EVIOCGBIT(0, EV_CNT), evbit) < 0) ||
++ !(evbit[BIT_WORD(EV_ABS)] & BIT_MASK(EV_ABS)) ||
++ !(evbit[BIT_WORD(EV_KEY)] & BIT_MASK(EV_KEY)) ) {
++ fprintf (stderr, "tslib: device does not support ABS and KEY event types\n");
++ return SANE_ERROR;
++ }
++
++ if ((ioctl(ts->fd, EVIOCGBIT(EV_ABS, ABS_CNT), absbit)) < 0 ||
++ !(absbit[BIT_WORD(ABS_X)] & BIT_MASK(ABS_X)) ||
++ !(absbit[BIT_WORD(ABS_Y)] & BIT_MASK(ABS_Y))) {
++ fprintf (stderr, "tslib: device does not support ABS_X and ABS_Y events\n");
++ return SANE_ERROR;
++ }
++
++ /* Since some touchscreens (eg. infrared) physically can't measure pressure,
++ the input system doesn't report it on those. Tslib relies on pressure, thus
++ we set it to constant 255. It's still controlled by BTN_TOUCH - when not
++ touched, the pressure is forced to 0. */
++ if (!(absbit[BIT_WORD(ABS_PRESSURE)] & BIT_MASK(ABS_PRESSURE))) {
++ i->current_pressure = 255;
++
++ if ((ioctl(ts->fd, EVIOCGBIT(EV_KEY, KEY_CNT), keybit) < 0) ||
++ !(keybit[BIT_WORD(BTN_TOUCH)] & BIT_MASK(BTN_TOUCH)) ) {
++ fprintf (stderr, "tslib: device does support BTN_TOUCH events\n");
++ return SANE_ERROR;
++ }
++ }
++
++ if (! (evbit[BIT_WORD(EV_SYN)] & BIT_MASK(EV_SYN))) {
++ fprintf (stderr, "tslib: device does not use EV_SYN\n");
++ return SANE_ERROR;
++ }
++
++ if (i->grab_events == GRAB_EVENTS_WANTED) {
++ if (ioctl(ts->fd, EVIOCGRAB, (void *)1)) {
++ fprintf (stderr, "tslib: unable to grab selected input device\n");
++ return -1;
++ }
++ i->grab_events = GRAB_EVENTS_ACTIVE;
++ }
++
++ return SANE_OK;
++}
++
++
++
++static int ts_galax_read (struct tslib_module_info *inf,
++ struct ts_sample *samp, int nr)
++{
++ struct tslib_galax *i = (struct tslib_galax *)inf;
++ struct tsdev *ts = inf->dev;
++ struct input_event ev;
++ int ret = nr;
++ int total = 0;
++
++ if (i->sane_fd == SANE_INIT)
++ i->sane_fd = ts_galax_check_fd(i);
++
++ if (i->sane_fd == SANE_ERROR)
++ return 0;
++
++ while (total < nr) {
++
++ ret = read(ts->fd, &ev, sizeof(struct input_event));
++ if (ret < (int)sizeof(struct input_event)) {
++ total = -1;
++ break;
++ }
++
++ switch (ev.type) {
++ case EV_KEY:
++ switch (ev.code) {
++ case BTN_TOUCH:
++ if (ev.value == 0) {
++ /* pen up */
++ i->current_x = 0;
++ i->current_y = 0;
++ i->current_pressure = 0;
++ } else {
++ i->current_pressure = 255;
++ }
++ break;
++ }
++ break;
++
++ case EV_SYN:
++ /* Fill out a new complete event */
++ samp->x = i->current_x;
++ samp->y = i->current_y;
++ samp->pressure = i->current_pressure;
++ samp->tv = ev.time;
++ samp++;
++ total++;
++ break;
++
++ case EV_ABS:
++ switch (ev.code) {
++ case ABS_X+2: i->current_x = ev.value; break;
++ case ABS_Y+2: i->current_y = ev.value; break;
++ case ABS_PRESSURE: i->current_pressure = ev.value; break;
++ }
++ break;
++ }
++ }
++ ret = total;
++
++ return ret;
++}
++
++
++
++static int ts_galax_fini (struct tslib_module_info *inf)
++{
++ struct tslib_galax *i = (struct tslib_galax *)inf;
++ struct tsdev *ts = inf->dev;
++
++ if (i->grab_events == GRAB_EVENTS_ACTIVE) {
++ if (ioctl (ts->fd, EVIOCGRAB, (void *)0)) {
++ fprintf (stderr, "tslib: Unable to un-grab selected input device\n");
++ }
++ }
++
++ free (inf);
++ return 0;
++}
++
++
++
++static const struct tslib_ops __ts_galax_ops = {
++ .read = ts_galax_read,
++ .fini = ts_galax_fini,
++};
++
++
++
++static int parse_raw_grab (struct tslib_module_info *inf, char *str, void *data)
++{
++ struct tslib_galax *i = (struct tslib_galax *)inf;
++ unsigned long v;
++ int err = errno;
++
++ v = strtoul (str, NULL, 0);
++
++ if (v == ULONG_MAX && errno == ERANGE)
++ return -1;
++
++ errno = err;
++ switch ((int)data) {
++ case 1:
++ if (v)
++ i->grab_events = GRAB_EVENTS_WANTED;
++ break;
++ default:
++ return -1;
++ }
++ return 0;
++}
++
++
++
++static const struct tslib_vars raw_vars[] =
++{
++ { "grab_events", (void *)1, parse_raw_grab },
++};
++
++#define NR_VARS (sizeof(raw_vars) / sizeof(raw_vars[0]))
++
++
++
++TSAPI struct tslib_module_info *mod_init (struct tsdev *dev, const char *params)
++{
++ struct tslib_galax *i;
++
++ i = malloc (sizeof (struct tslib_galax));
++ if (i == NULL)
++ return NULL;
++
++ i->module.ops = &__ts_galax_ops;
++ i->current_x = 0;
++ i->current_y = 0;
++ i->current_pressure = 0;
++ i->sane_fd = SANE_INIT;
++ i->grab_events = GRAB_EVENTS_NO;
++
++ if (tslib_parse_vars (&i->module, raw_vars, NR_VARS, params)) {
++ free (i);
++ return NULL;
++ }
++
++ return &(i->module);
++}
+diff -Naur tslib/plugins/Makefile.am tslib-1.0-mine/plugins/Makefile.am
+--- tslib/plugins/Makefile.am 2009-03-24 19:02:37.000000000 +0100
++++ tslib-1.0-mine/plugins/Makefile.am 2009-06-30 13:49:07.000000000 +0200
+@@ -91,6 +91,18 @@
+ INPUT_MODULE =
+ endif
+
++if ENABLE_GALAX_MODULE
++GALAX_MODULE = galax.la
++else
++GALAX_MODULE =
++endif
++
++if ENABLE_TOUCHKIT_MODULE
++TOUCHKIT_MODULE = touchkit.la
++else
++TOUCHKIT_MODULE =
++endif
++
+ if ENABLE_H2200_LINEAR_MODULE
+ H2200_LINEAR_MODULE = linear_h2200.la
+ else
+@@ -110,8 +122,10 @@
+ $(ARCTIC2_MODULE) \
+ $(DMC_MODULE) \
+ $(H2200_LINEAR_MODULE) \
+- $(INPUT_MODULE)
+-
++ $(INPUT_MODULE) \
++ $(GALAX_MODULE) \
++ $(TOUCHKIT_MODULE)
++
+ variance_la_SOURCES = variance.c
+ variance_la_LDFLAGS = -module $(LTVSN)
+
+@@ -154,5 +168,12 @@
+ input_la_LDFLAGS = -module $(LTVSN)
+ input_la_LIBADD = $(top_builddir)/src/libts.la
+
++galax_la_SOURCES = galax-raw.c
++galax_la_LDFLAGS = -module $(LTVSN)
++galax_la_LIBADD = $(top_builddir)/src/libts.la
++
++touchkit_la_SOURCES = touchkit-raw.c
++touchkit_la_LDFLAGS = -module $(LTVSN)
++
+ linear_h2200_la_SOURCES = linear-h2200.c
+ linear_h2200_la_LDFLAGS = -module $(LTVSN)
+diff -Naur tslib/plugins/touchkit-raw.c tslib-1.0-mine/plugins/touchkit-raw.c
+--- tslib/plugins/touchkit-raw.c 1970-01-01 01:00:00.000000000 +0100
++++ tslib-1.0-mine/plugins/touchkit-raw.c 2009-07-07 14:43:40.000000000 +0200
+@@ -0,0 +1,160 @@
++
++#include <stdlib.h>
++#include <stdio.h>
++#include <unistd.h>
++#include <termios.h>
++#include <string.h>
++
++#include "config.h"
++#include "tslib-private.h"
++
++/*
++ * TouchKit RS232 driver
++ * (controller type SAT4000UR)
++ * 2009.07 Fred Salabartan
++ *
++ * Packet format for position report (5 bytes):
++ * [0] 1 0 0 0 0 0 0 t = header (t=touched)
++ * [1] 0 0 0 0 X X X X = X coord most significant bits
++ * [2] 0 X X X X X X X = X coord less significant bits
++ * [3] 0 0 0 0 Y Y Y Y = Y coord most significant bits
++ * [4] 0 Y Y Y Y Y Y Y = Y coord less significant bits
++ *
++ * Problem: sometimes some packets overlap, so it is possible
++ * to find a new packet in the middle of another packet.
++ * -> check that no byte in the packet (but the first one)
++ * have its first bit set (0x80 = start)
++ *
++ * This file is placed under the LGPL. Please see the file
++ * COPYING for more details.
++*/
++
++enum {
++ PACKET_SIZE = 5,
++ BUFFER_SIZE = 100,
++ PACKET_SIGNATURE = 0x81
++};
++
++// Is is a start of packet ?
++#define IsStart(x) (((x)|1) == PACKET_SIGNATURE)
++
++
++//------------------------------------------------------------------------------
++
++
++static int touchkit_init (int dev)
++{
++ struct termios tty;
++
++ tcgetattr (dev, &tty);
++ tty.c_iflag = IGNBRK | IGNPAR;
++ tty.c_oflag = 0;
++ tty.c_lflag = 0;
++ tty.c_line = 0;
++ tty.c_cc[VTIME] = 0;
++ tty.c_cc[VMIN] = 1;
++ tty.c_cflag = CS8|CREAD|CLOCAL|HUPCL;
++ tty.c_cflag |= B9600;
++ tcsetattr (dev, TCSAFLUSH, &tty);
++
++ return 1;
++}
++
++
++
++static int touchkit_read (struct tslib_module_info *inf, struct ts_sample *samp, int nr)
++{
++ static initDone = 0;
++ static unsigned char buffer[BUFFER_SIZE]; // enough space for 2 "normal" packets
++ static int pos = 0;
++
++ struct tsdev *ts = inf->dev;
++
++ if (initDone == 0) {
++ initDone = touchkit_init (ts->fd);
++ if (initDone == -1)
++ return -1;
++ }
++
++ // read some new bytes (enough for 1 normal packet)
++ int ret = read (ts->fd, buffer+pos, PACKET_SIZE);
++ if (ret <= 0) return -1;
++
++ pos += ret;
++ if (pos < PACKET_SIZE) return 0;
++
++ // find start
++ int p;
++ int total = 0;
++ for (p = 0; p < pos; ++p)
++ if (IsStart (buffer[p])) {
++ // we have enough data for a packet ?
++ if (p+PACKET_SIZE > pos) {
++ if (p > 0) {
++ // we have found a start >0, it means we have garbage
++ // at beginning of buffer
++ // so let's shift data to ignore this garbage
++ memcpy (buffer, buffer+p, pos-p);
++ pos -= p;
++ }
++ break;
++ }
++
++ unsigned char *data = buffer + p;
++
++ // check if all bytes are ok (no 'start' embedded)
++ int q;
++ for (q = 1; q < PACKET_SIZE; ++q)
++ if (IsStart (buffer[p+q]))
++ break;
++ if (q < PACKET_SIZE) {
++#ifdef DEBUG
++ fprintf (stderr, "Start found within packet [%X %X %X %X %X] ignore %d bytes\n",
++ data[0], data[1], data[2], data[3], data[4], q);
++#endif
++ p += q-1;
++ continue;
++ }
++
++ // now let's decode it
++ samp->x = (data[1] & 0x000F) << 7 | (data[2] & 0x007F);
++ samp->y = ((data[3] & 0x000F) << 7 | (data[4] & 0x007F));
++ samp->pressure = (data[0] & 1) ? 200 : 0;
++ gettimeofday (&samp->tv, NULL);
++#ifdef DEBUG
++ fprintf (stderr, "RAW -------------------------> data=[%X %X %X %X %X] x=%d y=%d pres=%d\n",
++ nr, data[0], data[1], data[2], data[3], data[4],
++ samp->x, samp->y, samp->pressure);
++#endif
++ samp++;
++
++ // now remove it
++ memcpy (buffer, buffer+p+PACKET_SIZE, pos-p-PACKET_SIZE);
++ pos -= p+PACKET_SIZE;
++ total = 1;
++ break;
++ }
++
++ return total;
++}
++
++
++
++static const struct tslib_ops touchkit_ops =
++ {
++ .read = touchkit_read,
++ };
++
++
++
++TSAPI struct tslib_module_info *mod_init (struct tsdev *dev, const char *params)
++{
++ struct tslib_module_info *m;
++
++ m = malloc (sizeof(struct tslib_module_info));
++ if (m == NULL)
++ return NULL;
++
++ m->ops = &touchkit_ops;
++ return m;
++}
diff --git a/patches/tslib-1.0/series b/patches/tslib-1.0/series
index 392e0bade..6061cc944 100644
--- a/patches/tslib-1.0/series
+++ b/patches/tslib-1.0/series
@@ -4,4 +4,5 @@ tests_assume_input_api.diff -p0
tests_clear_screen_at_end.diff -p0
dmc-support.diff
add-open-env.diff
+egalax.diff
fix-autotools.diff