aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/ts_filter.h
diff options
context:
space:
mode:
authorNelson Castillo <arhuaco@freaks-unidos.net>2009-03-10 12:04:05 +0000
committerAndy Green <agreen@octopus.localdomain>2009-03-10 12:04:05 +0000
commitbd88fa696f505a8a71484341e4fcde581b2d12a6 (patch)
treebca483a0c57848ca6d122907c42a0c7c04fbeb4a /drivers/input/touchscreen/ts_filter.h
parent45aeeebf673b03329c423c2382a836ca878dd851 (diff)
Improve filter API and update filters
This patch turns upstream feedback into API modifications and code improvements. There will be more patches implementing upstream corrections but this one is the that will make most of the invasive changes and make the most important improvements to the API. Tested in a GTA02/rev06. The goals of this patch are: * Replace recursive calls with iteration. * General code improvements. * Make ts_filter_mean.c a reference for the rest of the filters. * Make the (almost)minimum number of changes to the other filters so that they compile and work, patches for cleaning these up will come next. * Filters should do what they were doing before. Some important changes: * Move "struct ts_filter tsf" in the private structures to force a crash (or break things) if we forget to remove an open-coded cast. * ts_filter.c/ts_filter.h ~ API modifications. * s3c2410_ts.c: ~ Use the new API. ~ Cleanups. * ts_filter_mean.c ~ Replace with a simple mean. ~ Use as a reference for the new API. ~ Move private structure from the .h to the .c. * ts_filter_group.c ~ Update to use the new API. * ts_filter_median.c ~ Update to use the new API. * ts_filter_linear.c ~ Remove functions that are no longer needed. Note: I might leave some TODOs and FIXMEs with this patch. Most of them will be removed shortly. Signed-off-by: Nelson Castillo <arhuaco@freaks-unidos.net>
Diffstat (limited to 'drivers/input/touchscreen/ts_filter.h')
-rw-r--r--drivers/input/touchscreen/ts_filter.h81
1 files changed, 61 insertions, 20 deletions
diff --git a/drivers/input/touchscreen/ts_filter.h b/drivers/input/touchscreen/ts_filter.h
index 3746e45bccc..b5e8c7c3845 100644
--- a/drivers/input/touchscreen/ts_filter.h
+++ b/drivers/input/touchscreen/ts_filter.h
@@ -4,7 +4,7 @@
/*
* Touchscreen filter.
*
- * (c) 2008 Andy Green <andy@openmoko.com>
+ * (c) 2008,2009 Andy Green <andy@openmoko.com>
*/
#include <linux/platform_device.h>
@@ -17,11 +17,41 @@ struct ts_filter;
/* Operations that a filter can perform. */
struct ts_filter_api {
+ /* Create the filter - mandatory. */
struct ts_filter * (*create)(struct platform_device *pdev, void *config,
int count_coords);
- void (*destroy)(struct platform_device *pdev, struct ts_filter *filter);
+ /* Destroy the filter - mandatory. */
+ void (*destroy)(struct ts_filter *filter);
+ /* Clear the filter - optional. */
void (*clear)(struct ts_filter *filter);
+
+
+ /*
+ * The next three API functions only make sense if all of them are
+ * set for a filter. If a filter has the next three methods then
+ * it can propagate coordinates in the chain.
+ */
+
+ /*
+ * Process the filter.
+ * It returns non-zero if the filter reaches an error.
+ */
int (*process)(struct ts_filter *filter, int *coords);
+ /*
+ * Is the filter ready to return a point?
+ * Please do not code side effects in this function.
+ */
+ int (*haspoint)(struct ts_filter *filter);
+ /*
+ * Get a point.
+ * Do not call unless the filter actually has a point to deliver.
+ */
+ void (*getpoint)(struct ts_filter *filter, int *coords);
+
+ /*
+ * Scale the points - optional.
+ * A filter could only scale coordinates.
+ */
void (*scale)(struct ts_filter *filter, int *coords);
};
@@ -31,32 +61,43 @@ struct ts_filter_api {
* 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];
+ struct ts_filter_api *api; /* operations for this filter */
+ int count_coords; /* how many coordinates to process */
+ int coords[MAX_TS_FILTER_COORDS]; /* count_coords coordinates */
};
+#ifdef CONFIG_TOUCHSCREEN_FILTER
+
/*
- * 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.
+ * Helper to create a filter chain. It will allocate an array of
+ * null-terminated pointers to filters.
*/
-
-#ifdef CONFIG_TOUCHSCREEN_FILTER
-extern int ts_filter_create_chain(struct platform_device *pdev,
- struct ts_filter_api **api, void **config,
- struct ts_filter **arr, int count_coords);
+extern struct ts_filter **ts_filter_chain_create(
+ struct platform_device *pdev,
+ struct ts_filter_api **api, void **config, int count_coords);
/* Helper to destroy a whole chain from the list of filter pointers. */
+extern void ts_filter_chain_destroy(struct ts_filter **arr);
+
+/* Helper to call the clear API function */
+extern void ts_filter_chain_clear(struct ts_filter **arr);
+
+/*
+ * Try to get one point. Returns 0 if no points are available.
+ * coords will be used as temporal space, thus you supply a point
+ * using coords but you shouldn't rely on its value on return unless
+ * it returns a nonzero value that is not -1.
+ * If one of the filters find an error then this function will
+ * return -1.
+ */
+int ts_filter_chain_feed(struct ts_filter **arr, int *coords);
-extern void ts_filter_destroy_chain(struct platform_device *pdev,
- struct ts_filter **arr);
-#else
-#define ts_filter_create_chain(pdev, api, config, arr, count_coords) (0)
-#define ts_filter_destroy_chain(pdev, arr) do { } while (0)
+#else /* !CONFIG_TOUCHSCREEN_FILTER */
+#define ts_filter_chain_create(pdev, api, config, arr, count_coords) (0)
+#define ts_filter_chain_destroy(pdev, arr) do { } while (0)
+#define ts_filter_chain_clear(arr) do { } while (0)
+#define ts_filter_chain_feed(arr, coords) (1)
#endif
#endif