summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tslib/tslib.oe6
-rw-r--r--tslib/tslib/doc.patch (renamed from tslib/tslib/configure.patch)0
-rw-r--r--tslib/tslib/pthres.patch295
-rw-r--r--tslib/tslib/raw-hwread.patch (renamed from tslib/tslib/envvar_doc.patch)0
-rw-r--r--tslib/tslib/raw.patch923
-rw-r--r--tslib/tslib/zap.patch1684
6 files changed, 2905 insertions, 3 deletions
diff --git a/tslib/tslib.oe b/tslib/tslib.oe
index 7303fe9fea..cc62df3a0a 100644
--- a/tslib/tslib.oe
+++ b/tslib/tslib.oe
@@ -5,16 +5,16 @@ RDEPENDS = libc6
SRC_URI = cvs://cvs:@pubcvs.arm.linux.org.uk/mnt/src/cvsroot;module=tslib
SRC_URI_append=" file://${FILESDIR}/automake.patch;patch=1"
+SRC_URI_append=" file://${FILESDIR}/doc.patch;patch=1"
SRC_URI_append=" file://${FILESDIR}/zap.patch;patch=1"
SRC_URI_append=" file://${FILESDIR}/pthres.patch;patch=1"
+SRC_URI_append=" file://${FILESDIR}/raw.patch;patch=1"
+SRC_URI_append=" file://${FILESDIR}/raw-hwread.patch;patch=1"
#SRC_URI_append=" file://${FILESDIR}/collie-module.patch;patch=1"
-#SRC_URI_append=" file://${FILESDIR}/configure.patch;patch=1"
#SRC_URI_append=" file://${FILESDIR}/devfs.patch;patch=1"
-#SRC_URI_append=" file://${FILESDIR}/envvar_doc.patch;patch=1"
#SRC_URI_append=" file://${FILESDIR}/event1.patch;patch=1"
#SRC_URI_append=" file://${FILESDIR}/multievent.patch;patch=1"
#SRC_URI_append=" file://${FILESDIR}/pointercal.patch;patch=1"
-#SRC_URI_append=" file://${FILESDIR}/raw.patch;patch=1"
#SRC_URI_append=" file://${FILESDIR}/ts_calibrate.patch;patch=1"
S = ${WORKDIR}/${PN}
diff --git a/tslib/tslib/configure.patch b/tslib/tslib/doc.patch
index e69de29bb2..e69de29bb2 100644
--- a/tslib/tslib/configure.patch
+++ b/tslib/tslib/doc.patch
diff --git a/tslib/tslib/pthres.patch b/tslib/tslib/pthres.patch
index e69de29bb2..b4bafcbf60 100644
--- a/tslib/tslib/pthres.patch
+++ b/tslib/tslib/pthres.patch
@@ -0,0 +1,295 @@
+
+#
+# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
+#
+
+--- tslib/configure.in~tslib-pthres
++++ tslib/configure.in
+@@ -10,6 +10,8 @@
+ [ "x$enableval" = "xyes" ] && PLUGINS="$PLUGINS dejitter.la", PLUGINS="$PLUGINS dejitter.la")
+ AC_ARG_ENABLE(variance, [ --enable-variance Enable building of variance filter [default=yes]],
+ [ "x$enableval" = "xyes" ] && PLUGINS="$PLUGINS variance.la", PLUGINS="$PLUGINS variance.la")
++AC_ARG_ENABLE(pthres, [ --enable-pthres Enable building of pthres filter [default=yes]],
++ [ "x$enableval" = "xyes" ] && PLUGINS="$PLUGINS pthres.la", PLUGINS="$PLUGINS pthres.la")
+
+ AC_MSG_CHECKING(--enable-debug argument)
+ AC_ARG_ENABLE(debug, [ --enable-debug Enable debug messages from filters [default=no]],
+--- tslib/plugins/Makefile.am~tslib-pthres
++++ tslib/plugins/Makefile.am
+@@ -19,7 +19,7 @@
+ LIBS =
+ plugindir = $(PLUGIN_DIR)
+
+-EXTRA_LTLIBRARIES = variance.la dejitter.la linear.la
++EXTRA_LTLIBRARIES = variance.la dejitter.la linear.la pthres.la
+ plugin_LTLIBRARIES = $(PLUGINS)
+
+ variance_la_SOURCES = variance.c
+@@ -30,3 +30,6 @@
+
+ linear_la_SOURCES = linear.c
+ linear_la_LDFLAGS = -module $(LTVSN)
++
++pthres_la_SOURCES = pthres.c
++pthres_la_LDFLAGS = -module $(LTVSN)
+--- /dev/null
++++ tslib/plugins/pthres.c
+@@ -0,0 +1,157 @@
++/*
++ * tslib/plugins/pthres.c
++ *
++ * Copyright (C) 2003 Texas Instruments, Inc.
++ *
++ * Based on:
++ * tslib/plugins/linear.c
++ * Copyright (C) 2001 Russell King.
++ *
++ * This file is placed under the LGPL. Please see the file
++ * COPYING for more details.
++ *
++ * Ensure a release is always pressure 0, and that a press is always >=1.
++ */
++#include <stdlib.h>
++#include <string.h>
++#include <sys/types.h>
++#include <stdio.h>
++#include <unistd.h>
++#include <errno.h>
++#include <limits.h>
++
++#include "tslib.h"
++#include "tslib-filter.h"
++
++struct tslib_pthres {
++ struct tslib_module_info module;
++ int pmin;
++ int pmax;
++};
++
++static int
++pthres_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
++{
++ struct tslib_pthres *p = (struct tslib_pthres *)info;
++ int ret;
++ static int xsave = 0, ysave = 0;
++ static int press = 0;
++
++ ret = info->next->ops->read(info->next, samp, nr);
++ if (ret >= 0) {
++ int nr = 0, i;
++ struct ts_sample *s;
++
++ for (s = samp, i = 0; i < ret; i++, s++) {
++ if (s->pressure < p->pmin) {
++ if (press != 0) {
++ /* release */
++ press = 0;
++ s->pressure = 0;
++ s->x = xsave;
++ s->y = ysave;
++ } else {
++ /* release with no press, outside bounds, dropping */
++ int left = ret - nr - 1;
++ if (left > 0) {
++ memmove(s, s + 1, left * sizeof(struct ts_sample));
++ s--;
++ continue;
++ }
++ break;
++ }
++ } else {
++ if (s->pressure > p->pmax) {
++ /* pressure outside bounds, dropping */
++ int left = ret - nr - 1;
++ if (left > 0) {
++ memmove(s, s + 1, left * sizeof(struct ts_sample));
++ s--;
++ continue;
++ }
++ break;
++ }
++ /* press */
++ press = 1;
++ xsave = s->x;
++ ysave = s->y;
++ }
++ nr++;
++ }
++ return nr;
++ }
++ return ret;
++}
++
++static int pthres_fini(struct tslib_module_info *info)
++{
++ free(info);
++ return 0;
++}
++
++static const struct tslib_ops pthres_ops =
++{
++ read: pthres_read,
++ fini: pthres_fini,
++};
++
++static int threshold_vars(struct tslib_module_info *inf, char *str, void *data)
++{
++ struct tslib_pthres *p = (struct tslib_pthres *)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 0:
++ p->pmin = v;
++ break;
++
++ case 1:
++ p->pmax = v;
++ break;
++
++ default:
++ return -1;
++ }
++ return 0;
++}
++
++
++static const struct tslib_vars pthres_vars[] =
++{
++ { "pmin", (void *)0, threshold_vars },
++ { "pmax", (void *)1, threshold_vars }
++};
++
++#define NR_VARS (sizeof(pthres_vars) / sizeof(pthres_vars[0]))
++
++struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
++{
++
++ struct tslib_pthres *p;
++
++ p = malloc(sizeof(struct tslib_pthres));
++ if (p == NULL)
++ return NULL;
++
++ p->module.ops = &pthres_ops;
++
++ p->pmin = 1;
++ p->pmax = INT_MAX;
++
++ /*
++ * Parse the parameters.
++ */
++ if (tslib_parse_vars(&p->module, pthres_vars, NR_VARS, params)) {
++ free(p);
++ return NULL;
++ }
++
++ return &p->module;
++}
+--- tslib/etc/ts.conf~tslib-pthres
++++ tslib/etc/ts.conf
+@@ -1,3 +1,4 @@
+-module variance delta=30 pthreshold=1
+-module dejitter delta=100 pthreshold=1
++module pthres pmin=1
++module variance delta=30
++module dejitter delta=100
+ module linear
+--- tslib/plugins/variance.c~tslib-pthres
++++ tslib/plugins/variance.c
+@@ -33,7 +33,6 @@
+
+ struct tslib_variance {
+ struct tslib_module_info module;
+- unsigned int pthreshold;
+ unsigned int delta;
+ struct ts_sample last;
+ struct ts_sample noise;
+@@ -62,7 +61,7 @@
+ } else if (!info->next->ops->read(info->next, &cur, 1))
+ return count;
+
+- if (cur.pressure < var->pthreshold) {
++ if (cur.pressure == 0) {
+ /* Flush the queue immediately when the pen is just
+ * released, otherwise the previous layer will
+ * get the pen up notification too late. This
+@@ -151,10 +150,6 @@
+ var->delta = v;
+ break;
+
+- case 2:
+- var->pthreshold = v;
+- break;
+-
+ default:
+ return -1;
+ }
+@@ -164,7 +159,6 @@
+ static const struct tslib_vars variance_vars[] =
+ {
+ { "delta", (void *)1, variance_limit },
+- { "pthreshold", (void *)2, variance_limit }
+ };
+
+ #define NR_VARS (sizeof(variance_vars) / sizeof(variance_vars[0]))
+@@ -180,7 +174,6 @@
+ var->module.ops = &variance_ops;
+
+ var->delta = 30;
+- var->pthreshold = 1;
+ var->flags = 0;
+
+ if (tslib_parse_vars(&var->module, variance_vars, NR_VARS, params)) {
+--- tslib/plugins/dejitter.c~tslib-pthres
++++ tslib/plugins/dejitter.c
+@@ -63,7 +63,6 @@
+
+ struct tslib_dejitter {
+ struct tslib_module_info module;
+- unsigned int pthreshold;
+ unsigned int delta;
+ unsigned int x;
+ unsigned int y;
+@@ -110,7 +109,7 @@
+
+ ret = info->next->ops->read(info->next, samp, nr);
+ for (s = samp; ret > 0; s++, ret--) {
+- if (s->pressure < djt->pthreshold) {
++ if (s->pressure == 0) {
+ /*
+ * Pen was released. Reset the state and
+ * forget all history events.
+@@ -184,10 +183,6 @@
+ djt->delta = v;
+ break;
+
+- case 2:
+- djt->pthreshold = v;
+- break;
+-
+ default:
+ return -1;
+ }
+@@ -197,7 +192,6 @@
+ static const struct tslib_vars dejitter_vars[] =
+ {
+ { "delta", (void *)1, dejitter_limit },
+- { "pthreshold", (void *)2, dejitter_limit }
+ };
+
+ #define NR_VARS (sizeof(dejitter_vars) / sizeof(dejitter_vars[0]))
+@@ -213,7 +207,6 @@
+ djt->module.ops = &dejitter_ops;
+
+ djt->delta = 100;
+- djt->pthreshold = 1;
+ djt->head = 0;
+
+ if (tslib_parse_vars(&djt->module, dejitter_vars, NR_VARS, params)) {
diff --git a/tslib/tslib/envvar_doc.patch b/tslib/tslib/raw-hwread.patch
index e69de29bb2..e69de29bb2 100644
--- a/tslib/tslib/envvar_doc.patch
+++ b/tslib/tslib/raw-hwread.patch
diff --git a/tslib/tslib/raw.patch b/tslib/tslib/raw.patch
index e69de29bb2..8f7f0dffe0 100644
--- a/tslib/tslib/raw.patch
+++ b/tslib/tslib/raw.patch
@@ -0,0 +1,923 @@
+
+#
+# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
+#
+
+--- tslib/src/tslib-private.h~raw
++++ tslib/src/tslib-private.h
+@@ -21,6 +21,9 @@
+ struct tsdev {
+ int fd;
+ struct tslib_module_info *list;
++ struct tslib_module_info *list_raw; /* points to position in 'list' where raw reads
++ come from. default is the position of the
++ ts_read_raw module. */
+ #ifdef USE_INPUT_API
+ int current_x;
+ int current_y;
+@@ -29,7 +32,9 @@
+ };
+
+ int __ts_attach(struct tsdev *ts, struct tslib_module_info *info);
++int __ts_attach_raw(struct tsdev *ts, struct tslib_module_info *info);
+ int ts_load_module(struct tsdev *dev, const char *module, const char *params);
++int ts_load_module_raw(struct tsdev *dev, const char *module, const char *params);
+ int ts_error(const char *fmt, ...);
+
+ #ifdef __cplusplus
+--- tslib/src/ts_attach.c~raw
++++ tslib/src/ts_attach.c
+@@ -10,6 +10,8 @@
+ *
+ * Attach a filter to a touchscreen device.
+ */
++#include <stdlib.h>
++
+ #include "config.h"
+
+ #include "tslib-private.h"
+@@ -22,3 +24,30 @@
+
+ return 0;
+ }
++
++int __ts_attach_raw(struct tsdev *ts, struct tslib_module_info *info)
++{
++ struct tslib_module_info *next, *prev, *prev_list = ts->list_raw;
++ info->dev = ts;
++ info->next = prev_list;
++ ts->list_raw = info;
++
++ /*
++ * ensure the last item in the normal list now points to the
++ * top of the raw list.
++ */
++
++ if (ts->list == NULL || ts->list == prev_list) { /* main list is empty, ensure it points here */
++ ts->list = info;
++ return 0;
++ }
++
++ next = ts->list;
++
++ while (next != NULL && next != prev_list)
++ prev = next, next = prev->next;
++
++ prev->next = info;
++
++ return 0;
++}
+--- tslib/src/ts_config.c~raw
++++ tslib/src/ts_config.c
+@@ -11,6 +11,7 @@
+ * Read the configuration and load the appropriate drivers.
+ */
+ #include "config.h"
++#include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
+@@ -29,8 +30,16 @@
+ return ts_load_module(ts, tok, rest);
+ }
+
++static int ts_opt_module_raw(struct tsdev *ts, char *rest)
++{
++ char *tok = strsep(&rest, " \t");
++
++ return ts_load_module_raw(ts, tok, rest);
++}
++
+ static struct opt options[] = {
+ { "module", ts_opt_module },
++ { "module_raw", ts_opt_module_raw },
+ };
+
+ #define NR_OPTS (sizeof(options) / sizeof(options[0]))
+--- tslib/src/ts_load_module.c~raw
++++ tslib/src/ts_load_module.c
+@@ -21,7 +21,7 @@
+
+ #include "tslib-private.h"
+
+-int ts_load_module(struct tsdev *ts, const char *module, const char *params)
++int __ts_load_module(struct tsdev *ts, const char *module, const char *params, int raw)
+ {
+ struct tslib_module_info * (*init)(struct tsdev *, const char *);
+ struct tslib_module_info *info;
+@@ -63,7 +63,11 @@
+
+ info->handle = handle;
+
+- ret = __ts_attach(ts, info);
++ if (raw) {
++ ret = __ts_attach_raw(ts, info);
++ } else {
++ ret = __ts_attach(ts, info);
++ }
+ if (ret) {
+ info->ops->fini(info);
+ dlclose(handle);
+@@ -71,3 +75,14 @@
+
+ return ret;
+ }
++
++
++int ts_load_module(struct tsdev *ts, const char *module, const char *params)
++{
++ __ts_load_module(ts, module, params, 0);
++}
++
++int ts_load_module_raw(struct tsdev *ts, const char *module, const char *params)
++{
++ __ts_load_module(ts, module, params, 1);
++}
+--- tslib/src/ts_open.c~raw
++++ tslib/src/ts_open.c
+@@ -60,7 +60,7 @@
+ goto close;
+ #endif /* USE_INPUT_API */
+
+- __ts_attach(ts, &__ts_raw);
++ __ts_attach_raw(ts, &__ts_raw);
+ }
+
+ return ts;
+--- tslib/src/Makefile.am~raw
++++ tslib/src/Makefile.am
+@@ -17,7 +17,7 @@
+ lib_LTLIBRARIES = libts.la
+ libts_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \
+ ts_fd.c ts_load_module.c ts_open.c ts_parse_vars.c \
+- ts_read.c ts_read_raw.c
++ ts_read.c ts_read_raw.c ts_read_raw_module.c
+ libts_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -release $(LT_RELEASE) -export-dynamic
+ libts_la_LIBADD = -ldl
+--- tslib/src/ts_read_raw.c~raw
++++ tslib/src/ts_read_raw.c
+@@ -1,378 +1,28 @@
+ /*
+ * tslib/src/ts_read_raw.c
+ *
+- * Original version:
+- * Copyright (C) 2001 Russell King.
+- *
+- * Rewritten for the Linux input device API:
+- * Copyright (C) 2002 Nicolas Pitre
++ * Copyright (C) 2003 Chris Larson.
+ *
+ * This file is placed under the LGPL. Please see the file
+ * COPYING for more details.
+ *
+- * $Id$
+- *
+ * Read raw pressure, x, y, and timestamp from a touchscreen device.
+ */
+ #include "config.h"
+
+-#include <stdio.h>
++#include "tslib-private.h"
+
++#ifdef DEBUG
+ #include <stdlib.h>
+-#ifdef HAVE_UNISTD_H
+-#include <unistd.h>
++#include <stdio.h>
++#include <string.h>
+ #endif
+-#include <sys/time.h>
+-#include <sys/types.h>
+-
+-#ifdef USE_INPUT_API
+-#include <linux/input.h>
+-#else
+-struct ts_event { /* Used in UCB1x00 style touchscreens (the default) */
+- unsigned short pressure;
+- unsigned short x;
+- unsigned short y;
+- unsigned short pad;
+- struct timeval stamp;
+-};
+-struct h3600_ts_event { /* Used in the Compaq IPAQ */
+- unsigned short pressure;
+- unsigned short x;
+- unsigned short y;
+- unsigned short pad;
+-};
+-struct mk712_ts_event { /* Used in the Hitachi Webpad */
+- unsigned int header;
+- unsigned int x;
+- unsigned int y;
+- unsigned int reserved;
+-};
+-struct arctic2_ts_event { /* Used in the IBM Arctic II */
+- signed short pressure;
+- signed int x;
+- signed int y;
+- int millisecs;
+- int flags;
+-};
+-struct collie_ts_event { /* Used in the Sharp Zaurus SL-5000d and SL-5500 */
+- long y;
+- long x;
+- long pressure;
+- long long millisecs;
+-};
+-struct corgi_ts_event { /* Used in the Sharp Zaurus SL-C700 */
+- short pressure;
+- short x;
+- short y;
+- short millisecs;
+-};
+-#endif /* USE_INPUT_API */
+-
+-#include "tslib-private.h"
+
+ int ts_read_raw(struct tsdev *ts, struct ts_sample *samp, int nr)
+ {
+-#ifdef USE_INPUT_API
+- struct input_event ev;
+-#else
+- struct ts_event *evt;
+- struct h3600_ts_event *hevt;
+- struct mk712_ts_event *mevt;
+- struct arctic2_ts_event *aevt;
+- struct collie_ts_event *collie_evt;
+- struct corgi_ts_event *corgi_evt;
+- char *tseventtype=NULL;
+- char *defaulttseventtype="UCB1x00";
+-#endif /* USE_INPUT_API */
+- int ret;
+- int total = 0;
+-
+-#ifdef USE_INPUT_API
+-#ifdef EV_SYN
+- /* This version uses EV_SYN */
+- while (total < nr) {
+- ret = read(ts->fd, &ev, sizeof(struct input_event));
+- if (ret < sizeof(struct input_event)) {
+- total = -1;
+- break;
+- }
+-
+- switch (ev.type) {
+- case EV_SYN:
+- /* Fill out a new complete event */
+- samp->x = ts->current_x;
+- samp->y = ts->current_y;
+- samp->pressure = ts->current_p;
+- samp->tv = ev.time;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------> %d %d %d %d.%d\n",
+- samp->x, samp->y, samp->pressure, samp->tv.tv_sec, samp->tv.tv_usec);
+-#endif /*DEBUG*/
+- samp++;
+- total++;
+- break;
+- case EV_ABS:
+- switch (ev.code) {
+- case ABS_X:
+- ts->current_x = ev.value;
+- break;
+- case ABS_Y:
+- ts->current_y = ev.value;
+- break;
+- case ABS_PRESSURE:
+- ts->current_p = ev.value;
+- break;
+- }
+- break;
+- }
+- }
+- ret = total;
+-#else /* This version doesn't use EV_SYN */
+- /* warning: maybe those static vars should be part of the tsdev struct? */
+- static int curr_x = 0, curr_y = 0, curr_p = 0;
+- static int got_curr_x = 0, got_curr_y = 0;
+- int got_curr_p = 0;
+- int next_x, next_y;
+- int got_next_x = 0, got_next_y = 0;
+- int got_tstamp = 0;
+-
+- while (total < nr) {
+- ret = read(ts->fd, &ev, sizeof(struct input_event));
+- if (ret < sizeof(struct input_event)) break;
+-
+- /*
+- * We must filter events here. We need to look for
+- * a set of input events that will correspond to a
+- * complete ts event. Also need to be aware that
+- * repeated input events are filtered out by the kernel.
+- *
+- * We assume the normal sequence is:
+- * ABS_X -> ABS_Y -> ABS_PRESSURE
+- * If that sequence goes backward then we got a different
+- * ts event. If some are missing then they didn't change.
+- */
+- if (ev.type == EV_ABS) switch (ev.code) {
+- case ABS_X:
+- if (!got_curr_x && !got_curr_y) {
+- got_curr_x = 1;
+- curr_x = ev.value;
+- } else {
+- got_next_x = 1;
+- next_x = ev.value;
+- }
+- break;
+- case ABS_Y:
+- if (!got_curr_y) {
+- got_curr_y = 1;
+- curr_y = ev.value;
+- } else {
+- got_next_y = 1;
+- next_y = ev.value;
+- }
+- break;
+- case ABS_PRESSURE:
+- got_curr_p = 1;
+- curr_p = ev.value;
+- break;
+- }
+-
+- /* go back if we just got irrelevant events so far */
+- if (!got_curr_x && !got_curr_y && !got_curr_p) continue;
+-
+- /* time stamp with the first valid event only */
+- if (!got_tstamp) {
+- got_tstamp = 1;
+- samp->tv = ev.time;
+- }
+-
+- if ( (!got_curr_x || !got_curr_y) && !got_curr_p &&
+- !got_next_x && !got_next_y ) {
+- /*
+- * The current event is not complete yet.
+- * Give the kernel a chance to feed us more.
+- */
+- struct timeval tv = {0, 0};
+- fd_set fdset;
+- FD_ZERO(&fdset);
+- FD_SET(ts->fd, &fdset);
+- ret = select(ts->fd+1, &fdset, NULL, NULL, &tv);
+- if (ret == 1) continue;
+- if (ret == -1) break;
+- }
+-
+- /* We consider having a complete ts event */
+- samp->x = curr_x;
+- samp->y = curr_y;
+- samp->pressure = curr_p;
++ int result = ts->list_raw->ops->read(ts->list, samp, nr);
+ #ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- samp++;
+- total++;
+-
+- /* get ready for next event */
+- if (got_next_x) curr_x = next_x; else got_curr_x = 0;
+- if (got_next_y) curr_y = next_y; else got_curr_y = 0;
+- got_next_x = got_next_y = got_tstamp = 0;
+- }
+-
+- if (ret) ret = -1;
+- if (total) ret = total;
++ fprintf(stderr,"TS_READ_RAW----> x = %d, y = %d, pressure = %d\n", samp->x, samp->y, samp->pressure);
+ #endif
+-
+-#else
+- tseventtype = getenv("TSLIB_TSEVENTTYPE");
+- if(tseventtype==NULL) tseventtype=defaulttseventtype;
+-
+- if( strcmp(tseventtype,"H3600") == 0) { /* iPAQ style h3600 touchscreen events */
+- hevt = alloca(sizeof(*hevt) * nr);
+- ret = read(ts->fd, hevt, sizeof(*hevt) * nr);
+- if(ret > 0) {
+- int nr = ret / sizeof(*hevt);
+- while(ret >= sizeof(*hevt)) {
+- samp->x = hevt->x;
+- samp->y = hevt->y;
+- samp->pressure = hevt->pressure;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- gettimeofday(&samp->tv,NULL);
+- samp++;
+- hevt++;
+- ret -= sizeof(*hevt);
+- }
+- } else {
+- return -1;
+- }
+- } else if( strcmp(tseventtype,"MK712") == 0) { /* Hitachi Webpad events */
+- mevt = alloca(sizeof(*mevt) * nr);
+- ret = read(ts->fd, mevt, sizeof(*mevt) * nr);
+- if(ret > 0) {
+- int nr = ret / sizeof(*mevt);
+- while(ret >= sizeof(*mevt)) {
+- samp->x = (short)mevt->x;
+- samp->y = (short)mevt->y;
+- if(mevt->header==0)
+- samp->pressure=1;
+- else
+- samp->pressure=0;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- gettimeofday(&samp->tv,NULL);
+- samp++;
+- mevt++;
+- ret -= sizeof(*mevt);
+- }
+- } else {
+- return -1;
+- }
+-
+- } else if( strcmp(tseventtype,"ARCTIC2") == 0) { /* IBM Arctic II events */
+- aevt = alloca(sizeof(*aevt) * nr);
+- ret = read(ts->fd, aevt, sizeof(*aevt) * nr);
+- if(ret > 0) {
+- int nr = ret / sizeof(*aevt);
+- while(ret >= sizeof(*aevt)) {
+- samp->x = (short)aevt->x;
+- samp->y = (short)aevt->y;
+- samp->pressure = aevt->pressure;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- gettimeofday(&samp->tv,NULL);
+- samp++;
+- aevt++;
+- ret -= sizeof(*aevt);
+- }
+- } else {
+- return -1;
+- }
+-
+- } else if( strcmp(tseventtype,"COLLIE") == 0) { /* Sharp Zaurus SL-5000d/5500 events */
+- collie_evt = alloca(sizeof(*collie_evt) * nr);
+- ret = read(ts->fd, collie_evt, sizeof(*collie_evt) * nr);
+- if(ret > 0) {
+- int nr = ret / sizeof(*collie_evt);
+- while(ret >= sizeof(*collie_evt)) {
+- samp->x = collie_evt->x;
+- samp->y = collie_evt->y;
+- samp->pressure = collie_evt->pressure;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- samp->tv.tv_usec = collie_evt->millisecs % 1000;
+- samp->tv.tv_sec = collie_evt->millisecs / 1000;
+- samp++;
+- collie_evt++;
+- ret -= sizeof(*collie_evt);
+- }
+- } else {
+- return -1;
+- }
+-
+- } else if( strcmp(tseventtype,"CORGI") == 0) { /* Sharp Zaurus SL-C700 events */
+- corgi_evt = alloca(sizeof(*corgi_evt) * nr);
+- ret = read(ts->fd, corgi_evt, sizeof(*corgi_evt) * nr);
+- if(ret > 0) {
+- int nr = ret / sizeof(*corgi_evt);
+- while(ret >= sizeof(*corgi_evt)) {
+- samp->x = corgi_evt->x;
+- samp->y = corgi_evt->y;
+- samp->pressure = corgi_evt->pressure;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- samp->tv.tv_usec = corgi_evt->millisecs % 1000;
+- samp->tv.tv_sec = corgi_evt->millisecs / 1000;
+- samp++;
+- corgi_evt++;
+- ret -= sizeof(*corgi_evt);
+- }
+- } else {
+- return -1;
+- }
+-
+- } else { /* Use normal UCB1x00 type events */
+- evt = alloca(sizeof(*evt) * nr);
+- ret = read(ts->fd, evt, sizeof(*evt) * nr);
+- if(ret > 0) {
+- int nr = ret / sizeof(*evt);
+- while(ret >= sizeof(*evt)) {
+- samp->x = evt->x;
+- samp->y = evt->y;
+- samp->pressure = evt->pressure;
+-#ifdef DEBUG
+- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+-#endif /*DEBUG*/
+- samp->tv.tv_usec = evt->stamp.tv_usec;
+- samp->tv.tv_sec = evt->stamp.tv_sec;
+- samp++;
+- evt++;
+- ret -= sizeof(*evt);
+- }
+- } else {
+- return -1;
+- }
+- }
+- ret = nr;
+-#endif /* USE_INPUT_API */
+-
+- return ret;
+-}
+-
+-static int __ts_read_raw(struct tslib_module_info *inf, struct ts_sample *samp, int nr)
+-{
+- return ts_read_raw(inf->dev, samp, nr);
++ return result;
+ }
+-
+-static const struct tslib_ops __ts_raw_ops =
+-{
+- read: __ts_read_raw,
+-};
+-
+-struct tslib_module_info __ts_raw =
+-{
+- next: NULL,
+- ops: &__ts_raw_ops,
+-};
+--- /dev/null
++++ tslib/src/ts_read_raw_module.c
+@@ -0,0 +1,374 @@
++/*
++ * tslib/src/ts_read_raw_module.c
++ *
++ * Original version:
++ * Copyright (C) 2001 Russell King.
++ *
++ * Rewritten for the Linux input device API:
++ * Copyright (C) 2002 Nicolas Pitre
++ *
++ * This file is placed under the LGPL. Please see the file
++ * COPYING for more details.
++ *
++ * $Id$
++ *
++ * Read raw pressure, x, y, and timestamp from a touchscreen device.
++ */
++#include "config.h"
++
++#include <stdio.h>
++
++#include <stdlib.h>
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#include <sys/time.h>
++#include <sys/types.h>
++
++#ifdef USE_INPUT_API
++#include <linux/input.h>
++#else
++struct ts_event { /* Used in UCB1x00 style touchscreens (the default) */
++ unsigned short pressure;
++ unsigned short x;
++ unsigned short y;
++ unsigned short pad;
++ struct timeval stamp;
++};
++struct h3600_ts_event { /* Used in the Compaq IPAQ */
++ unsigned short pressure;
++ unsigned short x;
++ unsigned short y;
++ unsigned short pad;
++};
++struct mk712_ts_event { /* Used in the Hitachi Webpad */
++ unsigned int header;
++ unsigned int x;
++ unsigned int y;
++ unsigned int reserved;
++};
++struct arctic2_ts_event { /* Used in the IBM Arctic II */
++ signed short pressure;
++ signed int x;
++ signed int y;
++ int millisecs;
++ int flags;
++};
++struct collie_ts_event { /* Used in the Sharp Zaurus SL-5000d and SL-5500 */
++ long y;
++ long x;
++ long pressure;
++ long long millisecs;
++};
++struct corgi_ts_event { /* Used in the Sharp Zaurus SL-C700 */
++ short pressure;
++ short x;
++ short y;
++ short millisecs;
++};
++#endif /* USE_INPUT_API */
++
++#include "tslib-private.h"
++
++static int __ts_read_raw(struct tslib_module_info *inf, struct ts_sample *samp, int nr)
++{
++ struct tsdev *ts = inf->dev;
++#ifdef USE_INPUT_API
++ struct input_event ev;
++#else
++ struct ts_event *evt;
++ struct h3600_ts_event *hevt;
++ struct mk712_ts_event *mevt;
++ struct arctic2_ts_event *aevt;
++ struct collie_ts_event *collie_evt;
++ struct corgi_ts_event *corgi_evt;
++ char *tseventtype=NULL;
++ char *defaulttseventtype="UCB1x00";
++#endif /* USE_INPUT_API */
++ int ret;
++ int total = 0;
++
++#ifdef USE_INPUT_API
++#ifdef EV_SYN
++ /* This version uses EV_SYN */
++ while (total < nr) {
++ ret = read(ts->fd, &ev, sizeof(struct input_event));
++ if (ret < sizeof(struct input_event)) {
++ total = -1;
++ break;
++ }
++
++ switch (ev.type) {
++ case EV_SYN:
++ /* Fill out a new complete event */
++ samp->x = ts->current_x;
++ samp->y = ts->current_y;
++ samp->pressure = ts->current_p;
++ samp->tv = ev.time;
++#ifdef DEBUG
++ fprintf(stderr,"RAW---------------------> %d %d %d %d.%d\n",
++ samp->x, samp->y, samp->pressure, samp->tv.tv_sec, samp->tv.tv_usec);
++#endif /*DEBUG*/
++ samp++;
++ total++;
++ break;
++ case EV_ABS:
++ switch (ev.code) {
++ case ABS_X:
++ ts->current_x = ev.value;
++ break;
++ case ABS_Y:
++ ts->current_y = ev.value;
++ break;
++ case ABS_PRESSURE:
++ ts->current_p = ev.value;
++ break;
++ }
++ break;
++ }
++ }
++ ret = total;
++#else /* This version doesn't use EV_SYN */
++ /* warning: maybe those static vars should be part of the tsdev struct? */
++ static int curr_x = 0, curr_y = 0, curr_p = 0;
++ static int got_curr_x = 0, got_curr_y = 0;
++ int got_curr_p = 0;
++ int next_x, next_y;
++ int got_next_x = 0, got_next_y = 0;
++ int got_tstamp = 0;
++
++ while (total < nr) {
++ ret = read(ts->fd, &ev, sizeof(struct input_event));
++ if (ret < sizeof(struct input_event)) break;
++
++ /*
++ * We must filter events here. We need to look for
++ * a set of input events that will correspond to a
++ * complete ts event. Also need to be aware that
++ * repeated input events are filtered out by the kernel.
++ *
++ * We assume the normal sequence is:
++ * ABS_X -> ABS_Y -> ABS_PRESSURE
++ * If that sequence goes backward then we got a different
++ * ts event. If some are missing then they didn't change.
++ */
++ if (ev.type == EV_ABS) switch (ev.code) {
++ case ABS_X:
++ if (!got_curr_x && !got_curr_y) {
++ got_curr_x = 1;
++ curr_x = ev.value;
++ } else {
++ got_next_x = 1;
++ next_x = ev.value;
++ }
++ break;
++ case ABS_Y:
++ if (!got_curr_y) {
++ got_curr_y = 1;
++ curr_y = ev.value;
++ } else {
++ got_next_y = 1;
++ next_y = ev.value;
++ }
++ break;
++ case ABS_PRESSURE:
++ got_curr_p = 1;
++ curr_p = ev.value;
++ break;
++ }
++
++ /* go back if we just got irrelevant events so far */
++ if (!got_curr_x && !got_curr_y && !got_curr_p) continue;
++
++ /* time stamp with the first valid event only */
++ if (!got_tstamp) {
++ got_tstamp = 1;
++ samp->tv = ev.time;
++ }
++
++ if ( (!got_curr_x || !got_curr_y) && !got_curr_p &&
++ !got_next_x && !got_next_y ) {
++ /*
++ * The current event is not complete yet.
++ * Give the kernel a chance to feed us more.
++ */
++ struct timeval tv = {0, 0};
++ fd_set fdset;
++ FD_ZERO(&fdset);
++ FD_SET(ts->fd, &fdset);
++ ret = select(ts->fd+1, &fdset, NULL, NULL, &tv);
++ if (ret == 1) continue;
++ if (ret == -1) break;
++ }
++
++ /* We consider having a complete ts event */
++ samp->x = curr_x;
++ samp->y = curr_y;
++ samp->pressure = curr_p;
++#ifdef DEBUG
++ fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
++#endif /*DEBUG*/
++ samp++;
++ total++;
++
++ /* get ready for next event */
++ if (got_next_x) curr_x = next_x; else got_curr_x = 0;
++ if (got_next_y) curr_y = next_y; else got_curr_y = 0;
++ got_next_x = got_next_y = got_tstamp = 0;
++ }
++
++ if (ret) ret = -1;
++ if (total) ret = total;
++#endif
++
++#else
++ tseventtype = getenv("TSLIB_TSEVENTTYPE");
++ if(tseventtype==NULL) tseventtype=defaulttseventtype;
++
++ if( strcmp(tseventtype,"H3600") == 0) { /* iPAQ style h3600 touchscreen events */
++ hevt = alloca(sizeof(*hevt) * nr);
++ ret = read(ts->fd, hevt, sizeof(*hevt) * nr);
++ if(ret > 0) {
++ int nr = ret / sizeof(*hevt);
++ while(ret >= sizeof(*hevt)) {
++ samp->x = hevt->x;
++ samp->y = hevt->y;
++ samp->pressure = hevt->pressure;
++#ifdef DEBUG
++ fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
++#endif /*DEBUG*/
++ gettimeofday(&samp->tv,NULL);
++ samp++;
++ hevt++;
++ ret -= sizeof(*hevt);
++ }
++ } else {
++ return -1;
++ }
++ } else if( strcmp(tseventtype,"MK712") == 0) { /* Hitachi Webpad events */
++ mevt = alloca(sizeof(*mevt) * nr);
++ ret = read(ts->fd, mevt, sizeof(*mevt) * nr);
++ if(ret > 0) {
++ int nr = ret / sizeof(*mevt);
++ while(ret >= sizeof(*mevt)) {
++ samp->x = (short)mevt->x;
++ samp->y = (short)mevt->y;
++ if(mevt->header==0)
++ samp->pressure=1;
++ else
++ samp->pressure=0;
++#ifdef DEBUG
++ fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
++#endif /*DEBUG*/
++ gettimeofday(&samp->tv,NULL);
++ samp++;
++ mevt++;
++ ret -= sizeof(*mevt);
++ }
++ } else {
++ return -1;
++ }
++
++ } else if( strcmp(tseventtype,"ARCTIC2") == 0) { /* IBM Arctic II events */
++ aevt = alloca(siz