From patchwork Fri Jul 14 10:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 120427 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2432294vqm; Fri, 14 Jul 2023 04:23:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgtU6uf5032q8hSuNSkOSxfBPhY7g7yCiIyroKwlga1up0hE+CIGfS1YR7R9c15dM0JACb X-Received: by 2002:a05:6a00:2e05:b0:667:85e6:4d1 with SMTP id fc5-20020a056a002e0500b0066785e604d1mr5765809pfb.33.1689333830563; Fri, 14 Jul 2023 04:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689333830; cv=none; d=google.com; s=arc-20160816; b=sMiC8S8N0T+iaHeMfIMBhWmufNnGeVOFzAmzOXnhUhU714Mo4ilXCCO+qlX1RJm7Nh Os8snazMpeJosVBCYngP4Hxk8RlY0u469l0HTAIHoKMLFa5qmlADxchfv6rqAiJNUkMS 9YNy6xdeS+71mAcqqfOTYU8V7OfTZks7uUeG7Q5PWcTAZlvh7yoDuttarxzTnKipMuwX 4en7zc//xwydp6ugNsQop4wFbpq4IswtyMOEozmwplKFa3Ur/RP4XhRrBJ3wbnmRcHSF c9Mei3onDn+RwFCQQaC5ilDwAMlS67ZvI1Xl87QkTd/HTUGPhChMUyaooMKC1WhAC9MD MsUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UQ+dgEJhccslLRCe6E0bHpIqKrs+yHP/rIwnEJNcN7Q=; fh=8w8yyCTMH0rq+KBMYXFhprgOqds0QG0pCmGK0cf9kP8=; b=fCtG4kI4yfO2JErXa5Fm9m2KlsIRVVSpuiArvSS6swdlSjci4Pq/E6HVx4EXVjy4GU tp4qGpjM/Whru3nRgxJP2ZOTPw5bAt51lCuiVrlIKGKIvogBnDsi9BDC+QVaaqjM33c6 dn2HGP0U5m8d/5HXlUKYnl5jhvn7tTtl2U/vXwt92n3mLKS10uh/Xdx6yuIY1H+qqCqu rCZfyaXPiJd0ClMm/o4LuuXbOnzCdvtI6zlDtPXUa9e6k3AVIFrokkxdZ9E+F/PY9GAo tGJ5/zm+Liviw/BkppVEklL4IZd4Mm1yg41WhoXscVLKb5DUpy2d6liVJozmcM5wErht l9qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=T9I9KnWi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ct8-20020a056a000f8800b00682399fa4f9si6973988pfb.300.2023.07.14.04.23.37; Fri, 14 Jul 2023 04:23:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=T9I9KnWi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235944AbjGNKEg (ORCPT + 99 others); Fri, 14 Jul 2023 06:04:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235917AbjGNKEd (ORCPT ); Fri, 14 Jul 2023 06:04:33 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E7082700; Fri, 14 Jul 2023 03:04:32 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-9891c73e0fbso343694566b.1; Fri, 14 Jul 2023 03:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689329071; x=1691921071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UQ+dgEJhccslLRCe6E0bHpIqKrs+yHP/rIwnEJNcN7Q=; b=T9I9KnWi3qLdDOlHb7Jrn9WJ/cfF34/BvKrRNhOuYySN+NvoaQYaKNiNw15fxvMIKx 4rkdXMIRlj0Snw8hFbPUz/dPiradwsYCkyD7m8ttPiRFaLDTCAO8gk52x8WqxVnB8d2b BCCvE0tbn1sY53i4VRNNfR8efDTmTIiSYwrO4N4jjpD8cgAkGZGVai5dQu3/WVspAMuu vrEMRv2JE3XhTT6RefdI9yi8sGjyDW1p9XI2SlwIUM6YUIh/1s5Q25wkFGViVKL2/CaG M0Vtdk9i5AwfBBTXXNH/myTYjspWBNifKomjHNt+OxZJtMQOYk0q7Qd0fH8LWJ+X8QV9 pQDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689329071; x=1691921071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UQ+dgEJhccslLRCe6E0bHpIqKrs+yHP/rIwnEJNcN7Q=; b=aTld50N9X4dysfIz0ijmx+o2BimFDpqxSgkQUKa8zd+8pLe/p56sQmtaW5jZqlWKUw U1RAGvnvLiwKhM9XrUN4AvuVaiYQPbes/HqeWQOnfw+aTqkoABkRf/lv8E5m/C0dn3YY vfuvGlv25JXcGU5oseSMzwGTO7jWjO6YqZ9z5hucC3SaWCVugTq4Hhqf9W0m5ASYRsdO FActQBVpqlJfS8edohWpBoT9VYKQ49tI0VP8xDnq+N9n/Hl21Gqcx1WX67bOW0cWP9eT 91q/9ca0BdXb1z5ETNT58fI4cyTNe7FgWw8ZwSgRtZsG+GTY8whMTkGXfOk+uTbyj0Dk E0qQ== X-Gm-Message-State: ABy/qLYl+iw/rHXh3q4O/pn2vZn6RYvs9S2y+2Dt3lA/gezbsAcan51a i11BuEp5lN5YTf0i7kP7cek= X-Received: by 2002:a17:906:225c:b0:994:5407:9ac9 with SMTP id 28-20020a170906225c00b0099454079ac9mr649852ejr.5.1689329070634; Fri, 14 Jul 2023 03:04:30 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-105.multi.internet.cyfrowypolsat.pl. [37.248.157.105]) by smtp.gmail.com with ESMTPSA id h7-20020a1709063c0700b0098e42bef736sm5215415ejg.176.2023.07.14.03.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 03:04:30 -0700 (PDT) From: Artur Weber To: Dmitry Torokhov , Rob Herring Cc: Krzysztof Kozlowski , Linus Walleij , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber , Conor Dooley Subject: [RESEND PATCH 1/2] dt-bindings: mms114: Add linux,keycodes property for touch keys Date: Fri, 14 Jul 2023 12:04:23 +0200 Message-ID: <20230714100424.29798-2-aweber.kernel@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714100424.29798-1-aweber.kernel@gmail.com> References: <20230714100424.29798-1-aweber.kernel@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771394910558773954 X-GMAIL-MSGID: 1771394910558773954 MELFAS MMS114 and similar touchscreens have support for touch keys. Add the linux,keycodes property which can be used to set up the keycodes for the touch keys. Acked-by: Conor Dooley Signed-off-by: Artur Weber --- .../devicetree/bindings/input/touchscreen/melfas,mms114.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas,mms114.yaml b/Documentation/devicetree/bindings/input/touchscreen/melfas,mms114.yaml index fdd02898e249..07f9dd6b1c9c 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/melfas,mms114.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/melfas,mms114.yaml @@ -52,6 +52,11 @@ properties: touchscreen-swapped-x-y: true touchscreen-max-pressure: true + linux,keycodes: + description: Keycodes for the touch keys + minItems: 1 + maxItems: 15 + additionalProperties: false required: From patchwork Fri Jul 14 10:04:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Weber X-Patchwork-Id: 120399 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2403089vqm; Fri, 14 Jul 2023 03:26:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlGpHu6rUAW3eW7vLOazh+gkmHiM6uT6M2io8euLMuZZy3nndUC+fe73CpItPhazFzGq8tWU X-Received: by 2002:a17:90a:fe0c:b0:256:cc5e:e55b with SMTP id ck12-20020a17090afe0c00b00256cc5ee55bmr3493045pjb.7.1689330386992; Fri, 14 Jul 2023 03:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689330386; cv=none; d=google.com; s=arc-20160816; b=YsSi8tZ5tJFyvWNoko1jybOg5XTzmbIsNdwpcI2u5af9wTprgRPXAAPFH96bQhBz71 THM96Z7n0t/7HBYjxkWcMRCMPKX603Fo8MjQudX5k9LYxcZFRtIf67MN4lB/mpjvEkeI cNvVuNSndjjfcCR4PrzOvNnx36TTWjbd566zvroZLhHs8X29KVcPj3ppX5LrUPkuLgfY mT/kQj9r59rtTZrnF8qbyADbvocOhYqzBPiVYcuDtbWwxzfrTP2qwiiKaKkQv3PlagA6 12fow04gVRy7l0FgtARJJGCIaMnQqd/yhpnBSiEgRJwW18ljE6+/qHufeOlp2Hu0PgvL FouA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pC/ekmqpW/98xWIWVd/9RI7IBbK7bLokWpnG3F0TMEs=; fh=N/2fIFaQz2lrYh61yb0qBwFuxyS0KJmyYg0Z7UUGswg=; b=seONUegGNIoChlHjBc9UFzoCWMTwQYReC+gxm153supnfx3vcmqT5zDijtk2bEuE/Z 91Z92ZHHa1a8APep2oUKG81J0SdyN3doWFxj5sSEieY/8IRPsY0Vw3ERNq9gWdS6hKrM 0CpesgY3926EPsrFVndQUfawUh3l+Og1kQyQ+YR5FyPd8eOBeqTMZweFFBTwzeqJ5NVa CwCufC4Z04cGuuNmIAl9MwgrGKurD+8ht83FFilqx8GInk6mSKkscO4cpSPtp+UjbcRw bWUQ7n/ACt9Pe/F3fjLEpRF7AnQN9MLEtWljOW5HkCOQDmvL0XyOYzWTMc/0OhXHIBYB sUSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KdeS9tXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z4-20020a17090abd8400b00263638bb354si1046820pjr.93.2023.07.14.03.26.14; Fri, 14 Jul 2023 03:26:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=KdeS9tXY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235917AbjGNKEj (ORCPT + 99 others); Fri, 14 Jul 2023 06:04:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235931AbjGNKEf (ORCPT ); Fri, 14 Jul 2023 06:04:35 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBA972D63; Fri, 14 Jul 2023 03:04:33 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9924ac01f98so227463866b.1; Fri, 14 Jul 2023 03:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689329072; x=1691921072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pC/ekmqpW/98xWIWVd/9RI7IBbK7bLokWpnG3F0TMEs=; b=KdeS9tXY3ojXr5cPM6vOzItutVezVCodV0EQVVq6PqzC5qtulq234RLWNCcMzac9vD 5itkDtJyQoO4oJzAW6nXnhzH+C5u5I619ssfl1zCKw1OGEoak0w8XflYutMQxamjM4SV 6GY2xA+C7niDtmyJZpC9orSrMIJR7C0FbleCEbNx+Kxi+j2NYSembuuSwHQqGMpX37xL jU45XkASr6bH9iX2Zt9r52IoF0RyrBDFE8N3QeHwgII3UltuXlwDc4o7fAAR/+Fn7CoB GovYmXXpnRId7VXUKzinFJfn/GgWtnYLrdnUmE2xf3m9u3iJtcYA+Ggt6cZhKVtgUpqk 6g8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689329072; x=1691921072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pC/ekmqpW/98xWIWVd/9RI7IBbK7bLokWpnG3F0TMEs=; b=be74CynDGlC6L5ibB3hTWrk4QaftHoPUZBzEVDGy4Gz9aXET6ipgf9luRJJwW34k+n ya5fg47PXDui/M1M8eKG7ThkzjXQJ1o5280XLi0Q3OW7cNFsSU+PKiNSy63V7YUIM58L A2ULSbxdysdtjZBNgiba20xEbRGI3ePWAAkLhAbJ9Y1gJYcKcrxuWqzhAkF2ZWlBuidR Usv2DeK6eh1NrK9CJXui4h7dnR5X35XigCNChT0VjZ7EuqLaP4+uNscsWs5S3oIH9/GV JXBTUw1Ilv2GWzed+tAKXImh/8tWUgXF6zF0Q2LJRqk12g4/7KnzQHIL1O/WaPeJtgtv a5NQ== X-Gm-Message-State: ABy/qLYWWCcWEzuyoo+teTA1Ts+DZTYt6ptpt38pUnIdHBAzEnISU1+c CkrYCCtPktnYSreNb/fneco= X-Received: by 2002:a17:907:1a58:b0:992:c40e:3c17 with SMTP id mf24-20020a1709071a5800b00992c40e3c17mr3179674ejc.75.1689329072184; Fri, 14 Jul 2023 03:04:32 -0700 (PDT) Received: from tablet.my.domain (ip-37-248-157-105.multi.internet.cyfrowypolsat.pl. [37.248.157.105]) by smtp.gmail.com with ESMTPSA id h7-20020a1709063c0700b0098e42bef736sm5215415ejg.176.2023.07.14.03.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 03:04:31 -0700 (PDT) From: Artur Weber To: Dmitry Torokhov , Rob Herring Cc: Krzysztof Kozlowski , Linus Walleij , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Artur Weber Subject: [RESEND PATCH 2/2] Input: mms114 - add support for touch keys Date: Fri, 14 Jul 2023 12:04:24 +0200 Message-ID: <20230714100424.29798-3-aweber.kernel@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230714100424.29798-1-aweber.kernel@gmail.com> References: <20230714100424.29798-1-aweber.kernel@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771391300082280674 X-GMAIL-MSGID: 1771391300082280674 MELFAS MMS114 and similar touchscreens have support for touch keys. Enable support of them in the driver. The keycodes to emit can be controlled by the linux,keycodes DT property. Sidenote - the MAX_TOUCHKEYS value is set to 15, as that's the maximum value that the ID field can contain. I don't have access to any datasheets that could confirm or deny whether this is accurate. Most downstream drivers I've been able to find only use up to 2 keys (though I did find a driver that mentioned up to 4, but only 2 were used). They don't have any checks for a maximum keycode value, it is just extracted from the ID bits (0xf mask). The drivers I've been able to find also don't use touch ID 0; I assume that it is never used, so the keycodes provided in the DT start from touch ID 1. I suppose this is in-line with the regular behavior for touch IDs in touchscreen events, as there the provided touch ID is always lowered by 1, which would cause an overflow if it was 0... Just in case, we quietly return if the touch ID is set to 0 here. The implementation of the linux,keycodes property handling code was adapted from the msg2638 driver. Signed-off-by: Artur Weber --- drivers/input/touchscreen/mms114.c | 88 +++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c index ac12494c7930..14c0514a21ff 100644 --- a/drivers/input/touchscreen/mms114.c +++ b/drivers/input/touchscreen/mms114.c @@ -43,6 +43,7 @@ /* Touchscreen absolute values */ #define MMS114_MAX_AREA 0xff +#define MMS114_MAX_TOUCHKEYS 15 #define MMS114_MAX_TOUCH 10 #define MMS114_EVENT_SIZE 8 #define MMS136_EVENT_SIZE 6 @@ -70,6 +71,9 @@ struct mms114_data { unsigned int contact_threshold; unsigned int moving_threshold; + u32 keycodes[MMS114_MAX_TOUCHKEYS]; + int num_keycodes; + /* Use cache data for mode control register(write only) */ u8 cache_mode_control; }; @@ -167,11 +171,6 @@ static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *tou return; } - if (touch->type != MMS114_TYPE_TOUCHSCREEN) { - dev_err(&client->dev, "Wrong touch type (%d)\n", touch->type); - return; - } - id = touch->id - 1; x = touch->x_lo | touch->x_hi << 8; y = touch->y_lo | touch->y_hi << 8; @@ -191,9 +190,33 @@ static void mms114_process_mt(struct mms114_data *data, struct mms114_touch *tou } } +static void mms114_process_touchkey(struct mms114_data *data, + struct mms114_touch *touch) +{ + struct i2c_client *client = data->client; + struct input_dev *input_dev = data->input_dev; + unsigned int keycode_id; + + if (touch->id == 0) + return; + + if (touch->id > data->num_keycodes) { + dev_err(&client->dev, "Wrong touch id for touchkey (%d)\n", + touch->id); + return; + } + + keycode_id = touch->id - 1; + dev_dbg(&client->dev, "keycode id: %d, pressed: %d\n", keycode_id, + touch->pressed); + + input_report_key(input_dev, data->keycodes[keycode_id], touch->pressed); +} + static irqreturn_t mms114_interrupt(int irq, void *dev_id) { struct mms114_data *data = dev_id; + struct i2c_client *client = data->client; struct input_dev *input_dev = data->input_dev; struct mms114_touch touch[MMS114_MAX_TOUCH]; int packet_size; @@ -223,8 +246,22 @@ static irqreturn_t mms114_interrupt(int irq, void *dev_id) if (error < 0) goto out; - for (index = 0; index < touch_size; index++) - mms114_process_mt(data, touch + index); + for (index = 0; index < touch_size; index++) { + switch (touch[index].type) { + case MMS114_TYPE_TOUCHSCREEN: + mms114_process_mt(data, touch + index); + break; + + case MMS114_TYPE_TOUCHKEY: + mms114_process_touchkey(data, touch + index); + break; + + default: + dev_err(&client->dev, "Wrong touch type (%d)\n", + touch[index].type); + break; + } + } input_mt_report_pointer_emulation(data->input_dev, true); input_sync(data->input_dev); @@ -446,6 +483,7 @@ static int mms114_probe(struct i2c_client *client) struct input_dev *input_dev; const void *match_data; int error; + int i; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "Not supported I2C adapter\n"); @@ -469,6 +507,42 @@ static int mms114_probe(struct i2c_client *client) data->type = (enum mms_type)match_data; + data->num_keycodes = device_property_count_u32(&client->dev, + "linux,keycodes"); + if (data->num_keycodes == -EINVAL) { + data->num_keycodes = 0; + } else if (data->num_keycodes < 0) { + dev_err(&client->dev, + "Unable to parse linux,keycodes property: %d\n", + data->num_keycodes); + return data->num_keycodes; + } else if (data->num_keycodes > MMS114_MAX_TOUCHKEYS) { + dev_warn(&client->dev, + "Found %d linux,keycodes but max is %zd, ignoring the rest\n", + data->num_keycodes, MMS114_MAX_TOUCHKEYS); + data->num_keycodes = MMS114_MAX_TOUCHKEYS; + } + + if (data->num_keycodes > 0) { + error = device_property_read_u32_array(&client->dev, + "linux,keycodes", + data->keycodes, + data->num_keycodes); + if (error) { + dev_err(&client->dev, + "Unable to read linux,keycodes values: %d\n", + error); + return error; + } + + input_dev->keycode = data->keycodes; + input_dev->keycodemax = data->num_keycodes; + input_dev->keycodesize = sizeof(data->keycodes[0]); + for (i = 0; i < data->num_keycodes; i++) + input_set_capability(input_dev, + EV_KEY, data->keycodes[i]); + } + input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_X); input_set_capability(input_dev, EV_ABS, ABS_MT_POSITION_Y); input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 255, 0, 0);