Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: ili210x - implement pressure reporting for ILI251x

The ILI251x seems to report pressure information in the 5th byte of
each per-finger touch data element. On the available hardware, this
information has the values ranging from 0x0 to 0xa, which is also
matching the downstream example code. Report pressure information
on the ILI251x.

Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20201224071238.160098-1-marex@denx.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Marek Vasut and committed by
Dmitry Torokhov
60159e9e a3a9060e

+19 -7
+19 -7
drivers/input/touchscreen/ili210x.c
··· 29 29 void *buf, size_t len); 30 30 int (*get_touch_data)(struct i2c_client *client, u8 *data); 31 31 bool (*parse_touch_data)(const u8 *data, unsigned int finger, 32 - unsigned int *x, unsigned int *y); 32 + unsigned int *x, unsigned int *y, 33 + unsigned int *z); 33 34 bool (*continue_polling)(const u8 *data, bool touch); 34 35 unsigned int max_touches; 35 36 unsigned int resolution; 36 37 bool has_calibrate_reg; 38 + bool has_pressure_reg; 37 39 }; 38 40 39 41 struct ili210x { ··· 84 82 85 83 static bool ili210x_touchdata_to_coords(const u8 *touchdata, 86 84 unsigned int finger, 87 - unsigned int *x, unsigned int *y) 85 + unsigned int *x, unsigned int *y, 86 + unsigned int *z) 88 87 { 89 88 if (touchdata[0] & BIT(finger)) 90 89 return false; ··· 140 137 141 138 static bool ili211x_touchdata_to_coords(const u8 *touchdata, 142 139 unsigned int finger, 143 - unsigned int *x, unsigned int *y) 140 + unsigned int *x, unsigned int *y, 141 + unsigned int *z) 144 142 { 145 143 u32 data; 146 144 ··· 173 169 174 170 static bool ili212x_touchdata_to_coords(const u8 *touchdata, 175 171 unsigned int finger, 176 - unsigned int *x, unsigned int *y) 172 + unsigned int *x, unsigned int *y, 173 + unsigned int *z) 177 174 { 178 175 u16 val; 179 176 ··· 240 235 241 236 static bool ili251x_touchdata_to_coords(const u8 *touchdata, 242 237 unsigned int finger, 243 - unsigned int *x, unsigned int *y) 238 + unsigned int *x, unsigned int *y, 239 + unsigned int *z) 244 240 { 245 241 u16 val; 246 242 ··· 251 245 252 246 *x = val & 0x3fff; 253 247 *y = get_unaligned_be16(touchdata + 1 + (finger * 5) + 2); 248 + *z = touchdata[1 + (finger * 5) + 4]; 254 249 255 250 return true; 256 251 } ··· 268 261 .continue_polling = ili251x_check_continue_polling, 269 262 .max_touches = 10, 270 263 .has_calibrate_reg = true, 264 + .has_pressure_reg = true, 271 265 }; 272 266 273 267 static bool ili210x_report_events(struct ili210x *priv, u8 *touchdata) ··· 276 268 struct input_dev *input = priv->input; 277 269 int i; 278 270 bool contact = false, touch; 279 - unsigned int x = 0, y = 0; 271 + unsigned int x = 0, y = 0, z = 0; 280 272 281 273 for (i = 0; i < priv->chip->max_touches; i++) { 282 - touch = priv->chip->parse_touch_data(touchdata, i, &x, &y); 274 + touch = priv->chip->parse_touch_data(touchdata, i, &x, &y, &z); 283 275 284 276 input_mt_slot(input, i); 285 277 if (input_mt_report_slot_state(input, MT_TOOL_FINGER, touch)) { 286 278 touchscreen_report_pos(input, &priv->prop, x, y, true); 279 + if (priv->chip->has_pressure_reg) 280 + input_report_abs(input, ABS_MT_PRESSURE, z); 287 281 contact = true; 288 282 } 289 283 } ··· 447 437 max_xy = (chip->resolution ?: SZ_64K) - 1; 448 438 input_set_abs_params(input, ABS_MT_POSITION_X, 0, max_xy, 0, 0); 449 439 input_set_abs_params(input, ABS_MT_POSITION_Y, 0, max_xy, 0, 0); 440 + if (priv->chip->has_pressure_reg) 441 + input_set_abs_params(input, ABS_MT_PRESSURE, 0, 0xa, 0, 0); 450 442 touchscreen_parse_properties(input, true, &priv->prop); 451 443 452 444 error = input_mt_init_slots(input, priv->chip->max_touches,