From patchwork Wed May 10 13:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13236945 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 C5EE9C7EE23 for ; Wed, 10 May 2023 13:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237232AbjEJNxH (ORCPT ); Wed, 10 May 2023 09:53:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237316AbjEJNww (ORCPT ); Wed, 10 May 2023 09:52:52 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20631.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F92AD10; Wed, 10 May 2023 06:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mwQQBROZv3j7ugdrMULOAM7tL1PRY40cTe22aWq9zwtXYK0FFtcampY33ZdJZh7ViN8RE6OkhUo5rg3urnyRmD+H8ew+O84ckhO+9JOdWdW2z+Dqjjt1oTwDS3NihwTdtIuoPFeUTAhaWiWuabsIMmGeG7r03aD5PcIDSQaiDRRQb1QNcB5l26YsOnTcjn4aY9LIvrxBGX4i62yo27mDSkA+SfbAuwwSiTZwyTGhMCymAArpvsgW/jQEHJ1j1PZ9cuD/oUBx10bzTVcWwQ4tCfZY91D0kxH6rkU8RemaVvrv35scNiMNGPB0Ep9yhRNI3z9KLqRwC4qLcshXMwJ+bw== 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=CFVRitJFlI6mxlQmNRx8FZPHBNUHRPAFfG+HfHhgBjY=; b=bkB3KChpVtb4Op0nn0aRvS4nU3tN74zg3+ITUVmrdH8ElwBVKW2wcUvQqER+VIPMql22f8GW9qz857oRqabMq0ifO8uNF6YErSPQqDsaRYb3lvTQfvLhfEZPnHCk9XVoyiFt97ORcCqTr7mjDMsjVXmVVbwv5IiZ1WIyf1llXdA2eIbIXDMQt8JWBOWgwZ8DVlht+Ib4RZ/Zl2ILrw1EqIckDSlrOa4o463gVs02SQ4XJNcPVRap7g7moOS0ju8SbQglqO92883wErxZ3MWD7ZtrksWnlUPAqLan8nswUY8ceSrQmH2wJMimyV0r9JkhNF7Srw+7eEXK7NuiJtjFsA== 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=CFVRitJFlI6mxlQmNRx8FZPHBNUHRPAFfG+HfHhgBjY=; b=VThCI4MSPH921HY9ZTo4k7pKXkZyWKtcvzNpg9mXnn2A6IeEsjKsgowDJZQ+lO4oq47WmHDJWdmldbngQ/IQ6yxdXj+TL6pk4ZkIz7mESCk+phiJz0XpYDJZIgvu+uljbmcXjpX1CQhPEh7QfJPE2FjK0HrcPdVvIhQJrEHq8GY= 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 PAWPR08MB10212.eurprd08.prod.outlook.com (2603:10a6:102:369::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.19; Wed, 10 May 2023 13:51:12 +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.019; Wed, 10 May 2023 13:51:12 +0000 From: Javier Carrasco Date: Wed, 10 May 2023 15:50:46 +0200 Subject: [PATCH 1/4] Input: ts-virtobj - Add touchsreen virtual object handling Message-Id: <20230510-feature-ts_virtobj_patch-v1-1-5ae5e81bc264@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@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=1683726670; l=14195; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=9hafbOgn/l1b7xRyuf2Eep+jcODbpHfdSt2LYOw75W0=; b=BRd7C1/IJJAmoc/hyGLE1XAGxzeBJaR62fc3FAXnpim3wtGYMXJxXYcZwh+HnUiySS2YD2v6a 2xfvos7lz6bDjSQEdgKKVuZZYjN3jqpSkKURqgtuaiGM7MrGwLCu547 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR0102CA0093.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::34) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|PAWPR08MB10212:EE_ X-MS-Office365-Filtering-Correlation-Id: 11566b4a-2bc9-4a07-a6cd-08db515d9d4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Arf0hmoMSwoSdU2tnCT73QfLnU+2h35o/GZUcudmOZt+9uYIIEnrGDoa3vNkBueA4JSYLZMlijLODXu+pBXUc0xu+pZrFXDD4CAH5u1oDxADKZiChc3AMSErga75nwVK+fwQsywfb8kzhknXgZCCg7FtHhYed3WnZ0n1gjvM32JRarbyu6RSpd6o5bODNgx3Q/PlIZCK9xPdmV6hMIas7Pab0Hi8IavotYlanBNM4xdLB3xWytL7Yneo8AI+POTFyCufj8d6z1ahV/UUiT52vGkwIe5Ggs8fZPd4qc1MB3l55jHGBcL3OZqlSoZcXi9wj73tfGm/9/dHeRi7LzsZc1xSsa3gwOMcXDmRZaG9mlpC9RxiY3nAqAyMwjzRTLbwfx4xXAsLEwxyg4LoBhRpdOLhU+8EbEAtm/jsXgdFWssu7dmnEnRDm7WT0LrXohtma05Y0dPr87xzYVGTHooIj4mijOsUzT5YptYJWmCdcjP7Bd/75psQU8w+rDnATTlMgXCIl0iOpnzp4TyP3yIucvQIUHnZoeX3j0tjktdJT+ydmh5R/2UdGxDBgAHfQ5tyCdO97xwBPlaTuwISIU1UhMnBNiObxlWFw4QIML896LU= 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)(366004)(346002)(376002)(136003)(39850400004)(396003)(451199021)(86362001)(36756003)(6666004)(966005)(110136005)(316002)(6636002)(4326008)(66476007)(52116002)(478600001)(66946007)(66556008)(6486002)(41300700001)(5660300002)(44832011)(8936002)(8676002)(2906002)(30864003)(38100700002)(38350700002)(186003)(2616005)(26005)(6512007)(107886003)(6506007)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qMIVJG6jupm2oOgV0D2wyn4tKLHJ?= =?utf-8?q?ahxbfrA9GkUuX5lG8ntJQJaw8RmT93GGoHnmheMvTHcavLVPjQwzQSotgGJynh/5u?= =?utf-8?q?joVvwBEdpU+v1STK7o0L4ogzSxk8kxnYJUpFUVyXNGxr0S1dR81VWo/euZ2UFGLrw?= =?utf-8?q?E4oqRUJR/NQnr1brcXr6It7YvLc7n/vtUAJCI+wl1sO80G05SyFoptgVhGwYvuMJ/?= =?utf-8?q?PvH8p0XKw+/7cFh7pqlYLvmGNCnkPxSEuXpHskCzSLpSOT+BLF0EuTjuGZTtOLUrc?= =?utf-8?q?fdsaKjE8enBch1d10Wn36u/5qIxxEYE6R/z/5OfOpdrS53tLW1EG+5zXYYVUtcR1w?= =?utf-8?q?POuu7h4ghpmwpaaKXVbogvu2MP8ySyIiMTJxMufyHRXDWwWBR1ZkjLxrqhnehAd95?= =?utf-8?q?2t6cK3/Vj4+5rkLAIQN5M2f90QtYsxPD/33E59SkQALynJ39tieCg69Sc8OXStfTq?= =?utf-8?q?IaeRrayKhrsxAqDj0TIizlOoipiAIq+EfZb92ZkmrnbPBKQhUDpLBjvhR3afaTdRX?= =?utf-8?q?NPIm4agB8sCJOUXhWBnA6FwC+inlLppk0ABnss6uKdfG8HC+acsEYmT5u09YjIjh2?= =?utf-8?q?zvu2zAdFbGkHvp5xJezvaoK5aWxm2IO+F6wr1D8tr8B0t9AoYpZ5e4cd+/2fNYEGU?= =?utf-8?q?FCXVi8USC210o7bTaAufytQeMSacPEMUrBCRYNRxoeBpil/02HR0UGCV3I0YuVidV?= =?utf-8?q?/jPLPyDwvAMSI2L2VqjiPn4Us+Dr8o5S+ug+NfDAIy6rlcfl+lFw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08db515d9d4e X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 13:51:11.7855 (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: rQ3o/S5kMuqLC47esDe8AiuZy9CKh0LssFffWXOo+Xo7KwtkQj+GI9TkBHmC1+xs6a1x0q50zZbo8pUYI+dIJUqS8VomsaShQ79WicOj2wU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10212 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 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 | 360 +++++++++++++++++++++++++++++++++ include/linux/input/ts-virtobj.h | 95 +++++++++ 5 files changed, 472 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..276f6e0b914b 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. + + To compile this feature as a module, choose M here: the + module will be called ts-virtobj. + 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..56c137fc49a3 --- /dev/null +++ b/drivers/input/touchscreen/ts-virtobj.c @@ -0,0 +1,360 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Helper functions for virtual objects on touchscreens + * + * Copyright (c) 2023 Javier Carrasco + */ + +#include +#include +#include +#include +#include + +#if IS_ENABLED(CONFIG_TOUCHSCREEN_TS_VIRTOBJ) + +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); + +#endif + +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..5f9d0059451e --- /dev/null +++ b/include/linux/input/ts-virtobj.h @@ -0,0 +1,95 @@ +/* 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; +}; + +#if IS_ENABLED(CONFIG_TOUCHSCREEN_TS_VIRTOBJ) +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); +#else +static inline struct ts_virtobj_map * +ts_virtobj_map_objects(struct device *dev, struct input_dev *input) +{ + return NULL; +} + +static inline void ts_virtobj_get_touchscreen_abs(struct ts_virtobj_map *map, + u16 *x, u16 *y) +{ +} + +static inline bool ts_virtobj_mapped_touchscreen(struct ts_virtobj_map *map) +{ + return false; +} + +static inline bool ts_virtobj_mapped_buttons(struct ts_virtobj_map *map) +{ + return false; +} + +static inline bool ts_virtobj_mt_on_touchscreen(struct ts_virtobj_map *map, + u32 *x, u32 *y) +{ + return true; +} + +static inline bool ts_virtobj_button_press(struct ts_virtobj_map *map, + struct input_dev *input, u32 x, + u32 y, u32 slot) +{ + return false; +} + +static inline bool ts_virtobj_is_button_slot(struct ts_virtobj_map *map, + int slot) +{ + return false; +} + +static inline void ts_virtobj_button_release(struct ts_virtobj_map *map, + struct input_dev *input, u32 slot) +{ +} + +static inline void ts_virtobj_set_button_caps(struct ts_virtobj_map *map, + struct input_dev *dev) +{ +} +#endif + +#endif From patchwork Wed May 10 13:50:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13236947 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 C7343C7EE23 for ; Wed, 10 May 2023 13:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237125AbjEJNx0 (ORCPT ); Wed, 10 May 2023 09:53:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236995AbjEJNxB (ORCPT ); Wed, 10 May 2023 09:53:01 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2067.outbound.protection.outlook.com [40.107.20.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 733C5D2FC; Wed, 10 May 2023 06:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLCUt4bmIKBALLZBRKI+ZiqkRGi80j4+BLwgK7vJbg5fpl29lVq5E90es1OZc1xo23fibAdsoO0vx8qxJm7H4p7Yd435T+cc5jUb6MLb5lS5J0I1NB1NOqXqtzZPtS6LlDTqTpC/h/TjNAk/C/IKNBV+DbYqwaXHd9wy2DXrBqTy+cTk5q5g/qCBQGcdTaWQ/AjwNgImd8aj+xTyGKP712sEBQemmonOJ1tsyNtYejucLS4tyATn0/sm9sF4kMJ8UWN0EYVIgVYD/PoV2mMlMkJM21qQckiluRRMIB5BUSqqu1wM1stej4VJC1M66Bkd72jY1xb88bXpgDzvWtDaPQ== 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=Ke1LFs/dT6GQmzTiLzBym6UON1WUtBhFgAWU2ef3oII=; b=UbQG/LXfS6DvylAJHwES5A6k/zbqXwB9XgOMaagPynv+vKJ3FYQmCwS7U0qCcWA72FUkq6qIfASuyrmirXllw7O1D+qGdIzNRCjSmyPBq19lTyaz+iy+PUsMSxzMm8M+k4hz3Xumfwd+xVngGElDhMZ2grNPfrWRVoNl2HuzELAf7pUI7SvexPPXfcjwsXR1OpWA1f2ZlGNFrmIxMGlcU32ExbTJmPD425071X4yeF/drXgxLpVdSI9J/fyMsSMdkRu7GySEZF0ONkywtuL43SXs8HNoZr8XN7GYU3thGVyOizKF8DePWgISHEZQQXFEUvQ/yMHhyC15jVAlb8lq1Q== 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=Ke1LFs/dT6GQmzTiLzBym6UON1WUtBhFgAWU2ef3oII=; b=Lc4CNG02Ekn652HwjAq6oiX/q9lZK91e3gL8l/YeceWWH/5wLJ0FyI3j1mP6z23U14vRvm2MBx/SaG+IfrCTj0QMuc9vWdNHgvE+BGzjKTVn1+o20HL6SsrUYQKGfrCvcJnM/j6CrxzNIoRXDapZyKdfbkgah7jczXGhI2Uh2Tc= 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 PAWPR08MB10212.eurprd08.prod.outlook.com (2603:10a6:102:369::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.19; Wed, 10 May 2023 13:51:12 +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.019; Wed, 10 May 2023 13:51:12 +0000 From: Javier Carrasco Date: Wed, 10 May 2023 15:50:47 +0200 Subject: [PATCH 2/4] dt-bindings: touchscreen: add virtual-touchscreen and virtual-buttons properties Message-Id: <20230510-feature-ts_virtobj_patch-v1-2-5ae5e81bc264@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@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=1683726670; l=2958; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=oif59evYmkWx/9LoiD8k2HlA1dSFIUUqMXLuvbr2Lqk=; b=PzFUqKYA9spA9HVPy0NQowGVPFY6XWsf+m5guzxZwONFkKWUt0v51cT/CTBChNhfn1/QXPMIR tWxcavHOxBlCm72auxFBBbSha80HbYL6raye9SIZjOqvw5UJgLUnRI1 X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR0102CA0093.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::34) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|PAWPR08MB10212:EE_ X-MS-Office365-Filtering-Correlation-Id: 63ecf529-b5b4-4ce9-0505-08db515d9d8f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0RIv+VKXC3HObnyQvw+BDinCebPoI9inh0dLbujFdWKLvXGtc4wxhVkNHOc8KU2TcnyPtMPncou+a8yzobz82HSpzzzvLjqz73MIwy5l4OMxlqjdWAT6N+2CS9VH+aBGvPwt9EAew+VlTipPW6egH8m22Tn6qv+nGWrpVu8LIJ+8k+Tl+mPUlUfyYDW2Y1Lp4uy0s1lHuEiST3fHVjQM+BCjR3k03+LHafTd9FVUFuZPWi6zYoNhZQxY3j4hWB6U7S5SgrhUwdzUYQzVqeMDDAe/Q9UWxSfTZQYyEdfUrpzwk4iMGEloylOGk1QJw/5rgkvXklaautfP/NsdpKT1Z6ZeVwNbtuvV21HTg/TD0zlW2LxjmIGZP1feGBp48waD/lVtz51u2srgBjsmfUny+y6beO/i/D3KYOFvn68tb1aakCPRLAaulVDZZxPffhY09C1PYR8SIR3iCiRLSe0xr0kYICvhSwZrxTiONQuRZJFtYNMFl+Zy/uyLfAuVP7OM9W3QNZP9CXWb+sVq4CeHHKXuqU7MgdsnGhAQc6dwhw5TyDJ/XLx0J8yEjmYvmhqodQOjDz6bGwjGVQWNdzvYoddIsOyVQQGY0sUR4997mEa7xgilXD2j4/CG0lUpTPCD 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)(366004)(346002)(376002)(136003)(39850400004)(396003)(451199021)(86362001)(36756003)(6666004)(110136005)(316002)(6636002)(4326008)(66476007)(52116002)(478600001)(66946007)(66556008)(6486002)(41300700001)(5660300002)(44832011)(8936002)(8676002)(2906002)(38100700002)(38350700002)(186003)(2616005)(26005)(6512007)(107886003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?cK8vAFYivq+0BfQ68bl/3oXGx+td?= =?utf-8?q?IVdjriQ01ncvKXxPHGTrYXyE3eML2b+aXetD87HN7iOY+P6BrcQe83wGe8FztFUtG?= =?utf-8?q?Hi7oB6sKJ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JzmDDrkWiuinS9wXUbvJdMdpoED03AImZrvYFbDO+ETXymPbxIFgTYZSR?= =?utf-8?q?82O0LtGW/lr92BTviY9bZLyoSpHw2DmCxNEhLYGx8l9NctLgrVTnHw/EKyEIKxM5b?= =?utf-8?q?L3kvJ4lHiLXFv9VK1SzrQSmhPydHga1vmtBa/q/8bDCnyuP5liXNqvpVKgYf5V3IM?= =?utf-8?q?mCpDoJoM3cFNT96g8gpcCBLwMf1GgibO7XuBAf8uHPFSurhllHKHLmuZe80iq1CKj?= =?utf-8?q?WOH+N9xCDY6tElMYP3j62HrfTg84eOX22JcR8MJ/+HHaJJUGw1oUCOH40Krl2zyuf?= =?utf-8?q?mPI+5rzgIxiMqxmYKmlPeXfBIxepDLKb5YqUka5vychp5kBiBEHzp3K9vhYIp6O1M?= =?utf-8?q?ZNcqZvER+bdXatpUtg7d/ZweGb+MhuNQHdX/lvxJvrUkcStwrrzNjLSJjk8+AUls2?= =?utf-8?q?T0dRyZS7MZH4VKZakUeV9X+6ljyb9Z8XOU5G6BNPWIhnpl571HR/OtNK2xkETCaW0?= =?utf-8?q?x4ZF/r+sp8w5IwlWQH1ytMUSDTFEvX9Mw04frTN8i5yf0hQpAlTLz6pM3FcQ3V5AS?= =?utf-8?q?VuNDVFhhO3RUBuFCh0/5VFS4sMlNPla1UFhzfSeRn7NpsxyTyWVeWKA=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 63ecf529-b5b4-4ce9-0505-08db515d9d8f X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 13:51:12.1890 (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: o99MtG53dc4xH/rpmLiIf2UvdN+wyhCxrk/bzVG8IHPjwsa4Spz+OOOBVdwPnFNb90OJbZUgt5aq6s+TUQRd5jTX/gaOonbCTGJMIWjkNQA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10212 Precedence: bulk List-ID: X-Mailing-List: linux-input@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 --- .../bindings/input/touchscreen/touchscreen.yaml | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml index 895592da9626..869be007eb6f 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.yaml @@ -80,6 +80,60 @@ properties: touchscreen-y-plate-ohms: description: Resistance of the Y-plate in Ohms + virtual-touchscreen: + description: Clipped touchscreen area + 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 + 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 Wed May 10 13:50:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13236946 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 2E595C7EE23 for ; Wed, 10 May 2023 13:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237281AbjEJNxJ (ORCPT ); Wed, 10 May 2023 09:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236975AbjEJNw4 (ORCPT ); Wed, 10 May 2023 09:52:56 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20602.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaf::602]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82844DC54; Wed, 10 May 2023 06:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vt5/nr0qEKeaNQdjfBTR+T11sr1l9/Nb6BCj552HU6+ED4KmhPhobLJI+AtCqQampY2t6LEwkB2P2nd6l8WbkyJMvC49GDymfvq2mis4BB+WlqkJr6E9cQd5PjJWb0QOSnyo5SkPyLLqMnlTqEgyojjKnFpUHDiRtQQxSjvUMrOzNRMRwfFKLSzv5p3hChAh8RlfLTvLHtvxdfB4wwCH3cDZ2CpSB1U2YtY+TYteG2hLKxbXJCWejcDDHTMQPLdKDZNe28JS+IEsembknI9vC4LZg95ICh1CJciDfbK9tWEznTzUxzoMTcTDlRBEt+DvcR8w935ParCzLa7789QHrQ== 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=LOuqX80ES/n3XjsvI7/oioFCWoheiOJW/6TgOGVbclM=; b=mZS1APL6mf++221zv3eW30stDIkJSp12g0a5fyrtdk20iaaXeaNGQab09y2QP3p5XZz82MThovXPk7Conr/KDGAlZdT4g4VoJDTPgc/dBnDu60RnPgnXH2Izhub/F8dZYspH59xxgf46Z0pfn00QEfS4AfeI4Wzpn9ecnGCjR7bC1yHMT6ZDtSx8f4F7wOmPw//qUD+VtTrHKwU60sK/73Yhl99HacIe0yICNwLKimYTQQYGHT8U3tRTCMhNTgYNPe4ssOZQYLcWeDBTMjP1e3IvqeJtDqvFwjoDCwW8PTHucby0s8gqSOAkwDcGvtGH8ztPV5VOgxZ2BtEcJK+uHQ== 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=LOuqX80ES/n3XjsvI7/oioFCWoheiOJW/6TgOGVbclM=; b=WgdWAUaF6oEGyX1fPeyT/+/rrWm6NJ8ttHqk3NO24OTPcwDcHHkkgm74dk+jWVszYT7T7PZIhRUoCRud22Xmg3Q0pKqE8Qpv+l2gkQtUuqw+AFxEA3a62CHfjcirxzFQzhhv8UvYBLVSO8/mJ+Y8NlXxv31V/AR42x/xEEHrjIo= 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 PAWPR08MB10212.eurprd08.prod.outlook.com (2603:10a6:102:369::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.19; Wed, 10 May 2023 13:51:13 +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.019; Wed, 10 May 2023 13:51:13 +0000 From: Javier Carrasco Date: Wed, 10 May 2023 15:50:48 +0200 Subject: [PATCH 3/4] Input: st1232 - add virtual touchscreen and buttons handling Message-Id: <20230510-feature-ts_virtobj_patch-v1-3-5ae5e81bc264@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@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=1683726670; l=5714; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=fWrCGxaXlY48WwSbRN/CYfxP5nues3x9k/+33c+j4hk=; b=aVn1MhrI4JhXOMAF279flCvJahcG4mP/BJWunH9hIKJheOxmF6mGL10i+kBzbNeNiK308QbdY W1JeUKzqa8qCmnlafjvuy0mSPtjh2rbx3PPvsDufKP7aw5JMxuUHj+N X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR0102CA0093.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::34) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|PAWPR08MB10212:EE_ X-MS-Office365-Filtering-Correlation-Id: 232d81bc-852d-428c-00c8-08db515d9dcd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i5s+7sy7N1zpBERTKW773zpFALz/rNXAWBMCaz7tsDi3jfFAhxmkpgAPUlpoYrS7n1QC+4C4mglcwWNqjhVt+/4seM9OEJVzujEaYS2TLEyrV4LV9PLJz6ytCXc09DL6v/O0Fqu4VFlsHNGz9OTkUFa19jqHwqEIVfMGxg4M/SzmYk9Ey/wVU9kOhKWyMJMwJZMPyvIZ4QzYLfUNL0UBTf+hzaK6aLIh8G4NCnBheJp7QWewUakmbggPUVqtAEqiLC6xgYgqs+akepb5nqHnAUcg+0i4iI/Phe9fJBNqR0ybkPTxHfXiPhjL1egIAmbbXQjelIEACehHKwdZVwpKIulbHa/9uf5hHAW4+48ZHivkbIjfO9VVb5aXYmPAuWEehggaxyaokP1oxTYfCOu4YcIiGWxNcqlGiqBpplkA0kKEBbTF1XBsDrYMF2LIIyiIN/puBRpO8AJWTy8Opmq4oGk0abw/68xrGXB4b/uKF+GOxctR+PbfxFbQKYEvHJ4JAS2MW5ChUbYBfNVQspZ6NuVpuSkuyvvuE4wWB0kE6S6bsZHdBn04a9xu98HLWiFVEPtz/iy9mDLlpH1edC/YkuqagCayQsjRcAOaiJ2lWLcA1kQTpYXuT1BG+KM9kfYu 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)(366004)(346002)(376002)(136003)(39850400004)(396003)(451199021)(86362001)(36756003)(6666004)(110136005)(316002)(6636002)(4326008)(66476007)(52116002)(478600001)(66946007)(66556008)(6486002)(41300700001)(5660300002)(44832011)(8936002)(8676002)(2906002)(38100700002)(38350700002)(186003)(2616005)(26005)(6512007)(107886003)(6506007)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?QLowoXt/LQPR2txVpupDugsB1tAU?= =?utf-8?q?xaTwtcNhDRTruC7jXWmHCPv315g0xRQXnbMMNrCq2arDgk6/qthZEd++DDv3Xofs5?= =?utf-8?q?NglI8TLNtvQMMjQlZq3WQOL72goBcoNT25SUjt1iH8HScl4rZ1Y+dJ7bxm7OGv690?= =?utf-8?q?VIc1xvs6qVJIdYupotKd31h6GtXIlSaOvmoAyxiWqr3WoVgo1niKYmboOc47/xmyN?= =?utf-8?q?D/4qcWp5aksiI9w4uldkOJcRmsh6k4mxMB9dZrmGI+Z1OqLIwhq1Flu0C67G+8pfp?= =?utf-8?q?3wu+CQ5u9HrI9IKnJ7k+yLsrnHpaPSoZNrGqb3XUw6wm3uYH/ppfP8ars5vvwPKKk?= =?utf-8?q?x2n01IDncFWYfLGe6rfK5uSNhLv+gnIPtHFEtGC2CCo8PtL4TzV4NVrv/9JBq94TY?= =?utf-8?q?4cFKYdu9To1b2Q0n5exZv8I/vrXaPSzgUYKS7PbhbsohabBXsNyu+RrjluMTn+2IJ?= =?utf-8?q?9TyvPLLTwOvRjunlrFOu+7dGzvCZnvtNIil05O7CzYpOGky1Bc64+tjLh+Ai66Lxy?= =?utf-8?q?XqUdq4Hat1nNd2ojRabziPVMnfFj3s08CN7V6fslsK+MxMgKt/BVxzlARxSGgKUav?= =?utf-8?q?IK9qqNNyOdXlmzU/9RqbMigXXJI2yc8OBh8LeNvmVvNhYI/R2QWb6jp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?q?1lPgVybXnrDOBTO+graVPBh9VFq8QG6D6sUcvEbFYzjHe+0kFEklE5g=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 232d81bc-852d-428c-00c8-08db515d9dcd X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 13:51:13.0848 (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: w3HvyBafXPCY0h1FuzM/JTxPCcX58gjEz3jzKVVGbuXvpAOlTAhAxvjIy6m8RwQWQ28nLBuMKPU6ekHUny0ILch9WMErqGy3RMKqHkX0qPU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10212 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use ts-virtobj to support overlay objects such as buttons and resized frames defined in the device tree. Signed-off-by: Javier Carrasco --- drivers/input/touchscreen/st1232.c | 87 ++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 18 deletions(-) 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 Wed May 10 13:50:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13236944 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 612F0C77B7D for ; Wed, 10 May 2023 13:52:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237293AbjEJNwo (ORCPT ); Wed, 10 May 2023 09:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236355AbjEJNw2 (ORCPT ); Wed, 10 May 2023 09:52:28 -0400 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20631.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2D232130; Wed, 10 May 2023 06:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHYTWhUVE6QZZNfpPBt9XQveCJFJnW9xiSntG2UzSXceRza06YHaZCUXZkQg2DG7VqjFqOe143FDTKBY6mldWCMchZoLuAKn4HmwvzXuc986z0AO91b4y6sle97Z0ssmG35LNgpzvfloymfC03NbQwEYlDuH8HEaz7ove+c0rgZNNPaX1QwId/M4usZl9DylaBs1ejHmnMHCXAJnp7stPuGapOqevwxfpfRBWAVXnIf2X4q+ewjEQ89vxE+hi9o3KtwQ4I0MO9SyCIctp4D3BRzLi/9TOizZT86YmRZERux9rX4C6/bLr0uIX+v0LLk8LP6w3GxL6VyOviO42OBHtw== 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=MsTR+tyipsU7lsIwkkWcPeOjmoMlyz5OJDdhgY9VDIativyC9xJNzASDTjdErEg6167vEQ/w5IQs3PzpQPwoSrmzIYq/nGQNrf/X/t5VPxkfG8ZoV9gBUZ5U0zuNgq/je8jk7t6TKQGDKlICvuMu1HfGfvQgY58zFEglsOHg9S15aFxXATr1/eoHmzBP2n3b/KhzxdpBiqUcV5CQqyIMGv1I49CLQaoi61FdIM/iXPhVZ6+qw4dHbaND3TK/Qa9QeQwKr6AHcabPD7OCIcOOgcp0Q1JO4joHnDpy7MJ1y33VJetDABxQyoPIaqh/6d/pJoTzyrHNMJwEaHaJCKAtuA== 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=RNCI5YYBjSJGmFCf95qXXXDtm/nBgNN9bnj2dNIlAnmZ7wYubVD0bZSlkEF3IZRQ9LU5Tae7GaUMnMtECHcC5L4WMd24vT12sVgKPUMHRJOqrW2RiVSoypvIqyDabINMrZ+PysnCT0kNlrjrpDuhRXlqyDShMbYFBlGuTa1eAZs= 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 PAWPR08MB10212.eurprd08.prod.outlook.com (2603:10a6:102:369::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.19; Wed, 10 May 2023 13:51:13 +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.019; Wed, 10 May 2023 13:51:13 +0000 From: Javier Carrasco Date: Wed, 10 May 2023 15:50:49 +0200 Subject: [PATCH 4/4] dt-bindings: input: touchscreen: st1232: add example with ts-virtobj Message-Id: <20230510-feature-ts_virtobj_patch-v1-4-5ae5e81bc264@wolfvision.net> References: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@wolfvision.net> In-Reply-To: <20230510-feature-ts_virtobj_patch-v1-0-5ae5e81bc264@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=1683726670; l=2481; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=L1HZGtYon0Lsj8171GCXGrnNhGVlNBwOHdE3pp0WTB4=; b=lkvjoEGqMVKC47UUSoWEIcyfEkqJJWQlBhDKJ2MuLqTvnXUPdFUa/PY90PH6/aUs7HED/PiEp H6a1SMtjfugACpmVRfiLZzual2Jj7vCv3QLDdgSkjlJHX+QDQc3W3jN X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1PR0102CA0093.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::34) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|PAWPR08MB10212:EE_ X-MS-Office365-Filtering-Correlation-Id: 1341ba47-dcaa-46a8-6d2e-08db515d9e5e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xhcUYR65ibgG6bQ1MmzsMtQrPzWsyq7SRwfelWJSrUAITc0/9yZAYD3Z3pEewxZNIGfd699M1hRepUwKgRibULLDoN23+O7A9KBYiIWbAgm0OBqV1nhZQe5mxp/+yYwMZ/bAHq9v0ZxBHdFLLFns1FPyY6aTGfqXp9JrdfRzG098V0Ab9JMl+YimYETXfQbCoQbVqQnywOkffuK/jf6jkoNTrGvm6Ui6qtbvQeyQ7mSjU7GU0uclz6lwEqeju6eqv01+YN7QCYvZI/XRHRLNetdSyLsyCtBDfHsDTGv3lLNg0rBuNs8bXyYvv/413f+EVSeCXZsGhC17Pixq4opc4hMBaHkVVPl5mJ1b8S+JyDAkf7IUSJCtheq4h+d1gIoaSc5loLMqSBHxsSSCeBLSFgM4moDVTr8nsN/p+tN4I2d7sKi7EDW9ruREvsi+nV9R2bq1DSaJjrzcBvy8nxFFqW7NCP5S/ucN1Ea0Yhs5eOJ0zLU0iMEAX2ObxWwMNuMohl8OUPa3lwo+mrUEgWMZ8tryeAl+Qbaq1ggV/Roi0gh5Yy/LvXIO3+Bh8mTxg9t7YQMwWUE53yCDoGKVofcN+TYoJnl8mMTMX8wwLiIkacg= 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)(366004)(346002)(376002)(136003)(39850400004)(396003)(451199021)(86362001)(36756003)(6666004)(110136005)(316002)(6636002)(4326008)(66476007)(52116002)(478600001)(66946007)(66556008)(6486002)(41300700001)(5660300002)(44832011)(8936002)(8676002)(2906002)(38100700002)(38350700002)(186003)(2616005)(26005)(6512007)(107886003)(6506007)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Z6JGIBTXMdUw2gWE3vyiORQwz/TO?= =?utf-8?q?j6KiS/lGrwTIvTYEQ1POOiw6PL6Qb46vorHZZfJrdyEUWzUwcdVfh5nDTKRBZV4Bx?= =?utf-8?q?UpUw+CfaiD3sMlwaGOKDdmxjWU1I1VO3rLnQaCw9c9k2I1DNpURNlDjv8GCtccl8u?= =?utf-8?q?yG+QL+2K57XJ0CdTQ8FjtLtW6Xdu2mUFVSE+ByeQdJGUiGOwnPojQ5WccQy2gU5CY?= =?utf-8?q?YyjaPsdOW68pWwbzsmIjRM+cDpUdmIrH1k0zXiSux6Cub5lPY7c3U0FRM8JpZn5X1?= =?utf-8?q?8XxHnjYp12xi8lNvXCwdSSAJr9Y5kYWkV/oxzuxWQNKsg9bKC6zumShX9l8Gmfb0I?= =?utf-8?q?3P1XfOlVawneSJferbiLb+RWvDi6vHesT0mFIAlUfN7uFuK0VbTwzBHih6TXrKfcO?= =?utf-8?q?F47CMHZftb7EKdwllt+v6p8gMfhTQICtsjJB8tc3U089QXJs09aaOMWlcL8plr9Rp?= =?utf-8?q?hSG1L9Zt10k38B46T2+0yvRpBtpcV26xV6BHw6KcD1pTSc/iymkm4LCoCspTmmLR+?= =?utf-8?q?PJzj0nJLxM8tnEZjzxUjfmMpOfMd/cXKwrK4WuEvaIEL8A1DWrXY3PLRFw6FAT0Qo?= =?utf-8?q?IBeYVbsnaSTvRqloQqRr3DzBI88yF6WdteZ9kU20LtP2SU5GhUpHRRROsJRTjjEIo?= =?utf-8?q?J1ZhwaLCMT7URGotpKQa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lK8kjAXbjeUd1ZEy+7+k=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 1341ba47-dcaa-46a8-6d2e-08db515d9e5e X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 13:51:13.5063 (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: gk6bCu9Eg6kUDXfLVxMpOI3DMS7hq6bZnrnAZG2FprnsCIXwOgmFFrRG7HavRubFa+pF333LdAA/+u93A+ANEsrw/m7XsVCsaTLw2p+DVlI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10212 Precedence: bulk List-ID: X-Mailing-List: linux-input@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>; + }; + }; + }; + };