From patchwork Mon Jan 7 16:42:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donghoon Han X-Patchwork-Id: 10750853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CDEC17D2 for ; Mon, 7 Jan 2019 16:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CBFD288CD for ; Mon, 7 Jan 2019 16:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 817D7288D4; Mon, 7 Jan 2019 16:43:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17501288AC for ; Mon, 7 Jan 2019 16:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727145AbfAGQna (ORCPT ); Mon, 7 Jan 2019 11:43:30 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37419 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbfAGQna (ORCPT ); Mon, 7 Jan 2019 11:43:30 -0500 Received: by mail-pg1-f196.google.com with SMTP id c25so377305pgb.4; Mon, 07 Jan 2019 08:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qd8d9av0X2U/poq85wxG6Xx4DFGNRfZuTQF5237CE6I=; b=oZdN4v7L0oJGbbdXPwG0OrDxbZD+A79AAtNco3D1RbchYX2jPpTCkl5Y0J825q+gDh thgG3bql3TXFwx/ic2kurJox3w1aowxUzbBuLoc5Nrcfz/7xU3CID393VkGtKp55h4Ci TylpZjOPmszZXcJFLkaqmr1631lRlTwBFKLgWUYAJggNZMH/EnC5qWteKHt9wPa6jjHG JHem55b1ypYQFKdKfsHHic4595XgkBpLYMsj0aoBCuHa/+n4Ry7rFtea6D/FhdB1BoG7 4t8L7MmK4mAp10rDqZDGlzOaWan+FPFd5hh7znttCJZk0P3FVtptYVIS3m/18sBNk2Q+ uaQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qd8d9av0X2U/poq85wxG6Xx4DFGNRfZuTQF5237CE6I=; b=AQ66Kq33s+Qd/R3mDsO2k2Q3xbut+TOpii7gqUDu37j3x1J6kXY3sbFZ78Qhwt64fR cxSzasNm4ud7RTGWz4HMZ6IFgGF8k5d7BGOAoocNtQbH165w4EFaAHBaP9PEEVSYhXXd ev9HuldOIfWreNWExd27zE53dv2CiTV84e2OIA2ygsi6CbpDP9f+VN6lmrde3p2clUe4 d2WEmoMIW0jPQZ/aJq2u1Md0FnSHC+CxC3sP0Yg9hQ/FZBmB4z9l9jGVg/grNtBBKTre 5ZxMPipUOzJ6aGlPz+oc+mC91iVSk0dyeamqqIuhRxuO6MmQ6hDZDbLdkh47dEBIlg5i S3iQ== X-Gm-Message-State: AJcUukdEqxgY86ta72jxGgddSBg7BNALTFuHaOwqnJ6xsj6X7xAMCrM/ PI6X1BFg0VcvCtU/aT64kZw0tk3F X-Google-Smtp-Source: ALg8bN4tm+rwR2jor3ow9WQRX08ARyPvwYz2lyo2V+wzNY+yuohx36rjQFivWHtViwsRxT95XOZq2w== X-Received: by 2002:a63:5c22:: with SMTP id q34mr11512297pgb.417.1546879409162; Mon, 07 Jan 2019 08:43:29 -0800 (PST) Received: from localhost.localdomain ([121.161.238.230]) by smtp.gmail.com with ESMTPSA id c72sm118865326pfb.107.2019.01.07.08.43.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:43:28 -0800 (PST) From: Donghoon Han To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Daniel Mack , linux-kernel@vger.kernel.org, Steven Han Subject: [PATCH V2 1/2] Input: rotary_encoder - Support key events Date: Tue, 8 Jan 2019 01:42:48 +0900 Message-Id: <20190107164249.2342-2-nazgul33@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107164249.2342-1-nazgul33@gmail.com> References: <20190107164249.2342-1-nazgul33@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Steven Han Support generating EV_KEY pair, instead of EV_REL. Signed-off-by: Donghoon Han Cc: Dmitry Torokhov Cc: Daniel Mack To: linux-input@vger.kernel.org --- V2: added missing input_sync() --- drivers/input/misc/rotary_encoder.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 72eee6d55527..0014a7d9f8f9 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c @@ -41,6 +41,8 @@ struct rotary_encoder { u32 steps; u32 axis; bool relative_axis; + bool relative_keys; + u32 keycodes[2]; bool rollover; enum rotary_encoder_encoding encoding; @@ -79,6 +81,11 @@ static void rotary_encoder_report_event(struct rotary_encoder *encoder) if (encoder->relative_axis) { input_report_rel(encoder->input, encoder->axis, encoder->dir); + } else if (encoder->relative_keys) { + u32 keycode = encoder->keycodes[encoder->dir > 0]; + input_event(encoder->input, EV_KEY, keycode, 1); + input_sync(encoder->input); + input_event(encoder->input, EV_KEY, keycode, 0); } else { unsigned int pos = encoder->pos; @@ -237,6 +244,16 @@ static int rotary_encoder_probe(struct platform_device *pdev) device_property_read_u32(dev, "linux,axis", &encoder->axis); encoder->relative_axis = device_property_read_bool(dev, "rotary-encoder,relative-axis"); + encoder->relative_keys = + device_property_read_bool(dev, "rotary-encoder,relative-keys"); + if (encoder->relative_keys) { + err = device_property_read_u32_array(dev, + "rotary-encoder,relative-keycodes", + encoder->keycodes, 2); + if (err) + dev_err(dev, "unable to get keycodes: %d\n", err); + return err; + } encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN); if (IS_ERR(encoder->gpios)) { @@ -260,9 +277,12 @@ static int rotary_encoder_probe(struct platform_device *pdev) input->id.bustype = BUS_HOST; input->dev.parent = dev; - if (encoder->relative_axis) + if (encoder->relative_axis) { input_set_capability(input, EV_REL, encoder->axis); - else + } else if (encoder->relative_keys) { + input_set_capability(input, EV_KEY, encoder->keycodes[0]); + input_set_capability(input, EV_KEY, encoder->keycodes[1]); + } else input_set_abs_params(input, encoder->axis, 0, encoder->steps, 0, 1); From patchwork Mon Jan 7 16:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donghoon Han X-Patchwork-Id: 10750849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 238916C5 for ; Mon, 7 Jan 2019 16:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13E2628887 for ; Mon, 7 Jan 2019 16:43:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 076662887F; Mon, 7 Jan 2019 16:43:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0DDF28887 for ; Mon, 7 Jan 2019 16:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728047AbfAGQne (ORCPT ); Mon, 7 Jan 2019 11:43:34 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42528 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726668AbfAGQnd (ORCPT ); Mon, 7 Jan 2019 11:43:33 -0500 Received: by mail-pl1-f193.google.com with SMTP id y1so392305plp.9; Mon, 07 Jan 2019 08:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iTXKezavfd1/8uh6u+UUWRqnfi0okDbl6ln27kN1WUE=; b=GO/XE8/nuZmHgZU7hFnddfFS//MJQrg3pyrilzu4JG/5INqvl7mkwiTLA/+yXclzSE nxj9aS+7OTeNi949+BQhEyMJufqxrjoeAt3Bq7bmbYTl7sGWNBoEZRH6Tlxw51Qt7j7t A+nO6HPIDRK5mpSqivE/o9sD/vTwR0LPNFwiKPVNcXsMiPOLu6Tz0bTr+KeEzh6dSU6Q +ar+S3F8fAARlJDL6ZVUe2oRvNynskbDHqInhyBAR2iL18JfXgNxB0/u/UKm4hvmQ0u6 PSyj54/5nUSg7RijrPEyVYOAOn0iz6N/1Nr66eBuY+v6hGRTtkC/tx/akYHTrsH4f8Km agPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iTXKezavfd1/8uh6u+UUWRqnfi0okDbl6ln27kN1WUE=; b=J60MHk6W0aGi7/YTga3fIl3lW8owHeZ37k4Fx8swQ2d7od+SfWuvrfbVc8/T71ZQL/ KuvzjdsR5+4QWB+eqCzjFjGWZ9q5cUo9Pa+vqnm0/22GQTWeC1HQEZLB1gZtAEIwpgyf 5t+4Q2WOsmOy8lZ2p/PGQWIiIjFyDclCFnHAGBzYaYn83O3rrHLcToTZlQfuOFpjuWk2 K9IXqdMo/3vNzLnDyoWGBWjtBNdFoq4RAwT3jqAH5dIImjVOxgBudAD55GQfuh1HYOpo xGZg5CzF9vAwy/4gW/MW7oVjb4FvwFt+92kFiWSOntuEeVF432xrVS+oNrxfq1loKcpT 7hWA== X-Gm-Message-State: AJcUukegCks/6iolDb9KmN1xoUCt+R8sDNQ/hpWzE7rWDGD3pqaGqh6A nuWNYgx+CAo2CR7hMMpJOizD9l8e X-Google-Smtp-Source: ALg8bN6EJu6JUv3CwrN7tnCDHYXbg1g9cy5QKTNwJJLjSTGvFkUQ4+G0tL4nTl3DxV1daUzGP9AyDA== X-Received: by 2002:a17:902:1d4a:: with SMTP id u10mr59444329plu.122.1546879412609; Mon, 07 Jan 2019 08:43:32 -0800 (PST) Received: from localhost.localdomain ([121.161.238.230]) by smtp.gmail.com with ESMTPSA id c72sm118865326pfb.107.2019.01.07.08.43.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jan 2019 08:43:32 -0800 (PST) From: Donghoon Han To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Daniel Mack , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH V2 2/2] Input: rotaty-encoder - Add DT binding document Date: Tue, 8 Jan 2019 01:42:49 +0900 Message-Id: <20190107164249.2342-3-nazgul33@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190107164249.2342-1-nazgul33@gmail.com> References: <20190107164249.2342-1-nazgul33@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add DT binding document for rotary-encoder, keycode options. Signed-off-by: Donghoon Han Cc: Dmitry Torokhov Cc: Daniel Mack Cc: devicetree@vger.kernel.org To: linux-input@vger.kernel.org --- .../devicetree/bindings/input/rotary-encoder.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/input/rotary-encoder.txt b/Documentation/devicetree/bindings/input/rotary-encoder.txt index f99fe5cdeaec..9986ec2af2d4 100644 --- a/Documentation/devicetree/bindings/input/rotary-encoder.txt +++ b/Documentation/devicetree/bindings/input/rotary-encoder.txt @@ -12,6 +12,10 @@ Optional properties: - rotary-encoder,relative-axis: register a relative axis rather than an absolute one. Relative axis will only generate +1/-1 events on the input device, hence no steps need to be passed. +- rotary-encoder,relative-keys : generate pair of key events. This setting + behaves just like relative-axis, generating key events instead. + (Keycodes[2] corresponds to -1/1 events.) +- rotary-encoder,relative-keycodes : keycodes for relative-keys - rotary-encoder,rollover: Automatic rollover when the rotary value becomes greater than the specified steps or smaller than 0. For absolute axis only. - rotary-encoder,steps-per-period: Number of steps (stable states) per period. @@ -48,3 +52,11 @@ Example: rotary-encoder,encoding = "binary"; rotary-encoder,rollover; }; + + rotary@2 { + compatible = "rotary-encoder"; + gpios = <&gpio 21 0>, <&gpio 22 0>; + rotary-encoder,relative-keys; + rotary-encoder,relative-keycode = <103>, <108>; + rotary-encoder,steps-per-period = <2>; + };