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?ygn6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VEsBds6NHI0ncp/346oaCiViGjJ1Qi8iPvPZj4/r+vqCxyU2je+odMj6+XbHc?= =?utf-8?q?sO/ccRQLBG5Ad39zhI/sQMMwMuDCiApuIDIxg8RUgxgCeYVtuVyTt2UxTTmBe9m6c?= =?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?= =?ut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WLSMd?= =?utf-8?q?QEBd+8q1jHpDvYgWgG2OfqqKyTeCndV3gsSdsUp+i/RcTIgZF6yCWX7wWDfw3JLtV?= =?utf-8?q?3j/KBK2JKDyOVuFyp0HH9N9yR0SbZCzw7WQc8hsSOPomscQTgHD+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,