From patchwork Wed Jun 26 09:56:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 807618 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2134.outbound.protection.outlook.com [40.107.104.134]) (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 801D116F0D1; Wed, 26 Jun 2024 09:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395789; cv=fail; b=G1be8I3gD1SHYKhJWUL2lRph+w6MJULPb/wU1jONrk9QCtrjUYz+1BFmefsCXY6CTQ0x8keoKj9IaW6oLRCSnxvQ0G2gHCXoJhvrbUVisKscIUrr0C3rJNj5M5w6IBfrjUlnpMti7IlwgZ/CugUdPNSsp+EvYHx7QT6stmed2rk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395789; c=relaxed/simple; bh=We4djLZrQmwTewoy3TXvLCuEcuRF2BZn64gf0yEafpU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=b2b9TFFpQq8jxF/XoIkRuOkMadgttaOOBaxbVxkk44tlZzgYIv53du4AjziaNY/BI/D/E1WREINszmESdg+KCYRn3eF5hM22w/N0l0VXh+v08p3d0peeCj/0OAfSkZTEWR/sHiJ/uInnUvqHZ1hIxjzCZ5XleHgV87NiDi9meJg= 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=UiCYjQIc; arc=fail smtp.client-ip=40.107.104.134 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="UiCYjQIc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eCi1vMbb1booEQ5+ovz0I1f0yzfOLOU1RRSwuc1iA8zAEhpwcAsnmw6H88lymkzowhriWAbhBuWW90Z97o3dQCzS20b2nRRqXwrtXsFXH0UTBGeN7GZ2U0/D4VY5bKk0Yrkg0prsCdWJoWqo7DzZ/qKCYE76LUddSQs+lX1o5uO2pVcL5mxd8UdZoy5SCKV3db/umOnEoxZQ84RYVcILt/zuS2feDZ08d1HXos22nB4nAciFFbXnkqkG1ZLmITjvT1WiEzCB3OWRlyw24UkGTowq3h8RySkcuXSbGjjQ2SuHi01n1673DxJlGs6dNdveQA/xzsgCPPDEWi06evRgmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lRUe7KDkC01XwoHUft0RG9xZV2wyedfrobtHpSyaX+g=; b=FBeMhlwBUBqcwB8kFqb675DwjdqoqL5RGoP92ljtj91MzpRNLuhbbgq8dCp8990E5v/JzGYTdl7aOapBO2i308yPP0uv0a3bQ7RmWVY6uw/Yy4QRpV21pu9XduKYvfmSO+/vRVIu2yKG0Dh6xnDtWsml0NcP49piemrmQnxaEPDbai4+DaeD8RRPmKV+F+v9QZoLQxfCoiDpO730hg8fjE4yO64IgudbEC5HtGS6xaTMPBvNJMDzunhZXMh78Zalo8acCos6o5AtmAg/5SDkGD+/AjtLJI4gEM4MP0D2dnT1Te+ZQy9r6tQzzY003FzgD/oLEcxbJKw6OGjP9SFJ8g== 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=lRUe7KDkC01XwoHUft0RG9xZV2wyedfrobtHpSyaX+g=; b=UiCYjQIc9WzBNVC78GkJQ1CUJR3kFZYFiI14+ZrLXqk3Kht1J2Kh0qE1Hgz9QD7tlsblVkRIheq3LTvm+Ez/Dm57PB5Ay5xAb8YmuYzwIgzgBKtRIBIjsPUhCNFr6M+gtSMJRuptABTrled2LeLdgJKkZumPXFGunZ56xmrDttE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by GV2PR08MB8679.eurprd08.prod.outlook.com (2603:10a6:150:b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Wed, 26 Jun 2024 09:56:20 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1%4]) with mapi id 15.20.7698.025; Wed, 26 Jun 2024 09:56:20 +0000 From: Javier Carrasco Date: Wed, 26 Jun 2024 11:56:13 +0200 Subject: [PATCH v10 1/4] dt-bindings: touchscreen: add touch-overlay property Message-Id: <20240626-feature-ts_virtobj_patch-v10-1-873ad79bb2c9@wolfvision.net> References: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@wolfvision.net> In-Reply-To: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@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=1719395779; l=7148; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=We4djLZrQmwTewoy3TXvLCuEcuRF2BZn64gf0yEafpU=; b=YlK4JaFidAVMRn33kw1XiwovX2umUaWolUAhUf5+jWXp1ufEs4jEbzu5fz9EoCQAQOa3fabxz 4NqfySMMCDxDjKgtwxROK1H5apOPE6b4GAotRXyhlnboxGs1HI7BdAE X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR09CA0118.eurprd09.prod.outlook.com (2603:10a6:803:78::41) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) 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: VE1PR08MB4974:EE_|GV2PR08MB8679:EE_ X-MS-Office365-Filtering-Correlation-Id: a988b97e-b829-4cf2-ebb5-08dc95c63a86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|366014|52116012|376012|1800799022|38350700012; X-Microsoft-Antispam-Message-Info: =?utf-8?q?SaCwmkPQDJC8C6lGfhJFg6Qv+hku3WX?= =?utf-8?q?VuV45EgJDpVc7p328KSzLkmvcbWANo8iLyAiOiGHgNCRzLKq1E2236xMi5SS1tF/O?= =?utf-8?q?moX9oWmYBwiQvwViwl3v7Sp6ilSmjLr5ve1YcGFqw8lPI2+OeGqLMEKt6ZQFzzUqd?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NDlc85LnhadiIi/EitvgMJx+oueLHO1oh55EUul8x768GNrHJvDrf6?= =?utf-8?q?d2PZJ2kbg23Mx2mEpn28FSF57tfpiUUrEk2G+tnFI5zJOYf3SraLWf3+ZZ6Tc2N9r?= =?utf-8?q?yykYNh6yanXRRhKWNlrDMpScZJwKV/b7yn+4k5ACfPIvMTRPtAwOqbrbu1i98qhMx?= =?utf-8?q?Ds/0H224E3CI395z9qgfqPRnOMaTbkz8gSZgeg754ub61s++XmSvdSp2fM7a5chTA?= =?utf-8?q?uofaKygFyqbAEiaccRQJGnC/Zvw7636jwsfMNZNPRGu4M9oHXDct6CNbFHbqQ70Np?= =?utf-8?q?DJCFNfbgfZoBaHmSrfHCgY/bw/kEbcSzgw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4974.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230038)(366014)(52116012)(376012)(1800799022)(38350700012); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LbSOYh43TFaWX3UEXFlwI6lr0Yx1?= =?utf-8?q?hsC/llruA0xGGlG1/EKSRU5OvqkIOvFzFtvS9BEyqTzE5K0on1El+qrVIl6LwFQbz?= =?utf-8?q?/StB3ZsRkwa/F5f9U+rqmLjmmMPy53zPV8WlmUklxKtlXGn4J8drfKEIYw+Rxh6oE?= =?utf-8?q?84EQJWcXs99MFXSpV+eyhZPjBE6ISH2dEv99WvwJjziTZ3uUjUWXKLCRTuxP146uC?= =?utf-8?q?g6oiOem+kq4uFL3XxZZNdHv1HVauyGRn3/iBd9qFQQ8VH38atKhcvgfpMpcyDibMo?= =?utf-8?q?6B9lMugouaBg6JDvKxa2zmlnOoF7Mu2BhkBlQFnkmTtvmLXBhkIi2h2nDrMB0v9rg?= =?utf-8?q?mB7N0o3I2cGa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XMxNM6IAZGMPvi4rlzS5gkjS?= =?utf-8?q?cZ5UBgHCCphH2WileE6FS0BhZwONE6pJztHcV/uWv+6dZXiJhR0QDj1dLDJr8geB7?= =?utf-8?q?pWhi3mKSJKMjpLCC3adRnhXmpIfANghJ0+B8RbDABbESA0aYbZ/TNIa4C+jb81ryF?= =?utf-8?q?8cI5M95GnU6VrUqSS1aZYhDM1klOBnKP9SzxqIxAF/dxrokN0yUaY8LLvUKYSpG3f?= =?utf-8?q?SXYoPleQk4ZjOLB1WWqqnAmkcNBXL7Qawbc8MRiNvTifpRynXD7alnDw+Er8UF2kh?= =?utf-8?q?NwwtQt7xlMj17Z87u3YEVoLZrM4DQU2tF8l8u+R2Haq6tY729a9luHQ=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: a988b97e-b829-4cf2-ebb5-08dc95c63a86 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 09:56:19.9003 (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: wOIXqecYMEBws73wjpv2ogeZLtE/2K7L2Vig7BGKlg2ftbB0rvFSVDUs06qRXh9NmE4YdMi8nknm/yuaONedUyGvwHKETn1gTTlBNnjVEIk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8679 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 Jun 26 09:56:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 808010 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2134.outbound.protection.outlook.com [40.107.104.134]) (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 90CAF176247; Wed, 26 Jun 2024 09:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395791; cv=fail; b=KU1ry2ReyDK8offjE59WLPiQsYarogy7TbGbkQ5NyA8h98Sro5pJjZ2ib+489zHZ2WatxCKaGT7hlzg9Zqykmi5BVY/UpXZq+rYEak8s1+JQQBiet2OAH17jQoLqy3xPO/QBazoJ38d2EOQQMl2RVPznLpTgaWd4R+UzF6OVNrI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395791; c=relaxed/simple; bh=6B/C0oxZu4Olzt/Ju5SccabXqApih9npj2j2VCrFKU4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=tnPWRtteUR+gl2gLyPqy3e4YPcTC67HT07WH2MXWEzkzysikwIEza52+y2bEbb00Nj8LGLwhG/kY0vNRh66BjXBlUNFvIv42xRPZGcT8TzKNe/aG1r14gkaFNkbmkp0Ox8XfA9lhOIIXnZKrDIgmOe8VdnPjVsMBbS00mrsOes0= 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=q7AEez9D; arc=fail smtp.client-ip=40.107.104.134 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="q7AEez9D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hDeGyQvAwih8MWSfa5JaOBzK2kiHIHUFOeZqBnIKtoxdLq2dnzN42GCV/a0te507Pb2Nb1IjDj+JHlOdavr0V7O98G3CxtPqwresk/vhtI9S0ky2Juw6zUmWqHBsy4uCnbRMlt2YUXetRONyOUbJdt+ZLVG3+wD4gUEzKw3CD5pj24283rx52jdUz+AKDsWmNQapiegkSnGf7mP+twyxPPNDtkYm9Bnzm07JpHReSwLTnpai0HSucwRFxEFnNxs2YWaWCPYdfo6/xxKBIQ0NzZpYzyVQpMNiiYuD2RF1GH3Ogg/DU059GxsfWO4w4zOxbCcEh+3PSwyIMBrV75z/QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=roqc8FkYwAZlQedOCVa4cYily+ZuhxMgO69P0lr/2eQ=; b=UPNz72BBSt2ejUJymk7Y72imditZgf4wE8y7amMSpdehCw4zPk12eL1SjXRm1bFmhnOZNhBkfla0kypS/auBDIYqj/zGS7wrSHNVbiknCrUMNyVFu39zVHrQ5fVM7RIoC5SfnwSezngf9APJwiLI0VvfnMAFUSvo6y1NfSTd3H6qR//SPLvn9CS5g9UzKMZyPr6OmLoixXKzn3CBluA2hxwMk9FvG9+d9whO98h9QMBfVvYcm5ERjoOydNPzan+B7DVkF/C4Kg8Eujgp7SDJL2r6LEjM1DxSrllj3727XsZkatFmIFjY/3raN6j/GryR8eq3hw4tunOswYOnGQjHWg== 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=roqc8FkYwAZlQedOCVa4cYily+ZuhxMgO69P0lr/2eQ=; b=q7AEez9D9+Jas7pYpsPS/94r/oblNuL+Rg9SJ6rW4VpcehZxU61KyD6PsMZaWzufJFlj9T7TSO3nniic5oW96iVlv7PxnRJRpipFx61RHxQ8D5f697GvrbjE9MpoJwNRJHuDBriart8ysOrtiMin+eGma3R/s/hZtdE3V85JDqA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by GV2PR08MB8679.eurprd08.prod.outlook.com (2603:10a6:150:b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Wed, 26 Jun 2024 09:56:20 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1%4]) with mapi id 15.20.7698.025; Wed, 26 Jun 2024 09:56:20 +0000 From: Javier Carrasco Date: Wed, 26 Jun 2024 11:56:14 +0200 Subject: [PATCH v10 2/4] Input: touch-overlay - Add touchscreen overlay handling Message-Id: <20240626-feature-ts_virtobj_patch-v10-2-873ad79bb2c9@wolfvision.net> References: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@wolfvision.net> In-Reply-To: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@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=1719395779; l=10965; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=6B/C0oxZu4Olzt/Ju5SccabXqApih9npj2j2VCrFKU4=; b=1Xt6RN6QiGWGylIWBlZL+TFXHHgw0SKrZf/j0VGo6maqQcpjoAbQkmIg5/2RyqiC1ySeYqgpS Ut3LAYKCiuGDx/OllYJkirABOO/q6X6wtFOE1hnioKMrr9/bpM/3ECJ X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR09CA0118.eurprd09.prod.outlook.com (2603:10a6:803:78::41) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) 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: VE1PR08MB4974:EE_|GV2PR08MB8679:EE_ X-MS-Office365-Filtering-Correlation-Id: b232ca1f-7702-4b1a-9bc8-08dc95c63abe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|366014|52116012|376012|1800799022|38350700012; X-Microsoft-Antispam-Message-Info: =?utf-8?q?NlB5iCSfUS637TwnMNQ+jwj1Ol3pU/N?= =?utf-8?q?64vs176kpk4v5iNmyzzuqyTfx3vfDgFD9MF4DNWFMWNQRcqWdtAqyP8gALqy+c4nJ?= =?utf-8?q?lFPxjCvoY28pJteODIDZVAUg2AEXCmf/5T7w0sJQkBBmP+7Gg6yOyCtdrTX/zxomk?= =?utf-8?q?6+vL3gxvvRcFP78QV4kcXsZlFC5CeVQphgJD3JrEkP2NQMjL8wJLC33UGILU25G+s?= =?utf-8?q?BGuc/lyvC093P9vtl785gfUEzbEHT8etCljvHrqg6X6/XL7m8c/XjYQPmuFi0ulgf?= =?utf-8?q?03wgOmUIWKdO1RYccOKOQC54tLlxqvnvXPh5c2ux+91A6OfvdWKB2asZzeUqvBec+?= =?utf-8?q?jFXXWeADyQ14FIsQNKqpNYR74v1rf3gtL8Q2XkaS0wiUcNxJcbo/uxhVY1Mf8c7wU?= =?utf-8?q?IWUeRSOmqUc+JPC/bH0ubaiBuB49UJieBilERT5BVJbkxT2MymaZ2TlN9geGgNWVt?= =?utf-8?q?sbawH3Uj/BNGoHFMYY7NHprGvEbn636/XCqK+EtqSu2v3x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= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4974.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230038)(366014)(52116012)(376012)(1800799022)(38350700012); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PJqm4jPznvpBOqyl6L1LXgn6t4sH?= =?utf-8?q?EubyT7xQL43WRp/ZWebknhXcRiZHAU3rI4M3vNpqaDmFC8faVfGFWBvhKf+nwaqH3?= =?utf-8?q?32HNcRiL/SuP1Jb0uQCrr+rq6gJhufVgoWFLnznrLFyE9sdz3OfqJ0u3aoUFOlYuS?= =?utf-8?q?Drzkwg7fns3F+g67tYAz0miriFQB/U4OqN6ldf3Cus9/cxELj24GPfUOnhiUnLmUC?= =?utf-8?q?zvBQSG3d4NrLAOdMo5fUj3619LcHKwAyZpx5wCU8PpSGyOE3L136RGsk5ZJpIJYKL?= =?utf-8?q?FX2/hwALLY3sQmzkFz8SbJhb/W5rNsBfQApvihUJNgFKzLuxW43Shq3OV3dXPJKzM?= =?utf-8?q?bdjBo9B38G6UsDdMZgYX05eFjcMBaxYDnAkb7Bt4lV6UTANjwcH7f6c3wdLruBRrP?= =?utf-8?q?ZkjUPfX2KbkO686EsJro5u0/DhFIS+jBpqcPRnuoifD5CCltPkz9sUiIWlU9baaVW?= =?utf-8?q?BXGdCdGK/LbHLXZGHKZtdtD/kKR9rIxQ3R8CU8Xj+tbKqqe1L8HGx2dsh6lqCYYf5?= =?utf-8?q?cItow5Q4zTbUXr5Q7b4GgGxxE9fJemVTLri36eql7IQNP854HT26DCgwiQAzP/TLV?= =?utf-8?q?0f2JRStFjDuLmRFMubUZcdI9mRzpvdMnLHRjcnTpCgeDea3wGRD4nQR0m5MHoAUhC?= =?utf-8?q?el16gNQjA+pSDyAOq8PPWfVroJmKc9xx2GUmy1wl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PMFn97FgX6thIYQ=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: b232ca1f-7702-4b1a-9bc8-08dc95c63abe X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 09:56:20.2488 (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: xTDt+aFBU11V36Lnsw55YASfxItcHltMBIPHhyo5g97C8ay3PIEYR8Of1a/vTS5cFoz2vcEj1E/auoWq9NyqbX0oj/hCyWKET4wGX2jpCcc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8679 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 | 264 ++++++++++++++++++++++++++++++++++++ include/linux/input/touch-overlay.h | 22 +++ 4 files changed, 294 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 2ca8f35dfe03..fbe2824d99c1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22739,6 +22739,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..5f839b206358 --- /dev/null +++ b/drivers/input/touch-overlay.c @@ -0,0 +1,264 @@ +// 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 *overlay, *fw_segment; + struct device *dev = input->dev.parent; + struct touch_overlay_segment *segment; + int error = 0; + + overlay = 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); + error = -ENOMEM; + break; + } + error = touch_overlay_get_segment(fw_segment, segment, input); + if (error) { + fwnode_handle_put(fw_segment); + break; + } + list_add_tail(&segment->list, list); + } + fwnode_handle_put(overlay); + + return error; +} +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, + u32 x, u32 y) +{ + if (!seg) + return false; + + if (x >= seg->x_origin && x < (seg->x_origin + seg->x_size) && + y >= seg->y_origin && 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, u32 *x, u32 *y) +{ + struct touch_overlay_segment *segment; + struct list_head *ptr; + bool valid_touch = true; + + if (!x || !y) + return false; + + list_for_each(ptr, list) { + segment = list_entry(ptr, struct touch_overlay_segment, list); + if (segment->key) + continue; + + if (touch_overlay_segment_event(segment, *x, *y)) { + *x -= segment->x_origin; + *y -= segment->y_origin; + return true; + } + /* ignore touch events outside the defined area */ + valid_touch = false; + } + + return valid_touch; +} + +static bool touch_overlay_button_event(struct input_dev *input, + struct touch_overlay_segment *segment, + const u32 *x, const u32 *y, u32 slot) +{ + bool contact = x && y; + + if (segment->slot == slot && segment->pressed) { + /* button release */ + if (!contact) { + segment->pressed = false; + input_report_key(input, segment->key, false); + input_sync(input); + return true; + } + + /* sliding out of the button releases it */ + if (!touch_overlay_segment_event(segment, *x, *y)) { + segment->pressed = false; + input_report_key(input, segment->key, false); + input_sync(input); + /* keep available for a possible touch event */ + return false; + } + /* ignore sliding on the button while pressed */ + return true; + } else if (contact && touch_overlay_segment_event(segment, *x, *y)) { + segment->pressed = true; + segment->slot = slot; + input_report_key(input, segment->key, true); + input_sync(input); + return true; + } + + return false; +} + +/** + * touch_overlay_process_event - process input events according to the overlay + * mapping. This function acts as a filter to release the calling driver from + * the events 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 event + * @x: pointer to the x coordinate (NULL if not available - no contact) + * @y: pointer to the y coordinate (NULL if not available - no contact) + * @slot: slot associated to the event + * + * Returns true if the event was processed (reported for valid key events + * and dropped for events outside the overlay touchscreen area) or false + * if the event 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_event(struct list_head *list, + struct input_dev *input, + u32 *x, u32 *y, u32 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, x, y, slot)) + return true; + } + + /* + * valid touch events 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, x, y); +} +EXPORT_SYMBOL(touch_overlay_process_event); + +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..cef05c46000d --- /dev/null +++ b/include/linux/input/touch-overlay.h @@ -0,0 +1,22 @@ +/* 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_event(struct list_head *list, struct input_dev *input, + u32 *x, u32 *y, u32 slot); + +#endif From patchwork Wed Jun 26 09:56:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 807619 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2134.outbound.protection.outlook.com [40.107.104.134]) (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 458EFEEDD; Wed, 26 Jun 2024 09:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.134 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395787; cv=fail; b=n0h9h76qQoENoJdJFzw+lt/F7Enc9C7eFHl0KCV9ViF2DG0Ye5lpLpgf0Ea3YaeTxcVLmFMt42WCsZ+uGJrFpG25dxtqzEwkAdiLsm+7mes5wsQQG/lLHjluPFNIKHD0Mieje2p35Wd1j5x58n2ZsUVjp1sBY4S18NNJXKn9uVk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395787; c=relaxed/simple; bh=p9Jwz/8rK0zTZPWVuIL6lA7Sdrjcu8RH3+Ur4C6kCgs=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=AByjWg9YkwzS8YkuU378msfylBc3YAi6Fl1cK5FnrcW4cepGHgCH9hEHl7WrYkpXcEw5wZ95x1il01IS8DQ8+9W2seA9PoaLu4070ORWMX+KKwNaldQ4NvqSlljp+4VeWa0IFESKz6FBUrqTIXX9GPyPCks7tXmUKb80Fni9cBs= 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=WnYQyLHy; arc=fail smtp.client-ip=40.107.104.134 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="WnYQyLHy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g6fT8LjrlHowDNSyLJQiEMieRicvTLas9fuJKFa84xpbai2pCJTVLGZVGOOhm5fQsoWrXk7qcQVkxFE3kP2yi5oDClAUQoQoU1fkX6ElR9YYm/ZvS6YV3CwyPO2Do5P8nD6At76J+asELpp8hRFlhNg/kEviAMqranfh6JLG1s2S4oJKvctCwZVPNuC0rm44kRj+MBV+h4/LSQwtIHo64LTKidv+Gq2NCsGlIPUNv7Z4IgoujI4B2Mfh/rA6+xxswHF53MiC4Ng73NJz0l/p4QrfcZLRDMddnNrMCSX+78yU0U4/AgDLrnU+rf/4JzZYWE6ZJjzvZJ7RHhpoka/mRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0u1KdYXdRmqiAc1PitUbeMUNPuGUu3updOr0DLsVY+c=; b=mwOdxKUnYsyfHLE6UHckjUYlYSUGagjYfVWyymwPaGzAFJ5P3h2VK+1R6LByFDtKbooWKUTnVSMavQVAsQCgteclSinZPP4n0TAZG7JJ2D1JryO7IibvrYaM+9DHsWqyPtlJgFz1zBN+3YhEOTIPsJBrE51H2fThWrQk4IlFiCD8sCDxEEj0QDhuNkx4NzJ8iDi3F5ayowaaVHT6FTqGUPsQXGX/0EXp5wqzC2r7xm/LgkGgAFa1ZEVYvNoplCuzgNJUXtFs+/m7WiaCOlWqb4ZDQ6VT+Pj4APXtBTKIltSfscoZxDwHj6sKV3n4SdT/aZ/HkW7s8njp9P/FN/y5mA== 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=0u1KdYXdRmqiAc1PitUbeMUNPuGUu3updOr0DLsVY+c=; b=WnYQyLHygJav0em+nIwujeMZZIZ2kVCPL0dSgE49QjFBFuXZhlcQ6cvenmBhqw2YI3rINXJFUQDn7Dx+SF9IVvxR9/ie1GSXDNIO/zyEt6I5NDKgAj9W0Bw/GSC3MZyNElP0Sedk6Qo5uUECa/VY36o0cGw+266HfPiNn0dwdgY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by GV2PR08MB8679.eurprd08.prod.outlook.com (2603:10a6:150:b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Wed, 26 Jun 2024 09:56:21 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1%4]) with mapi id 15.20.7698.025; Wed, 26 Jun 2024 09:56:21 +0000 From: Javier Carrasco Date: Wed, 26 Jun 2024 11:56:15 +0200 Subject: [PATCH v10 3/4] dt-bindings: input: touchscreen: st1232: add touch-overlay example Message-Id: <20240626-feature-ts_virtobj_patch-v10-3-873ad79bb2c9@wolfvision.net> References: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@wolfvision.net> In-Reply-To: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@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=1719395779; l=2517; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=p9Jwz/8rK0zTZPWVuIL6lA7Sdrjcu8RH3+Ur4C6kCgs=; b=YOY/sceyh/9SmhZoZz1Yj0SLpNlA/xWw+BsDI0zl/k50nkrYzJthkY6t1JZlxSFiT4uWyM01V d0lQtx2XOngDq8b9AFcbh/hpKjdBCIr2ug3XBLMx0/VEh1IM58AgM9O X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR09CA0118.eurprd09.prod.outlook.com (2603:10a6:803:78::41) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) 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: VE1PR08MB4974:EE_|GV2PR08MB8679:EE_ X-MS-Office365-Filtering-Correlation-Id: 373c5a69-c95c-4d01-6a1c-08dc95c63af2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|366014|52116012|376012|1800799022|38350700012; X-Microsoft-Antispam-Message-Info: =?utf-8?q?oXaIS+ur10AgqAWwyDjRebV88ISRXwh?= =?utf-8?q?frFYRl5Egr2MLXdnE8ahONwSQXS4UEC0WztVwLfQpsjcUTmYpEbrPY27aVQRMUIbj?= =?utf-8?q?ggiPdZ8SpaLZI7d5ikPjkAeT9IuwTxPasim1bTpDAebJuyK1ywKNIIEi952qTOBDv?= =?utf-8?q?e+BWGKEm1FnKRraJ8Ruh8IIGg3ZS4L/W4WKRrMRcfBGsUijxtnS5SMEPrT4C//PHC?= =?utf-8?q?l9F7Br4LRCLaSoAbpymx6bwL+93i5OkdfK/jwd7+ogGuMvbXFNYLAIfbLJZ4+SmFY?= =?utf-8?q?dxOdALCELHg7Dryn3zDzBjx8xGHl3J4yuSqdfFB02VqceStkW6b5SLHO5X9lpjrJU?= =?utf-8?q?kHQKp/2vH/+FyLl1OsiaiZsig+X3XWTrPQorHq79XXCX9A1jiN+MzdR92PFWUsSDA?= =?utf-8?q?vkTGjZaJvvAN//AVWfCQdMx4KoV7uOXfPP0qPcmK3EgJqYuZj7EjTMihIFEGKddSi?= =?utf-8?q?Bk6OEffLmZ7Jb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=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4974.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230038)(366014)(52116012)(376012)(1800799022)(38350700012); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?BCdLtdx9TUAsaKjL75JNMIxUz8wm?= =?utf-8?q?lM/xfvt9+eNEPghDKZlEXDJeQTgG3N8G5qdGu6zfc3cehX3uNueZAn0hqyHUVdYAS?= =?utf-8?q?dsCrFNaMZMjKJFbZkjVhU8bEDZJKPWaC6XkEnV7Phsi+bZM1P1wJLECKwGKu2kxBu?= =?utf-8?q?JzQGXWM4gL9muSj4oj8bMOU5zVTv20KmqbI+Fz28h/E61kKA59VDK4qYOE5L+2do9?= =?utf-8?q?PFbpeyeDaKUKysrKYXpgVBUHu7W791Ul7c3XI1iPdKGT3KAZHqEsq45poQ5XZ0x1S?= =?utf-8?q?cgSPPb1aWLazUvaNNI6pT3HF9PtRztWfWolY2qjLTxiTTdZeJJjBYzO3oo8Ffg70+?= =?utf-8?q?IkMf/ouC6bGiezCfQjDQJVsec/ULwvsKMFdtyAjVOtISTxDV393fT7ocu9Pf2ysd/?= =?utf-8?q?fuia1zejpXg9O9XTkMxjw1JjiUSUmowavjtJqDner8f2CdKaPF5P7EAlknWJkU5PS?= =?utf-8?q?PSltyhleGuMQjIGVczog/0XesxQSX/tc+4KK3mgUFGJCOLS32H7RAHLOksZdgtZqf?= =?utf-8?q?5TmqnaVfEjcHYCjO2+zQrPZpWLWwtWnvGAOjehoQNitDdrDoeXsqhdQ+oa3GAE4zx?= =?utf-8?q?5RbEbJ9GSCOUF7FymrRBpDA7zxOL6PjYb4+ykd8WU1Fd63H/As1t7ETm1afe9EwIh?= =?utf-8?q?BthDKMienqQpBarr8WTwghmVpDJUoe3g3/tL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oklto=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 373c5a69-c95c-4d01-6a1c-08dc95c63af2 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 09:56:20.5690 (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: 0ZIjfpY8Dp59xtqtozBUi5ihSNX/5cxnHWgTJ5Vwj6InB2PmPW3CM9ml5mKLH7jlpW16aheyDmzxoFQ7IPXGfRG1H33q/wwLK5abCW7+E/8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8679 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 Jun 26 09:56:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 808011 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2136.outbound.protection.outlook.com [40.107.20.136]) (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 D1DB116630E; Wed, 26 Jun 2024 09:56:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.136 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395788; cv=fail; b=Our/tYqatWSXv9K9Z9wNac3r31nxjJXHrk/orllpExn9bmqsTJajEFYM66o7iyHlMxVz2ebtQrPvfNVOK+xvqenTD9QKJGIx/v1WFcG7Ax9JWmOg/izoJePQwsxjLYaCI7wZLjKr0LWfNCeZUdilJwTmGaxQ/NIBbXKtMgOiv1g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719395788; c=relaxed/simple; bh=vsFZ9q+ydDIxRWmbs1NXOo9kzGcFogQc7xsPDOQ5BJY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Ltj0y9ya7MUzUX+FkDu0stT3DSnADCSvVrtujD6HmKzkLnAGmvQ4C8l4PSgQuuCjk20Jk9cQ0iMc0L6aFYhtqQ4ZkUNXe/Y/UyP8zgaY4x+D9TWOYjlhUUNNkSABq9vmunwDL7o/SDhOkb9MFZ9pgIEXZULWrmLpsQ3Xm+mtvQY= 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=TAK4nxUH; arc=fail smtp.client-ip=40.107.20.136 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="TAK4nxUH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+kP21oWfuAWUYP5wewlED4lbnGbqZor2PXRk28oAAVtCI5tBv82XHFxfepLT8HRHldyuZCSG+xcWMbsael0w01Q9UUIVmI0J1xW/0NPd1/0NQMaZaMRIxzzHf6CnGB6wHYkvhff+rR85CPDgPovsbxYxh92+O6tmFNHdtOnwbi8Zb6iJgq/TyueKE0qWCeSNHn2Y05t9I0dcHEayrzABuhJTOGHsRV7Zz0lapS71DWqGlkPhWXw8n0TmZZ1QVNtd9bMNeOS8TCOEytUNBDA9mQYZ186ZT+Lq0TBhdJ/r6yykggl6JX8/pO94wdFqM8JxNO9a9RKxPNa9Sc4o6sdLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=16dHfUkG6vspy9E+xLRgyQx+eEGZf+k0YLqnYjZmSGE=; b=PBW9+kxuYtONRWYyx8gCLuWZoskORxQSfZBatC0XjSkQPgcF5dutc5OxPyvMZzD2vR7vWMkuMh/NhFiuKHeX2h3H3nDpDMDyr8W9Yn3KGEiWziib2vXhNxPGrnFL1iSumH92sPEIWV3HURj3OxUwtzEYoV42KK1ociuswsCo1Q6pK43OyHXFeGPl/kYGsUqbWhK0vYMv45ZrdDLQ3T+Lsgy9V5i1wCjo1mbKcrJo3/I/4bsiRKA30POUn+t+3zw7ljMBE118vtD00DCObekyl2bmEjb7t6UtMre78xV4cxClylqE07Vn5k8CIAXwqz8apw8rFDQ6xnXWX38MUhX1hQ== 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=16dHfUkG6vspy9E+xLRgyQx+eEGZf+k0YLqnYjZmSGE=; b=TAK4nxUHW8eP38+gd8WajBFs1S0FbGO8SowooB7s3pJw+GkgLM+ZVTfRiDiriJ59cGBijWayXuVFu8OwSE0yEEMvOWTLCEC0MvpFd++DjXUMXgw9BgacBe5u3sJZZg4A3kIkHxA6MCwZkgE5rimSM4grkIbFllPeR5g2z6Dp+4s= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by AS8PR08MB5893.eurprd08.prod.outlook.com (2603:10a6:20b:23e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.32; Wed, 26 Jun 2024 09:56:22 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::a08:11be:8709:f5e1%4]) with mapi id 15.20.7698.025; Wed, 26 Jun 2024 09:56:22 +0000 From: Javier Carrasco Date: Wed, 26 Jun 2024 11:56:16 +0200 Subject: [PATCH v10 4/4] Input: st1232 - add touch overlays handling Message-Id: <20240626-feature-ts_virtobj_patch-v10-4-873ad79bb2c9@wolfvision.net> References: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@wolfvision.net> In-Reply-To: <20240626-feature-ts_virtobj_patch-v10-0-873ad79bb2c9@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=1719395779; l=3367; i=javier.carrasco@wolfvision.net; s=20240617; h=from:subject:message-id; bh=vsFZ9q+ydDIxRWmbs1NXOo9kzGcFogQc7xsPDOQ5BJY=; b=55Ks+AEa+N68j45g05Yo/HraT+5FsMOqFEGQ1g5gLaV19GDbogCTq5FrHnjlb51TjQv0g1rS/ 4kRtBurCQ9fD613yTeuHd6L14cGDh13i4pP/MYNGXmPrqiZOt6e1b0g X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=hfASRUP6l4lf3Lo2mjLM085/h37dT3m0Qj1HejXDPDc= X-ClientProxiedBy: VI1PR09CA0118.eurprd09.prod.outlook.com (2603:10a6:803:78::41) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) 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: VE1PR08MB4974:EE_|AS8PR08MB5893:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c37b82f-737d-4640-adbc-08dc95c63b23 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230038|366014|1800799022|376012|52116012|38350700012; X-Microsoft-Antispam-Message-Info: =?utf-8?q?YyBXoLZ3puSr3lxgSKTt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-8?q?WxrZDCrAp0hCR0/fuQTjdlQ5oA+cduNKJ7YUx3fPOPiXlrfIl4whCbsfH/UOgm1tD?= =?utf-8?q?Ll5m2ag5MHSfrxcsnS1mXyI3pB3UEbbJ1u1HNJNCl/Z1ivCup9whSUlKYmTLuiLqi?= =?utf-8?q?Di4NbLIyZ1Yv2s3qsE+aUBjOGdfFTqX3gixJNrr6rseDCTuCGkoE5fd6POORUsS6O?= =?utf-8?q?KMQGRP+KuNAxaIdEfNyMbTs7ZYDmiikwf88QvLxHAaY+/rWy/we+yDUVzTF2dstsY?= =?utf-8?q?Bdj60g5o24d+2O418jy2tuxTVR/aXGTivnF46NUHYK7vU/ely7nvxZz5Aq/ePwS6V?= =?utf-8?q?0ChMeozAUOB4Ye2BzxqHUO0x3TllBL/SAOPiZymGHhmpbmom00AjlBYQgkSGb6APY?= =?utf-8?q?QnhRbsbVNsVAicU+tDXkU8oP5QWvPMBeTNfEBCQZOMiRYK9ga2xxRkps=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR08MB4974.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230038)(366014)(1800799022)(376012)(52116012)(38350700012); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?tirxe1zvkxLh8Arr1Yj0B+YepEVQ?= =?utf-8?q?qRSBAjExISTl1TmsNkOApQ66D8f03hH6OtkV+XS2Zic6V/q5aDFYLUU7RHBx2jtxD?= =?utf-8?q?97zuzH9h/kYPSSi9JFNiRQMZZnFpIO6z1b+J8a1N+CZ+K3YZ203wOLHyJ2JzBLwCu?= =?utf-8?q?SvtAIurS4YOU5S4uCBJfmitu514dK2d2fAwR4iHyX4TQdR4gF9WU/zCb4tymVx8j+?= =?utf-8?q?on65hnrcR7xMg8KuCKDW/0YqmOshX8Z+LyUbFutf36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y8KN3wpd1GGqermtBS?= =?utf-8?q?QS5U7aAY4AJ6seaJqSPjvJ9QsBMyZfMsEf+H2jfOEtivQac7HgAk+s/Ut7Yu750/H?= =?utf-8?q?9hqt1aX6FFg/Ww41RX5WijIbT91e7F4SQSsL7HrK8beZ8QjsgPfkmwPRW74ypDX1U?= =?utf-8?q?gJYbPknAdN0/yYepdry/OVtQpVJ83Sbwerj8e0cFMna2n3AFSYj/RA26QBN/cPTi7?= =?utf-8?q?TZYIPR3LEsW37uqDi90Rm7j4hYXVFKGlpoEqHgkz+s+I1CR1bGogLgoGfsuaLATce?= =?utf-8?q?m2gkuWwPQEqVj0PnrEQA3EB5ak7ugpiJb5v1UL9ZFRdbJAaUBKJRUfP6jbkfhVFYv?= =?utf-8?q?P5vPmWJT4w13uUK5k01uPltTkI3wT2FmU6vwCJsGyUivr/q6cnyJrEpQjq8/Pt09o?= =?utf-8?q?CbwWQjve5jDoYRpEhh/rVOi/JTbdniLYTe36ec/u/MXmqgcnPJkhjN4=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 8c37b82f-737d-4640-adbc-08dc95c63b23 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jun 2024 09:56:20.9499 (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: Vrr0sksCYcSBfF08uaG6rq0Uo9K5jafWveXK8u414RiAzz2MAqtXJDIcrBnUivdLoLmp8Try/hFuJMXYKG1h1O74TpctW6n9IfV8H+9upkU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5893 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 | 48 +++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 6475084aee1b..4fa31447dbc1 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; }; @@ -138,14 +140,20 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) for (i = 0; i < ts->chip_info->max_fingers; i++) { u8 *buf = &ts->read_buf[i * 4]; + bool contact = buf[0] & BIT(7); + unsigned int x, y; - if (buf[0] & BIT(7)) { - unsigned int x = ((buf[0] & 0x70) << 4) | buf[1]; - unsigned int y = ((buf[0] & 0x07) << 8) | buf[2]; - - touchscreen_set_mt_pos(&pos[n_contacts], - &ts->prop, x, y); + if (contact) { + x = ((buf[0] & 0x70) << 4) | buf[1]; + y = ((buf[0] & 0x07) << 8) | buf[2]; + } + if (touch_overlay_process_event(&ts->touch_overlay_list, input, + contact ? &x : NULL, + contact ? &y : NULL, i)) + continue; + if (contact) { + touchscreen_set_mt_pos(&pos[n_contacts], &ts->prop, x, y); /* st1232 includes a z-axis / touch strength */ if (ts->chip_info->have_z) z[n_contacts] = ts->read_buf[i + 6]; @@ -292,18 +300,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,