From 97545aee69224054b129690095ad809eec0da936 Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Wed, 25 Mar 2009 17:45:09 +0000 Subject: [PATCH] MINI2440: Add touchscreen support Uses the newly merged moko's touchscreen, optional. Signed-off-by: Michel Pollet --- arch/arm/mach-s3c2440/Kconfig | 2 + arch/arm/mach-s3c2440/mach-mini2440.c | 99 ++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig index 29b50dc5a7c..b0995ed18bc 100644 --- a/arch/arm/mach-s3c2440/Kconfig +++ b/arch/arm/mach-s3c2440/Kconfig @@ -105,6 +105,8 @@ config MACH_MINI2440 select SND_S3C24XX_SOC_S3C24XX_UDA134X select S3C_DEV_NAND select S3C_DEV_USB_HOST + select TOUCHSCREEN_S3C2410 + select TOUCHSCREEN_FILTER help Say Y here to select support for the MINI2440. Is a 10cm x 10cm board available via various sources. It can come with a 3.5" or 7" touch LCD. diff --git a/arch/arm/mach-s3c2440/mach-mini2440.c b/arch/arm/mach-s3c2440/mach-mini2440.c index 159e6a76c31..c9e645edc0f 100644 --- a/arch/arm/mach-s3c2440/mach-mini2440.c +++ b/arch/arm/mach-s3c2440/mach-mini2440.c @@ -48,6 +48,16 @@ #include #include +/* + * This is compiled conditionaly, as: + * 1) not everyone needs the touchscreen + * 2) that s3c_ts code might not have been added + * to the kernel with this file + */ +#ifdef CONFIG_TOUCHSCREEN_S3C2410 +#include +#endif + #include #include #include @@ -59,6 +69,13 @@ #include +#ifdef CONFIG_TOUCHSCREEN_FILTER +#include <../drivers/input/touchscreen/ts_filter_linear.h> +#include <../drivers/input/touchscreen/ts_filter_mean.h> +#include <../drivers/input/touchscreen/ts_filter_median.h> +#include <../drivers/input/touchscreen/ts_filter_group.h> +#endif + #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300) static struct map_desc mini2440_iodesc[] __initdata = { @@ -118,6 +135,69 @@ static struct s3c2410_udc_mach_info mini2440_udc_cfg __initdata = { .udc_command = mini2440_udc_pullup, }; +/* touchscreen configuration */ + +#ifdef CONFIG_TOUCHSCREEN_FILTER +static struct ts_filter_linear_configuration mini2440_ts_linear_config __initdata = { + .constants = { + 0, /* x factor */ + 1, /* y proportion */ + 0, /* x offset */ + + 1, /* x factor */ + 0, /* y factor */ + 0, /* y offset */ + + 1 /* common divisor */ + }, + .coord0 = 0, + .coord1 = 1, +}; + +static struct ts_filter_group_configuration mini2440_ts_group_config __initdata = { + .extent = 12, + .close_enough = 10, + .threshold = 6, /* at least half of the points in a group */ + .attempts = 10, +}; + +static struct ts_filter_median_configuration mini2440_ts_median_config __initdata = { + .extent = 20, + .decimation_below = 3, + .decimation_threshold = 8 * 3, + .decimation_above = 4, +}; + +static struct ts_filter_mean_configuration mini2440_ts_mean_config __initdata = { + .bits_filter_length = 2, /* 4 points */ +}; + +static struct s3c2410_ts_mach_info mini2440_ts_cfg __initdata = { + .delay = 10000, + .presc = 0xff, /* slow as we can go */ + .filter_sequence = { + [0] = &ts_filter_group_api, + [1] = &ts_filter_median_api, + [2] = &ts_filter_mean_api, + [3] = &ts_filter_linear_api, + }, + .filter_config = { + [0] = &mini2440_ts_group_config, + [1] = &mini2440_ts_median_config, + [2] = &mini2440_ts_mean_config, + [3] = &mini2440_ts_linear_config, + }, +}; +#else /* !CONFIG_TOUCHSCREEN_FILTER */ +#ifdef CONFIG_TOUCHSCREEN_S3C2410 +static struct s3c2410_ts_mach_info mini2440_ts_cfg = { + .delay = 10000, + .presc = 0xff, /* slow as we can go */ +}; +#endif /* CONFIG_TOUCHSCREEN_S3C2410 */ +#endif + +/* LCD driver info */ /* LCD timing and setup */ @@ -636,8 +716,18 @@ static void mini2440_parse_features( features->done |= FEATURE_BACKLIGHT; break; case 't': - printk(KERN_INFO "MINI2440: '%c' ignored, " - "touchscreen not compiled in\n", f); +#ifdef CONFIG_TOUCHSCREEN_S3C2410 + if (features->done & FEATURE_TOUCH) + printk(KERN_INFO "MINI2440: '%c' ignored, " + "touchscreen already set\n", f); + else + features->optional[features->count++] = + &s3c_device_ts; + features->done |= FEATURE_TOUCH; +#else + printk(KERN_INFO "MINI2440: '%c' ignored, " + "touchscreen not compiled in\n", f); +#endif break; case 'c': if (features->done & FEATURE_CAMERA) @@ -708,6 +798,11 @@ static void __init mini2440_init(void) i2c_register_board_info(0, mini2440_i2c_devs, ARRAY_SIZE(mini2440_i2c_devs)); +#ifdef CONFIG_TOUCHSCREEN_S3C2410 + if (features.done & FEATURE_TOUCH) + set_s3c2410ts_info(&mini2440_ts_cfg); +#endif + platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices)); if (features.count) /* the optional features */ -- 2.11.4.GIT