From patchwork Mon May 15 15:00:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 683739 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 91D9EC77B7D for ; Mon, 15 May 2023 15:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241954AbjEOPBf (ORCPT ); Mon, 15 May 2023 11:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241705AbjEOPBV (ORCPT ); Mon, 15 May 2023 11:01:21 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2079.outbound.protection.outlook.com [40.107.7.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97397212B; Mon, 15 May 2023 08:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MLBPe8mkI5QvCX1plCNO2906o10akskIpg8w/a/rtimDvUs2cZK2ucJpunVqsIKXLKUkLmSynj7KsORp9gYhvg2AM3sROi+EzNgPvmfnEdW2tMbuf91QyJAl6pl+RUwl1MYeUhtZmQu87fjhT3lqvqSLdvqBnpdbbzMCew3Y3YPXdbmZ9sVfVTxP9DU3Eqx9OPtqotRLpf3r7PH/iuNeLcYrCEkaTVQuzsxETOrF9to3gKuHWf4EVugNgY999JW06nt9cmd00ztgjOst2SBeEMbj93IlQ/1geyXC+yZN/FPjV+MSe5Py22SNeZ/MIKEN1UpPj/IcWywm3zk5XVXGJQ== 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=uYToyZ0+i3E3hnhG8uBYcbo72aC37etu9afp+sPnR1E=; b=RMZp57B9gb1l2YjVOaLJVwxUR/LbEJ180e488630LiNkT91dmbfCbqCcW2X3SHJz7FVXEB6qDD94FkoGPuzrME3pP7gZ4SphKAmnGyrdui8VnP92nchNe4VVZfI51lwh9lOQTKbBsSzs00i3mcPpK3DXptFn0qRlr4whNKLrayJ+mHiEeo/9+HjUzjcR1FBgh7Rn1Ta5fOb8gn0+UrAIJgXPXue11gDIpMc5kyZl8IMntyGoV6LrgzuOu61NuqV+jah2oNT09A3eDdrCoWi47elSbps6ycofjusI7+1GnF8ue1N5e9pDPzp//IVvx+ElupqpwHL6MgoefKLpOVZubg== 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=uYToyZ0+i3E3hnhG8uBYcbo72aC37etu9afp+sPnR1E=; b=gcXTk27c/niFNUsCirr7VgQ7y4W9u7t8Lt+m5M8c6qYlyFVtBtabUmTlFkU1fDRW4oOkkGdaD66Dl3r2uZfc3zz5g1QbO9zNi4cCaFIjttnUZotQRMvMouRVIc+8peX+CbE1iwmDm9mvAGvL9U9Hq895HwnpjcpR7FwUD3smIh8= 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 VI1PR08MB9982.eurprd08.prod.outlook.com (2603:10a6:800:1c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.29; Mon, 15 May 2023 15:01:06 +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.6387.030; Mon, 15 May 2023 15:01:06 +0000 From: Javier Carrasco Date: Mon, 15 May 2023 17:00:58 +0200 Subject: [PATCH v2 1/4] Input: ts-virtobj - Add touchscreen virtual object handling Message-Id: <20230510-feature-ts_virtobj_patch-v2-1-f68a6bfe7a0f@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@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=1684162864; l=12903; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=jSKDHg8ewhTwMLA62fQ6dNqfEgjqCy3qsgeiLccQLgY=; b=PtWogpeXfR7xGbsSEs1/jMCAr6gDy0q/8ZB6fyJyKsx/kdbF2L5uhzBy+pKDibI9tiIjzyubL bcQQpcoxgoyDXRbG+uMBa/9iylRSo4XRTFg2++yTIet9Y/ane6Y8dXw X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1P195CA0039.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::28) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|VI1PR08MB9982:EE_ X-MS-Office365-Filtering-Correlation-Id: a10a2b8a-6443-4756-4865-08db55553501 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CYeigci8pr+v63tpcHlm+7RF+kbi/BSZRbcgy2aBpmZd4/YMklmA/VuvSFFbmpkoaHbrtN5dClV5LCZewu+3/VjP3nWVwZtQR6qmb1G0TK110SBko0EGBVu087qsnmSBUiB4Ip7DTIkSc/PBd+pGDHtMCViicwa9oYjbbauLX/gSFZpfCDqHUcBHRTrYCspwiITYg/LoPaXWQNg/D/M3iCjl9dNYAwje7BbLDAU5A0KCnzVs+6L+Ualmva9Hsw7zTkIrqnt5YwaZg81BmPwR4kBUPJSpJAf0yIbYMECDgrujjivzo8SQVhpN/w1epoDlj8wFdeGUIpm0keLVAk0gTDbXNvTAEJOuANKJgE2g8iF8P80eBw2RYAcYk8QI6AgzpeLpeyxr6Ayn/DwRhQUAiVPAyOrl70t9NtZsyjv+bIpEh37k7CVDXR6qcD+u5iNuePN2oKbVs4l18w4mJB7HzP/nQjnw+nH7muCSsiVQdae4C1RCN0zD6KBZAlLTN/t//uN4yJWJjV5vn+ODykpOjKnxZn8Hc4LWztuU0O2Dq9t/ZmZs3L1YSmMBkYMfEBBcCVxp3FR1F1qfnWznIl1FdRXqhbvPBpYRbTk8dOVySBY= 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)(136003)(376002)(396003)(346002)(366004)(39840400004)(451199021)(478600001)(2616005)(86362001)(6486002)(83380400001)(6512007)(6506007)(26005)(186003)(38100700002)(38350700002)(107886003)(36756003)(52116002)(966005)(6666004)(110136005)(30864003)(2906002)(66946007)(66476007)(66556008)(5660300002)(316002)(6636002)(4326008)(44832011)(8676002)(8936002)(41300700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VZmdw5Ug8eAzBOVh+rl77ch/K08k?= =?utf-8?q?6K6fVSh8ctmfcpivLrCMl2fKxTIYOrrLUIv1XLXxAVvQCbs7gPZaofh37sNugP6JT?= =?utf-8?q?6CafNxiyHA9ltY5LBqkWGECPSrf6ByYrxWzcLeI+xa/uE2ipUJ8bUCN/zKZAUfIof?= =?utf-8?q?iKWVVcjOxAKBZ0Bno38kgQ+wyQlxaZcAslTs4dDc2xyCgelIDkqn1g8PCKv0s9+F8?= =?utf-8?q?YqHNe5fvgoWyzHWki1H7guBC641XvX9kbpsk1Zjrv2h3ozEYNBTAmqnnU7o8GPXCV?= =?utf-8?q?BoFidSm5cF3Jz9Ril1rW+7XP2AnsoRLObG3T12UY72Yv7Mc4lDTb3OBKd+cnzLvOy?= =?utf-8?q?9M5uBFZRAwWgtpkcWngHWJ3nPgyCN19Ux8bZQw5Yopi23ylwEuaQEiJL2WozhMPhX?= =?utf-8?q?ix5hciCQx3I9gqX64sW2IMZGdO4Je1JXyayhU0Kp8PxcphluGOrvTrWVZFCh47krT?= =?utf-8?q?vxdVlqI3Oyb01Vjul6NYwiYuHFmYmBRzQzjxMP/1uxO0LeUtO89pHzDz1bcDBDPPG?= =?utf-8?q?wqGkN4hULw2PL5VWv1F31ZgxG98hBDeIjHQ99eeF0nqzCi1bxhonY/EE3qEvkUEo/?= =?utf-8?q?BFdGt7OkjJR3j5Owm9XIe9l0H49rLjXOcrRj2CFhPLX1ZrygWXQAoXTkmP+NUoyv+?= =?utf-8?q?TQM8/zrmeHJSE31mmXABNTdOX7zRWTRUaWITdRfC9UYH5PV3u5+QLeE/kG1VTc4z9?= =?utf-8?q?KqoKrlbdQcdu5sccHhBrw34p850rq9olnftSzMFdODrtYMxBCLuXrHd66sFZqkDBM?= =?utf-8?q?H5qoQ26DEi2TzcKrsngi4kw0i/SzqN5aoIbqqX7Fp1GhU8dxRiyjVRzxXt70o1XQd?= =?utf-8?q?SVOtMAl8PMKq/3oSa8T3+y0zbV7hVFlkVdzqH/Q4Sdtq9LZAkTO7Wfe1mcBVyA+hu?= =?utf-8?q?R2s0gNMRBIGig3aHBCzgZLpb6/S2JdLlsyesF1wfwNfDtxVcpzJpxsAqW2xE2RdYv?= =?utf-8?q?lpsJOhFznwlH9OmgudfAn0Bjr5wF3krv2VqQM8HDuTe5PFFLSf0Tw6EfMU3zBjAOm?= =?utf-8?q?ZkoOv4RbLw/DFbDye0tgPkPx8inZWHWVgD9Ipvwa4nSeZrjWXWy7uPmxDZ2gwDUa6?= =?utf-8?q?9stQxx+zq2VF56vgFlTrGbpfD59165sxJQ4MY1ZRfIlKsiOuG4o+EpPRn2xALkUsS?= =?utf-8?q?t3LsBIsiYyKCxFDvuN4G4Ts2YJN01tTLm5TtDnUZtIwgxlFl+s+m5ZorbLWx4624Z?= =?utf-8?q?j7sAtOCbEiWJq32ZnUse7kFzxvbVC0CZmZvJgNAkPdohV+iqby9+h9tqC4WdFTlZ3?= =?utf-8?q?qsGyYi029+YhyZFQtq1joSuBQI0o498PHlC73haNS1hpuYdxZZumlRZyml1Tt6Mkw?= =?utf-8?q?9KZEJieKi87XAXxYTWFxAM05a8izlDng/0VcGMBKbv6n5Wj+NJbH8WGy/NHjxep4T?= =?utf-8?q?omWWFt3DWD8e9ABq562tboPFTReEHbPhq4twe6Sgl614upovqdjyedan+X4hROXL/?= =?utf-8?q?umjFl0RpbvXEHDHnQ3j4/8RzlqQwfTBLBnFkTpJIB4VPP5NCp+/8+1yCgSuEQeeLa?= =?utf-8?q?hLj63da8akVa1ocS66HZ2rktgEScymXh9gnr18seMecUeO2lwuBDUso=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: a10a2b8a-6443-4756-4865-08db55553501 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2023 15:01:05.4036 (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: k08OnY3bDGb80PS6VCu/D6er0MfkTL4GFrTVQMhOR6osL1+JjvqaAVJ16zHzpA13NH627Bdzi4aRa5fr8I+x9d1acn9ssae9keZ6km2GKHU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB9982 Precedence: bulk List-ID: X-Mailing-List: devicetree@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 virtual objects via device tree nodes. These virtual 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-virtobj.c | 356 +++++++++++++++++++++++++++++++++ include/linux/input/ts-virtobj.h | 43 ++++ 5 files changed, 416 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7e0b87d5aa2e..296f71bcfe92 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 VIRTUAL OBJECTS +M: Javier Carrasco +L: linux-input@vger.kernel.org +S: Maintained +F: drivers/input/touchscreen/ts-virtobj.c +F: include/linux/input/ts-virtobj.h + TTY LAYER M: Greg Kroah-Hartman M: Jiri Slaby diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 143ff43c67ae..0bdbe0a77b34 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_VIRTOBJ + tristate "Touchscreen Virtual 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..dc315d58a03b 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_VIRTOBJ) += ts-virtobj.o diff --git a/drivers/input/touchscreen/ts-virtobj.c b/drivers/input/touchscreen/ts-virtobj.c new file mode 100644 index 000000000000..07e5611b7b3d --- /dev/null +++ b/drivers/input/touchscreen/ts-virtobj.c @@ -0,0 +1,356 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Helper functions for virtual objects on touchscreens + * + * Copyright (c) 2023 Javier Carrasco + */ + +#include +#include +#include +#include +#include + +enum ts_virtobj_valid_objects { + TOUCHSCREEN, + BUTTON, +}; + +static const char *const ts_virtobj_names[] = { + [TOUCHSCREEN] = "virtual-touchscreen", + [BUTTON] = "virtual-buttons", +}; + +struct ts_virtobj_shape { + u32 x_origin; + u32 y_origin; + u32 x_size; + u32 y_size; +}; + +struct ts_virtobj_button { + struct ts_virtobj_shape shape; + u32 key; + bool pressed; + int slot; +}; + +static int ts_virtobj_get_shape_properties(struct fwnode_handle *child_node, + struct ts_virtobj_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_virtobj_get_button_properties(struct device *dev, + struct fwnode_handle *child_node, + struct ts_virtobj_button *btn) +{ + struct fwnode_handle *child_btn; + int rc; + int j = 0; + + fwnode_for_each_child_node(child_node, child_btn) { + rc = ts_virtobj_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_virtobj_set_button_caps(struct ts_virtobj_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_virtobj_set_button_caps); + +static int ts_virtobj_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_virtobj_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_virtobj_map_touchscreen(struct device *dev, + struct ts_virtobj_map *map) +{ + struct fwnode_handle *child; + int rc = 0; + + child = device_get_named_child_node(dev, ts_virtobj_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_virtobj_get_shape_properties(child, map->touchscreen); + if (rc < 0) + goto touchscreen_free; + + map->virtual_touchscreen = true; + dev_info(dev, "Added virtual 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_virtobj_map_buttons(struct device *dev, + struct ts_virtobj_map *map, + struct input_dev *input) +{ + struct fwnode_handle *child; + u32 button_count; + int rc = 0; + + button_count = ts_virtobj_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_virtobj_names[BUTTON]); + if (unlikely(!child)) + goto map_buttons_free; + + rc = ts_virtobj_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_virtobj_defined_objects(struct device *dev) +{ + struct fwnode_handle *child; + int i; + + for (i = 0; i < ARRAY_SIZE(ts_virtobj_names); i++) { + child = device_get_named_child_node(dev, ts_virtobj_names[i]); + if (child) { + fwnode_handle_put(child); + return true; + } + fwnode_handle_put(child); + } + + return false; +} + +struct ts_virtobj_map *ts_virtobj_map_objects(struct device *dev, + struct input_dev *input) +{ + struct ts_virtobj_map *map = NULL; + int rc; + + if (!ts_virtobj_defined_objects(dev)) + return NULL; + + map = devm_kzalloc(dev, sizeof(*map), GFP_KERNEL); + if (!map) { + rc = -ENOMEM; + goto objects_err; + } + rc = ts_virtobj_map_touchscreen(dev, map); + if (rc < 0) + goto objects_free; + + rc = ts_virtobj_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_virtobj_map_objects); + +void ts_virtobj_get_touchscreen_abs(struct ts_virtobj_map *map, u16 *x, u16 *y) +{ + *x = map->touchscreen->x_size - 1; + *y = map->touchscreen->y_size - 1; +} +EXPORT_SYMBOL(ts_virtobj_get_touchscreen_abs); + +static bool ts_virtobj_shape_event(struct ts_virtobj_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_virtobj_touchscreen_event(struct ts_virtobj_shape *touchscreen, + u32 *x, u32 *y) +{ + if (ts_virtobj_shape_event(touchscreen, *x, *y)) { + *x -= touchscreen->x_origin; + *y -= touchscreen->y_origin; + return true; + } + + return false; +} + +bool ts_virtobj_mapped_touchscreen(struct ts_virtobj_map *map) +{ + if (!map || !map->virtual_touchscreen) + return false; + + return true; +} +EXPORT_SYMBOL(ts_virtobj_mapped_touchscreen); + +bool ts_virtobj_mapped_buttons(struct ts_virtobj_map *map) +{ + if (!map || !map->button_count) + return false; + + return true; +} +EXPORT_SYMBOL(ts_virtobj_mapped_buttons); + +bool ts_virtobj_mt_on_touchscreen(struct ts_virtobj_map *map, u32 *x, u32 *y) +{ + if (!ts_virtobj_mapped_touchscreen(map)) + return true; + + if (!ts_virtobj_touchscreen_event(map->touchscreen, x, y)) + return false; + + return true; +} +EXPORT_SYMBOL(ts_virtobj_mt_on_touchscreen); + +bool ts_virtobj_button_press(struct ts_virtobj_map *map, + struct input_dev *input, u32 x, u32 y, u32 slot) +{ + int i; + + if (!ts_virtobj_mapped_buttons(map)) + return false; + + for (i = 0; i < map->button_count; i++) { + if (ts_virtobj_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_virtobj_button_press); + +bool ts_virtobj_is_button_slot(struct ts_virtobj_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_virtobj_is_button_slot); + +void ts_virtobj_button_release(struct ts_virtobj_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_virtobj_button_release); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Helper functions for virtual objects on touchscreens"); diff --git a/include/linux/input/ts-virtobj.h b/include/linux/input/ts-virtobj.h new file mode 100644 index 000000000000..f221b46c4d09 --- /dev/null +++ b/include/linux/input/ts-virtobj.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2023 Javier Carrasco + */ + +#ifndef _TS_VIRTOBJ +#define _TS_VIRTOBJ + +#include + +struct input_dev; +struct device; + +struct ts_virtobj_map { + struct ts_virtobj_shape *touchscreen; + bool virtual_touchscreen; + struct ts_virtobj_button *buttons; + u32 button_count; +}; + +struct ts_virtobj_map *ts_virtobj_map_objects(struct device *dev, + struct input_dev *input); + +void ts_virtobj_get_touchscreen_abs(struct ts_virtobj_map *map, u16 *x, u16 *y); + +bool ts_virtobj_mapped_touchscreen(struct ts_virtobj_map *map); + +bool ts_virtobj_mapped_buttons(struct ts_virtobj_map *map); + +bool ts_virtobj_mt_on_touchscreen(struct ts_virtobj_map *map, u32 *x, u32 *y); + +bool ts_virtobj_button_press(struct ts_virtobj_map *map, + struct input_dev *input, u32 x, u32 y, u32 slot); + +bool ts_virtobj_is_button_slot(struct ts_virtobj_map *map, int slot); + +void ts_virtobj_button_release(struct ts_virtobj_map *map, + struct input_dev *input, u32 slot); + +void ts_virtobj_set_button_caps(struct ts_virtobj_map *map, + struct input_dev *dev); + +#endif From patchwork Mon May 15 15:00:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 682129 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 C9ED1C7EE26 for ; Mon, 15 May 2023 15:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240266AbjEOPBY (ORCPT ); Mon, 15 May 2023 11:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241547AbjEOPBS (ORCPT ); Mon, 15 May 2023 11:01:18 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2079.outbound.protection.outlook.com [40.107.7.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BD81BCC; Mon, 15 May 2023 08:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cHsksdh1Vz3YErMQtePMysAzxtupXaz4hYvFysG8Jt+3rcLvJz8oWb/FXdr3ab7GQiYk71heKq8oDXRwdq9dtXQ77m24fx0AG9u4jhdUmyxA984ZN3+2j0r8+YFiEkV6eIc4eQ15EhihOF7/54lmqiDNRNJv+TeMfWiZ6V7fQ39mzbEd7i8asKlWGQS2cSHpJK7RINXN/Q3ewyj7pOJpKMFhw+ilYNGBo9gufv6eEbp8bAAIW8gKlwppNVyrQ04G38Tbhmvr44mo1Q7++OYAX0hU9K/cZgSOC7bY3xD/fi3IV87VE5HCwwkQGEDSYWlgemSgCC4pyN6T15vAlqoOqw== 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=e2B0A3FeBz4LnUbKf47NFwdHTKByHJWHe0IhxqVwHrU=; b=jU111r77Re6RyfjO8Ix27udKeoLfVMWrbpz8nlil3emCDTJtCY0kOBip0QAnyaQG6LDZ2FBwuPvo/D9c/nplRcQX5KNsDxfXDy5tWZw9KLN9YTKVephp0pggXcKK7+3HYeoKxfgojdZhr1UKET61vt16viABsAHi3YYLlKk0RrVslr4/qPW0Iu9jPJczAnatcErjpe7aiVucLEygXM4JMaOTMhCC52CeV4UCXImnNTWY9frDDc/U52ohMl83ngFYD9v+opV1wUZ0EuAQvN0121MX388bdix4kWhKHI3rqOH0yV9oTJQpZhZfbLVSc/Im/jBPNSa3CzJpScoTuS2EIg== 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=e2B0A3FeBz4LnUbKf47NFwdHTKByHJWHe0IhxqVwHrU=; b=RyMfQNSDMCK1NjeKvNRobK49+v6U3eJNIGHqHtoTk+JOfolb3uhL2inUr4mrbYmy8R3LhtCk1cyI84rut87NkLeSnEP4scBTtRa5UbryUUBpi95SA4FGGCe1wety/EQv0rQdykZWA1eHzQjOy/Mxk1fl4tJivjXh7NiMHDUJn2A= 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 VI1PR08MB9982.eurprd08.prod.outlook.com (2603:10a6:800:1c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.29; Mon, 15 May 2023 15:01:06 +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.6387.030; Mon, 15 May 2023 15:01:06 +0000 From: Javier Carrasco Date: Mon, 15 May 2023 17:00:59 +0200 Subject: [PATCH v2 2/4] dt-bindings: touchscreen: add virtual-touchscreen and virtual-buttons properties Message-Id: <20230510-feature-ts_virtobj_patch-v2-2-f68a6bfe7a0f@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@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=1684162864; l=8153; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=QxvMvto/x5XLmhjZ2TbUw5YHv6JL/NthIoSVo7Q2ReE=; b=y49lBfaZ0RNiO3hEYbRqMdT/J6FZz6aI+3xGFEZoSWJ1R7FPwrJWo2Xq63GBau7SOzfE2F4LP epBbe7xJKeeDYXAI/lh8sIgrF26MzsRXzjyhxWkjyUdKEtGUD+yh7CI X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1P195CA0039.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::28) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|VI1PR08MB9982:EE_ X-MS-Office365-Filtering-Correlation-Id: a20afc66-8c3d-4cf2-bb1a-08db55553535 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ajtihGuFBVyNRqfgWLWpboXVvMvryXFKtWodulG6CoTyb01GSUWUdahbG71c+PebSC0KibV//jCStGf33RA0S30Ij3K9+O/+2cr+IjsXFZTF9MNMuRkV9fTl/REfuODhm640tNKEeTEmNFohcO5OEyMa1wviwUPTNtR1uEqB0Nd5YzNlJ8cNdnxqNit/7hh1wsCKBtw9sDk8oLeRC4FpbkythJc+6fQgSj7GXprnXYzZL0njhuXU1SDNLQAK54qvISrDi7WIo5i0o6Jg37OdSO/wFjRLbTqChqHTDJoBk9eojRIND7Rjl8ZAi7cJZHxSE8iWCR6EmpT10QAq/51bQwcmCSUZ480UeSJbeZsRie0MX0udQTx3bfHeCspDI4cTKMUaJFsFKmyu3NVva8BHuQYV57BtEELsAx7OtwL3lHFq3ueYg2KeNa1CbOMrky5NCxSAou/i+Tk1S8XyGud4aQSZh3bGY76SFPP1E0kVaco3kMJqGNtXipNpg2OukQQnz+kdbsDhIIaAkBbgXxKla9rvzFp5nb1rcbIy7l02/OuVKy1okWaunbTXyaTZk0irmcHaC7Ne55y34PvOtfMZiGRLXZv4/cSkwKuY6f93UB6XbkottvzV0xXsM7frL0CG 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)(136003)(376002)(396003)(346002)(366004)(39840400004)(451199021)(478600001)(2616005)(86362001)(6486002)(6512007)(6506007)(26005)(186003)(38100700002)(38350700002)(107886003)(36756003)(52116002)(6666004)(110136005)(2906002)(66946007)(66476007)(66556008)(5660300002)(316002)(6636002)(4326008)(44832011)(8676002)(8936002)(41300700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NbNLWiqh+vnfoZPP30q+D/fatyxQ?= =?utf-8?q?9Sja4c13UBBB1g70zFiNmg6BTDIMk2M4tbHjMFFH/3KxRCG92e1DFA9cdKHiLrtUS?= =?utf-8?q?JCjw7qWkeTIqggiEQZO/iY2RAZl1GbSJdrwh3P62/Yhe+VYSX5Op9hT5XIuVgkJXk?= =?utf-8?q?Q/p7IBh2AkNINx8CVaqGvLpcC4cew72il+8P01Y9NUZtUfNvF4g/7Di0cd5hpmOXS?= =?utf-8?q?cx/we8xA8sxl7vyLX6jmksmcMgeawxEriuIMaqAoqHefdM8JR0ubzVlsFSFMn56Hw?= =?utf-8?q?CUnP24bT5LotOPXWMsdorHm6TrJSyZShywVUGQK4uxBSNf0ffID0nbixGgw8BIxrw?= =?utf-8?q?OgejxyBdifywAp09Gufe9LRfSYbciUe4QgyAf8N1GaZrGTOV2dMCMQ8SRkCinmb6P?= =?utf-8?q?yXCRUxCoNWM9MNdcTRXfNiOXSj2Y+RlrbQxD2b3ZMuC6q8BGM/lSOYVscR+dT6Rp2?= =?utf-8?q?JVM/k9+mqC7D7ynev7gbFfrNr9UOpUnBfAidCIBuQ31EMalCAR3mf6WciDljAuzHu?= =?utf-8?q?sUBY/LYg8zgRJYgih8YNecwWpsRCwOuwrHlfqZH4Yrf4R3NiUqIjvVIdLFApnUC6Q?= =?utf-8?q?sPbZUCBH/rYVEA6TK62/utB3oUMcytahDbT/aWrA/jQ9yfkEVAeYmsC+SUE+ygUZz?= =?utf-8?q?hH/qImxn7Lnfaj8G/dCjnNT5L7fLsIoZH8cRtjaOlO590wXTWZUFpeuZADmZxxbx1?= =?utf-8?q?jBNqaikTEHpsLCw+U+vlvTCRzzG19L9faegUr5FuVScQC64KElTTTFzpswxtpYneQ?= =?utf-8?q?wncIP+9HpP/b7qJgAt8nxzk2XnKTQqdS4a00mcyICFkei5QSPNWADt6yUyMDbNl0K?= =?utf-8?q?+ZBM8RAt13pgXibfNJazYpXWbZeKYlFAllCBXw+YffHf3K9y2DueFaL2MEErxyZCc?= =?utf-8?q?6YBHSmb0zctaTy2uwMHQFTUWM6Pye8DgMTQ7+UiisngsqTnjcz+vKtspqBjJB5z/I?= =?utf-8?q?u+1GGZEuWOzabP6KwO1TWoIfnrM71UQmz3jS52QZPWWxLGTWbdEkzITVxR7QiIdsb?= =?utf-8?q?sIn95M9PiUmOV1gSvQNPCy8gU/qv7OMMikSvLH5hirGrvI3Wcemr/PkiWD8vAkX4Q?= =?utf-8?q?yjW+7CinmmSHCnnElaeyoAnLQwJR2IKRvdF0CdOQCJjQXboerdM6Fcf9NVK7z2iZx?= =?utf-8?q?QXfr16iTwnxgHemfc8R/VXIDbqhSNLpKgVFQDI6Qb8qXsElWD0zHGPkJ9RutstsSn?= =?utf-8?q?1myKCzywnzonXybi1VPWr0nmOoWrCWpZQrWd5uFv+pKeXXyH4EyjQx4heM9xY29wT?= =?utf-8?q?Uc5cTXboGf8mvsByBeP3lSewLsS/wquziYyHKV6bMWWXiLsLGRt289kGFMJpHecPU?= =?utf-8?q?11QUiNTg9XCZTRxCMu54/ZuJZ3P+gqGUodKoHoOr0+AbD0xWzKiHu1hgKMQOSKzs1?= =?utf-8?q?rRJN1lcA4gdBx2Gvr/PnRuBQdQ3oCx9u/A28kcJTGVriT4oyaPjraEMHxwlMI7ukr?= =?utf-8?q?A3iNTnRXGuXuSPf0wlnGjQeTnwnuRBG7ebupXzvRjxgurdAsMQBjkqNmuivZXfiz+?= =?utf-8?q?1BVlrWbK44gcTocXndTezuNQEPaVj/H1/c35W+4JlDQl0cxFLmsbOE4=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: a20afc66-8c3d-4cf2-bb1a-08db55553535 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2023 15:01:05.7545 (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: zmkv/yMPLENwtzlWylevIavpFw2o3aEBw7fYhm/lt3W7RUucjQ2KJFiiVX5AFDcX0Lm6YsHOPkO6+7Wvk4QzGql15UZ1COnjOyVm1tTbQxk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB9982 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The virtual-touchscreen object defines an area within the touchscreen where touch events are reported and their coordinates get converted to the virtual 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 virtual-buttons object contains a node for every button and the key event that should be reported when pressed. Signed-off-by: Javier Carrasco Reviewed-by: Krzysztof Kozlowski --- .../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..866bfb45a8cf 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 + virtual-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 virtual-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 │ │ + │ │ │ │ + │ │ virtual-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 + + virtual-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 virtual-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 virtual-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 virtual-buttons object can be combined with the virtual-touchscreen + object as shown in the following example. In that case only the events + within the virtual-touchscreen object are reported as touch events. + + Touchscreen (full area) + ┌─────────┬──────────────────────────────┐ + │ │ │ + │ │ ┌───────────────────────┐ │ + │ button 0│ │ │ │ + │KEY_POWER│ │ │ │ + │ │ │ │ │ + ├─────────┤ │ virtual-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 Mon May 15 15:01:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 683740 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 9BC42C7EE2C for ; Mon, 15 May 2023 15:01:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241209AbjEOPBQ (ORCPT ); Mon, 15 May 2023 11:01:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240559AbjEOPBP (ORCPT ); Mon, 15 May 2023 11:01:15 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2079.outbound.protection.outlook.com [40.107.7.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AFF10C2; Mon, 15 May 2023 08:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LiKNpPi/Pqc3CCC7qkfkyLM9t3A6VI1pI76MqwqP5j+02MRIGKrvfd9yUgHb7532dDx1AUMKvKlvotWD79g4i5/mYUUxRc4AhCYu4nxZU1welQ0XgRkO4ZlHEhSjC7IiwcMqGnvvVe084BM/MEnCtCIue5CEbYZuIKjA7BAIiuwl/+AGrCqZcJcZWFcgRVHzzRRlqyXagqpnyQQO+GRIpDhTXDvMmKRPOzfx1cLfFnbkR1S3yfu9oM/OFytQcnJ1D5Odv4vHpJ7DNBtvU5MexO/QqbTFEl8JaFT6SJ4VdOJQTkqLNsSUa3KMfJ4WO6jKi6HHt4qB9q6eosbJXt3cVw== 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=dshsPAo++u9o6DL2oV0uKmYNROUNzWuw1+rmEUN4UUE=; b=kZ2KaTa9mAXLIHbAwRhGJQFGh3pMbgEgmDG5cwCRZM8eexIVw5WwhT6cBl/ebeF/YkfJVGYxR4y9WlhVbevsIkL1Vvjj4okemKQetdWX6CBrWeXfQ7s71QpTfI4EVCDtbYd5FHQguU6QBIdFqSQNMWQk5oOjYaHrBe0/E/9krUXi77HoV9yxU0i4R52+FOmNPt4rGTwS6G2kLC+xXlgq8e8SZyrGBfiW1wU6pJyCZ7AyleclpDukDJkcV9g5E9u0S2OlTYHW6I8aTVnVyseGsGjytgiKbc+6ws2T/y8AE6OdXKweoEHVJPGlpCWJkWtLerHW/f2/wvTcU3nEjYCxJg== 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=dshsPAo++u9o6DL2oV0uKmYNROUNzWuw1+rmEUN4UUE=; b=tXMkh5Vi3T7Dr2BvlZWOINzBkpa6+/rga/XopaNK+b4rSqcZVJ+6yEFIcjmvHvpYkN3tTgAJxrBZNR0fpNnUJPL7jWKo3O283BVBPp/QiVXuShYaZeUe0eIGciZ6MJwM3mh4wdhRXyHitkma+QpgKyaA932j7YFT73vb68wibxI= 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 VI1PR08MB9982.eurprd08.prod.outlook.com (2603:10a6:800:1c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.29; Mon, 15 May 2023 15:01:06 +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.6387.030; Mon, 15 May 2023 15:01:06 +0000 From: Javier Carrasco Date: Mon, 15 May 2023 17:01:00 +0200 Subject: [PATCH v2 3/4] Input: st1232 - add virtual touchscreen and buttons handling Message-Id: <20230510-feature-ts_virtobj_patch-v2-3-f68a6bfe7a0f@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@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=1684162864; l=6684; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=M+YZI1K1J+Kh4MA1HKdyZxvjj6Vk6SOC4UKp3Gwdwag=; b=4MVZkZdyiQJHqLRGA22GENL5xPknLmgJ+2gN3Gb3Vay/OebDDAPNAV+rUrZwfGR8CHnk9eLkp bY6qwV9Gii0CthgIZcPgj9eOCNc0hblpdjeguwMV5JeBVSIAwPaE6hj X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1P195CA0039.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::28) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|VI1PR08MB9982:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d753767-e2e9-4eab-f279-08db5555356e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IUAVAQHkCJ9yK/D99UK14aSS1sYn37j4C7SZayoKPALGucoqmjirnjvx2X5VPSm7RYfCsAyjdf3dUTnBBUPsnbAuaAjd6vgv0mPPpyRcJlDBA2PeNVwefH55BjF+JaqGF8FzOi5AoC2Kh+8B02eQWXOH+mtQzqwrGzg1fbv8BuEk3Nwz7WyyqfVz+n+/Xoq5ifqj0WsEBBP+2ZRfMZsF4I5oJxRfjIvvkzUxmcgRaASrpMHb5Z7A4mNO2MzsD6Xb7sWjc30AIl6kPjwoq/1qhLe5p+ek69lK3Kaxig77ld+i96n+w64PsIrUl37JGoWOmyN5sPKylOy1CVGdNv9ZKWm36LXZAcsGeV8lB2yysdtt9Ww22UFOmY+545ti4+P2FV09gCH8qkD4zpU3R68UHe0F0mXp1yABULEQuezjivZ+Zh/36+9cagF+WMFi+kioF+XmaxgJMFt6NrAKC6mxX3g/cWH+izO4/YKxtokL5v11sb8roAKmnuTF0HQGr/1/t17nvrcjxe2gHfUMUteUrSPHwHL9vDUKJK1cUP0s/h6BH4cT2GblPNILqpodidg20DcZCdBxIHdePeZLdkOc/LcrdRX3DGHMlHGeadt1gaq0eyNIju1HJEgKPur6jLoC 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)(136003)(376002)(396003)(346002)(366004)(39840400004)(451199021)(478600001)(2616005)(86362001)(6486002)(83380400001)(6512007)(6506007)(26005)(186003)(38100700002)(38350700002)(107886003)(36756003)(52116002)(6666004)(110136005)(2906002)(66946007)(66476007)(66556008)(5660300002)(316002)(6636002)(4326008)(44832011)(8676002)(8936002)(41300700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?0LtsPTmgM1igrS4hWpIzRR56FWJI?= =?utf-8?q?1Df5Mvno2QAEA+B7FBxnD5SP98B/Vu68gVyUgBYhKT42rhKfU/KgVJ/iPjZwbhJfh?= =?utf-8?q?R2sDlHTbLRcecmaCulWgcpAIbcVXXbiF8M3xgHizTDwUmJjTLAl+9sCqYC/GhPNDc?= =?utf-8?q?HQHD5uPY46Kp9vPEm9d5ZQ6Y3sQRZaO7wjzNVsz92+IZvivJMorWBFFPP/nMNIp5s?= =?utf-8?q?k/IaQhljpNzr66NTT9H1Z7H/kgK6BGcunyjKYPcNq6ttCuHsmdtSyi7MD6aTRo1Ro?= =?utf-8?q?p0p1gCU4pD9amCyufb2NNxU1nIKM6J7k8knO4g8IagGWSuh5KP1+36uf+jgHR1ph+?= =?utf-8?q?vxrNjtcKfJMLURRh9dNpYfR5KxTjbIa0U9vDjDycLhievlNLjNbkUYcZQC2lsuv7h?= =?utf-8?q?4B5zbgFs6WkxXOtAU7aoCQ/ff/p3RdS1fK5XpbKEFGb86T9gHgN/Re9yXC2YYPCEs?= =?utf-8?q?e36vv4ky/11WT5GsXLfjxyqcS18JrKTinSNDsv5VKSr6udT5HMTFDaeU2Hh8vE2jr?= =?utf-8?q?Dji/vfKJqT9tAKxYnRANTIHexEjfL9wRddcPe1oUh2OuWqt6NBNaoW+iD0eKtp6Yq?= =?utf-8?q?k1VcwMEAn8kbGrDUElfKgbyh7CsCBR4HDzevJdCnHlZ/YMxX8anUH2PqdfaNeW9pq?= =?utf-8?q?X0ZULHThYpjT1/cQ2BIlDYzRx5E5fWR+bB6EH/Crcg66t1wuJK01mJoAXK3JtZBvE?= =?utf-8?q?9nbfSnnBmBP/I9b0t2vRuv1jkwI1QBKaFG3+sL/DZFrKAE7meljlIMjHQvw54twK1?= =?utf-8?q?Jg5/aDp4RwfhbKrppIIgyFweOib9oOze8uReHhM5h7TZ1x3CTdHCFGmarsgeNcM2U?= =?utf-8?q?Nn0FtseoP3YWjmLIv45S+2U0UvdXzq50IgmuTayh9r932BLQjuqpMvHwLKUL+Vuvj?= =?utf-8?q?Qs2atyHH+QoB5LOTgdpJG9S8al2G7mPzAEl2qkwmqImICZp5OIDA2O+0JSf3C2tQ6?= =?utf-8?q?BREf51Iipv7HPKgnvScQvGvLjYn/dplGXUlO+0dTICZc3lLJSn4ZBOswxBalmzM5f?= =?utf-8?q?9Eo1fBxxblCGWWM1Z11Bpv0TVrqDpStqlJmqsDTOZycMCxiq5aOaEzkaqInfB42C9?= =?utf-8?q?u7VEeACOXex/Fe+EYTc8uZbM+qKIn/fFMw9ILGPx41E0EpFsDu7DTNzDitHeaFu16?= =?utf-8?q?KJnE7bmXH+n6LBZjaRKroBLbW749aIH3NgxjsoWtgEWZtIt0x3lz2fGGPnfd8KaIl?= =?utf-8?q?Wq9QwTypBXQiWpWtUvKmmzBT/rj1xLC9IOzky8xdeOXyPOh/yoouL71agf5Gp2IYY?= =?utf-8?q?Oz5isKy4YL6PAO24dKztgZZ5wYWGtN0n4ks6++5DbTw1Df7HeDlaKmMfDVw3zA8jh?= =?utf-8?q?HjglxW2WkcWR4laqsBHx7/xsTHOI0jQSne9oqfNMzJDvXOgwnIKdibBY4ROTrBgm5?= =?utf-8?q?Mwys/23Oludpc/LDSjzzCpB1Zja8iz5No8IJRqT0763+VK/2DAxCCc9J6/Ro+pjSt?= =?utf-8?q?Vcbtbaqctl8gsCdjxD8MOIMZy0uj5OKyhjtuSKk0ji0Hmp6hX/84Pd3e0TJuoxumA?= =?utf-8?q?Q1tyt1HQg99UIDvr/Yj3yQ/OkH4BJnYUpWyjwvWY0Yul5vkgmq0dYdE=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 3d753767-e2e9-4eab-f279-08db5555356e X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2023 15:01:06.1441 (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: gDAZemVqe90ex0sAsjbR4KgIWqCLPi4pTNvz/GTi77E2kUTduwTChC+DJrtPR42BJIC6HI8S01k/RO7lIk0qm/e9/57FsabRAo5PegvjarE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB9982 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use ts-virtobj to support overlay objects such as buttons and resized frames defined in the device tree. If a virtual-touchscreen is provided, ignore touch events outside of the area defined by its properties. Otherwise, transform the event coordinates to the virtual-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 0bdbe0a77b34..d975ca308439 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_VIRTOBJ 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..b8139b7daa40 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 *virtual_keypad; + struct ts_virtobj_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->virtual_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_virtobj_is_button_slot(ts->map, i) || + ts_virtobj_button_press(ts->map, keypad, x, y, i)) { + button_pressed[i] = true; + continue; + } + /* Ignore events out of the virtual screen if defined */ + if (!ts_virtobj_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_virtobj_mapped_buttons(ts->map)) { + for (i = 0; i < ts->chip_info->max_fingers; i++) + if (ts_virtobj_is_button_slot(ts->map, i) && + !button_pressed[i]) + ts_virtobj_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 *virtual_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 virtual objects if defined in the device tree */ + ts->map = ts_virtobj_map_objects(&ts->client->dev, ts->input_dev); + if (IS_ERR(ts->map)) + return PTR_ERR(ts->map); + + if (ts_virtobj_mapped_touchscreen(ts->map)) { + /* Read resolution from the virtual touchscreen if defined*/ + ts_virtobj_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 virtual buttons were defined */ + if (ts_virtobj_mapped_buttons(ts->map)) { + virtual_keypad = devm_input_allocate_device(&client->dev); + if (!virtual_keypad) + return -ENOMEM; + + ts->virtual_keypad = virtual_keypad; + virtual_keypad->name = "st1232-keypad"; + virtual_keypad->id.bustype = BUS_I2C; + ts_virtobj_set_button_caps(ts->map, virtual_keypad); + error = input_register_device(ts->virtual_keypad); + if (error) { + dev_err(&client->dev, + "Unable to register %s input device\n", + virtual_keypad->name); + return error; + } + } + i2c_set_clientdata(client, ts); return 0; From patchwork Mon May 15 15:01:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 683741 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 20191C7EE22 for ; Mon, 15 May 2023 15:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239182AbjEOPBM (ORCPT ); Mon, 15 May 2023 11:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjEOPBL (ORCPT ); Mon, 15 May 2023 11:01:11 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2079.outbound.protection.outlook.com [40.107.7.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80ADE10C2; Mon, 15 May 2023 08:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oJhYjWBw/SxGZ4mV2Ot7i5X7/oa+UaId3qbumUTHnpMVcoW1J8lsHV18pYfw6lO4wYD/irrzVHfVfZf5iKPuUfuvn3iMy8ubA/lPX/S3UTAbmaR45xlgwoRm7oRJCUFDXmiklRFCjH7vpaoEnthZjRvPrkuY8PGrpi/bVPk2G4Pn3EmKVi0qK4Vsiiy40Bfb+XCZEHmqu5u1SuwtX+VdhlGW5U1N7BmzSPHPKQVpH9H0NzLY/PiWhrDl0jKOF4hhGtPvFl62PelQmv6FQbIMtzPuXD5L3sSWVqm6fTytN/2uHzkmnftHBBn9DQ9fGP7fnv6V7EczA7HjVF/mftAJHQ== 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=J/w98p7Rv9XfeHIsLTjEjGeRBBY+/4FbzuuN0XWRfwI=; b=n9ci8VstWoSt076hQ2rFXYIY/4+jfVq93oqY/1Uj7ECz2cdnzd5MTblsNznyPtSBQujkE2WqRdlOH8y8NVoLRFuIiM94nf61exbnZTARmepWBFak+5TlpJtv1VhOxsktaJ4p09qUhwnVhZsUZ9Im2fyHtMqKgwehz2M5iBJCE3Hu1lAoI2IKlo0RKRrVSvf3Ena7mcMO+Sb1IPQ8c9BumQEpmqgFTpycgiDePsOwD5AWrbT0d+A3O2EJRxh/09Y4PPmXDC1fJ4b9pCivgwW3CNKQzHiW6ki39wOU8l1+0KrR8tnIQrsmHXaUkBbyezSwK5qWYZxnBGcmdj6S7zT1iw== 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=J/w98p7Rv9XfeHIsLTjEjGeRBBY+/4FbzuuN0XWRfwI=; b=bdsTSG7+0ALEC3wpmZpJovQT8XTXyHgOdVpwm5DU4pBPVWxM3OYB7IrSUdsqmJVDF/0GerhMji3QsP2WLCdSRG14JwRkqYG4m5ivsAttbh+bfTvKhGD1ZI5FvznRKq8AN+e99tb+xYr58k4WXbkXL3DvLLycRgeehNI/HajhF9A= 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 VI1PR08MB9982.eurprd08.prod.outlook.com (2603:10a6:800:1c4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.29; Mon, 15 May 2023 15:01:07 +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.6387.030; Mon, 15 May 2023 15:01:07 +0000 From: Javier Carrasco Date: Mon, 15 May 2023 17:01:01 +0200 Subject: [PATCH v2 4/4] dt-bindings: input: touchscreen: st1232: add example with ts-virtobj Message-Id: <20230510-feature-ts_virtobj_patch-v2-4-f68a6bfe7a0f@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v2-0-f68a6bfe7a0f@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=1684162864; l=2481; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=L1HZGtYon0Lsj8171GCXGrnNhGVlNBwOHdE3pp0WTB4=; b=RSy6sQKnTs6FG/8jZef0jKE9dkRm94wCFi/4KxuvfB+Rs8qPhYEA48oMtppQ9JwfqxrNt5msj vqFQwsd7XH3DPE8jgcvH4+Vq0+sIUu9FMeAHXyINW2XLW8hyDAhUyRl X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1P195CA0039.EURP195.PROD.OUTLOOK.COM (2603:10a6:802:5a::28) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|VI1PR08MB9982:EE_ X-MS-Office365-Filtering-Correlation-Id: e10db002-eaf2-4670-8c10-08db555535aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bmbw5sfIxWM2Xys/rjbaLGVb5Qes4/kWvLUfijxQTQVPvarI8io9gjEI6/Ho/CEDdGbrYLNEJixwUSikFMdaGEfQXMtZIVI2ukTZn6H2T/i3t1i/7EFpVbL/1qsb4Ua10XcNC+MXXdsNtEpTiFmqLO/XpMSAMLYQ/MY15kFWIQvEW5ySreLr0+XjcHGr3BtUpt6NSgpkz2nLD4WfNeIUkdwwfSGjTjjkZm7PlAwwZZ1o6A9MtjAqKwqC+uzr6KYEjs+91Q0x/hb1L0hL+c7CJ/U89wURXKoJKSS6WfcIiXvnw9tZjgVB0eRSRSCMTAZVYp/7/Q00rdyFSDRzlc+kHRZqvraf/B6g77ZdQcPWVYUoEk0zMH8fqxsHxmsSFnEp4PKDkN2qwqxiv9Q2HfdMvLtIZMc4ZmAGihZHf2/CdmCqL7OXnGIn+H+SwGsV507ybCTvEuQOxScFBVzQCWHERmnRhzeKrkzlb2kUX4iMhJVQGhShSF/kr5Tt3iCtKYP/B3YwgmqvgUxiLscX4ZfymAClK5MByhL2oZPswNz1erI/9e8YUaqXUC1b5+UnKSX/qnnEBvOHv+CRdBIByaiVE1xZfySsC48qD2664V3ECc0= 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)(136003)(376002)(396003)(346002)(366004)(39840400004)(451199021)(478600001)(2616005)(86362001)(6486002)(83380400001)(6512007)(6506007)(26005)(186003)(38100700002)(38350700002)(107886003)(36756003)(52116002)(6666004)(110136005)(2906002)(66946007)(66476007)(66556008)(5660300002)(316002)(6636002)(4326008)(44832011)(8676002)(8936002)(41300700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?p4xPmqcHKLvJy/2HVHM7mAhE0Osd?= =?utf-8?q?rHgjTcNV+6Hinl92hhB9N+Y4GNJA/RI/5PyhLu8/KOhgH1wmVU4Ym2xZKNfCEJUxm?= =?utf-8?q?JjRpIR/bqOMdSIA+yU9O28OfYWUbxa0xXn7eHCrTSoFX9xM+uZE59t7OMi47bkXxM?= =?utf-8?q?kRqAuP1bzaP1oUKgSLR2G8wjdyQP7Ji8lJS0k8CFRs06ShVNzjSe1qUeUVNFw+8Vu?= =?utf-8?q?WPON9B78C731uJrwOJ5UAVdbFXgmW4mX9uyi/5FkYGBc6HizfllOKc3MXLuAZDUTG?= =?utf-8?q?YXXBZXMN5eCNwqLeU1m8qHNCWhEmSJebPvznYjjdO4VTvkL/+U3nSNT8Y0GPaX0dR?= =?utf-8?q?DZeQFIwysrIW097J7ST5X4jwQNlABsmAyo304pyMUvQupaA2k/PetzPYaVubYeXF9?= =?utf-8?q?BJwxii31HHd4oP8SRA9I6xQDLR/kKPRNjupE0BDyGVBE6U00++lMcBZi8cQNaAfnV?= =?utf-8?q?dtMlb/9BOYwe0jyG6QuFfSDRJFx4to1ZbTPuEvE5CSR5IrK7gmQ1lsr2ZpqBgE3KZ?= =?utf-8?q?e8Fx9wXZNK65rpMm/FETwzvS9NL78hNvXZXLXFYZQVWJ/bJPr2RIGYjJY961aD9E2?= =?utf-8?q?KAkDLmCSirbexI01YODjZb+jed9MGG3dNQ4vNPvTecwPH7IZ6avbQ8sBjgd1ZAZIQ?= =?utf-8?q?ghFrhOJAJg2oqDf60RjX31l0w3PuQwTnPg/YAXngnfUq6he9Jxl/UZRT3XPzf8Oat?= =?utf-8?q?QU45+M+ooyvStXHE4S49RRDIoKWcHGJ+fz0nkIPVu8nFSXyVPwODauPCtt2iuKrSp?= =?utf-8?q?VZBvBI0maEzxYXqtndcNqhPvw5Tw5BbZNFMYP+cdwQtlD5MPgs8P4OHG5+G84fuGU?= =?utf-8?q?QVw6fJoDNquhQWlp19FOwtbmKnjQ9/dKGyaKnk+W/XknzbTt7aQDiT5EukgXQgDon?= =?utf-8?q?h1QMFfGo2QRJeFRGCRDRneSGhZkpcXpPNtUGj/nXZ1QT//CXKhztNmRDKDvUt1mZr?= =?utf-8?q?7ByTC12gym7uVYdvbi3/NLAILFiE6+RBB9p56Pl+B2ebfAvoAjS45rWhTsJIgTtmY?= =?utf-8?q?e/Su7YPKDp65bUwsHplOuomkDNn5JQlXgk77XhA+2Zs1Rp9R2hRf/kNj4ZfGkf6yi?= =?utf-8?q?bP/TKNnX3AMDnB7a6NDPo1IRuC2WJtAz/2QizVuHnmDBsztsOLgq83nVoM6Q66jc2?= =?utf-8?q?7zq08rpBgze5C3EOJk/7q15jRtXHIQwhzL+4Rt/unyLsKFTe6j3RZ3KgF2B2fr9X9?= =?utf-8?q?N85k7NhbVLLOBGE9vOuUVGHaSsIchBUpBE2noD+VIBJxkqtrvImE6jXORd/UwXIf0?= =?utf-8?q?x/Y8aqiKwJyYYQSc4nRcbLRWZ52A6JiqaN1472JO1Lj2GGqsmLk6VFX44WH9Kdk+3?= =?utf-8?q?3Yd/r+K4tvZzEs0NIuCPZMwyX5R7nqooiofNcYqCzdD0pkDetj9o8kCY3BiYuhOYd?= =?utf-8?q?WIpTos24OATTGvPh6MTfqyRcoZ6aYbtlNZdQxpc/ASJDCV6BjtH9Wc5HsYSTdaKzV?= =?utf-8?q?Jenr9yadCArauNCfeA7xtcKmM/m0XcYOWc0M5vvQ7uAtz+Vu2NJMd3N7hn74kk727?= =?utf-8?q?7OPZ80CbZQ1cVReb0xzKgMGcKQnpBSoAabpHOcwEcKjvmJ2f+m3A3/Q=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: e10db002-eaf2-4670-8c10-08db555535aa X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2023 15:01:06.5307 (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: XXi775TUX85mmcGOgMuxCzHXBEGtHsWp/ED87BAKO3birnhG7whwIXlkcRgybdyaQL5jgXgKNx1XVYzzEZ3p0JKwu5D9mYNTubR4iXvwlZU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB9982 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The st1232 driver supports the virtual-touchscreen and virtual-buttons objects defined in the generic touchscreen bindings and implemented in the ts-virtobj module. Add an example where nodes for a virtual touchscreen and virtual 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..97a2c063b47c 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>; + + virtual-touchscreen { + x-origin = <0>; + x-size = <240>; + y-origin = <40>; + y-size = <280>; + }; + + virtual-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>; + }; + }; + }; + };