From patchwork Sat Mar 28 18:59:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11463775 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 6DCC792A for ; Sat, 28 Mar 2020 18:59:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BA6B2076E for ; Sat, 28 Mar 2020 18:59:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kktvz/xD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727151AbgC1S7a (ORCPT ); Sat, 28 Mar 2020 14:59:30 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:46728 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgC1S71 (ORCPT ); Sat, 28 Mar 2020 14:59:27 -0400 Received: by mail-qk1-f202.google.com with SMTP id y5so4367742qky.13 for ; Sat, 28 Mar 2020 11:59:24 -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=rl7WtDkNIzzT60ikOJJ0txPNPltV1gR7r9BpQuGY/24=; b=kktvz/xDC5Ag4Xmj8Jrm0AhTJwkFC/qsP3ICI3dL1lLCrOBa3csHUlKe52KKIgeqvE +86bW8xHb9NQYofFO9FAGbuK06EQF0uVZDDcvX4dSpQt63uKvll77VmDU+cVnDEhYZ2g BlEFOtQLAlKHaXDpfDsWKAtJDtClBjQ5cMyYKXBxNUPZqZVx6ckeTGFQlTTRaaolhiZC GdH36ObUiOXvsyaTuMFD+0s22cNxXMU4n0XaRzN+pKzTgbimBzVLtDEPApgVsClTk4MC OFL7DFFBF5iDe2EMb6o5ddUCtdLrsHHgBcy4g1wpQTXoBjvv4sWBuPMXvc/47au5mNg1 fGyQ== 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=rl7WtDkNIzzT60ikOJJ0txPNPltV1gR7r9BpQuGY/24=; b=qIMyWG/KiedI/6+wWGMeDCRlqZKww08uQeFv9epp94sflEh+2QgHwhpQlRILOE+HfF vxu+acGmEaTkWM9G7fVCSg7rQG5woFAeqBDh/vqUxUf0bREncTJ9vGRGb3qWi4xKQY2Z ZjMBczqBWuO8eUiaIbdz6YTtEgrQ4xbvclUBmDuMEW892X1WUA72TgGklkSxsc8jKICG HFxfSifN5tPuTGblUaxv3SkBI6blT7eLbGMOk4xJbmpUuAG4vzH3dd6tmwmc+7NS/MrW 5ANW9Jj5GXz1a6olg8XrOZTz+o3wGpEW/PmigUAb+meZFIA0PyujlbacPkswVMEGmgXL VEfQ== X-Gm-Message-State: ANhLgQ16uPmqcQA9EhjyZT97Ryw0tizaK3gg9J1/EAqerPVf2d7FRRhV DTHIPkwS5U5FxWgnk1SndqP7oW3/O+Eb X-Google-Smtp-Source: ADFU+vs2gnpUlOHy0fXAvwisX5Qfdkf3EWGsz6IBFlP2etVqkgtyIwl4tosOOeSYJ4Ov1RnVl30PVeeFZQ2t X-Received: by 2002:a05:620a:4d5:: with SMTP id 21mr4933357qks.433.1585421964138; Sat, 28 Mar 2020 11:59:24 -0700 (PDT) Date: Sat, 28 Mar 2020 11:59:12 -0700 Message-Id: <20200328185916.98423-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [PATCH v4 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 --- v4: Same as v3 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 Sat Mar 28 18:59:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 11463773 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 1DC1A81 for ; Sat, 28 Mar 2020 18:59:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E74B320732 for ; Sat, 28 Mar 2020 18:59:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DAQ8XHD8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727125AbgC1S7a (ORCPT ); Sat, 28 Mar 2020 14:59:30 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:36503 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727131AbgC1S72 (ORCPT ); Sat, 28 Mar 2020 14:59:28 -0400 Received: by mail-yb1-f202.google.com with SMTP id w185so12535563ybe.3 for ; Sat, 28 Mar 2020 11:59:27 -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=cb6A4ZievIvvysAvumZN4FIO7dPjsgeMK8Q/oul1Xgs=; b=DAQ8XHD8okBVh2XJa2USholx+1RJddSlBF8w3rKul+bEhcpC5OB7CgsmbHySNT5MJU H5RfSes0X3kz7itAjJPnhGW4wMPiSdhkWYf5TbYt5tcDeJDy1CysmVteAXTw3wLkp5+S uAxj5rvzEzFn4lrDtMMHQOLiRcEhwZnrVWDEUoDI2Iw3aup9M/ylYf/ozgT9Qzu1o2zX m3HgF5Bbc9x1zyMdpXaDku2GIEi6EAVYOZbHMvjK8Hy8yfPGIoQxFqW8EaiDNoFTPimU ysxEwBS4A/KOyF+PfZ32GBx3fzfxIoUKYx2NiCsCtEIcJinhiawCVDMwPC2Ra9kbTe6Y xPQA== 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=cb6A4ZievIvvysAvumZN4FIO7dPjsgeMK8Q/oul1Xgs=; b=cjPBTmQ9bxkoUfI9Z1P6FYVMMNhAwLyUgFf/FiWn/woLrybKcW4tyMHqegSE5wGG/B nq0DGb7DlWgHUupSeAqN+y/INPG+z0lrtj7MzNVwxVf7vteYAUCYduUyYuix3JD8BhxP XVUQXvv6XnbOnuXy52eOC9/L8c3ebm/UIHjEbOt5WLKdQvSY/VvgYxd7hEE2m6Y47lOO U3yAdnNFpHYSzpJAAH9iMoy05o904GWsAnN5XzyfFVwv95+MfwoDxjhitIxzC+gSyObQ euVJiH2NsD/TimeabFL9n8vgKaVbZ12aceuOnL1Bp1QE0Ey3566qeYUEsxzCb/9kfpF2 opmg== X-Gm-Message-State: ANhLgQ2kbPdB2F2aAdek59PAz/+qicpHY6t2xFwvvfS6am3NxuFYrVC+ ZWRoljFIvxdLd8P49UMzBeIx0pZ8R6/Y X-Google-Smtp-Source: ADFU+vtux+3y6NC8cdca093ciq5FCliMi9Au9EXmPcbUQ9hQB3QDO5O6FwgnREVqgVeBRyFCZRy1RPr7nH3g X-Received: by 2002:a25:9d88:: with SMTP id v8mr7013374ybp.433.1585421966999; Sat, 28 Mar 2020 11:59:26 -0700 (PDT) Date: Sat, 28 Mar 2020 11:59:13 -0700 In-Reply-To: <20200328185916.98423-1-rajatja@google.com> Message-Id: <20200328185916.98423-2-rajatja@google.com> Mime-Version: 1.0 References: <20200328185916.98423-1-rajatja@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [PATCH v4 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 --- v4: Same as v3 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 Sat Mar 28 18:59: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: 11463771 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 12AE581 for ; Sat, 28 Mar 2020 18:59:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E692120732 for ; Sat, 28 Mar 2020 18:59:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="LsfvxAZT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727356AbgC1S7b (ORCPT ); Sat, 28 Mar 2020 14:59:31 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:39592 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727193AbgC1S7a (ORCPT ); Sat, 28 Mar 2020 14:59:30 -0400 Received: by mail-pf1-f202.google.com with SMTP id x189so11484729pfd.6 for ; Sat, 28 Mar 2020 11:59:30 -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=RmZqFhOWmJfblEL39xHqmka8Tn/Hx8czxElVow6EI48=; b=LsfvxAZTfx0EdEbqJrtv0QvW38sITdabmPyei4aZ2Hy3cyyWY8SsoAvWle9hPf5oDC ioejvTsBSCiwQsSjc2tzw9uRHh5zKQM35MiR5Jdej0EAugnnFvynwQezlZKSIaFKf+La nIHtqe5HTcqlUdFEb8uGC3sm6xVXOuKjYe9VctUSWq2rT40VMpsnwW1JlzqcHdJ/3ez7 Iqv4ChmXgPnGbUir4rlt7tTWuh4eaLA4hd2t5DdPvqYnkNloLEfog78LvamAkZV9W4++ wA5TR4ndSFw18N6W6nDejDarzS/aDW4vxFXuhtAkifBrNPgcvyAUmmDz7Cdr0CFTNk91 7fOA== 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=RmZqFhOWmJfblEL39xHqmka8Tn/Hx8czxElVow6EI48=; b=NwBfv/Y45pep+3JUC4iTAjTkFg99OWcz+RswRNHA/OKeX9um8QxhsU0ZG3TmOjE5oM /+tC/7rrVGsA+xhCnFEAkmassJse+aqmuS/iX+tpVNJfpelJK2djGxo8PW/UetpYRSUa az4WQ2e1JTcz/Urq2ofHrZr/brg51IA+9L3P/NZbAR2VF+46v1uAuCtB2Dje6Hzny1CT WQf//2QekRFW3JtvtU3epT/UiJFVnelVn5M8S+KFjYPACrp1KoLnlFbzVzBEm2srfp+d c71iOS7nNb5XrBSX0H28OMh4W47nUbkPcDHZwSEEB334/JL4hUw9L83D1D2BqL5bUg7R iyMw== X-Gm-Message-State: ANhLgQ2extK52ED4zFteAbCZe+kdivnP8nweH5HFgoAAZV9QZGqWv7ES NbQ2S5MUAxpC0ytYzcfPyzxObKvENoZD X-Google-Smtp-Source: ADFU+vuoEMxULA3UhwesqVMltERLeDVP8XgmIuQ9z/hiaou45fh2RQVncRU3HyXUkshQHrnPQy2r2ato9pUj X-Received: by 2002:a63:4c0b:: with SMTP id z11mr5506572pga.385.1585421969560; Sat, 28 Mar 2020 11:59:29 -0700 (PDT) Date: Sat, 28 Mar 2020 11:59:14 -0700 In-Reply-To: <20200328185916.98423-1-rajatja@google.com> Message-Id: <20200328185916.98423-3-rajatja@google.com> Mime-Version: 1.0 References: <20200328185916.98423-1-rajatja@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [PATCH v4 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 --- v4: Same as v3 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 Sat Mar 28 18:59: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: 11463767 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 6EE0C81 for ; Sat, 28 Mar 2020 18:59:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39A9C20732 for ; Sat, 28 Mar 2020 18:59:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sj3kS01e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727191AbgC1S7d (ORCPT ); Sat, 28 Mar 2020 14:59:33 -0400 Received: from mail-pl1-f201.google.com ([209.85.214.201]:39731 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727406AbgC1S7d (ORCPT ); Sat, 28 Mar 2020 14:59:33 -0400 Received: by mail-pl1-f201.google.com with SMTP id d11so9697341pll.6 for ; Sat, 28 Mar 2020 11:59:32 -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=OGNXs3NwKjk0dDeSHSXg81YijfbEbudE8mDeHpkOVOE=; b=Sj3kS01eYr5WT4Fc1GvJ9Y3z7uu2N1FDeotd7kk6k8/7QydjsRgg7y84YBxLjH/5px Ja3168nhkht1ak+6owEmdvZ08ApoeSJby75xk4dDbRLESLOVZEpdwlNibYYRZQQVR8UD AailkVpZN+syYaACa2t7ZUmwNSo67n4iSXI6fsCP6dF7GaFSttHKThBML1fByuRpO8cX nuzAJhnN2SdaZDERJ9Hgi8AUVbkgX0onXkY2nklQcYdw4djr2Ql11NDBNULzqIisWuOg SPsyx5uT6uX9ed7pM+D7tbmKQjvbQICjbFQ8LwFFQF3x+vA/VV3VuIV5vBMFqV7vdPs/ edyw== 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=OGNXs3NwKjk0dDeSHSXg81YijfbEbudE8mDeHpkOVOE=; b=UdneL2GAHAA397QaU5wDUkh/7FKpe1S3Vv78umwoSX9JywLxNgYSYWj3RJEbVGNy6m MoHaMSbaFo2SlOVNnpdRmv3t4VQPnbrO5+VPZYG+BxrrXmCuci5JWPOgcd+HPkvvHpkQ kSBhNMbTSly/dlESkHpBmwtFaI0y9KVKx4Q1VHywyN9o2p2NoCmxVBLTSUkSkrptFpkp iY3lFN2tRryT+bzH56gAe06Dl2mj3PhSwTDlg86nMHsRA3OSLvnWUFdxuuoPAnBk7ohZ TUWJ8lbEXGJzhRbOI+7qrSO45pcNwFfwA9C8SGTW9xzeLPB7eahbRwFaAJDHsNPnIg64 HNTg== X-Gm-Message-State: ANhLgQ0KXzKQvmpdwPbuYW/XsGp6DFwd/tywfnQ0SxFqLG4eX2EiFZ6r YDLXMsTo5nKrVQKYEvwbDt+QA3uzik// X-Google-Smtp-Source: ADFU+vvC8nj/oK4By2+uBwrMdTDFPDLZ8i8ninPAa5Vf86oXT8sTO+R/ULp/peL9EAEGwoArfK8NIXRQWcTR X-Received: by 2002:a63:6d43:: with SMTP id i64mr5379169pgc.201.1585421972254; Sat, 28 Mar 2020 11:59:32 -0700 (PDT) Date: Sat, 28 Mar 2020 11:59:15 -0700 In-Reply-To: <20200328185916.98423-1-rajatja@google.com> Message-Id: <20200328185916.98423-4-rajatja@google.com> Mime-Version: 1.0 References: <20200328185916.98423-1-rajatja@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [PATCH v4 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 "linux,keymap" property which is an array of u32 values, each value specifying mapping for a key. Signed-off-by: Rajat Jain --- v4: Property name "keymap" -> "linux,keymap" 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..3379fb5e7169b 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 "linux,keymap" property */ + n = device_property_count_u32(dev, "linux,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, "linux,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 Sat Mar 28 18:59: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: 11463769 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 2473A81 for ; Sat, 28 Mar 2020 18:59:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0372620732 for ; Sat, 28 Mar 2020 18:59:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eaJepCUA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbgC1S7i (ORCPT ); Sat, 28 Mar 2020 14:59:38 -0400 Received: from mail-yb1-f202.google.com ([209.85.219.202]:46146 "EHLO mail-yb1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727447AbgC1S7g (ORCPT ); Sat, 28 Mar 2020 14:59:36 -0400 Received: by mail-yb1-f202.google.com with SMTP id h185so7814659yba.13 for ; Sat, 28 Mar 2020 11:59:35 -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=SJTEeEKUV6TX+oPumalrivliTEZBzSn7PT5Yeqgsp2I=; b=eaJepCUAwlimKsXKMAKNJjSZXgGfYYQs8q1MPuEmLZuJw6/LfxHDz+ro1ySSWGlI21 /Pdl3c/UX2EZI2gTIB9hMIGkxxtTXR2tDf5liLSZCSH0WSju8OySAWKjKmpyF4bohM3u VZ2mHvAFx+oGS4BRTPiRJD9tkI000CowpLcYV7rmrU5RfDKamqS0bqhTvGKsNZXWJHYY iosjHw+SyBn6u0qt0i+kUFlBLlYE74Lt/8FaXgzBMngDo6SeJ7FOb8MLu8D40v0jfGQW 5oDkRcEA5pDmTOTRN3LA9shC/eTPTryav0qiENQ/lpufgJ17FRYORPEZmJMTshC6RZCZ Ff0g== 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=SJTEeEKUV6TX+oPumalrivliTEZBzSn7PT5Yeqgsp2I=; b=IxHg0alw4ybpRvOFveZPx4+iLGPZQP5wixV0mYW/j5FOJM9pCqhIeGDZZrHjkuNBUL HIUjgW82rqLeOLgd8yNs9TIhTA1kjKLFP2TgUsGeB8yEMK5/x+smz3H5L0LXFmDa0HdC w39A38PgHPkgmzW1plz9FguND8e1JVppoyw+QLllek37tBhyMvSeYqWziwR/o7jkkb3b EEMLQaLT1mFiaKan1VZEK+EOSD/JnpsMBvLN0y7j09bYph8ZE2roJ7zX+/fTkCDq+oBw wpr6TbO0oDU3sNyRRX3hnB540UXfjKyEZ3hGSzZ6IhUiOUQkj3YYlMI5L9KSBp58bl1C 9maA== X-Gm-Message-State: ANhLgQ1QhufPp9kp/j7lOXej0jBw8cFF6vb9tLm/A/LXr1d6k7UMioBL sia0OWa7BYgB8/ZVIF8ibhzia8Uq4eqm X-Google-Smtp-Source: ADFU+vsI0cZ9NAw9lkP2sgVNhfkx3UtYksWw5uSv9BLEwzeRDk4wXySWY9En8Bk1kv5+Bl0QL15WbBbA35lf X-Received: by 2002:a25:38d2:: with SMTP id f201mr8070008yba.226.1585421974894; Sat, 28 Mar 2020 11:59:34 -0700 (PDT) Date: Sat, 28 Mar 2020 11:59:16 -0700 In-Reply-To: <20200328185916.98423-1-rajatja@google.com> Message-Id: <20200328185916.98423-5-rajatja@google.com> Mime-Version: 1.0 References: <20200328185916.98423-1-rajatja@google.com> X-Mailer: git-send-email 2.26.0.rc2.310.g2932bb562d-goog Subject: [PATCH v4 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 --- v4: Property name "keymap" -> "linux,keymap" 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..8b6d7e2c55bb6 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. + linux,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 () { "linux,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 */ + ... + + } } } })