From patchwork Wed Oct 16 04:02:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 835970 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2099.outbound.protection.outlook.com [40.107.104.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C93B8290F; Wed, 16 Oct 2024 04:02:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.99 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051374; cv=fail; b=MUAQuWw0o7N1QQZw4SvR8Zw5kjRiu8WrHHBG7jKTjG6x8gM8VzuXEl300bSEkAnliZZwZKeCDuXzerHpyHB0qlRQSWZPicGor/HskQ2gNH61q1rAwZVv9s0q5gUvM0i5IlPKe8z8w9H5BL03eumC6Q9Nu0/BYpnj7IgsLJTyUj0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051374; c=relaxed/simple; bh=yQHrhy/cLj8m5cwZywJZimlUvuzO6TSYXrE1Tzqpzjs=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=eFOHrxsKyS3GX5zauX/WzM/T1Wbcdcfm/26Fg0WMi+rHMig1uQGDQ20lv/t9mvRdkhESUlKlUsHX0omt8XfNyJsRXpCp4rkzUTO2b47TCQXqY6hn8w4GiB/4TJUk3SlpRm58f9ZJLmW/dTEiWXaOWkG28qNz7rHxXS9r3gYLWH4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=OqLP5Smh; arc=fail smtp.client-ip=40.107.104.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="OqLP5Smh" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=C6uBeA3zjBFn7h+4f3Ky1G7Xpa0JGLu5RC5YwIvSVUTZG4qAbBtlyGd1W4Qz4grPGwHy8HnDXdah9XBIyFEZSr8KVxh3vBZqmIadoxiHHDzaAVJyueW5j/OVpKIVuYTbpXk99m8YN0P1j1TdUgcPDaYKSfMSwPulfdSvhnSQSn1XBF7rW9UOSE0uCDwjUInkW5bnPkm8FFjVbyihUXM9vr9vjvxRbBZivAi79ee0ad3k0H4VkkdPk6eMae+xBjvbhdvvwni0cTcgTYWuqMEy9W7TjnOV5MtfwV0Jkt9B6iKrhiffnW76rOKf8fbqxxU9RQ8Taun24ppZrGBpVWz6XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XBaP2zOuwSQ9ixzTarI2EZ4kIOrr2eYt2I5CT+KpXPM=; b=Qwo1Qq5ak25Texp1dgzN1Y4hBEyKvtZtIAnGmQaJBhTqWGRP1YWYfFPxA1uWBphe12xKhF6qjedrh9O9ouOgaFnTtfjVqUUF0xVRfUICKJjBllmkme6dEuJNPRqU3g0AK8EoAYVf8kL1gLrM40bP46fXIFTWVIf9pcFBPW8+LakMdceRUqycDpCVOI55Lnn5uvexs8CA0h5CaamOQp9iJy4DfV+aLUHIn5+hKw3RCCjIECOtgYJjXtvEN99Z8scXwwMqWXfhnlSgRVwr9rIYDZLoow0b8nPwiOT86+fbOaSf8wLSNxy/wd6+rQObTdnDrO1YzXvPDDja648vmI/bYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XBaP2zOuwSQ9ixzTarI2EZ4kIOrr2eYt2I5CT+KpXPM=; b=OqLP5Smhf4BfVBoAyM5r6NtYXK2aD9J2up+Ww7earZRCMJNbS/OeCyrJaX5rbhW2gvS2YQh2JHVjYTyfpFH1E4OxGKWhRm5zaBUTKBXcj1AeGn5sWJFTLZwhkbEskenuTR+xAy0xSHfEowmbI4cpeoeL5ZnmILuLyVF1l8bIE2U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) by PAWPR08MB10183.eurprd08.prod.outlook.com (2603:10a6:102:368::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 04:02:50 +0000 Received: from DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4]) by DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4%6]) with mapi id 15.20.8048.020; Wed, 16 Oct 2024 04:02:50 +0000 From: Javier Carrasco Date: Wed, 16 Oct 2024 06:02:40 +0200 Subject: [PATCH v11 1/4] dt-bindings: touchscreen: add touch-overlay property Message-Id: <20241016-feature-ts_virtobj_patch-v11-1-b292a1bbb0a1@wolfvision.net> References: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> In-Reply-To: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bastian Hecht , Michael Riesch Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , Jeff LaBundy X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729051368; l=7148; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=yQHrhy/cLj8m5cwZywJZimlUvuzO6TSYXrE1Tzqpzjs=; b=ob0lSkhZOvOSkCPz6IQbJspuk7I1NAkYwGEAwH1zMNvCCDEakBcLwBo9N+9NJEL7T0AJRWnnK i7kVS6mjte1CUulxz/0avGy4PUtA0uK0bO2kkTFwlI2Yv7vp12yeYDZ X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR07CA0154.eurprd07.prod.outlook.com (2603:10a6:802:16::41) To DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR08MB9190:EE_|PAWPR08MB10183:EE_ X-MS-Office365-Filtering-Correlation-Id: c1578ee6-f8df-4b7c-007c-08dced9766c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?VzXHuuNGn+I/Wk3ldXelnWSKpYh/AVr?= =?utf-8?q?EQTbzG7MFvcarlrbAF91DdUSLDc9WUkI7+rh85Hsi1hARqTXlHbyEzv5z7T5ysDlg?= =?utf-8?q?IdEc/Akvv8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iCzbh4l24ZZKilrQ6Z2V73JyQEFhjbrUN1?= =?utf-8?q?BaoAcbjl1Fj82ZbY8VfoWayLkAviJe/CYPlHr4Mm/ex8Ryop8FIKTZq7/Ab8GNZ+o?= =?utf-8?q?aBSVzjFjiBqIEudDqRXmuSN9riTD/TyaIjtFWTahZX7kOGCaTm4fmc+D1n2/cAv8J?= =?utf-8?q?IUvr1C55Rxz5oXbUltjV6gyqzYtkwYcNdP37/bo+ND8Zd/j38w3oT6eale9psLawR?= =?utf-8?q?CVDj4bpjKaTrDVtE9fydOHJ2M8dbBdfb7PA9zuzQsiZnf4YKenZ7sKVvxaGzne+jZ?= =?utf-8?q?YzI9WI4o8UhyJCRz2ooW8XRYsRDmHpY0PXw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB4PR08MB9190.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?DyxyoKdrGQQnH9Hie7cHz9baftP2?= =?utf-8?q?w02VG0RpKTDrjOn7Ag0lC4jGjqpTzc8WV5KbJpa/AnJDX03ErX18Q/OI/xtvt4KD+?= =?utf-8?q?GB7TafZCwUQp4kQ0SH2F4bh4gkurm0hpDRdgWbSk20ka+42+VQfxtM45fZn09t778?= =?utf-8?q?4OVwFNYfu5mhrGMb6iJNeYdqDVxchR+F3h1KnV1SVQkYBmWZhUplql+eGCyWMIPuY?= =?utf-8?q?c4Nu4pjqSL1F9n0eo4FqF6I/+mpYwDy1SIzsLY6pM/wwv6F/LX1xOB3zE0/vyaIka?= =?utf-8?q?3ehslmuQ/V/CApwEWrSMuRTiS6ninBkZiWR4tAXCJbQCWTw/apMFoIlT6YkLEXOi5?= =?utf-8?q?Goy9iVw9j4jRAs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bmIoJz2D9vxreTCxxzG/Mm+gcxLRGjmoMYHMciUQTGAIp?= =?utf-8?q?yD6RtAk79CE0os4jXGsROjbHRuFjcTuJwJtSn6hikAmyulN9byX8fuXwLLRsJ8RNU?= =?utf-8?q?iBMu6RhxmwJVscUrmbOvwZIB8cmF26LGsQAWDzJ5rXEL1WnMyXTRtXKtsb2IS+0LK?= =?utf-8?q?cIrBScBkV/KfhgUpJ9bzZo9kjG1k+goqAZ9ZoM+xqaupOY4jc0UZXLzakcgjjjN3I?= =?utf-8?q?UeVIYt9rKXM4l+oevSjR03qqniJVMjh4xoFDlRwOKM2u20p66J2+RxJaiYpP6WDWh?= =?utf-8?q?hBwJAsT4SfYWvMTF7ifa6D5/JOhqc6DjvaCYUZOIpsI2eFfWggNe298=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: c1578ee6-f8df-4b7c-007c-08dced9766c5 X-MS-Exchange-CrossTenant-AuthSource: DB4PR08MB9190.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 04:02:50.0983 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O1nN6UleeuNHLied8xn5mVlxFTQHugMyFSxJForwAhZSY6j2r0JNODJlxHjMHCuiGvAZpI07yTPGLIv8xsRylQ2RgzIpKK8W0sE69yputJ4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10183 The touch-overlay encompasses a number of touch areas that define a clipped touchscreen area and/or buttons with a specific functionality. A clipped touchscreen area avoids getting events from regions that are physically hidden by overlay frames. For touchscreens with printed overlay buttons, sub-nodes with a suitable key code can be defined to report key events instead of the original touch events. Reviewed-by: Jeff LaBundy Reviewed-by: Rob Herring Signed-off-by: Javier Carrasco --- .../bindings/input/touchscreen/touchscreen.yaml | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml index 431c13335c40..3e3572aa483a 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml @@ -87,6 +87,125 @@ properties: touchscreen-y-plate-ohms: description: Resistance of the Y-plate in Ohms + touch-overlay: + description: | + List of nodes defining segments (touch areas) on the touchscreen. + + This object can be used to describe a series of segments to restrict + the region within touch events are reported or buttons with a specific + functionality. + + This is of special interest if the touchscreen is shipped with a physical + overlay on top of it with a frame that hides some part of the original + touchscreen area. Printed buttons on that overlay are also a typical + use case. + + A new touchscreen area is defined as a sub-node without a key code. If a + key code is defined in the sub-node, it will be interpreted as a button. + + The x-origin and y-origin properties of a touchscreen area define the + offset of a new origin from where the touchscreen events are referenced. + This offset is applied to the events accordingly. The x-size and y-size + properties define the size of the touchscreen effective area. + + The following example shows a new touchscreen area with the new origin + (0',0') for the touch events generated by the device. + + Touchscreen (full area) + ┌────────────────────────────────────────┐ + │ ┌───────────────────────────────┐ │ + │ │ │ │ + │ ├ y-size │ │ + │ │ │ │ + │ │ touchscreen area │ │ + │ │ (no key code) │ │ + │ │ │ │ + │ │ x-size │ │ + │ ┌└──────────────┴────────────────┘ │ + │(0',0') │ + ┌└────────────────────────────────────────┘ + (0,0) + + where (0',0') = (0+x-origin,0+y-origin) + + Sub-nodes with key codes report the touch events on their surface as key + events instead. + + The following example shows a touchscreen with a single button on it. + + Touchscreen (full area) + ┌───────────────────────────────────┐ + │ │ + │ │ + │ ┌─────────┐ │ + │ │button 0 │ │ + │ │KEY_POWER│ │ + │ └─────────┘ │ + │ │ + │ │ + ┌└───────────────────────────────────┘ + (0,0) + + Segments defining buttons and clipped toushcreen areas can be combined + as shown in the following example. + In that case only the events within the touchscreen area are reported + as touch events. Events within the button areas report their associated + key code. Any events outside the defined areas are ignored. + + Touchscreen (full area) + ┌─────────┬──────────────────────────────┐ + │ │ │ + │ │ ┌───────────────────────┐ │ + │ button 0│ │ │ │ + │KEY_POWER│ │ │ │ + │ │ │ │ │ + ├─────────┤ │ touchscreen area │ │ + │ │ │ (no key code) │ │ + │ │ │ │ │ + │ button 1│ │ │ │ + │ KEY_INFO│ ┌└───────────────────────┘ │ + │ │(0',0') │ + ┌└─────────┴──────────────────────────────┘ + (0,0) + + type: object + + patternProperties: + '^segment-': + type: object + description: + Each segment is represented as a sub-node. + properties: + x-origin: + description: horizontal origin of the node area + $ref: /schemas/types.yaml#/definitions/uint32 + + y-origin: + description: vertical origin of the node area + $ref: /schemas/types.yaml#/definitions/uint32 + + x-size: + description: horizontal resolution of the node area + $ref: /schemas/types.yaml#/definitions/uint32 + + y-size: + description: vertical resolution of the node area + $ref: /schemas/types.yaml#/definitions/uint32 + + label: + description: descriptive name of the segment + $ref: /schemas/types.yaml#/definitions/string + + linux,code: true + + required: + - x-origin + - y-origin + - x-size + - y-size + + unevaluatedProperties: false + dependencies: touchscreen-size-x: [ touchscreen-size-y ] touchscreen-size-y: [ touchscreen-size-x ] From patchwork Wed Oct 16 04:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 835969 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2099.outbound.protection.outlook.com [40.107.104.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3243D189906; Wed, 16 Oct 2024 04:02:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.99 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051379; cv=fail; b=gv3HiDDLPMD8NSUwBaKcfPWYt4ZxT9/2ex4vKECCulcwmCfOhcWU8To0J3fybQ1l/Lq4IO2HKlAELuWsN/TTe/25rorpZqUZxyvSz4yzaxT3f/i7a95BuF1jjnzSpAlH4Q7OzCI/Gz38ePOvFEY+2fvzu6MRzOngoTgfmAc5slY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051379; c=relaxed/simple; bh=jdJvamDCLB03jG7UmkYQcoILhVnVlu7OFv5WsJ4UHqc=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=sfNBaoJ1HufgztxPPes2xz2uWtSNCTNkGkq8sxR0eegrP6Tv6BRaIw630/Y85/OS5Z3FrArMCIoepVLVBqLIGTFV9YeMrsdIsdk2wvpO5PWrnDljpfDK1LH6x89Sc8FqS0ZFY/0jEIl9+q2lw4a75Xn8nB37EofV8vx776ivvdM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=Z/WE3BpY; arc=fail smtp.client-ip=40.107.104.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="Z/WE3BpY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bw6xNYWCxd2ksNiAKDuHV0tBYJ9jiTaF5hlh9bsYnIGHdaKAO80j+B69GSoHLX5UDid6dLPHY0JkULBhYkVBk28VO9ap3BzD385MrFqjGOsHpLPujH+9WF02nFVwVFmV5z/wZcZwhNUq/He0UpT4sNSnFCTV2fMg2ymti9Rx459/sA6/VxhYBOUqCSCPbkLKWmjfMu/wWwIhDT5f4EQbw7mjDjivaN4oSZ26K4bp5l6WowY9+/l6CYksuA72MvTaX/qA6JaO+7vh+BIKJUd3/WR4H1W8cZIUBd6DUCsUL0bO6XMLCBL3wOIkWrSwEbfoBJWEIOrWkfUrsTwtbU69jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=roCj5cj0UOTRVRR4/qbjDDBEx1tybxsLLqewz0ql7fs=; b=ies/FIlTT6HnNSAjZrgbbe65rXdFI1RmpFM2HWWqjU6MxBX3Hd0yTO9EM3iglGHk7ChlzvZpdxoVJmU/iYzMDHbHV+nh2xrNxW9nowvJixfMmgqSVVwh6AEcUF4SqlZGwBkkiSGOCq9Q2DnxiKZFPFnI8u4s/95VmbPTZ1aCay/O3rXu8Px+uhQAAFZuPNCVF56wQk2BxcVIQzzuqFUcw0Vy2fSl5wCUReTRvsRWhHsTjugbVftiubdreuTMx8UVDR0cW8pboWIJePoBzpCKB1wKzT0U8QJZQ4xPjmlEU2D9z9aNKpo5a1uYIXuRWmkmtYxd2WUNezDdq5xsAck0cA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=roCj5cj0UOTRVRR4/qbjDDBEx1tybxsLLqewz0ql7fs=; b=Z/WE3BpYF2/DWfHQwMeKxsF7k7CelwHiZ3nEofvynWLGdzdMXjtn9XEePhvBxbMl6K39Csj3Z43V0z2J18LXt1AR+sBkJFgNl3heMCragfKpcEiv+Rkx/UqfUq425xcJu4rNmPMBTH9m9db8nJdkwvDRSPqzK7K2uMkXY4PUrXY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) by PAWPR08MB10183.eurprd08.prod.outlook.com (2603:10a6:102:368::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 04:02:50 +0000 Received: from DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4]) by DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4%6]) with mapi id 15.20.8048.020; Wed, 16 Oct 2024 04:02:50 +0000 From: Javier Carrasco Date: Wed, 16 Oct 2024 06:02:41 +0200 Subject: [PATCH v11 2/4] Input: touch-overlay - Add touchscreen overlay handling Message-Id: <20241016-feature-ts_virtobj_patch-v11-2-b292a1bbb0a1@wolfvision.net> References: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> In-Reply-To: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bastian Hecht , Michael Riesch Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , Jeff LaBundy X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729051368; l=11690; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=jdJvamDCLB03jG7UmkYQcoILhVnVlu7OFv5WsJ4UHqc=; b=MOF9v6orUPG7u1JyizROmgsCf7RZnL11Ki0tgFvsi59Onp/9Iknu/0z08qSNHPMHe59zWDnNq JXI5i96zSZRCJW5vjBojCeOU5NCmNfX/xzR8/Yp5VEtnHP6rdYkRdjr X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR07CA0154.eurprd07.prod.outlook.com (2603:10a6:802:16::41) To DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR08MB9190:EE_|PAWPR08MB10183:EE_ X-MS-Office365-Filtering-Correlation-Id: d12cadb6-6201-410c-3de6-08dced976740 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OXUfVsnF580kKlmZC7tkj9akINSJDKI?= =?utf-8?q?q0U2ZtTuK2r/hrdNZjoEhO5IK6YIeokxVFx+GxeNqaQ5xPbJSbPFVG4XzGLQYDUf8?= =?utf-8?q?KXT8Ay7953oqAZjNPoepL0C3aKb85BIBvJfhsJa7eDFoPdN240Impe8AENeKTf15L?= =?utf-8?q?tmxQl31RYmKn52iYXVF6l62/4i5LaxVE66UnghZBjJVPfpjSOcHra+Z72erFjBcNG?= =?utf-8?q?lQjhUyPrAsIHKuh+RoV8YW3mHfMe20sBpbO/+92Tc99uKPGc0k2exLGl8b97w0108?= =?utf-8?q?2YVoUaz8lqTN/Vp4HdMNS8ES0HNiejvuP0M52sW5drbBeSCdAzeORo8YQh7Brb6HT?= =?utf-8?q?4ZluwWd7Knlfkt+LpQUFUzIUOg3eYNmPowcmbDPDt8ySsw1tyWt1slYv360xHkH7B?= =?utf-8?q?SY/CUOi263HJmhpMfTcCAlVQ1WT0vL04Ne0pVln8HNARVX4TASK19p848oaQmVq16?= =?utf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Y:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB4PR08MB9190.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZyIDqyhi3+y++obengZgFA/DmOXB?= =?utf-8?q?bI1NYhLzpEYsGeOj6XgLHYjbvHNqN9xNkUc6+MQpNBRBs84VMrDFn+nBXq54myk1m?= =?utf-8?q?JNGdDjhLs52nugCTAWSMPrxEgpBmSU829RLw+Dj+B5SrQSfM5JIRoAcU70gaXgPu3?= =?utf-8?q?8wPE0Vdh5z7prWw9T4DATWf4ktAWzXmtXxOsOLQRdCXdx7mjmv/w2oXVHNuWHm0aY?= =?utf-8?q?sBYHeqMp0oRXmcBpzFgx+s4WhuPpFHIeEW6FDaJQ1FP8xko5TRvtCCUPJYh34Zk85?= =?utf-8?q?hzZn2mZRtBPGslRGM78h/0r7ARbmBDe0wlwlc4zxHpH2ZqdQZKGCBxwbp2Jm2D/Qd?= =?utf-8?q?+NwdIgvDJLFRBghH1nalUsgl6952ZPATifNWbHXaquch1Et2XCEQ0ipxKEjJGgAtu?= =?utf-8?q?BJIpQBpR4tZXa2r3w4haqdyEDYmpT6kmU1ZI28174ncMlS3D7SSW/s1Hz+pFwgyfK?= =?utf-8?q?PSJ2AN0oU+l1fa3T3c7Ob59NeKUrDbjG8cANVzOijtqmYKz1rVcFMdaSFIufozGHl?= =?utf-8?q?0Fbd5YLfXchvco5cjnFyAbKfH2L/UlJ8eoCnPHDm0GgyJJYlT6wwEibuQs5/vJH53?= =?utf-8?q?i3q4aIiNAqNXe9K2p8r8sryfp8d88atwAw0P6nw2CBviarMAFA/NnPMvbeXg9sDM3?= =?utf-8?q?6cyp2196Omfc2GnW0h7osTtNEXfMVofeQP0rl+DsAE37k/0ZMt3QWjOpLq0/wA89u?=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ginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: d12cadb6-6201-410c-3de6-08dced976740 X-MS-Exchange-CrossTenant-AuthSource: DB4PR08MB9190.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 04:02:50.8603 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ML54QFZoRIBNd5xUsARMQNAdokpPQYEUyqdKx8oVSl6e/m1tHwm+YRvlu6tkhmxbRfPCS5Qxo2nlW4IdjAgVcZh1AZ1X8xrgV/vNAcs8WLY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10183 Some touch devices provide mechanical overlays with different objects like buttons or clipped touchscreen surfaces. In order to support these objects, add a series of helper functions to the input subsystem to transform them into overlay objects via device tree nodes. These overlay objects consume the raw touch events and report the expected input events depending on the object properties. Note that the current implementation allows for multiple definitions of touchscreen areas (regions that report touch events), but only the first one will be used for the touchscreen device that the consumers typically provide. Should the need for multiple touchscreen areas arise, additional touchscreen devices would be required at the consumer side. There is no limitation in the number of touch areas defined as buttons. Reviewed-by: Jeff LaBundy Signed-off-by: Javier Carrasco --- MAINTAINERS | 7 + drivers/input/Makefile | 2 +- drivers/input/touch-overlay.c | 277 ++++++++++++++++++++++++++++++++++++ include/linux/input/touch-overlay.h | 25 ++++ 4 files changed, 310 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c27f3190737f..898083ea3a1b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -23478,6 +23478,13 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: drivers/platform/x86/toshiba-wmi.c +TOUCH OVERLAY +M: Javier Carrasco +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/input/touch-overlay.c +F: include/linux/input/touch-overlay.h + TPM DEVICE DRIVER M: Peter Huewe M: Jarkko Sakkinen diff --git a/drivers/input/Makefile b/drivers/input/Makefile index c78753274921..393e9f4d00dc 100644 --- a/drivers/input/Makefile +++ b/drivers/input/Makefile @@ -7,7 +7,7 @@ obj-$(CONFIG_INPUT) += input-core.o input-core-y := input.o input-compat.o input-mt.o input-poller.o ff-core.o -input-core-y += touchscreen.o +input-core-y += touchscreen.o touch-overlay.o obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o diff --git a/drivers/input/touch-overlay.c b/drivers/input/touch-overlay.c new file mode 100644 index 000000000000..8806373f7a4a --- /dev/null +++ b/drivers/input/touch-overlay.c @@ -0,0 +1,277 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Helper functions for overlay objects on touchscreens + * + * Copyright (c) 2023 Javier Carrasco + */ + +#include +#include +#include +#include +#include +#include + +struct touch_overlay_segment { + struct list_head list; + u32 x_origin; + u32 y_origin; + u32 x_size; + u32 y_size; + u32 key; + bool pressed; + int slot; +}; + +static int touch_overlay_get_segment(struct fwnode_handle *segment_node, + struct touch_overlay_segment *segment, + struct input_dev *input) +{ + int error; + + error = fwnode_property_read_u32(segment_node, "x-origin", + &segment->x_origin); + if (error) + return error; + + error = fwnode_property_read_u32(segment_node, "y-origin", + &segment->y_origin); + if (error) + return error; + + error = fwnode_property_read_u32(segment_node, "x-size", + &segment->x_size); + if (error) + return error; + + error = fwnode_property_read_u32(segment_node, "y-size", + &segment->y_size); + if (error) + return error; + + error = fwnode_property_read_u32(segment_node, "linux,code", + &segment->key); + if (!error) + input_set_capability(input, EV_KEY, segment->key); + else if (error != -EINVAL) + return error; + + return 0; +} + +/** + * touch_overlay_map - map overlay objects from the device tree and set + * key capabilities if buttons are defined. + * @list: pointer to the list that will hold the segments + * @input: pointer to the already allocated input_dev + * + * Returns 0 on success and error number otherwise. + * + * If buttons are defined, key capabilities are set accordingly. + */ +int touch_overlay_map(struct list_head *list, struct input_dev *input) +{ + struct fwnode_handle *fw_segment; + struct device *dev = input->dev.parent; + struct touch_overlay_segment *segment; + int error; + + struct fwnode_handle *overlay __free(fwnode_handle) = + device_get_named_child_node(dev, "touch-overlay"); + if (!overlay) + return 0; + + fwnode_for_each_available_child_node(overlay, fw_segment) { + segment = devm_kzalloc(dev, sizeof(*segment), GFP_KERNEL); + if (!segment) { + fwnode_handle_put(fw_segment); + return -ENOMEM; + } + error = touch_overlay_get_segment(fw_segment, segment, input); + if (error) { + fwnode_handle_put(fw_segment); + return error; + } + list_add_tail(&segment->list, list); + } + + return 0; +} +EXPORT_SYMBOL(touch_overlay_map); + +/** + * touch_overlay_get_touchscreen_abs - get abs size from the touchscreen area. + * @list: pointer to the list that holds the segments + * @x: horizontal abs + * @y: vertical abs + */ +void touch_overlay_get_touchscreen_abs(struct list_head *list, u16 *x, u16 *y) +{ + struct touch_overlay_segment *segment; + struct list_head *ptr; + + list_for_each(ptr, list) { + segment = list_entry(ptr, struct touch_overlay_segment, list); + if (!segment->key) { + *x = segment->x_size - 1; + *y = segment->y_size - 1; + break; + } + } +} +EXPORT_SYMBOL(touch_overlay_get_touchscreen_abs); + +static bool touch_overlay_segment_event(struct touch_overlay_segment *seg, + struct input_mt_pos *pos) +{ + if (pos->x >= seg->x_origin && pos->x < (seg->x_origin + seg->x_size) && + pos->y >= seg->y_origin && pos->y < (seg->y_origin + seg->y_size)) + return true; + + return false; +} + +/** + * touch_overlay_mapped_touchscreen - check if a touchscreen area is mapped + * @list: pointer to the list that holds the segments + * + * Returns true if a touchscreen area is mapped or false otherwise. + */ +bool touch_overlay_mapped_touchscreen(struct list_head *list) +{ + struct touch_overlay_segment *segment; + struct list_head *ptr; + + list_for_each(ptr, list) { + segment = list_entry(ptr, struct touch_overlay_segment, list); + if (!segment->key) + return true; + } + + return false; +} +EXPORT_SYMBOL(touch_overlay_mapped_touchscreen); + +static bool touch_overlay_event_on_ts(struct list_head *list, + struct input_mt_pos *pos) +{ + struct touch_overlay_segment *segment; + struct list_head *ptr; + + list_for_each(ptr, list) { + segment = list_entry(ptr, struct touch_overlay_segment, list); + if (segment->key) + continue; + + if (touch_overlay_segment_event(segment, pos)) { + pos->x -= segment->x_origin; + pos->y -= segment->y_origin; + return true; + } + /* ignore touch events outside the defined area */ + return false; + } + + return true; +} + +static bool touch_overlay_button_event(struct input_dev *input, + struct touch_overlay_segment *segment, + struct input_mt_pos *pos, int slot) +{ + struct input_mt *mt = input->mt; + struct input_mt_slot *s = &mt->slots[slot]; + bool button_contact = touch_overlay_segment_event(segment, pos); + + if (segment->slot == slot && segment->pressed) { + /* sliding out of the button releases it */ + if (!button_contact) { + input_report_key(input, segment->key, false); + segment->pressed = false; + /* keep available for a possible touch event */ + return false; + } + /* ignore sliding on the button while pressed */ + s->frame = mt->frame; + return true; + } else if (button_contact) { + input_report_key(input, segment->key, true); + s->frame = mt->frame; + segment->slot = slot; + segment->pressed = true; + return true; + } + + return false; +} + +/** + * touch_overlay_sync_frame - update the status of the segments and report + * buttons whose tracked slot is unused. + * @list: pointer to the list that holds the segments + * @input: pointer to the input device associated to the contact + */ +void touch_overlay_sync_frame(struct list_head *list, struct input_dev *input) +{ + struct touch_overlay_segment *segment; + struct input_mt *mt = input->mt; + struct input_mt_slot *s; + struct list_head *ptr; + + list_for_each(ptr, list) { + segment = list_entry(ptr, struct touch_overlay_segment, list); + if (!segment->key) + continue; + + s = &mt->slots[segment->slot]; + if (!input_mt_is_used(mt, s) && segment->pressed) { + input_report_key(input, segment->key, false); + segment->pressed = false; + } + } +} +EXPORT_SYMBOL(touch_overlay_sync_frame); + +/** + * touch_overlay_process_contact - process contacts according to the overlay + * mapping. This function acts as a filter to release the calling driver + * from the contacts that are either related to overlay buttons or out of the + * overlay touchscreen area, if defined. + * @list: pointer to the list that holds the segments + * @input: pointer to the input device associated to the contact + * @pos: pointer to the contact position + * @slot: slot associated to the contact (0 if multitouch is not supported) + * + * Returns true if the contact was processed (reported for valid key events + * and dropped for contacts outside the overlay touchscreen area) or false + * if the contact must be processed by the caller. In that case this function + * shifts the (x,y) coordinates to the overlay touchscreen axis if required. + */ +bool touch_overlay_process_contact(struct list_head *list, + struct input_dev *input, + struct input_mt_pos *pos, int slot) +{ + struct touch_overlay_segment *segment; + struct list_head *ptr; + + /* + * buttons must be prioritized over overlay touchscreens to account for + * overlappings e.g. a button inside the touchscreen area. + */ + list_for_each(ptr, list) { + segment = list_entry(ptr, struct touch_overlay_segment, list); + if (segment->key && + touch_overlay_button_event(input, segment, pos, slot)) + return true; + } + + /* + * valid contacts on the overlay touchscreen are left for the client + * to be processed/reported according to its (possibly) unique features. + */ + return !touch_overlay_event_on_ts(list, pos); +} +EXPORT_SYMBOL(touch_overlay_process_contact); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Helper functions for overlay objects on touch devices"); diff --git a/include/linux/input/touch-overlay.h b/include/linux/input/touch-overlay.h new file mode 100644 index 000000000000..0253e554d3cd --- /dev/null +++ b/include/linux/input/touch-overlay.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Javier Carrasco + */ + +#ifndef _TOUCH_OVERLAY +#define _TOUCH_OVERLAY + +#include + +struct input_dev; + +int touch_overlay_map(struct list_head *list, struct input_dev *input); + +void touch_overlay_get_touchscreen_abs(struct list_head *list, u16 *x, u16 *y); + +bool touch_overlay_mapped_touchscreen(struct list_head *list); + +bool touch_overlay_process_contact(struct list_head *list, + struct input_dev *input, + struct input_mt_pos *pos, int slot); + +void touch_overlay_sync_frame(struct list_head *list, struct input_dev *input); + +#endif From patchwork Wed Oct 16 04:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 836890 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2099.outbound.protection.outlook.com [40.107.104.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BFB618A93F; Wed, 16 Oct 2024 04:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.99 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051381; cv=fail; b=uQ/PY4Q0Saby45GWDLFu1D9NO47d0hY3XYS6m31qDRkoO3zmzYM8V9mN4tC+QAik9UdehZ4BZidUlsxa0B/mMqmW/gPm1kf6+eCHf3cT8S6hQ2mglrHwAKsp8vrJH/ncGz3b2ac5a5sB4Sw9LjeJfOhOkIvKow7kPVN+jlvcfJg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051381; c=relaxed/simple; bh=XWHXrVKqE2CO9WPWm0JSgomvOBlZ7nKTdoLdXMwhYpk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=C4RXWm3WkRt8hRiGJkyQG6b03TkXWCHdrC5D75HNfSvvYlz/9akx5fHYC9Imvui9HxnEPBFTVqe6ERSDgbuGgL3PipvcjMYRrsPvU4RgyNxJ6HCeJZUb06IyrLcFR3GJ0AhU+SAQzB4AdeIVjPTY//54EoqmvFAU95xxTZoVcVQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=jf2RBX6B; arc=fail smtp.client-ip=40.107.104.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="jf2RBX6B" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SefXL8PbzSJGaEcsJyLW/nOx2c0rK3o1l+3qYa+tr2RO/vqqHDnVm4FMne5J2LsLK+Ccf12Zt25uATW6voOoJnROuHJBCIenEvy5AVVodTXJ81/5JgwCx6BMfaSp8DkucaDqffFBx59ObrBbuXq4VuyYkB/OTjfZZJwHuntybUyFfgNWObhTK6KeOvJGnx1FQK7c1F2Xyp+uCtPEA4bG1yVkl0xD87wZ7+nshMAUoSALOmQv/4hM8q6nbfVXol05yVL8W6eM62L+KRHMmNElxegSzTnGx9J13agxKl9HQCmooD6AdDUsNjL3+6CbSXaiZQMXfaRD4aA9U4lZ+JRw6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OMAGtTuTnOUoFkDvbGTrc/5C9LZDKdMlTNViTlbiSRQ=; b=ZlYlwRhA5CBmXd+Caz5IKQY9rO5ddLjJ4DDvSu0MP6NsGsfZha2ZeiR0BjcB6aRxyRjcdU1nGL1csshz3zAaRYJmbC3mdfJ4YkMta3caOwzn31vkljGQvgEhPMXqHukAeNs2snyZdJrF7Elxx1fjRfTatjvd7EqeVuaM3lBQIHcXl77/rhzCkvS+wMzNjW4WaIXDaaMId0WmjgtEfJe7i6SqGE4z6KD5cE1znLyfczljNZWpH0URvIGtSOdGd021QawLs/wI3VkT3j8P5EFisU2xVZiG/I1CA1pSsuGNipCixC4ObOZhtqhxp8cu2+2CZAJPw4tUaqeXQgOCdNcNug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OMAGtTuTnOUoFkDvbGTrc/5C9LZDKdMlTNViTlbiSRQ=; b=jf2RBX6BHtDskvUB84e/9hSOUaVFCe27VjQBmAPeeT2q1OFHTeeGxZSjfo7aFsQsqTm76mH+gg8M7qtRLx/kXtEpMSlHcDjN7V6TspMCu2sw+RVIm0xUgO05QnRYxGUjhJHKoAqLyyk6Z2Dm+BqjDeuZbGxWb/GA/u3QuI7vaHc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) by PAWPR08MB10183.eurprd08.prod.outlook.com (2603:10a6:102:368::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 04:02:51 +0000 Received: from DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4]) by DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4%6]) with mapi id 15.20.8048.020; Wed, 16 Oct 2024 04:02:51 +0000 From: Javier Carrasco Date: Wed, 16 Oct 2024 06:02:42 +0200 Subject: [PATCH v11 3/4] dt-bindings: input: touchscreen: st1232: add touch-overlay example Message-Id: <20241016-feature-ts_virtobj_patch-v11-3-b292a1bbb0a1@wolfvision.net> References: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> In-Reply-To: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bastian Hecht , Michael Riesch Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729051368; l=2517; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=XWHXrVKqE2CO9WPWm0JSgomvOBlZ7nKTdoLdXMwhYpk=; b=ZDQYS1QI2o5Q8E4/PyNeXvhlm9If7BAMd/TUA+C7PmIhqysNISDC1G1uIyi5U32OzS+Uzm+nk eMFaSVC7kOYA3U6IrYf5eXe2myZnGrjFuOE5+SNibonzNpotXgobvWK X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR07CA0154.eurprd07.prod.outlook.com (2603:10a6:802:16::41) To DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR08MB9190:EE_|PAWPR08MB10183:EE_ X-MS-Office365-Filtering-Correlation-Id: ffe7a1a6-adb2-452e-d2ef-08dced9767b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3lPuqu1fwueA+NsTXnrZsdAhsTMWe0G?= =?utf-8?q?p5Q53cfi3YExazStjqoyn+TL3kBXj3yINBIJ4IaLx8eDE4M8aqRrmGdeeo5tZ8MRQ?= =?utf-8?q?6tgjEwg3d7M1I+fm4TLM2MyQDnQrdhtpa4lCGjbFQ4TySPMWIA3Am62dkcQa/D4lB?= =?utf-8?q?MVa8o9b/DeqDkaAX/Tj5iJWm/ZB4JdnVCU0QDxLyzf4hl9CiBdw6TUznu0oGrC+wN?= =?utf-8?q?mUTGHFJWks/EXmVZ1uTmFpeWQ1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1TO0v8fCH3Nur7xTL1ARlkJi95/xNamGCAYr1MtIYscmgYn7fHxJXaFp?= =?utf-8?q?aRkdgozQxlaSUAYgg3Bi+RZpWgQpvCg+2kOynXeOfImN7a4ToXzOmq/IAHPpw42kw?= =?utf-8?q?NHWWueykP3ZF2Ny42hfuJU0eijQfKMzijgBB5FOeh5BRMk9NFfbeNK4teWHoRiHSQ?= =?utf-8?q?VSj+4hXg8SNMBbCwnZ3TjoGaXselOpKl0Hg=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB4PR08MB9190.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?DatVF+u+iFx0e2G78jfqjbsqcY+7?= =?utf-8?q?uTULAitA2swW08IRSX352lf10ora8zPXpPwwOHvxDIDCmOddlI/8oZDXnz8qTRi3r?= =?utf-8?q?xR5anuwJ5bXc7ZGSxFe5bS62FsTJk8y3iOvoS0MdrdoOIV3VDbfoBGV0GtW5L3y5I?= =?utf-8?q?omgQvD2+7CadVQmR7lLMlqPU1E005/Z7QVXX0LlUcUovA46ZUljEc+yPhOj/e5PHa?= =?utf-8?q?44Dr+GEo0NvWCqSOFhfmqLNgY+LkFFG3zZgqAcJ+P1uDn9ZrfDbxgU+rgyAbrEfJ6?= =?utf-8?q?md8+IXvkdCVSC87Jk/o/6KyIzzArFbdXqHPVRkS56aT31cCUDP/DdmfN/ZjbljmH7?= =?utf-8?q?qeNaSuIIja614e5tBxwApalI/g337Rkr7UhLe8qsJUlC6ygNneEFeUuI84hwZkEc0?= =?utf-8?q?ASbW+o/64MduQTs9BMB6Yi9Z6kaP5RSRzvmbOo/wVRxVzPLTb2ikA3yzol9r2z8wM?= =?utf-8?q?V8pU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KTlB8L6Aj+oXskTgiwtyYIUQlAH?= =?utf-8?q?6gq12T3kRrpEM6oCwud2IUcr3TlN3GpAwXcbH4FqVi/r6AodjAfbE213i/UyuqODq?= =?utf-8?q?5kV9R0TT73s4r7u5xx0/5sYXr8U6QxKiH1rJGtd4tXOsk05vdwWNDapQHObJJkBy4?= =?utf-8?q?YHoYCQxMUhj/iwzbyvL5gp5LV5gvIkb+XCWEs0Tc6BmsHltzw8WNXew=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: ffe7a1a6-adb2-452e-d2ef-08dced9767b3 X-MS-Exchange-CrossTenant-AuthSource: DB4PR08MB9190.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 04:02:51.6074 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: omwnKBAkm0hcze/gc9WIS4qfke7pZ+TzE3n1LjZ7A9F8Oev9DN5MkMildkH6QunHxmmEuBMMFFRD1DMxWkk+QH5rrtRvxK2lum/ZGPjO92g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10183 The touch-overlay feature adds support for segments (touch areas) on the touchscreen surface that represent overlays with clipped touchscreen areas and printed buttons. Add nodes for a clipped touchscreen and overlay buttons to the existing example. Reviewed-by: Rob Herring Signed-off-by: Javier Carrasco --- .../input/touchscreen/sitronix,st1232.yaml | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml b/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml index 1d8ca19fd37a..e7ee7a0d74c4 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml @@ -37,6 +37,7 @@ unevaluatedProperties: false examples: - | + #include i2c { #address-cells = <1>; #size-cells = <0>; @@ -46,5 +47,33 @@ examples: reg = <0x55>; interrupts = <2 0>; gpios = <&gpio1 166 0>; + + touch-overlay { + segment-0 { + label = "Touchscreen"; + x-origin = <0>; + x-size = <240>; + y-origin = <40>; + y-size = <280>; + }; + + segment-1a { + label = "Camera light"; + linux,code = ; + x-origin = <40>; + x-size = <40>; + y-origin = <0>; + y-size = <40>; + }; + + segment-2a { + label = "Power"; + linux,code = ; + x-origin = <160>; + x-size = <40>; + y-origin = <0>; + y-size = <40>; + }; + }; }; }; From patchwork Wed Oct 16 04:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 835968 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2099.outbound.protection.outlook.com [40.107.104.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53946290F; Wed, 16 Oct 2024 04:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.99 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051383; cv=fail; b=abaMM7H6h0E1zuVYdYUXyH4wQ+h+583/sYaku18l6Y0oDgNMg/xdYAExjZ1p47JRRRAtMlUZNE72BIEfU2M4yGFutsVPB5eSBNPPp91vHUKhf0w9cNdsu+WZE9ADPp8K8U3jUy8A3yNbGlD6RrO0oOvXj3LE0TGQC1jgbpE+1ic= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729051383; c=relaxed/simple; bh=6Rd06mzprzVBozWdIS79zpyXpkHY0oY+g8+KrxW3IOM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=eJjRo/YU5MmxSbF57uOLyO0aqFNRj1xd+Ojou6+9yR9Wg99sDoQCEZ67b1Ye8R9S2k/6SO1UW1TsSV6/dLf7Dvr8XTFnopHBM898xlqmtEsG/14/PqCZrMznmDMfyNqKVjxkzvFfEKMfbBv6dC8n3Ex4rHINb3eOQRUiJ4yR5fo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net; spf=pass smtp.mailfrom=wolfvision.net; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b=eKGV5CfY; arc=fail smtp.client-ip=40.107.104.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wolfvision.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="eKGV5CfY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dTpX33ZQR1uZl9d0uG2kPqOyEzUsb4JD92TJjlgBnRJnE9eqHpeaH1dLjbgIoYlkCgAWQ4pE7KpO/Yxi20x4vpJ5R4WAWrpVHLoU/w6rqPtL1SSEkBghYtXScygjJwzsH5WSORqulm7D1L3d+9V+l+UU0fKAd4td4ZrAMVOgQtTttPFepNfW5PxbKfFtXRVBtYb6XCxJgBCWUu5RHtzvdk73NOBCc/kIkObQA6HYFaYAB1qFGHk60caHgf+4ddR0etbKh7WOUqRXZE3IN5qNz3NrjRvKm+5Vvl24JJyefm8u2MBjhQhICgqekWdB+XlW9oKH8t0gVlglyenNr8qOfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R8aCWi7+qUdaWhJcJz61qNnK96Og/DumwNYjndfUjZo=; b=Lhm9ecbnyxP+/JjUltpT8Uz7U3WfJ0ltfmeiiDM9Lw4frY8LJ3hZ28ttMK3EfT6RDikUGeu2P4QOKLTTYxAdMuSjFdaRDLdV0GDnm1IBqLSMmDZyd6YRLxpTGML2WRP2NZetAvs3GqFLdWeWZFHTXyMefKzlfDewN11bMk+PoWY2uu8lHPQwr7i65I3jp11msaK9w9IP30J4tykZJ11szQ91qbWnEwp768GKC4Ca8MFvAtd92pHLCxqCy5Fne+xLb4ctGmecxGzBdhNCm6xThUjUKy8P1LvPg2smoEhYzg4OWEVPacMNz1lcOg6qUaTFrUWYRlD4KNTboWwlk1rIUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R8aCWi7+qUdaWhJcJz61qNnK96Og/DumwNYjndfUjZo=; b=eKGV5CfYd15QsTJFh71ooQMVWE+kngURGo6SWzMeJKknAy6blLUsobC0yQ/ePESxQFQbZanxmu4heIimvG4mMe9a/z2H4EucgwkTvEH5kCmb0aWZQfms21lRDterfpQ2BkE0mcO5iKYzjkHYQwe9l9ZYbaBKMiSYWmdjBvVBBTo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) by PAWPR08MB10183.eurprd08.prod.outlook.com (2603:10a6:102:368::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 04:02:52 +0000 Received: from DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4]) by DB4PR08MB9190.eurprd08.prod.outlook.com ([fe80::c7a:6978:9afa:19a4%6]) with mapi id 15.20.8048.020; Wed, 16 Oct 2024 04:02:52 +0000 From: Javier Carrasco Date: Wed, 16 Oct 2024 06:02:43 +0200 Subject: [PATCH v11 4/4] Input: st1232 - add touch-overlay handling Message-Id: <20241016-feature-ts_virtobj_patch-v11-4-b292a1bbb0a1@wolfvision.net> References: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> In-Reply-To: <20241016-feature-ts_virtobj_patch-v11-0-b292a1bbb0a1@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bastian Hecht , Michael Riesch Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , Jeff LaBundy X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729051368; l=3162; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=6Rd06mzprzVBozWdIS79zpyXpkHY0oY+g8+KrxW3IOM=; b=VF44P9sxVB7wtJtTURWetgKIiz/ENaKIyFWiF/DEWnWiMyykkaPCFvM0ahcPkyKbrmIe7GSqA boT59t/HczUBYWKZ1/IJCieumLYG4wubuz8IHvD4EHVsgQtdoJ3e3n/ X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR07CA0154.eurprd07.prod.outlook.com (2603:10a6:802:16::41) To DB4PR08MB9190.eurprd08.prod.outlook.com (2603:10a6:10:3fd::21) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB4PR08MB9190:EE_|PAWPR08MB10183:EE_ X-MS-Office365-Filtering-Correlation-Id: 4b06a46b-5030-4d04-a3e1-08dced976826 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?w0F+nfrv1ApSbdOkraOQVC45eOFgQr+?= =?utf-8?q?o9P7e+AlrigxZI98gRpsaMtbVvKVr0bNAEofSU8/IC1NX+4m8k/og+Env97XuUfIE?= =?utf-8?q?+ZqCn5GA+22r51/mJ0Srw4DDEb8p8c6VD9bZWB9yXeKZYZSgdkXGXUWsAqj9QRYtU?= =?utf-8?q?Xw3RjTttnUL4GJQNA5+0l3XnlEtvj0YL0I+XFZAp2rPnhyCcWoetkSDbHGsqbD3+B?= =?utf-8?q?5H5SF6b8/R2jjURVMoFRZDLg21NfAglhKe8bVnP92J4g8alm6wE5Cos0T9zN+2Vv5?= =?utf-8?q?gf+bXaPan86aC0eUrDnMrDZmA0eIG3E8EDVv6U2UcILaM6029sOiI1lOEdwsKad1e?= =?utf-8?q?TEqEKzWLFTnnrhMs3oqcNmDBL/efwIYKzowAC2OXlAVXlOHBc7hCcTlsTRrXhRsm5?= =?utf-8?q?f2H3R2yWQUyPR46TQTrqJmDLcTcLNxXl8g11LqMSl5Df5OtyBG8uzTByyp4eSvs9l?= =?utf-8?q?YxmqHRZ9PdhJdaGND+Jmkxls9l+PyJ5C9bEp2+KYKLReYentBIERsRbkJc0ChzE6H?= =?utf-8?q?jYA6xeFLt0RHcae2+hSGO5gaAn11MIH+ZKK1DIa1HYo8oq/Qzd0tVpn3n34nRXGeM?= =?utf-8?q?HjJJqCuCSkPYjoTvgVq6cAgOMXv3o7/ACCq145BWp09lMYdPftZVpvEltCjKSnACH?= =?utf-8?q?8c58qE/nX9uHDKB0/0ezhNMgkAQTw/CtSFuUmZg2xy8l0kX34zZrqI3MQIlzzyJJA?= =?utf-8?q?pgZz2lz/BEACdwGdvVDEBu+E+P6ZK0irIF6r/XOSSa3U84NA3wGDTOUO0l9kiCfRJ?= =?utf-8?q?4R612q5QqH8fIqeRkCxr0vk6u5Ws/xL71PYnxUBQURRYPyQfsLh847MjgLt99rr0Z?= =?utf-8?q?t3YwjUexkwQuJcvWRjdj37GIT97FbWL5gouQdg8/EL+KTLpqXjaLT0me8hKaN5mJn?= =?utf-8?q?ilzMjKHwdtHj17yVCUiQqkcD+L192zbZ+roXN4qUe8v5JfLjH3c5s4miRte9FU7Vw?= =?utf-8?q?Gn+7o/gTm4tfFCEv9palAjnQy+GNgbI7sfyCu7fNCufKXF3rMf0JYtwKXuhKn2rXy?= =?utf-8?q?Db4JbbQjXyOr0CheuU4TWTZrBPR1ber2Y+wiIwaLRI5pmH7h0KcoOWO1nUwEqN5wX?= =?utf-8?q?/h+myRREBK1f75MirOlh1/qdx0sbLavOHtgCmw84+yKGGMqDzJqnBZT3vngvH8kTh?= =?utf-8?q?s2l2fwzVVpnLBJDUzwgwgkzvIqQyHA7T5uxzvVrc9dYcT3MoZNhIkgdnxEhCKsiRz?= =?utf-8?q?V3DpT51fNDXwVp/Y5SnFoAcwDh0zv1wyM79zp7zM2/u3v4hvMoHKTI4QU7LQHR8Mc?= =?utf-8?q?hLFiNGUdAq/A9Ucq6svxwWdiaSxx7OeW82w=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB4PR08MB9190.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lAZDpD4nk6IhYlYp3/zbaCZMpiUh?= =?utf-8?q?06elMPxIXAa/oqmkB8TP/a5EFNwvPrgLyzHvfrccNxyv7I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tErUZ9oDAs1dDdSPGvTeY9m4pd2AyY?= =?utf-8?q?RF/FzEc4ogm2BipR6EmmNz9dd5LPI5IMPup3gBIFO10RlmER8f1Uj/2WPSvrGMAfb?= =?utf-8?q?zCHbwfFsi+REK2Ml8SdLjp+avDDjCCD8YbFYGUJ/KbmdUgxmZsea/G89eEMfdoQ41?= =?utf-8?q?eWe91Es8brGSjSkvjfp9iR/YYe4PhWxsbaboJf2PZlJG7VOr4/isVQpNfPLB+V0YG?= =?utf-8?q?vg4xniH2TbNE7+1baURQWOvLrB8kQ44HGU/MRWOrk1IqtVpqITt77D40FEW4b2EZE?= =?utf-8?q?LScIpcOobxO4XcbJe+/sxbO6e8PZVWu5KwE/XWUalC8ZqkOgJ5PXqQwIX0+G4Hwrq?= =?utf-8?q?w/Ocrd4JKKheDn+YiVbLDmoeNDaX27ObxQ3kE+a8HpRSKA2+cy11BXOAMMOr72+rU?= =?utf-8?q?SxTdCneQEEh8NF3rBbA4tZX3U18HWg2P4iV8/T0gJ+PaOXUCYSVT6ojT3Uzs0BIJI?= =?utf-8?q?+L5ZKZMeo+naf+R2+AkXxB0iNP3sLyOptUDs+HUSsfzBb2FNOGubL6XfHyHp1I9L+?= =?utf-8?q?wmepulY9m31c+On0IuRxPc2KC20Gkd8fhBhzi8oTD6H2fZmfKU42VqLl6txi2M6y4?= =?utf-8?q?F357HDTPuZjnp10X2HHlzlLjiagVxNoF6tWxq4Wz7Q0H7/vSbCvCKDA=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 4b06a46b-5030-4d04-a3e1-08dced976826 X-MS-Exchange-CrossTenant-AuthSource: DB4PR08MB9190.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 04:02:52.3570 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 29dSvq+SUhKTuL3IWz/FWbXwR6iwHkbIXALG2n31dbk+39ANFTU5x7ZdNWuR2not1GB0rHyaIohYokAtsLYNlvhwrLUCohXDORqeprAl/QQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10183 Use touch-overlay to support overlay objects such as buttons and a resized frame defined in the device tree. A key event will be generated if the coordinates of a touch event are within the area defined by the button properties. Reviewed-by: Jeff LaBundy Signed-off-by: Javier Carrasco --- drivers/input/touchscreen/st1232.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 6475084aee1b..9b3901eec0a5 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -22,6 +22,7 @@ #include #include #include +#include #define ST1232_TS_NAME "st1232-ts" #define ST1633_TS_NAME "st1633-ts" @@ -57,6 +58,7 @@ struct st1232_ts_data { struct dev_pm_qos_request low_latency_req; struct gpio_desc *reset_gpio; const struct st_chip_info *chip_info; + struct list_head touch_overlay_list; int read_buf_len; u8 *read_buf; }; @@ -156,6 +158,10 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) input_mt_assign_slots(input, slots, pos, n_contacts, 0); for (i = 0; i < n_contacts; i++) { + if (touch_overlay_process_contact(&ts->touch_overlay_list, + input, &pos[i], slots[i])) + continue; + input_mt_slot(input, slots[i]); input_mt_report_slot_state(input, MT_TOOL_FINGER, true); input_report_abs(input, ABS_MT_POSITION_X, pos[i].x); @@ -164,6 +170,7 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) input_report_abs(input, ABS_MT_TOUCH_MAJOR, z[i]); } + touch_overlay_sync_frame(&ts->touch_overlay_list, input); input_mt_sync_frame(input); input_sync(input); @@ -292,18 +299,30 @@ static int st1232_ts_probe(struct i2c_client *client) if (error) return error; - /* Read resolution from the chip */ - error = st1232_ts_read_resolution(ts, &max_x, &max_y); - if (error) { - dev_err(&client->dev, - "Failed to read resolution: %d\n", error); - return error; - } - if (ts->chip_info->have_z) input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, ts->chip_info->max_area, 0, 0); + /* map overlay objects if defined in the device tree */ + INIT_LIST_HEAD(&ts->touch_overlay_list); + error = touch_overlay_map(&ts->touch_overlay_list, input_dev); + if (error) + return error; + + if (touch_overlay_mapped_touchscreen(&ts->touch_overlay_list)) { + /* Read resolution from the overlay touchscreen if defined */ + touch_overlay_get_touchscreen_abs(&ts->touch_overlay_list, + &max_x, &max_y); + } else { + /* Read resolution from the chip */ + error = st1232_ts_read_resolution(ts, &max_x, &max_y); + if (error) { + dev_err(&client->dev, + "Failed to read resolution: %d\n", error); + return error; + } + } + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0); input_set_abs_params(input_dev, ABS_MT_POSITION_Y,