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

Input: sun4i-ts - allow controlling filter and sensitivity via DT

This commit introduces two new optional device-tree properties:
"tp-sensitive-adjust": adjust sensitivity of pen down detection
"filter-type": select median and averaging filter

The previous fixed defaults, didn't work well for the Olimex
A13-LCD10TS (I have).

Signed-off-by: Jens Thiele <karme@karme.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jens Thiele and committed by
Dmitry Torokhov
4ed0e032 68c581d5

+33 -6
+17 -2
Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
··· 9 9 - #thermal-sensor-cells: shall be 0 10 10 11 11 Optional properties: 12 - - allwinner,ts-attached: boolean indicating that an actual touchscreen is 13 - attached to the controller 12 + - allwinner,ts-attached : boolean indicating that an actual touchscreen 13 + is attached to the controller 14 + - allwinner,tp-sensitive-adjust : integer (4 bits) 15 + adjust sensitivity of pen down detection 16 + between 0 (least sensitive) and 15 17 + (defaults to 15) 18 + - allwinner,filter-type : integer (2 bits) 19 + select median and averaging filter 20 + samples used for median / averaging filter 21 + 0: 4/2 22 + 1: 5/3 23 + 2: 8/4 24 + 3: 16/8 25 + (defaults to 1) 14 26 15 27 Example: 16 28 ··· 32 20 interrupts = <29>; 33 21 allwinner,ts-attached; 34 22 #thermal-sensor-cells = <0>; 23 + /* sensitive/noisy touch panel */ 24 + allwinner,tp-sensitive-adjust = <0>; 25 + allwinner,filter-type = <3>; 35 26 };
+16 -4
drivers/input/touchscreen/sun4i-ts.c
··· 30 30 * These kinds of heuristics are just asking for trouble (and don't belong 31 31 * in the kernel). So this driver offers straight forward, reliable single 32 32 * touch functionality only. 33 + * 34 + * s.a. A20 User Manual "1.15 TP" (Documentation/arm/sunxi/README) 35 + * (looks like the description in the A20 User Manual v1.3 is better 36 + * than the one in the A10 User Manual v.1.5) 33 37 */ 34 38 35 39 #include <linux/err.h> ··· 250 246 int error; 251 247 u32 reg; 252 248 bool ts_attached; 249 + u32 tp_sensitive_adjust = 15; 250 + u32 filter_type = 1; 253 251 254 252 ts = devm_kzalloc(dev, sizeof(struct sun4i_ts_data), GFP_KERNEL); 255 253 if (!ts) ··· 328 322 ts->base + TP_CTRL0); 329 323 330 324 /* 331 - * sensitive_adjust = 15 : max, which is not all that sensitive, 325 + * tp_sensitive_adjust is an optional property 332 326 * tp_mode = 0 : only x and y coordinates, as we don't use dual touch 333 327 */ 334 - writel(TP_SENSITIVE_ADJUST(15) | TP_MODE_SELECT(0), 328 + of_property_read_u32(np, "allwinner,tp-sensitive-adjust", 329 + &tp_sensitive_adjust); 330 + writel(TP_SENSITIVE_ADJUST(tp_sensitive_adjust) | TP_MODE_SELECT(0), 335 331 ts->base + TP_CTRL2); 336 332 337 - /* Enable median filter, type 1 : 5/3 */ 338 - writel(FILTER_EN(1) | FILTER_TYPE(1), ts->base + TP_CTRL3); 333 + /* 334 + * Enable median and averaging filter, optional property for 335 + * filter type. 336 + */ 337 + of_property_read_u32(np, "allwinner,filter-type", &filter_type); 338 + writel(FILTER_EN(1) | FILTER_TYPE(filter_type), ts->base + TP_CTRL3); 339 339 340 340 /* Enable temperature measurement, period 1953 (2 seconds) */ 341 341 writel(TEMP_ENABLE(1) | TEMP_PERIOD(1953), ts->base + TP_TPR);