summaryrefslogtreecommitdiff
path: root/packages/linux/linux-jlime-arm-2.6.17/Newfile-Jornada720_ts.patch
blob: 6cfab690f3abced60c29d36d8780259cb86837d8 (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
--- linux-2.6.17/drivers/input/touchscreen/jornada720_ts.c_orig	2006-07-03 00:17:18.000000000 +0000
+++ linux-2.6.17/drivers/input/touchscreen/jornada720_ts.c	2006-07-03 00:16:37.000000000 +0000
@@ -0,0 +1,103 @@
+/*
+ * Jornada 720 touchscreen interface based on Jornada 56x interface
+ */
+ 
+#include <linux/input.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/jornada720.h>
+#include <asm/irq.h>
+#include <asm/mach/irq.h>
+
+MODULE_AUTHOR("Alex Lange <chicken@handhelds.org>");
+MODULE_DESCRIPTION("Jornada 720 touchscreen driver");
+MODULE_LICENSE("GPL");
+
+static char jornada720_ts_name[] = "Jornada 720 touchscreen";
+
+static struct input_dev dev;
+
+static irqreturn_t jornada720_mouse_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+	int down;
+	int X[3], Y[3], high_x, high_y, x, y;
+	
+	udelay(1);
+	
+	down = ( (GPLR & GPIO_JORNADA720_MOUSE) == 0);
+	
+	if(!down) {
+		input_report_key(&dev, BTN_TOUCH, down); /* report a pen up */
+		input_report_abs(&dev, ABS_PRESSURE, 0);
+		input_sync(&dev);
+		return IRQ_HANDLED;
+	}
+	
+	/* read x & y data from mcu interface and pass it on */
+	
+	jornada720_mcu_start(MCU_GetTouchSamples);
+	X[0] = jornada720_mcu_read();
+	X[1] = jornada720_mcu_read();
+	X[2] = jornada720_mcu_read();
+	Y[0] = jornada720_mcu_read();	
+	Y[1] = jornada720_mcu_read();
+	Y[2] = jornada720_mcu_read();
+	high_x = jornada720_mcu_read(); /* msbs of samples */
+	high_y = jornada720_mcu_read();	
+	jornada720_mcu_end();
+	
+	X[0] |= (high_x & 3) << 8;
+	X[1] |= (high_x & 0xc) << 6;
+	X[2] |= (high_x & 0x30) << 4;
+
+	Y[0] |= (high_y & 3) << 8;
+	Y[1] |= (high_y & 0xc) << 6;
+	Y[2] |= (high_y & 0x30) << 4;
+
+        /* simple averaging filter */
+	x = (X[0] + X[1] + X[2])/3;
+	y = (Y[0] + Y[1] + Y[2])/3;
+	
+	input_report_key(&dev, BTN_TOUCH, down);
+	input_report_abs(&dev, ABS_X, x);
+	input_report_abs(&dev, ABS_Y, y);
+	input_report_abs(&dev, ABS_PRESSURE, 1);
+	input_sync(&dev);
+	
+	return IRQ_HANDLED;
+	
+}
+
+static int __init jornada720_ts_init(void)
+{
+	printk("jornada720_ts: Jornada 720 touchscreen\n");
+	
+	init_input_dev(&dev);
+	dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+	dev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+	dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
+	
+	dev.absmin[ABS_X] = 270; dev.absmin[ABS_Y] = 180;
+	dev.absmax[ABS_X] = 3900;  dev.absmax[ABS_Y] = 3700;
+	
+	dev.name = jornada720_ts_name;
+
+	if (request_irq(GPIO_JORNADA720_MOUSE_IRQ, jornada720_mouse_interrupt, SA_INTERRUPT, "Jornada720 Mouse", NULL))
+		printk("Unable to grab Jornada 720 touchscreen IRQ!\n");
+		
+	set_irq_type(GPIO_JORNADA720_MOUSE_IRQ, IRQT_RISING);
+	
+	input_register_device(&dev);
+	
+	return 0;
+}
+
+module_init(jornada720_ts_init);
+