From patchwork Mon Mar 23 23:45:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11454227 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 69E7517D4 for ; Mon, 23 Mar 2020 23:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49D5120719 for ; Mon, 23 Mar 2020 23:45:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q0if1IPW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727159AbgCWXpM (ORCPT ); Mon, 23 Mar 2020 19:45:12 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:55838 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbgCWXpM (ORCPT ); Mon, 23 Mar 2020 19:45:12 -0400 Received: by mail-pg1-f202.google.com with SMTP id r10so12066336pgu.22 for ; Mon, 23 Mar 2020 16:45:11 -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=CGN67ai+uJsj1tfuyyku3cDC0jfYqRZasznuB25TKmc=; b=Q0if1IPWh8AYjLmejNgFM/5LxJSF4tTmF2CGc43pEBQoAo5A7TUfQn+Fl1tKmCP94O YjxNL6tnuwxAWIcr/4lITV7Db7lVzcpMk3rxE/XcW6XqbxCTPsxNogSTJSWnqXNPQTGn Z+YZgKyL8RF/m2T+RPJHO9Usk7eQgFW2jlmxTxNMIXdGW9HSADbVQYi9qiw1j/p7InKE quFlVly1IFxFxc7hs26rHsjrmEk9jaT85zweyDHV8rFTqho9Z7bXJ62ntmqnYnLa/6Vu L/DnRIbIf4LsqFVMlN3ARFgjI1p4IX0XgoS+JIbLgjXLQWi+dChZiw5xn89xw/nqpK8o g7fg== 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=CGN67ai+uJsj1tfuyyku3cDC0jfYqRZasznuB25TKmc=; b=QIfcpqUbClgWpP91aEPAJWi4/db5h9QcQt18wtZ/azVZpBrMjehfigBL4OdzAJ0yt3 KPwjZdUX1wxjcznkMqPWN/+LuZbPgGuh3C7OBBtik+Iiz2wWyH7t3qORPr/4Q7nDUD6G iQlDUP5bo7H7RWZKwbmCcZFT7b4OyOx+UpDOuepWkDp4uQd4yLtbTiEuJjIUa5EPYWKu CpwLr08ewMfLT0JcXKOmYErAntv5do2O394cCgDjAmNdPjTWzIc4UvoujMB+8eD5uKzh MwQ5p9gPnSTSgPxnaebV+Y/qLiE7rsqVQh11d0vj11KlCa6uA27LYlCc0zde6dBYvgkK J8VQ== X-Gm-Message-State: ANhLgQ0682gKsXG1K9G7gVRqzt5B+45AP7WyUirhAAeeW6gQjRFAOPlk OubyM5gwMqnJXkdvzN952DCv9tBiznw1 X-Google-Smtp-Source: ADFU+vtRoRdRhiliKxgPtQ4nIIHEEpqIJquaKhign2V700OM3SZHQ9ohPI5e6M7C2XEOcvCHlU5HjgmAecY0 X-Received: by 2002:a17:90b:14cb:: with SMTP id jz11mr2036390pjb.142.1585007111026; Mon, 23 Mar 2020 16:45:11 -0700 (PDT) Date: Mon, 23 Mar 2020 16:45:01 -0700 Message-Id: <20200323234505.226919-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH RESEND 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 Change-Id: I36032f4bdee1dc52f26b57734068fd0ee7a6db0b --- 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 Mon Mar 23 23:45:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11454229 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 889981392 for ; Mon, 23 Mar 2020 23:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6134A20719 for ; Mon, 23 Mar 2020 23:45:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mNBqjMPE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbgCWXpS (ORCPT ); Mon, 23 Mar 2020 19:45:18 -0400 Received: from mail-pl1-f202.google.com ([209.85.214.202]:36991 "EHLO mail-pl1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbgCWXpQ (ORCPT ); Mon, 23 Mar 2020 19:45:16 -0400 Received: by mail-pl1-f202.google.com with SMTP id t12so10728561plo.4 for ; Mon, 23 Mar 2020 16:45:13 -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=/QBjDN0nv6YWKV4K8B7ojsyFGdc9mVww0s2ISlcMwfs=; b=mNBqjMPEu4CjE6fb+ojog2lWCsrLpRQ0vatIYB0KwQAI2pVbf21VRF+BczKOgYUYuN mHZc3TEB32+pUXcjw3pvM6gq/ReNHITJZzaabtsY+g0Q0krBpUoB/FF4FbiP9M35fIZt tDRIB106g7MZ4ogmRX3knxaRBZGss2hLUpBU+o+AXTmEzkMziOHd+raCxyImHypVzNJI Zl8xAyuskQz0WUyQ9h31o/pg9ygdz2Muvw8+/xNBK426DhB21dgAb+asfgcxTMd+5OWX aS3jtMsWrxgQHR7qiXxFZMxIrAhQyeyc9D87ZyDAAdjNH5c2a1mDDE8UEK6rLsD0r8P4 JYrA== 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=/QBjDN0nv6YWKV4K8B7ojsyFGdc9mVww0s2ISlcMwfs=; b=dq2KxiTIGO73/e9fEzVuuo42Wo0ctp9vUvvQ5isqJ5Gla/D/asGEyxnvfKPeleL6kF cxKCarazn+nxzhRllFiXsZQ5n7KkEYqTM0oEMoFg+HLs/J6R9Wuj0iLgT9qTbygFuyf0 2veFKcCyEs+zplNOFGLiZMBBEMAQUOv1in+38l+wNrkHJ9ziyhm7f3xj/5cWydRwaUOp M9HFxipuue8SkaKBGF6Zs8V29me9rom+NuXQ/EkOz+FtNOfZqjnuaYhsw8h/vLE+jzv5 RPg4CLyhWgIe/xsFRJfv59WnV3aPjVVTM3y9VR6EoZoijJcDr7MlxxDUvK8JBJdbutE+ YbXQ== X-Gm-Message-State: ANhLgQ0fvpFItvtpgfvHvDEZy5EwxmCKdaJb9Ecs+se8SynJYdJtLns9 NvzQzrY7KC1QyUOenTwWNxCezb90Q3X+ X-Google-Smtp-Source: ADFU+vssdXVIa3r7hv9GAMgK277VoxTDFir+NdBaE08HaPDMmkI2Fk563mHWM1pX8kNQyoB/+uhI3V6SmW01 X-Received: by 2002:a63:56:: with SMTP id 83mr24405892pga.249.1585007113269; Mon, 23 Mar 2020 16:45:13 -0700 (PDT) Date: Mon, 23 Mar 2020 16:45:02 -0700 In-Reply-To: <20200323234505.226919-1-rajatja@google.com> Message-Id: <20200323234505.226919-2-rajatja@google.com> Mime-Version: 1.0 References: <20200323234505.226919-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH RESEND 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 (e.g. Chromeos) 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 Change-Id: I75311c844a2576e6169eae5184b8ef54b363554c --- 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 Mon Mar 23 23:45:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11454235 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 79FEA1668 for ; Mon, 23 Mar 2020 23:45:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B50020753 for ; Mon, 23 Mar 2020 23:45:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="et1B+wP9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbgCWXpT (ORCPT ); Mon, 23 Mar 2020 19:45:19 -0400 Received: from mail-pj1-f73.google.com ([209.85.216.73]:32830 "EHLO mail-pj1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727290AbgCWXpQ (ORCPT ); Mon, 23 Mar 2020 19:45:16 -0400 Received: by mail-pj1-f73.google.com with SMTP id ng13so849142pjb.0 for ; Mon, 23 Mar 2020 16:45:16 -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=4Nt1NzwBOv+0yT5sCiw6dDGnfYenncnTIG2PE5hdU3M=; b=et1B+wP9LkYL30MUtIZIXL7mabpmsyXueZypWjPPj2Bku/RHTD1y+8nFSrJG4QsxJS OaUbstMHBg8Ls/rx+t5RdoM/OOiSpjqjP99H8qAcz8zaoR/WWFIGClA0YY1Z9u0w3DNh 7FmwPcclAffI6nx0Ae55mAmEyis6jYHmOHcFAVqeJz4KPRwK7AyctDQqMvz8I3VqqWRs NAvEwIkCh1NyJ6L9lKa63hKNPCLyTqLAe6An5FvYGyGqD0gbdM9z/xdeJsbjpB3pftd/ jhigxT35bxIej99rwMbTdxp+iuNaK707Y15Tk8mwkxEMHUalhQ1IvXQznIobsOHXN4ry /1RQ== 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=4Nt1NzwBOv+0yT5sCiw6dDGnfYenncnTIG2PE5hdU3M=; b=Tqyy+LaQSzTAuXbH7Qb1t9zgltCzpZNEA+7GKoJJZ1VxP0PQrwBQC++sCDFut9tSf1 A0mAVpLvWM6dc4DLTrQzAQ3/i6GP60LOKxbZ4ZpyNy+JJqQDdaIzY0xArVnfCvt4MZtt nD7PqVWpdNjhUeRvRLpOUD1J4KFhA7+p9DNKqzSSa25S6LtV1VfJb60TdaruVpSM5QX2 GovGXVZR9MtGPGxgeOiaD7725utyfuIZdxXepkdpGuToBS/SRZKQcDkJu1urwExqcgaf flrC0ZOD8n3g5Y/OF0w6WYdvYMYE+ugWLflmNTTM+QTTp60r6hJCauze0nxTqwXgbhES tHZg== X-Gm-Message-State: ANhLgQ0yW+vvFOkGNhA/c7+R0BKWw30T3HaOiBhw0pIUT1xPWhAwDXue 41w7RCtWvxt0z6K02qLi297oFBj1at0r X-Google-Smtp-Source: ADFU+vvPJ6+5Vbkq4pk8U+dO3lSHGSMt7IwxzYsEL+baO313m2V3EEjuYz3a6oks+uiP96WQo9FNWXQnSv75 X-Received: by 2002:a17:90b:282:: with SMTP id az2mr2023188pjb.13.1585007115675; Mon, 23 Mar 2020 16:45:15 -0700 (PDT) Date: Mon, 23 Mar 2020 16:45:03 -0700 In-Reply-To: <20200323234505.226919-1-rajatja@google.com> Message-Id: <20200323234505.226919-3-rajatja@google.com> Mime-Version: 1.0 References: <20200323234505.226919-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH RESEND 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 Change-Id: I1786a09258670ed9c782ec1b529e0e347cdfda8e --- .../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 Mon Mar 23 23:45:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11454233 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 4B7F81668 for ; Mon, 23 Mar 2020 23:45:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BFA220409 for ; Mon, 23 Mar 2020 23:45:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cuzXzgMY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727315AbgCWXpU (ORCPT ); Mon, 23 Mar 2020 19:45:20 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:37521 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727301AbgCWXpU (ORCPT ); Mon, 23 Mar 2020 19:45:20 -0400 Received: by mail-pf1-f201.google.com with SMTP id n28so12592995pfq.4 for ; Mon, 23 Mar 2020 16:45:19 -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=0xG7SpHFsGGPYJqubi6X08/1oBrgthJjI40CuA+QSdM=; b=cuzXzgMYxlp2Hk8cl73XQ8CjeSrGWd6GdfReHHWmRMeKd6+1XygJZjnzoGFiXOGkuM teJ64eam15fP/Ri5ZHQb4vBWnN/XSpxsWi8Euql93wVPz1XwO1YOq4rFLX3ZqjxpIaw4 RJhzPYz5kw0j5LDZwpU7AE+6zNF6g/Xyd737VaDQTIoFlfji2aEAAidkOEJuOSyHE86d Sv+bimEAuEpJCY3tEHzLwBCuc2228TrY4hT2BL+SUAVK/YbqcwHhQqZaf4ck7saog/oN qsKbOKgcSGT68pzK5YGV6GK0vOoy5csZEAO4QZ0RH2a9qR5K9JZZn7X5lqFYFT4oZFL6 JvBQ== 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=0xG7SpHFsGGPYJqubi6X08/1oBrgthJjI40CuA+QSdM=; b=r2cD8VmwjCyZ4FpDyERSSc2tiCOVgGzHxenzX9PmgHENbnLVRL2YKTATEA047kFxhv JRw6DrPYbUG/NdIXOpU5ofQukLQL7bdFYw/YA81S3ppTuM181bz2fl8Xjj+fifV8UhFC lRqgg9+h2uesDhYTW0U1wFRuhPKMQExguapNphBVVyjGTHduBj3J+kwzDPGA+2/cW2zc KPufpQ9eJyI0jBPSWJRRex92jsrkiyGOAfHGKcBBNjMZiJT+6LH9VWb+yMfqDnEhQEB2 PvLHVam54o9o9pkrscS+Zq/4u2oEwkXchX5Sze5Yn5pvZjF3O5r9BkCT+20kqq0xhqqA UnJg== X-Gm-Message-State: ANhLgQ28UrxQ10g9xUR/KfeVD+qQKpg9fV8hCEcJZN1GhM4/gnNZ5SCe 6y39TpcEb/2dNEqLx7tZCpAWVqf6eCUF X-Google-Smtp-Source: ADFU+vsR1uNwvPvRd9XsNS5rlpId8dNHQrxMfshA+HKQap35OolVUlrZmVmFMNvK998A+U3rthE/KBeeDFR6 X-Received: by 2002:a17:90b:230d:: with SMTP id mt13mr1997940pjb.164.1585007118195; Mon, 23 Mar 2020 16:45:18 -0700 (PDT) Date: Mon, 23 Mar 2020 16:45:04 -0700 In-Reply-To: <20200323234505.226919-1-rajatja@google.com> Message-Id: <20200323234505.226919-4-rajatja@google.com> Mime-Version: 1.0 References: <20200323234505.226919-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH RESEND 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 Change-Id: I18fd5eac746c0b75a23e8f4ee9b7595ce9eca707 --- 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 Mon Mar 23 23:45:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11454231 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 9171B1392 for ; Mon, 23 Mar 2020 23:45:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7200C20753 for ; Mon, 23 Mar 2020 23:45:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FJ96uvPE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727332AbgCWXpX (ORCPT ); Mon, 23 Mar 2020 19:45:23 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:53848 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727323AbgCWXpX (ORCPT ); Mon, 23 Mar 2020 19:45:23 -0400 Received: by mail-pf1-f202.google.com with SMTP id i26so12595362pfk.20 for ; Mon, 23 Mar 2020 16:45:21 -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=K7VFDU7GlU5U4OxUapn6OgbtnHCUEbg6buPZcCk3EXM=; b=FJ96uvPEpHjQNRDWex/xGNOmSvOdt1pxL2MVP9Hn8diPXufsanczI0F9UAwO9HFVTX AgDe+k3+hRhAyxWUMmJIrgSJpJ2qMRUI+aGSVuv6dNc+zBRwUg5Ub/YbdtHAw5Un5RXS d5IiS9DkmsILyrHWrBDYIIQYUkJgqkBlJtY+XQoXuw1slRWB8/1/uarmnWmyKGSkogFP 40hGgvrLi0bP4NbCEWZIB5CNNHknbs6EDbY04O1VSXN85uELIroHuGM2ksd0R9YD+KyN t832C0CLLfJcotEpZqoGckNiIXDgEuc0Nq6WfXCCNgEqx1JzdFkQyi6xFQV+lzGB0zJA fWCA== 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=K7VFDU7GlU5U4OxUapn6OgbtnHCUEbg6buPZcCk3EXM=; b=NT69386cMCoqbgMz2WI3MN38Z7ypFeirpx2qXkaKUDWB/DwL80R9xR/hXE+XZ73JCi 6wUjq/FVwpLUyIPzBojvQXN5PZ7QsIrtHCFmrAuJpPkqzXo+GdEGFxdVVEjvBdvBHdu/ gKF4LxMzvS6nCzWlzLXgsdkdUCeMMFpMX46WPP400MMNWf5426zjeKrijQMHypfmBaV/ 7CZu89+OURiyP5XQgk/yCvb1eTlkkZquBuK+js0GEU5qFet9qhX4yrZrvlIFXcUcvBtG /XIXxJzK52+hD3AWyAradsOpNFTEcrbkJKiYkwhUaQZl7bARMDEEkzeZv5gETd8bjH74 Smuw== X-Gm-Message-State: ANhLgQ39zykGBnPjDcZPU9n5jmUseYbUdM2bvayvW/oTX/l/jzPiRkI/ R1WDbKXu7fviLP6m4o8+AZQ4uhiWK0Ze X-Google-Smtp-Source: ADFU+vtzNNZ+frS2k2eYn6AUK9rcW4jYx4Hb49mce2tIaK5oiVCnnrj0ZBd2sKY+xjgd7DejcbjvLfReTdBh X-Received: by 2002:a17:90a:8586:: with SMTP id m6mr1937984pjn.121.1585007121296; Mon, 23 Mar 2020 16:45:21 -0700 (PDT) Date: Mon, 23 Mar 2020 16:45:05 -0700 In-Reply-To: <20200323234505.226919-1-rajatja@google.com> Message-Id: <20200323234505.226919-5-rajatja@google.com> Mime-Version: 1.0 References: <20200323234505.226919-1-rajatja@google.com> X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH RESEND 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 Change-Id: I5226fffc048399f003bc30410d5893f5ab24be08 --- .../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 */ + ... + + } } } })