MINI2440: Add touchscreen support
authorMichel Pollet <buserror@gmail.com>
Wed, 25 Mar 2009 17:45:09 +0000 (25 17:45 +0000)
committerMichel Pollet <buserror@gmail.com>
Tue, 24 Nov 2009 22:38:46 +0000 (24 22:38 +0000)
Uses the newly merged moko's touchscreen, optional.

Signed-off-by: Michel Pollet <buserror@gmail.com>
arch/arm/mach-s3c2440/Kconfig
arch/arm/mach-s3c2440/mach-mini2440.c

index 29b50dc..b0995ed 100644 (file)
@@ -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.
index 159e6a7..c9e645e 100644 (file)
 #include <plat/mci.h>
 #include <plat/udc.h>
 
+/*
+ * 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 <mach/ts.h>
+#endif
+
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/nand_ecc.h>
 
 #include <sound/s3c24xx_uda134x.h>
 
+#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 */