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

Input: MT - make slot cleanup callable outside mt_sync_frame()

Some semi-mt drivers use the slots in a manual way, but may still
want to call parts of the frame synchronization logic. This patch
makes input_mt_drop_unused callable from those drivers.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Reviewed-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Henrik Rydberg and committed by
Dmitry Torokhov
f8ec8949 437d4f37

+28 -11
+27 -11
drivers/input/input-mt.c
··· 237 237 EXPORT_SYMBOL(input_mt_report_pointer_emulation); 238 238 239 239 /** 240 + * input_mt_drop_unused() - Inactivate slots not seen in this frame 241 + * @dev: input device with allocated MT slots 242 + * 243 + * Lift all slots not seen since the last call to this function. 244 + */ 245 + void input_mt_drop_unused(struct input_dev *dev) 246 + { 247 + struct input_mt *mt = dev->mt; 248 + int i; 249 + 250 + if (!mt) 251 + return; 252 + 253 + for (i = 0; i < mt->num_slots; i++) { 254 + if (!input_mt_is_used(mt, &mt->slots[i])) { 255 + input_mt_slot(dev, i); 256 + input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); 257 + } 258 + } 259 + 260 + mt->frame++; 261 + } 262 + EXPORT_SYMBOL(input_mt_drop_unused); 263 + 264 + /** 240 265 * input_mt_sync_frame() - synchronize mt frame 241 266 * @dev: input device with allocated MT slots 242 267 * ··· 272 247 void input_mt_sync_frame(struct input_dev *dev) 273 248 { 274 249 struct input_mt *mt = dev->mt; 275 - struct input_mt_slot *s; 276 250 bool use_count = false; 277 251 278 252 if (!mt) 279 253 return; 280 254 281 - if (mt->flags & INPUT_MT_DROP_UNUSED) { 282 - for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { 283 - if (input_mt_is_used(mt, s)) 284 - continue; 285 - input_mt_slot(dev, s - mt->slots); 286 - input_event(dev, EV_ABS, ABS_MT_TRACKING_ID, -1); 287 - } 288 - } 255 + if (mt->flags & INPUT_MT_DROP_UNUSED) 256 + input_mt_drop_unused(dev); 289 257 290 258 if ((mt->flags & INPUT_MT_POINTER) && !(mt->flags & INPUT_MT_SEMI_MT)) 291 259 use_count = true; 292 260 293 261 input_mt_report_pointer_emulation(dev, use_count); 294 - 295 - mt->frame++; 296 262 } 297 263 EXPORT_SYMBOL(input_mt_sync_frame); 298 264
+1
include/linux/input/mt.h
··· 105 105 106 106 void input_mt_report_finger_count(struct input_dev *dev, int count); 107 107 void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count); 108 + void input_mt_drop_unused(struct input_dev *dev); 108 109 109 110 void input_mt_sync_frame(struct input_dev *dev); 110 111