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?YyBXoLZ3puSr3lxgSKTtEwtZxmqSEQI?= =?utf-8?q?Ai7DgCBXk11p03l3u7JzhvvEkPnxpZkzDx35+CINsCJ5XT6vpDfqALn0yxDJd/P9L?= =?utf-8?q?caBG8nSfm1HJd4hAlfQ2NPivFuwes3rMv1Ql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Cup9whSUlKYmTLuiLqi?= =?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+LyUbFutf36fbgfK0GNU8ilPMp7x7z52zT?= =?utf-8?q?GAm6/B5B+iXdN0us2Wu6ydV2ipo8WY9AJzlNbY34at1XqRjoFlCeX7H/1gDjrJ4xm?= =?utf-8?q?nNpTGbA6/Uf7ISw63FOTq9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4SQSsL7HrK8beZ8QjsgPfkmwPRW74ypDX1U?= =?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,