aboutsummaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authormerge <null@invalid>2009-01-19 00:47:51 +0000
committerAndy Green <agreen@octopus.localdomain>2009-01-19 00:47:51 +0000
commit3779b1cf0be55e0affcff56379cdfb8a07fdd840 (patch)
treef7b05d2e2188885a37ac3be6fd3c0bf075fe05ac /drivers/input
parent3a01f98ede89d2d0791393c43625e824f03c3065 (diff)
MERGE-via-pending-tracking-hist-MERGE-via-stable-tracking-fix-touchscreen-filter-include-1232325217
pending-tracking-hist top was MERGE-via-stable-tracking-fix-touchscreen-filter-include-1232325217 / d063e8c6d85c48de80b3d158bfa98d5a97149711 ... parent commitmessage: From: merge <null@invalid> MERGE-via-stable-tracking-hist-fix-touchscreen-filter-include stable-tracking-hist top was fix-touchscreen-filter-include / bb151f28fc8e8923baad96e0f3e8f0ae57af95f5 ... parent commitmessage: From: Nelson Castillo <arhuaco@freaks-unidos.net> Fix touchscreen filter includes Fix #includes to make the kernel compile again. Signed-off-by: Nelson Castillo <arhuaco@freaks-unidos.net>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/Kconfig2
-rw-r--r--drivers/input/touchscreen/s3c2410_ts.c2
-rw-r--r--drivers/input/touchscreen/ts_filter.c41
-rw-r--r--drivers/input/touchscreen/ts_filter.h57
-rw-r--r--drivers/input/touchscreen/ts_filter_group.c2
-rw-r--r--drivers/input/touchscreen/ts_filter_group.h39
-rw-r--r--drivers/input/touchscreen/ts_filter_linear.c11
-rw-r--r--drivers/input/touchscreen/ts_filter_linear.h64
-rw-r--r--drivers/input/touchscreen/ts_filter_mean.c12
-rw-r--r--drivers/input/touchscreen/ts_filter_mean.h34
-rw-r--r--drivers/input/touchscreen/ts_filter_median.c12
-rw-r--r--drivers/input/touchscreen/ts_filter_median.h36
12 files changed, 275 insertions, 37 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 5db7a67d5b2..014a9e7a1ef 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -50,7 +50,7 @@ config TOUCHSCREEN_FILTER_LINEAR
depends on INPUT_TOUCHSCREEN && TOUCHSCREEN_FILTER
default Y
help
- Say Y here if you want to use the Mean touchscreen filter, it
+ Say Y here if you want to use the Linear touchscreen filter, it
enables the use of calibration data for the touchscreen.
endif
diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 46a33dfddc1..1a930a2aacc 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -65,7 +65,7 @@
#include <plat/regs-adc.h>
-#include <linux/ts_filter.h>
+#include "ts_filter.h"
/* For ts.dev.id.version */
#define S3C2410TSVERSION 0x0101
diff --git a/drivers/input/touchscreen/ts_filter.c b/drivers/input/touchscreen/ts_filter.c
index 15083882e1c..832844da55f 100644
--- a/drivers/input/touchscreen/ts_filter.c
+++ b/drivers/input/touchscreen/ts_filter.c
@@ -18,11 +18,13 @@
#include <linux/kernel.h>
#include <linux/device.h>
-#include <linux/ts_filter.h>
+#include "ts_filter.h"
+
+static DEFINE_MUTEX(chain_mutex);
int ts_filter_create_chain(struct platform_device *pdev,
struct ts_filter_api **api, void **config,
- struct ts_filter **list, int count_coords)
+ struct ts_filter **arr, int count_coords)
{
int count = 0;
struct ts_filter *last = NULL;
@@ -30,35 +32,42 @@ int ts_filter_create_chain(struct platform_device *pdev,
if (!api)
return 0;
- while (*api && count < MAX_TS_FILTER_CHAIN) {
- *list = ((*api)->create)(pdev, *config++, count_coords);
- if (!*list) {
+ mutex_lock(&chain_mutex);
+
+ while (*api) {
+ *arr = ((*api)->create)(pdev, *config++, count_coords);
+ if (!*arr) {
printk(KERN_ERR "Filter %d failed init\n", count);
return count;
}
- (*list)->api = *api++;
+ (*arr)->api = *api++;
if (last)
- last->next = *list;
- last = *list;
- list++;
+ last->next = *arr;
+ last = *arr;
+ arr++;
count++;
}
+ mutex_unlock(&chain_mutex);
+
return count;
}
EXPORT_SYMBOL_GPL(ts_filter_create_chain);
void ts_filter_destroy_chain(struct platform_device *pdev,
- struct ts_filter **list)
+ struct ts_filter **arr)
{
- struct ts_filter **first;
- int count = 0;
+ struct ts_filter **first = arr;
- first = list;
- while (*list && count++ < MAX_TS_FILTER_CHAIN) {
- ((*list)->api->destroy)(pdev, *list);
- list++;
+ mutex_lock(&chain_mutex);
+
+ while (*arr) {
+ ((*arr)->api->destroy)(pdev, *arr);
+ arr++;
}
*first = NULL;
+
+ mutex_unlock(&chain_mutex);
}
EXPORT_SYMBOL_GPL(ts_filter_destroy_chain);
+
diff --git a/drivers/input/touchscreen/ts_filter.h b/drivers/input/touchscreen/ts_filter.h
new file mode 100644
index 00000000000..5578e936b91
--- /dev/null
+++ b/drivers/input/touchscreen/ts_filter.h
@@ -0,0 +1,57 @@
+#ifndef __TS_FILTER_H__
+#define __TS_FILTER_H__
+
+/*
+ * Touchscreen filter.
+ *
+ * (c) 2008 Andy Green <andy@openmoko.com>
+ */
+
+#include <linux/platform_device.h>
+
+#define MAX_TS_FILTER_CHAIN 8 /* Max. filters we can chain up. */
+#define MAX_TS_FILTER_COORDS 3 /* X, Y and Z (pressure). */
+
+struct ts_filter;
+
+/* Operations that a filter can perform. */
+
+struct ts_filter_api {
+ struct ts_filter * (*create)(struct platform_device *pdev, void *config,
+ int count_coords);
+ void (*destroy)(struct platform_device *pdev, struct ts_filter *filter);
+ void (*clear)(struct ts_filter *filter);
+ int (*process)(struct ts_filter *filter, int *coords);
+ void (*scale)(struct ts_filter *filter, int *coords);
+};
+
+/*
+ * This is the common part of all filters.
+ * We use this type as an otherwise opaque handle on to
+ * the actual filter. Therefore you need one of these
+ * at the start of your actual filter struct.
+ */
+
+struct ts_filter {
+ struct ts_filter *next; /* Next in chain. */
+ struct ts_filter_api *api; /* Operations to use for this object. */
+ int count_coords;
+ int coords[MAX_TS_FILTER_COORDS];
+};
+
+/*
+ * Helper to create a filter chain from an array of API pointers and
+ * array of config ints. Leaves pointers to created filters in arr
+ * array and fills in ->next pointers to create the chain.
+ */
+
+extern int ts_filter_create_chain(struct platform_device *pdev,
+ struct ts_filter_api **api, void **config,
+ struct ts_filter **arr, int count_coords);
+
+/* Helper to destroy a whole chain from the list of filter pointers. */
+
+extern void ts_filter_destroy_chain(struct platform_device *pdev,
+ struct ts_filter **arr);
+
+#endif
diff --git a/drivers/input/touchscreen/ts_filter_group.c b/drivers/input/touchscreen/ts_filter_group.c
index 73e3625a5a6..f2ecd92916e 100644
--- a/drivers/input/touchscreen/ts_filter_group.c
+++ b/drivers/input/touchscreen/ts_filter_group.c
@@ -40,7 +40,7 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/sort.h>
-#include <linux/ts_filter_group.h>
+#include "ts_filter_group.h"
static void ts_filter_group_clear_internal(struct ts_filter_group *tsfg,
int attempts)
diff --git a/drivers/input/touchscreen/ts_filter_group.h b/drivers/input/touchscreen/ts_filter_group.h
new file mode 100644
index 00000000000..c411080eae2
--- /dev/null
+++ b/drivers/input/touchscreen/ts_filter_group.h
@@ -0,0 +1,39 @@
+#ifndef __TS_FILTER_GROUP_H__
+#define __TS_FILTER_GROUP_H__
+
+#include "ts_filter.h"
+
+/*
+ * Touchscreen group filter.
+ *
+ * Copyright (C) 2008 by Openmoko, Inc.
+ * Author: Nelson Castillo <arhuaco@freaks-unidos.net>
+ *
+ */
+
+struct ts_filter_group_configuration {
+ int extent;
+ int close_enough;
+ int threshold;
+ int attempts;
+};
+
+struct ts_filter_group {
+ struct ts_filter tsf;
+ struct ts_filter_group_configuration *config;
+
+ int N; /* How many samples we have */
+ int *samples[MAX_TS_FILTER_COORDS]; /* the samples, our input */
+
+ int *group_size; /* used for temporal computations */
+ int *sorted_samples; /* used for temporal computations */
+
+ int range_max[MAX_TS_FILTER_COORDS]; /* max computed ranges */
+ int range_min[MAX_TS_FILTER_COORDS]; /* min computed ranges */
+
+ int tries_left; /* We finish if we don't get enough samples */
+};
+
+extern struct ts_filter_api ts_filter_group_api;
+
+#endif
diff --git a/drivers/input/touchscreen/ts_filter_linear.c b/drivers/input/touchscreen/ts_filter_linear.c
index 4803e17ae49..c336252d0ff 100644
--- a/drivers/input/touchscreen/ts_filter_linear.c
+++ b/drivers/input/touchscreen/ts_filter_linear.c
@@ -24,15 +24,13 @@
*
*/
-#include <linux/ts_filter_linear.h>
+#include "ts_filter_linear.h"
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/string.h>
-/*
- * sysfs functions
- */
+/* sysfs functions */
static ssize_t const_attr_show(struct kobject *kobj,
@@ -82,9 +80,7 @@ static ssize_t const_store(struct const_obj *obj, struct const_attribute *attr,
return count;
}
-/*
- * filter functions
- */
+/* filter functions */
static struct ts_filter *ts_filter_linear_create(struct platform_device *pdev,
void *conf, int count_coords)
@@ -118,7 +114,6 @@ static struct ts_filter *ts_filter_linear_create(struct platform_device *pdev,
tsfl->const_ktype.default_attrs = tsfl->attrs;
tsfl->c_obj.tsfl = tsfl; /* kernel frees tsfl in const_release */
- /* TODO: /sys/ts-calibration is not OK */
ret = kobject_init_and_add(&tsfl->c_obj.kobj, &tsfl->const_ktype,
&pdev->dev.kobj, "calibration");
if (ret) {
diff --git a/drivers/input/touchscreen/ts_filter_linear.h b/drivers/input/touchscreen/ts_filter_linear.h
new file mode 100644
index 00000000000..fc27cf77228
--- /dev/null
+++ b/drivers/input/touchscreen/ts_filter_linear.h
@@ -0,0 +1,64 @@
+#ifndef __TS_FILTER_LINEAR_H__
+#define __TS_FILTER_LINEAR_H__
+
+#include "ts_filter.h"
+#include <linux/kobject.h>
+
+/*
+ * Touchscreen linear filter.
+ *
+ * Copyright (C) 2008 by Openmoko, Inc.
+ * Author: Nelson Castillo <arhuaco@freaks-unidos.net>
+ *
+ */
+
+#define TS_FILTER_LINEAR_NCONSTANTS 7
+
+/* sysfs */
+
+struct ts_filter_linear;
+
+struct const_obj {
+ struct ts_filter_linear *tsfl;
+ struct kobject kobj;
+};
+
+#define to_const_obj(x) container_of(x, struct const_obj, kobj)
+
+struct const_attribute {
+ struct attribute attr;
+ ssize_t (*show)(struct const_obj *const, struct const_attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct const_obj *const, struct const_attribute *attr,
+ const char *buf, size_t count);
+};
+
+#define to_const_attr(x) container_of(x, struct const_attribute, attr)
+
+/* filter configuration */
+
+struct ts_filter_linear_configuration {
+ int constants[TS_FILTER_LINEAR_NCONSTANTS];
+ int coord0;
+ int coord1;
+};
+
+/* the filter */
+
+struct ts_filter_linear {
+ struct ts_filter tsf;
+ struct ts_filter_linear_configuration *config;
+
+ int constants[TS_FILTER_LINEAR_NCONSTANTS];
+
+ /* sysfs */
+ struct const_obj c_obj;
+ struct kobj_type const_ktype;
+ struct const_attribute kattrs[TS_FILTER_LINEAR_NCONSTANTS];
+ struct attribute *attrs[TS_FILTER_LINEAR_NCONSTANTS + 1];
+ char attr_names[TS_FILTER_LINEAR_NCONSTANTS][2];
+};
+
+extern struct ts_filter_api ts_filter_linear_api;
+
+#endif
diff --git a/drivers/input/touchscreen/ts_filter_mean.c b/drivers/input/touchscreen/ts_filter_mean.c
index a7b4a5aac6f..e4e0f2ac68e 100644
--- a/drivers/input/touchscreen/ts_filter_mean.c
+++ b/drivers/input/touchscreen/ts_filter_mean.c
@@ -34,7 +34,7 @@
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/slab.h>
-#include <linux/ts_filter_mean.h>
+#include "ts_filter_mean.h"
static void ts_filter_mean_clear_internal(struct ts_filter *tsf)
{
@@ -63,7 +63,7 @@ static struct ts_filter *ts_filter_mean_create(struct platform_device *pdev,
int n;
struct ts_filter_mean *tsfs = kzalloc(
sizeof(struct ts_filter_mean), GFP_KERNEL);
-
+
if (!tsfs)
return NULL;
@@ -112,8 +112,9 @@ static void ts_filter_mean_scale(struct ts_filter *tsf, int *coords)
(tsf->next->api->scale)(tsf->next, coords);
}
-/* give us the raw sample data in x and y, and if we return 1 then you can
- * get a filtered coordinate from tsm->x and tsm->y: if we return 0 you didn't
+/*
+ * Give us the raw sample data in x and y, and if we return 1 then you can
+ * get a filtered coordinate from tsm->x and tsm->y. If we return 0 you didn't
* fill the filter with samples yet.
*/
@@ -125,7 +126,8 @@ static int ts_filter_mean_process(struct ts_filter *tsf, int *coords)
for (n = 0; n < tsf->count_coords; n++) {
- /* has he moved far enough away that we should abandon current
+ /*
+ * Has he moved far enough away that we should abandon current
* low pass filtering state?
*/
if ((coords[n] < (tsfs->reported[n] -
diff --git a/drivers/input/touchscreen/ts_filter_mean.h b/drivers/input/touchscreen/ts_filter_mean.h
new file mode 100644
index 00000000000..44c506c99c0
--- /dev/null
+++ b/drivers/input/touchscreen/ts_filter_mean.h
@@ -0,0 +1,34 @@
+#ifndef __TS_FILTER_MEAN_H__
+#define __TS_FILTER_MEAN_H__
+
+#include "ts_filter.h"
+
+/*
+ * Touchscreen filter.
+ *
+ * mean
+ *
+ * (c) 2008 Andy Green <andy@openmoko.com>
+ */
+
+struct ts_filter_mean_configuration {
+ int bits_filter_length;
+ int averaging_threshold;
+
+ int extent;
+};
+
+struct ts_filter_mean {
+ struct ts_filter tsf;
+ struct ts_filter_mean_configuration *config;
+
+ int reported[MAX_TS_FILTER_COORDS];
+ int lowpass[MAX_TS_FILTER_COORDS];
+ int *fifo[MAX_TS_FILTER_COORDS];
+ int fhead[MAX_TS_FILTER_COORDS];
+ int ftail[MAX_TS_FILTER_COORDS];
+};
+
+extern struct ts_filter_api ts_filter_mean_api;
+
+#endif
diff --git a/drivers/input/touchscreen/ts_filter_median.c b/drivers/input/touchscreen/ts_filter_median.c
index 883ab06bff0..b3b6a9c1e5c 100644
--- a/drivers/input/touchscreen/ts_filter_median.c
+++ b/drivers/input/touchscreen/ts_filter_median.c
@@ -32,7 +32,7 @@
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/slab.h>
-#include <linux/ts_filter_median.h>
+#include "ts_filter_median.h"
static void ts_filter_median_insert(int *p, int sample, int count)
{
@@ -141,8 +141,9 @@ static void ts_filter_median_scale(struct ts_filter *tsf, int *coords)
(tsf->next->api->scale)(tsf->next, coords);
}
-/* give us the raw sample data coords, and if we return 1 then you can
- * get a filtered coordinate from coords: if we return 0 you didn't
+/*
+ * Give us the raw sample data coords, and if we return 1 then you can
+ * get a filtered coordinate from coords. If we return 0 you didn't
* fill all the filters with samples yet.
*/
@@ -169,9 +170,10 @@ static int ts_filter_median_process(struct ts_filter *tsf, int *coords)
/* discard the oldest sample in median sorted array */
tsfm->valid--;
- /* sum the middle 3 in the median sorted arrays. We don't divide back
+ /*
+ * Sum the middle 3 in the median sorted arrays. We don't divide back
* down which increases the sum resolution by a factor of 3 until the
- * scale API is called
+ * scale API is called.
*/
for (n = 0; n < tsfm->tsf.count_coords; n++)
/* perform the deletion of the oldest sample */
diff --git a/drivers/input/touchscreen/ts_filter_median.h b/drivers/input/touchscreen/ts_filter_median.h
new file mode 100644
index 00000000000..8f25e27b2aa
--- /dev/null
+++ b/drivers/input/touchscreen/ts_filter_median.h
@@ -0,0 +1,36 @@
+#ifndef __TS_FILTER_MEDIAN_H__
+#define __TS_FILTER_MEDIAN_H__
+
+#include "ts_filter.h"
+
+/*
+ * Touchscreen filter.
+ *
+ * median
+ *
+ * (c) 2008 Andy Green <andy@openmoko.com>
+ */
+
+struct ts_filter_median_configuration {
+ int extent;
+ int midpoint;
+ int decimation_threshold;
+ int decimation_above;
+ int decimation_below;
+};
+
+struct ts_filter_median {
+ struct ts_filter tsf;
+ struct ts_filter_median_configuration *config;
+
+ int decimation_count;
+ int last_issued[MAX_TS_FILTER_COORDS];
+ int valid; /* how many samples in the sort buffer are valid */
+ int *sort[MAX_TS_FILTER_COORDS]; /* samples taken for median */
+ int *fifo[MAX_TS_FILTER_COORDS]; /* samples taken for median */
+ int pos; /* where we are in the fifo sample memory */
+};
+
+extern struct ts_filter_api ts_filter_median_api;
+
+#endif