From patchwork Tue Mar 24 12:35:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11455315 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 DDBE76CA for ; Tue, 24 Mar 2020 12:35:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BECA720870 for ; Tue, 24 Mar 2020 12:35:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lrkNOvRm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbgCXMfc (ORCPT ); Tue, 24 Mar 2020 08:35:32 -0400 Received: from mail-pj1-f74.google.com ([209.85.216.74]:57377 "EHLO mail-pj1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727557AbgCXMfc (ORCPT ); Tue, 24 Mar 2020 08:35:32 -0400 Received: by mail-pj1-f74.google.com with SMTP id np3so2442846pjb.7 for ; Tue, 24 Mar 2020 05:35:26 -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=5LJBH8xQN/jQBYcxN7fADpsh/S4ILyM2BLQ/YSrufN0=; b=lrkNOvRmUfIaF/A680qHGLiVgg0GQPkzG6FPhLtY747Zb6pLNG8Zgn8lppIsH1ATDA qi2aczpwz1DwrvZaRiIJjdZuljpnhbxcIlV3tH30rFehu9n/VcQCT72NRCumITBYwZcs u2vqZHudgsefVYz+OnKrpUocL7ncCUxYD1sWAeTYAVKhNG36dPUFEeG2EsskGXE8Gqv7 W6t9VEvV6CZYmMIXsJng/CIAM5+9WkHrlLR16tuWvMJ5B0LjGhrKJnMuf5yTBkRfeVcS 7vQ9gQmNzQA/SHCh04nyP551vhjc9mEyIRgpsmkCP+XyWgTn8pTj+emFXRd7rC+KrqDH BUPg== 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=5LJBH8xQN/jQBYcxN7fADpsh/S4ILyM2BLQ/YSrufN0=; b=reoAJ+XmABDsIAFIgajf8KrqZj5FsmywMnugTyNug5UczE10iOaP9bCZfOVekeyTbz Ugzh61fBVI3rdoNb6luYF2k1A6kVIi275iyFBgc188oEELr6AFIYOA7X5MKlhgXDPjac aNjQLMGi9g+izk0QRDZ2eGgptbW7EDEb5Pjg5cZJjwbfNlfbHMgXtLDIcJjlXsnn8rKZ C5lJWBpJO8KiaGrv3GVGERYBjd0xEmAdvFh6uFat5oku45Owx/kURx1/ZhD1SaLTu6MO QGkUGgsXcSQ1EfCEyiBX7zHNwnAlSWCA2QYYb3xKYwOSd3pjto0Oh6yUCIJUmQTEBwEk QccQ== X-Gm-Message-State: ANhLgQ2G5b+bkSik+oFgVRzpRkzS9olyhiLpx+IIUMRZSIpuWZJ7lyZf RkSmZZ+jRDX5ozmGIioOdopWR/4eFR2l X-Google-Smtp-Source: ADFU+vu288sFSt11Qek/NJ9edzx6Ik5VpV0z7KGXLXL8qHNO1/Re0wIomUu+WPPbOweT/mkzeqW3EKHV9Tjl X-Received: by 2002:a17:90a:ba93:: with SMTP id t19mr4040036pjr.67.1585053326283; Tue, 24 Mar 2020 05:35:26 -0700 (PDT) Date: Tue, 24 Mar 2020 05:35:14 -0700 Message-Id: <20200324123518.239768-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v2 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 --- 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 Tue Mar 24 12:35:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11455317 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 BEC6B913 for ; Tue, 24 Mar 2020 12:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 982A7208D5 for ; Tue, 24 Mar 2020 12:35:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ryqLlcu+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727523AbgCXMfh (ORCPT ); Tue, 24 Mar 2020 08:35:37 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:46340 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbgCXMfh (ORCPT ); Tue, 24 Mar 2020 08:35:37 -0400 Received: by mail-pf1-f202.google.com with SMTP id f75so13828439pfa.13 for ; Tue, 24 Mar 2020 05:35:34 -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=/YRnD9CiSnz4bNQqQAQi7E7yBYNFZlFMr5qPYuWGXYo=; b=ryqLlcu+ZImrQtE0BsB+04n0p17Xu8OO8g6/NMipyvx7mN1TP5o2wYo9LSE59VqqBT 0o6PO7hfCON/n8dn8H3mvcF1f9+AoqrWyL69CvPdWRZgLgSynS3bBrOy2IilJEoxXkts Bg6rbIXllNhd8gs0lsXhE29c8JyYQsjgmdZ7+PYH9PTngwzux0uBr+fJQzsbGLM2mLuN +tHUpDGjXkPY6z+ZKrEH6JS15AeXCBx5krWG05AuGTaGf/9pht0lOicLCO/+igClk0LQ Mup0jURDYD5urOw3IV0ggPpgNy24b9JpuisS5RD45n5fHT/upFI4aCSqr0DDD7/3I376 lgIQ== 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=/YRnD9CiSnz4bNQqQAQi7E7yBYNFZlFMr5qPYuWGXYo=; b=ouSsWqUnm2vetz0sRtgK9YS7tRVqnkbQ1XLxzqYRGpC7EJb2GfHVdqadZutG9xyTrb YAbmTJrHy5tbm2WsDXLyCP1Y9N3IggPFxatWlvnKIMgy4z4AEKeqJHWgS/wMFmfQEdWv yWlJyb19WdbJv+wV8IxcPeuiID4skf3+3X4QrK1pXWfhbreYsypxDy0ei1n/OVtbzISt wq6pq4Flc3qUz4bn2C7+gRkL6DfXn3iwDyDx27MRvTMojIa0xdVKLKnYGJNQ0biOb1Bx eVH+fsIJLxMCq9IlBy47F8Z/7ibHAO4csxyLW2vXZgRqThODJUmAoioRl1i5xjPsAyej K8Gw== X-Gm-Message-State: ANhLgQ2wGGY0nOPr3/8Ehv+M7n+4f/BhF+gwYprkOkDxMxfeN3dsgtl6 RMZlvNVpTS/iaOdYhpzpUpY8f7M7pAN/ X-Google-Smtp-Source: ADFU+vupwZn7p/lnTjgKdRh3aONKbqdisHUy4MWZsIMqWdWh7L09grvSsyKzfmnrOynojDBh9qWzXaKqagJj X-Received: by 2002:a17:90b:14cb:: with SMTP id jz11mr5289443pjb.142.1585053333868; Tue, 24 Mar 2020 05:35:33 -0700 (PDT) Date: Tue, 24 Mar 2020 05:35:15 -0700 In-Reply-To: <20200324123518.239768-1-rajatja@google.com> Message-Id: <20200324123518.239768-2-rajatja@google.com> Mime-Version: 1.0 References: <20200324123518.239768-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v2 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 --- v2: Remove the Change-Id from the commit log drivers/input/keyboard/atkbd.c | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 7e3eae54c1926..7623eebef2593 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,25 @@ 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; + + if (!dev_fwnode(dev)) + return; + + /* 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_info(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 +1241,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 Tue Mar 24 12:35:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11455319 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 BAD32913 for ; Tue, 24 Mar 2020 12:35:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C2AB208C3 for ; Tue, 24 Mar 2020 12:35:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PGKtJEH2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727607AbgCXMfn (ORCPT ); Tue, 24 Mar 2020 08:35:43 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:35266 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727597AbgCXMfn (ORCPT ); Tue, 24 Mar 2020 08:35:43 -0400 Received: by mail-pl1-f202.google.com with SMTP id a8so10589666plm.2 for ; Tue, 24 Mar 2020 05:35:42 -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=9qa8aAp+bZ6gg3RjZoXrpyNia4xdGEkV4pXAFPahzW4=; b=PGKtJEH2E9p0fcB03gDuNWbPXiQ/2waoPhihfZtac0gHwtFY6/Srthu+qCNEaA9hWX ZMDCQJbkHXBUeJdiKVFWL6GEKHGRuADWPn1x3IWiQiE69GsV53fMxXoFyaCvKeC6l+he +x0H2QwnOypxbtb3WWtcSB4G3hvSBZ6fzOseLpEoNaJb+ozK2cL+XtqvsBthu1M2wOzB svB7tDExbTn+kH1naAnmbBMWO2SLH3cW47kfDkXUoKA7lzbfzSg6Y+toJevOADg0gG5G S9963zRiHbFOWHS0bO5cRcPwjsQx7VI2Uq0i4OcUS1h0bAl1Pjjt19e0Zict/AZR9kQS rzHw== 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=9qa8aAp+bZ6gg3RjZoXrpyNia4xdGEkV4pXAFPahzW4=; b=WKL4ojLU3eNXHaGo5HhBlw+F6rzT1b2Y5wHO04tO9KCkZxvv9cqLbrpJZdsE2FCZBP LN6upY1zVZoQprFGRUo+OdsJ4Bw09LkdWH+D1tg5FBMBmOYFZOWt3j1rExGe2PG0bADL j6DFOnJmezndjUBqv+7EcxF/YiE81iFedW2GY3M8tk7GTC+Q7wPJegGSMAg08U7KKfrs V+UKdbv3Hoi5u86u8vrbhWrjfuod+Y79rtoGxitNafkmqkHl8rkQu0H0BoRcem0rOMJv gICh4lIbjoNZS8TzL5AyX9xBP8eEXbqNK6CSsWdgIJNVICaBYbDFoqvukD/hAD9BrJhv A+RA== X-Gm-Message-State: ANhLgQ2btcciBTSne1A0eM8INInLYW7oodNn6WBzlzSJkxNRhv1EcqTV ekGzMemz2+y1Xu/HqTcrM8fOTmrdCoa0 X-Google-Smtp-Source: ADFU+vsjCf2WCgjHPJYj99N2JWIuBp5ZMQN3hRm0xa06BAW6KPosWLcQBDeNjnYsynKKF8M5UcQ85Nk9wBQJ X-Received: by 2002:a63:cb:: with SMTP id 194mr27725855pga.37.1585053342203; Tue, 24 Mar 2020 05:35:42 -0700 (PDT) Date: Tue, 24 Mar 2020 05:35:16 -0700 In-Reply-To: <20200324123518.239768-1-rajatja@google.com> Message-Id: <20200324123518.239768-3-rajatja@google.com> Mime-Version: 1.0 References: <20200324123518.239768-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v2 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 --- 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 Tue Mar 24 12:35:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11455321 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 618566CA for ; Tue, 24 Mar 2020 12:35:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 43351208C3 for ; Tue, 24 Mar 2020 12:35:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lmK5dE4x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbgCXMfr (ORCPT ); Tue, 24 Mar 2020 08:35:47 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:51587 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727600AbgCXMfr (ORCPT ); Tue, 24 Mar 2020 08:35:47 -0400 Received: by mail-pl1-f201.google.com with SMTP id d4so11826272plr.18 for ; Tue, 24 Mar 2020 05:35:46 -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=WTtDeohiw28fP+FvwRacg/QdAzt+SACVEqfc7+VrrSs=; b=lmK5dE4xTioOUJb0kqqlE/hDhMU+igvmxfqo3tYMIzpmNIebEgeymGk+5oMOWxFmIj Pa2/c+eASLAY0I3zgTuNOwPm2KyoWnMGqTGOgRudAJ7DuGjOrbQ+nfkeVqy6SW2CdF5f 1X6OmYom+zE7upFb4x+c77B16NLNxIxthW7Uv85WM7VBSUCRjJ7dxWqfn+NOVM/riz0E 9zLBb+L4QkBF4hdFi11MwfzYQ84DvoBgTOID/yj0VdXGKkogD22BDvlXkyq4C0f1iGoW 3Odza5xi4FS800WcDU4RONs1v5cElgzmCCZojxOKIYSQ56ibQQSJfuSEOd8ZTcTNr3zk OTXg== 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=WTtDeohiw28fP+FvwRacg/QdAzt+SACVEqfc7+VrrSs=; b=tiYb0+PnBNUhgLHuP2POKySJyOTobajeT1iQ7D9IWTWRaDwP2l0YBB2bkn6raG3CDq X7h8UARqwiteNT7jgofIooseFrkC+5+2CYU5BhSK/ild2iBir5367a7Yd9Q4d4b6eXQ+ viDTQywuibIbJf1v5gpF7OFdsSSDdywGyBLJboI8AoNxUo5mf4Y+gb7GpNo2MxXaiDut NFi3R026wcBEbVL2svCyLtA9BnGAVdEDTcvntmpbr1YoozLtOxrqwCNbLrsIxZny2dHM SmgLf6T3gXkGjjvB9IpRZWE3HpGLo6Ox61IZPqIaGJPbAdGD7icFN/A1tAkRwakcwYx3 /dEQ== X-Gm-Message-State: ANhLgQ3UwdcoAUz9B5jp3OW70sencrXWMELoq+1taTqSWRCoRYbIgwh5 ioCvEPhIhZDoVly2ZiaoNYISR2cE/GRL X-Google-Smtp-Source: ADFU+vsJs0BHAEl02/RH514VKhmIhuqhq3TQF2u/DvRz5zc4EnAPY3XIZDO/SZ6Wje9PY0p9EzHI7QG7CyVw X-Received: by 2002:a17:90b:300b:: with SMTP id hg11mr5035346pjb.181.1585053346423; Tue, 24 Mar 2020 05:35:46 -0700 (PDT) Date: Tue, 24 Mar 2020 05:35:17 -0700 In-Reply-To: <20200324123518.239768-1-rajatja@google.com> Message-Id: <20200324123518.239768-4-rajatja@google.com> Mime-Version: 1.0 References: <20200324123518.239768-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v2 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 --- v2: Remove the Change-Id from the commit log drivers/input/keyboard/atkbd.c | 39 ++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 7623eebef2593..c8017a5707581 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. @@ -236,6 +239,9 @@ struct atkbd { u16 function_row_physmap[MAX_FUNCTION_ROW_KEYS]; int num_function_row_keys; + + unsigned short fw_keymap[ATKBD_KEYMAP_SIZE]; + bool use_fw_keymap; }; /* @@ -1045,7 +1051,10 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd) memset(atkbd->keycode, 0, sizeof(atkbd->keycode)); bitmap_zero(atkbd->force_release_mask, ATKBD_KEYMAP_SIZE); - if (atkbd->translated) { + if (atkbd->use_fw_keymap) { + memcpy(atkbd->keycode, atkbd->fw_keymap, + sizeof(atkbd->keycode)); + } else if (atkbd->translated) { for (i = 0; i < 128; i++) { scancode = atkbd_unxlate_table[i]; atkbd->keycode[i] = atkbd_set2_keycode[scancode]; @@ -1163,7 +1172,9 @@ static void atkbd_parse_fwnode_data(struct serio *serio) { struct atkbd *atkbd = serio_get_drvdata(serio); struct device *dev = &serio->dev; - int n; + int i, n; + u32 *ptr; + u16 physcode, keycode; if (!dev_fwnode(dev)) return; @@ -1176,6 +1187,30 @@ static void atkbd_parse_fwnode_data(struct serio *serio) atkbd->num_function_row_keys = n; dev_info(dev, "FW reported %d function-row key locations\n", n); } + + /* Parse "keymap" property */ + n = device_property_count_u32(dev, "keymap"); + if (n > 0 && n <= ATKBD_KEYMAP_SIZE) { + + ptr = kcalloc(n, sizeof(u32), GFP_KERNEL); + if (!ptr) + return; + + if (device_property_read_u32_array(dev, "keymap", ptr, n)) { + dev_err(dev, "problem parsing FW keymap property\n"); + kfree(ptr); + return; + } + + for (i = 0; i < n; i++) { + physcode = PHYSCODE(ptr[i]); + keycode = KEYCODE(ptr[i]); + atkbd->fw_keymap[physcode] = keycode; + } + dev_info(dev, "Using FW keymap (%d keys)\n", n); + atkbd->use_fw_keymap = true; + kfree(ptr); + } } /* From patchwork Tue Mar 24 12:35:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11455323 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 C9D896CA for ; Tue, 24 Mar 2020 12:35:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AADF62098B for ; Tue, 24 Mar 2020 12:35:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FbYjimOK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727557AbgCXMfx (ORCPT ); Tue, 24 Mar 2020 08:35:53 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:42704 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727667AbgCXMfw (ORCPT ); Tue, 24 Mar 2020 08:35:52 -0400 Received: by mail-pl1-f202.google.com with SMTP id g7so7000437plj.9 for ; Tue, 24 Mar 2020 05:35:52 -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=hVHQV/dj3HvNuxis1PdKXEZxW+M5qBzMZyzK/EGMeCk=; b=FbYjimOK12I3PtYwelwNdAM2oLqQiMBiW6ebqxTWZSWqK1WLC+1+frlwjsMx9DI0CB /yfXTd2ISAw1B9RmhQ2JWRGMh+q5h0RvT2rl8xxYQxy6QKE9UUX7jAGn2q7Hrc3vstib Vxo9M9Xjb52PXkfCA0EDImFlAzYoWgv/DOD7q3CbUAIRhTShV3HgYgO3AJ9x1P86gTSw eaGh29VpqQpDD8VO/Ty4W3ecqFe73U60Gveu6iqzJigkW8z4DYo6PMi09w2M9zsC+UrZ 0jwTerdfdH62UUszaOpPEALroapa4mktu665iMT193wZhGKHqm1NY0CSalVcWI6DDnDJ r7ww== 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=hVHQV/dj3HvNuxis1PdKXEZxW+M5qBzMZyzK/EGMeCk=; b=R7EKN0MK5HnEiQ4eFHNmildjSXdR3nFrkj4rrn8DfeirTMHbT1dO47QQQAdRN3jOh/ kEcRMn7tfdWiam7FYONfPGK+/gxNcka7uVRKi0a+tqlmF1QuCY2h8j124F1kttga98GA Sax1xp2rbPcF003eIiFaCu49/Z87gcVSU18GlrQWD2k3aHxZlZCk6/vkLw/+vJveSmfZ XdDh85P3Tz15MaYh4lQ0hCe0+c0gqY2ygGTTS4JwemhuDjTG9BKoECyEfHNU/apo6ENi H9f9RO7Uo6V4Fteq3QAXEd3kZVA+rbHGyjerUb4jMuQkFZbqJeWbAYD63s31JZrrndwl 4PcQ== X-Gm-Message-State: ANhLgQ23a4iUbF7B0O/Ys+63AeJThun0imu9lZMcPJhdNCOUZ/FenCy0 E4jg2E26S+OMZJPKc5kAUu4m/OySUL57 X-Google-Smtp-Source: ADFU+vsjCoKpoZ06ftk7XttqwAP+E9Yftk1Lj/gHqvVXELUNqecE5DCpQGtBz3ovvibLOkGOpmVDNkzSdZyn X-Received: by 2002:a17:90a:bb92:: with SMTP id v18mr5069386pjr.171.1585053351277; Tue, 24 Mar 2020 05:35:51 -0700 (PDT) Date: Tue, 24 Mar 2020 05:35:18 -0700 In-Reply-To: <20200324123518.239768-1-rajatja@google.com> Message-Id: <20200324123518.239768-5-rajatja@google.com> Mime-Version: 1.0 References: <20200324123518.239768-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH v2 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 --- 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 */ + ... + + } } } })