aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mousedev.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/mousedev.c')
-rw-r--r--drivers/input/mousedev.c44
1 files changed, 26 insertions, 18 deletions
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index d8f68f77007b..83c24cca234a 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -22,6 +22,7 @@
22#include <linux/random.h> 22#include <linux/random.h>
23#include <linux/major.h> 23#include <linux/major.h>
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/kernel.h>
25#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 26#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
26#include <linux/miscdevice.h> 27#include <linux/miscdevice.h>
27#endif 28#endif
@@ -134,11 +135,14 @@ static void mousedev_touchpad_event(struct input_dev *dev,
134 switch (code) { 135 switch (code) {
135 136
136 case ABS_X: 137 case ABS_X:
138
137 fx(0) = value; 139 fx(0) = value;
138 if (mousedev->touch && mousedev->pkt_count >= 2) { 140 if (mousedev->touch && mousedev->pkt_count >= 2) {
139 size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; 141 size = input_abs_get_min(dev, ABS_X) -
142 input_abs_get_max(dev, ABS_X);
140 if (size == 0) 143 if (size == 0)
141 size = 256 * 2; 144 size = 256 * 2;
145
142 tmp = ((value - fx(2)) * 256 * FRACTION_DENOM) / size; 146 tmp = ((value - fx(2)) * 256 * FRACTION_DENOM) / size;
143 tmp += mousedev->frac_dx; 147 tmp += mousedev->frac_dx;
144 mousedev->packet.dx = tmp / FRACTION_DENOM; 148 mousedev->packet.dx = tmp / FRACTION_DENOM;
@@ -150,10 +154,12 @@ static void mousedev_touchpad_event(struct input_dev *dev,
150 case ABS_Y: 154 case ABS_Y:
151 fy(0) = value; 155 fy(0) = value;
152 if (mousedev->touch && mousedev->pkt_count >= 2) { 156 if (mousedev->touch && mousedev->pkt_count >= 2) {
153 /* use X size to keep the same scale */ 157 /* use X size for ABS_Y to keep the same scale */
154 size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; 158 size = input_abs_get_min(dev, ABS_X) -
159 input_abs_get_max(dev, ABS_X);
155 if (size == 0) 160 if (size == 0)
156 size = 256 * 2; 161 size = 256 * 2;
162
157 tmp = -((value - fy(2)) * 256 * FRACTION_DENOM) / size; 163 tmp = -((value - fy(2)) * 256 * FRACTION_DENOM) / size;
158 tmp += mousedev->frac_dy; 164 tmp += mousedev->frac_dy;
159 mousedev->packet.dy = tmp / FRACTION_DENOM; 165 mousedev->packet.dy = tmp / FRACTION_DENOM;
@@ -167,33 +173,35 @@ static void mousedev_touchpad_event(struct input_dev *dev,
167static void mousedev_abs_event(struct input_dev *dev, struct mousedev *mousedev, 173static void mousedev_abs_event(struct input_dev *dev, struct mousedev *mousedev,
168 unsigned int code, int value) 174 unsigned int code, int value)
169{ 175{
170 int size; 176 int min, max, size;
171 177
172 switch (code) { 178 switch (code) {
173 179
174 case ABS_X: 180 case ABS_X:
175 size = dev->absmax[ABS_X] - dev->absmin[ABS_X]; 181 min = input_abs_get_min(dev, ABS_X);
182 max = input_abs_get_max(dev, ABS_X);
183
184 size = max - min;
176 if (size == 0) 185 if (size == 0)
177 size = xres ? : 1; 186 size = xres ? : 1;
178 if (value > dev->absmax[ABS_X]) 187
179 value = dev->absmax[ABS_X]; 188 clamp(value, min, max);
180 if (value < dev->absmin[ABS_X]) 189
181 value = dev->absmin[ABS_X]; 190 mousedev->packet.x = ((value - min) * xres) / size;
182 mousedev->packet.x =
183 ((value - dev->absmin[ABS_X]) * xres) / size;
184 mousedev->packet.abs_event = 1; 191 mousedev->packet.abs_event = 1;
185 break; 192 break;
186 193
187 case ABS_Y: 194 case ABS_Y:
188 size = dev->absmax[ABS_Y] - dev->absmin[ABS_Y]; 195 min = input_abs_get_min(dev, ABS_Y);
196 max = input_abs_get_max(dev, ABS_Y);
197
198 size = max - min;
189 if (size == 0) 199 if (size == 0)
190 size = yres ? : 1; 200 size = yres ? : 1;
191 if (value > dev->absmax[ABS_Y]) 201
192 value = dev->absmax[ABS_Y]; 202 clamp(value, min, max);
193 if (value < dev->absmin[ABS_Y]) 203
194 value = dev->absmin[ABS_Y]; 204 mousedev->packet.y = yres - ((value - min) * yres) / size;
195 mousedev->packet.y = yres -
196 ((value - dev->absmin[ABS_Y]) * yres) / size;
197 mousedev->packet.abs_event = 1; 205 mousedev->packet.abs_event = 1;
198 break; 206 break;
199 } 207 }