From patchwork Mon Apr 22 10:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 791056 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2130.outbound.protection.outlook.com [40.107.22.130]) (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 712BF50280; Mon, 22 Apr 2024 10:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780469; cv=fail; b=hqSHtawKvCjs/4HXdwGPtMqTa6N8scfTXgfrXP8wNoX5VbTWBwgS5KaQ5w2XhqAlTWePjp9WJ1QGBeKpUiPipoYInFZ9wYqC5BGtEOj+DUZJi5qO4/zyjsXwXcMPamQgNyzuW04gpyJpd4WAhneN3t9vCCq8Iy0TQdKsxTG6wsw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780469; c=relaxed/simple; bh=We4djLZrQmwTewoy3TXvLCuEcuRF2BZn64gf0yEafpU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=nejg7ieqakLzDhNlsMXwTVasVLI3BAbi6BJqwyJA2sNw8BNSkkGXlyhtaUX3yEBugU2YJUGCrSu1RrSMJ5llr2ZVvgLBWL/FhPGBi8fHBUpyjTlzvmKFTbMfBXVz/GITmKH//qMLX/6lInYVL7NB/r7Mk//NiqZy1+ymf/9WNec= 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=H8WUzLp+; arc=fail smtp.client-ip=40.107.22.130 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="H8WUzLp+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iVYmKs2EJB0bRBy0l+ZPHIz/FHjPFZNjU0j37qLoSakvDZIX0M3wssO1R/9qavRGcnfqwCY3W+T6JAFbRrXa9h10opyRN7k/k4U1zF3fTk24HOU2dAv5C6ZcbFfMbhu00DYzrd3CYWwzstZLJyWUMadeqCQDOGjAR8SI7o31yHJK7XgJAbiMlOXC1X4wY05RLElwfyS/tLq6iUyJ/gRtB4/p+gNjoHhBaIelOL1mihj/rMRHx+RqB5GU1F2nast20osPGvL5Z5yeSi7pbT7PhVXRZVOx+BdIujZmMk8T3iYshr9S5ZooOfAG9TXnaM5wcu74CsafVsZkfAHKxp67DA== 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=adibL7lvQiAIXT1YwZmP5G7daAB3Kuwxo1L9KUSFaz4gzsP4EMFr9VlboIJIAW5f+bybEZyG0cKh/LtY2KHgCHYRfgUnndNhER2HBPUeTB1WnkUqLOsEt5C+BQvNpqpaXs1UwjLL9TvOBOqHuMHuu2DxD/0VPbYXN6Lbhon2SqZcA/JxET1o0R3PWv3M1SFXPTF362hSrI8lcfYK2RUhCud50fr0+V0QvDHrRdZkR2BlQ+YYm4PHrjI8UUa7s66+T7PYOmzkJWynIS0JKqzKSU1xCmZp8C0DpTh4K3mS9yV6j9BnCIeHuBd9jwNDF84/eulzpKRRXowUT51cNyQ4qA== 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=H8WUzLp+rXEtwEw0nx3+XvNC5+3Gt/E6g08B8H33aD2+2C0qLxfgjDz50rzebpWQU44reH/H/vhl54eNuaUd1wT+1wWRPh3Lb1JtZv/rnHwhwi8whf/9zw+gmZkZsSdPNdUxv/DysUj5PJMqjrMrVEuPcwEpjYJWDuJew8nGBWE= 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 AS8PR08MB7885.eurprd08.prod.outlook.com (2603:10a6:20b:508::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 10:07:44 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040%5]) with mapi id 15.20.7472.044; Mon, 22 Apr 2024 10:07:44 +0000 From: Javier Carrasco Date: Mon, 22 Apr 2024 12:07:37 +0200 Subject: [PATCH v9 1/4] dt-bindings: touchscreen: add touch-overlay property Message-Id: <20240422-feature-ts_virtobj_patch-v9-1-acf118d12a8a@wolfvision.net> References: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@wolfvision.net> In-Reply-To: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@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=1713780463; l=7148; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=We4djLZrQmwTewoy3TXvLCuEcuRF2BZn64gf0yEafpU=; b=iUybbeYwnurMTqQP5jqT8XMsCqrn4WHlnrhQK0/wtZO9q7xzpPON4JsIdKsSJ7jipH6YpeGNf 0/Sb8Utv9m6DszcLtI1YmBUo8Pg5MfXpdLBWXrVNIYXamQyhxFPe/hs X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) 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_|AS8PR08MB7885:EE_ X-MS-Office365-Filtering-Correlation-Id: 11e8eb70-faa2-46a6-d2c3-08dc62b40da4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?OT4cAufpRGXFq2KujawXP371mnXOvCg?= =?utf-8?q?UehzJ3Wb0mpm34/UoRFnYUDn1e8Jitrf64oDT+8PO2JhPiL+bD7m00i8lwQQPlJA7?= =?utf-8?q?BHOCvPvAge2ZZlamtz3yNGyZdjVv0oJCgMr9u7uILViIpsSwWTdXOhN4233mQR/oI?= =?utf-8?q?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xw7xvYjub3yNr09O1+1NG00KpH8brWolDFtOBF49mTLuq0ym/B5Zd?= =?utf-8?q?YiUha0Ta+RyImOsvBN0MAZkCFuyk6PKocCLxwoJGk/S74t64IbOWe4ATtR3c5geeX?= =?utf-8?q?OYd1wc4E8fCfwr7UOKVeGMyJkqpvabWD1CyWyTcgKJ7gPEBwdg/aO/zeuWvn8nrIz?= =?utf-8?q?Dzd2/+PGV7gJUmKpmm19bINVzUojockFar1z6nm9YdF3M1KNxNY7hXNons94KSvrl?= =?utf-8?q?8OSV5icizBIwtOhBqVgNpwdtDgQDKTzxSEw=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:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?V/6rotWEdZBl+6uFOlZS3rbspTb8?= =?utf-8?q?sGk++z9vaeLN0qsgHnJMGBEMuWH70Fu+OXydQ3R+hudf/lj7FpfIWMIBIdIgXm1kH?= =?utf-8?q?jIlelYnZ7cUVuAVQaAA9qmzy3znNme4rVtuCHQ0vTIgjKomlaaKKbtaZB5Cf4N6Zn?= =?utf-8?q?78inhyGp2xG+e5FPWhG3YpcF9wsOl+n8NQ2Pn6X4WAOnHVXS2+bxMZHUo2NULpPbW?= =?utf-8?q?E/MgCpLhrisUvbiS/sVDrlmvsqCb4c7pzLbny8EqybxziPs0Yr80TlL5Az2FVz/Hq?= =?utf-8?q?QntsA5LFeVk8bvvhaoB+2RX29sNbiOzpgwmeasfa/xio2dZKK/ov+pvPiGXHC79tJ?= =?utf-8?q?uKvPJ+ytlJfQNxm16MdqIpxYSyIUk8Burfv9Oa852naarswNnlNveuf0CyM7tdOMN?= =?utf-8?q?KPsYQVhoId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03X/cDKqY1mCOadG+rQR1kRf6Oxj/I8QrqHtPZ0dXnhJv+6tLN00PGZUkf?= =?utf-8?q?A+I6AZ0XvCI6aMivpp5QtfFxTGGLpk7UzIaToudFlD7k4x/EAjsvsXlNAW6Hh9axW?= =?utf-8?q?K4TBP//lojHWmcnbePFqc1yXhC0HKAV8ZtKEbrBzw7f/Urn9IDlubHumA9xRp/R6X?= =?utf-8?q?lAqAIFl5UTAkHUX7EThOHdvhFiyIt3u5Hr1MMrmKyfWzsxWOYZZa/puAi7g807Tzv?= =?utf-8?q?dzDrqiKmN/5TkCS9cfH2Z8gGrksuBQDSIwDpxtnUmVlv2l4RZqfGb+s=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 11e8eb70-faa2-46a6-d2c3-08dc62b40da4 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 10:07:44.3662 (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: OpKWzflexGb6shr0zRBwBw4vKr0oXv5MB3169SMSahMfovafnb9qWftXbuWkPA9lcFaBk9o4DcKvG9RuUbaeH7/Hccf8DalPaKImcCXB+u4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7885 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 Mon Apr 22 10:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 791055 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2130.outbound.protection.outlook.com [40.107.22.130]) (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 CC13B13E021; Mon, 22 Apr 2024 10:07:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780473; cv=fail; b=iPLwM1qb+xgpqYlfrxMU5I2hCIO8lwOElIYmxe4PMKqR/lPfUshydaTBVEZNmhthpvY0mTLe4B6n4q56KR43F0b9gAu1GXH/a285piytcjVCwHoxA3QI4+QJ3BAbn++5HRAQ6WvC9PyPBHcn05wiUoy8cjV6YRCu12V1mslhlYo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780473; c=relaxed/simple; bh=QN7FQA0Mrk3ueSx5uaFvLMxedIgNWxDjvIjBIP9Jc8o=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Vaz7GQp96CTCnMBVBa0Mp6x7uXNXzYe34uoY4Ajv3nkzCY5GttcKf/fBKjttGvg08hHux2wgqSvrkp5Mq3lEGPOzIe0lBwktTwHyniwq498D6YeF/TGaeDZ3Hnet8sWSRjdvHOiDbpxqBLD3+iVSTRtED5tXfWapsQ6zx9oofds= 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=wNLZ4o8t; arc=fail smtp.client-ip=40.107.22.130 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="wNLZ4o8t" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QRueilaxrTgjcm3pK5OcodbaliNtvwHMW9GxtMa6GdevkTXIw0MtDKNhO4ftT3WUmWblmV88sOlSVMILZCVe+ZcwvsKS/haCXHD925GT5zbCMGW4ZkIrqyL8wRdfZZer7cGzIup6nqmnghP+Ed7UJbmTBw7PYS6afl5tu2edK9AUtuIj9Ocf39cSxIrKYpSf/uJXKxJSHmctCeTkQtYnAa/G12Td8D90mm2emYa7x0zqLUsDyjoZC+2B9xS2+D/24SaWyVywQ49RGZmK2M9tK8LlMElRFocgR8gUOz/GEe3xmttFrE37B7YsRPxsTKP2GReGcbBsxJPVAuMiYsLCrA== 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=WRGBZxb5HWY1Hd8a6DnjerU8+6I4KbJy1lyTPsgbDlY=; b=XlPGGVfQGZIeLFpIVWgOs518ptLFCt5xk52g4k94NZduJsBPPAaOkOk7ds+4poRjOt8//CfaZkyTHBa8rK9XHwM+vohY0TlefQk/lKMpaQSJNNPKOPhwdrEV+8zZ6a7a8IKGgR6GfygT4ovb5aFPSAwC1lzb1hy5sk0rCA0vZJv2oU8Dl0ByGEexrT3ejlytG9KAuHxj+imEkZi1/w3x3BqozZhzoccXfsZz2LSAvPkiolfy0Bb1ZXMBtZhjvuICgB8UavavJZrG9H+p7NAK+uA56Gf3YfgxOnsCLahj76/Gga/kKZx6J+oFPPMBwS5knKIPJH6Ck2Sjcb19lo7KSA== 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=WRGBZxb5HWY1Hd8a6DnjerU8+6I4KbJy1lyTPsgbDlY=; b=wNLZ4o8t6btfevFnIEs9uNuVHVHeTPt55uZTUTB43aKfxyQ9wqzn4FeYKjiRLZqJ08ELL2JzqU0RtYDRdLRFyILQlgFkfWJtjxM62F+QzOSfbxF3ngfYMVL+fn/jMxPH0CgHds8zfZ7z0As/eWW0dTMFIT7MYtjiUrHOaPQKgu4= 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 AS8PR08MB7885.eurprd08.prod.outlook.com (2603:10a6:20b:508::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 10:07:45 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040%5]) with mapi id 15.20.7472.044; Mon, 22 Apr 2024 10:07:45 +0000 From: Javier Carrasco Date: Mon, 22 Apr 2024 12:07:38 +0200 Subject: [PATCH v9 2/4] Input: touch-overlay - Add touchscreen overlay handling Message-Id: <20240422-feature-ts_virtobj_patch-v9-2-acf118d12a8a@wolfvision.net> References: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@wolfvision.net> In-Reply-To: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@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=1713780463; l=10914; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=QN7FQA0Mrk3ueSx5uaFvLMxedIgNWxDjvIjBIP9Jc8o=; b=GvRLG4J01whX6SzbRf7+dMUnIcFjy3M3vUtJ+XIWvTRh1SPzoNCA5Fd3tnskCGHh26JEGgjnI zmFo2/vWq0BAycxVg9MgeOJioaY18BhkXis2JZ2KYdaA1EVzASt8H03 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) 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_|AS8PR08MB7885:EE_ X-MS-Office365-Filtering-Correlation-Id: 04118b2f-6482-41ed-3738-08dc62b40dde X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?QtsA27ociexLfbhN1jLMdIE4NWg6reB?= =?utf-8?q?XRVzuNfq5wqWgVrvdResPMNKYZfs2BEa3n9JcKBC6AkQgewvhmpMWgV7Wl7Jl1F4T?= =?utf-8?q?DScVvHKcbps4n/3PVdHlKEaG1kprdojRbZdecL/IA4KKcZWmJlTfTztpJHRfpoMn1?= =?utf-8?q?zg2KP/Kdm7pOnKJ+ufcG3TCRvAXLwhXYac9Gfl186OxOklX+2y+PRmxhlwxqT6hy2?= =?utf-8?q?gFfAaBCknwmgykXgR0lpcn782kCMD4esNSBjawdYAgehSyOI5vyjfIxA5q2pX1kOv?= =?utf-8?q?qDVdeLzumktvPiKUQB8R/mtyTlQc04QCtzOh2/bnU1Q7VXvC9rboSqMkuyL51neaZ?= =?utf-8?q?bNF1ehCvGTHbmgt0H6mMFfPaYKjm0ywzrJ2GLQJnNzvkbIZDtF73+RdUDn0f/1eSs?= =?utf-8?q?M1CZCXdSdnTwyzFsr4bid5jl8GAKdNlkh5ByLwZtr4WkiuKK9eznfnZhJ7m7e+hAe?= =?utf-8?q?61s6xSD31fOEgDxedyppDrSfg13+OhpYj6b3Kcz3uDMJZiHPomLmJGnDZaNi23Qg+?= =?utf-8?q?TQwby+uOXmu0A6lMJRY5DkDwsJBI8UdXAiP1DBJQJY5ovTbtFQLZEiVROyvNrqfae?= =?utf-8?q?W0xfGu8lJBsNK8saBt9zLKz8n8NzgZIgXKA/XWEPdz5+EMjrKKEoIQkjUbeToN/OV?= =?utf-8?q?idHctZ8WptrkqUPsHpFo/mRJ0a9+OsU3xQH5UKDV/x5blv7eD+p6HsOdjAbPhd+Qm?= =?utf-8?q?+14Q/qBDTEZkjE7NICfuH9YDhj9jbGKEIjOSa0X9ke0RJ5fJmI/6FMlSmX/L/k/Xz?= =?utf-8?q?DHtakgqr8rDzQYpUlpgHGPr3tQjE0B4yA6aCt0k8fZFfucLQZ47mj3S3245YkSFy+?= =?utf-8?q?ep4y9Nc6uiqwCqgAe2S5LosX8IJ3YiV+9/EnHlb3r/ss8i/RCMkfQexZttvGd2Mc7?= =?utf-8?q?aKj9Edm7U69cfuRlas6Kx2WZJzw9nbV392b+VtegXH+rREpldhPdFAXgtycmKl/Ls?= =?utf-8?q?JtytRc1PXA0pkBRnYFIRbE3COp+Eud46UUzUt1q34CSzP2sKij/f97V71P8x8XDCl?= =?utf-8?q?Momg6FHOSskKVESNn/OuNCNeaSvn1gMX9/ekb6hmOXEsBgy5CdAefMHwlBHw7YPTW?= =?utf-8?q?LdIDq9GNczrnbwonrLB+RkYn0GZiH/zJzwJiUqfyy9QxYbfWvZFoD08Kar0kv2PaA?= =?utf-8?q?Vl90Kuit81BIeJ44NTcgRoinue+1b3MAm4qg1bLBPhjfy8Sydzg0VEhcXA5mfvOnk?= =?utf-8?q?EwkeLx+jUbT8bluG1oYwyHkuIxa+h/wylYHMQHMCCu7nmZnjg3yulqHFM3zZ1nGAF?= =?utf-8?q?oc11/UTJGOmWqUykacV4iNDwOfpgExt4zxg=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:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?YjV0L0eq8q4620b+OhYahxNKzbGL?= =?utf-8?q?zCaO3/EgyROL58KhctcWm4T+SHQzfwABogncPRjYo3DTyZhrSUQt4iRWu/VKlzs3C?= =?utf-8?q?dYvKAPSzPEu1sosunhLD28LRyCrAOvCYm1VaprGUYLCOGcnPJ6ts0G+RB4TW/P2Ml?= =?utf-8?q?RzTJ2gfutdTJvbtGfcWUWXXttAcBuCqG/R0PzAw6iruQD+d2TnbkbbmOm0xeVgxK9?= =?utf-8?q?CR+c3ztQQriJdBwug59cHv493BGM4viEzEpMFkoClBnK+b2GqCxfRl/GfBSUoiDP7?= =?utf-8?q?QhCg7M/fdpyUXfLnBY6bBJoSo69UUjXFnAsmmatmKyNKnukPssI2NX9nZ++hZPQE2?= =?utf-8?q?LrYkk2GRjV3hYXGRiZcAqV7AQ/N+0RrVv0ns2z45CgGbVNk3uzhvEIWksY+a0J1IZ?= =?utf-8?q?uwhtWolk1xxjZ3+jspm/9guP/INWF8wZ34qUKG3I1F8E4oIlQe2Wo9x1+rtCKyq6l?= =?utf-8?q?O/vTge16Pjx0f2mGrq2/Zox0fZH26dAr6JsmExnuvYmC4zP3mSm0ThIhafCvxibiL?= =?utf-8?q?YM9YIMcwrSoEWxkE9K/te9YROjqMrTm1d3uRk029sOHpHC56YWTyG/KaHxRVNYFsL?= =?utf-8?q?e6qc+S6VxKPg+UbIJ1oclyT+VoaONyO5JmtqQrM61WiAniuVo/wS85h9IncYXRzV1?= =?utf-8?q?edzDKMYWtPIL2vACCNQ99zXTVXPTsIok4M9KIJBgSp66FsUM7DdMrvowx6pQWXJl2?= =?utf-8?q?r07VdsocmU7J4FW9znorzX8ZVuzfgR4JIEVugcfU1VdrnZvibeLvwmR4SU9/V8tpm?= =?utf-8?q?Cw7767TyrAXk5K7zVhvEGREw/dDGNbQDZgUO7dfOUEq1moyREUK0kOvIeF9dtG2vi?= =?utf-8?q?/2XXkx4yKhpgPRYoJHyyi0ixlfe37kC8z1zblAqgIP1POxP23Cj/ASxK9z3SKMpgq?= =?utf-8?q?NjEsy9N0RtpgkVR+aqY2MMM9YdfQ3WWFAoGillP3vCDgt78u+rN/AVAeScakkZq8o?= =?utf-8?q?I3APGlsKejaV1uAcAHm+z805o9rBV4kojJLQa8D/WYcsPvvihwWeFQiFgg4xLJNv8?= =?utf-8?q?r8y2pV1LVHPsA2Dxr48+nW+7sGX/a1SYZ4ftM5m+dApZNxo/Y9KyuqYJwHPPr0toW?= =?utf-8?q?f1btsvqVnxQEQTgpkH+idk2gBtsg8RrN54nRmrkLnosXkD7bTGztBcO/5xsXTXNpG?= =?utf-8?q?anrE8o6GM4DTVLmhHwUPDbl84Lpfwx02xSmu8WZr1Ep/iOgflnHoFiKwQYzY1L50S?= =?utf-8?q?T2Vb/e/0FxdZo9LmDB1wO3Yv1IhFC/iiymAE4Wjn3Ejek+LmCWq2yR7t4n6KfFZwe?= =?utf-8?q?iWc24uqLdd53djzhvia6jEjB5syCoL/ew8LDgXCTbYCmJ1bghL3EoPhf1v3u7C5P2?= =?utf-8?q?133nOl7gzKqpqr4om21OmZCIA68YdSNMeYgQpUxjg4DQC/t2dIY3lzSnoQnb2ji5i?= =?utf-8?q?N6olx1CqRSBgmyI6EfkDGnvNksZv2bKnprgJ/OjeEk49SCAClZAL3BczcBuMMZZQ4?= =?utf-8?q?KUKaNXQ+34HuuXmxnBkzgZsdvjsOruB16kYoQIUU3amvlQg89HpQN65PcRGQMmdRG?= =?utf-8?q?mliMFSAlCySwdenM8aVviJrLfPiM1CBp5hYvvyi5nKKrv6zeG8TRM7E=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 04118b2f-6482-41ed-3738-08dc62b40dde X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 10:07:44.7191 (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: S2Q/u8BuZtUmUx41iYW0/HmhWhf1Chd2RtdZcR+N8BzEjs4ecIqyESqLXpdU9uau3H2tDRjL1L/MOfyphKWcxN9b0IhL1FHJubROecsJ+HA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7885 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 | 263 ++++++++++++++++++++++++++++++++++++ include/linux/input/touch-overlay.h | 22 +++ 4 files changed, 293 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c23fda1aa1f0..7ccda28e12ce 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22414,6 +22414,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..5e05dab003cc --- /dev/null +++ b/drivers/input/touch-overlay.c @@ -0,0 +1,263 @@ +// 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; + + overlay = device_get_named_child_node(dev, "touch-overlay"); + if (!overlay) + return 0; + + fwnode_for_each_child_node(overlay, fw_segment) { + segment = devm_kzalloc(dev, sizeof(*segment), GFP_KERNEL); + if (!segment) { + error = -ENOMEM; + fwnode_handle_put(overlay); + break; + } + error = touch_overlay_get_segment(fw_segment, segment, input); + if (error) { + fwnode_handle_put(overlay); + break; + } + list_add_tail(&segment->list, list); + } + + 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 Mon Apr 22 10:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 791700 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2130.outbound.protection.outlook.com [40.107.22.130]) (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 EF25013E8BE; Mon, 22 Apr 2024 10:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780475; cv=fail; b=XX4GVfyjwqfrlHC3LkHjhLtCKr+q5rv8y/bxpNDMfYD65zBgdH2Xrl8rh5pZuXb99DgRxxfSZeYo7QGndkwJIfr9Zn+8KApYNw+8V6DBQkni7GlA/NAidmnTsg7FSNJjurhbaL2adR9oQoH1wbrfBh+OYM/J3zR0mYRcidgzBrs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780475; c=relaxed/simple; bh=p9Jwz/8rK0zTZPWVuIL6lA7Sdrjcu8RH3+Ur4C6kCgs=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=j0dk942T/x4sJOdomxpzUNX/68dtZ8wxykTb7CxQc0GzC0qioAYCN8UpYGFGicRIjekrrooa43r+CVsf+DXfbSqS+mBZqw7zKMbaTiyLQpKCikKd5fFEnvqOA4alG43fDknLmXq9E60kbLzI5MioMRH+rwg+HXNTe6j8U42jhYA= 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=lz2iNvhK; arc=fail smtp.client-ip=40.107.22.130 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="lz2iNvhK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NLLc0Hsu83S2RtHecw7kVVvEJW05ZQ9LoXxBllIUOP9aVca3PZlhASzp5ZGymwRcdPcxhgqgdRZmenNWpRebF+mSNQL6PqYfs4ER3M2gakmxOuxsM6FrGx0th/jbql33rN2vuWL/3+xp+zqm5Mah8M84R1Utb7BQQ1oFRMAIi0xaE1pl8NvYjJhNv10CuOrpGry/hS6pi51s26zOPlL1W5cwlY4sVip/B8SmvGvSDmA74S1qUUf+dJ4bc+dQj6hPHV8ht9/q7Mk/pTWEwVqQ5QZYgyGGb4Aeh/SCgry7BBvXfaTcfMjnLNOSdh4wXOUYGmvs+SIyK7wvvftYd8G9pw== 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=BkAFZ7hjyv2PpbzIOxL60Nj/uxUDInOQz4yzk1FF7+4PaBdvbww9tMQIrMVj+TMwOnUxzUD3Da11NB+ms4iitzlCe+6i8qmHNilktHy2aoiMgYG0cIPVlF2fO8vSpAAjtulbPEwxqnFQAP7wrFKy9KLbMHI1RWzJ8IHHBwL16g0+51Y9UFaPo6nzQFx4OOgWvI+N6tqMBerGy07v9WO//cw0wdErL9HCNnG+gxqdRrd/T9eAT5OIqcjEzCw6sZzkqVpWN/wPxrFz5tTczJFd6nnQHGJ/Iffh0qzzejQM8b0tgMQWeL7FI+xnrSQehhpATIWtbntEAn3M/pCajgipfQ== 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=lz2iNvhKcfks/MUDSmjMtL3W7J5MujW8+cRYvuOg0tRtU+t4G0PAoeKtU9isc5bW0qI8ITmcLK9Wz9MOCMyphRY5n+idWKDC+XWqGrH26H2SxkravgjGtfi73j8LqRZgJwbD2ejRiO+R3/N7aHLBi/Rrlv6PwElz7Ngdh3B3Nbg= 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 AS8PR08MB7885.eurprd08.prod.outlook.com (2603:10a6:20b:508::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 10:07:45 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040%5]) with mapi id 15.20.7472.044; Mon, 22 Apr 2024 10:07:45 +0000 From: Javier Carrasco Date: Mon, 22 Apr 2024 12:07:39 +0200 Subject: [PATCH v9 3/4] dt-bindings: input: touchscreen: st1232: add touch-overlay example Message-Id: <20240422-feature-ts_virtobj_patch-v9-3-acf118d12a8a@wolfvision.net> References: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@wolfvision.net> In-Reply-To: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@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=1713780463; l=2517; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=p9Jwz/8rK0zTZPWVuIL6lA7Sdrjcu8RH3+Ur4C6kCgs=; b=veMcZnBSjz+/gVOSf0+SqQmwXYUqbRRVhV4BSUnYUz3Ata7Mc3mhUuxX80kCdPRTy5pKOQIbi yyB/d1pRijIDuaFcum733CC4WIIeucDUyPVxP7k5+5sdgGR1d75OhNV X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) 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_|AS8PR08MB7885:EE_ X-MS-Office365-Filtering-Correlation-Id: ad556cf8-82f5-4a56-99fd-08dc62b40e12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?VkKxijzPtDYIOsI9CginWGGR8acNowR?= =?utf-8?q?nKnfgo8cfz5zNVWrCcrOraZvRlYAYzPMP3z3hP7oYL2WGkxFAD5hr7rvTDiJ0TndF?= =?utf-8?q?wOPGQg99jGZnbBwu/Kix0jpisnoEWjqIKcVSTv1M5aowCc/ojk5azHaI9hQQYiJpz?= =?utf-8?q?fJRRfDdDY1mI14q2jpNjr1RqDvrBmypkltfUtSxqmW8Xfp4GFKzfTwhDx0wBjZERM?= =?utf-8?q?M+cylVKIW8hZpTDZz6NOuWiLRWTAwc5hsgklcWPnZOvWKknVv6hbMBwNYXqrARjJN?= =?utf-8?q?rE+k5K1nTdw0AC85Ao7thhgD7CUWZg3jIi8aVj9LsrPWpVffb4ldhGTxcQHfthlq6?= =?utf-8?q?Z7z9E5KVKIAkSXDMlWXSUYXqU6+cbMdSv6f4nZOB+1tItk1wwCksW90bMCOKDTUfR?= =?utf-8?q?kpTtNZVxhdpnyTvFlcZYXutN5owopi7WrsWxXpJ6NDPpf2lUGFrFkUeWNrcCWC7nO?= =?utf-8?q?v/qAvSLDJ9RbMMPivoIW+nBg68uSKjSHhBoME/INbenYa5H7J3tviGIXLB6LGRcfM?= =?utf-8?q?iZEjUKIbTfHQgKwRKBSG+yrO9FE/A+dnD4L7t3SXYMewBHw+8sqZgd/QngmQJjCsB?= =?utf-8?q?JGhqJJzU8xj+DFl0RqMTCcdHIX6jLFNYViCFEOpr7Ds+sT1H2ivJ+xpHZchoYZyRW?= =?utf-8?q?x5/DbDrf+kr1h68WQm/nxjMffsG/NjJ/P2IMeuaR7CYKKW+HUWVcAJIuqGuz9FXrm?= =?utf-8?q?/LzY/1mPTH9mjMe52EWhIeQqF8uBuHKHCqqAAT864ug1fYa1GA4vmGGS+3nUogLAG?= =?utf-8?q?bLccIns1wfUHkPpVCSUp3dM4ppaN9VcUmEqWVCwBAFCUXJEKv0DBcMhZc/GkY01w9?= =?utf-8?q?xpSjksvneeHScMhu5T9nQLbOB27SeHq8x9541Gvp3xzhY3UupDQZqcsvt0CBMoK3P?= =?utf-8?q?oZFDyShNCCSoPc+dPdhj8vUfS81S2cM8gyOI5e2aianXyOh6BhBdavMR6bKPUtVhL?= =?utf-8?q?rQh72kHT7bInU+XLLLGOqHmOHbna1XQgWsNg9c5T9lTlGCdBfZzDgRttg5rz9IqaX?= =?utf-8?q?/GCefi26A24zs00so0E03jcy+aw7giyCjTT6vvg9crj3DKZfb6JNfVy5FkRkcOxiX?= =?utf-8?q?oxWWqVpqpVAiaO+w/N1177Lb6F+IQnGArgF+GyKHJNtWatyGoMEfLQPC6Bsk5BUSm?= =?utf-8?q?1qL8i4A7gz6kBi0VJ2bEdOqYjdUmbMHHfPlbceoXlfVsgvyyrNcYueeIUl5GuN7E9?= =?utf-8?q?Bq20K8sIvSeSl17KJVXGh8Pj1wUxw/kj0T9ruN/AXWcIAz97hLvhLI0hnJIzIFE/h?= =?utf-8?q?rz3s8DKWfpZZMk9Rm2c32i+DvS2qRL7nBqA=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:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FPfAEnew+FL4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T7SQNwuK81K?= =?utf-8?q?+ZLe11irf9w6JEhVJM0683zHW8NdevqhgG687a3qCYUbCJ3NE//D2F0cH5MUL/tce?= =?utf-8?q?4u8yer1MjRmwMHqHLdH+xYXsSYcBE/3oRIjf/ozrouwmG+JbF7NklqAcNLFHExISc?= =?utf-8?q?qbxzp6u0Rx/8dNFI8y9zrLwlnuqDAN4m/oJe6Ym0zCbGbKBTnaRSletp+ZCB64fYs?= =?utf-8?q?HogKRnSZmIos7/8TioeBlG8mBJShQcQWzD0XIP5b3tmx4eP7crD3e2PBw8f9eitz3?= =?utf-8?q?w+RqCtUIC3HUKNdWYlgUTle4yDEFwCPcTn8NvbZnASLfXJfV6J0jY+VMEkitLVoLR?= =?utf-8?q?QNURlG6nJ32ifY1ZFa3vOcWb7xwcUFyPBD+9MT82GUnKq/YQSnhIKUC1EwlsfU7hK?= =?utf-8?q?PYsXdfvhT7aXafyLPWegRZEvASXALpXyxIqJ/q2OE1xR8iJlrDlJYoCJp24AcvCeN?= =?utf-8?q?M8fiQEJt+IFGcdJ3ZFtzerkoB3+NuE32GQZ34n7mm+aPu05xFi1viCwLv1wWaBvFA?= =?utf-8?q?NyK9aCTjEBO6QxAU5iTTbLbI6i4v0EQXOCfkklHhaWBxI8t5rTY9lRejul11l9bDV?= =?utf-8?q?CSKqsPXgOcwyl6U8RqkfO8fBcfz5qXcoW2snn9RR9gtPN+oLANfZpZVWuFyxWah1z?= =?utf-8?q?bMzefVGCLQkvPYowFb4QMdlM2RrLAo7x2rIQAC2IJSrMMCAT7DIOIUs=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: ad556cf8-82f5-4a56-99fd-08dc62b40e12 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 10:07:45.0867 (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: dLwuz9JRpZepJLbpBsIBJgxVyrspAxlnRZRCKcjKVGx2RBmcoLc8Ckfl7YMem6W8Oe/I00Q4vMxcYQhogjLObt+aEBQbCKKw1jlll31CX04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7885 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 Mon Apr 22 10:07:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 791054 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2130.outbound.protection.outlook.com [40.107.22.130]) (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 E72AA1411D1; Mon, 22 Apr 2024 10:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.130 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780477; cv=fail; b=jCNjWiz3tdseVG0EwHyyreQ7F/DFXzgtOTRTUdSQ6/wKAa/k42lhN6alp42oKhJJPOedZlbaXUDTqEuqhjyYrwMUscWRG6gS4ObtNFZb0DallFBcdEPTJufBxzX1dRFwt8BLehT4LeTbQHfuNU4W0kSn1FsFn+gS1fAt8MWgfrs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713780477; c=relaxed/simple; bh=CRZ0sSYsoUecSbz+oUC0fLIT0nSbJZhwa7o6rQIIR/k=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=bhQDKs4NZZUlbZI3Osr7LRBGhG6hheAdej43+aQecAkRr9MgDrBsf79lkBJrgfCaJ95EM1XMw/iTwSmvPSjlMW4cPFoWrSAVVtOsKECUcpSUCcBFh4iBK1NNk5geu2EVMhIp6VbtkIjORA6Xw1LrO+9YDPbepep5FtOFrKBSfGY= 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=TJrIVUHz; arc=fail smtp.client-ip=40.107.22.130 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="TJrIVUHz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VuSucri5qQvu25UGjaoHG1R4KVp+QDId7qN8ccU2QoMQf/wZtfTPJ5ccF/oBPWKUz0hxFr7bqxAUak2+6IgPjhkupRxYbTqDf4aVkhwYCcYiL+b+WUoL6ajLSEST1TO3Nk6oh11CEx1ZbRGn6qkwB/mZgW+upMJokGJdU2GXXyCDSHxRdX4R3sps/YrL87ASSLIVwHPpP+uIsMV9Mup8z5Va7h27+PeMuAGmPIxzmRBOpvJke0sEhiYEkneonfma0HUkQlR4nDk+spAXcsFah0MopqQjwBrRuRxR9JJStgsArGOWQoy/TC0EvoB4UQ3YaRurQSY8qxS5kq19vl3bzw== 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=c+IO+awHoDqlqKjGNEtdGlN859aV5MdUs044vwjEIJE=; b=Dqr/QABE8caWa/a56ol4ReehKCkecS4iIPcklDA2OMhQGk5qM/jlWC6ZTZo/q84QWvfvKZyYy3TvF/vWDWSaOVyMuXUPJQQsz7R7r9VWjWxRFKY4FWUWdOb5kPKHaCtHiAQlDBGT7D4rKcidsBoEYzPUa4pJuZACLK6mQakkfKxGbc8BTfA/HIyBUyyttU6/xcB7de1VoBT46ZCVo5L6bOZ3Rzo90ppc+8WG79NKD0q6BYtveKU1jSA2hzXnVaYzLgHwluZX2ua2hGK3E/QU1Sv5y1TSRq5J9wllqNvgmkH2nxwkyT40tPQmaiS/gtVvz3LMo4NsJMZeDq8X4VW60g== 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=c+IO+awHoDqlqKjGNEtdGlN859aV5MdUs044vwjEIJE=; b=TJrIVUHzmiX++ET66TtSabvP7/Cxn9Yz17RKtlIwFvSBrdJkjwL4UEtM1DMqFx9c4xiftAfrD/5S1LW65uuZhGKXwNBW6mOyCFvdwOPBfU0HQ30Bhn8xvrrsG/k/BP5xWJvjvheqh2N49h1aPlN1D9ndjXf2DG1An1llk+rkqcc= 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 AS8PR08MB7885.eurprd08.prod.outlook.com (2603:10a6:20b:508::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 10:07:46 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6621:68a6:ab00:c040%5]) with mapi id 15.20.7472.044; Mon, 22 Apr 2024 10:07:46 +0000 From: Javier Carrasco Date: Mon, 22 Apr 2024 12:07:40 +0200 Subject: [PATCH v9 4/4] Input: st1232 - add touch overlays handling Message-Id: <20240422-feature-ts_virtobj_patch-v9-4-acf118d12a8a@wolfvision.net> References: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@wolfvision.net> In-Reply-To: <20240422-feature-ts_virtobj_patch-v9-0-acf118d12a8a@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=1713780463; l=3456; i=javier.carrasco@wolfvision.net; s=20240320; h=from:subject:message-id; bh=CRZ0sSYsoUecSbz+oUC0fLIT0nSbJZhwa7o6rQIIR/k=; b=Ij3WXv4AoCK198k/VO+yiqFnjQJkIXg8miW7U4oxVJMKoYov+VSQ9g/cn+ydgNQ/LsEN69lSl SM8zeRKAkK+CbRB9XotPC9rb7ISei1Wtuq2k0KZa7m8QIlVSfF5xATd X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=Vxk2/0sGIxM8rsKnceszFuSuHVfQwa1Yo8+is7BX2nY= X-ClientProxiedBy: VI1PR0502CA0004.eurprd05.prod.outlook.com (2603:10a6:803:1::17) 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_|AS8PR08MB7885:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d7f46a5-6868-41a9-1b22-08dc62b40e4c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?utf-8?q?sWr/5npVzLrIijslFJX6jX9D5jSL9qV?= =?utf-8?q?dFYslozlhDeart5IwR9lV/AGLGkbZY2iBfmpeaXV2Cw2wNx3r3bCNMigl2Sb0T5iq?= =?utf-8?q?sQKoGhEnoSkeF6KNhPTfX0g/493E8KjJp887Z/88i1fGGL8nCcET19UpEoe8RapWf?= =?utf-8?q?ygn6ICZWpEekxygJdE4oLWIppKReQ4kHNw4o7d2LWZ/GqM814dkoDw1hk+YMF6bV2?= =?utf-8?q?CgYuOST5YdEh4qudz1Amax5yOZED8lDwX+zLGcBn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8RUgxgCeYVtuVyTt2UxTTmBe9m6c?= =?utf-8?q?lkARQxpwC22jCxx3Cxm6g103kcUxLTS7/yyu73dbTX0cWcKR+kLIp3xO8LOd+jLoE?= =?utf-8?q?Th1tkKta8eWk5e3j8N1SFpi0xIRh9tnw0I/fcWt4S9i8cUUpnICC8r4SSjNz/OwJq?= =?utf-8?q?z0HzQ+k788nLOtxmfLHvAGIKM8GIjLIIrUg=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:(13230031)(52116005)(1800799015)(376005)(366007)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?byGI0jrrM4QWJwJwo8zWwhZFjChe?= =?utf-8?q?UEb+Jg85fOtlxcJ5xDOFDzDpVdFoTl5FTat2ciPVzYd1mHiib0Y81QXsqibcjnVMD?= =?utf-8?q?ADcPQTx/2O9MMa0pH5zhnqR6GVaJ5e58R88HTxnSnpNM4rHdnoxVZCKCx3IgV2TBQ?= =?utf-8?q?qSmZuDS6mbZJldCMWyKxZFKdu4WQjMMBZJhsNDfSnnuyLzDs6DliMedNXkLSjYAXY?= =?utf-8?q?tl/Z3OD1ryZILjPkXL3exeKRH6KipmOCbbh5Ojt+WxYqPgZysCjrmu+eKLyiFeDqA?= =?utf-8?q?MQyrXvHg4XqL9tmosP+qTalaavam6NkLgXo3KvFXB1IQqbcR+a/kJQcS2SmJeLRAz?= =?utf-8?q?Xf33UdJI8yKzwMxmm7yaj4Vk4plzDUNHrquBP8efi50tWuEoloOiUbu4YqePG4AS3?= =?utf-8?q?LJWewSl/JnKLQ2vk/nmalVDuJwxCfxL0cj1MiBF/EtA7qSGayVgNdmb6nP+TRpfcm?= =?utf-8?q?I3mVaw4vW9BUhX/r6nvZIT2v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uFyp0HH9N9yR0SbZCzw7WQc8hsSOPomscQTgHD+oeQD1odGdQs0x?= =?utf-8?q?GrNQ7S7INY5FCYyppZ368rbHopbeIrPOUNCsJaiH0iRTDmQJwPVaOH+q8iqfkZ1cF?= =?utf-8?q?eseIT4Jc8zdiuusYXjpoF1jLFRJbhIjsmD90zbya50BpWlvXvCpdDua1jqXq0bMlG?= =?utf-8?q?ZFvMmyEdXRotvciUckYD11IvTV9ZIM5GPJieC2c1zKL7QRzoyi/cz3c=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 5d7f46a5-6868-41a9-1b22-08dc62b40e4c X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 10:07:45.4293 (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: 9CbdI3PImcHTPKXIgC24z6TEsBz6qx49E7RRPHbx659H63BDRXG76wcJu6HZ1ATY4AJOFhVZy5EgsNNxZK6TVZHO0cqwhAyOF7QpFVtLzw8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7885 Use touch-overlay to support overlay objects such as buttons and a resized frame defined in the device tree. If buttons are provided, register an additional device to report key events separately. 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,