aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/atmel_tsadcc.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:52:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:52:08 -0400
commit36ac1d2f323f8bf8bc10c25b88f617657720e241 (patch)
treed51f87bdf16eaa19ce0c5a682c10dccfaef4b48d /drivers/input/touchscreen/atmel_tsadcc.c
parentd7a6119f457f48a94985fdbdc400cbb03e136a76 (diff)
parent4c0e799a9a6dc64426ddb6c03aea1a154357658f (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (32 commits) Input: wm97xx - update email address for Liam Girdwood Input: i8042 - add Thinkpad R31 to nomux list Input: move map_to_7segment.h to include/linux Input: ads7846 - fix cache line sharing issue Input: cm109 - add missing newlines to messages Input: document i8042.debug in kernel-parameters.txt Input: keyboard - fix potential out of bound access to key_map Input: psmouse - add OLPC touchpad driver Input: psmouse - tweak PSMOUSE_DEFINE_ATTR to support raw set callbacks Input: psmouse - add psmouse_queue_work() for ps/2 extension to make use of Input: psmouse - export psmouse_set_state for ps/2 extensions to use Input: ads7846 - introduce .gpio_pendown to get pendown state Input: ALPS - add signature for DualPoint found in Dell Latitude E6500 Input: serio_raw - allow attaching to translated (SERIO_I8042XL) ports Input: cm109 - don't use obsolete logging macros Input: atkbd - expand Latitude's force release quirk to other Dells Input: bf54x-keys - add power management support Input: atmel_tsadcc - improve accuracy Input: convert drivers to use strict_strtoul() Input: appletouch - handle geyser 3/4 status bits ...
Diffstat (limited to 'drivers/input/touchscreen/atmel_tsadcc.c')
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
index eee126b19e8b..a89a6a8f05e6 100644
--- a/drivers/input/touchscreen/atmel_tsadcc.c
+++ b/drivers/input/touchscreen/atmel_tsadcc.c
@@ -91,6 +91,9 @@ struct atmel_tsadcc {
91 char phys[32]; 91 char phys[32];
92 struct clk *clk; 92 struct clk *clk;
93 int irq; 93 int irq;
94 unsigned int prev_absx;
95 unsigned int prev_absy;
96 unsigned char bufferedmeasure;
94}; 97};
95 98
96static void __iomem *tsc_base; 99static void __iomem *tsc_base;
@@ -100,10 +103,9 @@ static void __iomem *tsc_base;
100 103
101static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev) 104static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
102{ 105{
103 struct input_dev *input_dev = ((struct atmel_tsadcc *)dev)->input; 106 struct atmel_tsadcc *ts_dev = (struct atmel_tsadcc *)dev;
107 struct input_dev *input_dev = ts_dev->input;
104 108
105 unsigned int absx;
106 unsigned int absy;
107 unsigned int status; 109 unsigned int status;
108 unsigned int reg; 110 unsigned int reg;
109 111
@@ -121,6 +123,7 @@ static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
121 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT); 123 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
122 124
123 input_report_key(input_dev, BTN_TOUCH, 0); 125 input_report_key(input_dev, BTN_TOUCH, 0);
126 ts_dev->bufferedmeasure = 0;
124 input_sync(input_dev); 127 input_sync(input_dev);
125 128
126 } else if (status & ATMEL_TSADCC_PENCNT) { 129 } else if (status & ATMEL_TSADCC_PENCNT) {
@@ -138,16 +141,23 @@ static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
138 } else if (status & ATMEL_TSADCC_EOC(3)) { 141 } else if (status & ATMEL_TSADCC_EOC(3)) {
139 /* Conversion finished */ 142 /* Conversion finished */
140 143
141 absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10; 144 if (ts_dev->bufferedmeasure) {
142 absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2); 145 /* Last measurement is always discarded, since it can
143 146 * be erroneous.
144 absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10; 147 * Always report previous measurement */
145 absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0); 148 input_report_abs(input_dev, ABS_X, ts_dev->prev_absx);
146 149 input_report_abs(input_dev, ABS_Y, ts_dev->prev_absy);
147 input_report_abs(input_dev, ABS_X, absx); 150 input_report_key(input_dev, BTN_TOUCH, 1);
148 input_report_abs(input_dev, ABS_Y, absy); 151 input_sync(input_dev);
149 input_report_key(input_dev, BTN_TOUCH, 1); 152 } else
150 input_sync(input_dev); 153 ts_dev->bufferedmeasure = 1;
154
155 /* Now make new measurement */
156 ts_dev->prev_absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10;
157 ts_dev->prev_absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2);
158
159 ts_dev->prev_absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10;
160 ts_dev->prev_absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0);
151 } 161 }
152 162
153 return IRQ_HANDLED; 163 return IRQ_HANDLED;
@@ -223,6 +233,7 @@ static int __devinit atmel_tsadcc_probe(struct platform_device *pdev)
223 } 233 }
224 234
225 ts_dev->input = input_dev; 235 ts_dev->input = input_dev;
236 ts_dev->bufferedmeasure = 0;
226 237
227 snprintf(ts_dev->phys, sizeof(ts_dev->phys), 238 snprintf(ts_dev->phys, sizeof(ts_dev->phys),
228 "%s/input0", pdev->dev.bus_id); 239 "%s/input0", pdev->dev.bus_id);