From nobody Sat May 11 06:11:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=kernkonzept.com ARC-Seal: i=1; a=rsa-sha256; t=1711112780; cv=none; d=zohomail.com; s=zohoarc; b=AUudfhwwghVy3rKnG8/M//Ck4q/It1vp5qh7eU4VkVqVOe6yBD07xJly25Kry9nO+2xlI+mKPuWBMkjmQQUCsOPNP+tciNZey6b9/0AUV0IzkdM6NEZhXUeO2hueMgmKgK1O7KNlhxqZXAqE/oOHwi75+P8emB23zj3tEJVjOtU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711112780; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uddgZXDiTzQQfpiNSJyLx5dFmvoi3NpsRnqm37BqGtk=; b=IBBILclCncF84oaRx4nXqczJZEsOB55cAWKsoOFfx84Iey7cjpUL46QnMgOefL2kz3ZixgUXqvN+zoEfT5+UK53fwCHp7+V0nJaSZkWDyJ6jIBD3pklqQpmM2uJnz9m3riWWvb92fANjTbPRFA16k29xoP3jLPzowsVdTqjt36A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711112780768874.8707296384206; Fri, 22 Mar 2024 06:06:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rneZm-0001fL-4s; Fri, 22 Mar 2024 09:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnc5V-0008Ni-DF for qemu-devel@nongnu.org; Fri, 22 Mar 2024 06:25:27 -0400 Received: from serv1.kernkonzept.com ([2a01:4f8:1c1c:b490::2] helo=mx.kernkonzept.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnc5S-0000Bh-CP for qemu-devel@nongnu.org; Fri, 22 Mar 2024 06:25:24 -0400 Received: from ip92349c68.dynamic.kabel-deutschland.de ([146.52.156.104] helo=iris.dd1.int.kernkonzept.com) by mx.kernkonzept.com with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) id 1rnc5J-007ZAZ-0I; Fri, 22 Mar 2024 11:25:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernkonzept.com; s=mx1; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:References:In-Reply-To: Reply-To:Content-ID:Content-Description; bh=uddgZXDiTzQQfpiNSJyLx5dFmvoi3NpsRnqm37BqGtk=; b=DtaDmNE8XeL/FuE43g8/HyOglQ ZD2B/44nck15qzEX/gACG8/ZOApjHs5LfcMDoKDViGV9+ZoARopmscgIUNmgRASXiEMRuyu5FoG2I dgs6rDmOZYHIWkW4aCalA5j2pDYDuxHgVyuSjLB67IFTiePu2Q/DifyRi5WbeZAGTqNp6YdnxV/9J rO3Qs8Y++JqciL6k8WYXuSoJFxF68w9enuwpWjT9fViGh9saEZUZA9WguW8DMODmUW+9Y/vqMljhd SP78aKjzebAfHDwbE+tQQgUP1s4COKCWsLrR7ZXAQoPhp5rqZIDor1r5K0x0k3VTD1bMPe2m/sXqL u5LpXEqA==; From: =?UTF-8?q?Christian=20P=C3=B6tzsch?= To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , "Michael S . Tsirkin" , =?UTF-8?q?Christian=20P=C3=B6tzsch?= Subject: [PATCH] Add support for abs info in vhost-user-input Date: Fri, 22 Mar 2024 11:24:21 +0100 Message-Id: <20240322102421.2158139-1-christian.poetzsch@kernkonzept.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:4f8:1c1c:b490::2; envelope-from=christian.poetzsch@kernkonzept.com; helo=mx.kernkonzept.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 22 Mar 2024 09:04:47 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @kernkonzept.com) X-ZM-MESSAGEID: 1711112782055100001 Absolute input device did not work, cause VIRTIO_INPUT_CFG_ABS_INFO is missing. Fetch this info when available and provide it to any virtio client. This is basically the same code as in hw/input/virtio-input-host.c, just modified to work here. Signed-off-by: Christian P=C3=B6tzsch --- contrib/vhost-user-input/main.c | 46 +++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/mai= n.c index 081230da54..9506e34d04 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -272,6 +272,32 @@ vi_bits_config(VuInput *vi, int type, int count) g_array_append_val(vi->config, bits); } =20 +static void +vi_input_abs_config(VuInput *vi, int axis) +{ + virtio_input_config config; + struct input_absinfo absinfo; + int rc; + + rc =3D ioctl(vi->evdevfd, EVIOCGABS(axis), &absinfo); + if (rc < 0) { + return; + } + + memset(&config, 0, sizeof(config)); + config.select =3D VIRTIO_INPUT_CFG_ABS_INFO; + config.subsel =3D axis; + config.size =3D sizeof(struct input_absinfo); + + config.u.abs.min =3D cpu_to_le32(absinfo.minimum); + config.u.abs.max =3D cpu_to_le32(absinfo.maximum); + config.u.abs.fuzz =3D cpu_to_le32(absinfo.fuzz); + config.u.abs.flat =3D cpu_to_le32(absinfo.flat); + config.u.abs.res =3D cpu_to_le32(absinfo.resolution); + + g_array_append_val(vi->config, config); +} + static char *opt_evdev; static int opt_fdnum =3D -1; static char *opt_socket_path; @@ -297,11 +323,12 @@ main(int argc, char *argv[]) { GMainLoop *loop =3D NULL; VuInput vi =3D { 0, }; - int rc, ver, fd; - virtio_input_config id; + int rc, ver, fd, i, axis; + virtio_input_config id, *abs; struct input_id ids; GError *error =3D NULL; GOptionContext *context; + uint8_t byte; =20 context =3D g_option_context_new(NULL); g_option_context_add_main_entries(context, entries, NULL); @@ -375,6 +402,21 @@ main(int argc, char *argv[]) vi_bits_config(&vi, EV_ABS, ABS_CNT); vi_bits_config(&vi, EV_MSC, MSC_CNT); vi_bits_config(&vi, EV_SW, SW_CNT); + + abs =3D vi_find_config(&vi, VIRTIO_INPUT_CFG_EV_BITS, EV_ABS); + if (abs) { + for (i =3D 0; i < abs->size; i++) { + byte =3D abs->u.bitmap[i]; + axis =3D 8 * i; + while (byte) { + if (byte & 1) { + vi_input_abs_config(&vi, axis); + } + axis++; + byte >>=3D 1; + } + } + } g_debug("config length: %u", vi.config->len); =20 if (opt_socket_path) { --=20 2.39.2