From patchwork Thu Nov 9 22:44:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Stefan_Br=C3=BCns?= X-Patchwork-Id: 10052029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 090D760631 for ; Thu, 9 Nov 2017 22:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F108D2AD72 for ; Thu, 9 Nov 2017 22:45:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5F152AD89; Thu, 9 Nov 2017 22:45:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 274EC2AD8B for ; Thu, 9 Nov 2017 22:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753850AbdKIWo4 (ORCPT ); Thu, 9 Nov 2017 17:44:56 -0500 Received: from mail-out-1.itc.rwth-aachen.de ([134.130.5.46]:3564 "EHLO mail-out-1.itc.rwth-aachen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbdKIWoz (ORCPT ); Thu, 9 Nov 2017 17:44:55 -0500 X-IronPort-AV: E=Sophos;i="5.44,371,1505772000"; d="scan'208";a="22965759" Received: from rwthex-w2-a.rwth-ad.de ([134.130.26.158]) by mail-in-1.itc.rwth-aachen.de with ESMTP; 09 Nov 2017 23:44:53 +0100 Received: from pebbles.fritz.box (78.49.52.200) by rwthex-w2-a.rwth-ad.de (2002:8682:1a9e::8682:1a9e) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.26; Thu, 9 Nov 2017 23:44:50 +0100 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= To: CC: , =?UTF-8?q?Stefan=20Br=C3=BCns?= , AceLan Kao , "Andy Shevchenko" , Darren Hart , Subject: [PATCH v2 2/5] platform/x86: intel-vbtn: Support separate press/release events Date: Thu, 9 Nov 2017 23:44:33 +0100 X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171109224436.16472-1-stefan.bruens@rwth-aachen.de> References: <20171109224436.16472-1-stefan.bruens@rwth-aachen.de> MIME-Version: 1.0 X-Originating-IP: [78.49.52.200] X-ClientProxiedBy: rwthex-w2-b.rwth-ad.de (2002:8682:1a9f::8682:1a9f) To rwthex-w2-a.rwth-ad.de (2002:8682:1a9e::8682:1a9e) Message-ID: <024c7574-12f2-4708-9f90-1192856df401@rwthex-w2-a.rwth-ad.de> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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); }