6e424c626cf51d18b09df373f8331648307f0403
[openembedded.git] / packages / linux / linux-ezx-2.6.21 / wyrm-ts.diff
1 Ignores read interrupts after penUP events until a penDOWN interrupt arrives.
2 Some other changes i dont remember exactly. :)
3 Signed-off-by: Daniel Ribeiro <drwyrm@gmail.com>
4 Index: linux-2.6.16/drivers/input/touchscreen/pcap_ts.c
5 ===================================================================
6 --- linux-2.6.16.orig/drivers/input/touchscreen/pcap_ts.c       2007-03-09 21:26:25.000000000 -0300
7 +++ linux-2.6.16/drivers/input/touchscreen/pcap_ts.c    2007-03-09 21:26:42.000000000 -0300
8 @@ -31,7 +31,7 @@
9  
10  #include "../../misc/ezx/ssp_pcap.h"
11  
12 -#if 1
13 +#if 0
14  #define DEBUGP(x, args ...) printk(KERN_DEBUG "%s: " x, __FUNCTION__, ## args)
15  #else
16  #define DEBUGP(x, args ...)
17 @@ -39,6 +39,7 @@
18  
19  #define PRESSURE 1
20  #define COORDINATE 2
21 +#define STANDBY 3
22  
23  struct pcap_ts {
24         int irq_xy;
25 @@ -97,7 +98,7 @@
26         int ret;
27         u_int32_t tmp;
28         DEBUGP("start xy read in mode %s\n", 
29 -               pcap_ts->read_state == COORDINATE ? "COORD" : "PRESS");
30 +               pcap_ts->read_state == COORDINATE ? "COORD" : (pcap_ts->read_state == PRESSURE ? "PRESS" : "STANDBY"));
31  
32         ret = ezx_pcap_read(SSP_PCAP_ADJ_ADC1_REGISTER, &tmp);
33         if (ret < 0)
34 @@ -122,7 +123,7 @@
35         u_int32_t tmp;
36  
37         DEBUGP("get xy value in mode %s\n", 
38 -               pcap_ts->read_state == COORDINATE ? "COORD" : "PRESS");
39 +               pcap_ts->read_state == COORDINATE ? "COORD" : (pcap_ts->read_state == PRESSURE ? "PRESS" : "STANDBY"));
40  
41         ret = ezx_pcap_read(SSP_PCAP_ADJ_ADC2_REGISTER, &tmp);
42         if (ret < 0)
43 @@ -145,7 +146,16 @@
44  static irqreturn_t pcap_ts_irq_xy(int irq, void *dev_id, struct pt_regs *regs)
45  {
46         struct pcap_ts *pcap_ts = dev_id;
47 +//     DEBUGP("read_state: %d\n", pcap_ts->read_state);
48  
49 +       /*
50 +        * Ignore further read interrupts after we set STANDBY - WM
51 +        */
52 +       if (pcap_ts->read_state == STANDBY)
53 +       {
54 +               DEBUGP("ignored\n");
55 +               return IRQ_HANDLED;
56 +       }
57         if (pcap_ts_get_xy_value(pcap_ts) < 0) {
58                 printk("pcap_ts: error reading XY value\n");
59                 return IRQ_HANDLED;
60 @@ -160,33 +170,32 @@
61                      pcap_ts->pressure <= PRESSURE_MIN ) &&
62                     pcap_ts->pressure == pcap_ts->pressure_last) {
63                         /* pen has been released */
64 +                       DEBUGP("UP\n");
65                         input_report_key(pcap_ts->input, BTN_TOUCH, 0);
66 -                       input_sync(pcap_ts->input);
67 -
68                         input_report_abs(pcap_ts->input, ABS_PRESSURE, 0);
69 +                       input_sync(pcap_ts->input);
70  
71                         pcap_ts->x = pcap_ts->y = 0;
72  
73 +                       /* no need for timer, we'll get interrupted with
74 +                        * next touch down event */
75 +                       del_timer(&pcap_ts->timer);
76 +
77                         /* ask PCAP2 to interrupt us if touch event happens
78                          * again */
79 -                       pcap_ts->read_state = PRESSURE;
80 +                       pcap_ts->read_state = STANDBY;
81                         pcap_ts_mode(PCAP_TS_STANDBY_MODE);
82                         ezx_pcap_bit_set(SSP_PCAP_ADJ_BIT_MSR_TSM, 0);
83 -
84 -                       /* no need for timer, we'll get interrupted with
85 -                        * next touch down event */
86 -                       del_timer(&pcap_ts->timer);
87                 } else {
88                         /* pen has been touched down */
89 +                       DEBUGP("DOWN\n");
90 +
91                         input_report_key(pcap_ts->input, BTN_TOUCH, 1);
92                         /* don't input_sync(), we don't know position yet */
93  
94                         if (pcap_ts->pressure == 0) 
95                                 pcap_ts->pressure = pcap_ts->pressure_last;
96  
97 -                       input_report_abs(pcap_ts->input, ABS_PRESSURE,
98 -                               pcap_ts->pressure);
99 -
100                         /* switch state machine into coordinate read mode */
101                         pcap_ts->read_state = COORDINATE;
102                         pcap_ts_mode(PCAP_TS_POSITION_XY_MEASUREMENT);
103 @@ -196,18 +205,14 @@
104                 /* we are in coordinate mode */
105                 if (pcap_ts->x <= X_AXIS_MIN || pcap_ts->x >= X_AXIS_MAX ||
106                     pcap_ts->y <= Y_AXIS_MIN || pcap_ts->y >= Y_AXIS_MAX) {
107 -                       DEBUGP("invalid x/y coordinate position: PEN_UP?\n");
108 -
109 +                       DEBUGP("PEN_UP?\n");
110                         pcap_ts->pressure = 0;
111 -#if 0
112 -                       input_report_key(pcap_ts->input, BTN_TOUCH, 0);
113 -                       pcap_ts->x = pcap_ts->y = 0;
114 -#endif
115                 } else {
116 +                       input_report_abs(pcap_ts->input, ABS_PRESSURE, pcap_ts->pressure);
117                         input_report_abs(pcap_ts->input, ABS_X, pcap_ts->x);
118                         input_report_abs(pcap_ts->input, ABS_Y, pcap_ts->y);
119 +                       input_sync(pcap_ts->input);
120                 }
121 -               input_sync(pcap_ts->input);
122  
123                 /* switch back to pressure read mode */
124                 pcap_ts->read_state = PRESSURE;