Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5904527imm; Tue, 26 Jun 2018 21:45:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdfwDePDC3FfAp6DMNMEJGfmxi/6MunleXf60VtpIYfRDIqrSWRU5H3zhW/kPSSr9JH53pk X-Received: by 2002:a62:5247:: with SMTP id g68-v6mr4293847pfb.149.1530074725214; Tue, 26 Jun 2018 21:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530074725; cv=none; d=google.com; s=arc-20160816; b=y4pORNYf8o2IdYm24gl+Zw7fzOLn3b1vY9j2REtjLCQ54/SY7lOeqIKMIvSUoMXf75 LXeCGr8912LFpPD/ZLoUW4ivlDRE4aBcANkEQX1CghwksrCM0cQFo2H3ySI0TcDsezW9 RJlupT5Wsu3IpsMJlH7MIyRKVkd6jYaoqZwDDoa6bJoyXgcuN27unGK4TNvQXqFmM74G 7CZisnR5uCtIxsNI3nTZeKQyFY+ipA9XwHPoPeKd50ye9eVk074xST0mrDaZPYi2v2Iv h/tgDxSSAvEv9KnOMMtZHJY2LN8OzE43ZJG8LOqeGi+CZsbQdku55/vr5glX3HCs5+AR tdlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=hD5i+aA3YapYgSK/kmVrhqHWWdJ9SRKN0q1zsxI0pBc=; b=Ji4uAtN21jZxYU8B/oR9IDI4dW79Yk2c/cKRX9RmSYrh+9/ONTHGUFe5/NdDBYAbd1 XiSLT6EeP5+mLjby3kjLwLWTk9CAd1GdUx8gv9+vi0N8PiNs5ENHcKPHYro1h0pkO0Qd Gaf5UCuqRA3byYCv5RocHIViZezShKCPGa9Xc/Y2LTd8N6v2nKu8aS040DOlqRpHsH1a fm51Ql73U5sTrbeJY7tmR/nnM0kCh9kQuv/TZ+SDzPbUm42h+PEKmiP0Il/YOnnNexrc 1TRkOVmR59UbJ4VCgTUC8b6CGopqqE18osmK15hhZxWcX0pKQGilvdkipvGu7tmR4Kwv qWCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j189-v6si3175457pfg.351.2018.06.26.21.45.10; Tue, 26 Jun 2018 21:45:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934606AbeF0BKY (ORCPT + 99 others); Tue, 26 Jun 2018 21:10:24 -0400 Received: from leo.clearchain.com ([199.73.29.74]:46731 "EHLO mail.clearchain.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933723AbeF0BKX (ORCPT ); Tue, 26 Jun 2018 21:10:23 -0400 Received: from leo.clearchain.com (localhost [127.0.0.1]) by mail.clearchain.com (8.15.2/8.15.2) with ESMTPS id w5R1AFij000761 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 27 Jun 2018 10:40:15 +0930 (CST) (envelope-from peter.hutterer@who-t.net) X-Authentication-Warning: leo.clearchain.com: Host localhost [127.0.0.1] claimed to be leo.clearchain.com Received: (from whot@localhost) by leo.clearchain.com (8.15.2/8.15.2/Submit) id w5R1AFXU000759; Wed, 27 Jun 2018 10:40:15 +0930 (CST) (envelope-from peter.hutterer@who-t.net) X-Authentication-Warning: leo.clearchain.com: whot set sender to peter.hutterer@who-t.net using -f Date: Wed, 27 Jun 2018 11:10:11 +1000 From: Peter Hutterer To: Benjamin Tissoires Cc: Jiri Kosina , Dmitry Torokhov , Mario.Limonciello@dell.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 12/12] HID: multitouch: handle palm for touchscreens Message-ID: <20180627011011.GC25847@jelly> References: <20180621120908.16706-1-benjamin.tissoires@redhat.com> <20180621120908.16706-13-benjamin.tissoires@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180621120908.16706-13-benjamin.tissoires@redhat.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.4.3 (mail.clearchain.com [127.0.0.1]); Wed, 27 Jun 2018 10:40:16 +0930 (CST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 21, 2018 at 02:09:08PM +0200, Benjamin Tissoires wrote: > From: Dmitry Torokhov > > Usually, there is no palm rejection for touchscreens. You don't rest > your palm on the touchscreen while interacting with it. > However, some wacom devices do so because you can rest your palm while > interacting with the stylus. > > Unfortunately, the spec for touchscreens[1] is less precise than the one > for touchpads[2]. This leads to a situation where it's 'legitimate' > for a touchscreen to provide both tipswitch off and confidence off in the > same report. > > Work around that by keeping the slot active for one frame where we report > MT_TOOL_PALM, and then synthesizing the release event in a separate frame. > frame > > Signed-off-by: Dmitry Torokhov > [rebased and new commit message] > Signed-off-by: Benjamin Tissoires Acked-by: Peter Hutterer to the series unless otherwise noted. Cheers, Peter > --- > changes in v2 (compared to Dmitry's initial submission): > - extracted from the initial submission in a separate patch > - rebased on top of my current series > - add an extra input_mt_sync_frame(input); to release the single touch > emulation > > no changes in v3 > --- > drivers/hid/hid-multitouch.c | 52 +++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 51 insertions(+), 1 deletion(-) > > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c > index 9c708aa261ee..3a1c2d80729b 100644 > --- a/drivers/hid/hid-multitouch.c > +++ b/drivers/hid/hid-multitouch.c > @@ -118,6 +118,9 @@ struct mt_application { > int left_button_state; /* left button state */ > unsigned int mt_flags; /* flags to pass to input-mt */ > > + unsigned long *pending_palm_slots; /* slots where we reported palm > + * and need to release */ > + > __u8 num_received; /* how many contacts we received */ > __u8 num_expected; /* expected last contact index */ > __u8 buttons_count; /* number of physical buttons per touchpad */ > @@ -863,6 +866,28 @@ static int mt_compute_slot(struct mt_device *td, struct mt_application *app, > return input_mt_get_slot_by_key(input, *slot->contactid); > } > > +static void mt_release_pending_palms(struct mt_device *td, > + struct mt_application *app, > + struct input_dev *input) > +{ > + int slotnum; > + bool need_sync = false; > + > + for_each_set_bit(slotnum, app->pending_palm_slots, td->maxcontacts) { > + clear_bit(slotnum, app->pending_palm_slots); > + > + input_mt_slot(input, slotnum); > + input_mt_report_slot_state(input, MT_TOOL_PALM, false); > + > + need_sync = true; > + } > + > + if (need_sync) { > + input_mt_sync_frame(input); > + input_sync(input); > + } > +} > + > /* > * this function is called when a whole packet has been received and processed, > * so that it can decide what to send to the input layer. > @@ -876,6 +901,9 @@ static void mt_sync_frame(struct mt_device *td, struct mt_application *app, > input_mt_sync_frame(input); > input_event(input, EV_MSC, MSC_TIMESTAMP, app->timestamp); > input_sync(input); > + > + mt_release_pending_palms(td, app, input); > + > app->num_received = 0; > app->left_button_state = 0; > > @@ -970,8 +998,23 @@ static int mt_process_slot(struct mt_device *td, struct input_dev *input, > > if (app->application == HID_GD_SYSTEM_MULTIAXIS) > tool = MT_TOOL_DIAL; > - else if (unlikely(!confidence_state)) > + else if (unlikely(!confidence_state)) { > tool = MT_TOOL_PALM; > + if (!active && > + input_mt_is_active(&mt->slots[slotnum])) { > + /* > + * The non-confidence was reported for > + * previously valid contact that is also no > + * longer valid. We can't simply report > + * lift-off as userspace will not be aware > + * of non-confidence, so we need to split > + * it into 2 events: active MT_TOOL_PALM > + * and a separate liftoff. > + */ > + active = true; > + set_bit(slotnum, app->pending_palm_slots); > + } > + } > > input_mt_slot(input, slotnum); > input_mt_report_slot_state(input, tool, active); > @@ -1206,6 +1249,13 @@ static int mt_touch_input_configured(struct hid_device *hdev, > if (td->is_buttonpad) > __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); > > + app->pending_palm_slots = devm_kcalloc(&hi->input->dev, > + BITS_TO_LONGS(td->maxcontacts), > + sizeof(long), > + GFP_KERNEL); > + if (!app->pending_palm_slots) > + return -ENOMEM; > + > ret = input_mt_init_slots(input, td->maxcontacts, app->mt_flags); > if (ret) > return ret; > -- > 2.14.3 >