From patchwork Fri Mar 27 01:32:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11461519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3D0392A for ; Fri, 27 Mar 2020 01:40:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B98C320787 for ; Fri, 27 Mar 2020 01:40:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OeidLvA5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727509AbgC0Bcu (ORCPT ); Thu, 26 Mar 2020 21:32:50 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:33216 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbgC0Bcu (ORCPT ); Thu, 26 Mar 2020 21:32:50 -0400 Received: by mail-pf1-f201.google.com with SMTP id o5so6974299pfp.0 for ; Thu, 26 Mar 2020 18:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=00RV7bNLHk/+srLS130iQAKmhRfndHchHDNeo4WMsqs=; b=OeidLvA5lvefgDK7/Lhlm9pfs2j2GdTsKuu8cUAqJgpnGukG4D3aD9o8ROmAxiZfiC N1um11XjyxlpPPHf/FZ8K1Knc0277Ub7tcnjwFjGTNp6UbKWixZoqxIJkikE/UJ+SBJU DEoQbeU3GkPGwQK1vCm+BsGV/ZnEauid0cdne89ZrJQXeRkV0wQdsZnIL82oHnGJ8Gy7 y8hn5XXtGEpKHzaVacRzIMYV4NRWE4E7QwF7lElKf7yq8G+pZwFc1UyIpMRgNs7bKa0z scMoBz3E+MotGPm3SgxPfEx/JimkmjYMipqOEL53oJ+eI8rT+Z4JP6MI7vZgX/rVgMOB LHJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=00RV7bNLHk/+srLS130iQAKmhRfndHchHDNeo4WMsqs=; b=oiHguGPNZT53uaGQS/AC/xM5Skh3Lchphp34Lij3JEsGOE3zSXYF2TMFoUtIQqtICk XIc7fWSthJ6FL0rnrrPnXvZOaUVbwqc485liPRdfoTgAn/zAH20ZsaRtth/FyItmFq1j Kb1NU3JZ7FsJeck7IsdHsWxkIF+WMnrjjOBkq4n6iwGaTGKVqWMPlQFMqjMAdHBfcccF gjDezyTPFa+vcgrRmnm39QkKg2Bv8Votn36UkEWTtkavNWCPZpF2xKxQ03Pq9S9vBtUj 89fyYLCGzMz2oLwNBQ9xrKHTpNYHl8m7I7DlDJZzYYW5u2XoX5DwJccIIDC0qkmmQ7vE PYdg== X-Gm-Message-State: ANhLgQ17vresWEG7Z9Kse+qsGwcQpcy3IvAgUlJFENrlH7D1vUsonqXy 8a+uwl9IlTNg2GTfpTKBDcSKU/uhRfMm X-Google-Smtp-Source: ADFU+vvxEB6/tnu1KoE7CiH6g1ntv3CfQrUiRH4eQWXOoeZZYIIdOLTg20OXiK4zK1sdzoHVsZ96xI4ldhQa X-Received: by 2002:a63:cf4a:: with SMTP id b10mr11648063pgj.354.1585272768440; Thu, 26 Mar 2020 18:32:48 -0700 (PDT) Date: Thu, 26 Mar 2020 18:32:35 -0700 Message-Id: <20200327013239.238182-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v3 1/5] input/serio/i8042: Attach fwnode to serio i8042 kbd device From: Rajat Jain To: Dmitry Torokhov , dtor@google.com, Rob Herring , Mark Rutland , Rajat Jain , Kate Stewart , Enrico Weigelt , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , "Rafael J. Wysocki" , Stephen Boyd , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, furquan@google.com, dlaurie@google.com, bleung@google.com, zentaro@google.com, dbehr@google.com Cc: rajatxjain@gmail.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Attach the firmware node to the serio i8042 kbd device so that device properties can be passed from the firmware. Signed-off-by: Rajat Jain --- v3: Same as v2 v2: Remove the Change-Id from the commit log drivers/input/serio/i8042-x86ia64io.h | 1 + drivers/input/serio/i8042.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index dc974c288e880..ed9ec4310d976 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h @@ -927,6 +927,7 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id * } i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id, sizeof(i8042_kbd_firmware_id)); + i8042_kbd_fwnode = dev_fwnode(&dev->dev); /* Keyboard ports are always supposed to be wakeup-enabled */ device_set_wakeup_enable(&dev->dev, true); diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c index 20ff2bed3917a..0dddf273afd94 100644 --- a/drivers/input/serio/i8042.c +++ b/drivers/input/serio/i8042.c @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -124,6 +125,7 @@ MODULE_PARM_DESC(unmask_kbd_data, "Unconditional enable (may reveal sensitive da static bool i8042_bypass_aux_irq_test; static char i8042_kbd_firmware_id[128]; static char i8042_aux_firmware_id[128]; +static struct fwnode_handle *i8042_kbd_fwnode; #include "i8042.h" @@ -1335,6 +1337,7 @@ static int __init i8042_create_kbd_port(void) strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); strlcpy(serio->firmware_id, i8042_kbd_firmware_id, sizeof(serio->firmware_id)); + set_primary_fwnode(&serio->dev, i8042_kbd_fwnode); port->serio = serio; port->irq = I8042_KBD_IRQ; From patchwork Fri Mar 27 01:32:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11461527 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6D4F17EA for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8510020774 for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IniSd5FS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbgC0BdH (ORCPT ); Thu, 26 Mar 2020 21:33:07 -0400 Received: from mail-pj1-f74.google.com ([209.85.216.74]:41869 "EHLO mail-pj1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727729AbgC0Bcw (ORCPT ); Thu, 26 Mar 2020 21:32:52 -0400 Received: by mail-pj1-f74.google.com with SMTP id k3so5825384pjo.6 for ; Thu, 26 Mar 2020 18:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=m+LBqNPjIzI/i9s16PMcLCo7oQ00z3NG9NsKpsashP4=; b=IniSd5FS/y8perrcfoLk0jYuwuXa9iiB7J6jReuu7Drq4aE2/mX2ZLrg+PF7EfI7Ef IOxyACbnWFgAg2bxNIqHCTatF8ZMi7A6axNsKDsvZsYXVIU/Omw/HGlcxztyvOzbFLUO Wd1OVOZBLhY6HdtSlhIalBcn1PLJVVGEm993t/nHozzxGk9zQnv02VcBHCp4j2Ds/nYO GYq7IBe3GUcxmGQbGgCWsLwSy9mfW3cheiajnPpylz51hEAlIPtP7zM4nAaipZRdJHjL It73mvnfAcAJiVsW9ttG3lv8f8pncVOYOdRk1qYFMoq3EQprr/CFW3mDmxjTVkZ8fqX/ /v+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=m+LBqNPjIzI/i9s16PMcLCo7oQ00z3NG9NsKpsashP4=; b=Hjk1ct0rO5XIMNwo6pdugAgPRc6fI0tN7eLbuQPA98rwIA89iR7M/K5FFcbz8JZVrq SHNmRMJHCaR92hvTk2lAr8ZAJhd5ztDvPcnHmbFcZ3mtBupDznGkGCwXvzrtpizcez3i 81PFG0IrhyzQ6Hr5nmhvNkVovInDbWgeyn1F4LxGMN4euA7ij2Blr2EDCoBt+IpTKLRp C8+zJirSrsVMG5nOl+z4Zw4Y9dGiDKJGvlnXZpC+ll07R4nvL7JAOC78r/jeqRQb5TtB CkOze8qScXHkLr5uG3WlCL7lDbrMg7MskyDJglcT8Dlnx8jx/cdAUDN90Mfv8t1+RfED bcZQ== X-Gm-Message-State: ANhLgQ0/horZa0fI6LtZMZY/BckJhojDn+vMBTpa6h/GvCEVu5ANNmfg gdeX7e7NyxkfF0ZBm++GE310DVUEYI7/ X-Google-Smtp-Source: ADFU+vuSZmpS1Lv5Y2YlOQwUVUT3i8v0Ev/ptDuGm8Q5/RE+iHg6qHDAHM4fAvW84XN9kAm7BD4iuXv8/SKz X-Received: by 2002:a17:90a:d349:: with SMTP id i9mr2965528pjx.180.1585272770919; Thu, 26 Mar 2020 18:32:50 -0700 (PDT) Date: Thu, 26 Mar 2020 18:32:36 -0700 In-Reply-To: <20200327013239.238182-1-rajatja@google.com> Message-Id: <20200327013239.238182-2-rajatja@google.com> Mime-Version: 1.0 References: <20200327013239.238182-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v3 2/5] Input: atkbd: Expose function row physical map to userspace From: Rajat Jain To: Dmitry Torokhov , dtor@google.com, Rob Herring , Mark Rutland , Rajat Jain , Kate Stewart , Enrico Weigelt , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , "Rafael J. Wysocki" , Stephen Boyd , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, furquan@google.com, dlaurie@google.com, bleung@google.com, zentaro@google.com, dbehr@google.com Cc: rajatxjain@gmail.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Certain keyboards have their top-row keys intended for actions such as "Browser back", "Browser Refresh", "Fullscreen" etc as their primary mode, thus they will send physical codes for those actions. Further, they don't have a dedicated "Fn" key so don't have the capability to generate function key codes (e.g. F1, F2 etc..). However in this case, if userspace still wants to "synthesize" those function keys using the top row action keys, it needs to know the physical position of the top row keys. (Essentially a mapping between usage codes and a physical location in the top row). This patch enhances the atkbd driver to receive such a mapping from the firmware / device tree, and expose it to userspace in the form of a function-row-physmap attribute. The attribute would be a space separated ordered list of physical codes, for the keys in the function row, in left-to-right order. The attribute will only be present if the kernel knows about such mapping, otherwise the attribute shall not be visible. Signed-off-by: Rajat Jain --- v3: Change to dev_dbg and remove unecessary error check v2: Remove the Change-Id from the commit log drivers/input/keyboard/atkbd.c | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 7e3eae54c1926..3b20aba1861cd 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -24,6 +24,7 @@ #include #include #include +#include #define DRIVER_DESC "AT and PS/2 keyboard driver" @@ -63,6 +64,8 @@ static bool atkbd_terminal; module_param_named(terminal, atkbd_terminal, bool, 0); MODULE_PARM_DESC(terminal, "Enable break codes on an IBM Terminal keyboard connected via AT/PS2"); +#define MAX_FUNCTION_ROW_KEYS 24 + /* * Scancode to keycode tables. These are just the default setting, and * are loadable via a userland utility. @@ -230,6 +233,9 @@ struct atkbd { /* Serializes reconnect(), attr->set() and event work */ struct mutex mutex; + + u16 function_row_physmap[MAX_FUNCTION_ROW_KEYS]; + int num_function_row_keys; }; /* @@ -283,6 +289,7 @@ static struct device_attribute atkbd_attr_##_name = \ __ATTR(_name, S_IRUGO, atkbd_do_show_##_name, NULL); ATKBD_DEFINE_RO_ATTR(err_count); +ATKBD_DEFINE_RO_ATTR(function_row_physmap); static struct attribute *atkbd_attributes[] = { &atkbd_attr_extra.attr, @@ -292,11 +299,42 @@ static struct attribute *atkbd_attributes[] = { &atkbd_attr_softrepeat.attr, &atkbd_attr_softraw.attr, &atkbd_attr_err_count.attr, + &atkbd_attr_function_row_physmap.attr, NULL }; +static ssize_t atkbd_show_function_row_physmap(struct atkbd *atkbd, char *buf) +{ + ssize_t size = 0; + int i; + + if (!atkbd->num_function_row_keys) + return 0; + + for (i = 0; i < atkbd->num_function_row_keys; i++) + size += sprintf(buf + size, "%02X ", + atkbd->function_row_physmap[i]); + size += sprintf(buf + size, "\n"); + return size; +} + +static umode_t atkbd_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int i) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct serio *serio = to_serio_port(dev); + struct atkbd *atkbd = serio_get_drvdata(serio); + + if (attr == &atkbd_attr_function_row_physmap.attr && + !atkbd->num_function_row_keys) + return 0; + + return attr->mode; +} + static struct attribute_group atkbd_attribute_group = { .attrs = atkbd_attributes, + .is_visible = atkbd_attr_is_visible, }; static const unsigned int xl_table[] = { @@ -1121,6 +1159,22 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd) } } +static void atkbd_parse_fwnode_data(struct serio *serio) +{ + struct atkbd *atkbd = serio_get_drvdata(serio); + struct device *dev = &serio->dev; + int n; + + /* Parse "function-row-physmap" property */ + n = device_property_count_u16(dev, "function-row-physmap"); + if (n > 0 && n <= MAX_FUNCTION_ROW_KEYS && + !device_property_read_u16_array(dev, "function-row-physmap", + atkbd->function_row_physmap, n)) { + atkbd->num_function_row_keys = n; + dev_dbg(dev, "FW reported %d function-row key locations\n", n); + } +} + /* * atkbd_connect() is called when the serio module finds an interface * that isn't handled yet by an appropriate device driver. We check if @@ -1184,6 +1238,8 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) atkbd->id = 0xab00; } + atkbd_parse_fwnode_data(serio); + atkbd_set_keycode_table(atkbd); atkbd_set_device_attrs(atkbd); From patchwork Fri Mar 27 01:32:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11461521 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1147F159A for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4CF020774 for ; Fri, 27 Mar 2020 01:40:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Z2i95Aqx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbgC0Bc4 (ORCPT ); Thu, 26 Mar 2020 21:32:56 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:48449 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727841AbgC0Bc4 (ORCPT ); Thu, 26 Mar 2020 21:32:56 -0400 Received: by mail-pf1-f202.google.com with SMTP id h24so6950311pfn.15 for ; Thu, 26 Mar 2020 18:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=CndPbhEYDs1U4gkN9kz/g201YX5b6/GIUM2pkWkOTok=; b=Z2i95AqxFtFVeJnN0ep10o2FLq3PHgLj0xV1jas+TG8DoHR/Ie+akCb78FuKraPzKz 5aoVGcNUcN8y2qQzoBO0xfnWUftDtaJwhSSJ3j4DqC7DT63Dw4v4mM5VXLzsrlcbEXpp 5OpEooJMSJpoIbeIy/wyazTFWjJ9rqCjPkliTqDnMNWWtGBW4ip8H6gDpwQmHE6NHRXP /e8lpO8XPWTXNUYU4mMInzlM3mpaz/GYK9bJAyiG+oT7KNYz2COa3tO7FBNqBBv4WH6p 8xOK/8TWkKuoLZwdOSnKmKYVvyr5dewf+biAQDRqc3ncEHidS84Wt9vcPYW49WP4Do7Z YUuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=CndPbhEYDs1U4gkN9kz/g201YX5b6/GIUM2pkWkOTok=; b=iWxPnRC2YctJaNOfmHkJhIPEMiPX1GFVSVIyrF+qygPxLhEq0mE8Dlrfwv3F/sQGB5 lfWY0xqlV8HogS/dpr0O4suRvU+MsRLE6kMQTErNeN+sg7RAS1yO4XvSTwE6/pCx4OjM juoe1vWgjMjs0gjPaiVQMIdsJ/+kpL4iBj7/gsegx/jF5BsMewY3Na3rlAvZwOhRX7O0 fCZ7TK7TEUNCUsJodYITpYjFELnNBipft8ob4OAGtg6/4zNpT8m0fMht5lcXoiKyjqBE 65yY/Pf7Evano/lLGKOnnkwx8qnDfJvJ0WNA/rNUebKxdIBnjPDwPgkGheFaShvX8IyN 0/ag== X-Gm-Message-State: ANhLgQ2oN5CEG31w3jRiQPwtmbEmX/8s75gC7dvlGIsG0/1Qxp7BxbL7 UWdtMENYUZ+UpLmR/Mu0mQOso7THx0Qb X-Google-Smtp-Source: ADFU+vtEHaAqRLOhguRyQ6WDAN2vuYnRbqyv9pgMaWqOyGbQOTVbIoWbvV3BqJHbw+jxXtfx1C87+q2KzjgX X-Received: by 2002:a63:da4d:: with SMTP id l13mr11745412pgj.216.1585272773528; Thu, 26 Mar 2020 18:32:53 -0700 (PDT) Date: Thu, 26 Mar 2020 18:32:37 -0700 In-Reply-To: <20200327013239.238182-1-rajatja@google.com> Message-Id: <20200327013239.238182-3-rajatja@google.com> Mime-Version: 1.0 References: <20200327013239.238182-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v3 3/5] dt-bindings: input/atkbd.txt: Add binding for "function-row-physmap" From: Rajat Jain To: Dmitry Torokhov , dtor@google.com, Rob Herring , Mark Rutland , Rajat Jain , Kate Stewart , Enrico Weigelt , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , "Rafael J. Wysocki" , Stephen Boyd , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, furquan@google.com, dlaurie@google.com, bleung@google.com, zentaro@google.com, dbehr@google.com Cc: rajatxjain@gmail.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Create the documentation for the new introduced property, that describes the function-row keys physical positions. Signed-off-by: Rajat Jain --- v3: same as v2 v2: Remove the Change-Id from the commit log .../devicetree/bindings/input/atkbd.txt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/input/atkbd.txt diff --git a/Documentation/devicetree/bindings/input/atkbd.txt b/Documentation/devicetree/bindings/input/atkbd.txt new file mode 100644 index 0000000000000..816653eb8e98d --- /dev/null +++ b/Documentation/devicetree/bindings/input/atkbd.txt @@ -0,0 +1,34 @@ +Device tree bindings for AT / PS2 keyboard device + +Optional properties: + + function-row-physmap: + An ordered array of the physical codes for the function + row keys. Arranged in order from left to right. + +Example: + + This is a sample ACPI _DSD node describing the property: + + Name (_DSD, Package () { + ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), + Package () { + Package () { "function-row-physmap", + Package () { + 0xEA, /* T1 BACK */ + 0xE7, /* T2 REFRESH */ + 0x91, /* T3 FULLSCREEN */ + 0x92, /* T4 SCALE */ + 0x93, /* T5 SNIP */ + 0x94, /* T6 BRIGHTNESS_DOWN */ + 0x95, /* T7 BRIGHTNESS_UP */ + 0x96, /* T8 PRIVACY_SCRN_TOGGLE */ + 0x97, /* T9 KBD_BKLIGHT_DOWN */ + 0x98, /* T10 KBD_BKLIGHT_UP */ + 0xA0, /* T11 VOL_MUTE */ + 0xAE, /* T12 VOL_DOWN */ + 0xB0, /* T13 VOL_UP */ + } + } + } + }) From patchwork Fri Mar 27 01:32:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11461523 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45F5881 for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B7CD20774 for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="b8YClyd+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgC0Bc5 (ORCPT ); Thu, 26 Mar 2020 21:32:57 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:41570 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727855AbgC0Bc5 (ORCPT ); Thu, 26 Mar 2020 21:32:57 -0400 Received: by mail-pl1-f202.google.com with SMTP id m9so5860294plt.8 for ; Thu, 26 Mar 2020 18:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=1tcAWU23e/8ucRLXfB8Bf3DPNWWN2Xhk2IPOTZhBJdU=; b=b8YClyd+joF1ICbitvFylO2DFCsO8F5g9Ec7xPO+DJ+873ECEI2/mwqWB4pYD4DbSI cOELowT0Dia3PdQp60x/0qhnpins6s/pRVrr7F1eb2Sf4dfplZ/S5CtaLgBZ/XzQO9nQ vY2PSMbyLbKl4bUY/qw7i9a+A/Moy94kiBd7+1qBBPEz6Ibp9uYCAWfDtFZwpEcU6e3P G3K1XwvYbjaeA4ewI1B0tbBBFIWphbp2n/AxLIvWqhMUT/1wKJ/8e2j6A9IMv6caNbeV yiKMlbkhoBZQcvbVdZWSAhMpDmc9wEd738zLIShROJRdsTHxnIK6H/paXuh+Gj+N6uKC U7NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1tcAWU23e/8ucRLXfB8Bf3DPNWWN2Xhk2IPOTZhBJdU=; b=hfLxbnZq6/duk21ZUZBQrsXZ1gptoTpvvbrvqsyF37SOK9eIpNOuy4RAqmXKGYWLud ZS8gV6vLu1/YhRUl3twRNE1BsgtHvd3DgQ27C0YUJSVR7j7nCJMMHOVdI7RX5CLw5M6h gVPGmrmgv4j+T0tVvsnOTf0wDxuyjHvKBA2L0naxFAJPUckyyQJKOXG/3RUz7LOch7qM 5wqBAVeM+VLk0IG9FnaX+OoA1Bh73DxaF7Rld/vpxep9tE4AO/icZppatcl9rzG0pat7 Q0CSWfYmiZck4ffy490MD596eooFrqxaEs6JDgh8CTWcqYOVRYfm8D4C9bNW4ClZHjlE H3oQ== X-Gm-Message-State: ANhLgQ3PbpoUe6f2hDtsf1TnEVRtMDmN+Mgs1qFwhrfM0jLsxwgzgi+F GGXPf6MDWoaQV5lCnTzXoXagNsf4/yAw X-Google-Smtp-Source: ADFU+vvU0Pz1HEuo3Vn8SApjRgiPioPAG2esbBsxvbRVTv3Ql/N7mV0cmtlBo34yI1UQ8TltLwOz2yCR6d0N X-Received: by 2002:a17:90b:1b01:: with SMTP id nu1mr3059618pjb.129.1585272775898; Thu, 26 Mar 2020 18:32:55 -0700 (PDT) Date: Thu, 26 Mar 2020 18:32:38 -0700 In-Reply-To: <20200327013239.238182-1-rajatja@google.com> Message-Id: <20200327013239.238182-4-rajatja@google.com> Mime-Version: 1.0 References: <20200327013239.238182-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v3 4/5] Input: atkbd: Receive and use physcode->keycode mapping from FW From: Rajat Jain To: Dmitry Torokhov , dtor@google.com, Rob Herring , Mark Rutland , Rajat Jain , Kate Stewart , Enrico Weigelt , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , "Rafael J. Wysocki" , Stephen Boyd , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, furquan@google.com, dlaurie@google.com, bleung@google.com, zentaro@google.com, dbehr@google.com Cc: rajatxjain@gmail.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Allow the firmware to specify the mapping between the physical code and the linux keycode. This takes the form of a "keymap" property which is an array of u32 values, each value specifying mapping for a key. Signed-off-by: Rajat Jain --- v3: Don't save the FW mapping in atkbd device. v2: Remove the Change-Id from the commit log drivers/input/keyboard/atkbd.c | 41 +++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 3b20aba1861cd..0afa6d5aec3b4 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -66,6 +66,9 @@ MODULE_PARM_DESC(terminal, "Enable break codes on an IBM Terminal keyboard conne #define MAX_FUNCTION_ROW_KEYS 24 +#define PHYSCODE(keymap) ((keymap >> 16) & 0xFFFF) +#define KEYCODE(keymap) (keymap & 0xFFFF) + /* * Scancode to keycode tables. These are just the default setting, and * are loadable via a userland utility. @@ -1032,6 +1035,38 @@ static unsigned int atkbd_oqo_01plus_scancode_fixup(struct atkbd *atkbd, return code; } +static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd) +{ + struct device *dev = &atkbd->ps2dev.serio->dev; + int i, n; + u32 *ptr; + u16 physcode, keycode; + + /* Parse "keymap" property */ + n = device_property_count_u32(dev, "keymap"); + if (n <= 0 || n > ATKBD_KEYMAP_SIZE) + return -ENXIO; + + ptr = kcalloc(n, sizeof(u32), GFP_KERNEL); + if (!ptr) + return -ENOMEM; + + if (device_property_read_u32_array(dev, "keymap", ptr, n)) { + dev_err(dev, "problem parsing FW keymap property\n"); + kfree(ptr); + return -EINVAL; + } + + memset(atkbd->keycode, 0, sizeof(atkbd->keycode)); + for (i = 0; i < n; i++) { + physcode = PHYSCODE(ptr[i]); + keycode = KEYCODE(ptr[i]); + atkbd->keycode[physcode] = keycode; + } + kfree(ptr); + return 0; +} + /* * atkbd_set_keycode_table() initializes keyboard's keycode table * according to the selected scancode set @@ -1039,13 +1074,16 @@ static unsigned int atkbd_oqo_01plus_scancode_fixup(struct atkbd *atkbd, static void atkbd_set_keycode_table(struct atkbd *atkbd) { + struct device *dev = &atkbd->ps2dev.serio->dev; unsigned int scancode; int i, j; memset(atkbd->keycode, 0, sizeof(atkbd->keycode)); bitmap_zero(atkbd->force_release_mask, ATKBD_KEYMAP_SIZE); - if (atkbd->translated) { + if (!atkbd_get_keymap_from_fwnode(atkbd)) { + dev_dbg(dev, "Using FW keymap\n"); + } else if (atkbd->translated) { for (i = 0; i < 128; i++) { scancode = atkbd_unxlate_table[i]; atkbd->keycode[i] = atkbd_set2_keycode[scancode]; @@ -1173,6 +1211,7 @@ static void atkbd_parse_fwnode_data(struct serio *serio) atkbd->num_function_row_keys = n; dev_dbg(dev, "FW reported %d function-row key locations\n", n); } + } /* From patchwork Fri Mar 27 01:32:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11461525 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7AC4E1805 for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5066320774 for ; Fri, 27 Mar 2020 01:40:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cOd197Tc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbgC0BdD (ORCPT ); Thu, 26 Mar 2020 21:33:03 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:52024 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727876AbgC0BdA (ORCPT ); Thu, 26 Mar 2020 21:33:00 -0400 Received: by mail-pl1-f202.google.com with SMTP id d4so5832423plr.18 for ; Thu, 26 Mar 2020 18:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=KfX4YhNI554hDVYR+6ARHJ1c92FuwzQbetwUIUbSZaQ=; b=cOd197Tc0jF8mPH8KVYwd9hJtOaPM0teR5d/aaVBilfpv2fnQq4VdJ8W2OLD9Wvn7g OeBDI3TNzKDHKT3W8qc0eDAr2I3PHdckKRs8YTe7xheYA62F6dUCRHYv+/hzH9B5iTcR SnY7GQpHxOxHfQo+NejJhn+Gg4cXCF+UOAucPeeLnSRNWVoTYm9hQSaG5JsS990B2pDd 9XIYxKRa37roipCiSN1F+//suiCaCII2Hu7nCtoWQBWMuTMhslCozyfRLdp4uSPHD7Du 12h94o8Z90VphWhaQYP5S01wZwMbZow82nU+GLcU9g9jLqFRD8qhpPtcg4+03NBI+BPu wZUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=KfX4YhNI554hDVYR+6ARHJ1c92FuwzQbetwUIUbSZaQ=; b=RJ8oEcqMcoGA+ky4fYGLoaNKUvA+F/EOp7Dy/HeH4PxtvahW8rFa7u2IlcAUAM36zT jpHaiufhLLlZ6ePARapSutADC+B+/wcacvDk0bvjGQKy4LyzWa4Q75UaoRrEmBCfHMgI hfzTIHvk5nnuqnGdHsv0i8u9vOjAfFlOnrwTUarJDvH2k3LwJmGF/CQ14lj3HavZOFDk DSL3BwMsmDNoC6UnamYXxjcTbgqIE9GR+zv7thAG6TSwe8YfLZyORqCQYzy9GwsKl8Es jj3/Ycz6ig1SMPoEC9oEQ2cZ37D6oV7n6PTnYLsJe7qkVSOlAeI5YnBI3dsvcfYKFamP WW3g== X-Gm-Message-State: ANhLgQ2RiVNTIt9aWYOCTtsrXDXOUoxl1EHPsoLJnPTiHdzHYTPOa8/p Jf7H1mUlpmccE95DqWGWbQD2QvLC9Qzo X-Google-Smtp-Source: ADFU+vvZVBcF8elF8fTvulona4bRznVutDnKtKKl/DFIzMuaGqA1lxuTP7n4DU222Wk5nXojz7mHQMYTa4xt X-Received: by 2002:a17:90a:e382:: with SMTP id b2mr2952451pjz.83.1585272778333; Thu, 26 Mar 2020 18:32:58 -0700 (PDT) Date: Thu, 26 Mar 2020 18:32:39 -0700 In-Reply-To: <20200327013239.238182-1-rajatja@google.com> Message-Id: <20200327013239.238182-5-rajatja@google.com> Mime-Version: 1.0 References: <20200327013239.238182-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v3 5/5] dt-bindings: input/atkbd.txt: Add binding info for "keymap" property From: Rajat Jain To: Dmitry Torokhov , dtor@google.com, Rob Herring , Mark Rutland , Rajat Jain , Kate Stewart , Enrico Weigelt , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , "Rafael J. Wysocki" , Stephen Boyd , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, furquan@google.com, dlaurie@google.com, bleung@google.com, zentaro@google.com, dbehr@google.com Cc: rajatxjain@gmail.com Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add the info for keymap property that allows firmware to specify the mapping from physical code to linux keycode, that the kernel should use. Signed-off-by: Rajat Jain --- v3: same as v2 v2: Remove the Change-Id from the commit log .../devicetree/bindings/input/atkbd.txt | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/atkbd.txt b/Documentation/devicetree/bindings/input/atkbd.txt index 816653eb8e98d..0a0037d70adc8 100644 --- a/Documentation/devicetree/bindings/input/atkbd.txt +++ b/Documentation/devicetree/bindings/input/atkbd.txt @@ -6,9 +6,15 @@ Optional properties: An ordered array of the physical codes for the function row keys. Arranged in order from left to right. + keymap: + An array of the u32 entries to specify mapping from the + keyboard physcial codes to linux keycodes. The top 16 + bits of each entry are the physical code, and bottom + 16 bits are the linux keycode. + Example: - This is a sample ACPI _DSD node describing the property: + This is a sample ACPI _DSD node describing the properties: Name (_DSD, Package () { ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), @@ -29,6 +35,25 @@ Example: 0xAE, /* T12 VOL_DOWN */ 0xB0, /* T13 VOL_UP */ } + }, + Package () { "keymap", + Package () { + 0xEA009E, /* EA -> KEY_BACK */ + 0xE700AD, /* E7 -> KEY_REFRESH */ + 0x910174, /* 91 -> KEY_FULL_SCREEN */ + 0x920078, /* 92 -> KEY_SCALE */ + 0x930280, /* 93 -> 0x280 */ + 0x9400E0, /* 94 -> KEY_BRIGHTNESS_DOWN*/ + 0x9500E1, /* 95 -> KEY_BRIGHTNESS_UP */ + 0x960279, /* 96 -> KEY_PRIVACY_SCRN_TOGGLE*/ + 0x9700E5, /* 97 -> KEY_KBDILLUMDOWN */ + 0x9800E6, /* 98 -> KEY_KBDILLUMUP */ + 0xA00071, /* A0 -> KEY_MUTE */ + 0xAE0072, /* AE -> KEY_VOLUMEDOWN */ + 0xB00073, /* B0 -> KEY_VOLUMEUP */ + ... + + } } } })