From patchwork Fri Jun 16 07:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 693468 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 EB692EB64D8 for ; Fri, 16 Jun 2023 07:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245192AbjFPH3l (ORCPT ); Fri, 16 Jun 2023 03:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244936AbjFPH3X (ORCPT ); Fri, 16 Jun 2023 03:29:23 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2057.outbound.protection.outlook.com [40.107.7.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B782296C; Fri, 16 Jun 2023 00:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DImIAe7RxSnJgJA3HAKB9iMLe3G2IfTLAiL5KA8xUBX63HLPa2Hf8Y2rSjdgHeP3805mPRbFZrbUrMQECEFSm7ZT8jTz9Nc9pAROYxECNIQKbJbLW2nMJm2u6c0WFO1SEpEFEWbLLfbRVPvuBq/fHzEBLhmaeYXpfDXxiWqyzwguTHW2mioLOHYduQ5edJqqjUUjyylyuNSuA0kt1U8IedztVpL1nMdApqK0WAdCfDgjW7zHlo8kpQUhAK1pQNH4eCZ9/DK2IPf733/q9+eQ5AuXXvZfL+wmg83O8K9WykBf6NNEjWf/cPsXVXZK889mzU3kDsoex2A0A1nk3S/fdQ== 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=4ZoO1BOL9DgnvOveaky/g3h+zoxmJJ/Fo2vXBEea9P0=; b=JUTsMOlrK/C3m8LOepcrFle9mBRY81T5d2CADbsTJetw/7L1GMTu/DZrd0UBv9wk6nABohUx7FmLSoT11cc6TLXvuwOqx9uJ+C/HnTbqrv+md1/yQiIPxFPDaJI0pjWjAtkAENZBXkJHUMugUHbD7dnMBZSealuPHbolquTRBVMGQS7RnJqaQ/iHDsL/far7GynxDcinwpUqSD2fJYEJnSAOSzrY6blGgTSXPy2pEzg2+YTfndxCi5IICYDplk89VtNXpE64HxHcxFMdcIDmAjtW3/JWn8SZA2Bd9tNMR5HDu66FNyivuYHlqnnmonzPL2yqPfFZjOf619pBclHNRA== 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=4ZoO1BOL9DgnvOveaky/g3h+zoxmJJ/Fo2vXBEea9P0=; b=v24uhm8iJW+DThZy257H5mfbqwZTY2fdaYVgLqcBKu1FxrpsEbILkx+PS8QhyIqTboFsbQMo8INXbgZ/6VPFk43i8YWDg9i2qD598B0kO5W2BPPy9OsR0uuyVB7fJMyoXIH3dreHG7Mu+qJzEy3j5r4fez+h3CHpVBSZMVgAP2U= 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 GV1PR08MB9916.eurprd08.prod.outlook.com (2603:10a6:150:a6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 07:29:10 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d%4]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 07:29:10 +0000 From: Javier Carrasco Date: Fri, 16 Jun 2023 09:28:51 +0200 Subject: [PATCH v3 1/4] Input: ts-overlay - Add touchscreen overlay object handling Message-Id: <20230510-feature-ts_virtobj_patch-v3-1-b4fb7fc4bab7@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@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=1686900549; l=12899; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=tlZJR0Nq53au4WcWFP/JGpj/86S4CM5u3uJYnsxte2M=; b=827nGfSzY4c4x/zjOH+BtHaeEq/+9Xh91NUVmtXyxbM2B2TPDp4wS+B7U6aW6pP9KnI+LFgaq RPvx1fKvUJSDIb3ZpYhh8JO+V6L/iq11DbcGZcLJ3F7pFJKzINj5OEB X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0197.eurprd07.prod.outlook.com (2603:10a6:802:3f::21) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|GV1PR08MB9916:EE_ X-MS-Office365-Filtering-Correlation-Id: 24d3bc74-163c-4cf4-f87b-08db6e3b6006 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iH++QW1ZrApgWYOeRHDMjuUJP61Nn/Zpqm68IFVI+sqyhkqSQHuWL/3mZq3toJWT3UVCBDDwXVP8QP/YY06ODwxy4fMoXaMduNsurU+JampvASgCHscoCEHdGb39b38pfCoXSINUi1AzT6Tpkm2BmpREBQ6dmDM0EP7wLXkgt90p73QeigmLUIMIS1jNoSdWoO5gFNliugQYi8Th7N1GeQkT5F6fZjjQg+BU/XgKha58aRF7Mq8QuAivSbvyspTblhrKzN3xa0mf+CO6nY73IgqzuadoxwxqP/pREt7PNyuv27CU1TxnllAUF/9MM67FUqGu35Df7u5l6NA8+NKYElIF2nYufVIiBxIqJVJ01LadMTD3lZt4jwjgmifZUH0SjKxrqwk38ym7E9JJ/yPwPCV8NMjpDLsa3Um4VxBzQPkpb5MKE0wjxnte3KSB/rH3mv+mPz+j3PmmIpmfFEc7bXic3Cszs1LyGmxZYURRDfZn3h2KhywRTq7kBrVgtGC468JtutacsfUj/wTPApfGIz5JpmHJceA9NUuJ79QTgw3NYW/FmWZQKr7VyYS18PQwMseqqoB0ottp2Jqh7v4nVToOwpD5TuZDyouVgmOVV8s= 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:(13230028)(4636009)(376002)(136003)(396003)(366004)(39850400004)(346002)(451199021)(36756003)(86362001)(30864003)(2906002)(44832011)(83380400001)(6486002)(6666004)(186003)(52116002)(107886003)(6512007)(6506007)(26005)(6636002)(66476007)(966005)(110136005)(316002)(41300700001)(38100700002)(4326008)(66556008)(2616005)(38350700002)(66946007)(5660300002)(478600001)(8676002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AQwXZgrgar/WmgIDIdGd73yV9J/E?= =?utf-8?q?N/2PiwQHM3Epaoh92+kruUZu0f0IqcO7NNY3cwW0JRsPxxelwcYdfo6XkpONYGRJ1?= =?utf-8?q?OVzG6jnHQX8mikzSpqlcwivM1jLT1u7OiKUJnriE162zn3SI3V0jObhAfJ/Lpclau?= =?utf-8?q?xW2eVdmECUZM46tvl1DCE3q9DZbiCFPwiiJJspOpO/UXSsslNTq+aaQKYcGH7Ap6R?= =?utf-8?q?7ADNTHTNIGiz6ZojMSkN0CwcJBUXlhDHwQtZ2GwyUhYTl8hGrunjRBT/LxF0yR9XZ?= =?utf-8?q?zJJqEcOcFP+FIQtio8tQVnVJaoQcd96PfU3bMP7DRj18EyAw04r0dvFXMqHI4vAQm?= =?utf-8?q?RADzm6cQl1uvIZtDGqgY5K45OEDUMnBx4wGZIZJvP/LQRP5aBQ31llIP9fYMZa7Bm?= =?utf-8?q?zmSazG3j4r+KwiOI28AcPD8yW9S/MZ3wjyyExSlPex7/0f78QmmRLd+cfFrdsONsX?= =?utf-8?q?zvVAjtTgA4odMH/MLjImavMoDo/knKnAgzYpsP+xzquuNjTuBxMqT4Swet/b19nNn?= =?utf-8?q?moQDXaJl1gQlGfRDLGGD59xjVLdIkuHanERNNXwcDM4Yz2gTTCoLbz8PKfsPLewh/?= =?utf-8?q?2+/T6pjGBMB/42tSRsjenhQ48jkFILVIeEd8FCQpqnCaui9L3M2nhZhjM9wxczn0R?= =?utf-8?q?MVh09WYgbKdDit6Hf7arKI0rAZx8iVCIacMfoU/Pvuz3ejUybwrNVjuklSsDDs/mD?= =?utf-8?q?Rt8DA23j2NQePSFddgrusaQpydK6kUjZYSC2jcuXJdIBIgW32/rW71EbswHaL7nE/?= =?utf-8?q?+GnjgEzCAf3yVBKt1+5jWpy8s0MzfwkB2xOUCm2Es7zkLI2KtNSHSK/zOyu22s9eJ?= =?utf-8?q?dNKwBIy9uAhFe/2y6mGuRsfPzKGPDqXRprf/PtAcYIMA38WtzyI1KhAnA9buXEX+g?= =?utf-8?q?B93sU77g5SYCSUQDaX+28gWEb24B6j6i2yzMicw1gfjjoq3JfhF3DEvsSarNRtore?= =?utf-8?q?ppveGP8qtFHmCLi9Bu8EAiJUItl8X2ok0eq2tO7NkoVWt54VhrCAO6/KgwMTXpo3Z?= =?utf-8?q?0vqO3ywCWg5V05XzQ9ZajFuly8v+2AiJ9kMixd4JwScDFi1Ef1Rp1BoPruF6aFNAX?= =?utf-8?q?cyvH79c59u1fF+TzK9VPwIc9gmYEogMTWR1uBRiEeE5xDJA7Tr8ivyWjYzGn0f0MC?= =?utf-8?q?SLEDVIJDgGWzw5vJZ8i3EJvDTKyspVQYWZXAQlloQtUs7jSk45WIU/EaaxAQGJEvd?= =?utf-8?q?9V7qDJ2FInTBq2EUxdRZG0iFLik1g5M4MxKbEKpvUfyq+yJpgcvNYQEcnPREbkrNE?= =?utf-8?q?cvo7PgpHuEFSavoibpVxqjdX5FQ5GQScQ8UDuyV82bOzlA6E9Z3pAWeErNAhJzEAK?= =?utf-8?q?j+SxxBdtLCuTk4gQx+j7rQ1b+zerf83msGzMNBgngzDMI4SP5WVXuobXU/B4Msw8k?= =?utf-8?q?Dn09T5+MQeJjfL9QzpTw108TEIJsvNi2ZbKjdxA5NwNZIZPvAKouh3Pv2X5sMsinT?= =?utf-8?q?mLOUQNywSl38zRBS0GsD18gThx5zUoH4pMrxeRs2fwlnuEbeyv+VIHdSLqUQs+suA?= =?utf-8?q?eoGgPefehJlOdK4pwy7mSj+Iy/P8Vlc/qA=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 24d3bc74-163c-4cf4-f87b-08db6e3b6006 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 07:29:09.7394 (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: UTgbeWmIYVjumNZQysVvbu4gyG9OYu5O7EGEOWThgQmQsGZOcYpwmxzKTQ1lMK2rHQw3/wgpr2y4GdnwxLDSKisEtk/Icg14dfRZ9mF8x9w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB9916 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Some touchscreens 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/touchscreen/Kconfig | 9 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/ts-overlay.c | 356 +++++++++++++++++++++++++++++++++ include/linux/input/ts-overlay.h | 43 ++++ 5 files changed, 416 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7e0b87d5aa2e..db9427926a4c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21434,6 +21434,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/ +TOUCHSCREEN OVERLAY OBJECTS +M: Javier Carrasco +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/input/touchscreen/ts-overlay.c +F: include/linux/input/ts-overlay.h + TTY LAYER M: Greg Kroah-Hartman M: Jiri Slaby diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 143ff43c67ae..8382a4d68326 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1388,4 +1388,13 @@ config TOUCHSCREEN_HIMAX_HX83112B To compile this driver as a module, choose M here: the module will be called himax_hx83112b. +config TOUCHSCREEN_TS_OVERLAY + bool "Touchscreen Overlay Objects" + help + Say Y here if you are using a touchscreen driver that supports + printed overlays with keys or a clipped touchscreen area. + + Should be selected by the touchscren drivers that support + this feature. + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 159cd5136fdb..f554826706ff 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -117,3 +117,4 @@ obj-$(CONFIG_TOUCHSCREEN_RASPBERRYPI_FW) += raspberrypi-ts.o obj-$(CONFIG_TOUCHSCREEN_IQS5XX) += iqs5xx.o obj-$(CONFIG_TOUCHSCREEN_ZINITIX) += zinitix.o obj-$(CONFIG_TOUCHSCREEN_HIMAX_HX83112B) += himax_hx83112b.o +obj-$(CONFIG_TOUCHSCREEN_TS_OVERLAY) += ts-overlay.o diff --git a/drivers/input/touchscreen/ts-overlay.c b/drivers/input/touchscreen/ts-overlay.c new file mode 100644 index 000000000000..7afa77d86c1f --- /dev/null +++ b/drivers/input/touchscreen/ts-overlay.c @@ -0,0 +1,356 @@ +// 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 ts_overlay_valid_objects { + TOUCHSCREEN, + BUTTON, +}; + +static const char *const ts_overlay_names[] = { + [TOUCHSCREEN] = "overlay-touchscreen", + [BUTTON] = "overlay-buttons", +}; + +struct ts_overlay_shape { + u32 x_origin; + u32 y_origin; + u32 x_size; + u32 y_size; +}; + +struct ts_overlay_button { + struct ts_overlay_shape shape; + u32 key; + bool pressed; + int slot; +}; + +static int ts_overlay_get_shape_properties(struct fwnode_handle *child_node, + struct ts_overlay_shape *shape) +{ + int rc; + + rc = fwnode_property_read_u32(child_node, "x-origin", &shape->x_origin); + if (rc < 0) + return rc; + + rc = fwnode_property_read_u32(child_node, "y-origin", &shape->y_origin); + if (rc < 0) + return rc; + + rc = fwnode_property_read_u32(child_node, "x-size", &shape->x_size); + if (rc < 0) + return rc; + + rc = fwnode_property_read_u32(child_node, "y-size", &shape->y_size); + if (rc < 0) + return rc; + + return 0; +} + +static int ts_overlay_get_button_properties(struct device *dev, + struct fwnode_handle *child_node, + struct ts_overlay_button *btn) +{ + struct fwnode_handle *child_btn; + int rc; + int j = 0; + + fwnode_for_each_child_node(child_node, child_btn) { + rc = ts_overlay_get_shape_properties(child_btn, &btn[j].shape); + if (rc < 0) + goto button_prop_cleanup; + + rc = fwnode_property_read_u32(child_btn, "linux,code", + &btn[j].key); + if (rc < 0) + goto button_prop_cleanup; + + dev_info(dev, "Added button at (%u, %u), size %ux%u, code=%u\n", + btn[j].shape.x_origin, btn[j].shape.y_origin, + btn[j].shape.x_size, btn[j].shape.y_size, btn[j].key); + j++; + } + + return 0; + +button_prop_cleanup: + fwnode_handle_put(child_btn); + return rc; +} + +void ts_overlay_set_button_caps(struct ts_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); +} +EXPORT_SYMBOL(ts_overlay_set_button_caps); + +static int ts_overlay_count_buttons(struct device *dev) +{ + struct fwnode_handle *child_node; + struct fwnode_handle *child_button; + int count = 0; + + child_node = device_get_named_child_node(dev, ts_overlay_names[BUTTON]); + if (!child_node) + return 0; + + fwnode_for_each_child_node(child_node, child_button) + count++; + fwnode_handle_put(child_node); + + return count; +} + +static int ts_overlay_map_touchscreen(struct device *dev, + struct ts_overlay_map *map) +{ + struct fwnode_handle *child; + int rc = 0; + + child = device_get_named_child_node(dev, ts_overlay_names[TOUCHSCREEN]); + if (!child) + goto touchscreen_ret; + + map->touchscreen = + devm_kzalloc(dev, sizeof(*map->touchscreen), GFP_KERNEL); + if (!map->touchscreen) { + rc = -ENOMEM; + goto touchscreen_handle; + } + rc = ts_overlay_get_shape_properties(child, map->touchscreen); + if (rc < 0) + goto touchscreen_free; + + map->overlay_touchscreen = true; + dev_info(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); + + rc = 0; + goto touchscreen_handle; + +touchscreen_free: + devm_kfree(dev, map->touchscreen); +touchscreen_handle: + fwnode_handle_put(child); +touchscreen_ret: + return rc; +} + +static int ts_overlay_map_buttons(struct device *dev, + struct ts_overlay_map *map, + struct input_dev *input) +{ + struct fwnode_handle *child; + u32 button_count; + int rc = 0; + + button_count = ts_overlay_count_buttons(dev); + if (button_count) { + map->buttons = devm_kcalloc(dev, button_count, + sizeof(*map->buttons), GFP_KERNEL); + if (!map->buttons) { + rc = -ENOMEM; + goto map_buttons_ret; + } + child = device_get_named_child_node(dev, + ts_overlay_names[BUTTON]); + if (unlikely(!child)) + goto map_buttons_free; + + rc = ts_overlay_get_button_properties(dev, child, map->buttons); + if (rc < 0) + goto map_buttons_free; + + map->button_count = button_count; + } + + return 0; + +map_buttons_free: + devm_kfree(dev, map->buttons); +map_buttons_ret: + return rc; +} + +static bool ts_overlay_defined_objects(struct device *dev) +{ + struct fwnode_handle *child; + int i; + + for (i = 0; i < ARRAY_SIZE(ts_overlay_names); i++) { + child = device_get_named_child_node(dev, ts_overlay_names[i]); + if (child) { + fwnode_handle_put(child); + return true; + } + fwnode_handle_put(child); + } + + return false; +} + +struct ts_overlay_map *ts_overlay_map_objects(struct device *dev, + struct input_dev *input) +{ + struct ts_overlay_map *map = NULL; + int rc; + + if (!ts_overlay_defined_objects(dev)) + return NULL; + + map = devm_kzalloc(dev, sizeof(*map), GFP_KERNEL); + if (!map) { + rc = -ENOMEM; + goto objects_err; + } + rc = ts_overlay_map_touchscreen(dev, map); + if (rc < 0) + goto objects_free; + + rc = ts_overlay_map_buttons(dev, map, input); + if (rc < 0) + goto objects_free; + + return map; + +objects_free: + devm_kfree(dev, map); +objects_err: + return ERR_PTR(rc); +} +EXPORT_SYMBOL(ts_overlay_map_objects); + +void ts_overlay_get_touchscreen_abs(struct ts_overlay_map *map, u16 *x, u16 *y) +{ + *x = map->touchscreen->x_size - 1; + *y = map->touchscreen->y_size - 1; +} +EXPORT_SYMBOL(ts_overlay_get_touchscreen_abs); + +static bool ts_overlay_shape_event(struct ts_overlay_shape *shape, u32 x, u32 y) +{ + if (!shape) + return false; + + if (x >= shape->x_origin && x < (shape->x_origin + shape->x_size) && + y >= shape->y_origin && y < (shape->y_origin + shape->y_size)) + return true; + + return false; +} + +static bool ts_overlay_touchscreen_event(struct ts_overlay_shape *touchscreen, + u32 *x, u32 *y) +{ + if (ts_overlay_shape_event(touchscreen, *x, *y)) { + *x -= touchscreen->x_origin; + *y -= touchscreen->y_origin; + return true; + } + + return false; +} + +bool ts_overlay_mapped_touchscreen(struct ts_overlay_map *map) +{ + if (!map || !map->overlay_touchscreen) + return false; + + return true; +} +EXPORT_SYMBOL(ts_overlay_mapped_touchscreen); + +bool ts_overlay_mapped_buttons(struct ts_overlay_map *map) +{ + if (!map || !map->button_count) + return false; + + return true; +} +EXPORT_SYMBOL(ts_overlay_mapped_buttons); + +bool ts_overlay_mt_on_touchscreen(struct ts_overlay_map *map, u32 *x, u32 *y) +{ + if (!ts_overlay_mapped_touchscreen(map)) + return true; + + if (!ts_overlay_touchscreen_event(map->touchscreen, x, y)) + return false; + + return true; +} +EXPORT_SYMBOL(ts_overlay_mt_on_touchscreen); + +bool ts_overlay_button_press(struct ts_overlay_map *map, + struct input_dev *input, u32 x, u32 y, u32 slot) +{ + int i; + + if (!ts_overlay_mapped_buttons(map)) + return false; + + for (i = 0; i < map->button_count; i++) { + if (ts_overlay_shape_event(&map->buttons[i].shape, x, y)) { + input_report_key(input, map->buttons[i].key, 1); + map->buttons[i].pressed = true; + map->buttons[i].slot = slot; + return true; + } + } + + return false; +} +EXPORT_SYMBOL(ts_overlay_button_press); + +bool ts_overlay_is_button_slot(struct ts_overlay_map *map, int slot) +{ + int i; + + if (!map || !map->button_count) + return false; + + for (i = 0; i < map->button_count; i++) { + if (map->buttons[i].pressed && map->buttons[i].slot == slot) + return true; + } + + return false; +} +EXPORT_SYMBOL(ts_overlay_is_button_slot); + +void ts_overlay_button_release(struct ts_overlay_map *map, + struct input_dev *input, u32 slot) +{ + int i; + + if (!map || !map->button_count) + return; + + for (i = 0; i < map->button_count; i++) { + if (map->buttons[i].pressed && map->buttons[i].slot == slot) { + input_report_key(input, map->buttons[i].key, 0); + map->buttons[i].pressed = false; + } + } +} +EXPORT_SYMBOL(ts_overlay_button_release); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Helper functions for overlay objects on touchscreens"); diff --git a/include/linux/input/ts-overlay.h b/include/linux/input/ts-overlay.h new file mode 100644 index 000000000000..b75df0dec3ab --- /dev/null +++ b/include/linux/input/ts-overlay.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Javier Carrasco + */ + +#ifndef _TS_OVERLAY +#define _TS_OVERLAY + +#include + +struct input_dev; +struct device; + +struct ts_overlay_map { + struct ts_overlay_shape *touchscreen; + bool overlay_touchscreen; + struct ts_overlay_button *buttons; + u32 button_count; +}; + +struct ts_overlay_map *ts_overlay_map_objects(struct device *dev, + struct input_dev *input); + +void ts_overlay_get_touchscreen_abs(struct ts_overlay_map *map, u16 *x, u16 *y); + +bool ts_overlay_mapped_touchscreen(struct ts_overlay_map *map); + +bool ts_overlay_mapped_buttons(struct ts_overlay_map *map); + +bool ts_overlay_mt_on_touchscreen(struct ts_overlay_map *map, u32 *x, u32 *y); + +bool ts_overlay_button_press(struct ts_overlay_map *map, + struct input_dev *input, u32 x, u32 y, u32 slot); + +bool ts_overlay_is_button_slot(struct ts_overlay_map *map, int slot); + +void ts_overlay_button_release(struct ts_overlay_map *map, + struct input_dev *input, u32 slot); + +void ts_overlay_set_button_caps(struct ts_overlay_map *map, + struct input_dev *dev); + +#endif From patchwork Fri Jun 16 07:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 693743 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 0ABE4EB64D7 for ; Fri, 16 Jun 2023 07:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245175AbjFPH3i (ORCPT ); Fri, 16 Jun 2023 03:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245003AbjFPH3U (ORCPT ); Fri, 16 Jun 2023 03:29:20 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2057.outbound.protection.outlook.com [40.107.7.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B519B1FF7; Fri, 16 Jun 2023 00:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KW2ZCjVcqrSx0jJJlLLU7fs2bTIcKTmMuywe8sLkT86jEszPKNqzDzBhZ4pyZ4LxhrQ/aG0+27njd9YBuujK1+cz1Nhr6BS1evM7Yv5oPI2EGHDPDQCZaJYANKtkf/5G1pv/M8jJSaj7nxhrKsmCrraqx66Ct8yqy+I6dPDEwHBdTCzRRhlnMvs2aYRQ2f0L1iGC+1Wjlufg7CxlTTH8YQdEsHH2TQffbLgWd3SAGWH17N1R6g5nmx6t92jUxiXSiJB7iwsiB1pi+JAgicxKQjjju6W8M3BNXe4se0PlEyXenJ1oOFmD6siRt3BpGJOFEk3c+VmcFJh9UlT3YXPlYQ== 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=luM64zW1esd8nyMkAcQ8THDxfES4R30WKA+gJAsMMcI=; b=AUbat4JMqQt1TGV8SmQOr/VMdRZmWMLUXRCj6SETZpfkSvW8yZnIGRTVzG1qDH0QYlbK7WFIcAXmni2OKjYB7RM9/rRYURe3UIwQcxq3LkF9WTIHeodSodsiHqzGTggzXZ5RdM5YwpxxCz6NVK7YrRwZghrWDEiAgiSut20he4OF4xeUvWcJQnPT+cecW0/XpzoeSiq808GonCPbOHi+JriH/QLbf/9/lp2tlPuvh9MNFNL02TxxcPwnkxfxGLbdkHBvb9MMs5+AcHOO0SmBpWS4rFkZNlt4SUpEeIyXJ1MEqKqIzUBmn3oJGT1qowkRy4Hg0nyC3cQOiI/GwtP/mg== 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=luM64zW1esd8nyMkAcQ8THDxfES4R30WKA+gJAsMMcI=; b=1hSwE+AkBP3lK4OdE+U86rxzxh+ufuxjKTvQrlmIeLNW1bReCVKFkezxq2YQjPakciT0Wlj1BZPSRgYyju1PNjuNun5LFLygEhIWIckugUpePEA4HaDtV4Ul/j3iym9djP4QlgaPltgTWdTn+HSn3Y51HpaHw3IfloIc+1hNxNI= 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 GV1PR08MB9916.eurprd08.prod.outlook.com (2603:10a6:150:a6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 07:29:10 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d%4]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 07:29:10 +0000 From: Javier Carrasco Date: Fri, 16 Jun 2023 09:28:52 +0200 Subject: [PATCH v3 2/4] dt-bindings: touchscreen: add overlay-touchscreen and overlay-buttons properties Message-Id: <20230510-feature-ts_virtobj_patch-v3-2-b4fb7fc4bab7@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@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=1686900549; l=8153; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=KNTIfSGexgxo0tpiTfZ54RzJDduakcxWEC2nJNHuT4s=; b=ltNIhCOlY0PJqO16dKMpSugz7WDUxohG992RsHoBdVKwGna767TwF4PHsB4W/rrEgU+OFPTAU aJ/OpiRbkckAu/gvx3+boq6voCh3LQ8bLDWcwPB1y9nCvOnSP77rTGF X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0197.eurprd07.prod.outlook.com (2603:10a6:802:3f::21) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|GV1PR08MB9916:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bee18e1-eb01-49d8-b904-08db6e3b6049 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LZvAZ+I2ruoVlLg1Ha1+PWtFBhlIURvB0d6Urq8B3txBIG3Yu8Wrfmcv8OFUZXmVgYBoHYkHO3mNXbneSCDFEY+SRpxqG7uMscr2B6H+2//fGgkSDXkhYS0oInebMvtdIHmFdUBKTpP9f8r0KAgLWCOEYROl4w5xqUES0HmIrdBkFDDq+emVMdVHUlaNmo+PwVBUGvobql70yuywY57eHlxi5lJKP6TdZuVe0yf6I7sNSHU8M591Eo472lrRJuiO09U7VxokUpZcmKlBA/3dOM91LGrdtvhm/SVPbNdC++AaN+028iF0kBWnh0XuvNSZBP/45llbvZMQCNSyXYAJmv5mGoiVI+X1aFRiuGEW+lAcB/2JDnmB6dI+AYgkymszT7ERj6fb4EPn1qgZLuHCXRwos6QgkG34P3jyxhbhJ6ALO7w8mayAgNmpLIxQMdUA4g8ZoKmBeVa3TNjzYhnCR2YuEV5BYP8H4Cxdopb7THWBNfF2UwJBhF/rUc2gFvgP7Y6mFg5XI03aNRO81yU6IiOHJ57Eyx7FKzhZSdRrlF6FQ4FTdYD8ILOU/5n80coJacopTLmdugaddYDnRB75yjtiiui9S1Awcj+67tVUjKDuQ2hFrXbFGmuqlEAZHrr2 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:(13230028)(4636009)(376002)(136003)(396003)(366004)(39850400004)(346002)(451199021)(36756003)(86362001)(2906002)(44832011)(6486002)(6666004)(186003)(52116002)(107886003)(6512007)(6506007)(26005)(6636002)(66476007)(110136005)(316002)(41300700001)(38100700002)(4326008)(66556008)(2616005)(38350700002)(66946007)(5660300002)(478600001)(8676002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?SlJNz2/8Imm0uHCNEuENfdPWmKwA?= =?utf-8?q?KECA54h6Lx6T5/BLVAllYRfq89ksSymU4C+nUhvSn2chs53Oezp/oHeK3UiJkJd2W?= =?utf-8?q?hgX93xujYnjOMqcOLibjxAWDqorWPu3creOhPzhS256icv+2dKqZsgOlzc7/gbUUl?= =?utf-8?q?tda1LMVxagreyFtbcYuKhkfbLES8UWSTdsq//h7kvmEJ37hvdj/KVqWCzB0RJIFTF?= =?utf-8?q?gsRitvpLDZ9W8L5LYh7GuoIRY0t+6xVXc+qKTy31JXDihVeS0W2nXcFIRkXVMAUXK?= =?utf-8?q?345pVCc1aAuJNzYvsDYfy0CiGwKsxoK7ardgoE6vxzbF7V1GlcyPF1+S/lUDla0e7?= =?utf-8?q?tDbDFlsCxJwlmD8uwsvGeAqHRur3+HPXVLxMMXbMpVj40S7BoBRLbKOQJb8a3Cwcq?= =?utf-8?q?ZWzaAVo5iZgt9+N5BUBiVusO5yvIabps20x8oTqLe6rxBdDmmo2wzNzUclfW0tLYa?= =?utf-8?q?fMmvxgyAfNw8trQ7greLB+q/nglEcGEQdzUwCgILgtNYigj5QyeWlKn7YxUFOmqgM?= =?utf-8?q?qcrXUmAtKzLJeSp/GsaIW8BVTZ9dynQWAwy8ZKvGvFeT+c4pSeQ7d5j1l01w2BIwa?= =?utf-8?q?RjrtiN9FLWUKlXzT48ZLXlqCYLuxkYsvQdxXk+/uQ9vulKUdvQmr+rjbiczSx7FhQ?= =?utf-8?q?IwoRzYIPGPXjUhYDvdngbAxjSyyQRWDUIY+Ap2xTCW/waosPsqv5Mqa09gwV2yU6h?= =?utf-8?q?peNDw/R+xm23ND6cg8ngF4uFMHYR4ijli/8Y6XrY+E2ylMiV3XPscbhJGRJkwxL4X?= =?utf-8?q?sMWhyK3WwgeWTTH+JKSBWOxTCTUgCYYwhbk5WRoqhtMoXni9fPTLIUmhv4qKT1/Qn?= =?utf-8?q?SBlm9y2Tb3/ev/aUgPGuVqKaAYE6MtW0f0SDC8olYNmdVcPKao2+VTd98TkzYVKLA?= =?utf-8?q?JXsyuzxmaO0lJCOoL7kn4V0/6yT2fSOrM1qJj8FTuKYsfqovcr3nEAdnJq9vvEs5S?= =?utf-8?q?zzIj3OztxpTsD6zXy5Os3KNUl3mJ3dKHmK7eWWmmAQqtBZ9Y/FuelWaUCYN2b3I47?= =?utf-8?q?w9o1IavXpPuCFe+Gie6D2BeVm/kTSsz0qu2oxk18HqABwZ0gRg/QcXKgEAG20NxRU?= =?utf-8?q?Ou9sGEXQJfVSrvHgvwsqY4gn/Q1opGKgtZ1KXj7Z2a+Kl96juXSk5Qb9RLcQveor2?= =?utf-8?q?5K+2H9R1cW9akT+DyxMh/c76BSMlDF4+L85bC2GRJO7dzOcHJttH2n3K73vWP8eZV?= =?utf-8?q?C7o6ZPkKVqojmQZBwghYPK7xOsdl9jUrSBAmWtmg5YoTYMTfWlEUB+fwThJwlb1tH?= =?utf-8?q?ioXlb12cfFKqMyZkMt3e4/EslTiBjoTomPlmhi2xhw/0idzN1MvJv/IyJH9rQiQit?= =?utf-8?q?Yt6SaMUnu2wGOf9vwhtnPZz5pUhbkArcUWS5LDaJzA8QtWmK7TpKbGZ8d5JZtEaKW?= =?utf-8?q?RFrSnv37iFTGjUAeDM0Ng7Sn0Kib8SXQhJLt3FR00R3lFgJl9uA9QfX+NvLg3GVEN?= =?utf-8?q?+pL+lzpAyTzTIkP+0MHWZQ4Pd6oyKAec9aT49hib1WnRyHb3A1sapySIu2sERHNVU?= =?utf-8?q?QypddGYtnnceU7qZQyUpMVTd/38pw5L5sQ=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 5bee18e1-eb01-49d8-b904-08db6e3b6049 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 07:29:10.2145 (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: 3QQ+86gE2p/f+p2e8ci9dm6n5aoN7KdgykY7g5ANs/oVziFWr4/jklFSRq27SAM2ItSF61r8MKUUkRX7/jolAEDqxNFueIBdptN3iJmB85E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB9916 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 | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml index 895592da9626..6f5d7ac5560e 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml @@ -80,6 +80,145 @@ 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 + + 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 + dependencies: touchscreen-size-x: [ touchscreen-size-y ] touchscreen-size-y: [ touchscreen-size-x ] From patchwork Fri Jun 16 07:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 693469 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 9752EEB64DA for ; Fri, 16 Jun 2023 07:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbjFPH3Z (ORCPT ); Fri, 16 Jun 2023 03:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245011AbjFPH3S (ORCPT ); Fri, 16 Jun 2023 03:29:18 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2057.outbound.protection.outlook.com [40.107.7.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32EF626A9; Fri, 16 Jun 2023 00:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kiNFtqIaNYOlCABg2sKaq4TbAaB9MJqmnZ/vHs2JkuCFd/JkL6lPbstnqfxQOpEzdMaWgVfQFs/+K3No2qCTKQYo9gi/CvD24Tl5takBBPu2S1oQMZ/qofFVTFcaRo9dg6sXXF4J5BffAYDLGRPQGRCquGg4NGJCkf8blk+MVlC9AlJVELFBEJ+t0+G7Z74tTs1uEZqj7MCpvjcIlDRWTzS2xb1ZYoKHnU6eeYGlREWQwyIunrUI/4LTqVX6ySFGK2nuVuDKGu5YtgPnOZNBwMfR4XivniCrVUfMOU3dtewGKv6yyehmGDFtE3sGNZPnB8hFkobZI7+hZxh0MaUONg== 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=sLgaUQuMEy87mQOE6+9pRSxODWfmtoB2wTXnumPyZpI=; b=ee4A7BHVGXjseLzhd7KzH2vEuSUF4p3hMz2RNh9nGjAZs8vEUCuFgwTmZYQY9IfbPnJkJ86mCVQ1y6bI1PqR04j++ptJHFMZ6ODyoXjx06qsMQZqjz+D6DGcWTIg89hQWaZFpTXTFoVcDrT6CkrxrdE0yE85xUE3N295qsLOc4WaVazOkyNTDACgEHpIQZa6WKy0GJUre5ZVzOw8jRz5/pkEp6JxTn22gUZgsIzKNx1TPRwCsnQ6zc1YVBCuAK4yYskwgyCdXhlpv0X+xgEpt6CfsL3xr+j+PkHf1FaVi6+tgWRx6dkbUeGPfXM/OJXluJlZh7DWyzLkZYIs0eVrIA== 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=sLgaUQuMEy87mQOE6+9pRSxODWfmtoB2wTXnumPyZpI=; b=J2xSIIzq+gLBreJq7GpbCWQKP3Dre6WP9QEGJk9Xhz5k6Jl+DGtYMYUMEw/baKyHGf4v/Piijn3g35KnkTZhBjp8XNidJ3j/7K+TOMoQzcd/PkW0rxsOF/wMb3kQlfnw7pjQGu04A+LGzpY7P7c44kDLXNwdXJD2wqU3m/k6doU= 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 GV1PR08MB9916.eurprd08.prod.outlook.com (2603:10a6:150:a6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 07:29:11 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d%4]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 07:29:11 +0000 From: Javier Carrasco Date: Fri, 16 Jun 2023 09:28:53 +0200 Subject: [PATCH v3 3/4] Input: st1232 - add overlay touchscreen and buttons handling Message-Id: <20230510-feature-ts_virtobj_patch-v3-3-b4fb7fc4bab7@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@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=1686900549; l=6684; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=Ufj+40UV5TZ6PtKmvGP2w2PJ/I7zFECdsQf3vvqBzHU=; b=375jOJh0X/XWT8jYPZJRozUoliXOe5jkfsTwibeMlUaYt9ii4Dw9RajpyCwrhZP/I3PrsITna 8RVEfXMii4kAzI9WpMbz4bnIdd8QxnWhQhuG+AZpwgGH7TZnX3w6zGE X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0197.eurprd07.prod.outlook.com (2603:10a6:802:3f::21) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|GV1PR08MB9916:EE_ X-MS-Office365-Filtering-Correlation-Id: a76a3520-f15c-492f-52ac-08db6e3b6085 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YUNPbzUEyYlJ0etxSaHPvjxqH3fYoIO9syALhg9fkpMzP5bOrosyCGooV9escL8prwIB/DdZGZpTtMMb8yjCPiFdupq3gznd737ZORhQU4VzfaYShqu6YU37FvJnw2q9oIq+w/yfP2MYEczXSztEYaGLa3wAGYvOO7TN12zeT3Fv4X1p9LxKE/925ZVar3I/FdouJJWwn8yodPAERcHsGeB6so6ASp7fLvpQ5qWwo0GaplucQe9G95IBMVMOlxeFDmhr0rvS7oND1zKBK73PqznIFJffW8fbpYwBsvRstpxMdvvmgWvO0y6MmJQsXFnsZj8724UAWEsQxk7o7Fo3pKhuHYkBWWc8oKabsF28taXxc2oQRe5spHzdaw/5zOte9N3CakviTnFmPFgx9ZLjAZPH3srJR8F9vUcvbo6kOakEe5R29fYEHKJMI45MX/ANii2NgNLZYlPzbdmWDwybuZq39lmXJanex22MZe+SapX6zvmuHrJPe05tQqwU5SNpFuNcgt8gBXgYKi/KhO5dycYf8lHYV7Q5TxCJ7IP87yZi1Ha56inIS5bWrXY9bW587O3EJrvVeSze/ctl2lhQXiCH1NEPlov4Zh/bjjgmb9lFO3ImLHyT2y3e9y7OyqxQ 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:(13230028)(4636009)(376002)(136003)(396003)(366004)(39850400004)(346002)(451199021)(36756003)(86362001)(2906002)(44832011)(83380400001)(6486002)(6666004)(186003)(52116002)(107886003)(6512007)(6506007)(26005)(6636002)(66476007)(110136005)(316002)(41300700001)(38100700002)(4326008)(66556008)(2616005)(38350700002)(66946007)(5660300002)(478600001)(8676002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6IZ0B+G+jTZa8FcKQ38FgpLq9Ejo?= =?utf-8?q?ms/PxDH0hLAaTEEh9ygz9hiByx9TUHx5PISJpa3JwCnmKdF3iAY/3eGUQgU5XChlR?= =?utf-8?q?dNKWUpfChLi/CH6qL8ZNcB+V9cL07Omr3PLbwj5ln3S4xr4V6IevcsNgC8hjkCfDk?= =?utf-8?q?dfB9kkY/GzpWcmvkxIRKFbgxEiR4SsQGC09HuvGCwYqaE17YS5ydc4wGIYGPK63bW?= =?utf-8?q?0wvOtlni/r+QJp9Ev0wNh2kv4QOiyupKKl94Ydyy9uJy2YJLYr+nhXSHZcO0Vc6oU?= =?utf-8?q?U+D2x2noFlp8McxAUzmuymYymbuJhRMpNVdARCKyVeMi/KGnNEG2XS5xuLHZzb+p9?= =?utf-8?q?B4SlimF7eiIYTYybON9c2sTChoVby/Dv5wPiNoCcyJRIQ9L4cq+LzRLfS0S0PSJhM?= =?utf-8?q?IVzMmBj370L9grhSgb3+zK2fdQfRxs/kHUpHRVZnCY5WfE2nNkjOwrYTmrnWKZi9U?= =?utf-8?q?3N01w02KrqM2wpo3+ia/mSJSV3J2lLVgOINF94lDw/RfcQ4LdSzhaMqsighgYgHym?= =?utf-8?q?Hby1e48vyL9bcJPsz3e0wRt1NfaVaqHS288QuOqoBmUYqkH5d+WQFLPYNTzbj76zR?= =?utf-8?q?sUHB6og82fiP0dPuPkvpBQ/UUe8nwv6y/edyRsAZJ97qO7iBnrQaG5NXJIxrelb8o?= =?utf-8?q?0trg3dXZK/EOKfD6zAdagqQbFQxKZXicAeCs4VqkzCjbbkePmgq1+eSoAs0jmRdzT?= =?utf-8?q?Oq2ECoSLrlhll2Kjh85IvgGojsX9gn/aB2SK45pxLY7IvVySlP67dI5SjxpuEFKsF?= =?utf-8?q?Ix6mx1sckmUKfGVVxQYScFcBrxKFxeQibQRTeDB6o/5PKf4QCufJlZjsmgOON0URz?= =?utf-8?q?SSEZcJtD0346vrkzVwmY/QEJJ7qiP4ruFLJyAInXYrmGzn+pdy3Bjx9namLVke0Gn?= =?utf-8?q?8xA2kihTCRyQHSwXSnSXMQGIgSvQwIB28ySkpE1VbwAe6Sby6qK0y/4lta/o3N5t/?= =?utf-8?q?CXUJ8EqZ1yEdpxRZs1+imxXoTCROTC3kDln1zgsp7RCSNdtQEuiIhYnFqlq3Cjx7b?= =?utf-8?q?bqmXS9c1kSDvcbLISlpyiDkACK5KX1HRaaNVkeuEge/X/VdC0/1RibRVU7M8qkkxg?= =?utf-8?q?nISTvL71mc6RH5WE8fZoLXzRPuaqn+Ur625/Ok45b3U9oLEeW/ViG6jVpitY2y5eV?= =?utf-8?q?JOFsS6lMiAfVMSJVLysivA/0AKsHK0p7SUcf6YFgE5605rSgA7xIfVt12vsJmUkuE?= =?utf-8?q?xkhHFoWldtBvQhD20/9prGUdPw9k5YE3MaNQfaBiAWcklPC/xqTJjzTyQ8p3gCzm3?= =?utf-8?q?1OKC7w2jgB0q/yzX3CyipJvl5mvwBbZw2bcjc31QPsutUJSgfEzLLQhGq+YAGjk2i?= =?utf-8?q?VOFXhrXuQ5UIs9R/zLmhFoU1W3ozpTnwpwNCoShfKFqQFSIBAA+/jPpbyLs4oVUIk?= =?utf-8?q?THYD2/wH4XsJCIKIUvmbwzBcyQE6K7aXEzWPiwyKgbDL+9XrsP1SyVL2sutzLvWWd?= =?utf-8?q?gaLMC5L40ubwnoItHQgdxnYgwlyZxQlf/JwlNL3WSCiJVvE+YbE/sEW5TJFAE7Ycy?= =?utf-8?q?7m1qV5rVBkxpCwQjaMi22MFKEfrdWEYrKQ=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: a76a3520-f15c-492f-52ac-08db6e3b6085 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 07:29:10.5897 (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: t6+21fR4sRzRrJDkYi+NIwWOR9MZaOK2Od8oEk3t894xu3pgdCL+rO5IWYCqL5AeWKD8pSGKKylEgsJUYcXeGopC1nGxUQ9XuKOwAQvpvbM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB9916 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use ts-overlay to support overlay objects such as buttons and resized frames defined in the device tree. If a 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/Kconfig | 1 + drivers/input/touchscreen/st1232.c | 87 ++++++++++++++++++++++++++++++-------- 2 files changed, 70 insertions(+), 18 deletions(-) diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 8382a4d68326..202e559371e8 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1215,6 +1215,7 @@ config TOUCHSCREEN_SIS_I2C config TOUCHSCREEN_ST1232 tristate "Sitronix ST1232 or ST1633 touchscreen controllers" depends on I2C + select TOUCHSCREEN_TS_OVERLAY help Say Y here if you want to support the Sitronix ST1232 or ST1633 touchscreen controller. diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index f49566dc96f8..7d8a69e4831b 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 ts_overlay_map *map; const struct st_chip_info *chip_info; int read_buf_len; u8 *read_buf; @@ -129,10 +132,12 @@ 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 *tscreen = ts->input_dev; + __maybe_unused 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]; + __maybe_unused bool button_pressed[ST_TS_MAX_FINGERS]; int n_contacts = 0; int i; @@ -143,6 +148,15 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) unsigned int x = ((buf[0] & 0x70) << 4) | buf[1]; unsigned int y = ((buf[0] & 0x07) << 8) | buf[2]; + /* forward button presses to the keypad input device */ + if (ts_overlay_is_button_slot(ts->map, i) || + ts_overlay_button_press(ts->map, keypad, x, y, i)) { + button_pressed[i] = true; + continue; + } + /* Ignore events out of the overlay screen if defined */ + if (!ts_overlay_mt_on_touchscreen(ts->map, &x, &y)) + continue; touchscreen_set_mt_pos(&pos[n_contacts], &ts->prop, x, y); @@ -154,18 +168,25 @@ static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) } } - input_mt_assign_slots(input, slots, pos, n_contacts, 0); + input_mt_assign_slots(tscreen, slots, pos, n_contacts, 0); for (i = 0; i < n_contacts; i++) { - input_mt_slot(input, slots[i]); - input_mt_report_slot_state(input, MT_TOOL_FINGER, true); - input_report_abs(input, ABS_MT_POSITION_X, pos[i].x); - input_report_abs(input, ABS_MT_POSITION_Y, pos[i].y); + input_mt_slot(tscreen, slots[i]); + input_mt_report_slot_state(tscreen, MT_TOOL_FINGER, true); + input_report_abs(tscreen, ABS_MT_POSITION_X, pos[i].x); + input_report_abs(tscreen, ABS_MT_POSITION_Y, pos[i].y); if (ts->chip_info->have_z) - input_report_abs(input, ABS_MT_TOUCH_MAJOR, z[i]); + input_report_abs(tscreen, ABS_MT_TOUCH_MAJOR, z[i]); + } + input_mt_sync_frame(tscreen); + input_sync(tscreen); + + if (ts_overlay_mapped_buttons(ts->map)) { + for (i = 0; i < ts->chip_info->max_fingers; i++) + if (ts_overlay_is_button_slot(ts->map, i) && + !button_pressed[i]) + ts_overlay_button_release(ts->map, keypad, i); + input_sync(keypad); } - - input_mt_sync_frame(input); - input_sync(input); return n_contacts; } @@ -226,6 +247,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 __maybe_unused *overlay_keypad; u16 max_x, max_y; int error; @@ -292,18 +314,28 @@ static int st1232_ts_probe(struct i2c_client *client) if (error) return error; - /* Read resolution from the chip */ - error = st1232_ts_read_resolution(ts, &max_x, &max_y); - if (error) { - dev_err(&client->dev, - "Failed to read resolution: %d\n", error); - return error; - } - if (ts->chip_info->have_z) input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, ts->chip_info->max_area, 0, 0); + /* map overlay objects if defined in the device tree */ + ts->map = ts_overlay_map_objects(&ts->client->dev, ts->input_dev); + if (IS_ERR(ts->map)) + return PTR_ERR(ts->map); + + if (ts_overlay_mapped_touchscreen(ts->map)) { + /* Read resolution from the overlay touchscreen if defined*/ + ts_overlay_get_touchscreen_abs(ts->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 +367,25 @@ static int st1232_ts_probe(struct i2c_client *client) return error; } + /* Register keypad input device if overlay buttons were defined */ + if (ts_overlay_mapped_buttons(ts->map)) { + overlay_keypad = devm_input_allocate_device(&client->dev); + if (!overlay_keypad) + return -ENOMEM; + + ts->overlay_keypad = overlay_keypad; + overlay_keypad->name = "st1232-keypad"; + overlay_keypad->id.bustype = BUS_I2C; + ts_overlay_set_button_caps(ts->map, overlay_keypad); + 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; + } + } + i2c_set_clientdata(client, ts); return 0; From patchwork Fri Jun 16 07:28:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 693470 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 4DD92EB64D7 for ; Fri, 16 Jun 2023 07:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244932AbjFPH3T (ORCPT ); Fri, 16 Jun 2023 03:29:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244936AbjFPH3R (ORCPT ); Fri, 16 Jun 2023 03:29:17 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2057.outbound.protection.outlook.com [40.107.7.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E6E42110; Fri, 16 Jun 2023 00:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TLIazik4f35cIIUUsLK3+I7x3TcldgZXr2+Klzt1VSdXSI//+J1baxafSaCqgNJUE0V3JlVx+FN1Ow5wcdPxE51YZg+qAXASEF6s7M7cEyPUK5VlOSS814D9MenVxHfo0cr5JGMGtGFWjwDRPAAN8qdBC5jCEELSdS3jYBD5/AbGz85XY2/gjE2hbNk54QPhup8QyvjoAR/ykv/GMEm3GLMT/fOPmYCYq0gwCpoEuC3y5UkuhcqQMUlsmQjLGnjG/cf8VYiQplIvKvE2Ez6fLBK0MoxYlFw8sNeQ6nmDvUpOZeC5rYgvFVQiBEd6YCspOYgWOguBVtI6K0aQm/CRWw== 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=LCrl4ZbJ3Kh6c3qmxW6uwwiFwGgNUB5sft9lr3jk/K0=; b=leNV9MM8h8YzBhcSA16692qWCBl6G+6Jg1ePZUufGtOH2nTfbFRHFnC2iskFWV0FT86gsqS7t+9YaBd1omLX7mj8O1OUZXZzUFnPG4HejSs1lTTvtsxlllcUtwuRMJkBd+YI5XC0RRLOVFwQiZUrWvFKplhAvJwj/MnOM5TCebwjrXheFAghq84BqGnUx1sLMWromWqnioziii9a8kYF6/mdXyByC7OotsiDf5XtXDJS/k2dCMzNWaWPu7+ouHOI50rhWPa+Xi3RE41yveuMur2b4VCIKBpdANoJP3FVOX6+fm0OmoekzytER0JMwnjCe4PckehPnsorcZeBbtT4Sg== 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=LCrl4ZbJ3Kh6c3qmxW6uwwiFwGgNUB5sft9lr3jk/K0=; b=X4a67l+3865kTscv7coywZjQRUHZn6/mtTt6hLIrxT4EzVSIuHILZQUAlUvxpy5zL8wfIAin3RRl0AFu6x1Br7glh16/unxmVqOJ0YlgQBOBCKrbU1752P0hsBRa/HAG8N7wXFK3FklzWJ7qHkrMk6tmyRHefp39EP0eUDSDi2I= 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 GV1PR08MB9916.eurprd08.prod.outlook.com (2603:10a6:150:a6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 07:29:11 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::bd0e:a139:9e67:b86d%4]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 07:29:11 +0000 From: Javier Carrasco Date: Fri, 16 Jun 2023 09:28:54 +0200 Subject: [PATCH v3 4/4] dt-bindings: input: touchscreen: st1232: add example with ts-overlay Message-Id: <20230510-feature-ts_virtobj_patch-v3-4-b4fb7fc4bab7@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v3-0-b4fb7fc4bab7@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=1686900549; l=2481; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=u41+vfnnWlumMLfPi3uNqi+j7l8YievMuwAbZnCAEtc=; b=weaZMYa9i73fJy1hCjWn5NlMCoWNIfZ4Y3iRVyNC5bpL69dtSHvgusSHOPYx9R6Fcda5m3/Op QW4SrIFOKUlD5D1QCT/yRniZfm2w7EwabDe9rdHAuUZbE3sIGo7VOto X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR07CA0197.eurprd07.prod.outlook.com (2603:10a6:802:3f::21) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|GV1PR08MB9916:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d8d9333-7a74-4369-4e8b-08db6e3b60c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oUFFTODsQK6ruovUgingej42hKFKDl4emCCT5oFWqCTLlQlGiISZ6bvIFl90NYQ7l7iTjlIQSkIJ48njDWoWRvNTQ/DdQb5oQb1FyPlG/E90wNby8/qS6JpZx5Re7ILd3GHCE/jP3WW1fsh8MnmFBpoiKfV5OBJ9jbOIDqsDVpy1Nbj6aHG+D86RXCkliTx+AzsIIVgLiuyZFiX6ckbYmtcSuKx7ZuDOtxlOGVOqXbVeUEOt55o2YXiVlvXmNG117B4kmpy7YYlQgX03wxdz0YME6j/XNJ70j+cuUchAWCN9dErQi42PIwe+yebBLr/XfLImjPW6J3f2m3vggyGe9RZNwCI5CMtcndgp19aNUWDUw3bXw+SCRjADjVt2e85r53nkqwhKa8yzKUMup9+anThmk2nxsnBDQpxotqXwoua3NFdCGuad6qwbniGfYXgpxaaUqfwIPoQKgHxUA7xnbYuTKcnaLmPKhxTaEEwYdpd8zrTb/LHH2MknnCh6lEmiuT0SJa+E5mBYbesfLvRT1Ga3Wk+AchNEauV8U/zK/7wQtK1aKj+VkuZoXFqaXjcGtkREl8G9wGeNnmjuXhdDpS1lRh3EFmy67r+slYSd6JRorZ3U08/yrS3QlXbp9SWB 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:(13230028)(4636009)(376002)(136003)(396003)(366004)(39850400004)(346002)(451199021)(36756003)(86362001)(2906002)(44832011)(83380400001)(6486002)(6666004)(186003)(52116002)(107886003)(6512007)(6506007)(26005)(6636002)(66476007)(110136005)(316002)(41300700001)(38100700002)(4326008)(66556008)(2616005)(38350700002)(66946007)(5660300002)(478600001)(8676002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/DK2GbKAWIBUaImWNltIRceWGS3Z?= =?utf-8?q?/BxHTH/MR/s87WUtlshTH50Mul7REpKEmBBgrhkFQs6TWbNRJ+0AlL6EXYA8EPNEQ?= =?utf-8?q?/LxhS2SXHmenZWSw+Xg6WSBLkk2wcfxVDAoLiI7JgE1CstbUcL754KXXugjwHyXJ8?= =?utf-8?q?BmyZ4euYkxgJipCCWHrcTX4WqHe8+KKYowcJ2wEtgTqkzUKG8fBsGKtVOmdHb801y?= =?utf-8?q?yhhrM3AEDXRV8/66Y9ldRmnNgwgb3fRvXU8NcCcrWfOKKhiHedQyNr/jUNcAB0bdO?= =?utf-8?q?U0y7wYhl5EQ+4H95fkFfMPQHCghCBt2nrNYO4EZQQlUf0nDs5ZQwq+26hHD4IVDha?= =?utf-8?q?S4bG0Um7DPegBIqTxHTlmlIgY/yshJyzk3v1wgjtQrESlviyCgt5DHTBy4LahtbjA?= =?utf-8?q?m13PvnMbWNWv6p3hYudX8NKb87WEOxnr0YNMA6Yri4HtFNPwitcfH59B6eLN1bnUo?= =?utf-8?q?uGtPlfiQghnv3Av1RpIWPemSiQXbqSwPdcnExO3SJMdSOU67NcwmHP/9bcKC8PAAQ?= =?utf-8?q?OIUD+CLbKRrN0yJaVw/kQGoL9nuAZqB6Ly7a2mGlUgONHwuRiiq8Mzj76Em2NxO+z?= =?utf-8?q?+D8AtxLsus79DA9ZTPgWns1WGc+T4FyNm9gxXxO8iVbs0OBwK+W6RhWyJCwGySseE?= =?utf-8?q?2qbI3KT5+WOnxwhj3O6DuND8XNoPCeT5u2m+xRL9Y2aBBZSRzuiIHTIMKM/RuSbBh?= =?utf-8?q?8J2ok728OQzRWIcbcSXxOBnxgnlpoc6PHTLdQjKqfvO9uSQjrLfNMS1j3F9ArDmKl?= =?utf-8?q?pbAiJF4DoccmaPuP4qMcWmRsdbPRlwPU4krKk35IFPQvUXn8o0Mb0zw/314xZe3p+?= =?utf-8?q?Zsh2ZvCq+V7dsqHYCGhUpmI3kOrlKNb/eq3hRsQ+KUqgESXLZaV6S0+RXMQ8V4o4/?= =?utf-8?q?4Vw9cHLlhXjULt7hWqrQVjGEAuxMxkyegd3FhoQ4wkRP+wm7XnMlBH5mzhxNYT+Y3?= =?utf-8?q?eu9rLMtHWFytJIgsjaYLh5oCWDOpQwP2yRz+LhcBCTJlkzLartEFqXUeFjhlkrt/J?= =?utf-8?q?93S92vHcmyeHw5XssOL8M7K8kjDuN4VjAlFcoUhr5LazezLrj8VKEotfdJkALp4av?= =?utf-8?q?8FXOpt+rgV+DN8dq1cEldm4iG4WePaQ3OHP3yM0T2FcwsgMJ3sI/+AOpSlOeo2emg?= =?utf-8?q?ehoBfgEYnjZcbpXB9bJc8l6tBflwpi5jwxtC1yNDLPVnugYFQsuqmnEyLVNz7/kxd?= =?utf-8?q?39kF1NYKM9aOlDqjUf6ON+IMOJ4GO24LOlkIPK9KXObPzrgQqqHz2ejzC0vNKHcjv?= =?utf-8?q?sc0GnXq5Bjfl2kIBgUUCAhgG/PvK7+3zLn/Ujma4KKjY5WB8dmGnFXXtM9pH4yUif?= =?utf-8?q?mOVCFzvPewrgf2TEVPdMW1MvdW2j+IXKnFub6C9GobQ+f314tNN/vd0pzKWAbFz6b?= =?utf-8?q?JChm7bOXEdHfguILHqGhhGowCixfQzp59xNRoL+mBpa5CngTeYCZRYACBW1Gt2PKA?= =?utf-8?q?Fcm6ukpIVNBrkRqerDyWtZpO5u72HOv2txk9doVET7odWcOjW0R1lcR+PTlWFwS1D?= =?utf-8?q?ldr4sI5vBdn2gpygk6J37/6IEMjX8kEA3w=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 2d8d9333-7a74-4369-4e8b-08db6e3b60c3 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 07:29:10.9809 (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: 3gUUfkHwaU+P/lYEDVSqr/fb9l5tGySubc4o2OHlZfFMbyG3fUHf5q5JUva+mbmPzOhOxf21W0273UNQkEkWEy4+VDPIAUDb479hsGSlmDc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB9916 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 ts-overlay module. Add an example where nodes for a 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..6cc34e4c6c87 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-suspend { + label = "Suspend"; + linux,code = ; + x-origin = <160>; + x-size = <40>; + y-origin = <0>; + y-size = <40>; + }; + }; + }; + };