aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2015-03-12 17:50:36 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-03-12 17:53:10 -0400
commit877bef7de141db241e0c5d06db988b4ecbe29cf3 (patch)
tree7bea020aa908e9b21378429f5e0937c26bdff80b /drivers/input/touchscreen
parentb6310affbe2bf14cbe6b6d28db48e1e37d52fbca (diff)
Input: sun4i-ts - really fix A10 temperature reporting
The commit titled: "Input: sun4i-ts - A10 (sun4i) has a different temperature curve" contains a math error, the offset it uses is in degrees, but the actual code applies the offset before multiplying by stepsize :| Given that this is rather backwards (every math course ever thought applies the multiplication before the offset for linear functions), this commit fixes things by changing the code applying the offset to do the logical thing, adjusting the offset for the other models accordingly. This has been tested on an A10, A13, A20 and A31 to make sure everything really is correct now. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/sun4i-ts.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
index 66ccd5af537d..178d2efb8353 100644
--- a/drivers/input/touchscreen/sun4i-ts.c
+++ b/drivers/input/touchscreen/sun4i-ts.c
@@ -193,7 +193,7 @@ static int sun4i_get_temp(const struct sun4i_ts_data *ts, long *temp)
193 if (ts->temp_data == -1) 193 if (ts->temp_data == -1)
194 return -EAGAIN; 194 return -EAGAIN;
195 195
196 *temp = (ts->temp_data - ts->temp_offset) * ts->temp_step; 196 *temp = ts->temp_data * ts->temp_step - ts->temp_offset;
197 197
198 return 0; 198 return 0;
199} 199}
@@ -255,17 +255,17 @@ static int sun4i_ts_probe(struct platform_device *pdev)
255 ts->ignore_fifo_data = true; 255 ts->ignore_fifo_data = true;
256 ts->temp_data = -1; 256 ts->temp_data = -1;
257 if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) { 257 if (of_device_is_compatible(np, "allwinner,sun6i-a31-ts")) {
258 /* Allwinner SDK has temperature = -271 + (value / 6) (C) */ 258 /* Allwinner SDK has temperature (C) = (value / 6) - 271 */
259 ts->temp_offset = 1626; 259 ts->temp_offset = 271000;
260 ts->temp_step = 167; 260 ts->temp_step = 167;
261 } else if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) { 261 } else if (of_device_is_compatible(np, "allwinner,sun4i-a10-ts")) {
262 /* 262 /*
263 * The A10 temperature sensor has quite a wide spread, these 263 * The A10 temperature sensor has quite a wide spread, these
264 * parameters are based on the averaging of the calibration 264 * parameters are based on the averaging of the calibration
265 * results of 4 completely different boards, with a spread of 265 * results of 4 completely different boards, with a spread of
266 * temp_step from 96 - 170 and temp_offset from 1758 - 3310. 266 * temp_step from 0.096 - 0.170 and temp_offset from 176 - 331.
267 */ 267 */
268 ts->temp_offset = 2570; 268 ts->temp_offset = 257000;
269 ts->temp_step = 133; 269 ts->temp_step = 133;
270 } else { 270 } else {
271 /* 271 /*
@@ -273,13 +273,13 @@ static int sun4i_ts_probe(struct platform_device *pdev)
273 * the temperature. The formula used here is from the AXP209, 273 * the temperature. The formula used here is from the AXP209,
274 * which is designed by X-Powers, an affiliate of Allwinner: 274 * which is designed by X-Powers, an affiliate of Allwinner:
275 * 275 *
276 * temperature = -144.7 + (value * 0.1) 276 * temperature (C) = (value * 0.1) - 144.7
277 * 277 *
278 * Allwinner does not have any documentation whatsoever for 278 * Allwinner does not have any documentation whatsoever for
279 * this hardware. Moreover, it is claimed that the sensor 279 * this hardware. Moreover, it is claimed that the sensor
280 * is inaccurate and cannot work properly. 280 * is inaccurate and cannot work properly.
281 */ 281 */
282 ts->temp_offset = 1447; 282 ts->temp_offset = 144700;
283 ts->temp_step = 100; 283 ts->temp_step = 100;
284 } 284 }
285 285