linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Hutterer <peter.hutterer@who-t.net>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	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
Date: Wed, 27 Jun 2018 11:10:11 +1000	[thread overview]
Message-ID: <20180627011011.GC25847@jelly> (raw)
In-Reply-To: <20180621120908.16706-13-benjamin.tissoires@redhat.com>

On Thu, Jun 21, 2018 at 02:09:08PM +0200, Benjamin Tissoires wrote:
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> 
> 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 <dmitry.torokhov@gmail.com>
> [rebased and new commit message]
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Acked-by: Peter Hutterer <peter.hutterer@who-t.net>

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
> 

      reply	other threads:[~2018-06-27  1:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 12:08 [PATCH v3 00/12] Hid multitouch rewrite, support os system multi-axis devices, take 3 Benjamin Tissoires
2018-06-21 12:08 ` [PATCH v3 01/12] input: add MT_TOOL_DIAL Benjamin Tissoires
2018-06-27  0:54   ` Peter Hutterer
2018-06-21 12:08 ` [PATCH v3 02/12] HID: multitouch: make sure the static list of class is not changed Benjamin Tissoires
2018-06-21 12:08 ` [PATCH v3 03/12] HID: multitouch: Store per collection multitouch data Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 04/12] HID: multitouch: store a per application quirks value Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 05/12] HID: multitouch: ditch mt_report_id Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 06/12] HID: multitouch: remove one copy of values Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 07/12] HID: input: enable Totem on the Dell Canvas 27 Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 08/12] HID: core: do not upper bound the collection stack Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 09/12] HID: microsoft: support the Surface Dial Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 10/12] HID: multitouch: report MT_TOOL_PALM for non-confident touches Benjamin Tissoires
2018-06-27  1:08   ` Peter Hutterer
2018-07-04 15:18     ` Dmitry Torokhov
2018-06-21 12:09 ` [PATCH v3 11/12] HID: multitouch: touchscreens also use confidence reports Benjamin Tissoires
2018-06-21 12:09 ` [PATCH v3 12/12] HID: multitouch: handle palm for touchscreens Benjamin Tissoires
2018-06-27  1:10   ` Peter Hutterer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180627011011.GC25847@jelly \
    --to=peter.hutterer@who-t.net \
    --cc=Mario.Limonciello@dell.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).