From patchwork Tue Oct 17 11:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 735352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA247C41513 for ; Tue, 17 Oct 2023 11:00:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233570AbjJQLAW (ORCPT ); Tue, 17 Oct 2023 07:00:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234599AbjJQLAV (ORCPT ); Tue, 17 Oct 2023 07:00:21 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2047.outbound.protection.outlook.com [40.107.249.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEEE7EA; Tue, 17 Oct 2023 04:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sy1olJNOhmDHRBOhus44YvgfCURDJ8BkBmXgF5EyUwn05arVsyDHwZVQf5qTGcfNveYe3dWV9BcjT5SWFufnyVGL58sv/jDcy2vaoDSR36rlB56iGmxXiaMDhSgEc6kwfDrD7CprQ4sfv99Map6oOUFe8W2stgP6ptHMKzHFxr/aUAZ0CuW0Osv0cIVzpN/2ezFuqwNhWcWuzAfIypkPgXCa9Cft+xOLd8FFdoVqFbBWLsslqUY8v5JgTvMuho6LGAe+X+98ZV4FzACbg1yHB3evvED8ksIB5MSk86oJAxYhmQQZbBwsqTw4PZ3rElE9RJ6nC6aXDh+396cUq/Xezg== 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=OJEi3vJTduqpwezb9xJhU4ifPF+ITuUK8LQovSBDtjI=; b=h6zi0FlKCBmQpU1KBuQ6OiIqS7JIINA3sT4Os/aYdv1Nh+E9ckAcclvUgYhgCHlZj3uAkLc1PwFs91mKSaxA/Cf3iPjFLhvgUSgfYa6qSd0I2myjZhowaOLzfQptF5sHn4ZFVaSvY69rWd3rg8LJh873CclEG+MBylyxV6duh0KW8ak2hUvjATA/QwA8aA56oviG8C5f9Qb+DILac/B2Sj8xZJDZI8iL7AgJoM5qaadKdF8MXcg3XGhTU35bRsPwVvtQr8FBa1nxXP6KCrAccKxvP4r4wjwpPZ/YFzAdYhDRo/clDpxUSqc24zYcxHdeSfSOItg9VcvK16euokf5NA== 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=OJEi3vJTduqpwezb9xJhU4ifPF+ITuUK8LQovSBDtjI=; b=nBYptv/IjX+ZInccxbjyVS1XcywJEfJSC79fxvlYFQfl+J97PCtKrT7VmqPGmB1+E8SA0vEZHsbXfJpZEMTBm+gTxuLXKwvZLopsLoDMsCDBZWO+urA3i91eaR/jIjZ6LSQgLyVHW2QMEVlGBrDRVlNe9U2A1/XURr1toFSbuGA= 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 AS8PR08MB6295.eurprd08.prod.outlook.com (2603:10a6:20b:295::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Tue, 17 Oct 2023 11:00:14 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63%6]) with mapi id 15.20.6886.034; Tue, 17 Oct 2023 11:00:14 +0000 From: Javier Carrasco Date: Tue, 17 Oct 2023 13:00:07 +0200 Subject: [PATCH v5 1/4] Input: touch-overlay - Add touchscreen overlay object handling Message-Id: <20230510-feature-ts_virtobj_patch-v5-1-ff6b5c4db693@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , Bastian Hecht , Michael Riesch Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1697540413; l=13918; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=qqwR/kVL/sYBH0UecdndEJ2NdLb3YcmcKBDR3n9upRE=; b=x37HELZ1xdHJkxwJd6Atm9hDaBs3yJWMpyRpcia9Yz1XStauFQqcc0A1QrqNeg1he36APZDg/ ZyVFcebCV1nAIlKguXz7Z7oxcCPgR1OhsK6ovF8DPCQbhhlh8Qv75Nl X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0250.eurprd07.prod.outlook.com (2603:10a6:803:b4::17) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AS8PR08MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ce8f732-03d9-45e6-e69a-08dbcf003d81 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NJdf0Hkaftpq/D3rwJLoFPwnLFyQY6koaFvJPYdLXv8G2k7RpaQdfnOiENzn7A2Cxy38GkEoG601+UUM660pzQa7vBEp+90101jnFMfNmKyL1BUBLCKu46LezitrO5/lk1pCZspk77ooSXMU2uWdy3BC6EFrleSE41Y5/sik4paY/Di46D264VKrbX9eDAqLT8Ak3OxsUvz3FnwUkn6hQtF8hTLIL8zb8ICN+KlrXhexZYl3zzWhdD3mVDdTvb+tulx169zyP0i9VjSpqfzhbNvb5yFf9Ow0XwaiKolGM9ZPlNj030KwJM8lAqd+G/vOVwe4C7UU6ZAgTIuFZ7qoxvPCakkFoy/27JxtnlX4hLxfh3QAxe/BK0Gzpvi7Owy5mkBZHSdwKi1SOWmha+tcFlUtt4jBIJQUbZUv46aO6VAFLRXcl71pjE00QzjLDjb6gsf6pluWx4A5Y4WKsn3WkkJKX8MQjOrwr4+4QFUxbPD3hCgw4yeNsY2HEGuJAkG5Xol7Q9wHjiJSVb84c0K+7Pkm/2ny1rDrqXVl9M0v1wu6BdsiEV9LPNm1sAc34WRwzatJT+J9RrAgKMMUdI8kbQrbIqQ8tpVo14B5gm5ZfbE= 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)(136003)(346002)(376002)(39840400004)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(107886003)(478600001)(38100700002)(52116002)(6506007)(2616005)(6486002)(38350700005)(83380400001)(26005)(966005)(6512007)(6666004)(41300700001)(44832011)(5660300002)(4326008)(8936002)(8676002)(316002)(66946007)(30864003)(86362001)(110136005)(2906002)(66556008)(66476007)(6636002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?B/GSu/CJ3RdWBGm2+foWmZAa+HKs?= =?utf-8?q?zFxFZuu1ilXtcqYlXMgbw1x7EStQWAknDhpzBoApuGqNzjBlZbKH4BWff3W6vZ5zy?= =?utf-8?q?p+PflYoYHiVkEHYDTUDl1NxmZmgqgirtIddj6LbQArMA0RBfM5qnnqDt2SjrS3w4x?= =?utf-8?q?JbvQflO3BY4V2toY++FbJGxsGwubEs5w+ore/r3IF+0EMW7yOkcghFr5sQ7k4ckLh?= =?utf-8?q?Gr2TewfZusxZP9winHcpOMzaN9X/zI0ShkS12mAPOPUSXYQBq7BEcqXpv/uOt/4rd?= =?utf-8?q?fSdX1uhnb6KGdN482wR5kEnCWlzqlGf97N5tUVgSJdSce8YL1ICMX/l587uR+Fl06?= =?utf-8?q?fm0PtenUDCNC9YqOtCW+98dFojHkXgS3Sx6B19a5LqDWKqkA2Cnz18TtP9IcqXERG?= =?utf-8?q?nr45WIFPusZCB/rtLOJyMWNF3gyDqi0KgdJTS55Um7OJvHLYAHAsQv4ApLbPizsMm?= =?utf-8?q?5IhMWG/BOBCljUHdU/JzIdGX3ul2ikPIYNRvCxveF9WTuLbXvUBrzfLjpgFwT+ScX?= =?utf-8?q?qG/MIDF6b262rmAuyU6LeAbBLp7Tx2eSTeXQLHnccHvrikaOto1vdL/RsWP8GCVrw?= =?utf-8?q?OjgaGb7c+G2OY6K2p+u72aFyoC25ZNTZjxRXkwlVWAouRP7W9iMmlYfkDsrv5uoeW?= =?utf-8?q?Y1eqjScfcDQTqQbKOQqo4vrwS+c5+wRXvcCVdMMd4tffXWLrxnjwTwvVpc8G7CM3u?= =?utf-8?q?T75vbiRs8fNLm67ECtlq/vjFMHb14vZ3iC7jnj8I7zVvOfw4CpQX7rarj0gvaGscG?= =?utf-8?q?aAUtok6zrhqaL2WKT8G8brVVudDrY3GUXmiI3MgG/nTVjtJUTw/yWTKOsGMVe4eLd?= =?utf-8?q?Qq3SfKbWIKeanORan/mZ0kUmS2FvuNaYDMyOjh6oCOAl8t8M7JcUbgs+u2g27xvts?= =?utf-8?q?jMlRgl21CidxqL5R0WDLVS1poddznZ/nmNk3/w7CF6hdXIpiELsGhF0CuloNng3yi?= =?utf-8?q?yypbWtEXkvZeEFHXf6l1JyzvH7v/jNSXUYkqsWQ+6ia1ek3fcKJyYkOwGT1jQrfHX?= =?utf-8?q?ZWqn6aU1WGtOdhB5EN+r82ySAew9p0YyyTtK+7flWaExUHy/9enCw+BqGpWvGeTT6?= =?utf-8?q?HUCuAcAqV9jQh8uPrI/y/Wdej7DELbeDz9VjpJCYAKeuPCkaJ78RKFPnxiUmTFsr6?= =?utf-8?q?sLyrOk/nWxH7OxzmuodXMw6j4glulosYhf5VDtrvIQyRpRUvu0nfshBh+jemj1Yzo?= =?utf-8?q?jKbeVnluOicwFquNwHRY61XN/oXjObhWXJ40PQeX8UaXIp8afa13Ts7UcuUv4z4y8?= =?utf-8?q?4VINtz1i8ZjBZHKgXBRqOwp4PP2+pUPvfpGHf1Ui8oWR/9g5jcalz4LLB6BdoYdfH?= =?utf-8?q?VPQfrMc53BEFJWm4EjEb276lH0TLe2ev4W7uvtikM3KCWdr+mVJGHOAGRXVQAuwbb?= =?utf-8?q?yQ7Pox2B/GODqnZl/F2l8slqhOUL5B3oFrX+K7rd7mf4UH8m/E3LhyBBuW+aTEwIL?= =?utf-8?q?GqnixRrSBnr2vFUQv3vcRhpflTG/HzoUYWVpBz+5ktOiB2MISqivN59Pt+tmSw39I?= =?utf-8?q?oJeWqpXi+csX689kvBOLdHwevsH64wpIsx/HlXGpyc61jDiNb97RNw8=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 5ce8f732-03d9-45e6-e69a-08dbcf003d81 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 11:00:14.3346 (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: sp/yNjIl2+KKHBb0kwFSlZDQSvsSuPeMtRMoDHcdppRPPskU5/LSfUoa5Hn+yGcMvcXvmcWmuQaCPxyBX2cad0kN7H20LbI1CCnvKNoXbS0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6295 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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. Signed-off-by: Javier Carrasco --- MAINTAINERS | 7 + drivers/input/Makefile | 2 +- drivers/input/touch-overlay.c | 399 ++++++++++++++++++++++++++++++++++++ include/linux/input/touch-overlay.h | 34 +++ 4 files changed, 441 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7a7bd8bd80e9..00c03824c3ac 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21884,6 +21884,13 @@ W: https://github.com/srcres258/linux-doc T: git git://github.com/srcres258/linux-doc.git doc-zh-tw F: Documentation/translations/zh_TW/ +TOUCH OVERLAY OBJECTS +M: Javier Carrasco +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/input/touch-overlay.c +F: include/linux/input/touch-overlay.h + TTY LAYER AND SERIAL DRIVERS M: Greg Kroah-Hartman M: Jiri Slaby 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..007dbd994474 --- /dev/null +++ b/drivers/input/touch-overlay.c @@ -0,0 +1,399 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Helper functions for overlay objects on touchscreens + * + * Copyright (c) 2023 Javier Carrasco + */ + +#include +#include +#include +#include +#include + +enum touch_overlay_valid_objects { + TOUCH_OVERLAY_TS, + TOUCH_OVERLAY_BTN, +}; + +static const char *const object_names[] = { + [TOUCH_OVERLAY_TS] = "overlay-touchscreen", + [TOUCH_OVERLAY_BTN] = "overlay-buttons", +}; + +struct touch_overlay_segment { + u32 x_origin; + u32 y_origin; + u32 x_size; + u32 y_size; +}; + +struct touch_overlay_button { + struct touch_overlay_segment segment; + u32 key; + bool pressed; + int slot; +}; + +static int touch_overlay_get_segment_props(struct fwnode_handle *segment_node, + struct touch_overlay_segment *segment) +{ + int error; + + error = fwnode_property_read_u32(segment_node, "x-origin", + &segment->x_origin); + if (error < 0) + return error; + + error = fwnode_property_read_u32(segment_node, "y-origin", + &segment->y_origin); + if (error < 0) + return error; + + error = fwnode_property_read_u32(segment_node, "x-size", + &segment->x_size); + if (error < 0) + return error; + + error = fwnode_property_read_u32(segment_node, "y-size", + &segment->y_size); + if (error < 0) + return error; + + return 0; +} + +static int +touch_overlay_get_button_properties(struct device *dev, + struct fwnode_handle *overlay_node, + struct touch_overlay_button *btn) +{ + struct fwnode_handle *btn_node; + int error; + int j = 0; + + fwnode_for_each_child_node(overlay_node, btn_node) { + error = touch_overlay_get_segment_props(btn_node, + &btn[j].segment); + if (error < 0) + goto button_put; + + error = fwnode_property_read_u32(btn_node, "linux,code", + &btn[j].key); + if (error < 0) + goto button_put; + + dev_dbg(dev, "Added button at (%u, %u), size %ux%u, code=%u\n", + btn[j].segment.x_origin, btn[j].segment.y_origin, + btn[j].segment.x_size, btn[j].segment.y_size, btn[j].key); + j++; + } + + return 0; + +button_put: + fwnode_handle_put(btn_node); + return error; +} + +static void touch_overlay_set_button_caps(struct touch_overlay_map *map, + struct input_dev *dev) +{ + int i; + + for (i = 0; i < map->button_count; i++) + input_set_capability(dev, EV_KEY, map->buttons[i].key); +} + +static int touch_overlay_count_buttons(struct device *dev) +{ + struct fwnode_handle *overlay; + struct fwnode_handle *button; + int count = 0; + + overlay = device_get_named_child_node(dev, + object_names[TOUCH_OVERLAY_BTN]); + if (!overlay) + return 0; + + fwnode_for_each_child_node(overlay, button) + count++; + fwnode_handle_put(overlay); + + return count; +} + +static int touch_overlay_map_touchscreen(struct device *dev, + struct touch_overlay_map *map) +{ + struct fwnode_handle *ts_node; + int error = 0; + + ts_node = device_get_named_child_node(dev, + object_names[TOUCH_OVERLAY_TS]); + if (!ts_node) + return 0; + + map->touchscreen = + devm_kzalloc(dev, sizeof(*map->touchscreen), GFP_KERNEL); + if (!map->touchscreen) { + error = -ENOMEM; + goto handle_put; + } + error = touch_overlay_get_segment_props(ts_node, map->touchscreen); + if (error < 0) + goto handle_put; + + map->overlay_touchscreen = true; + dev_dbg(dev, "Added overlay touchscreen at (%u, %u), size %u x %u\n", + map->touchscreen->x_origin, map->touchscreen->y_origin, + map->touchscreen->x_size, map->touchscreen->y_size); + +handle_put: + fwnode_handle_put(ts_node); + + return error; +} + +static int touch_overlay_map_buttons(struct device *dev, + struct touch_overlay_map *map) +{ + struct fwnode_handle *button; + u32 count; + int error = 0; + + count = touch_overlay_count_buttons(dev); + if (!count) + return 0; + + map->buttons = devm_kcalloc(dev, count, + sizeof(*map->buttons), GFP_KERNEL); + if (!map->buttons) { + error = -ENOMEM; + goto map_buttons_ret; + } + button = device_get_named_child_node(dev, + object_names[TOUCH_OVERLAY_BTN]); + if (unlikely(!button)) { + error = -ENODEV; + goto map_buttons_ret; + } + + error = touch_overlay_get_button_properties(dev, button, + map->buttons); + + if (error < 0) + goto map_buttons_put; + + map->button_count = count; + +map_buttons_put: + fwnode_handle_put(button); +map_buttons_ret: + return error; +} + +static bool touch_overlay_defined_objects(struct device *dev) +{ + struct fwnode_handle *obj_node; + int i; + + for (i = 0; i < ARRAY_SIZE(object_names); i++) { + obj_node = device_get_named_child_node(dev, object_names[i]); + if (obj_node) { + fwnode_handle_put(obj_node); + return true; + } + fwnode_handle_put(obj_node); + } + + return false; +} + +/** + * touch_overlay_map_overlay - map overlay objects from the device tree and set + * key capabilities if buttons are defined. + * @keypad: pointer to the already allocated input_dev. + * + * Returns a pointer to the object mapping struct. + * + * If a keypad input device is provided and overlay buttons are defined, + * its button capabilities are set accordingly. + */ +struct touch_overlay_map *touch_overlay_map_overlay(struct input_dev *keypad) +{ + struct device *dev = keypad->dev.parent; + struct touch_overlay_map *map = NULL; + int error; + + if (!touch_overlay_defined_objects(dev)) + return NULL; + + map = devm_kzalloc(dev, sizeof(*map), GFP_KERNEL); + if (!map) { + error = -ENOMEM; + goto map_error; + } + error = touch_overlay_map_touchscreen(dev, map); + if (error < 0) + goto map_error; + + error = touch_overlay_map_buttons(dev, map); + if (error < 0) + goto map_error; + + touch_overlay_set_button_caps(map, keypad); + + return map; + +map_error: + return ERR_PTR(error); +} +EXPORT_SYMBOL(touch_overlay_map_overlay); + +/** + * touch_overlay_get_touchscreen_abs - get abs size from the overlay node + * @map: pointer to the struct that holds the object mapping + * @x: horizontal abs + * @y: vertical abs + * + */ +void touch_overlay_get_touchscreen_abs(struct touch_overlay_map *map, u16 *x, + u16 *y) +{ + *x = map->touchscreen->x_size - 1; + *y = map->touchscreen->y_size - 1; +} +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 an overlay touchscreen is mapped + * @map: pointer to the struct that holds the object mapping + * + * Returns true if an overlay touchscreen is mapped or false otherwise. + */ +bool touch_overlay_mapped_touchscreen(struct touch_overlay_map *map) +{ + if (!map || !map->overlay_touchscreen) + return false; + + return true; +} +EXPORT_SYMBOL(touch_overlay_mapped_touchscreen); + +/** + * touch_overlay_mapped_buttons - check if overlay buttons are mapped + * @map: pointer to the struct that holds the object mapping + * + * Returns true if overlay buttons mapped or false otherwise. + */ +bool touch_overlay_mapped_buttons(struct touch_overlay_map *map) +{ + if (!map || !map->button_count) + return false; + + return true; +} +EXPORT_SYMBOL(touch_overlay_mapped_buttons); + +static bool touch_overlay_mt_on_touchscreen(struct touch_overlay_map *map, + u32 *x, u32 *y) +{ + bool contact = x && y; + + if (!touch_overlay_mapped_touchscreen(map)) + return true; + + /* Let the caller handle events with no coordinates (release) */ + if (!contact) + return false; + + if (touch_overlay_segment_event(map->touchscreen, *x, *y)) { + *x -= map->touchscreen->x_origin; + *y -= map->touchscreen->y_origin; + return true; + } + + return false; +} + +static bool touch_overlay_button_event(struct input_dev *input, + struct touch_overlay_button *button, + const u32 *x, const u32 *y, u32 slot) +{ + bool contact = x && y; + + if (!contact && button->pressed && button->slot == slot) { + button->pressed = false; + input_report_key(input, button->key, false); + input_sync(input); + return true; + } else if (contact && touch_overlay_segment_event(&button->segment, + *x, *y)) { + button->pressed = true; + button->slot = slot; + input_report_key(input, button->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. + * @map: pointer to the struct that holds the object mapping + * @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 touch_overlay_map *map, + struct input_dev *input, + u32 *x, u32 *y, u32 slot) +{ + int i; + + if (!map) + return false; + + /* buttons must be prioritized over overlay touchscreens to account for + * overlappings e.g. a button inside the touchscreen area + */ + if (touch_overlay_mapped_buttons(map)) { + for (i = 0; i < map->button_count; i++) { + if (touch_overlay_button_event(input, &map->buttons[i], + 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_mt_on_touchscreen(map, 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..3e0db813dc34 --- /dev/null +++ b/include/linux/input/touch-overlay.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Javier Carrasco + */ + +#ifndef _TOUCH_OVERLAY +#define _TOUCH_OVERLAY + +#include + +struct input_dev; +struct device; + +struct touch_overlay_map { + struct touch_overlay_segment *touchscreen; + bool overlay_touchscreen; + struct touch_overlay_button *buttons; + u32 button_count; +}; + +struct touch_overlay_map *touch_overlay_map_overlay(struct input_dev *keypad); + +void touch_overlay_get_touchscreen_abs(struct touch_overlay_map *map, + u16 *x, u16 *y); + +bool touch_overlay_mapped_touchscreen(struct touch_overlay_map *map); + +bool touch_overlay_mapped_buttons(struct touch_overlay_map *map); + +bool touch_overlay_process_event(struct touch_overlay_map *map, + struct input_dev *input, + u32 *x, u32 *y, u32 slot); + +#endif From patchwork Tue Oct 17 11:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 734800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3305DCDB482 for ; Tue, 17 Oct 2023 11:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343727AbjJQLAX (ORCPT ); Tue, 17 Oct 2023 07:00:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjJQLAW (ORCPT ); Tue, 17 Oct 2023 07:00:22 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2047.outbound.protection.outlook.com [40.107.249.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5986B0; Tue, 17 Oct 2023 04:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWmMSVixzF/PIR+tC6JHTsenD9P88P5os/AY41O12ayCN3Blu/EOn1FVsr+HhpwkAo9JaUG+gqItRwcxHu19WmFsU9SX5hqaACr3PcPclreIFUVvIN+1SazdPKaoQVQkey/9ajwTEonZz7ZQFoc68uxRVdhCODx86NWtg5IibO77CdcSDRhBgV6eCVnXGkisPkLeGe0eWOqRy9awtjHYF/jbfv5twa/3CUPEn/LUyYtyoh+6VhNLD93075I7KC1Jre+UX+DYHKUJYwIlM1DVbg+iD1vXBIy4asewZugbyWA2hBdNqH5QMeH/I35r1WEHj1c2GLA7DeuDrlbO6zoREg== 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=q2PhTsUJcMQ4SW1OvpZNerNhpFQAX2maswC0f+vfs70=; b=cKBZ91FIEF0bChbpdwrIiTA+rxIGHVTz3IRkpS82ZweVm6vNL4A311zVFBi6z/YQIvz2GCvQLUKrR32NXO4MpY4TOcuHG2q5Zi1BvOz0IPNMjmWO4ybPdVOMoiMFrllDxWbB2sDkg2pUJdr4sqzNIGHQmeLf1DvgV8PW3VQ1TCaNBnHNGJEoHYKzYSCtEQpaojcDU/KULPMuU+f42yxGdiIo19XNX1mnUK5/oUsChneffMxmGXGpW3LPC5MMPaiHilGl5xCh4ceBg5vWyX8qat5bpnH8QT9vbEclFJBUQV+VE7+JYaZkhz4Lw9BVyO59ACjiEyghRXnAd+Cl4Z1FWg== 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=q2PhTsUJcMQ4SW1OvpZNerNhpFQAX2maswC0f+vfs70=; b=1vComKO4VFSPizXJeM3owWTxtyT+y/5eTj0xYPQ0emlhBG9ZA0tKahN+D/INpShv6syk2HcJNdoqntW6n5zWfxBrXsqiQtazuVBhKeGxXVo6YVkoICPTN/DyEq4tHdEfqwPH3ymj5f731ebnZnIUnRuxF+usode5teDJfgZSOUc= 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 AS8PR08MB6295.eurprd08.prod.outlook.com (2603:10a6:20b:295::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Tue, 17 Oct 2023 11:00:15 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63%6]) with mapi id 15.20.6886.034; Tue, 17 Oct 2023 11:00:15 +0000 From: Javier Carrasco Date: Tue, 17 Oct 2023 13:00:08 +0200 Subject: [PATCH v5 2/4] dt-bindings: touchscreen: add overlay-touchscreen and overlay-buttons properties Message-Id: <20230510-feature-ts_virtobj_patch-v5-2-ff6b5c4db693@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , Bastian Hecht , Michael Riesch Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1697540413; l=8076; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=wU9mLFkAGHcvGbxx9FJKDONfjfWjyoVrkM1llQopSTA=; b=XLIuisbolFeig/Z3ayKvnMqCF4whG3kIp9PhOPP9aY9r/G3u7sNSg5rUUSnyIOJXPEb1bWunM CZSxQ/s9Jm0DHjoSEwuA7wCAD/V5FTX7vqM8eOFcgBlF2ECszSHL0gC X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0250.eurprd07.prod.outlook.com (2603:10a6:803:b4::17) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AS8PR08MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 6075dda0-d713-4eb3-df1d-08dbcf003e1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f9arAlYJR5derrwSuzQAjKxdKsntFwhMekMcG+y78MaXQmpGlU3oFhwjHCQ1pIctcUN3JMI56pl15nuBVQ2m+igStkQ6G18xI060b70pIAz2xr+9bXG7EUj1tCIA/KWWrFMkl+MOK2gVh+GJCO6x75U+qD8nRBD2AV9aDZZETjRexl8syum/73EZ5WGO+u6npV4TCNc/AwpZX5vgNMUVGswmrrm1aodlTiYMoChvbxkQOLjAXGlAqgBNGXVlqu2e6uDEA0DN4yOLvLRzK/RyiO6evHl5KbuuKutnc51f7Vc92COGTwjQ4ssPufDi7PSVh0RI5TGTaejoMKQ58MU93D9Mz8F1JOftuB/ttMoM7joTpSDQSsOxk/xTkkngh9OHGG+EUYGyMA5KMTPIC1Yl2GvRCHeEv74SNxpYpdbWAAuf10T0yiR7sM3GBgjNwTMHOdxy3iWpTeGrrYDCEcdrwUgvmWcCuvijOYjUA3UT9TI/4dTeGSgZpNRPSzfKr/UvX6VWhSrLARIEaK3XMERkKuk8SEQhegMyd0rusk+30EGItFtWFj9FhnUbTLR6rODzav+9u2+oiaVuAqeGGdcquz/ty6cw99SvKnpmzESM9iDntWM3yrgT1+Mo+dyLQKKz 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)(136003)(346002)(376002)(39840400004)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(107886003)(478600001)(38100700002)(52116002)(6506007)(2616005)(6486002)(38350700005)(26005)(6512007)(6666004)(41300700001)(44832011)(5660300002)(4326008)(8936002)(8676002)(316002)(66946007)(86362001)(110136005)(2906002)(66556008)(66476007)(6636002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GjGb6IJm93TKRDL0QvzraKzfNiD2?= =?utf-8?q?X/nRWD3Wx2lua1OnSgkZb7o4r+E4BJAX70gAMz3yNc5hQTDLGJqv44U5hFCkxZZbA?= =?utf-8?q?ERxdKdrizeDTDz+q1RfeHKkmZj9xf1XjNZj/UGAopk7XQerN1HFqfCy+QWRQu7Mv7?= =?utf-8?q?2VHRL3feRV62KPCUkvOSJpxVgTwa1tG/n6lyEKN5n46Tw8hcT4BFolW6myYxj5aQg?= =?utf-8?q?+fVlvJeF+zKpA9GkAWNgz+pQBpVq/GBwpJjJ0J+WNRV+LQm7QcPeXEu9dYrYs9IhG?= =?utf-8?q?JDHn9vSSlXNCoSqAfy2dsE4JW5en5tCRifdzdDBehU/lAzepO39qSdHeBTfq+tr2g?= =?utf-8?q?Kgqb1asRSPKasymuCDRCIkk/k6L6m5yEY7/xN1nS52uPkt8V2X2mxuGMhYVMJei9F?= =?utf-8?q?wxN1WQxY8lypSKzdaqLmYHQbBaJMJUsR3mwq83VjgMtvx8P9SQijX8334TAK6dPpV?= =?utf-8?q?s+TLnT7RZ3x6BAxSJWVnhTWcPato7RjsHNQAXZOOQVruj7lFWGOQ0Q3b0hcI3JXD1?= =?utf-8?q?I9n4/hcaf+p0W5okcwV4BkyYQqd+Sn1IxSUNTTBerIpnVTQA1JpPBBo7lY1bZSbso?= =?utf-8?q?YVyRo7708nCqrTbpXKNEO2fy4hPNRc+fzRuKLO3v/suPllc/ET6PkqonxywGQn7Q/?= =?utf-8?q?Z3W4ffa7FOL4q0ZLHHrrgHkyTJLwF7P07qgDKSmV84FOdlsN1DlmK0q58IBW9CU0R?= =?utf-8?q?iGeZ5bTy3gwCkNV0u5fN1Y05Tw96vo9JoWaJ3x0eN1UwpJvkhkQPFLICB5zuOPjsX?= =?utf-8?q?F+uDaS+qDKol7xFOC9YYQxER8YIC1cMQQZ/l76Xoc5M68JT4SppjUAzG1D9qzZT1S?= =?utf-8?q?5cwQ02DHhhO4oeg6Wjb/jXmn55MdgQ6iP2n7mCphprffByl22E5b2x2hPoTB4VSrm?= =?utf-8?q?KHQ6I6YD/0jm/IqjDPMgz7ZK++piX74Wq9eukDbenouaonKKF1DI1XiHzZ0PiVxm3?= =?utf-8?q?tX5j31artSccmo6h8F9X+WnqQ/DOnfbSpBtt2IgI9dnEDlylxnzp3lEp/6Zy/j2A+?= =?utf-8?q?4y89LaPyIdcfFrAQXvyyID1AwSvl0YA5fJL47Kq/DtQoZP1ZtB5t9VXSmAuB7shsh?= =?utf-8?q?XGImm29LzpUxWXCEdNtSlgrHK0vyjCXwehFgbkWWRAWUwd8KIqPZHqmMaihoacCXm?= =?utf-8?q?5dg30sRlsqofgRUmdIYp/EELNpGaVp3nJxbllv8EU6Nw0i/LYWBG00JVo8+keuMOX?= =?utf-8?q?usvDciksAp4ZWB5qGUF1Sw3uUOXPltOObxm1Dz5OVHrA76es8h3iZBe60EgSAOsMq?= =?utf-8?q?1QSJ62Tig7NbzizPDzqQyxwmTPoOr2574YTNvwNFIqw/nJxBgJYDnXqPwIfIbAzSp?= =?utf-8?q?uKLIlAjqqjH6IgrtwVOr927CVB4fm/A0bgVGcI7PDP09Vhi0w/jKW3Bi7SHe0Og2z?= =?utf-8?q?lfROUx2r6b0kCdiCMxKJgFsJ3gNDY/4RcvzEbi+bkGd4erVykW79jH3No0+kyQQje?= =?utf-8?q?9qctFs26h4TRZFpTDOwnMxWURfcFKkJAJLLimKfuxBxc3QAUP8EwaQPxQ2anbNsNb?= =?utf-8?q?tEsf7xT3X6aLEKXJOPNzPCbfcqqJpDkFeReM03teisEmgydnrTF98xw=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 6075dda0-d713-4eb3-df1d-08dbcf003e1c X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 11:00:15.3057 (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: uK4O51GRrmrmeatfZl7n6nWs5hmKHWp0ZXXDF0VNvzLt38JcoKzPWhDF/coMiUoChqG0p0GHIlEONsc+0URNaUECnSymM8yqi3deiDbgNFQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6295 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The overlay-touchscreen object defines an area within the touchscreen where touch events are reported and their coordinates get converted to the overlay origin. This object avoids getting events from areas that are physically hidden by overlay frames. For touchscreens where overlay buttons on the touchscreen surface are provided, the overlay-buttons object contains a node for every button and the key event that should be reported when pressed. Signed-off-by: Javier Carrasco --- .../bindings/input/touchscreen/touchscreen.yaml | 143 +++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml index 431c13335c40..5c58eb79ee9a 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml @@ -87,6 +87,129 @@ properties: touchscreen-y-plate-ohms: description: Resistance of the Y-plate in Ohms + overlay-touchscreen: + description: Clipped touchscreen area + + This object can be used to describe a frame that restricts the area + within touch events are reported, ignoring the events that occur outside + this area. 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. + + The x-origin and y-origin properties of this object 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 overlay-touchscreen (effective area). + + The following example shows the new touchscreen area and the new origin + (0',0') for the touch events generated by the device. + + Touchscreen (full area) + ┌────────────────────────────────────────┐ + │ ┌───────────────────────────────┐ │ + │ │ │ │ + │ ├ y-size │ │ + │ │ │ │ + │ │ overlay-touchscreen │ │ + │ │ │ │ + │ │ │ │ + │ │ x-size │ │ + │ ┌└──────────────┴────────────────┘ │ + │(0',0') │ + ┌└────────────────────────────────────────┘ + (0,0) + + where (0',0') = (0+x-origin,0+y-origin) + + type: object + $ref: '#/$defs/overlay-node' + unevaluatedProperties: false + + required: + - x-origin + - y-origin + - x-size + - y-size + + overlay-buttons: + description: list of nodes defining the buttons on the touchscreen + + This object can be used to describe buttons on the touchscreen area, + reporting the touch events on their surface as key events instead of + the original touch events. + + This is of special interest if the touchscreen is shipped with a + physical overlay on top of it where a number of buttons with some + predefined functionality are printed. In that case a specific behavior + is expected from those buttons instead of raw touch events. + + The overlay-buttons properties define a per-button area as well as an + origin relative to the real touchscreen origin. Touch events within the + button area are reported as the key event defined in the linux,code + property. Given that the key events do not provide coordinates, the + button origin is only used to place the button area on the touchscreen + surface. Any event outside the overlay-buttons object is reported as a + touch event with no coordinate transformation. + + The following example shows a touchscreen with a single button on it + + Touchscreen (full area) + ┌───────────────────────────────────┐ + │ │ + │ │ + │ ┌─────────┐ │ + │ │button 0 │ │ + │ │KEY_POWER│ │ + │ └─────────┘ │ + │ │ + │ │ + ┌└───────────────────────────────────┘ + (0,0) + + The overlay-buttons object can be combined with the overlay-touchscreen + object as shown in the following example. In that case only the events + within the overlay-touchscreen object are reported as touch events. + + Touchscreen (full area) + ┌─────────┬──────────────────────────────┐ + │ │ │ + │ │ ┌───────────────────────┐ │ + │ button 0│ │ │ │ + │KEY_POWER│ │ │ │ + │ │ │ │ │ + ├─────────┤ │ overlay-touchscreen │ │ + │ │ │ │ │ + │ │ │ │ │ + │ button 1│ │ │ │ + │ KEY_INFO│ ┌└───────────────────────┘ │ + │ │(0',0') │ + ┌└─────────┴──────────────────────────────┘ + (0,0) + + type: object + + patternProperties: + '^button-': + type: object + description: + Each button (key) is represented as a sub-node. + $ref: '#/$defs/overlay-node' + unevaluatedProperties: false + + properties: + label: + $ref: /schemas/types.yaml#/definitions/string + description: descriptive name of the button + + linux,code: true + + required: + - linux,code + - x-origin + - y-origin + - x-size + - y-size + dependencies: touchscreen-size-x: [ touchscreen-size-y ] touchscreen-size-y: [ touchscreen-size-x ] @@ -94,3 +217,23 @@ dependencies: touchscreen-y-mm: [ touchscreen-x-mm ] additionalProperties: true + +$defs: + overlay-node: + type: object + 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 From patchwork Tue Oct 17 11:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 735351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B94E2CDB474 for ; Tue, 17 Oct 2023 11:00:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234964AbjJQLAg (ORCPT ); Tue, 17 Oct 2023 07:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343751AbjJQLAY (ORCPT ); Tue, 17 Oct 2023 07:00:24 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2047.outbound.protection.outlook.com [40.107.249.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20F10EB; Tue, 17 Oct 2023 04:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pf+crTVOsl1KWCPdf+4mutL9lYvo5QnRrAmPtqlesGq43MC3iYajYUtV/HKKB5R6NPbDYh7qD8XMYMleghcxdKKrCJ7l+4TvegnyflWKj8wvbTHtGgUEoI59XrIWzofusQEpqeSuU5F+LPK/J5m6DfdqSUuHZxcMCrUch8btU0kcFwy7e0N4pZ/n1j3GX3uxr+jAx1WECRtwO1j6612Z8EAqLoJiTj+wnWFBY+8fcqe8pClTwxvnqjXr2NqGmmykiLhGhMhfXvZ5SJeDVod+xQzvPgsbdre4ItrcQn/FMuJy7mGlO3LW5MeiJPMFDg5Ce5/x6lywL7E4QN/CYVSO8Q== 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=6s+e6xOeLPB29hou1wYdBocfusQeBy7NbBpEtLp6KMQ=; b=SQthJtuI4IehgmSyCOPLaK9j7RXWAvB4KO9Zk02KZenXXbek/X56lg2lZ0zBJM8kHkYWL+939VUHbaBBYvx0ArMitkfXqxdLb/BMbENVqyzt/WtKQ8rJHXCqLsYViG12fs4pdz+IEt53fmGiV2wTQhvwGRfwOXEi7G5IuVSkrhCb0aXI8oMLyHXz5eO6DsvUinyz/lgfUXEMJhYAxH2PnS6uCbaw0tzf2WmeRi4g8J0EkuTimc3Izuke3jQ11TCb0KTlmQQXjn6X655cyfZiB9uMtv18jlRta/b1xF2vo7d3FT83yOnpufTpbAHg3NTExlxZLufa7ZJ1TR9+uIPq1g== 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=6s+e6xOeLPB29hou1wYdBocfusQeBy7NbBpEtLp6KMQ=; b=e5bgKzsOHnOnlCoKRZlypMT/5SPWP+pYxKIi8DJCC1Wp5w72EKBX1mDB2j96Q/G0cdiFq3DSzVQSdXNqmkQU8mJ7g34BSZvHmc29Jov9EG5A6M+kF4wTwAPplO+3wr/NmSocUmexodIfaBumGIna1TK09UxGi/Q3rAWCiE1Tl84= 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 AS8PR08MB6295.eurprd08.prod.outlook.com (2603:10a6:20b:295::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Tue, 17 Oct 2023 11:00:15 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63%6]) with mapi id 15.20.6886.034; Tue, 17 Oct 2023 11:00:15 +0000 From: Javier Carrasco Date: Tue, 17 Oct 2023 13:00:09 +0200 Subject: [PATCH v5 3/4] Input: st1232 - add touch overlays handling Message-Id: <20230510-feature-ts_virtobj_patch-v5-3-ff6b5c4db693@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , Bastian Hecht , Michael Riesch Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1697540413; l=5477; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=wCiL2h9+IZtOVcDxQziwk7mw/m8sSJBkQv4/SlZOqeA=; b=QTfUM/tIasSQRn3+wFhKeLxyHv33ZDj/X5O0uZ0RPzJHQ1fuIsMSn+mdDmgLKuqd9t34LbFuc 1bxzt7kjuBqBB4yxiaxYNxcHVZKybVu7hz3+Y6NTK1XPPgAAmXAW96V X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0250.eurprd07.prod.outlook.com (2603:10a6:803:b4::17) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AS8PR08MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 0aa2f15b-edee-41c9-f086-08dbcf003e4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E8atFWAx7aL9omG4yQpnOQ0Tn8Qk2/UFiVzPzhMQemkb8MA5fmGUyUmMP3pVV/EoISiAzetmh+Cem9t1wts1S1yD2w4+e4D0epjSxLPjDi9f2pJMZc99iAR3BeGRScAtiEEEgo+2LjTzgFTVuRT5G25nJKBv0Qao9gQoWcohF529AZeU90qGy+LcROvML17qzzitkekvTWnZgU3B+XM0TYqWyjw+dmxl+b/E5Uvpbxs3+1uawBi/8JOVmHKvu1URgbyfI1hhztFn9C9/TFD1SA7lYIacMl70TDSHI4cmNxnlugYzWu32CFvni2hP4uyMnpBUS0aXSytR4jH1kzMSYmSwRxiQFvB/MfMKfPd27hyKifzbovojlgeQUE7j/sXHUvYzBA4X1pnsCAN+tvvXTQ1g25NlmLcEEN8kCA/TmCxtJINduUKci7m9G3vIel0nOKjYtVmjgidPW9eSk8iiP7jvV2fEjWlljJThqD8ptvZBYnRM97d+3WyZQr2amBHw9SPZyMiEU7un+S/kIF+TEW7clucCKIAqQbId6sSO/qjUuEAmguQgvSiQFIB4EyVslttBtpkP6PvSIaFrlPCOI+cdxm/GNkzoerP2OaIXrxU9zg8JmJUL920NILPOM274 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)(136003)(346002)(376002)(39840400004)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(107886003)(478600001)(38100700002)(52116002)(6506007)(2616005)(6486002)(38350700005)(83380400001)(26005)(6512007)(6666004)(41300700001)(44832011)(5660300002)(4326008)(8936002)(8676002)(316002)(66946007)(86362001)(110136005)(2906002)(66556008)(66476007)(6636002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?rIGM1Es91rbuMJjMAJ0bykbNrKM/?= =?utf-8?q?iBHcXgTg1uIt4GZF5UR56lASnoy0dQRNyV5nWkhRZD3pw1PNihXTfjKKZD7R+Ceia?= =?utf-8?q?apscTbM5g4Y2ANWScdRmW/8QFRrwOPpzKzMkMV6AR4rW3UhUlseOHkrGZkscrdoYq?= =?utf-8?q?TKpGm1fqNpkdS7bKLEnE4VYrPDeqodICklSLzKVpB5j9DHSQxQElCH6mTNRmg0M0W?= =?utf-8?q?vApS1lPK7VxQ94l/jNKbKWeqkGSsAFlNNAqVh4ZmLllJ0SXu+bIkwgoetSXmwmlfX?= =?utf-8?q?YXofAqDaC69MwBfeLVaH3Ff0zEcNu+P16+hhg/k5/k5371tMnIxLr3M+CFfCglqa/?= =?utf-8?q?yMPJEx/kwW2G+ocky+kmotKYqRvIlNwi3PWVKwoaXr1jtnMpAj8OXxhd1FCVxSWMf?= =?utf-8?q?5H9PBrewMP3gponXfQTGGuzp66JsqJ3ZdKLFzcftJSZanXh+Sah3ZMmGyPF9buAPs?= =?utf-8?q?LdgTmTMeetQUbK6xANZaurs18AL6+9MZGdUOm7ka1k3lrETAduMnjsqyDKzF3HZr/?= =?utf-8?q?y0kSYDxzvop2vZBRct/0s6dDGt3To99BLNtClm8vEo+WozBhdDfQJgKH6pINFUnFr?= =?utf-8?q?fi58F/dhy9+hi8jZp/Zl0vrN1jJS5BBzY53Ir5eJUYQqfmR5IqlzYBF0w4rV9owaw?= =?utf-8?q?DKQLn1+ajllCOfxCpMR2UAiER0JUpjoV6xZCnAiuqPMpVUDe5UT8xrAcIYDVxBVex?= =?utf-8?q?2GyVXDVHaO2Vo7p/88ZNbQphPHSea5/LwxRfxHrbi7L+wM79+N/7F3DCbqK54vKkt?= =?utf-8?q?yiRAQ65i6LYAaHNDKzvnMTvrp6Chih1/OyRVmcyM5YqAap52T4BDck3sXzuiaPbd8?= =?utf-8?q?TB99rsH/wqdTvnDX5Ag3flQV+YuFr4xE0z5OdM2ytHOlTdHu5r34SvzaLlcGpfOxD?= =?utf-8?q?wmagxPJ56uoA3KZaxoveZj7puNskOolBZI1RJ7HiBxb2qfSDnXZVLnyMiPXZ/j9P0?= =?utf-8?q?1nmgRcqr67YPM6ns7LbMu1JPU/Te2bEVSvUSnm1rDF0ajGNVLhr6/ocH8QGnzpLMP?= =?utf-8?q?F1L0qU39kyYMqZdA2YRB+f3GB3OshQNtiitrWb7Pa79sZYtJnztRtAzSAu5UWbive?= =?utf-8?q?hHsluFwV/HU73q/fKze0Ey6pdSDPJbWos1jRPBuNSzQ4YnlASaW7Qw9LQdPdvh6f4?= =?utf-8?q?0WiRMMzle7zvTwYGnVaZ5qqYVmz/fYBpIf4GcF9wi4QMrqMDF1yMd1FZQgPq8eq71?= =?utf-8?q?D1HsrotIH50074YCRlmtpBiC9MxQOC/bH7TZBvJL2UpMP6TU8qv5quGTKFd/f2Zt4?= =?utf-8?q?h5fR1ybBmkG+05h/bNfvX6N12Bnz/c+e6OISUyutZzWhVp1rYjd0vAdGR8pcUSGvw?= =?utf-8?q?wUn2EXAJ7GHfZ7oQY+/iL8q5Vo0CdkfhMLrBzd6G+Ke0M6qy5GoKTFf9qNOwuvKNd?= =?utf-8?q?vw93zQCwlgdaEWTNs7XPj6IFrrWW4JnzCkPTKQsWtDo5j1hW4g5zeGB3KSCKaqanS?= =?utf-8?q?f+8fXuT/YH+ZFmH8eUMiLfKShxNQuSJbVri7HBOmGq59yW0nPikKGpyZ6H/hcixMC?= =?utf-8?q?dAtZ7mi53lhNMgD2pivnqLrz5c6e0LMdtJk1Leb3XpzSvwBlyZoceic=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 0aa2f15b-edee-41c9-f086-08dbcf003e4e X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 11:00:15.7554 (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: qWnJrAU2XDy6dLSd9ghe2Ark6b8AiesspZtSxl/2ZzcE3VtnlNMUtUpDm2bGiP0m9rbpI6k6vZfd3GblfOeNJrVGnQZdfvudDj7OxLkTwlM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6295 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use touch-overlay to support overlay objects such as buttons and resized frames defined in the device tree. If an overlay-touchscreen is provided, ignore touch events outside of the area defined by its properties. Otherwise, transform the event coordinates to the overlay-touchscreen x and y-axis if required. 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. Signed-off-by: Javier Carrasco --- drivers/input/touchscreen/st1232.c | 70 ++++++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 6475084aee1b..d22f7d57f468 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" @@ -56,6 +57,8 @@ struct st1232_ts_data { struct touchscreen_properties prop; struct dev_pm_qos_request low_latency_req; struct gpio_desc *reset_gpio; + struct input_dev *overlay_keypad; + struct touch_overlay_map *overlay_map; const struct st_chip_info *chip_info; int read_buf_len; u8 *read_buf; @@ -130,6 +133,7 @@ static int st1232_ts_read_resolution(struct st1232_ts_data *ts, u16 *max_x, static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) { struct input_dev *input = ts->input_dev; + struct input_dev *keypad = ts->overlay_keypad; struct input_mt_pos pos[ST_TS_MAX_FINGERS]; u8 z[ST_TS_MAX_FINGERS]; int slots[ST_TS_MAX_FINGERS]; @@ -138,14 +142,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->overlay_map, keypad, + 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]; @@ -226,6 +236,7 @@ static int st1232_ts_probe(struct i2c_client *client) const struct st_chip_info *match; struct st1232_ts_data *ts; struct input_dev *input_dev; + struct input_dev *overlay_keypad; u16 max_x, max_y; int error; @@ -263,8 +274,13 @@ static int st1232_ts_probe(struct i2c_client *client) if (!input_dev) return -ENOMEM; + overlay_keypad = devm_input_allocate_device(&client->dev); + if (!overlay_keypad) + return -ENOMEM; + ts->client = client; ts->input_dev = input_dev; + ts->overlay_keypad = overlay_keypad; ts->reset_gpio = devm_gpiod_get_optional(&client->dev, NULL, GPIOD_OUT_HIGH); @@ -286,24 +302,37 @@ static int st1232_ts_probe(struct i2c_client *client) input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; + overlay_keypad->name = "st1232-keypad"; + overlay_keypad->id.bustype = BUS_I2C; /* Wait until device is ready */ error = st1232_ts_wait_ready(ts); 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 */ + ts->overlay_map = touch_overlay_map_overlay(ts->overlay_keypad); + if (IS_ERR(ts->overlay_map)) + return PTR_ERR(ts->overlay_map); + + if (touch_overlay_mapped_touchscreen(ts->overlay_map)) { + /* Read resolution from the overlay touchscreen if defined */ + touch_overlay_get_touchscreen_abs(ts->overlay_map, + &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, @@ -335,6 +364,19 @@ static int st1232_ts_probe(struct i2c_client *client) return error; } + /* Register keypad input device if overlay buttons were defined */ + if (touch_overlay_mapped_buttons(ts->overlay_map)) { + error = input_register_device(ts->overlay_keypad); + if (error) { + dev_err(&client->dev, + "Unable to register %s input device\n", + overlay_keypad->name); + return error; + } + } else { + input_free_device(ts->overlay_keypad); + } + i2c_set_clientdata(client, ts); return 0; From patchwork Tue Oct 17 11:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 734799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3990ECDB474 for ; Tue, 17 Oct 2023 11:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234941AbjJQLAq (ORCPT ); Tue, 17 Oct 2023 07:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234913AbjJQLAf (ORCPT ); Tue, 17 Oct 2023 07:00:35 -0400 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2047.outbound.protection.outlook.com [40.107.249.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B63BF7; Tue, 17 Oct 2023 04:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B0xMTsXpqwiqQcoRSGaDpNJI2vHwb+LNr6v0o2CLo3cNfGXYZEtqftO5Le3FwUyOe0n/Rqv0X4uyw7/vbf8/oMSZTVcOMIQM/tpknHDWYRZ7QydocVeRE4HAB9VIEYJMZkkHbEVoeV6Kz+2nwnZDYZ/gfupcg0JWr4O2eJo5bIvUh/YjCSMacEJi+0CnKoklswBGfmxbH5aqPvhj+gLntjRQ+ZaY30fPFalbHJF4oQVB23ys3jvFRv2p0gcMs9o/1hhliPFv324PbP7byle6CzM/nV2vrFE5D9JWXBN9PgrTxNI3Hj1tIxCLvcIf87ifgKCz9ngl5Cfmq7fkst2+1Q== 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=s7bJxCqTJ9g4MIATbCMC0K8OKp28hAs7h61w97OYN30=; b=Rm6hkdbZ74HwK/nNGAz1UeN6O4bykfglO6wxnp4Y/iDukE0DCTtU2NVgkAOkI9tEu0GlDTe0FqXSKXUJoTSqRh9ocCfoTe4LpHz4f9yKf5eFAHzDoBL9oNjMWOyne+9KoCKfeIGpWNXN0Sb/Kh55kuOrhWfzooZID1Gxv2zYIXzWqHRw210s1hCS457EcAdF7KzXVUuAzi2J76W5d7TQOjG9/3HqFf8yh6ju2bh9T2rwU6aGviEmPK59hACMtps/uVfYnVLT6sgSZNAUaJfSBvDi1w1fT324CH5ZPS/PRyPgWHfFfdUyczLJXRayJVJt50C+9ulAzd+lZRCyxVpCvQ== 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=s7bJxCqTJ9g4MIATbCMC0K8OKp28hAs7h61w97OYN30=; b=XUtxCd+0Wldq3JggtckXspZtPVEVTDqjXSH8TIt9i//ZHWIo5w6TMs0/CFayZi3H9X02bW6VymEFzayAMuCML6dJkdYwzJQ2RYUZ9nXfrm3mj+r9GlL694CtJxhyvS2rBJffIZqv1yafwQcz7ZT1txJjeXhjK7ejIwtNkJNYNEY= 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 AS8PR08MB6295.eurprd08.prod.outlook.com (2603:10a6:20b:295::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Tue, 17 Oct 2023 11:00:16 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bc92:216b:11ed:db63%6]) with mapi id 15.20.6886.034; Tue, 17 Oct 2023 11:00:16 +0000 From: Javier Carrasco Date: Tue, 17 Oct 2023 13:00:10 +0200 Subject: [PATCH v5 4/4] dt-bindings: input: touchscreen: st1232: add touch-overlay example Message-Id: <20230510-feature-ts_virtobj_patch-v5-4-ff6b5c4db693@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v5-0-ff6b5c4db693@wolfvision.net> To: Dmitry Torokhov , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Henrik Rydberg , Bastian Hecht , Michael Riesch Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, devicetree@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1697540413; l=2380; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=1LZHOKMnwrpCeQ2+qaEcztfZHfZu03BFbjJG0+mOSG0=; b=w7WigiRzqN4MYZGEwYUBbZ/8FDWA3dLCYshizEXgtxJYWAi05xD+3e9pfGquhb2hAKhlPltbc Io7nKxUKK3YB1lEEoU6fDucrSGDl3cgvttsml7Q4EbU3IIpRS7XtPRQ X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0250.eurprd07.prod.outlook.com (2603:10a6:803:b4::17) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|AS8PR08MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d35a0a1-cb80-491b-3b9c-08dbcf003e9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FQPUpZPh3LSfGD1WZwS07NDUjK/YdEKyA8aTEo0RCwmB9uRqvNSgUpnP+2eC15VljqUVQt8p/5N5ZmxF9E0AxqUnKWZINRPRCT5RKBKU/S3uSSoPoxF8LkiT07qbzlhSQuYxXcsxRTsHklRafL/xOscLfZPYLVrFczw7COtuzlwf48rUO5pkn12ovvWwAfXZAeEvJZr2DqgjEA4yr4PEQluyjOd2RULYc9poIkaETcmiQ3NfNq8pBIYIojn9XlqyHjDZVOTAwpq81AKzAOETmvQzF6p4ZENXE/UGRMWjI00S2AprdTkrApZxEkVX+39Q2qGnM+iTuKQOThNsAC8zctetJeQpqetnDhlbYEW9xeUGYXFO+IwNGKQMxCE3LITY+NdHCmCAOUdRcUXeleR6M/9hmakKKo09oHmrxow4KdsDlf2msYhm2dtwnnJnA0fs0VaqgOsx+3WVmxxPCbB50DbXudD9A2tL9sl7fgX6x3bLerbQlCrIDaaatujEkdWGE1/rvyRah9sQFn0PZ6rk5na0trVEgS/cIBtX1Qtou6Fe7WSwTwCw0CXdHPRwJSQ+YhIHL4Xs1TzK3KRTn2KfRycbHzF4Iz+HofpzSlGVn/BhiCSEVViBAiWEgsd6ojh4 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)(136003)(346002)(376002)(39840400004)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(107886003)(478600001)(38100700002)(52116002)(6506007)(2616005)(6486002)(38350700005)(26005)(6512007)(6666004)(41300700001)(44832011)(5660300002)(4326008)(8936002)(8676002)(316002)(66946007)(86362001)(110136005)(2906002)(66556008)(66476007)(6636002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eKHVcGeHAAfrwoZaOmsCNZ4HbkjI?= =?utf-8?q?UekLXg234201EDaYTOWmissMrpKRh+crTXYD+nZPu/I64sSky/YXANzlyrUy+gj8r?= =?utf-8?q?eBrN8UfwJT6yt23NA18G1UKxINVfL72RRbYYMNMiToE1LTITyCxs3ywrbiFb2Cb6w?= =?utf-8?q?1S0lhl9B+ZjhfAFJ2oCJlMeDwbBRz/GAzcoeiaXjyTa9f7P1F2NrfOrGy+yh4xLeY?= =?utf-8?q?ix5tDZ8Z9IsnMx8WN/BZqSZCR4mrv4h4Gh1J5CltUT1yxFqJkEyFYovECG+5QYjue?= =?utf-8?q?lz6JO36JfT6FLqs0RhM7qM1WXDrjg/Q0URGefMqjWJt3rToIFKLcTNH0+N1+Hvb7m?= =?utf-8?q?pMuc5rjIA3NpjotMptA1gjgQCjsKlsYP/KHkJskvK6r7s2vqhHfWpjF2ZlJ3Y0/qv?= =?utf-8?q?9+6b/tc/S6FwR4i8xklJs+v7qA1ZPQqhUMdaQj9vSo3+XXWOfSUax5vcVZQSKTuTX?= =?utf-8?q?aHjDhC2nwOBs77zY5ypOhWDg1uOGZVa2Zpwoz7bOWsRy7KCNtSMtuIPidkznla1+8?= =?utf-8?q?RKuBfodoASHW7qoXK0+vuHRUi2BwyeI+JHTiTryHuhZOeXTvRSvdUj+LxraS+8AxB?= =?utf-8?q?8aewb31NWh4p/IYxvguHIUkUJC2gQq+IJFI3XZbQnkCa0ir0dl/Vxce6HYu61De+l?= =?utf-8?q?CPqhMbvf0G3+RgUYpgzs55G38Ii8uiBXs7Lct5JETM5aMKh7wP1YFC2gWaQRHGzCh?= =?utf-8?q?Q65qd2yB7r79XYaXX8z9lwnxa8pbStVbOSCJuGtIErs9KrnoiRmnn6XZ0jFy6wkIJ?= =?utf-8?q?fAWTUJQnbCZjWa5JAkFWAyCCDI8PcTUI/PWaJUYx/9iw54g7ECdjxMcgXPU3hd2Ri?= =?utf-8?q?hleBqLmUDuRY+uFQEIWxw/DnD30wn8fjuyYMMDRvCCTVYtp5Z72oY27rPda+Sw3zJ?= =?utf-8?q?wOGboh84M/hDA0UxPaTZjci73Jl7nzShWs3na5GRz1wKU4LlZBT+MMRmjh7Ti7MlC?= =?utf-8?q?3KVeUwBxl4yO/Akz1isBSyuJ8vkczwxqX8M5m+aEz7rKyjVxuiu0FmcJHzKdyZFaW?= =?utf-8?q?dDVP255bNmdNh3ztiaGvu1mcUnVMfmNsogGHpSWOGDJrHwTXPHhUiB/k0z/dS7S/N?= =?utf-8?q?FtOZuo/qw4rJdplnVF1wTSlS6dqaY9GixX1gao1CRjPJQf4DJ9mlqS7OgkzTdL/W4?= =?utf-8?q?fQkls5/fREsPIKlIZ3VWcGtJryr0kIJea4SWpDFc5gbFx2fJgcNQ8WHU167ntbelk?= =?utf-8?q?ILb9R1Fy8hicG0/KzTa9mqQT7fX/DycZMPbsXQpRQ40WGZdzZqcwfPXkovNUZEbQA?= =?utf-8?q?b7LLQt1++ZpEo/02GH7eqRS4LbfNcpQN8SgETqzXA0vTwNtscheUorc/5kO50KomN?= =?utf-8?q?TLY+dcqdlU34LZbOLKa9qK82fPEjd/QatCPm55HVZQC+0CLcEnR4oIIytUPvVYTcn?= =?utf-8?q?zOIrrGo+9AquOz60Zx765c5+8/QejtsaZYLPMQTEl1rv0nLYLAfMEWagLGpMhE0qK?= =?utf-8?q?EbYD1cyhOjXi7w3gxTGXrmB3VHygZkOuPcUIRlhazF0p89hhC416l8X3tYgioB/U1?= =?utf-8?q?gKbqcZy7zzjNMqylJnkJE4bK+czqkTJCaEnni+dQqeOb46qZbH4o8fg=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 5d35a0a1-cb80-491b-3b9c-08dbcf003e9b X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 11:00:16.1687 (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: Pa25oFj+U583y1Lgy6cdZYVvyQiDyAlojOh7fOatR5FlFBkHIL2WZgPnxl2Q4+I/DZ5UTjj3x/EYD6Y1kBudPTNdkFcHz5uks20Mo0EopQg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6295 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The st1232 driver supports the overlay-touchscreen and overlay-buttons objects defined in the generic touchscreen bindings and implemented in the touch-overlay module. Add nodes for an overlay touchscreen and overlay buttons to the existing example. Signed-off-by: Javier Carrasco --- .../input/touchscreen/sitronix,st1232.yaml | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml b/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml index 1d8ca19fd37a..f33fc0113a67 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,32 @@ examples: reg = <0x55>; interrupts = <2 0>; gpios = <&gpio1 166 0>; + + overlay-touchscreen { + x-origin = <0>; + x-size = <240>; + y-origin = <40>; + y-size = <280>; + }; + + overlay-buttons { + button-light { + label = "Camera light"; + linux,code = ; + x-origin = <40>; + x-size = <40>; + y-origin = <0>; + y-size = <40>; + }; + + button-power { + label = "Power"; + linux,code = ; + x-origin = <160>; + x-size = <40>; + y-origin = <0>; + y-size = <40>; + }; + }; }; };