From 0328f2d7844b000c71650a14d8479fcf98b1a58e Mon Sep 17 00:00:00 2001 From: Florian Boor Date: Wed, 15 Apr 2009 11:49:06 +0200 Subject: linux: initial micro2440 support for 2.6.29 using mini2440 kernel patches. --- ...rted-the-s3c2410-touchscreen-from-openmok.patch | 792 ++ ...Backported-openmoko-s-touchscreen-filters.patch | 1260 ++ .../micro2440/0003-VENDOR-armworks-logo.patch | 12079 +++++++++++++++++++ .../0004-920T-Use-specific-920t-mtune.patch | 28 + ...mp-fix-for-the-40-relocation-binutils-pro.patch | 49 + ...the-machine-code-to-get-the-BBT-table-fro.patch | 49 + .../0007-MINI2440-Add-machine-support.patch | 793 ++ ...I2440-Delays-command-check-response-on-SD.patch | 30 + .../0009-MINI2440-Rename-the-SoC-tty-names.patch | 35 + ...INI2440-creates-a-mini2440_defconfig-file.patch | 2067 ++++ .../0011-MINI2440-Add-touchscreen-support.patch | 192 + ...2-GRO-Disable-GRO-on-legacy-netif_rx-path.patch | 54 + recipes/linux/linux-2.6.29/micro2440/defconfig | 2053 ++++ recipes/linux/linux_2.6.29.bb | 16 + 14 files changed, 19497 insertions(+) create mode 100644 recipes/linux/linux-2.6.29/micro2440/0001-S3C-Backported-the-s3c2410-touchscreen-from-openmok.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0002-S3C-Backported-openmoko-s-touchscreen-filters.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0003-VENDOR-armworks-logo.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0004-920T-Use-specific-920t-mtune.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0005-920T-Temp-fix-for-the-40-relocation-binutils-pro.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0006-S3C-Allow-the-machine-code-to-get-the-BBT-table-fro.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0007-MINI2440-Add-machine-support.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0008-MINI2440-Delays-command-check-response-on-SD.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0009-MINI2440-Rename-the-SoC-tty-names.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0010-MINI2440-creates-a-mini2440_defconfig-file.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0011-MINI2440-Add-touchscreen-support.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/0012-GRO-Disable-GRO-on-legacy-netif_rx-path.patch create mode 100644 recipes/linux/linux-2.6.29/micro2440/defconfig (limited to 'recipes') diff --git a/recipes/linux/linux-2.6.29/micro2440/0001-S3C-Backported-the-s3c2410-touchscreen-from-openmok.patch b/recipes/linux/linux-2.6.29/micro2440/0001-S3C-Backported-the-s3c2410-touchscreen-from-openmok.patch new file mode 100644 index 0000000000..4e3b3001f8 --- /dev/null +++ b/recipes/linux/linux-2.6.29/micro2440/0001-S3C-Backported-the-s3c2410-touchscreen-from-openmok.patch @@ -0,0 +1,792 @@ +From d13aef4d7aff3b01ea349a07b899debe094bf33e Mon Sep 17 00:00:00 2001 +From: Michel Pollet +Date: Fri, 13 Mar 2009 18:43:43 +0000 +Subject: [PATCH] S3C: Backported the s3c2410 touchscreen from openmoko + +This peripheral is pretty essential for the s3c and is missing +from mainstream linux. This is a straight port of the moko +kernel. +--- + arch/arm/mach-s3c2410/include/mach/ts.h | 35 ++ + arch/arm/plat-s3c/include/plat/devs.h | 3 +- + arch/arm/plat-s3c24xx/devs.c | 19 + + arch/arm/plat-s3c24xx/s3c244x.c | 3 + + drivers/input/touchscreen/Kconfig | 18 + + drivers/input/touchscreen/Makefile | 1 + + drivers/input/touchscreen/s3c2410_ts.c | 609 +++++++++++++++++++++++++++++++ + 7 files changed, 687 insertions(+), 1 deletions(-) + create mode 100644 arch/arm/mach-s3c2410/include/mach/ts.h + create mode 100644 drivers/input/touchscreen/s3c2410_ts.c + +diff --git a/arch/arm/mach-s3c2410/include/mach/ts.h b/arch/arm/mach-s3c2410/include/mach/ts.h +new file mode 100644 +index 0000000..1b451ea +--- /dev/null ++++ b/arch/arm/mach-s3c2410/include/mach/ts.h +@@ -0,0 +1,35 @@ ++/* arch/arm/mach-s3c2410/include/mach/ts.h ++ * ++ * Copyright (c) 2005 Arnaud Patard ++ * ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ * ++ * ++ * Changelog: ++ * 24-Mar-2005 RTP Created file ++ * 03-Aug-2005 RTP Renamed to ts.h ++ */ ++ ++#ifndef __ASM_ARM_TS_H ++#define __ASM_ARM_TS_H ++ ++#include <../drivers/input/touchscreen/ts_filter.h> ++ ++struct s3c2410_ts_mach_info { ++ int delay; ++ int presc; ++ /* array of pointers to filter APIs we want to use, in order ++ * ends on first NULL, all NULL is OK ++ */ ++ struct ts_filter_api *filter_sequence[MAX_TS_FILTER_CHAIN]; ++ /* array of configuration ints, one for each filter above */ ++ void *filter_config[MAX_TS_FILTER_CHAIN]; ++}; ++ ++void set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info); ++ ++#endif /* __ASM_ARM_TS_H */ ++ +diff --git a/arch/arm/plat-s3c/include/plat/devs.h b/arch/arm/plat-s3c/include/plat/devs.h +index 6b1b523..cf160ab 100644 +--- a/arch/arm/plat-s3c/include/plat/devs.h ++++ b/arch/arm/plat-s3c/include/plat/devs.h +@@ -45,10 +45,11 @@ extern struct platform_device s3c_device_nand; + + extern struct platform_device s3c_device_usbgadget; + ++extern struct platform_device s3c_device_ts; ++ + /* s3c2440 specific devices */ + + #ifdef CONFIG_CPU_S3C2440 + + extern struct platform_device s3c_device_camif; +- + #endif +diff --git a/arch/arm/plat-s3c24xx/devs.c b/arch/arm/plat-s3c24xx/devs.c +index 16ac01d..a3f8102 100644 +--- a/arch/arm/plat-s3c24xx/devs.c ++++ b/arch/arm/plat-s3c24xx/devs.c +@@ -26,6 +26,8 @@ + #include + #include + #include ++#include ++#include + #include + + #include +@@ -229,6 +231,23 @@ struct platform_device s3c_device_nand = { + + EXPORT_SYMBOL(s3c_device_nand); + ++/* Touchscreen */ ++struct platform_device s3c_device_ts = { ++ .name = "s3c2410-ts", ++ .id = -1, ++}; ++ ++EXPORT_SYMBOL(s3c_device_ts); ++ ++static struct s3c2410_ts_mach_info s3c2410ts_info; ++ ++void set_s3c2410ts_info(struct s3c2410_ts_mach_info *hard_s3c2410ts_info) ++{ ++ memcpy(&s3c2410ts_info,hard_s3c2410ts_info,sizeof(struct s3c2410_ts_mach_info)); ++ s3c_device_ts.dev.platform_data = &s3c2410ts_info; ++} ++EXPORT_SYMBOL(set_s3c2410ts_info); ++ + /* USB Device (Gadget)*/ + + static struct resource s3c_usbgadget_resource[] = { +diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c +index c1de6bb..df78a15 100644 +--- a/arch/arm/plat-s3c24xx/s3c244x.c ++++ b/arch/arm/plat-s3c24xx/s3c244x.c +@@ -59,6 +59,8 @@ void __init s3c244x_init_uarts(struct s3c2410_uartcfg *cfg, int no) + s3c24xx_init_uartdevs("s3c2440-uart", s3c2410_uart_resources, cfg, no); + } + ++extern struct platform_device s3c_device_ts; ++ + void __init s3c244x_map_io(void) + { + /* register our io-tables */ +@@ -70,6 +72,7 @@ void __init s3c244x_map_io(void) + s3c_device_sdi.name = "s3c2440-sdi"; + s3c_device_i2c0.name = "s3c2440-i2c"; + s3c_device_nand.name = "s3c2440-nand"; ++ s3c_device_ts.name = "s3c2440-ts"; + s3c_device_usbgadget.name = "s3c2440-usbgadget"; + } + +diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig +index bb6486a..9076492 100644 +--- a/drivers/input/touchscreen/Kconfig ++++ b/drivers/input/touchscreen/Kconfig +@@ -79,6 +79,24 @@ config TOUCHSCREEN_FUJITSU + To compile this driver as a module, choose M here: the + module will be called fujitsu-ts. + ++config TOUCHSCREEN_S3C2410 ++ tristate "Samsung S3C2410 touchscreen input driver" ++ depends on ARCH_S3C2410 && INPUT && INPUT_TOUCHSCREEN ++ select SERIO ++ help ++ Say Y here if you have the s3c2410 touchscreen. ++ ++ If unsure, say N. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called s3c2410_ts. ++ ++config TOUCHSCREEN_S3C2410_DEBUG ++ boolean "Samsung S3C2410 touchscreen debug messages" ++ depends on TOUCHSCREEN_S3C2410 ++ help ++ Select this if you want debug messages ++ + config TOUCHSCREEN_GUNZE + tristate "Gunze AHL-51S touchscreen" + select SERIO +diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile +index d3375af..fbcde99 100644 +--- a/drivers/input/touchscreen/Makefile ++++ b/drivers/input/touchscreen/Makefile +@@ -34,3 +34,4 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o + wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o + wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o + obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o ++obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o +diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c +new file mode 100644 +index 0000000..ea0777c +--- /dev/null ++++ b/drivers/input/touchscreen/s3c2410_ts.c +@@ -0,0 +1,609 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Copyright (c) 2004 Arnaud Patard ++ * iPAQ H1940 touchscreen support ++ * ++ * ChangeLog ++ * ++ * 2004-09-05: Herbert Pƶtzl ++ * - added clock (de-)allocation code ++ * ++ * 2005-03-06: Arnaud Patard ++ * - h1940_ -> s3c2410 (this driver is now also used on the n30 ++ * machines :P) ++ * - Debug messages are now enabled with the config option ++ * TOUCHSCREEN_S3C2410_DEBUG ++ * - Changed the way the value are read ++ * - Input subsystem should now work ++ * - Use ioremap and readl/writel ++ * ++ * 2005-03-23: Arnaud Patard ++ * - Make use of some undocumented features of the touchscreen ++ * controller ++ * ++ * 2007-05-23: Harald Welte ++ * - Add proper support for S32440 ++ * ++ * 2008-06-23: Andy Green ++ * - removed averaging system ++ * - added generic Touchscreen filter stuff ++ * ++ * 2008-11-27: Nelson Castillo ++ * - improve interrupt handling ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include ++ ++#include ++ ++#include "ts_filter.h" ++ ++/* For ts.dev.id.version */ ++#define S3C2410TSVERSION 0x0101 ++ ++#define TSC_SLEEP (S3C2410_ADCTSC_PULL_UP_DISABLE | S3C2410_ADCTSC_XY_PST(0)) ++ ++#define WAIT4INT(x) (((x)<<8) | \ ++ S3C2410_ADCTSC_YM_SEN | \ ++ S3C2410_ADCTSC_YP_SEN | \ ++ S3C2410_ADCTSC_XP_SEN | \ ++ S3C2410_ADCTSC_XY_PST(3)) ++ ++#define AUTOPST (S3C2410_ADCTSC_YM_SEN | \ ++ S3C2410_ADCTSC_YP_SEN | \ ++ S3C2410_ADCTSC_XP_SEN | \ ++ S3C2410_ADCTSC_AUTO_PST | \ ++ S3C2410_ADCTSC_XY_PST(0)) ++ ++#define DEBUG_LVL KERN_DEBUG ++ ++MODULE_AUTHOR("Arnaud Patard "); ++MODULE_DESCRIPTION("s3c2410 touchscreen driver"); ++MODULE_LICENSE("GPL"); ++ ++/* ++ * Definitions & global arrays. ++ */ ++ ++static char *s3c2410ts_name = "s3c2410 TouchScreen"; ++ ++#define TS_RELEASE_TIMEOUT (HZ >> 7 ? HZ >> 7 : 1) /* 8ms (5ms if HZ is 200) */ ++#define TS_EVENT_FIFO_SIZE (2 << 6) /* must be a power of 2 */ ++ ++#define TS_STATE_STANDBY 0 /* initial state */ ++#define TS_STATE_PRESSED 1 ++#define TS_STATE_RELEASE_PENDING 2 ++#define TS_STATE_RELEASE 3 ++ ++/* ++ * Per-touchscreen data. ++ */ ++ ++struct s3c2410ts { ++ struct input_dev *dev; ++ struct ts_filter *tsf[MAX_TS_FILTER_CHAIN]; ++ int coords[2]; /* just X and Y for us */ ++ int is_down; ++ int state; ++ struct kfifo *event_fifo; ++}; ++ ++static struct s3c2410ts ts; ++ ++static void __iomem *base_addr; ++ ++/* ++ * A few low level functions. ++ */ ++ ++static inline void s3c2410_ts_connect(void) ++{ ++ s3c2410_gpio_cfgpin(S3C2410_GPG12, S3C2410_GPG12_XMON); ++ s3c2410_gpio_cfgpin(S3C2410_GPG13, S3C2410_GPG13_nXPON); ++ s3c2410_gpio_cfgpin(S3C2410_GPG14, S3C2410_GPG14_YMON); ++ s3c2410_gpio_cfgpin(S3C2410_GPG15, S3C2410_GPG15_nYPON); ++} ++ ++static void s3c2410_ts_start_adc_conversion(void) ++{ ++ writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, ++ base_addr + S3C2410_ADCTSC); ++ writel(readl(base_addr + S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, ++ base_addr + S3C2410_ADCCON); ++} ++ ++/* ++ * Just send the input events. ++ */ ++ ++enum ts_input_event {IE_DOWN = 0, IE_UP}; ++ ++static void ts_input_report(int event, int coords[]) ++{ ++#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG ++ static char *s[] = {"down", "up"}; ++ struct timeval tv; ++ ++ do_gettimeofday(&tv); ++#endif ++ ++ if (event == IE_DOWN) { ++ input_report_abs(ts.dev, ABS_X, coords[0]); ++ input_report_abs(ts.dev, ABS_Y, coords[1]); ++ input_report_key(ts.dev, BTN_TOUCH, 1); ++ input_report_abs(ts.dev, ABS_PRESSURE, 1); ++ ++#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG ++ printk(DEBUG_LVL "T:%06d %6s (X:%03d, Y:%03d)\n", ++ (int)tv.tv_usec, s[event], coords[0], coords[1]); ++#endif ++ } else { ++ input_report_key(ts.dev, BTN_TOUCH, 0); ++ input_report_abs(ts.dev, ABS_PRESSURE, 0); ++ ++#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG ++ printk(DEBUG_LVL "T:%06d %6s\n", ++ (int)tv.tv_usec, s[event]); ++#endif ++ } ++ ++ input_sync(ts.dev); ++} ++ ++/* ++ * Manage the state of the touchscreen. ++ */ ++ ++static void event_send_timer_f(unsigned long data); ++ ++static struct timer_list event_send_timer = ++ TIMER_INITIALIZER(event_send_timer_f, 0, 0); ++ ++static void event_send_timer_f(unsigned long data) ++{ ++ static int noop_counter; ++ int event_type; ++ ++ while (__kfifo_get(ts.event_fifo, (unsigned char *)&event_type, ++ sizeof(int))) { ++ int buf[2]; ++ ++ switch (event_type) { ++ case 'D': ++ if (ts.state == TS_STATE_RELEASE_PENDING) ++ /* Ignore short UP event */ ++ ts.state = TS_STATE_PRESSED; ++ break; ++ ++ case 'U': ++ ts.state = TS_STATE_RELEASE_PENDING; ++ break; ++ ++ case 'P': ++ if (ts.is_down) /* stylus_action needs a conversion */ ++ s3c2410_ts_start_adc_conversion(); ++ ++ if (unlikely(__kfifo_get(ts.event_fifo, ++ (unsigned char *)buf, ++ sizeof(int) * 2) ++ != sizeof(int) * 2)) ++ goto ts_exit_error; ++ ++ ts_input_report(IE_DOWN, buf); ++ ts.state = TS_STATE_PRESSED; ++ break; ++ ++ default: ++ goto ts_exit_error; ++ } ++ ++ noop_counter = 0; ++ } ++ ++ if (noop_counter++ >= 1) { ++ noop_counter = 0; ++ if (ts.state == TS_STATE_RELEASE_PENDING) { ++ /* We delay the UP event for a ++ * while to avoid jitter. If we get a DOWN ++ * event we do not send it. */ ++ ++ ts_input_report(IE_UP, NULL); ++ ts.state = TS_STATE_STANDBY; ++ ++ if (ts.tsf[0]) ++ (ts.tsf[0]->api->clear)(ts.tsf[0]); ++ } ++ } else { ++ mod_timer(&event_send_timer, jiffies + TS_RELEASE_TIMEOUT); ++ } ++ ++ return; ++ ++ts_exit_error: /* should not happen unless we have a bug */ ++ printk(KERN_ERR __FILE__ ": event_send_timer_f failed\n"); ++} ++ ++/* ++ * Manage interrupts. ++ */ ++ ++static irqreturn_t stylus_updown(int irq, void *dev_id) ++{ ++ unsigned long data0; ++ unsigned long data1; ++ int event_type; ++ ++ data0 = readl(base_addr+S3C2410_ADCDAT0); ++ data1 = readl(base_addr+S3C2410_ADCDAT1); ++ ++ ts.is_down = (!(data0 & S3C2410_ADCDAT0_UPDOWN)) && ++ (!(data1 & S3C2410_ADCDAT0_UPDOWN)); ++ ++ event_type = ts.is_down ? 'D' : 'U'; ++ ++ if (unlikely(__kfifo_put(ts.event_fifo, (unsigned char *)&event_type, ++ sizeof(int)) != sizeof(int))) /* should not happen */ ++ printk(KERN_ERR __FILE__": stylus_updown lost event!\n"); ++ ++ if (ts.is_down) ++ s3c2410_ts_start_adc_conversion(); ++ else ++ writel(WAIT4INT(0), base_addr+S3C2410_ADCTSC); ++ ++ mod_timer(&event_send_timer, jiffies + 1); ++ ++ return IRQ_HANDLED; ++} ++ ++static irqreturn_t stylus_action(int irq, void *dev_id) ++{ ++ int buf[3]; ++ ++ /* grab the ADC results */ ++ ts.coords[0] = readl(base_addr + S3C2410_ADCDAT0) & ++ S3C2410_ADCDAT0_XPDATA_MASK; ++ ts.coords[1] = readl(base_addr + S3C2410_ADCDAT1) & ++ S3C2410_ADCDAT1_YPDATA_MASK; ++ ++ if (ts.tsf[0]) { /* filtering is enabled, don't use raw directly */ ++ switch ((ts.tsf[0]->api->process)(ts.tsf[0], &ts.coords[0])) { ++ case 0: /* ++ * no real sample came out of processing yet, ++ * get another raw result to feed it ++ */ ++ s3c2410_ts_start_adc_conversion(); ++ return IRQ_HANDLED; ++ case 1: /* filters are ready to deliver a sample */ ++ (ts.tsf[0]->api->scale)(ts.tsf[0], &ts.coords[0]); ++ break; ++ case -1: ++ /* error in filters, ignore the event */ ++ (ts.tsf[0]->api->clear)(ts.tsf[0]); ++ writel(WAIT4INT(1), base_addr + S3C2410_ADCTSC); ++ return IRQ_HANDLED; ++ default: ++ printk(KERN_ERR":stylus_action error\n"); ++ } ++ } ++ ++ /* We use a buffer because want an atomic operation */ ++ buf[0] = 'P'; ++ buf[1] = ts.coords[0]; ++ buf[2] = ts.coords[1]; ++ ++ if (unlikely(__kfifo_put(ts.event_fifo, (unsigned char *)buf, ++ sizeof(int) * 3) != sizeof(int) * 3)) ++ /* should not happen */ ++ printk(KERN_ERR":stylus_action error\n"); ++ ++ writel(WAIT4INT(1), base_addr + S3C2410_ADCTSC); ++ mod_timer(&event_send_timer, jiffies + 1); ++ ++ return IRQ_HANDLED; ++} ++ ++static struct clk *adc_clock; ++ ++/* ++ * The functions for inserting/removing us as a module. ++ */ ++ ++static int __init s3c2410ts_probe(struct platform_device *pdev) ++{ ++ int rc; ++ struct s3c2410_ts_mach_info *info; ++ struct input_dev *input_dev; ++ int ret = 0; ++ ++ dev_info(&pdev->dev, "Starting\n"); ++ ++ info = (struct s3c2410_ts_mach_info *)pdev->dev.platform_data; ++ ++ if (!info) ++ { ++ dev_err(&pdev->dev, "Hm... too bad: no platform data for ts\n"); ++ return -EINVAL; ++ } ++ ++#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG ++ printk(DEBUG_LVL "Entering s3c2410ts_init\n"); ++#endif ++ ++ adc_clock = clk_get(NULL, "adc"); ++ if (!adc_clock) { ++ dev_err(&pdev->dev, "failed to get adc clock source\n"); ++ return -ENOENT; ++ } ++ clk_enable(adc_clock); ++ ++#ifdef CONFIG_TOUCHSCREEN_S3C2410_DEBUG ++ printk(DEBUG_LVL "got and enabled clock\n"); ++#endif ++ ++ base_addr = ioremap(S3C2410_PA_ADC,0x20); ++ if (base_addr == NULL) { ++ dev_err(&pdev->dev, "Failed to remap register block\n"); ++ ret = -ENOMEM; ++ goto bail0; ++ } ++ ++ ++ /* If we acutally are a S3C2410: Configure GPIOs */ ++ if (!strcmp(pdev->name, "s3c2410-ts")) ++ s3c2410_ts_connect(); ++ ++ if ((info->presc & 0xff) > 0) ++ writel(S3C2410_ADCCON_PRSCEN | ++ S3C2410_ADCCON_PRSCVL(info->presc&0xFF), ++ base_addr + S3C2410_ADCCON); ++ else ++ writel(0, base_addr+S3C2410_ADCCON); ++ ++ /* Initialise registers */ ++ if ((info->delay & 0xffff) > 0) ++ writel(info->delay & 0xffff, base_addr + S3C2410_ADCDLY); ++ ++ writel(WAIT4INT(0), base_addr + S3C2410_ADCTSC); ++ ++ /* Initialise input stuff */ ++ memset(&ts, 0, sizeof(struct s3c2410ts)); ++ input_dev = input_allocate_device(); ++ ++ if (!input_dev) { ++ dev_err(&pdev->dev, "Unable to allocate the input device\n"); ++ ret = -ENOMEM; ++ goto bail1; ++ } ++ ++ ts.dev = input_dev; ++ ts.dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | ++ BIT_MASK(EV_ABS); ++ ts.dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); ++ input_set_abs_params(ts.dev, ABS_X, 0, 0x3FF, 0, 0); ++ input_set_abs_params(ts.dev, ABS_Y, 0, 0x3FF, 0, 0); ++ input_set_abs_params(ts.dev, ABS_PRESSURE, 0, 1, 0, 0); ++ ++ ts.dev->name = s3c2410ts_name; ++ ts.dev->id.bustype = BUS_RS232; ++ ts.dev->id.vendor = 0xDEAD; ++ ts.dev->id.product = 0xBEEF; ++ ts.dev->id.version = S3C2410TSVERSION; ++ ts.state = TS_STATE_STANDBY; ++ ts.event_fifo = kfifo_alloc(TS_EVENT_FIFO_SIZE, GFP_KERNEL, NULL); ++ if (IS_ERR(ts.event_fifo)) { ++ ret = -EIO; ++ goto bail2; ++ } ++ ++ /* create the filter chain set up for the 2 coordinates we produce */ ++ ret = ts_filter_create_chain( ++ pdev, (struct ts_filter_api **)&info->filter_sequence, ++ (void *)&info->filter_config, ts.tsf, ARRAY_SIZE(ts.coords)); ++ if (ret) ++ dev_info(&pdev->dev, "%d filter(s) initialized\n", ret); ++ else /* this is OK, just means there won't be any filtering */ ++ dev_info(&pdev->dev, "Unfiltered output selected\n"); ++ ++ if (ts.tsf[0]) ++ (ts.tsf[0]->api->clear)(ts.tsf[0]); ++ else ++ dev_info(&pdev->dev, "No filtering\n"); ++ ++ /* Get irqs */ ++ if (request_irq(IRQ_ADC, stylus_action, IRQF_SAMPLE_RANDOM, ++ "s3c2410_action", ts.dev)) { ++ dev_err(&pdev->dev, "Could not allocate ts IRQ_ADC !\n"); ++ iounmap(base_addr); ++ ret = -EIO; ++ goto bail3; ++ } ++ if (request_irq(IRQ_TC, stylus_updown, IRQF_SAMPLE_RANDOM, ++ "s3c2410_action", ts.dev)) { ++ dev_err(&pdev->dev, "Could not allocate ts IRQ_TC !\n"); ++ free_irq(IRQ_ADC, ts.dev); ++ iounmap(base_addr); ++ ret = -EIO; ++ goto bail4; ++ } ++ ++ dev_info(&pdev->dev, "successfully loaded\n"); ++ ++ /* All went ok, so register to the input system */ ++ rc = input_register_device(ts.dev); ++ if (rc) { ++ ret = -EIO; ++ goto bail5; ++ } ++ ++ return 0; ++ ++bail5: ++ free_irq(IRQ_TC, ts.dev); ++ free_irq(IRQ_ADC, ts.dev); ++ clk_disable(adc_clock); ++ iounmap(base_addr); ++ disable_irq(IRQ_TC); ++bail4: ++ disable_irq(IRQ_ADC); ++bail3: ++ ts_filter_destroy_chain(pdev, ts.tsf); ++ kfifo_free(ts.event_fifo); ++bail2: ++ input_unregister_device(ts.dev); ++bail1: ++ iounmap(base_addr); ++bail0: ++ ++ return ret; ++} ++ ++static int s3c2410ts_remove(struct platform_device *pdev) ++{ ++ disable_irq(IRQ_ADC); ++ disable_irq(IRQ_TC); ++ free_irq(IRQ_TC,ts.dev); ++ free_irq(IRQ_ADC,ts.dev); ++ ++ if (adc_clock) { ++ clk_disable(adc_clock); ++ clk_put(adc_clock); ++ adc_clock = NULL; ++ } ++ ++ input_unregister_device(ts.dev); ++ iounmap(base_addr); ++ ++ ts_filter_destroy_chain(pdev, ts.tsf); ++ ++ kfifo_free(ts.event_fifo); ++ ++ return 0; ++} ++ ++#ifdef CONFIG_PM ++static int s3c2410ts_suspend(struct platform_device *pdev, pm_message_t state) ++{ ++ writel(TSC_SLEEP, base_addr+S3C2410_ADCTSC); ++ writel(readl(base_addr+S3C2410_ADCCON) | S3C2410_ADCCON_STDBM, ++ base_addr+S3C2410_ADCCON); ++ ++ disable_irq(IRQ_ADC); ++ disable_irq(IRQ_TC); ++ ++ clk_disable(adc_clock); ++ ++ return 0; ++} ++ ++static int s3c2410ts_resume(struct platform_device *pdev) ++{ ++ struct s3c2410_ts_mach_info *info = ++ ( struct s3c2410_ts_mach_info *)pdev->dev.platform_data; ++ ++ clk_enable(adc_clock); ++ mdelay(1); ++ ++ if (ts.tsf[0]) ++ (ts.tsf[0]->api->clear)(ts.tsf[0]); ++ ++ enable_irq(IRQ_ADC); ++ enable_irq(IRQ_TC); ++ ++ if ((info->presc&0xff) > 0) ++ writel(S3C2410_ADCCON_PRSCEN | ++ S3C2410_ADCCON_PRSCVL(info->presc&0xFF), ++ base_addr+S3C2410_ADCCON); ++ else ++ writel(0,base_addr+S3C2410_ADCCON); ++ ++ /* Initialise registers */ ++ if ((info->delay & 0xffff) > 0) ++ writel(info->delay & 0xffff, base_addr+S3C2410_ADCDLY); ++ ++ writel(WAIT4INT(0), base_addr+S3C2410_ADCTSC); ++ ++ return 0; ++} ++ ++#else ++#define s3c2410ts_suspend NULL ++#define s3c2410ts_resume NULL ++#endif ++ ++static struct platform_driver s3c2410ts_driver = { ++ .driver = { ++ .name = "s3c2410-ts", ++ .owner = THIS_MODULE, ++ }, ++ .probe = s3c2410ts_probe, ++ .remove = s3c2410ts_remove, ++ .suspend = s3c2410ts_suspend, ++ .resume = s3c2410ts_resume, ++ ++}; ++ ++static struct platform_driver s3c2440ts_driver = { ++ .driver = { ++ .name = "s3c2440-ts", ++ .owner = THIS_MODULE, ++ }, ++ .probe = s3c2410ts_probe, ++ .remove = s3c2410ts_remove, ++ .suspend = s3c2410ts_suspend, ++ .resume = s3c2410ts_resume, ++ ++}; ++ ++static int __init s3c2410ts_init(void) ++{ ++ int rc; ++ ++ rc = platform_driver_register(&s3c2410ts_driver); ++ if (rc < 0) ++ return rc; ++ ++ rc = platform_driver_register(&s3c2440ts_driver); ++ if (rc < 0) ++ platform_driver_unregister(&s3c2410ts_driver); ++ ++ return rc; ++} ++ ++static void __exit s3c2410ts_exit(void) ++{ ++ platform_driver_unregister(&s3c2440ts_driver); ++ platform_driver_unregister(&s3c2410ts_driver); ++} ++ ++module_init(s3c2410ts_init); ++module_exit(s3c2410ts_exit); ++ +-- +1.5.6.3 + diff --git a/recipes/linux/linux-2.6.29/micro2440/0002-S3C-Backported-openmoko-s-touchscreen-filters.patch b/recipes/linux/linux-2.6.29/micro2440/0002-S3C-Backported-openmoko-s-touchscreen-filters.patch new file mode 100644 index 0000000000..c171db81ec --- /dev/null +++ b/recipes/linux/linux-2.6.29/micro2440/0002-S3C-Backported-openmoko-s-touchscreen-filters.patch @@ -0,0 +1,1260 @@ +From fe4e1650cff50bff8e8ad62dc036609f53307442 Mon Sep 17 00:00:00 2001 +From: Michel Pollet +Date: Sat, 14 Mar 2009 10:24:07 +0000 +Subject: [PATCH] S3C: Backported openmoko's touchscreen filters + +Openmoko's touchscreen layer supports various filtering policy +for the ADC and touchscreen corrdinates. This is a staight port. +--- + drivers/input/touchscreen/Kconfig | 48 ++++++ + drivers/input/touchscreen/Makefile | 5 + + drivers/input/touchscreen/ts_filter.c | 73 +++++++++ + drivers/input/touchscreen/ts_filter.h | 62 +++++++ + drivers/input/touchscreen/ts_filter_group.c | 221 ++++++++++++++++++++++++++ + drivers/input/touchscreen/ts_filter_group.h | 39 +++++ + drivers/input/touchscreen/ts_filter_linear.c | 173 ++++++++++++++++++++ + drivers/input/touchscreen/ts_filter_linear.h | 64 ++++++++ + drivers/input/touchscreen/ts_filter_mean.c | 174 ++++++++++++++++++++ + drivers/input/touchscreen/ts_filter_mean.h | 34 ++++ + drivers/input/touchscreen/ts_filter_median.c | 217 +++++++++++++++++++++++++ + drivers/input/touchscreen/ts_filter_median.h | 36 ++++ + 12 files changed, 1146 insertions(+), 0 deletions(-) + create mode 100644 drivers/input/touchscreen/ts_filter.c + create mode 100644 drivers/input/touchscreen/ts_filter.h + create mode 100644 drivers/input/touchscreen/ts_filter_group.c + create mode 100644 drivers/input/touchscreen/ts_filter_group.h + create mode 100644 drivers/input/touchscreen/ts_filter_linear.c + create mode 100644 drivers/input/touchscreen/ts_filter_linear.h + create mode 100644 drivers/input/touchscreen/ts_filter_mean.c + create mode 100644 drivers/input/touchscreen/ts_filter_mean.h + create mode 100644 drivers/input/touchscreen/ts_filter_median.c + create mode 100644 drivers/input/touchscreen/ts_filter_median.h + +diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig +index 9076492..75ff0a8 100644 +--- a/drivers/input/touchscreen/Kconfig ++++ b/drivers/input/touchscreen/Kconfig +@@ -11,6 +11,54 @@ menuconfig INPUT_TOUCHSCREEN + + if INPUT_TOUCHSCREEN + ++menuconfig TOUCHSCREEN_FILTER ++ boolean "Touchscreen Filtering" ++ depends on INPUT_TOUCHSCREEN ++ select TOUCHSCREEN_FILTER_GROUP ++ select TOUCHSCREEN_FILTER_MEDIAN ++ select TOUCHSCREEN_FILTER_MEAN ++ select TOUCHSCREEN_FILTER_LINEAR ++ help ++ Select this to include kernel touchscreen filter support. The filters ++ can be combined in any order in your machine init and the parameters ++ for them can also be set there. ++ ++if TOUCHSCREEN_FILTER ++ ++config TOUCHSCREEN_FILTER_GROUP ++ bool "Group Touchscreen Filter" ++ depends on INPUT_TOUCHSCREEN && TOUCHSCREEN_FILTER ++ default Y ++ help ++ Say Y here if you want to use the Group touchscreen filter, it ++ avoids using atypical samples. ++ ++config TOUCHSCREEN_FILTER_MEDIAN ++ bool "Median Average Touchscreen Filter" ++ depends on INPUT_TOUCHSCREEN && TOUCHSCREEN_FILTER ++ default Y ++ help ++ Say Y here if you want to use the Median touchscreen filter, it's ++ highly effective if you data is noisy with occasional excursions. ++ ++config TOUCHSCREEN_FILTER_MEAN ++ bool "Mean Average Touchscreen Filter" ++ depends on INPUT_TOUCHSCREEN && TOUCHSCREEN_FILTER ++ default Y ++ help ++ Say Y here if you want to use the Mean touchscreen filter, it ++ can further improve decent quality data by removing jitter ++ ++config TOUCHSCREEN_FILTER_LINEAR ++ bool "Linear Touchscreen Filter" ++ depends on INPUT_TOUCHSCREEN && TOUCHSCREEN_FILTER ++ default Y ++ help ++ Say Y here if you want to use the Linear touchscreen filter, it ++ enables the use of calibration data for the touchscreen. ++ ++endif ++ + config TOUCHSCREEN_ADS7846 + tristate "ADS7846/TSC2046 and ADS7843 based touchscreens" + depends on SPI_MASTER +diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile +index fbcde99..4b0a03e 100644 +--- a/drivers/input/touchscreen/Makefile ++++ b/drivers/input/touchscreen/Makefile +@@ -35,3 +35,8 @@ wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o + wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713) += wm9713.o + obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE) += mainstone-wm97xx.o + obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o ++obj-$(CONFIG_TOUCHSCREEN_FILTER) += ts_filter.o ++obj-$(CONFIG_TOUCHSCREEN_FILTER_GROUP) += ts_filter_group.o ++obj-$(CONFIG_TOUCHSCREEN_FILTER_LINEAR) += ts_filter_linear.o ++obj-$(CONFIG_TOUCHSCREEN_FILTER_MEDIAN) += ts_filter_median.o ++obj-$(CONFIG_TOUCHSCREEN_FILTER_MEAN) += ts_filter_mean.o +diff --git a/drivers/input/touchscreen/ts_filter.c b/drivers/input/touchscreen/ts_filter.c +new file mode 100644 +index 0000000..832844d +--- /dev/null ++++ b/drivers/input/touchscreen/ts_filter.c +@@ -0,0 +1,73 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Copyright (c) 2008 Andy Green ++ */ ++ ++#include ++#include ++#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 **arr, int count_coords) ++{ ++ int count = 0; ++ struct ts_filter *last = NULL; ++ ++ if (!api) ++ return 0; ++ ++ 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; ++ } ++ (*arr)->api = *api++; ++ if (last) ++ 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 **arr) ++{ ++ struct ts_filter **first = arr; ++ ++ 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 0000000..3746e45 +--- /dev/null ++++ b/drivers/input/touchscreen/ts_filter.h +@@ -0,0 +1,62 @@ ++#ifndef __TS_FILTER_H__ ++#define __TS_FILTER_H__ ++ ++/* ++ * Touchscreen filter. ++ * ++ * (c) 2008 Andy Green ++ */ ++ ++#include ++ ++#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. ++ */ ++ ++#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); ++ ++/* 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); ++#else ++#define ts_filter_create_chain(pdev, api, config, arr, count_coords) (0) ++#define ts_filter_destroy_chain(pdev, arr) do { } while (0) ++#endif ++ ++#endif +diff --git a/drivers/input/touchscreen/ts_filter_group.c b/drivers/input/touchscreen/ts_filter_group.c +new file mode 100644 +index 0000000..f2ecd92 +--- /dev/null ++++ b/drivers/input/touchscreen/ts_filter_group.c +@@ -0,0 +1,221 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Copyright (C) 2008 by Openmoko, Inc. ++ * Author: Nelson Castillo ++ * All rights reserved. ++ * ++ * This filter is useful to reject samples that are not reliable. We consider ++ * that a sample is not reliable if it deviates form the Majority. ++ * ++ * 1) We collect S samples. ++ * ++ * 2) For each dimension: ++ * ++ * - We sort the points. ++ * - Points that are "close enough" are considered to be in the same set. ++ * - We choose the set with more elements. If more than "threshold" ++ * points are in this set we use the first and the last point of the set ++ * to define the valid range for this dimension [min, max], otherwise we ++ * discard all the points and go to step 1. ++ * ++ * 3) We consider the unsorted S samples and try to feed them to the next ++ * filter in the chain. If one of the points of each sample ++ * is not in the allowed range for its dimension, we discard the sample. ++ * ++ */ ++ ++#include ++#include ++#include ++#include "ts_filter_group.h" ++ ++static void ts_filter_group_clear_internal(struct ts_filter_group *tsfg, ++ int attempts) ++{ ++ tsfg->N = 0; ++ tsfg->tries_left = attempts; ++} ++ ++static void ts_filter_group_clear(struct ts_filter *tsf) ++{ ++ struct ts_filter_group *tsfg = (struct ts_filter_group *)tsf; ++ ++ ts_filter_group_clear_internal(tsfg, tsfg->config->attempts); ++ ++ if (tsf->next) /* chain */ ++ (tsf->next->api->clear)(tsf->next); ++} ++ ++static struct ts_filter *ts_filter_group_create(struct platform_device *pdev, ++ void *conf, int count_coords) ++{ ++ struct ts_filter_group *tsfg; ++ int i; ++ ++ BUG_ON((count_coords < 1) || (count_coords > MAX_TS_FILTER_COORDS)); ++ ++ tsfg = kzalloc(sizeof(struct ts_filter_group), GFP_KERNEL); ++ if (!tsfg) ++ return NULL; ++ ++ tsfg->config = (struct ts_filter_group_configuration *)conf; ++ tsfg->tsf.count_coords = count_coords; ++ ++ BUG_ON(tsfg->config->attempts <= 0); ++ ++ tsfg->samples[0] = kmalloc((2 + count_coords) * sizeof(int) * ++ tsfg->config->extent, GFP_KERNEL); ++ if (!tsfg->samples[0]) { ++ kfree(tsfg); ++ return NULL; ++ } ++ for (i = 1; i < count_coords; ++i) ++ tsfg->samples[i] = tsfg->samples[0] + i * tsfg->config->extent; ++ tsfg->sorted_samples = tsfg->samples[0] + count_coords * ++ tsfg->config->extent; ++ tsfg->group_size = tsfg->samples[0] + (1 + count_coords) * ++ tsfg->config->extent; ++ ++ ts_filter_group_clear_internal(tsfg, tsfg->config->attempts); ++ ++ printk(KERN_INFO" Created group ts filter len %d depth %d close %d " ++ "thresh %d\n", tsfg->config->extent, count_coords, ++ tsfg->config->close_enough, tsfg->config->threshold); ++ ++ return &tsfg->tsf; ++} ++ ++static void ts_filter_group_destroy(struct platform_device *pdev, ++ struct ts_filter *tsf) ++{ ++ struct ts_filter_group *tsfg = (struct ts_filter_group *)tsf; ++ ++ kfree(tsfg->samples[0]); /* first guy has pointer from kmalloc */ ++ kfree(tsf); ++} ++ ++static void ts_filter_group_scale(struct ts_filter *tsf, int *coords) ++{ ++ if (tsf->next) ++ (tsf->next->api->scale)(tsf->next, coords); ++} ++ ++static int int_cmp(const void *_a, const void *_b) ++{ ++ const int *a = _a; ++ const int *b = _b; ++ ++ if (*a > *b) ++ return 1; ++ if (*a < *b) ++ return -1; ++ return 0; ++} ++ ++static int ts_filter_group_process(struct ts_filter *tsf, int *coords) ++{ ++ struct ts_filter_group *tsfg = (struct ts_filter_group *)tsf; ++ int n; ++ int i; ++ int ret = 0; /* ask for more samples by default */ ++ ++ BUG_ON(tsfg->N >= tsfg->config->extent); ++ ++ for (n = 0; n < tsf->count_coords; n++) ++ tsfg->samples[n][tsfg->N] = coords[n]; ++ ++ if (++tsfg->N < tsfg->config->extent) ++ return 0; /* we meed more samples */ ++ ++ for (n = 0; n < tsfg->tsf.count_coords; n++) { ++ int *v = tsfg->sorted_samples; ++ int ngroups = 0; ++ int best_size; ++ int best_idx = 0; ++ int idx = 0; ++ ++ memcpy(v, tsfg->samples[n], tsfg->N * sizeof(int)); ++ sort(v, tsfg->N, sizeof(int), int_cmp, NULL); ++ ++ tsfg->group_size[0] = 1; ++ for (i = 1; i < tsfg->N; ++i) { ++ if (v[i] - v[i - 1] <= tsfg->config->close_enough) ++ tsfg->group_size[ngroups]++; ++ else ++ tsfg->group_size[++ngroups] = 1; ++ } ++ ngroups++; ++ ++ best_size = tsfg->group_size[0]; ++ for (i = 1; i < ngroups; i++) { ++ idx += tsfg->group_size[i - 1]; ++ if (best_size < tsfg->group_size[i]) { ++ best_size = tsfg->group_size[i]; ++ best_idx = idx; ++ } ++ } ++ ++ if (best_size < tsfg->config->threshold) { ++ /* this set is not good enough for us */ ++ if (--tsfg->tries_left) { ++ ts_filter_group_clear_internal ++ (tsfg, tsfg->tries_left); ++ return 0; /* ask for more samples */ ++ } ++ return -1; /* we give up */ ++ } ++ ++ tsfg->range_min[n] = v[best_idx]; ++ tsfg->range_max[n] = v[best_idx + best_size - 1]; ++ } ++ ++ for (i = 0; i < tsfg->N; ++i) { ++ int r; ++ ++ for (n = 0; n < tsfg->tsf.count_coords; ++n) { ++ coords[n] = tsfg->samples[n][i]; ++ if (coords[n] < tsfg->range_min[n] || ++ coords[n] > tsfg->range_max[n]) ++ break; ++ } ++ ++ if (n != tsfg->tsf.count_coords) /* sample not OK */ ++ continue; ++ ++ if (tsf->next) { ++ r = (tsf->next->api->process)(tsf->next, coords); ++ if (r) { ++ ret = r; ++ break; ++ } ++ } else if (i == tsfg->N - 1) { ++ ret = 1; ++ } ++ } ++ ++ ts_filter_group_clear_internal(tsfg, tsfg->config->attempts); ++ ++ return ret; ++} ++ ++struct ts_filter_api ts_filter_group_api = { ++ .create = ts_filter_group_create, ++ .destroy = ts_filter_group_destroy, ++ .clear = ts_filter_group_clear, ++ .process = ts_filter_group_process, ++ .scale = ts_filter_group_scale, ++}; ++ +diff --git a/drivers/input/touchscreen/ts_filter_group.h b/drivers/input/touchscreen/ts_filter_group.h +new file mode 100644 +index 0000000..c411080 +--- /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 ++ * ++ */ ++ ++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 +new file mode 100644 +index 0000000..c336252 +--- /dev/null ++++ b/drivers/input/touchscreen/ts_filter_linear.c +@@ -0,0 +1,173 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Copyright (C) 2008 by Openmoko, Inc. ++ * Author: Nelson Castillo ++ * All rights reserved. ++ * ++ * Linearly scale touchscreen values. ++ * ++ * Expose the TS_FILTER_LINEAR_NCONSTANTS for the linear transformation ++ * using sysfs. ++ * ++ */ ++ ++#include "ts_filter_linear.h" ++#include ++#include ++#include ++ ++ ++/* sysfs functions */ ++ ++ ++static ssize_t const_attr_show(struct kobject *kobj, ++ struct attribute *attr, ++ char *buf) ++{ ++ struct const_attribute *a = to_const_attr(attr); ++ ++ return a->show(to_const_obj(kobj), a, buf); ++} ++ ++static ssize_t const_attr_store(struct kobject *kobj, ++ struct attribute *attr, ++ const char *buf, size_t len) ++{ ++ struct const_attribute *a = to_const_attr(attr); ++ ++ return a->store(to_const_obj(kobj), a, buf, len); ++} ++ ++static struct sysfs_ops const_sysfs_ops = { ++ .show = const_attr_show, ++ .store = const_attr_store, ++}; ++ ++static void const_release(struct kobject *kobj) ++{ ++ kfree(to_const_obj(kobj)->tsfl); ++} ++ ++static ssize_t const_show(struct const_obj *obj, struct const_attribute *attr, ++ char *buf) ++{ ++ int who; ++ ++ sscanf(attr->attr.name, "%d", &who); ++ return sprintf(buf, "%d\n", obj->tsfl->constants[who]); ++} ++ ++static ssize_t const_store(struct const_obj *obj, struct const_attribute *attr, ++ const char *buf, size_t count) ++{ ++ int who; ++ ++ sscanf(attr->attr.name, "%d", &who); ++ sscanf(buf, "%d", &obj->tsfl->constants[who]); ++ return count; ++} ++ ++/* filter functions */ ++ ++static struct ts_filter *ts_filter_linear_create(struct platform_device *pdev, ++ void *conf, int count_coords) ++{ ++ struct ts_filter_linear *tsfl; ++ int i; ++ int ret; ++ ++ tsfl = kzalloc(sizeof(struct ts_filter_linear), GFP_KERNEL); ++ if (!tsfl) ++ return NULL; ++ ++ tsfl->config = (struct ts_filter_linear_configuration *)conf; ++ tsfl->tsf.count_coords = count_coords; ++ ++ for (i = 0; i < TS_FILTER_LINEAR_NCONSTANTS; ++i) { ++ tsfl->constants[i] = tsfl->config->constants[i]; ++ ++ /* sysfs */ ++ sprintf(tsfl->attr_names[i], "%d", i); ++ tsfl->kattrs[i].attr.name = tsfl->attr_names[i]; ++ tsfl->kattrs[i].attr.mode = 0666; ++ tsfl->kattrs[i].show = const_show; ++ tsfl->kattrs[i].store = const_store; ++ tsfl->attrs[i] = &tsfl->kattrs[i].attr; ++ } ++ tsfl->attrs[i] = NULL; ++ ++ tsfl->const_ktype.sysfs_ops = &const_sysfs_ops; ++ tsfl->const_ktype.release = const_release; ++ tsfl->const_ktype.default_attrs = tsfl->attrs; ++ tsfl->c_obj.tsfl = tsfl; /* kernel frees tsfl in const_release */ ++ ++ ret = kobject_init_and_add(&tsfl->c_obj.kobj, &tsfl->const_ktype, ++ &pdev->dev.kobj, "calibration"); ++ if (ret) { ++ kobject_put(&tsfl->c_obj.kobj); ++ return NULL; ++ } ++ ++ printk(KERN_INFO" Created Linear ts filter depth %d\n", count_coords); ++ ++ return &tsfl->tsf; ++} ++ ++static void ts_filter_linear_destroy(struct platform_device *pdev, ++ struct ts_filter *tsf) ++{ ++ struct ts_filter_linear *tsfl = (struct ts_filter_linear *)tsf; ++ ++ /* kernel frees tsfl in const_release */ ++ kobject_put(&tsfl->c_obj.kobj); ++} ++ ++static void ts_filter_linear_clear(struct ts_filter *tsf) ++{ ++ if (tsf->next) /* chain */ ++ (tsf->next->api->clear)(tsf->next); ++} ++ ++ ++static void ts_filter_linear_scale(struct ts_filter *tsf, int *coords) ++{ ++ struct ts_filter_linear *tsfl = (struct ts_filter_linear *)tsf; ++ int *k = tsfl->constants; ++ int c0 = coords[tsfl->config->coord0]; ++ int c1 = coords[tsfl->config->coord1]; ++ ++ coords[tsfl->config->coord0] = (k[2] + k[0] * c0 + k[1] * c1) / k[6]; ++ coords[tsfl->config->coord1] = (k[5] + k[3] * c0 + k[4] * c1) / k[6]; ++ ++ if (tsf->next) ++ (tsf->next->api->scale)(tsf->next, coords); ++} ++ ++static int ts_filter_linear_process(struct ts_filter *tsf, int *coords) ++{ ++ if (tsf->next) ++ return (tsf->next->api->process)(tsf->next, coords); ++ ++ return 1; ++} ++ ++struct ts_filter_api ts_filter_linear_api = { ++ .create = ts_filter_linear_create, ++ .destroy = ts_filter_linear_destroy, ++ .clear = ts_filter_linear_clear, ++ .process = ts_filter_linear_process, ++ .scale = ts_filter_linear_scale, ++}; +diff --git a/drivers/input/touchscreen/ts_filter_linear.h b/drivers/input/touchscreen/ts_filter_linear.h +new file mode 100644 +index 0000000..fc27cf7 +--- /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 ++ ++/* ++ * Touchscreen linear filter. ++ * ++ * Copyright (C) 2008 by Openmoko, Inc. ++ * Author: Nelson Castillo ++ * ++ */ ++ ++#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 +new file mode 100644 +index 0000000..e4e0f2a +--- /dev/null ++++ b/drivers/input/touchscreen/ts_filter_mean.c +@@ -0,0 +1,174 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Copyright (c) 2008 Andy Green ++ * ++ * ++ * Mean has no effect if the samples are changing by more that the ++ * threshold set by averaging_threshold in the configuration. ++ * ++ * However while samples come in that don't go outside this threshold from ++ * the last reported sample, Mean replaces the samples with a simple mean ++ * of a configurable number of samples (set by bits_filter_length in config, ++ * which is 2^n, so 5 there makes 32 sample averaging). ++ * ++ * Mean works well if the input data is already good quality, reducing + / - 1 ++ * sample jitter when the stylus is still, or moving very slowly, without ++ * introducing abrupt transitions or reducing ability to follow larger ++ * movements. If you set the threshold higher than the dynamic range of the ++ * coordinates, you can just use it as a simple mean average. ++ */ ++ ++#include ++#include ++#include ++#include "ts_filter_mean.h" ++ ++static void ts_filter_mean_clear_internal(struct ts_filter *tsf) ++{ ++ struct ts_filter_mean *tsfs = (struct ts_filter_mean *)tsf; ++ int n; ++ ++ for (n = 0; n < tsfs->tsf.count_coords; n++) { ++ tsfs->fhead[n] = 0; ++ tsfs->ftail[n] = 0; ++ tsfs->lowpass[n] = 0; ++ } ++} ++ ++static void ts_filter_mean_clear(struct ts_filter *tsf) ++{ ++ ts_filter_mean_clear_internal(tsf); ++ ++ if (tsf->next) /* chain */ ++ (tsf->next->api->clear)(tsf->next); ++} ++ ++static struct ts_filter *ts_filter_mean_create(struct platform_device *pdev, ++ void *config, int count_coords) ++{ ++ int *p; ++ int n; ++ struct ts_filter_mean *tsfs = kzalloc( ++ sizeof(struct ts_filter_mean), GFP_KERNEL); ++ ++ if (!tsfs) ++ return NULL; ++ ++ BUG_ON((count_coords < 1) || (count_coords > MAX_TS_FILTER_COORDS)); ++ tsfs->tsf.count_coords = count_coords; ++ ++ tsfs->config = (struct ts_filter_mean_configuration *)config; ++ ++ tsfs->config->extent = 1 << tsfs->config->bits_filter_length; ++ BUG_ON((tsfs->config->extent > 256) || (!tsfs->config->extent)); ++ ++ p = kmalloc(tsfs->config->extent * sizeof(int) * count_coords, ++ GFP_KERNEL); ++ if (!p) ++ return NULL; ++ ++ for (n = 0; n < count_coords; n++) { ++ tsfs->fifo[n] = p; ++ p += tsfs->config->extent; ++ } ++ ++ if (!tsfs->config->averaging_threshold) ++ tsfs->config->averaging_threshold = 0xffff; /* always active */ ++ ++ ts_filter_mean_clear_internal(&tsfs->tsf); ++ ++ printk(KERN_INFO" Created Mean ts filter len %d depth %d thresh %d\n", ++ tsfs->config->extent, count_coords, ++ tsfs->config->averaging_threshold); ++ ++ return &tsfs->tsf; ++} ++ ++static void ts_filter_mean_destroy(struct platform_device *pdev, ++ struct ts_filter *tsf) ++{ ++ struct ts_filter_mean *tsfs = (struct ts_filter_mean *)tsf; ++ ++ kfree(tsfs->fifo[0]); /* first guy has pointer from kmalloc */ ++ kfree(tsf); ++} ++ ++static void ts_filter_mean_scale(struct ts_filter *tsf, int *coords) ++{ ++ if (tsf->next) /* chain */ ++ (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 ++ * fill the filter with samples yet. ++ */ ++ ++static int ts_filter_mean_process(struct ts_filter *tsf, int *coords) ++{ ++ struct ts_filter_mean *tsfs = (struct ts_filter_mean *)tsf; ++ int n; ++ int len; ++ ++ for (n = 0; n < tsf->count_coords; n++) { ++ ++ /* ++ * Has he moved far enough away that we should abandon current ++ * low pass filtering state? ++ */ ++ if ((coords[n] < (tsfs->reported[n] - ++ tsfs->config->averaging_threshold)) || ++ (coords[n] > (tsfs->reported[n] + ++ tsfs->config->averaging_threshold))) { ++ tsfs->fhead[n] = 0; ++ tsfs->ftail[n] = 0; ++ tsfs->lowpass[n] = 0; ++ } ++ ++ /* capture this sample into fifo and sum */ ++ tsfs->fifo[n][tsfs->fhead[n]++] = coords[n]; ++ if (tsfs->fhead[n] == tsfs->config->extent) ++ tsfs->fhead[n] = 0; ++ tsfs->lowpass[n] += coords[n]; ++ ++ /* adjust the sum into an average and use that*/ ++ len = (tsfs->fhead[n] - tsfs->ftail[n]) & ++ (tsfs->config->extent - 1); ++ coords[n] = (tsfs->lowpass[n] + (len >> 1)) / len; ++ tsfs->reported[n] = coords[n]; ++ ++ /* remove oldest sample if we are full */ ++ if (len == (tsfs->config->extent - 1)) { ++ tsfs->lowpass[n] -= tsfs->fifo[n][tsfs->ftail[n]++]; ++ if (tsfs->ftail[n] == tsfs->config->extent) ++ tsfs->ftail[n] = 0; ++ } ++ } ++ ++ if (tsf->next) /* chain */ ++ return (tsf->next->api->process)(tsf->next, coords); ++ ++ return 1; ++} ++ ++struct ts_filter_api ts_filter_mean_api = { ++ .create = ts_filter_mean_create, ++ .destroy = ts_filter_mean_destroy, ++ .clear = ts_filter_mean_clear, ++ .process = ts_filter_mean_process, ++ .scale = ts_filter_mean_scale, ++}; +diff --git a/drivers/input/touchscreen/ts_filter_mean.h b/drivers/input/touchscreen/ts_filter_mean.h +new file mode 100644 +index 0000000..44c506c +--- /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 ++ */ ++ ++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 +new file mode 100644 +index 0000000..b3b6a9c +--- /dev/null ++++ b/drivers/input/touchscreen/ts_filter_median.c +@@ -0,0 +1,217 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++ * ++ * Copyright (c) 2008 Andy Green ++ * ++ * ++ * Median averaging stuff. We sort incoming raw samples into an array of ++ * MEDIAN_SIZE length, discarding the oldest sample each time once we are full. ++ * We then return the sum of the middle three samples for X and Y. It means ++ * the final result must be divided by (3 * scaling factor) to correct for ++ * avoiding the repeated /3. ++ * ++ * This strongly rejects brief excursions away from a central point that is ++ * sticky in time compared to the excursion duration. ++ * ++ * Thanks to Dale Schumacher (who wrote some example code) and Carl-Daniel ++ * Halifinger who pointed out this would be a good method. ++ */ ++ ++#include ++#include ++#include ++#include "ts_filter_median.h" ++ ++static void ts_filter_median_insert(int *p, int sample, int count) ++{ ++ int n; ++ ++ /* search through what we got so far to find where to put sample */ ++ for (n = 0; n < count; n++) ++ /* we met somebody bigger than us? */ ++ if (sample < p[n]) { ++ /* starting from the end, push bigger guys down one */ ++ for (count--; count >= n; count--) ++ p[count + 1] = p[count]; ++ p[n] = sample; /* and put us in place of first bigger */ ++ return; ++ } ++ ++ p[count] = sample; /* nobody was bigger than us, add us on the end */ ++} ++ ++static void ts_filter_median_del(int *p, int value, int count) ++{ ++ int index; ++ ++ for (index = 0; index < count; index++) ++ if (p[index] == value) { ++ for (; index < count; index++) ++ p[index] = p[index + 1]; ++ return; ++ } ++} ++ ++ ++static void ts_filter_median_clear_internal(struct ts_filter *tsf) ++{ ++ struct ts_filter_median *tsfm = (struct ts_filter_median *)tsf; ++ ++ tsfm->pos = 0; ++ tsfm->valid = 0; ++ ++} ++static void ts_filter_median_clear(struct ts_filter *tsf) ++{ ++ ts_filter_median_clear_internal(tsf); ++ ++ if (tsf->next) /* chain */ ++ (tsf->next->api->clear)(tsf->next); ++} ++ ++static struct ts_filter *ts_filter_median_create(struct platform_device *pdev, ++ void *conf, int count_coords) ++{ ++ int *p; ++ int n; ++ struct ts_filter_median *tsfm = kzalloc(sizeof(struct ts_filter_median), ++ GFP_KERNEL); ++ ++ if (!tsfm) ++ return NULL; ++ ++ tsfm->config = (struct ts_filter_median_configuration *)conf; ++ BUG_ON((count_coords < 1) || (count_coords > MAX_TS_FILTER_COORDS)); ++ tsfm->tsf.count_coords = count_coords; ++ ++ tsfm->config->midpoint = (tsfm->config->extent >> 1) + 1; ++ ++ p = kmalloc(2 * count_coords * sizeof(int) * (tsfm->config->extent + 1), ++ GFP_KERNEL); ++ if (!p) { ++ kfree(tsfm); ++ return NULL; ++ } ++ ++ for (n = 0; n < count_coords; n++) { ++ tsfm->sort[n] = p; ++ p += tsfm->config->extent + 1; ++ tsfm->fifo[n] = p; ++ p += tsfm->config->extent + 1; ++ } ++ ++ ts_filter_median_clear_internal(&tsfm->tsf); ++ ++ printk(KERN_INFO" Created Median ts filter len %d depth %d dec %d\n", ++ tsfm->config->extent, count_coords, ++ tsfm->config->decimation_threshold); ++ ++ return &tsfm->tsf; ++} ++ ++static void ts_filter_median_destroy(struct platform_device *pdev, ++ struct ts_filter *tsf) ++{ ++ struct ts_filter_median *tsfm = (struct ts_filter_median *)tsf; ++ ++ kfree(tsfm->sort[0]); /* first guy has pointer from kmalloc */ ++ kfree(tsf); ++} ++ ++static void ts_filter_median_scale(struct ts_filter *tsf, int *coords) ++{ ++ int n; ++ ++ for (n = 0; n < tsf->count_coords; n++) ++ coords[n] = (coords[n] + 2) / 3; ++ ++ if (tsf->next) /* chain */ ++ (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 ++ * fill all the filters with samples yet. ++ */ ++ ++static int ts_filter_median_process(struct ts_filter *tsf, int *coords) ++{ ++ struct ts_filter_median *tsfm = (struct ts_filter_median *)tsf; ++ int n; ++ int movement = 1; ++ ++ for (n = 0; n < tsf->count_coords; n++) { ++ /* grab copy in insertion order to remove when oldest */ ++ tsfm->fifo[n][tsfm->pos] = coords[n]; ++ /* insert these samples in sorted order in the median arrays */ ++ ts_filter_median_insert(tsfm->sort[n], coords[n], tsfm->valid); ++ } ++ /* move us on in the fifo */ ++ if (++tsfm->pos == (tsfm->config->extent + 1)) ++ tsfm->pos = 0; ++ ++ /* we have finished a median sampling? */ ++ if (++tsfm->valid != tsfm->config->extent) ++ return 0; /* no valid sample to use */ ++ ++ /* discard the oldest sample in median sorted array */ ++ tsfm->valid--; ++ ++ /* ++ * 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. ++ */ ++ for (n = 0; n < tsfm->tsf.count_coords; n++) ++ /* perform the deletion of the oldest sample */ ++ ts_filter_median_del(tsfm->sort[n], tsfm->fifo[n][tsfm->pos], ++ tsfm->valid); ++ ++ tsfm->decimation_count--; ++ if (tsfm->decimation_count >= 0) ++ return 0; ++ ++ for (n = 0; n < tsfm->tsf.count_coords; n++) { ++ /* give the coordinate result from summing median 3 */ ++ coords[n] = tsfm->sort[n][tsfm->config->midpoint - 1] + ++ tsfm->sort[n][tsfm->config->midpoint] + ++ tsfm->sort[n][tsfm->config->midpoint + 1] ++ ; ++ ++ movement += abs(tsfm->last_issued[n] - coords[n]); ++ } ++ ++ if (movement > tsfm->config->decimation_threshold) /* fast */ ++ tsfm->decimation_count = tsfm->config->decimation_above; ++ else ++ tsfm->decimation_count = tsfm->config->decimation_below; ++ ++ memcpy(&tsfm->last_issued[0], coords, ++ tsfm->tsf.count_coords * sizeof(int)); ++ ++ if (tsf->next) /* chain */ ++ return (tsf->next->api->process)(tsf->next, coords); ++ ++ return 1; ++} ++ ++struct ts_filter_api ts_filter_median_api = { ++ .create = ts_filter_median_create, ++ .destroy = ts_filter_median_destroy, ++ .clear = ts_filter_median_clear, ++ .process = ts_filter_median_process, ++ .scale = ts_filter_median_scale, ++}; +diff --git a/drivers/input/touchscreen/ts_filter_median.h b/drivers/input/touchscreen/ts_filter_median.h +new file mode 100644 +index 0000000..8f25e27 +--- /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 ++ */ ++ ++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 +-- +1.5.6.3 + diff --git a/recipes/linux/linux-2.6.29/micro2440/0003-VENDOR-armworks-logo.patch b/recipes/linux/linux-2.6.29/micro2440/0003-VENDOR-armworks-logo.patch new file mode 100644 index 0000000000..47909aa684 --- /dev/null +++ b/recipes/linux/linux-2.6.29/micro2440/0003-VENDOR-armworks-logo.patch @@ -0,0 +1,12079 @@ +From 42c2c795ebc07043ee046dc95d1da5320a02e2ae Mon Sep 17 00:00:00 2001 +From: Michel Pollet +Date: Wed, 25 Mar 2009 17:38:41 +0000 +Subject: [PATCH] VENDOR: arm