From patchwork Thu Aug 24 13:17: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: 13364141 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 A9AF5EE4993 for ; Thu, 24 Aug 2023 13:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240529AbjHXNSE (ORCPT ); Thu, 24 Aug 2023 09:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240994AbjHXNRv (ORCPT ); Thu, 24 Aug 2023 09:17:51 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2051.outbound.protection.outlook.com [40.107.8.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A22181B0; Thu, 24 Aug 2023 06:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oP6y9qMCZLbduX0vQ/4UMTcBRQbFtfZiX4q6unRzBeehh5SbAEOk+4yyEjQRh7tWnmSF0cQkaZ7iNAlBEaEURTH4rU34UAq6OTi/emh1sUZZUHujP2k5UKW8DqQAU2+FSymaiCFSaXeXnxP3MKd0q+d2M/chsXfOdNCOweUI5h24bMuCVvjiicU/Tdlr0gaG0zXBXuCRpnnxKtuLNL+tfkVH7Wr+HZ2DHsApFuwV2Gx9hLZO1N9lq632HV7SeBzuVDwALqLeI1n2BmIu+N5YbnWazZdZX1QU0NmYN4zxLkgQEEoSN+2ukeeH2LNxnYqglhFGVWZAWiRABof57h5oEQ== 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=nqazVur3+oyuyZKRcL1W+LO0K7QxW9KJEE88Bn/Fh5o=; b=BRwvoSNTAA4aDkUTbQZZd2XoT9K/D+QfsdCjuhmAVYyCN4PZtsUOytRmWNHR/eokuXKNQtL7uyGW4a+DF+pLjwR6u8kgleeVq0mJ8sWRtBWmajrFcxsYi8w0rTC+koICcc/Ri+jub1i3w7xttfmPGEYDEdV6qGuXEoHz4yATNufoTIw/qn/V8St497Y90uYH9FIbeVg2IwK4ZOlQDvzoKsoY964uQI9gam7xC+XAeW38maM0qc15MdyP3yFhzBla7y1gMfVaAjSQW03a8aJQvUkYbfnVYIb3M9iatQ+o5GlUAnTbDNSR24q3zrR8usOZXCDQCFdABvYkk40QBaGQQQ== 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=nqazVur3+oyuyZKRcL1W+LO0K7QxW9KJEE88Bn/Fh5o=; b=dWQXa8Gi0yFfWtqy4OEejJJ6BifKoc95BCjAvsAUHI/5rEs4a3HVigCjzupn0KNushKBHHzonD1rdNfocM4pGZ+AgKCpGXgXWFlyelgX9ckVvk0lFD0SziCGVH5qDQVT8ZrgDY12+SVqUJKCMEvbgTmpLbaKiUG1oqQssRm8l/8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) by AM7PR08MB5397.eurprd08.prod.outlook.com (2603:10a6:20b:dd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Thu, 24 Aug 2023 13:17:45 +0000 Received: from AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7]) by AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7%6]) with mapi id 15.20.6699.027; Thu, 24 Aug 2023 13:17:45 +0000 From: Javier Carrasco Date: Thu, 24 Aug 2023 15:17:09 +0200 Subject: [PATCH v4 1/4] Input: touch-overlay - Add touchscreen overlay object handling Message-Id: <20230510-feature-ts_virtobj_patch-v4-1-5c6c0fc1eed6@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@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=1692883063; l=13899; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=JL3dP0O0DqFxMnYjj9dQs6fIBWPOaEgzUZcZU6ZZguM=; b=FPkTzo+0yM0Gt9uoR2bSQpyErmk33BNIRe1l4WAQxStttbUWWHyye76VJZwPPuS8iwJ0Sl2yH fEKTmkeaizTC2aP8toakb4JN4JEdRTxckfh0FoCW/EdTCl3Ve6M+6CD X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0301.eurprd07.prod.outlook.com (2603:10a6:800:130::29) To AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR08MB4966:EE_|AM7PR08MB5397:EE_ X-MS-Office365-Filtering-Correlation-Id: 67e8615b-a5d5-4de1-6b6f-08dba4a4810c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m5rW+dEK4vVmZnZP6LnXO+IOs3jcbntBs2HZb3ZkJ3n2zTVsWFzUmIit61e9hwFhkVphPvach5s7wnF0gmOgldFf4OXbvidEWU10fggy7YImahLzmnsvRHbcUpjkb8dzAjxhRL/5Mw5QFSLkX+uKMHurVwbK54xs+Yx5kD2eknMzU61HfQ6+umxPdnPBYKAbWzageEMPxpkHp4GQ9AH/DnMtWcPTLHRtjcEx41iaNTcamuoCU7jDCxJP6iGIVo+J3LaMTXMe5+zo70VuAW+RLqx2L2vVQ6CS2Ixc74pJHzvjdzmvaErx5YrxcfzhM/FDO9NpUWc2V6P61NemeLzxVaQPkFHs6O+Fq7Jz9+EFH1wXmgUeEB/874dR32bn0R2PVBYewCnn5XTrRHJwtLUPy6G7CTGb46pCpYm9vinhIRefstG8uMmiBN2Fg3/pQ6VryriHbmmeTycOpPkKYbOwkMDXN/xJ4XKUWse+1NXp+h9NAGatKWGbbVzqVgctFKKKevTF199cd+9Qk+6WfFW5crXokVcglBdKUrnvbq2aGP2IRSO7vZKsYDFG0lVE7c/D5hko3PoHrxzOQ5auTNfHf2UMyd/J79+K6dP3L22FqdQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB4966.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39840400004)(366004)(376002)(136003)(396003)(451199024)(1800799009)(186009)(2906002)(30864003)(38350700002)(52116002)(6506007)(6486002)(5660300002)(83380400001)(44832011)(26005)(86362001)(38100700002)(8676002)(107886003)(8936002)(4326008)(2616005)(966005)(66946007)(6512007)(66556008)(316002)(66476007)(110136005)(6636002)(478600001)(6666004)(36756003)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OMRtYYBZkujhuUR6b4P/It4L7o0N?= =?utf-8?q?sbTaUdXoolRKBqSNNljdBW5Ls/NLF0WPjD7ctemV+jCx4uNf3G+2ZConJZCGCD0cF?= =?utf-8?q?zVWwhpv2tl/Z0PVngCB9Tbwc1PADrvs9lmxD52j6+KJgQ4y/WT3YTvCt0OPpyle1N?= =?utf-8?q?EjButBgXiXmu4kUUPJQgZ3frST05KRRl++ycVoR5jwu3dlYaLIrDSEV6ju6Qm6SQv?= =?utf-8?q?UzbuFm+0WbxXqV+kIRDSEp3ciX0ZKKMHh/LMs0WOU17iAebdx4hRoEa+Bmgt5Fb4M?= =?utf-8?q?44iIROfioCvbhRbiU30k4b7Bf9F7qUNHFjFa0aOH9QSrhlYj6HxUQO+44YiOT3ZzG?= =?utf-8?q?JfDurcMog6W+MmEeZfhnrtAGCkw8S8bOJlvBT4CsyB52aLV7TgNIDkvMwUb3fJR7w?= =?utf-8?q?6B30/1O+bC2XPGq4XjeEyowMLPbEsc+N7LDdfxXZJuvqNNjGTZtFXNIiyDXQChWqA?= =?utf-8?q?ZKtzV+/rcrYbW3EeRV7yrFYRyGmB+OD7NKiApwJ3mf9dfOJ1akYWcOC/5dtNZXLZt?= =?utf-8?q?PHbdp56ErlGG3gPAgjwPrkUnk4gbQHlati29zIzHHFFUU3MqpCq1t0lEU0uvsBniL?= =?utf-8?q?GD6MDFxw5WkMW8CwxTt0/YXw2hLUu6kCKLMdZ1I07f5dgnOiOdfqO+ukuKkU9CEgO?= =?utf-8?q?lOP7HRML6zB/5FYYLzzj+Cz1DobeMg8KP9oeZ1lF+37NeiyWAUm+Lyi1/uCr/7jQ+?= =?utf-8?q?PEs6zDG3Kbep6fLLrrHEsqO2hbt7D8NFXgjmipJQNWZhSZ8JA5uOXflywOkl4pk08?= =?utf-8?q?5n57jkwm+jWQjgYh3HCelJPB2QrrqMRjUCHrqh3dSBYcbXYZLRM3ZiANpn1dF2qta?= =?utf-8?q?chzi2pnI+dxWTVv9yNgmWS8oLYcA65YH6JASdOYbtHa83urr0He5f3Mr/K6XNGQf/?= =?utf-8?q?NKQdMsBkpzgEbXnGnAMdZZ8hgoK9m502mHv52BFREHTBpayihlrF9LD+JHXfVCJNR?= =?utf-8?q?oKM0l0zp8CrYcHsCpNYNii2bPVsjqslkGZa25Ajy4jyvQM+y2CDbhoeqB3MjVTB0/?= =?utf-8?q?dkZuTj03YcW6ck4oIz7mVryqtyH4PmgpcMiwZlPixNBGdg3fTKvzO6vcsveoofqXE?= =?utf-8?q?C0xGXUdh+ho0waTaIdhdwmmAIvjmf12MzjFdKNy4PZ+uNbm8+zGt0qyaug9sIQK01?= =?utf-8?q?JlZQdANivyUhsY9SYv9gCxBlKkz250NrGGbq3zXyUmuBKxBBaD5xFZv8SiXnP+oHA?= =?utf-8?q?5CgcmVKc1oXmUo8oQzZ+WFuoNpwI05N2smIe2dBomyUQI9PkvTiW8qmUk3nA2aJkE?= =?utf-8?q?g0jKjOl2CqZolnPw6sdZFWASn95byV3rNxajHc9X7Pi7DEfo0s3Rb3+WghDujZSXv?= =?utf-8?q?PCK8noLPhMm2MSWuP29lDWvB3tc3xZE9M+yGotjYV1pRq0LXN1XzocWfcqaPW4Onm?= =?utf-8?q?oYm1RQX2HfYx5et/atInaG1KugZy4moFGBhDtWpjIREjOCBQOIax5wCs/SyZFkJRP?= =?utf-8?q?EN/x3xinoUR9qfqvka4Ib59gSYlAN1oCRqUaUgU913v6mn6ZDDx5Mh/4Ny2H4Y7/j?= =?utf-8?q?0w8TGCMit4HwZfyrQs7x6LvhEuQ/NkKEQHME71Fy4HiRbMyWVftQHjA=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 67e8615b-a5d5-4de1-6b6f-08dba4a4810c X-MS-Exchange-CrossTenant-AuthSource: AM6PR08MB4966.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:17:45.0925 (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: QGaR3FFGAeThvNBtq2M9K9ysYKcZtnQOGqk9jGAQ/xh+bNCdFpnnl00FyJ+fSt8ZhgtiFQZHD+IvYL4Ga0zHmryHbWQzYxVbI0OB4frNgII= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5397 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 3be1bdfe8ecc..dbc0d315d3d3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21625,6 +21625,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 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 Thu Aug 24 13:17:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13364140 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 2CA38C71145 for ; Thu, 24 Aug 2023 13:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240643AbjHXNSD (ORCPT ); Thu, 24 Aug 2023 09:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241006AbjHXNRw (ORCPT ); Thu, 24 Aug 2023 09:17:52 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2051.outbound.protection.outlook.com [40.107.8.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7925219A; Thu, 24 Aug 2023 06:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N+Epv1woY8dhSXJ7cAsEm3KiCKFxhVrLsmE28Kxo/aMPkgnG93EsL7fubD8GnUkEeYEKiHBfTo/PzV6RMhrkd7PKwHySvhTzdIdU1I4Gdd4B9URfEKK+JVNm9nFlQJcUJkxQLfQ9foTAwlXWF+AboPgw4Xp0WnNGYEYHMJG1yonrKHYN4YeafhWuSacskVSM+gERTX45+Rd/liOZ31US2z/Qhf8IiTXya03ROllV11DD1TOffesg4u5q80OdY7UD6uhHTjIVMf8KaLXnsvgKJSHBHo9foBukR4B5XsYziZYDi4ohhrPXYXKOL8g1+Ru5NpklHdQ+TtV1MP2mywWMvQ== 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=w6/kFKI0NorhWh1j4OXQ2/MPC4YGBNjdWP527DLbt6s=; b=hEXNmCFRrpOM5QX+EEGshe5kG2Z8zHyesiVaRzogXYZEIZbc0Vvw5U187sESo4XjS7fCqhatBAPkqVPBVZBsd5FIupgiZBcGS03i9+yCwrCoB+jllFPB72qDItuKWYNi16faC8GopK9LsvK+fsv8Q5Gn7+Ohk8VdbTVoshRoCmGhqmQRAc5A9j/9Lk7xPjE7wwtISnSUmhdUVEuFbECTa/yhOfNCFA7SRHMF0IdgjGK6x4wHbg327PsFi442SgbnZovKC1wM7x0k3yMxIfxvWhK9SeqWvTjTDOAa4FClckq0fLAKDEGfTPYlvtVGn9ULpXBcFQct8MwKxNOK34ntwQ== 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=w6/kFKI0NorhWh1j4OXQ2/MPC4YGBNjdWP527DLbt6s=; b=X5XoVpZapGzpmpIBxk7bbh8//FuwfVQoMs9g02/4ZdCThOVeMkK75AflRisaAJE76AwggXDF4G+bWlFqR9Ptvd0y6QpQtT3HJNkg7n0c9Mk8K1Ui0+JQchwsVG8mMa2BrmREkXyqun60JJ0lfpLV297aKdISuOu5rb1bx9oZRIw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) by AM7PR08MB5397.eurprd08.prod.outlook.com (2603:10a6:20b:dd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Thu, 24 Aug 2023 13:17:46 +0000 Received: from AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7]) by AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7%6]) with mapi id 15.20.6699.027; Thu, 24 Aug 2023 13:17:46 +0000 From: Javier Carrasco Date: Thu, 24 Aug 2023 15:17:10 +0200 Subject: [PATCH v4 2/4] dt-bindings: touchscreen: add overlay-touchscreen and overlay-buttons properties Message-Id: <20230510-feature-ts_virtobj_patch-v4-2-5c6c0fc1eed6@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@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=1692883063; l=8400; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=ZWJjL37dWNM/Rum/o4XxZV7Z+HY/odWYwXzuhSOL4eo=; b=FdJeaG3FsJ5N6GkYznUooDYeMHIfjoO7hygJLRjqPQ9APVxnedwC608GgM2bQ4nzvRWTL0NxF UPi6H+M3S4/AACRupRpOYDrBO9TIgwOxdv5+YH3j9ncBxe0l2tpvVga X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0301.eurprd07.prod.outlook.com (2603:10a6:800:130::29) To AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR08MB4966:EE_|AM7PR08MB5397:EE_ X-MS-Office365-Filtering-Correlation-Id: 5891f476-724f-475a-24c1-08dba4a4818d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hwU3PXnYCJbP2ItNJdMtbUCVmRY89vQSXU5MuALDXnSeJvxkWp5OXTUodQgyHV9w+lBByNh0izo3bimv0HGVfOdBtCRbMc7gvISaUHkdT00hQ9pyUW5311A0+FbQDyUGlpNxR5g2sTar3xUtuf84GbdaaItkvAap1c/v+s9zrE61RoB+qewJTJDCB8K2d+698996RSf5nuSev8UQ1WCn5JOiMPNO7Ah2/xGxLrKul7o9Xp1TC7zfV6N69qroiqolKGTv7vduoW6yOvaHPvW26q61RcDfsU9Fvv01vOUvEXGIwbaprDkVEKBHXl8MOExAKzY5d35efZiYvwCSwDCQcqu0+d/BmvMJSjot3Dlz4mAFcMuhSXv1Bk+MDBx4NH6lmMTpQas81Vblzro64CJY1VBGcBv9BOYk3CWkqVgp0oTA22qUjtCbxS6IQSt6zIiP+t1JNzqlGdl/rUEjCgF8hlZJylZkVlJjbr1SMWefC5Zlpv/YiCBHwc1pSEFN6NZyXPfW25FKNfc3JLfcbWa+z7JKVeSKopn0gwr3MKb8gBV4uwUzXDmCCX/2ACM0Fez/RR2YaKkYH7fJ32v61yiOLS4CWYP9GbJheDwCekMCFSCcNbAxj0CMgYyumjUa1Lhf X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB4966.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39840400004)(366004)(376002)(136003)(396003)(451199024)(1800799009)(186009)(2906002)(38350700002)(52116002)(6506007)(6486002)(5660300002)(44832011)(26005)(86362001)(38100700002)(8676002)(107886003)(8936002)(4326008)(2616005)(66946007)(6512007)(66556008)(316002)(66476007)(110136005)(6636002)(478600001)(6666004)(36756003)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TDxFqQflM0CCs4IzmE5soPMkl+b/?= =?utf-8?q?HnLYKBuUVoWSrvcpPBP/gKw97cHKh31OmkhyT1K+7DRxhoo/sYwa7D+Bamxadh0IH?= =?utf-8?q?zCUSMpSMe+rdKyU5SSZbaBFsSUTCNfIHizhU17H6PcgOO8K/kHPj837X5PqDQy+GA?= =?utf-8?q?65ebT2/S3wAJFnIg4WMSYu+0ihk69lOQwTSDzhv5jQkoopLjuROAxK7RskI3c9jn2?= =?utf-8?q?fJKCHIPLNOrRCZOn7Q16bR1QEV7ID0Tua7XbhRApqwsXrdJwuRA/c5JfkC/9vFBEQ?= =?utf-8?q?Qshq9pbHMC4ZCV0Xth+jMEMlwYw1HjWJZiunoRR9NM5EiqtgvPQEQv714UbW7JYfa?= =?utf-8?q?Zui/Gm48HtSiA8/TmqqzsUPyvBdzhnw5gkzRh5CfswiXmw0M3K0Q+8SjjKyqWZQAy?= =?utf-8?q?AkrI3jNdTxIq1n6kjpOcTm69Ow5enrX1u/Je+GcpYEow7BcukNt+lFV4TwA7DhmIz?= =?utf-8?q?SpXI6xjJMZ6ShSGVfbEqwzEvYvA+OrJDluddCW726NSyFZUVC7sKWhP4brz6xrDbf?= =?utf-8?q?sFqELqs5K9j7N17DUb426aLvL7SDa4iJwp/Bq7CrX7uxB2fmc+HGnjNnLINkHFdF0?= =?utf-8?q?SUQ9nbHdF8uoFtrLqMdcnCvA5re5y4HgNhDC0NqmlPdQXmpQxr4xJZArELhcAxUQt?= =?utf-8?q?QtElzJUqJbhDuQCZwyhwrmiZrSQz8FKuVEheKmDPF1E3mUSNkOF98FjwH6ez23mAj?= =?utf-8?q?zhebPusI3qluApBpzAmNVb1BNJVXsoYgaIJpIHvmDEp7fnn11EUoMSB3vuAWqJ0r2?= =?utf-8?q?wqYqXE6jVvs8UhMQWpad2f8+I2hUANu290OWnwIdDXzR3XTUQ5HEvlj/vjQjxSHo3?= =?utf-8?q?zcKchYYA8Q4omWOvxybEry5Y+rlJD1RWdsbMty0ZAQTFxG6mwrb+7HODUlSZhrPlQ?= =?utf-8?q?uieEbwQmw6qyPUSz8fVLLjASpkoVgVKavqigzC4jtzFM9sV+6XNnaklTLWb1Pv68Z?= =?utf-8?q?+WPZgOEIllyb+zRuwjMMMXd95w47zFXA0zZfY74nwJ/cgBYuz6Qicmo+23idJMCcl?= =?utf-8?q?G2xgYV7CFUBgw8IC92EfO1KR7npWYJNZVAC8g0o47veNGg1aZCn2OHnalfF0MUhUX?= =?utf-8?q?R1BdAFgDRnhmFuj/bsH6wFvufHqVj8jpvasKZEJllSnf46+520Zis1Bfq/Ra4ixO+?= =?utf-8?q?fjbCbZ9IT5+QH3XpWN9rqBOpf6GSglsbq8dT3WSsLTEHnd6VjOVDaLVmJgBO6LRSZ?= =?utf-8?q?arueEaWs1kzDB9+8wPOReyU+Jic4219fW7FA1LUBcpVpfpOBLKe9vjANt9ZDsOsEK?= =?utf-8?q?PJf5XNfuBOC+N4N2+itn4u86h/sHDw7LFSNr6uckuDVvfOKLTF2i2C1gr9mpNVWpj?= =?utf-8?q?/cjc7Dp9fiajtu2PkiAPJvyce3HD5Hhs4HN5RHwfauvs6QBas4mzk4xG4vKC3OFrc?= =?utf-8?q?xXQGm7+ZD8jzw1dPIU2Zu9FwVfu0VtnupFjUoY9yYm3fP7Nqg7j0DKN86A4rOiwDH?= =?utf-8?q?a4EbKZbA/IhkYJfOXUOh7Ln8Bjmlql0kgXFA3rj2t/CLdDwQ4AruCpCDP/ErPKS1r?= =?utf-8?q?knJ1SLH54gVhIv2rSLvnJVVaKj65nX8I7iJTtPDRuwGSMCr0z1WOons=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 5891f476-724f-475a-24c1-08dba4a4818d X-MS-Exchange-CrossTenant-AuthSource: AM6PR08MB4966.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:17:45.9714 (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: X75KWb3QzM1nwAH6vHJzbvp4w/DqaKGLn8pTbGnr/gV3R4w47P9BlsyJsSx2hN/rc55UdqQ5pcbf7CUUXpB9qKNQkyITlkkwreX9RnWVfgc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5397 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 | 152 +++++++++++++++++++++ 1 file changed, 152 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml index 895592da9626..d90cbb4932b5 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml @@ -80,6 +80,158 @@ 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 + + properties: + x-origin: + description: horizontal origin of the clipped area + $ref: /schemas/types.yaml#/definitions/uint32 + + y-origin: + description: vertical origin of the clipped area + $ref: /schemas/types.yaml#/definitions/uint32 + + x-size: + description: horizontal resolution of the clipped area + $ref: /schemas/types.yaml#/definitions/uint32 + + y-size: + description: vertical resolution of the clipped area + $ref: /schemas/types.yaml#/definitions/uint32 + + 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. + + properties: + label: + $ref: /schemas/types.yaml#/definitions/string + description: descriptive name of the button + + linux,code: true + + x-origin: + description: horizontal origin of the button area + $ref: /schemas/types.yaml#/definitions/uint32 + + y-origin: + description: vertical origin of the button area + $ref: /schemas/types.yaml#/definitions/uint32 + + x-size: + description: horizontal resolution of the button area + $ref: /schemas/types.yaml#/definitions/uint32 + + y-size: + description: vertical resolution of the button area + $ref: /schemas/types.yaml#/definitions/uint32 + + required: + - linux,code + - x-origin + - y-origin + - x-size + - y-size + dependencies: touchscreen-size-x: [ touchscreen-size-y ] touchscreen-size-y: [ touchscreen-size-x ] From patchwork Thu Aug 24 13:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13364138 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 74CA4C7EE43 for ; Thu, 24 Aug 2023 13:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240811AbjHXNSF (ORCPT ); Thu, 24 Aug 2023 09:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241008AbjHXNRx (ORCPT ); Thu, 24 Aug 2023 09:17:53 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2051.outbound.protection.outlook.com [40.107.8.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80691B0; Thu, 24 Aug 2023 06:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DqRRfbKOeerPOyD0VOYcZYAJo61tWPYrqyJGtY7O+XANjdGsbAuqU0U+TfJc5/4v5cv7H+/12ze4OZHN2DSy0dsN0rLxbE7Ch/WQHLJVVvH8Lh1JmcmmVtMna4YNmF4uUqrSoNbnolEicBDUlNqSICJAM2e/XJyPaPDx1eyxcH5ZoO/vwlc4aVHm+tGrs8gpBzqg8QZUVkY8SWjJ9mv9FmU8Enb/aH4mmoih2Hg/qtTGv6Q3iEXxjFrEh06TpOYmVDk+HdPlgCRA1aPbj54FCVCrmFIbi0Dh9DZF0918Mc8Ft+hgqQL6bLYgVFBIM2YgqIppR/YriGnpGEwLlCe8oA== 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=WjRdTHfwaIlIF4OMRo/kbKXkkX1PiAap1FdkmBlexXc9Yf/K4CLVIaeXRBACgbPEhIHYVT3fI13y5tMrm1KolQvFu7h77ajAapcSvq6uB1j+83mw0kgmdCcLWbe8m+P6XbyXPSWRz2tdUZ+/bSH0FYWjc0WXRGQNrLCzjVpiOXowKDRcHqHYT/DufGf+BEvIEwtlefhks8LmGOzG1um9YVMjuK+RE1lphF7BjINSdJjZ1q82H8mdSgwQRgay8OS+oNDap8NxHanuTmMx+sVewEV3LbhH1Hj25p7nfLXceAA8jbmBxmcC/oUuOM808AqCBjb85GcGSPYmqFfngwXhIg== 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=SYnKLykSaLZ4BXAU83IwiuxvP0sKGyilSiAk8H51Fm1ob2NdHG9pTVnFJyFvo825RLInc6+C3U9AApuwkZJkBY4A6ITJaq2N1irGmzVdCs5KDidGcyKglxPDRVP4X720vf04j2tluxmTXThwE/zVjr5zQF3o/vgt64D8Qt12F0g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) by AM7PR08MB5397.eurprd08.prod.outlook.com (2603:10a6:20b:dd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Thu, 24 Aug 2023 13:17:46 +0000 Received: from AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7]) by AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7%6]) with mapi id 15.20.6699.027; Thu, 24 Aug 2023 13:17:46 +0000 From: Javier Carrasco Date: Thu, 24 Aug 2023 15:17:11 +0200 Subject: [PATCH v4 3/4] Input: st1232 - add touch overlays handling Message-Id: <20230510-feature-ts_virtobj_patch-v4-3-5c6c0fc1eed6@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@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=1692883063; l=5477; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=wCiL2h9+IZtOVcDxQziwk7mw/m8sSJBkQv4/SlZOqeA=; b=0aOfbqGOID55D2nKAGaVEbrDuMotGy/iif1NwUDFWaqqnWatCMyUAOt6UPNerHI7gdYb3lAl1 0ajP6u+cIqhCFc78JDet3JdLtw6LxkU18+m81uTC1nAq25ZviGigxY0 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0301.eurprd07.prod.outlook.com (2603:10a6:800:130::29) To AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR08MB4966:EE_|AM7PR08MB5397:EE_ X-MS-Office365-Filtering-Correlation-Id: 03bae396-59e7-483f-45cc-08dba4a481f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uzxzANlSCC/Y3qlm5V8TfmINqlkWfqyXoI5P6t7I+8uHtytO/UHrUmYbJi4E/Fzolr6/vzQ7uOVxQHnSioevCTrdN9TDF2mmsHOZHhxGmpXC4SB1JyUwQ4xdnMhnGeoEMM01rKJaKykJRtRe1nzIz2d9G7bkUdEg/JDskml3F7cv0dK9UCwHQvOOgQiuGGbdu1I7ifn8/9aclGdUJuC3qobSd6AkVyIZ0Sq8mj7FUoLVBq7rKaDXWH7SdlqRYKp77qCFpS2lHB4zgsR4VYjEJ4NzgJx0RRuH7Gm+1JVoiyaY9x5/7q7kxaKJzwiEhbbfChP35sgEc/piVfS/EDH0jbs9Q0l0A/rQx+goCSts4GCgJY1WQAnjabAWD2/3HUZqEchpycnH61YyvK8QO+D4DMjUjo6H7cPgBgSxXqjDwcpmviL7WygcrwRK2or0V2vJkMnU8rmMhpQxN7aqrgqOJNWZXnG/82EAyFifO34LqosRh4g9p/+evlxX74pAbkjlcxF1fkLvK/StYbD60uHXEMtCQkWCOhQsrxYsLPWXcMfAoDp7WGWScm0PKo7DPY2hcn1A9WRkNrIuL85KSZ6taBEJV0ye9Hk2Qr4UFXM9+k2XXDajvGH6bt5yjKhSiDSu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB4966.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39840400004)(366004)(376002)(136003)(396003)(451199024)(1800799009)(186009)(2906002)(38350700002)(52116002)(6506007)(6486002)(5660300002)(83380400001)(44832011)(26005)(86362001)(38100700002)(8676002)(107886003)(8936002)(4326008)(2616005)(66946007)(6512007)(66556008)(316002)(66476007)(110136005)(6636002)(478600001)(6666004)(36756003)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?w3vk+fC43/fEyRnwRwqx4wLWaYkh?= =?utf-8?q?ohqxayzB0uZlTUdwIFxhpR6qgCBTLgy7U+Lo61emYeufc2kh0fA6/mly1C+auoW8Q?= =?utf-8?q?Ps7KsEgF/TxstnozGRbG0sEouWuEcZ/CLj6Yk0Av0Y1xyLKv68Wudm0DkrHFUHWQ9?= =?utf-8?q?zl8kC9MrZdRS3lj6SUqLy0YaYLKYSFFYcBtUnPZd831Np75vh/3E/B8CTbXqwNfrp?= =?utf-8?q?o3xO3+njBliYFV9Tq9i+YY4w9mfM6vNAzeIV01T1XpR6xqQbKZkjY8PbXAWjjWDs9?= =?utf-8?q?xdEJAPtAtu9YBUCGUS5tczAoRgtE2Z0vUvNVtDYaUgmKj++v31451rTUsC6ftCakC?= =?utf-8?q?hHZ7ycN/1hQO+78av3j5ZqqYU11Y6EbCW78GLjS4MmfuSd7eKupi3+i/0c4WyPDd0?= =?utf-8?q?iP4++IIOsC4cJzNn1XNm5uMDXZmYg1TfZu6FZs5WqgRld+aUnV1mG5e2gdcalwPzj?= =?utf-8?q?DB+HlBCTonJPVH1ERTfc3D7/qduJu6BVufHafvBXpzCpOZ60v6dWKTtVk21BsTl92?= =?utf-8?q?Ou6+7HtQAWhYkulpZUkt2nCUIggKmW3oruUqOzXNCueEYJAJvZPYrw9vQJNahq19A?= =?utf-8?q?EziF0q2lwFPUG0d+grjj9nofJFMO+Kd9S5/IUT7S+cVImkQwFQC+ygD8PUUU7hEzn?= =?utf-8?q?8ilAIgiBP7WPnQ44lBMgiLp1wMqqXqibHuDvd6fxRquy8dUr857DqUwmdH5xhz8T5?= =?utf-8?q?0SXUMzJT4LjBTnLwkz37CY0upVcQxTZWc1IKuId4M1g2kDAj53m+cQnGWSC/DPa4n?= =?utf-8?q?CnSHTVL+bGtOM6CXiPAvOHsb61DZI560bWCypmzJ1cSsSRU+69o8gxZoPRTlkhMYd?= =?utf-8?q?jLdbjY7hPB+K/sp+ThXmND+j7N3FmdL2LOUbdaTUO6s1hRwD/f9aK4zyvLe+SVHHc?= =?utf-8?q?wQvJ/7OkVkNXYrHhxIKCP5uiSGssHnfIks5LTyBJ/OAtqHgebOUsb88jQIZtj2zjB?= =?utf-8?q?5VSCwQMxdfV5VSYai8x6E/lLMNIx7EZwYgMXoesyZQ1bSzPt2PK1/K3nbiYDWtETQ?= =?utf-8?q?oEaytkWP2MJUW94kExIf1dhWk5CRif0to6slCjqwtInzv9bB9mK6q1xx32iIZmefO?= =?utf-8?q?224gB5R6UrlmjHLV7nm1enqMkxL9/2gbqGRvWKtbLPE+WErjDvwbcUDMGK1jXtpzm?= =?utf-8?q?x83TxOGa11yRkzuP5qhwH7AfEhaRsxlfD74L+ZQDDAIGvRRl2rePNCGm5Qly630mc?= =?utf-8?q?XO93OxdSN+bi2JewJnaVgv+O2oP/MI9CETdrNffTVcaQOjbuOYigzdIrEn/0cp5FX?= =?utf-8?q?CmZA9Xe0nEKWIvyFeBsOffe9/rom/MPjRlSBSYusd2OJmoX/XhVoNOlhKN/Xhwx/0?= =?utf-8?q?yAzGSVmocIso4+Q9Rtn3MmYM2oY+afdGFnbzkS9u8VTi++hvrd/tORSlViv5GgAEj?= =?utf-8?q?M4u3qFLo2TWX+Ih9+KvGFjmHdWj9gBplNA8iErU1XRmHdjAakUYeA+wwt+00Ryp1u?= =?utf-8?q?0BORynteyBOGM0y18EXkCLr8p+dZoPhdPumE7r5TOs09I59k6y3A4hpzhkSyi71jl?= =?utf-8?q?IIjibUDaxIIChblGmJxHQ+fk0BHbi+/i/aQdl7oH2Yo5QthrJ+T0sIY=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 03bae396-59e7-483f-45cc-08dba4a481f1 X-MS-Exchange-CrossTenant-AuthSource: AM6PR08MB4966.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:17:46.6001 (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: K/0pud9y/jNMjk6SW5LH6UFVlM2YK9Vd42JJJVFUZNkkiNU3uhvmDzaGGEdu9DMpfqqk97gYTtp6xuHrEFT26TrGi3G3WXMYs1WeF0wz5Kc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5397 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 Thu Aug 24 13:17:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13364139 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 616E0C88CB2 for ; Thu, 24 Aug 2023 13:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240371AbjHXNSD (ORCPT ); Thu, 24 Aug 2023 09:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241024AbjHXNRy (ORCPT ); Thu, 24 Aug 2023 09:17:54 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2051.outbound.protection.outlook.com [40.107.8.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1923319A; Thu, 24 Aug 2023 06:17:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bcAOMdzd0wH96/mFg9dbGHa35kZsxIEKLR2SUXVasfvGPLEKHbPXZlbADmllPJhp1SPsrG8heEHulf95SfzIg4hgBk4YNx+JTFMno5OvUnsKyxy160nF1JGOBSycl7XwuNwKz6tsxEbpSgpGLRtxmlqW5OIbBVLdMpZpT4+pXX9BODFdq3IFn1J3o0JRQ/JZNeem61Y0yG4cJ1XSbcsdSxyY7VBu8ZazSrxiBQf8eCcVKOMkHu2d94vTRR0O0jNe3JomSJIqoFZDS2dzMkN+NpacsQ6UJqtchg5DqEFDXFNE8P5ZsGLlUdk9CvcwBwiF3idC6UB2E9jaCuCbNcn0Jw== 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=GYdtFDDBz9yufg0hNLisSjqXC3yZme/QuGXLfwrwy58=; b=HmEq4/yCUiM3zYqsUa+AcU2fZIcNJxn09uoSsiV/mZ9ZdL5OIB0B5k2Bdb5aOfLJM2nxiQHjsBqVwXbzW7kcz9Q5Fs/sOO60bqp5wIVnh6rih0UV9EZIHgVA+xAl5fNuzM7t+ACbXOUxlHpzp+3SWNqDePaz/dTz76sS2qdbLf9phwRiYq4XHVNAUWOqmMAcZoBBore9dzB5ztXA51tOckXrRaj+S5fBVsM/jBp+Q2LjDcsuLZ+ggtLmv7VW+YKxW+ZK6dwPEpiPnRR3m3qhtQGchN2f8mnumGQjT8hVbTygc7NYfBRjH3Rdk2UeeDJTLLrO8+ZXPVx+rqWkzpAxyw== 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=GYdtFDDBz9yufg0hNLisSjqXC3yZme/QuGXLfwrwy58=; b=DtQTLDMgSI6l58wM6sC+O733i23rQiG4414//s6pOb0PA8dOtRIBJyYiqKGFBCyhhnW15Tbl9hvb4TE61cmMmHw/Nu1yVfxtrDUt5OdPTo8Psw6QqL9hEhEhsQlBGckrOeQJvyx1EQIghRu1WsedrljYNEPcMLJ5YNcek42QlMo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) by AM7PR08MB5397.eurprd08.prod.outlook.com (2603:10a6:20b:dd::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Thu, 24 Aug 2023 13:17:47 +0000 Received: from AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7]) by AM6PR08MB4966.eurprd08.prod.outlook.com ([fe80::f7b3:4adb:c638:d8c7%6]) with mapi id 15.20.6699.027; Thu, 24 Aug 2023 13:17:47 +0000 From: Javier Carrasco Date: Thu, 24 Aug 2023 15:17:12 +0200 Subject: [PATCH v4 4/4] dt-bindings: input: touchscreen: st1232: add example with touch-overlay Message-Id: <20230510-feature-ts_virtobj_patch-v4-4-5c6c0fc1eed6@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v4-0-5c6c0fc1eed6@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=1692883063; l=2479; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=44cgFwtZzL2OXOflV7LmrL4zTle4mGDX3x0vaww9+g4=; b=9+7+UTtVdpzK1oVd/L4sTJvBrbxdOJ6P0EV+SUj0CO4syjwj2uZxr/JP+DjUUDvwjNQQMbAHw Z2AZUfSUWmwDKYPSt48xEEmQ8GHyWVtHNa6KpsiUphfcZPg1wBSXiv3 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0301.eurprd07.prod.outlook.com (2603:10a6:800:130::29) To AM6PR08MB4966.eurprd08.prod.outlook.com (2603:10a6:20b:d4::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR08MB4966:EE_|AM7PR08MB5397:EE_ X-MS-Office365-Filtering-Correlation-Id: 841a9e08-cf58-489a-16fe-08dba4a48266 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hi7yxZgzvMUINLQhcz5l3N70AFpAL3QgqoxTdVsMHEOPalbIEuNCpKe2sa3PPoVFW9F//6rxyl1pGk92Nvcx3wo8jojk5AwidC1+yd6HMw6mKiTTr1hmyov5dgyuXSeCIss8uVDFBRKRn/Cx4ByzA2JmIALd30/lugR5fZp9GpwjV2O/MBOLIHkZ+rnCIbLLWTMaHu4Y5EilAuVZAMEsrAxZ6PtXUghZuTsCkELESMZJaz+iyyUxgykmDURHp7HQTh9fmgBPDs4KWt4NKdvz7c6MtkUV7p+BU6qR6VuZn+6KbQU90CKbciCncSACXUosK60YkUx9p9SLcSfZtVQ8f0PsyL1mvOBWpza/dbG2zWuYB7TJEczBsfyQhySoN2egV2Y3qJAB7vIYzgjLYBe23CK25NHURWN9xTzXRblq68cxtH0FfhXHfdfAApQF08uDemIcsX1IrwC6OKahs3tu4Nr+kBfxob40+uqVvsKCYzelIYlhyVMueoNHOcW01LDEdwxXVW7+zQ0kG0Tl0D6XciA/utnPo9IcHYYrD7eDlwMrPqCb9+aPurDgqXRbeHvXgZApCyQ2KnRPTdUVxDuv9A+IkRtwWNVQ7BJYt5+Hf1cVZ19Fv11wlGE82MqvKMj+ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB4966.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39840400004)(366004)(376002)(136003)(396003)(451199024)(1800799009)(186009)(2906002)(38350700002)(52116002)(6506007)(6486002)(5660300002)(44832011)(26005)(86362001)(38100700002)(8676002)(107886003)(8936002)(4326008)(2616005)(66946007)(6512007)(66556008)(316002)(66476007)(110136005)(6636002)(478600001)(6666004)(36756003)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?N7DVkdNRcUheMyZTij1zbXbvhyik?= =?utf-8?q?7Hz/wxHQT8IcjZE+BsBRO5A00Fd0l+/AeP/6xHcBEP5zLAH4lU5SFv0ir0AApcXe+?= =?utf-8?q?b84oBi/fy2ZJHhcxgaA8HKH/ocpH5TWAjNay0XbG8i5qVMgWfRN/RtcxMag13+D9I?= =?utf-8?q?lIlsXTrK73LKy6t3DyPW5q7q9Qx8imtzXq5f0BswXBqtOcIZjhsHyo1xNrxuuQlKa?= =?utf-8?q?3lmhCd2FaJaHGQwvfgkQDVgohOP/R68NiL6DJd8pOAHrrPqiYbvevqS8gBgtfD2+g?= =?utf-8?q?+4/j2FSFvqPrqnLu0LxfOqBMx1jV9k8cDQHbtVPlMzioHq+UapOLKkMj0BodJlQ5n?= =?utf-8?q?qivH4Al1FOQXEwwyCJvraA3HgQ1pLrUZYF4jMtUgke9nJUyA6chVQFPxm0VCcgywG?= =?utf-8?q?9EQPN1SNoBs707FyQzOYKdOH6z8uU3Z8HROSWpyfV3VUCHI68GUIDW3oM4mWb/5bA?= =?utf-8?q?nzVr0ljjVbRRPbsm5G/Gu1APR/2t29FOHRjWWCUi27A2oBr4fqOqYPu5Mc/bNT7Qe?= =?utf-8?q?dfx4dwm17hATa5G/WF1Z5JMZPAMpxArLUtvHeC7iIP5VJtU2PkLLI2m6H8fZWdJ/q?= =?utf-8?q?JjG050ZnpxvFlxDmA9g/junMNx3oUU+cuEXbLjw1AFo2DWourGT+nZ+LYcErfNV5Q?= =?utf-8?q?N+ELdENOv21WwybQfOPOjMjhNgqCRrb24JFCl8Bsgdquew/+52Axw4zaELf6X4Gq9?= =?utf-8?q?Z1y7ncWQ+hyRrxK5mvtWIAfOTyyEyGGPs2MdqVz+cdpjY1aJMPGginRA1P+kUM1vu?= =?utf-8?q?yg8WukN4CLgjWMt98nxF0G4MePyJWYS7+bHnE+XOx6bCyBRvIEfd1q9mMOTPRtBV7?= =?utf-8?q?BDXk30GyVVNk2qE8AkPvliwFfDgdb8CN3FNivGiI2BU/GqLxhmMjVJ9XoA1LweEeE?= =?utf-8?q?0fXhl5+2wTCKWhvaB2OB1ko4ua/DhEo3Hz7OE1ivmAZNvG8iiQfdJl2S+icLzxHIF?= =?utf-8?q?JaFspxJgmOxHnN4f82h8Kes9KyUAxc/rN3HRSeSy/SGWu/fpDO2c1gXFsZmwgj9Z0?= =?utf-8?q?Z3eE6016WVioXQ+MdrDmVb3N6zUAQ+tezk5kO6JHQ42AwvmzEeSogEeSWRBsEgxX3?= =?utf-8?q?tzUF/+YOI31FD6gAv5RWbvqSZ8TgsxRy35rFeeBCZTj7mHj0ArNmPWRl0a5fFJD+1?= =?utf-8?q?m0K06PLuVa8eIDB7ZjtdTAs3CWz0lQMnEKz19J/t7Z2m7ZOEchnQe9Xiak/fHq2n0?= =?utf-8?q?1F8InyMU5FrhfuPubrowfRW1Q4Q5TJHQVmCDPk4x4a0FKWmufqYhOQDZWEP//3hL1?= =?utf-8?q?kzZsKXJUSBtRPRefQIOU6qEGcFY4zPZhwRdDXNayVoKtTAPmxX02jS8GuPHsJgjDI?= =?utf-8?q?vXbqnYyNf9MbfF1jH+8wCGELSfSDs+Lvl3tHE5zL3HnoXABZx2IuqW1YeqmVch6dR?= =?utf-8?q?s7eRHW7fCYmagAfvvfIVp59MZFV5TGa0nlCSb1fMokNc2jUES+DPfullwLnurLurl?= =?utf-8?q?5z/lEV1Noo1YZiLd1I1x7DrLlObxLbH9cS2wSUvV0XxD1cKplZKqyH3epl5KKlR4n?= =?utf-8?q?a3PXk9hPrJT4VAi2mAHuFF1QHXoK+qdQ3SRVuTgccnsaLVK+4f+gN6g=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 841a9e08-cf58-489a-16fe-08dba4a48266 X-MS-Exchange-CrossTenant-AuthSource: AM6PR08MB4966.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 13:17:47.3342 (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: s2ZPFgEr1G54xbut8jO+byeoIod6HAK9+tpbpdrgdhy616GQjguWZDCYQloj8cUNNI+FttJVNmAsPHR4nMMISfw68Vj2eBiz5HA9seLcW0Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5397 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 an example where nodes for an overlay touchscreen and overlay buttons are defined. Signed-off-by: Javier Carrasco --- .../input/touchscreen/sitronix,st1232.yaml | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml b/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml index 1d8ca19fd37a..857b611f84c2 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/sitronix,st1232.yaml @@ -48,3 +48,43 @@ examples: gpios = <&gpio1 166 0>; }; }; + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + touchscreen@55 { + compatible = "sitronix,st1232"; + 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>; + }; + }; + }; + };