All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stefan Brüns" <stefan.bruens@rwth-aachen.de>
To: <platform-driver-x86@vger.kernel.org>
Cc: linux-input@vger.kernel.org,
	"Stefan Brüns" <stefan.bruens@rwth-aachen.de>,
	"AceLan Kao" <acelan.kao@canonical.com>,
	"Andy Shevchenko" <andy@infradead.org>,
	"Darren Hart" <dvhart@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/5] platform/x86: intel-vbtn: Support separate press/release events
Date: Thu, 9 Nov 2017 23:44:33 +0100	[thread overview]
Message-ID: <024c7574-12f2-4708-9f90-1192856df401@rwthex-w2-a.rwth-ad.de> (raw)
In-Reply-To: <20171109224436.16472-1-stefan.bruens@rwth-aachen.de>

Currently all key events use autorelease, but this forbids use as a
modifier key.

As all event codes come in even/odd pairs, we can lookup the key type
(KE_KEY/KE_IGNORE) for the key up event corresponding to the currently
handled key down event. If the key up is ignored, we keep setting the
autorelease flag for the key down.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>

---

Changes in v2:
- New patch, add support for seperate key up/down in intel-vbtn

 drivers/platform/x86/intel-vbtn.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index ae55be91a64b..e3f6375af85c 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -76,14 +76,27 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 {
 	struct platform_device *device = context;
 	struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
+	const struct key_entry *ke_rel;
+	bool autorelease;
 
 	if (priv->wakeup_mode) {
 		if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
 			pm_wakeup_hard_event(&device->dev);
 			return;
 		}
-	} else if (sparse_keymap_report_event(priv->input_dev, event, 1, true)) {
-		return;
+	} else {
+		/* Use the fact press/release come in even/odd pairs */
+		if ((event & 1) && sparse_keymap_report_event(priv->input_dev,
+							      event, 0, false))
+			return;
+
+		ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev,
+							   event | 1);
+		autorelease = !ke_rel || ke_rel->type == KE_IGNORE;
+
+		if (sparse_keymap_report_event(priv->input_dev, event, 1,
+					       autorelease))
+			return;
 	}
 	dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
 }
-- 
2.15.0

WARNING: multiple messages have this Message-ID (diff)
From: "Stefan Brüns" <stefan.bruens@rwth-aachen.de>
To: platform-driver-x86@vger.kernel.org
Cc: linux-input@vger.kernel.org,
	"Stefan Brüns" <stefan.bruens@rwth-aachen.de>,
	"AceLan Kao" <acelan.kao@canonical.com>,
	"Andy Shevchenko" <andy@infradead.org>,
	"Darren Hart" <dvhart@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/5] platform/x86: intel-vbtn: Support separate press/release events
Date: Thu, 9 Nov 2017 23:44:33 +0100	[thread overview]
Message-ID: <024c7574-12f2-4708-9f90-1192856df401@rwthex-w2-a.rwth-ad.de> (raw)
In-Reply-To: <20171109224436.16472-1-stefan.bruens@rwth-aachen.de>

Currently all key events use autorelease, but this forbids use as a
modifier key.

As all event codes come in even/odd pairs, we can lookup the key type
(KE_KEY/KE_IGNORE) for the key up event corresponding to the currently
handled key down event. If the key up is ignored, we keep setting the
autorelease flag for the key down.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>

---

Changes in v2:
- New patch, add support for seperate key up/down in intel-vbtn

 drivers/platform/x86/intel-vbtn.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c
index ae55be91a64b..e3f6375af85c 100644
--- a/drivers/platform/x86/intel-vbtn.c
+++ b/drivers/platform/x86/intel-vbtn.c
@@ -76,14 +76,27 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
 {
 	struct platform_device *device = context;
 	struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
+	const struct key_entry *ke_rel;
+	bool autorelease;
 
 	if (priv->wakeup_mode) {
 		if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
 			pm_wakeup_hard_event(&device->dev);
 			return;
 		}
-	} else if (sparse_keymap_report_event(priv->input_dev, event, 1, true)) {
-		return;
+	} else {
+		/* Use the fact press/release come in even/odd pairs */
+		if ((event & 1) && sparse_keymap_report_event(priv->input_dev,
+							      event, 0, false))
+			return;
+
+		ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev,
+							   event | 1);
+		autorelease = !ke_rel || ke_rel->type == KE_IGNORE;
+
+		if (sparse_keymap_report_event(priv->input_dev, event, 1,
+					       autorelease))
+			return;
 	}
 	dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
 }
-- 
2.15.0


  parent reply	other threads:[~2017-11-09 22:45 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20171109224436.16472-1-stefan.bruens@rwth-aachen.de>
2017-11-09 22:44 ` [PATCH v2 1/5] platform/x86: intel-vbtn: support SW_TABLET_MODE Stefan Brüns
2017-11-09 22:44   ` Stefan Brüns
2017-11-09 22:44 ` Stefan Brüns [this message]
2017-11-09 22:44   ` [PATCH v2 2/5] platform/x86: intel-vbtn: Support separate press/release events Stefan Brüns
2017-11-10  1:34   ` Darren Hart
2017-11-10  1:58     ` Stefan Brüns
2017-11-10  1:58       ` Stefan Brüns
2017-11-10  2:11       ` Darren Hart
2017-11-10  2:44         ` Stefan Brüns
2017-11-10  2:44           ` Stefan Brüns
2017-11-10  2:15   ` Darren Hart
2017-12-08 20:33     ` Stefan Brüns
2017-12-08 20:33       ` Stefan Brüns
2017-11-09 22:44 ` [PATCH v2 3/5] Input: add KEY_ROTATE_LOCK_TOGGLE Stefan Brüns
2017-11-09 22:44   ` Stefan Brüns
2017-11-09 23:34   ` Bastien Nocera
2017-11-30 17:51     ` Brüns, Stefan
2017-11-30 17:51       ` Brüns, Stefan
2017-12-05 18:50       ` Jason Gerecke
2017-12-05 18:50         ` Jason Gerecke
2018-01-25 16:23         ` Jason Gerecke
2017-11-10  1:41   ` Darren Hart
2017-11-09 22:44 ` [PATCH v2 4/5] platform/x86: intel-vbtn: support KEY_ROTATE_LOCK_TOGGLE Stefan Brüns
2017-11-09 22:44   ` Stefan Brüns
2017-11-09 23:30   ` Bastien Nocera
2017-11-09 23:46     ` Darren Hart
2017-11-10  0:23       ` Stefan Brüns
2017-11-10  0:23         ` Stefan Brüns
2017-11-10  0:15     ` Stefan Brüns
2017-11-10  0:15       ` Stefan Brüns
2017-11-10  0:39       ` Bastien Nocera
2017-11-10  0:39         ` Bastien Nocera
2017-11-10  0:53       ` Darren Hart
2017-11-10  1:54       ` Darren Hart
2017-11-10  2:20         ` Stefan Brüns
2017-11-10  2:20           ` Stefan Brüns
2017-11-09 22:44 ` [PATCH v2 5/5] platform/x86: intel-vbtn: support panel front button Stefan Brüns
2017-11-09 22:44   ` Stefan Brüns
2017-11-09 23:40   ` Bastien Nocera
2017-11-10  0:21     ` Stefan Brüns
2017-11-10  0:21       ` Stefan Brüns

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=024c7574-12f2-4708-9f90-1192856df401@rwthex-w2-a.rwth-ad.de \
    --to=stefan.bruens@rwth-aachen.de \
    --cc=acelan.kao@canonical.com \
    --cc=andy@infradead.org \
    --cc=dvhart@infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.