From patchwork Thu Jun 12 19:41:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 896495 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0804D2D540C; Thu, 12 Jun 2025 19:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757314; cv=none; b=DNzX46wjiARJWtLYfPUBcYcFDudUjQ6goDvk6/hBIlC5AiHLgPpIXjAmfcIQxzJZzGxFzcxQks33bIyUCxLB/kINckYxjUa/t/LE2hQYXI5Aj8OxZ6Svg9+1HTX+kmR2RYB5l55ner/1TWAjeS40wkjPUEscqVNtfoYTm/pN4Pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757314; c=relaxed/simple; bh=kb6nDF3XHpH944ApFwN4563r+bV5OeHn65M+rhj/Ct8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dgr/j+D37DO5ssD4eZzSycEionJB/btdJeqtTfQHwRS8e+AaMUPshcs0EEY9lXltj+IbvUenA0B7tF0AxXzJs1eIAtdJxD/31pCcFL7jHOdJySEGNrgriUky3Rkw4tKSJ1jMEHamvTZinNl//kFDQ/i7JzBnQWEroQ7nQ0PKFH8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=NcWu2j0e; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="NcWu2j0e" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6D0562600D; Thu, 12 Jun 2025 21:41:51 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id XrQMMlhQz_Af; Thu, 12 Jun 2025 21:41:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1749757310; bh=kb6nDF3XHpH944ApFwN4563r+bV5OeHn65M+rhj/Ct8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=NcWu2j0evKneiYO9xqXQYq2cgY0d6jMWhdyhz3VGtM+pUxzuUdRpIbWXnspaLKBG/ VTouQrpwc5caMDL2KL43s4adFfBZBT3MsJotvlLbGh1OoBwB/9ykO1IEr/88MSpDd4 P+dp59nPuYVOo7OaVjSG/wmpnRmotDu9R9FrCO0I0ATq5wcalv52SjLhyPHWsky7iL PYKYJxJIILB/zBQEN3vbxF+jlPt9bswZjC9XM72YsZkRwteNcu1ZbNtetbKh9Yw+hF ORDnPnBwAD8qv6hpoCS9OPpCx+MZO0G1cWCqXUJQgHCV5mNcXPR6s+Rzy70ZhoRfKI mncE0x1M2va2A== From: Kaustabh Chakraborty Date: Fri, 13 Jun 2025 01:11:33 +0530 Subject: [PATCH RFC v2 1/5] dt-bindings: input: melfas-mip4: convert to dtschema Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250613-mip4-touchkey-v2-1-9bbbe14c016d@disroot.org> References: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> In-Reply-To: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1749757299; l=2902; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=kb6nDF3XHpH944ApFwN4563r+bV5OeHn65M+rhj/Ct8=; b=3Crb8yAOhMTHaMISmdk4bGxVqp7w7GjrNq1Emme+CldZsfr9ZAW/T3oJeNSNhS89xDb1eaIoR vogPzSq5ja5A/N4rkZbpcbJewxl4q9nQLLQvuHvtlRTOHFtAL5Nlq+7 X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Port the documentation file melfas_mip4.txt over to melfas,mip4_ts.yaml. Signed-off-by: Kaustabh Chakraborty --- .../bindings/input/touchscreen/melfas,mip4_ts.yaml | 55 ++++++++++++++++++++++ .../bindings/input/touchscreen/melfas_mip4.txt | 20 -------- 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5532d46f85a235127e2b3513846259aa7372bda5 --- /dev/null +++ b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/input/touchscreen/melfas,mip4_ts.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MELFAS MIP4 touchscreen controller + +maintainers: + - Sangwon Jee + +allOf: + - $ref: touchscreen.yaml# + +properties: + $nodename: + pattern: "^touchscreen(@.*)?$" + + compatible: + const: melfas,mip4_ts + + reg: + enum: [ 0x48, 0x34 ] + description: I2C slave address of the chip + + interrupts: + maxItems: 1 + + ce-gpios: + description: GPIO connected to the CE (chip enable) pin of the chip + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + touchscreen@48 { + compatible = "melfas,mip4_ts"; + reg = <0x48>; + interrupt-parent = <&gpio>; + interrupts = <0 IRQ_TYPE_EDGE_FALLING>; + ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + }; + }; + +... diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt b/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt deleted file mode 100644 index b2ab5498e51900e887fab4d9b5239cccccec2ea9..0000000000000000000000000000000000000000 --- a/Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt +++ /dev/null @@ -1,20 +0,0 @@ -* MELFAS MIP4 Touchscreen - -Required properties: -- compatible: must be "melfas,mip4_ts" -- reg: I2C slave address of the chip (0x48 or 0x34) -- interrupts: interrupt to which the chip is connected - -Optional properties: -- ce-gpios: GPIO connected to the CE (chip enable) pin of the chip - -Example: - i2c@00000000 { - touchscreen: melfas_mip4@48 { - compatible = "melfas,mip4_ts"; - reg = <0x48>; - interrupt-parent = <&gpio>; - interrupts = <0 IRQ_TYPE_EDGE_FALLING>; - ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; - }; - }; From patchwork Thu Jun 12 19:41:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 896095 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE5AB2D4B4B; Thu, 12 Jun 2025 19:41:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757321; cv=none; b=EzTkx42IPc0HiBGFgn+0PP6Vm/UmnChw5Z3sQM29WHAwrLYU07A8dUVLwU2wTBvHNhq29uZGWXKIw0Mbed5mCVPgGmRthN2FH9YbWAn1sUxGplW+UrgU2wOwsQs+SuKmKemjvxOH9QRE3qnVbeEu0PLCe4QEscAq1FxD7Zekf48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757321; c=relaxed/simple; bh=/gTnO/1RuBmF8+C1719L1QDUtsDQga6wf1RfvP9AhSA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=k2LmWw3eWGPkqq36mYpUHJQPYU8mc8P9AVdLXPeJX0lIzfgIgHHpxhJo+T5z3cf0oq3mkbOJc/tZjDe4l8AedVoKcbcI9kE7hEx8xOue0qpD6uSKklxPGlNNNmwrO+qhQocHjLzhXRsiIo69UFOfcN9nI7GnoXIzWTFi3Cszy7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=ZGUhFo+q; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="ZGUhFo+q" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 66BC82600F; Thu, 12 Jun 2025 21:41:58 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5bbsKMTDjPi0; Thu, 12 Jun 2025 21:41:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1749757316; bh=/gTnO/1RuBmF8+C1719L1QDUtsDQga6wf1RfvP9AhSA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ZGUhFo+q/BFGAu5M7Rm+qG6vvXM2TU2xlNU3DVi0S24W86l0jyXzaQUdys5Teb4tf it06kj89xWrSSTPIM1zRxr9IbqbNdS/+KAPWv4MjFDaQRsYy5HT/lF+mbWJ+IO960H ga9YMIQKLkrPeJ98Y6MAZEWVYghkGSzcj4bW5HF86FavZPwyxiiUfGXSkpfVftYPgb /BkgjjGWhSe+CUW+e3a64aoTbT5CsW5jOFczvb7WE7CSfynpD3cfzN0nMIKTeyWpMx CRN02Clwf11a2eyoqYZF73NGbcWLUqIhkfz4VYKwVPXjf7jGaoSDTZwphr2VFgKanw C3hPjUcoHooPg== From: Kaustabh Chakraborty Date: Fri, 13 Jun 2025 01:11:34 +0530 Subject: [PATCH RFC v2 2/5] dt-bindings: input: melfas-mip4: document linux,keycodes property Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250613-mip4-touchkey-v2-2-9bbbe14c016d@disroot.org> References: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> In-Reply-To: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1749757299; l=1291; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=/gTnO/1RuBmF8+C1719L1QDUtsDQga6wf1RfvP9AhSA=; b=IKwbFJtxDsvMPZQxScvOxo8vbtbodGI4CS/Pn7XjTQzOBjB/DJNvaMF6kwdBhQ5fYhf+GdNwp eRulrSHmMpoDx8Cc8v5Uu7jvL2LP2FNXdhEynb9uxIKvShtP/EqXqPt X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Document the linux,keycodes property. The property values are key codes which are used in input key events generated by the touchkey device. Signed-off-by: Kaustabh Chakraborty --- .../devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml index 5532d46f85a235127e2b3513846259aa7372bda5..6d5e0f4b062f44f83484eccd82353d6f150f9d8f 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/melfas,mip4_ts.yaml @@ -29,6 +29,11 @@ properties: ce-gpios: description: GPIO connected to the CE (chip enable) pin of the chip + linux,keycodes: + description: Array of keycodes to be reported by touchkeys + minItems: 1 + maxItems: 4 + additionalProperties: false required: @@ -49,6 +54,7 @@ examples: interrupt-parent = <&gpio>; interrupts = <0 IRQ_TYPE_EDGE_FALLING>; ce-gpios = <&gpio 0 GPIO_ACTIVE_HIGH>; + linux,keycodes = , ; }; }; From patchwork Thu Jun 12 19:41:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 896494 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DBE72D4B4B; Thu, 12 Jun 2025 19:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757327; cv=none; b=LrMEk8ZoBOHgGVnIkOFasWlhqLB579iXgky+Vn7ihY3xCUhDX5F+XK49b3+fbxAimCAKIIOPqTYTPV0qDQ2I8qUIW49wf9SZT4tS457DXLbS88Kpbgs0BLS+zlV5Dl1NoV6JaJw1vYFImb2qRttosVvzW1IDG+MW4qHpPZ5pSeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757327; c=relaxed/simple; bh=fg5AoTsDiUevWYSsxPAW01tdMPFTPzlekM5HpegsD7U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uNCZwnMM1Ds8CB8M0Hep9JLEn65ywWz0ed1CVIer++s9QY+qXVjz/zN+bKtGovsLmA2RGUHBHomEGqa//PgCm3B1e4umgD8Zv0vvlDOqslr72bOTr+HBjPy4wMUsYSdpBv/yr5osc3Zf+Cy0NDFY9PMrjk8cerDWGP9hVyR5OkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=CN6yUXBv; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="CN6yUXBv" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id DCFA42599D; Thu, 12 Jun 2025 21:42:03 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Op5vm5NIpRe3; Thu, 12 Jun 2025 21:42:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1749757322; bh=fg5AoTsDiUevWYSsxPAW01tdMPFTPzlekM5HpegsD7U=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CN6yUXBvFlqRxKpIAbU1qFojDvr0e+8TXIV6Aa7FSPAlMezflk28ZTO3IxkSPeZEe yYQPU4kPjKFsne4ffoLo2Hv+Q/efWTT1x96PotDy2iG74fIzY3i1mspCrHneuq4T1I /J4lkje3O1B2aP9VRVG3+wmdq/VGU/Il+RrpUnkRKjKgfcO40ZCqTAnP859May6Tyc p3SunbNcJzaJi1ITbC+6pLiY7ePbgHVjsl2R+qZUawbntK4APaOKEtPqfjxdWxvJ9w lyGLFE5MkAwJ9K+7MqF9AfIUQRuz2rRq3tAdwf1gnb5CFX8R8uHTIuzwSyaoO5dWLW d8F3Ay+5j0euA== From: Kaustabh Chakraborty Date: Fri, 13 Jun 2025 01:11:35 +0530 Subject: [PATCH RFC v2 3/5] Input: melfas-mip4 - add support for touchkey input events Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250613-mip4-touchkey-v2-3-9bbbe14c016d@disroot.org> References: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> In-Reply-To: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1749757299; l=3116; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=fg5AoTsDiUevWYSsxPAW01tdMPFTPzlekM5HpegsD7U=; b=n9c7NV53Qs/O2OG5V9FEfY12MmwA79kF1CRjpGS+MEDKLnKkeVNZIGiSvrP3594oVDr0uj+Db Y1usLjH0kKkCszzQRXF+xjuKNXvouOp69r/jUViSOgU4z1b2Bu64k5K X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= The MIP4 protocol are supposed to support touchscreens, touchkeys, and combo-devices. The driver handles touchscreen events, but touchkey events are unimplemented. Implement them. If compiled with devicetree support, the driver attempts to retrieve keycodes from a property named "linux,keycodes". Signed-off-by: Kaustabh Chakraborty --- drivers/input/touchscreen/melfas_mip4.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index a6946e3d8376d7e9b4c26f4194409e0ba78bb075..061ac353bc7a2e28f17581411af81f35c89733a1 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -169,7 +169,7 @@ struct mip4_ts { unsigned int event_format; unsigned int key_num; - unsigned short key_code[MIP4_MAX_KEYS]; + unsigned int key_code[MIP4_MAX_KEYS]; bool wake_irq_enabled; @@ -337,8 +337,13 @@ static int mip4_query_device(struct mip4_ts *ts) ts->ppm_x, ts->ppm_y); /* Key ts */ - if (ts->node_key > 0) + if (ts->node_key > MIP4_MAX_KEYS) { + dev_warn(&ts->client->dev, + "Too many keys (%u) found\n", ts->node_key); + ts->key_num = MIP4_MAX_KEYS; + } else { ts->key_num = ts->node_key; + } } /* Protocol */ @@ -1080,6 +1085,7 @@ static int mip4_flash_fw(struct mip4_ts *ts, const u8 *fw_data, u32 fw_size, u32 fw_offset) { struct i2c_client *client = ts->client; + unsigned int i; int offset; u16 buf_addr; int error, error2; @@ -1149,6 +1155,11 @@ static int mip4_flash_fw(struct mip4_ts *ts, input_abs_set_res(ts->input, ABS_X, ts->ppm_x); input_abs_set_res(ts->input, ABS_Y, ts->ppm_y); + for (i = 0; i < ts->key_num; i++) { + if (ts->key_code[i]) + input_set_capability(ts->input, EV_KEY, ts->key_code[i]); + } + return error ? error : 0; } @@ -1425,6 +1436,7 @@ static int mip4_probe(struct i2c_client *client) { struct mip4_ts *ts; struct input_dev *input; + unsigned int i; int error; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { @@ -1471,6 +1483,17 @@ static int mip4_probe(struct i2c_client *client) input_set_drvdata(input, ts); +#ifdef CONFIG_OF + error = of_property_read_u32_array(client->dev.of_node, "linux,keycodes", + ts->key_code, ts->key_num); + if (error && ts->key_num) { + dev_warn(&client->dev, + "Failed to get codes for %u supported keys", ts->key_num); + /* Disable touchkey support */ + ts->key_num = 0; + } +#endif + input->keycode = ts->key_code; input->keycodesize = sizeof(*ts->key_code); input->keycodemax = ts->key_num; @@ -1491,6 +1514,11 @@ static int mip4_probe(struct i2c_client *client) if (error) return error; + for (i = 0; i < ts->key_num; i++) { + if (ts->key_code[i]) + input_set_capability(input, EV_KEY, ts->key_code[i]); + } + i2c_set_clientdata(client, ts); error = devm_request_threaded_irq(&client->dev, client->irq, From patchwork Thu Jun 12 19:41:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 896094 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 276DC2D5417; Thu, 12 Jun 2025 19:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757332; cv=none; b=OPUv9u2FGpzQ1l79FHcV7yKxVUOje3S5jYN/JJx5j+XDT0xf0EAxzH7na6t3tuHGzlYM+Frr93JhkQZ+F9Yya5GZEOcWuVAZwbhGa2GSlmw6JfNMJhxmPBf0QSMfB1tUtyiiNC5MlaWG0Yo8PAS6LDdyx04QbkQTxj/BeHeaZ+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757332; c=relaxed/simple; bh=db09hgbzvuUJ1yzYHRq+CAMm77k09qcfo3UfxtjsWeY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cwKb9/Oq/qgCoCwu9JBkzgeHcIaZzNLLTT4sT5WJh58e/dwvq1EPU0TxE5quoLXiZN4FmARYO85fxDkjEHNM7yhinj6HrIc0mKS5ByqmpJnM+5Nle85uSp9979hd0dXpQpqbhELeOa8Enx4ux9DdO8UaxK87L3yqLgRot1rmGWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=Loqs1Gre; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="Loqs1Gre" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id A846226024; Thu, 12 Jun 2025 21:42:09 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id ixglB28ds2Vk; Thu, 12 Jun 2025 21:42:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1749757328; bh=db09hgbzvuUJ1yzYHRq+CAMm77k09qcfo3UfxtjsWeY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Loqs1Gre7sEBdRavftFxphL4OSPxllLVpJSzI4AY7Kxv+u9CIPbH8YwuBKfVnV1Ww xE3xbqv4xZrbOLr2OFocWCCR02UYnNL5Z5SGNM1uA+xW2ZZ+FfDV2HoVPF8EUBxGS0 uDiGZ+UDFo1g55Z8CiMA0zAy33vJIiYscZgy7/stcKBM3COcjKKIk+nUFXt2KUe7ZB Fl4OL4w8LzEBIOI4XBmgco52PE/8as+VAUmMqwX0D2v2MZCv7Dk8YhF9+p1rCdmUMR DGXoQLb8hkvIc2r1UO1jpFzD6gN4xLpv6Y3cvg7UBaSw1YNo+46p6mJGAlnl12q0lD gGIDSL2gT2EqQ== From: Kaustabh Chakraborty Date: Fri, 13 Jun 2025 01:11:36 +0530 Subject: [PATCH RFC v2 4/5] Input: melfas-mip4 - initialize touch events only if the device is a touchscreen Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250613-mip4-touchkey-v2-4-9bbbe14c016d@disroot.org> References: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> In-Reply-To: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1749757299; l=3948; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=db09hgbzvuUJ1yzYHRq+CAMm77k09qcfo3UfxtjsWeY=; b=jVvhya2K7et4gPQ1D2SoHMH75rK0PpUX3kgiS4WERstxyknOfOYKwRlEVR1eXLqGD45xgzuwl zHBYeTiz2yHDxDiH/TJ3dbLBacpoxqguVQuyXcilyuLYDZCErIvV9h1 X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Certain MIP4 devices report zero values when enquired for its touchscreen dimensions (MIP4_R1_INFO_RESOLUTION_X and MIP4_R1_INFO_RESOLUTION_Y), which is indicative of the fact that those devices are not touchscreens. While registering for touch events for the device, always check - and proceed - only if the device reports a non-zero resolution. Signed-off-by: Kaustabh Chakraborty --- drivers/input/touchscreen/melfas_mip4.c | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 061ac353bc7a2e28f17581411af81f35c89733a1..57b657694a420220be135c2f78d3ddad3ef6f520 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -1146,14 +1146,16 @@ static int mip4_flash_fw(struct mip4_ts *ts, mip4_query_device(ts); /* Refresh device parameters */ - input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); - input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); - input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0); - input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0); - input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); - input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); - input_abs_set_res(ts->input, ABS_X, ts->ppm_x); - input_abs_set_res(ts->input, ABS_Y, ts->ppm_y); + if (ts->max_x && ts->max_y) { + input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); + input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); + input_set_abs_params(ts->input, ABS_X, 0, ts->max_x, 0, 0); + input_set_abs_params(ts->input, ABS_Y, 0, ts->max_y, 0, 0); + input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); + input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); + input_abs_set_res(ts->input, ABS_X, ts->ppm_x); + input_abs_set_res(ts->input, ABS_Y, ts->ppm_y); + } for (i = 0; i < ts->key_num; i++) { if (ts->key_code[i]) @@ -1498,21 +1500,23 @@ static int mip4_probe(struct i2c_client *client) input->keycodesize = sizeof(*ts->key_code); input->keycodemax = ts->key_num; - input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); - input_set_abs_params(input, ABS_MT_PRESSURE, - MIP4_PRESSURE_MIN, MIP4_PRESSURE_MAX, 0, 0); - input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, - MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0); - input_set_abs_params(input, ABS_MT_TOUCH_MINOR, - MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0); - input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); - input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); - - error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT); - if (error) - return error; + if (ts->max_x && ts->max_y) { + input_set_abs_params(input, ABS_MT_TOOL_TYPE, 0, MT_TOOL_PALM, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_X, 0, ts->max_x, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, ts->max_y, 0, 0); + input_set_abs_params(input, ABS_MT_PRESSURE, + MIP4_PRESSURE_MIN, MIP4_PRESSURE_MAX, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, + MIP4_TOUCH_MAJOR_MIN, MIP4_TOUCH_MAJOR_MAX, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MINOR, + MIP4_TOUCH_MINOR_MIN, MIP4_TOUCH_MINOR_MAX, 0, 0); + input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->ppm_x); + input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->ppm_y); + + error = input_mt_init_slots(input, MIP4_MAX_FINGERS, INPUT_MT_DIRECT); + if (error) + return error; + } for (i = 0; i < ts->key_num; i++) { if (ts->key_code[i]) From patchwork Thu Jun 12 19:41:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaustabh Chakraborty X-Patchwork-Id: 896493 Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58BB82D5417; Thu, 12 Jun 2025 19:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757337; cv=none; b=Zhj+S/p1RSMT2uFuhfkatqZ4yYk2WJwUv23AYC0U+YM3FuXFhBE+WmrLfqEhdM551yOYRRmTWBuAlLegrI7hdDfzFDYJHhIzVzeco4SZVL/MreZPGX0iADQIT0hARWY9tgiVopjMaxKozZQ9T1F5RdQNA98Jv3NQKuZbN9TxO/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749757337; c=relaxed/simple; bh=5Ehg8aQGjsmQjFGFetFWzPdWaPT+YpJgL6j24A8jE6I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kQl8o+0iYoS3gevM2HPxNbGs2h+RB2qu+2o/ZwxVp1/1jIsE2H0Bbuy6/U1rXRuKHzK1mo9bxsHxJbpCKbqMMj+/GcS/7Sb4io1xOzM/HB9klDvASLiQdtQwhfgKZHivzmbYsQ5PnrmDLRQ+XTEgAxFDWF1FVmoSm+qJQvq9De8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org; spf=pass smtp.mailfrom=disroot.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b=UEUzuLgu; arc=none smtp.client-ip=178.21.23.139 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=disroot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=disroot.org header.i=@disroot.org header.b="UEUzuLgu" Received: from mail01.disroot.lan (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 22A4720A17; Thu, 12 Jun 2025 21:42:15 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id edM3XNj7nGm1; Thu, 12 Jun 2025 21:42:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1749757334; bh=5Ehg8aQGjsmQjFGFetFWzPdWaPT+YpJgL6j24A8jE6I=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=UEUzuLgu4Dchtus7KQuGiCqW0ifWE2FV6BsPy6we/R3AYCH6VDLdh6hgLrL/dUwJ3 /Gmvn5PJ11JA1Dewu/58xJ/AajK2gvVbU7CTHM10zsLWxm672VI2sBDHJh3Z/frdZg gaRBqWwB41vQ+5BYytzQ4c7vWwkZjHnywP1QOG0j0f1HKK/GF+WaJlwjfM5f+HxqTe k/Hnlcxb1j5NywZc3+CZgSenReVF1w/vYKouSN3A99Eh5PNc/EJN0sfVKRG4XlLGg+ nXthXHh/x9IHjwuDbYM/DEkMmCmamJd0SEAd2hliLqTOncevX9zgHN/DtqHIVV7bl6 RKsdjTXwd/+TA== From: Kaustabh Chakraborty Date: Fri, 13 Jun 2025 01:11:37 +0530 Subject: [PATCH RFC v2 5/5] Input: melfas-mip4 - add support for event formats 4 and 9 Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250613-mip4-touchkey-v2-5-9bbbe14c016d@disroot.org> References: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> In-Reply-To: <20250613-mip4-touchkey-v2-0-9bbbe14c016d@disroot.org> To: Sangwon Jee , Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kaustabh Chakraborty X-Developer-Signature: v=1; a=ed25519-sha256; t=1749757299; l=1820; i=kauschluss@disroot.org; s=20250202; h=from:subject:message-id; bh=5Ehg8aQGjsmQjFGFetFWzPdWaPT+YpJgL6j24A8jE6I=; b=yu443ThPP2LFhax3dbFRPTjpQ03zQG2ZGFPbLM8nL8IHNWVWe5Bh/Avtg8HotqxsHY1aIG3hC UpWAdL5Kz9eAKeVZ1Fvy90cA3SqG9f1DtC7NYVr5TnBrY3dTrjUhPVG X-Developer-Key: i=kauschluss@disroot.org; a=ed25519; pk=h2xeR+V2I1+GrfDPAhZa3M+NWA0Cnbdkkq1bH3ct1hE= Valid event formats in this driver is limited to 0, 1, and 3. These are event formats for MIP4 touchscreen devices. Add support for event formats 4 and 9, which belong to touchkey devices. While at it, simplify the logic in function mip4_query_device where valid event formats are checked. Use a human-readable switch-case block instead of an if statement with obscure conditions. Signed-off-by: Kaustabh Chakraborty --- drivers/input/touchscreen/melfas_mip4.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c index 57b657694a420220be135c2f78d3ddad3ef6f520..95a78c86873355d0a8e0207b1eb4a8408f55cee4 100644 --- a/drivers/input/touchscreen/melfas_mip4.c +++ b/drivers/input/touchscreen/melfas_mip4.c @@ -360,9 +360,19 @@ static int mip4_query_device(struct mip4_ts *ts) dev_dbg(&ts->client->dev, "event_format: %d, event_size: %d\n", ts->event_format, ts->event_size); - if (ts->event_format == 2 || ts->event_format > 3) + switch (ts->event_format) { + /* Touchscreens */ + case 0: + case 1: + case 3: + /* Touchkeys */ + case 4: + case 9: + break; + default: dev_warn(&ts->client->dev, "Unknown event format %d\n", ts->event_format); + } } return 0; @@ -440,6 +450,8 @@ static void mip4_report_keys(struct mip4_ts *ts, u8 *packet) switch (ts->event_format) { case 0: case 1: + case 4: + case 9: key = packet[0] & 0x0F; down = packet[0] & 0x80; break; @@ -552,6 +564,8 @@ static int mip4_handle_packet(struct mip4_ts *ts, u8 *packet) switch (ts->event_format) { case 0: case 1: + case 4: + case 9: type = (packet[0] & 0x40) >> 6; break;