linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mark Pearson" <mpearson-lenovo@squebb.ca>
To: "Hans de Goede" <hdegoede@redhat.com>
Cc: dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org,
	"platform-driver-x86@vger.kernel.org"
	<platform-driver-x86@vger.kernel.org>,
	"Vishnu Sankar" <vsankar@lenovo.com>,
	ibm-acpi-devel@lists.sourceforge.net,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
	linux-input@vger.kernel.org,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Peter Hutterer" <peter.hutterer@redhat.com>,
	"Nitin Joshi1" <njoshi1@lenovo.com>
Subject: Re: [ibm-acpi-devel] [PATCH 2/4] platform/x86: thinkpad_acpi: Support for trackpoint doubletap
Date: Mon, 08 Apr 2024 10:56:25 -0400	[thread overview]
Message-ID: <e88a2f41-f89d-444c-a09a-487097c6e9eb@app.fastmail.com> (raw)
In-Reply-To: <e1ccf281-5c77-4447-a6c7-5b0b008c7c56@redhat.com>

Hi Hans,

Many thanks for the review.

On Mon, Apr 8, 2024, at 9:04 AM, Hans de Goede wrote:
> Hi Mark,
>
> On 3/24/24 10:07 PM, Mark Pearson wrote:
>> Lenovo trackpoints are adding the ability to generate a doubletap event.
>> This handles the doubletap event and sends the KEY_DOUBLECLICK event to
>> userspace.
>> 
>> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Vishnu Sankar <vsankar@lenovo.com>
>> ---
>>  drivers/platform/x86/thinkpad_acpi.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>> 
>> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
>> index 82429e59999d..2bbb32c898e9 100644
>> --- a/drivers/platform/x86/thinkpad_acpi.c
>> +++ b/drivers/platform/x86/thinkpad_acpi.c
>> @@ -232,6 +232,7 @@ enum tpacpi_hkey_event_t {
>>  
>>  	/* Misc */
>>  	TP_HKEY_EV_RFKILL_CHANGED	= 0x7000, /* rfkill switch changed */
>> +	TP_HKEY_EV_TRACKPOINT_DOUBLETAP = 0x8036, /* doubletap on Trackpoint*/
>>  };
>>  
>>  /****************************************************************************
>> @@ -4081,6 +4082,22 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
>>  				break;
>>  			}
>>  			fallthrough;	/* to default */
>
> This now no longer fallsthrough to default. IMHO the best thing to do
> here is add a new preparation patch which initializes known_ev to false
> inside the while before the switch-case (together with the send_acpi_ev
> and ignore_acpi_ev init). and then change this fallthrough to a break
> in the preparation patch. You can then also remove the default case
> altogether in this prep patch.
>
Ack - that makes sense. I'll look at doing that.

>> +		case 8:
>> +			/* 0x8036: Trackpoint doubletaps */
>> +			if (hkey == TP_HKEY_EV_TRACKPOINT_DOUBLETAP) {
>> +				send_acpi_ev = true;
>> +				ignore_acpi_ev = false;
>
> These 2 values are set as the default above the switch-case, please
> drop these 2 lines.

Agreed. Will change.

>
>> +				known_ev = true;
>> +				/* Send to user space */
>> +				mutex_lock(&tpacpi_inputdev_send_mutex);
>> +				input_report_key(tpacpi_inputdev, KEY_DOUBLECLICK, 1);
>> +				input_sync(tpacpi_inputdev);
>> +				input_report_key(tpacpi_inputdev, KEY_DOUBLECLICK, 0);
>> +				input_sync(tpacpi_inputdev);
>> +				mutex_unlock(&tpacpi_inputdev_send_mutex);
>
> This code duplicates tpacpi_input_send_key(), what you want to do here
> is define a hotkey_keycode_map scancode range for new 0x8xxx codes like how this
> was done when extended scancodes where added to deal with the new 0x13xx hotkey
> event codes for the 2017+ models.
>
> See commit 696c6523ec8f ("platform/x86: thinkpad_acpi: add mapping for 
> new hotkeys")
>
> Despite re-using tpacpi_input_send_key() there are 2 reasons why we want
> scancodes for these new "keys".
>
> 1. By adding the keys to the hotkey_keycode_map they automatically
> also get input_set_capability(tpacpi_inputdev, EV_KEY, hotkey_keycode_map[i]);
> called on them advertising to userspace that tpacpi_inputdev can actually
> generate these keypresses. Something which is currently lacking from your
> patch. Related to this did you test this with evtest? I think that the input
> core will suppress the events when you do not set the capability ?
>
> 2. This allows remapping scancodes to different KEY_foo values with hwdb
> entries.
>
Will look into doing this.
There was a reason originally I did it like this, but I can't remember what it was. I'll revisit it.

I did test with evtest but I ended up having to cheat as there's quite a few layers in userspace and I got a bit bogged down chewing my way through those (building them against the right headers etc). 
I ended up using an already existing code to make sure it was doing the right thing in the driver - and then assumed that once the keycode was 'released', and the different user space projects updated per normal procedure, it would work. It's possible it meant I bypassed/missed this issue so I'll retry once I've made the updates.

Mark

  reply	other threads:[~2024-04-08 14:56 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 21:07 [PATCH 0/4] platform/x86,input: Support for new events on Mark Pearson
2024-03-24 21:07 ` [PATCH 1/4] Input: Add trackpoint doubletap and system debug info keycodes Mark Pearson
2024-04-08 12:45   ` Hans de Goede
2024-04-08 23:31   ` Dmitry Torokhov
2024-04-09  0:00     ` Mark Pearson
2024-04-09 10:16       ` Hans de Goede
2024-04-09 21:54         ` Dmitry Torokhov
2024-04-09  5:23     ` Peter Hutterer
2024-04-09 21:47       ` Dmitry Torokhov
2024-04-10  1:20         ` Dmitry Torokhov
2024-04-10  2:17           ` Mark Pearson
2024-04-11  0:02             ` Dmitry Torokhov
2024-04-11  2:48               ` Mark Pearson
2024-04-15 19:40                 ` Dmitry Torokhov
2024-04-15 19:50                   ` Hans de Goede
2024-04-15 19:58                     ` Dmitry Torokhov
2024-04-15 20:28                       ` Mark Pearson
2024-04-15 22:54                         ` Dmitry Torokhov
2024-04-15 23:57                           ` Mark Pearson
2024-04-16  8:33                             ` Hans de Goede
2024-04-16 12:48                               ` Mark Pearson
2024-04-16 13:03                                 ` Hans de Goede
2024-04-16  8:35                       ` Hans de Goede
2024-04-11 12:30               ` Hans de Goede
2024-04-15 19:35                 ` Dmitry Torokhov
2024-04-15 19:47                   ` Hans de Goede
2024-04-15 19:55                     ` Dmitry Torokhov
2024-04-10  4:32           ` Peter Hutterer
2024-04-15 19:32             ` Dmitry Torokhov
2024-03-24 21:07 ` [PATCH 2/4] platform/x86: thinkpad_acpi: Support for trackpoint doubletap Mark Pearson
2024-04-08 13:04   ` Hans de Goede
2024-04-08 14:56     ` Mark Pearson [this message]
2024-03-24 21:08 ` [PATCH 3/4] platform/x86: thinkpad_acpi: Support for system debug info hotkey Mark Pearson
2024-04-08 13:11   ` Hans de Goede
2024-04-08 14:56     ` Mark Pearson
2024-03-24 21:08 ` [PATCH 4/4] platform/x86: thinkpad_acpi: Support hotkey to disable trackpoint doubletap Mark Pearson
2024-04-08 13:13   ` Hans de Goede

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=e88a2f41-f89d-444c-a09a-487097c6e9eb@app.fastmail.com \
    --to=mpearson-lenovo@squebb.ca \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=hmh@hmh.eng.br \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=njoshi1@lenovo.com \
    --cc=peter.hutterer@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=vsankar@lenovo.com \
    /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).