aboutsummaryrefslogtreecommitdiffstats
path: root/packages/linux/linux-rp-2.6.24/tosa/0068-Preliminary-tosa-denoiser.patch
blob: e90e3751c05f90484828c128a0e8f7947ed9feeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
From f7dad1cd9c1bd3fce5d228e0b644a51baea50cd9 Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dbaryshkov@gmail.com>
Date: Fri, 15 Feb 2008 15:35:07 +0300
Subject: [PATCH] Preliminary tosa denoiser

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
---
 drivers/input/touchscreen/Kconfig       |   12 ++
 drivers/input/touchscreen/Makefile      |    1 +
 drivers/input/touchscreen/tosa-wm97xx.c |  182 +++++++++++++++++++++++++++++++
 3 files changed, 195 insertions(+), 0 deletions(-)
 create mode 100644 drivers/input/touchscreen/tosa-wm97xx.c

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 0be05a2..938aed2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -210,6 +210,18 @@ config TOUCHSCREEN_WM97XX_MAINSTONE
 	  To compile this driver as a module, choose M here: the
 	  module will be called mainstone-wm97xx
 
+config TOUCHSCREEN_WM97XX_TOSA
+	tristate "WM97xx Tosa denoiser"
+	depends on TOUCHSCREEN_WM97XX && MACH_TOSA
+	help
+	  Say Y here for support for touchscreen denoising on
+	  Sharl Zaurus SL-6000 (tosa) system.
+
+	  If unsure, say N
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tosa-wm97xx
+
 config TOUCHSCREEN_TOUCHWIN
 	tristate "Touchwin serial touchscreen"
 	select SERIO
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index d38156e..d86278b 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -23,6 +23,7 @@ obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN)	+= touchwin.o
 obj-$(CONFIG_TOUCHSCREEN_UCB1400)	+= ucb1400_ts.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX)	+= wm97xx-ts.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
+obj-$(CONFIG_TOUCHSCREEN_WM97XX_TOSA)	+= tosa-wm97xx.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705)  += wm9705.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712)  += wm9712.o
 wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9713)  += wm9713.o
diff --git a/drivers/input/touchscreen/tosa-wm97xx.c b/drivers/input/touchscreen/tosa-wm97xx.c
new file mode 100644
index 0000000..8fd542b
--- /dev/null
+++ b/drivers/input/touchscreen/tosa-wm97xx.c
@@ -0,0 +1,182 @@
+/*
+ * tosa_ts.c  --  Touchscreen driver for Sharp SL-6000 (Tosa).
+ *
+ * Copyright 2008 Dmitry Baryshkov
+ * Copyright 2006 Wolfson Microelectronics PLC.
+ * Author: Mike Arthur
+ *         linux@wolfsonmicro.com
+ *
+ *  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.
+ *
+ *  Revision history
+ *     1st Sep 2006  Initial version.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/wm97xx.h>
+#include <linux/fb.h>
+
+#include <asm/arch/tosa.h>
+#include <asm/gpio.h>
+
+static unsigned long hsync_time = 0;
+
+static void calc_hsync_time(const struct fb_videomode *mode)
+{
+	/* The 25 and 44 'magic numbers' are from Sharp's 2.4 patches */
+	if (mode->yres == 640) {
+		hsync_time = 25;
+	} else if (mode->yres == 320) {
+		hsync_time = 44;
+	} else {
+		printk(KERN_ERR "unknown video mode res specified: %dx%d!", mode->xres, mode->yres);
+		WARN_ON(1);
+	}
+
+	printk(KERN_ERR "tosa-wm97xx: using %lu hsync time\n", hsync_time);
+}
+
+static int fb_notifier_callback(struct notifier_block *self,
+				unsigned long event, void *_data)
+{
+	if (event != FB_EVENT_MODE_CHANGE && event != FB_EVENT_MODE_CHANGE_ALL)
+		return 0;
+
+	calc_hsync_time(tosa_lcd_get_mode());
+
+	return 0;
+}
+
+static void tosa_lcd_wait_hsync(void)
+{
+	/* Waits for a rising edge on the VGA line */
+	while (gpio_get_value(TOSA_GPIO_VGA_LINE) == 0);
+	while (gpio_get_value(TOSA_GPIO_VGA_LINE) != 0);
+}
+
+/* Taken from the Sharp 2.4 kernel code */
+#define CCNT(a)     asm volatile ("mrc p14, 0, %0, C1, C1, 0" : "=r"(a))
+#define CCNT_ON()   asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(1))
+#define CCNT_OFF()  asm("mcr p14, 0, %0, C0, C0, 0" : : "r"(0))
+
+/* On the Sharp SL-6000 (Tosa), due to a noisy LCD, we need to perform a wait
+ * before sampling the Y axis of the touchscreen */
+static void tosa_lcd_sync_on(int adcsel)
+{
+	unsigned long timer1 = 0, timer2 = 0, wait_time = 0;
+	if (adcsel & WM97XX_ADCSEL_Y) {
+		CCNT_ON();
+		wait_time = hsync_time;
+
+		if (wait_time) {
+
+			/* wait for LCD rising edge */
+			tosa_lcd_wait_hsync();
+			/* get clock */
+			CCNT(timer1);
+			CCNT(timer2);
+
+			while ((timer2 - timer1) < wait_time) {
+				CCNT(timer2);
+			}
+		}
+	}
+}
+
+static void tosa_lcd_sync_off(int adcsel)
+{
+	if (adcsel & WM97XX_ADCSEL_Y)
+		CCNT_OFF();
+}
+
+static struct wm97xx_mach_ops tosa_mach_ops = {
+	.pre_sample =  tosa_lcd_sync_on,
+	.post_sample = tosa_lcd_sync_off,
+};
+
+static int __devinit tosa_ts_probe(struct platform_device *dev) {
+	struct wm97xx *wm = platform_get_drvdata(dev);
+	struct notifier_block *notif;
+	int err = -ENOMEM;
+
+	notif = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
+	if (!notif)
+		goto err_alloc;
+
+	notif->notifier_call = fb_notifier_callback;
+
+	err = gpio_request(TOSA_GPIO_VGA_LINE, "hsync");
+	if (err)
+		goto err_gpio;
+
+	err = gpio_direction_input(TOSA_GPIO_VGA_LINE);
+	if (err)
+		goto err_gpio;
+
+	platform_set_drvdata(dev, notif);
+
+	err = fb_register_client(notif);
+	if (err)
+		goto err_register;
+
+	err = wm97xx_register_mach_ops(wm, &tosa_mach_ops);
+	if (err)
+		goto err_wm97xx;
+
+	calc_hsync_time(tosa_lcd_get_mode());
+
+	return 0;
+
+err_wm97xx:
+	fb_unregister_client(notif);
+err_register:
+	gpio_free(TOSA_GPIO_VGA_LINE);
+err_gpio:
+	kfree(notif);
+err_alloc:
+	return err;
+}
+
+
+static int __devexit tosa_ts_remove(struct platform_device *dev) {
+	struct wm97xx *wm = platform_get_drvdata(dev);
+
+	wm97xx_unregister_mach_ops(wm);
+
+	fb_unregister_client(platform_get_drvdata(dev));
+	gpio_free(TOSA_GPIO_VGA_LINE);
+	kfree(platform_get_drvdata(dev));
+
+	return 0;
+}
+
+static struct platform_driver tosa_ts_driver = {
+	.driver.name = "wm97xx-touch",
+	.driver.owner = THIS_MODULE,
+	.probe = tosa_ts_probe,
+	.remove = __devexit_p(tosa_ts_remove),
+};
+
+static int __init tosa_ts_init(void)
+{
+	return platform_driver_register(&tosa_ts_driver);
+}
+
+static void __exit tosa_ts_exit(void)
+{
+	platform_driver_unregister(&tosa_ts_driver);
+}
+
+module_init(tosa_ts_init);
+module_exit(tosa_ts_exit);
+
+/* Module information */
+MODULE_AUTHOR("Dmitry Baryshkov, Mike Arthur, mike@mikearthur.co.uk, www.wolfsonmicro.com");
+MODULE_DESCRIPTION("Sharp SL6000 Tosa Touch Screen Denoiser");
+MODULE_LICENSE("GPL");
-- 
1.5.4.1