From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515704; cv=none; d=zohomail.com; s=zohoarc; b=G40FQT2bpPaNjFmfFnOihvTxLW8ROf1XE/eyFs1+dTYeWumw560Gv+t1lAa3iPk5Tkm/HKJEA91FepbDmCFYXdCR72rI/37eaumV5EB4qiLCiSw9Wfc8nB0OTcgGCSdM0deARiO6quvplKIjhnivbOIXoKRwg6m6GjJ+Z6bc5eU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515704; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YBjKviHSEEDUVkGToh+5MHl5RaBzVuGNPEEBbtTtyb8=; b=dMzBqW27rmJpO15RfMxoSHtwWjBh/AHEz/zhxeG6xj2+6FDDFTSwctGnWxFS9aYnwPe/x9GGziZTbNp9PoiTzQLjHxAUqUZEL8O+wmDJxfVQaUGC0aKTNrxVoIejpDgeFr5pdHOcZLpi0ehUahe3SVo9gMNk7UNwVXpn2pwDF5s= 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 1694515704511676.3166027518371; Tue, 12 Sep 2023 03:48:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vC-0002qU-4Z; Tue, 12 Sep 2023 06:47:06 -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 1qg0vA-0002pj-Po for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0v7-0003DW-4d for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:04 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-434-l2YvkKMePRidhqb4IONc8g-1; Tue, 12 Sep 2023 06:46:58 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D7DE8A0737 for ; Tue, 12 Sep 2023 10:46:56 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74B9B2026D68; Tue, 12 Sep 2023 10:46:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515620; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YBjKviHSEEDUVkGToh+5MHl5RaBzVuGNPEEBbtTtyb8=; b=Tf8QZNf8zhy/TA5QYvWtwDoaiA2TWqDCAdWA83yP8obVFv1a690G3BjsM1D2XkE0BjDcrp xI6NbWPsYo9o/S1d/wbQ2W6Cr9Egk09E13tMC0FkdawtOeCBuTju1NvuCIg8SfjOTfM+fS /zKjrugpZr35tzXxH7a1rMZf4V+8YsE= X-MC-Unique: l2YvkKMePRidhqb4IONc8g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Erico Nunes , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 01/14] docs: vhost-user-gpu: add protocol changes for dmabuf modifiers Date: Tue, 12 Sep 2023 14:46:35 +0400 Message-ID: <20230912104649.1638640-2-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515705426100003 From: Erico Nunes VHOST_USER_GPU_DMABUF_SCANOUT2 is defined as a message with all the contents of VHOST_USER_GPU_DMABUF_SCANOUT plus the dmabuf modifiers which were ommitted. The VHOST_USER_GPU_PROTOCOL_F_DMABUF2 protocol feature is defined as a way to check whether this new message is supported or not. Signed-off-by: Erico Nunes Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Sergio Lopez Message-Id: <20230714153900.475857-2-ernunes@redhat.com> --- docs/interop/vhost-user-gpu.rst | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/interop/vhost-user-gpu.rst b/docs/interop/vhost-user-gpu.= rst index b78806892d..3035822d05 100644 --- a/docs/interop/vhost-user-gpu.rst +++ b/docs/interop/vhost-user-gpu.rst @@ -134,6 +134,19 @@ VhostUserGpuEdidRequest :scanout-id: ``u32``, the scanout to get edid from =20 =20 +VhostUserGpuDMABUFScanout2 +^^^^^^^^^^^^^^^^^^^^^^^^^^ + ++----------------+----------+ +| dmabuf_scanout | modifier | ++----------------+----------+ + +:dmabuf_scanout: ``VhostUserGpuDMABUFScanout``, filled as described in the + VhostUserGpuDMABUFScanout structure. + +:modifier: ``u64``, the DMABUF modifiers + + C structure ----------- =20 @@ -163,7 +176,8 @@ Protocol features =20 .. code:: c =20 - #define VHOST_USER_GPU_PROTOCOL_F_EDID 0 + #define VHOST_USER_GPU_PROTOCOL_F_EDID 0 + #define VHOST_USER_GPU_PROTOCOL_F_DMABUF2 1 =20 New messages and communication changes are negotiated thanks to the ``VHOST_USER_GPU_GET_PROTOCOL_FEATURES`` and @@ -263,3 +277,13 @@ Message types Retrieve the EDID data for a given scanout. This message requires the ``VHOST_USER_GPU_PROTOCOL_F_EDID`` protocol feature to be supported. + +``VHOST_USER_GPU_DMABUF_SCANOUT2`` + :id: 12 + :request payload: ``VhostUserGpuDMABUFScanout2`` + :reply payload: N/A + + Same as VHOST_USER_GPU_DMABUF_SCANOUT, but also sends the dmabuf modifie= rs + appended to the message, which were not provided in the other message. + This message requires the ``VHOST_USER_GPU_PROTOCOL_F_DMABUF2`` protocol + feature to be supported. --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515680; cv=none; d=zohomail.com; s=zohoarc; b=b4rSX7GFlGybrVjgHB3iuNZakewALDRXARt3xqDGsVrf8mq4nbb91jjLAugk2m2K7RVMDrGDwGopWNe7O/iwM4ac3BW2XO6z6xIhAL3RGTl08LWgQ9Sa0jgr2HAOn6CO0A+48N+K1R/c4YwyZeN4a2+X+RgmunxBrno21CPLdbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515680; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j0EHmtHt1Xn9fl2jW6TVrxoYeM5hV+CcFMmy9zENXco=; b=l0RTo9RmrbB6f+bE77QEVL0G7HtM6I3vW5v4f5RQgxfseqGfNKYNwbi4AUflUBGw2Z7/fT0iCOLUWdxFkHPt6pjFWW3HrpKGK2JuFxf6dGAK1GXOhNt5ncsfMYgUs27VZsKaJL13WZOsmYWScLNRuayzuPjbXx3UP1c3gZ/741c= 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 1694515680842818.7741562281125; Tue, 12 Sep 2023 03:48:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vD-0002qi-N2; Tue, 12 Sep 2023 06:47:07 -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 1qg0vC-0002qV-6c for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0v9-0003Dl-PW for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:05 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-194-9r5gN00EO2WwsTMkQHEsFw-1; Tue, 12 Sep 2023 06:47:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D7761C18C79 for ; Tue, 12 Sep 2023 10:47:00 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FD9C64687; Tue, 12 Sep 2023 10:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515622; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j0EHmtHt1Xn9fl2jW6TVrxoYeM5hV+CcFMmy9zENXco=; b=X/2kQ3OhzwX8CuixOMGwqoaj4mqay/a6c4aGue6rQ75G83cMV1tVCWtQn6EWtCWYphbtiH 7CakPQkXaRBfl9DpbAp/cEZotyMIrYo33S5ii6yc80FopIzcqP0TbDTmZPnDUBE8NX0D0o Jej/mWxqtTBI+kPW4atp9TYwsLYF62o= X-MC-Unique: 9r5gN00EO2WwsTMkQHEsFw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Erico Nunes , "Michael S. Tsirkin" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 02/14] contrib/vhost-user-gpu: add support for sending dmabuf modifiers Date: Tue, 12 Sep 2023 14:46:36 +0400 Message-ID: <20230912104649.1638640-3-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515682627100009 From: Erico Nunes virglrenderer recently added virgl_renderer_resource_get_info_ext as a new api, which gets resource information, including dmabuf modifiers. We have to support dmabuf modifiers since the driver may choose to allocate buffers with these modifiers for efficiency, and importing buffers without modifiers information may result in completely broken rendering. Signed-off-by: Erico Nunes Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Sergio Lopez Message-Id: <20230714153900.475857-3-ernunes@redhat.com> --- contrib/vhost-user-gpu/vugpu.h | 9 +++++ contrib/vhost-user-gpu/vhost-user-gpu.c | 5 ++- contrib/vhost-user-gpu/virgl.c | 51 +++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/contrib/vhost-user-gpu/vugpu.h b/contrib/vhost-user-gpu/vugpu.h index f0f2069c47..509b679f03 100644 --- a/contrib/vhost-user-gpu/vugpu.h +++ b/contrib/vhost-user-gpu/vugpu.h @@ -37,6 +37,7 @@ typedef enum VhostUserGpuRequest { VHOST_USER_GPU_DMABUF_SCANOUT, VHOST_USER_GPU_DMABUF_UPDATE, VHOST_USER_GPU_GET_EDID, + VHOST_USER_GPU_DMABUF_SCANOUT2, } VhostUserGpuRequest; =20 typedef struct VhostUserGpuDisplayInfoReply { @@ -84,6 +85,11 @@ typedef struct VhostUserGpuDMABUFScanout { int fd_drm_fourcc; } QEMU_PACKED VhostUserGpuDMABUFScanout; =20 +typedef struct VhostUserGpuDMABUFScanout2 { + struct VhostUserGpuDMABUFScanout dmabuf_scanout; + uint64_t modifier; +} QEMU_PACKED VhostUserGpuDMABUFScanout2; + typedef struct VhostUserGpuEdidRequest { uint32_t scanout_id; } QEMU_PACKED VhostUserGpuEdidRequest; @@ -98,6 +104,7 @@ typedef struct VhostUserGpuMsg { VhostUserGpuScanout scanout; VhostUserGpuUpdate update; VhostUserGpuDMABUFScanout dmabuf_scanout; + VhostUserGpuDMABUFScanout2 dmabuf_scanout2; VhostUserGpuEdidRequest edid_req; struct virtio_gpu_resp_edid resp_edid; struct virtio_gpu_resp_display_info display_info; @@ -112,6 +119,7 @@ static VhostUserGpuMsg m __attribute__ ((unused)); #define VHOST_USER_GPU_MSG_FLAG_REPLY 0x4 =20 #define VHOST_USER_GPU_PROTOCOL_F_EDID 0 +#define VHOST_USER_GPU_PROTOCOL_F_DMABUF2 1 =20 struct virtio_gpu_scanout { uint32_t width, height; @@ -132,6 +140,7 @@ typedef struct VuGpu { bool virgl; bool virgl_inited; bool edid_inited; + bool use_modifiers; uint32_t inflight; =20 struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-g= pu/vhost-user-gpu.c index 2e7815a7a3..aa304475a0 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -1071,6 +1071,7 @@ static gboolean protocol_features_cb(gint fd, GIOCondition condition, gpointer user_data) { const uint64_t protocol_edid =3D (1 << VHOST_USER_GPU_PROTOCOL_F_EDID); + const uint64_t protocol_dmabuf2 =3D (1 << VHOST_USER_GPU_PROTOCOL_F_DM= ABUF2); VuGpu *g =3D user_data; uint64_t protocol_features; VhostUserGpuMsg msg =3D { @@ -1082,7 +1083,7 @@ protocol_features_cb(gint fd, GIOCondition condition,= gpointer user_data) return G_SOURCE_CONTINUE; } =20 - protocol_features &=3D protocol_edid; + protocol_features &=3D (protocol_edid | protocol_dmabuf2); =20 msg =3D (VhostUserGpuMsg) { .request =3D VHOST_USER_GPU_SET_PROTOCOL_FEATURES, @@ -1100,6 +1101,8 @@ protocol_features_cb(gint fd, GIOCondition condition,= gpointer user_data) exit(EXIT_FAILURE); } =20 + g->use_modifiers =3D !!(protocol_features & protocol_dmabuf2); + return G_SOURCE_REMOVE; } =20 diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 211aa110a9..1da6cc1588 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -318,6 +318,37 @@ virgl_resource_detach_backing(VuGpu *g, vg_cleanup_mapping_iov(g, res_iovs, num_iovs); } =20 +static int +virgl_get_resource_info_modifiers(uint32_t resource_id, + struct virgl_renderer_resource_info *inf= o, + uint64_t *modifiers) +{ + int ret; +#ifdef VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION + struct virgl_renderer_resource_info_ext info_ext; + ret =3D virgl_renderer_resource_get_info_ext(resource_id, &info_ext); + if (ret < 0) { + return ret; + } + + *info =3D info_ext.base; + *modifiers =3D info_ext.modifiers; +#else + ret =3D virgl_renderer_resource_get_info(resource_id, info); + if (ret < 0) { + return ret; + } + + /* + * Before virgl_renderer_resource_get_info_ext, + * getting the modifiers was not possible. + */ + *modifiers =3D 0; +#endif + + return 0; +} + static void virgl_cmd_set_scanout(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) @@ -338,7 +369,9 @@ virgl_cmd_set_scanout(VuGpu *g, memset(&info, 0, sizeof(info)); =20 if (ss.resource_id && ss.r.width && ss.r.height) { - ret =3D virgl_renderer_resource_get_info(ss.resource_id, &info); + uint64_t modifiers =3D 0; + ret =3D virgl_get_resource_info_modifiers(ss.resource_id, &info, + &modifiers); if (ret =3D=3D -1) { g_critical("%s: illegal resource specified %d\n", __func__, ss.resource_id); @@ -354,8 +387,6 @@ virgl_cmd_set_scanout(VuGpu *g, } assert(fd >=3D 0); VhostUserGpuMsg msg =3D { - .request =3D VHOST_USER_GPU_DMABUF_SCANOUT, - .size =3D sizeof(VhostUserGpuDMABUFScanout), .payload.dmabuf_scanout.scanout_id =3D ss.scanout_id, .payload.dmabuf_scanout.x =3D ss.r.x, .payload.dmabuf_scanout.y =3D ss.r.y, @@ -367,6 +398,20 @@ virgl_cmd_set_scanout(VuGpu *g, .payload.dmabuf_scanout.fd_flags =3D info.flags, .payload.dmabuf_scanout.fd_drm_fourcc =3D info.drm_fourcc }; + + if (g->use_modifiers) { + /* + * The mesage uses all the fields set in dmabuf_scanout plus + * modifiers which is appended after VhostUserGpuDMABUFScanout. + */ + msg.request =3D VHOST_USER_GPU_DMABUF_SCANOUT2; + msg.size =3D sizeof(VhostUserGpuDMABUFScanout2); + msg.payload.dmabuf_scanout2.modifier =3D modifiers; + } else { + msg.request =3D VHOST_USER_GPU_DMABUF_SCANOUT; + msg.size =3D sizeof(VhostUserGpuDMABUFScanout); + } + vg_send_msg(g, &msg, fd); close(fd); } else { --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515681; cv=none; d=zohomail.com; s=zohoarc; b=djnjsBENT9C6bf1ILwXE+VGYIvfT1W6j1iNjTzdy7ZAdcwkmj/o2667w7lt9srDhWgdRwmrAsFgUMYfPsG15uosWrZIMkhGl5RYvRh6+kr8Y5ibyxGR33wecJuI+0JZG6DBBdh5/83QosyQRSfwQggQKtx7EQPPxMSOg6Y5ztXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515681; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/2bxcIHBHpFaidbRkCTSYJN8Ogex1gp3OkpT+6Cmerk=; b=m7nJEnT79XJZLH1UNXqR0mx1zSpqOlBDnmPb4dIvGYlZElFAsyxHo2VTok/t1flxNKlJDoFUxqVvecR3FlRfU6zawQOyNNVoqcGI5iU2V03ascGskp3jWkj0fx6Wj/jWEoJ4VrYH/XS8oleBwiIaoNf7RXsZb0tvwzB6Y8o4daY= 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 1694515681860294.8902816376351; Tue, 12 Sep 2023 03:48:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vF-0002rL-NX; Tue, 12 Sep 2023 06:47:09 -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 1qg0vE-0002qo-BE for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vC-0003EL-1M for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-450-QGeoN68HPtmtzfv1lRWq3Q-1; Tue, 12 Sep 2023 06:47:04 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D07BD181A6E7 for ; Tue, 12 Sep 2023 10:47:03 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE50C2156722; Tue, 12 Sep 2023 10:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/2bxcIHBHpFaidbRkCTSYJN8Ogex1gp3OkpT+6Cmerk=; b=Ja1yYlPtB4TPjHdDzDW4kNAQCBHTjaTj/mazKYOEfsWPIyf+fpOvbK5pApeInHP3xyTONH Py+WQOt/TpnCQJ9QBbHVJBBsKfULzDIAMuLhOrwIQKyLeqdqc2hkIH9CYbsv/WOrfmy0qA bkN5XV8O7z59hyiG1rySdVf8QoOlJqQ= X-MC-Unique: QGeoN68HPtmtzfv1lRWq3Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Erico Nunes , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PULL 03/14] vhost-user-gpu: support dmabuf modifiers Date: Tue, 12 Sep 2023 14:46:37 +0400 Message-ID: <20230912104649.1638640-4-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515682642100014 From: Erico Nunes When the backend sends VHOST_USER_GPU_DMABUF_SCANOUT2, handle it by getting the modifiers information which is now available. Signed-off-by: Erico Nunes Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Sergio Lopez Message-Id: <20230714153900.475857-4-ernunes@redhat.com> --- hw/display/vhost-user-gpu.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index e8ee03094e..1150521d9d 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -32,6 +32,7 @@ typedef enum VhostUserGpuRequest { VHOST_USER_GPU_DMABUF_SCANOUT, VHOST_USER_GPU_DMABUF_UPDATE, VHOST_USER_GPU_GET_EDID, + VHOST_USER_GPU_DMABUF_SCANOUT2, } VhostUserGpuRequest; =20 typedef struct VhostUserGpuDisplayInfoReply { @@ -79,6 +80,11 @@ typedef struct VhostUserGpuDMABUFScanout { int fd_drm_fourcc; } QEMU_PACKED VhostUserGpuDMABUFScanout; =20 +typedef struct VhostUserGpuDMABUFScanout2 { + struct VhostUserGpuDMABUFScanout dmabuf_scanout; + uint64_t modifier; +} QEMU_PACKED VhostUserGpuDMABUFScanout2; + typedef struct VhostUserGpuEdidRequest { uint32_t scanout_id; } QEMU_PACKED VhostUserGpuEdidRequest; @@ -93,6 +99,7 @@ typedef struct VhostUserGpuMsg { VhostUserGpuScanout scanout; VhostUserGpuUpdate update; VhostUserGpuDMABUFScanout dmabuf_scanout; + VhostUserGpuDMABUFScanout2 dmabuf_scanout2; VhostUserGpuEdidRequest edid_req; struct virtio_gpu_resp_edid resp_edid; struct virtio_gpu_resp_display_info display_info; @@ -107,6 +114,7 @@ static VhostUserGpuMsg m __attribute__ ((unused)); #define VHOST_USER_GPU_MSG_FLAG_REPLY 0x4 =20 #define VHOST_USER_GPU_PROTOCOL_F_EDID 0 +#define VHOST_USER_GPU_PROTOCOL_F_DMABUF2 1 =20 static void vhost_user_gpu_update_blocked(VhostUserGPU *g, bool blocked); =20 @@ -171,7 +179,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) .flags =3D VHOST_USER_GPU_MSG_FLAG_REPLY, .size =3D sizeof(uint64_t), .payload =3D { - .u64 =3D (1 << VHOST_USER_GPU_PROTOCOL_F_EDID) + .u64 =3D (1 << VHOST_USER_GPU_PROTOCOL_F_EDID) | + (1 << VHOST_USER_GPU_PROTOCOL_F_DMABUF2) } }; =20 @@ -236,6 +245,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) =20 break; } + case VHOST_USER_GPU_DMABUF_SCANOUT2: case VHOST_USER_GPU_DMABUF_SCANOUT: { VhostUserGpuDMABUFScanout *m =3D &msg->payload.dmabuf_scanout; int fd =3D qemu_chr_fe_get_msgfd(&g->vhost_chr); @@ -269,6 +279,11 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUs= erGpuMsg *msg) .fourcc =3D m->fd_drm_fourcc, .y0_top =3D m->fd_flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, }; + if (msg->request =3D=3D VHOST_USER_GPU_DMABUF_SCANOUT2) { + VhostUserGpuDMABUFScanout2 *m2 =3D &msg->payload.dmabuf_scanou= t2; + dmabuf->modifier =3D m2->modifier; + } + dpy_gl_scanout_dmabuf(con, dmabuf); break; } --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515680; cv=none; d=zohomail.com; s=zohoarc; b=E+Yq9xPX5rFc0gITluh+zQTXWtBtQdtd1yTiLfU+XPhoO/+lkU2uzxEO3+Mbw694tdJq4TcMpbtfUb4L2OM1RwfQmuo76gexyUOZwiDZ2FAhWebfuUh8mBn6pi3T+FzOUaGwbb2wToHH5Cxy1mXVCI9fEhKIXXKEodsJdyITBjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515680; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3bOMOL54my+Z6wYAOPlQ8SoK9BwSXftLjsjq4KCtGRE=; b=YSq3XGJHF73NiZsSM0bg2tFce7jmfHZ1hOrY8Q8E76bM+abI7haZCagXdWDYzCQVUt5gwRUQA1ZWueVhGdIKdWYFnqJ71FVeuLuP2XBsgoEf3KqiswFMIn1O6A7mKjCTZE5pCFmE9Hiy8xrovt1WZaR7KOPrk3GYowRlcm+hqX0= 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 1694515680363852.7580138552661; Tue, 12 Sep 2023 03:48:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vM-0002uR-2c; Tue, 12 Sep 2023 06:47:16 -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 1qg0vL-0002uE-08 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vI-0003F0-PS for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:14 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-1jqcNwdQO_CVK0MumC4j4Q-1; Tue, 12 Sep 2023 06:47:08 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E9012A59541; Tue, 12 Sep 2023 10:47:07 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id A261E40C6EBF; Tue, 12 Sep 2023 10:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3bOMOL54my+Z6wYAOPlQ8SoK9BwSXftLjsjq4KCtGRE=; b=aIpS6svT+3/So/XhIGkyF2FfZUHzxGqxkQz3MFq3PEdkLtj9Ev1r3q+lPF8K6ocDgKtIzx AFSrIij1srhynaFO3PK3mTxh1M0XbajlYRxr8N7Q2qPuNCWjrco7pjIANekACcegkF50fU NoGXy4dOO8I9TFJAU1+U4bRYwutJHfc= X-MC-Unique: 1jqcNwdQO_CVK0MumC4j4Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum Subject: [PULL 04/14] vmmouse: replace DPRINTF with tracing Date: Tue, 12 Sep 2023 14:46:38 +0400 Message-ID: <20230912104649.1638640-5-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515680975100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/vmmouse.c | 29 ++++++++++++++--------------- hw/i386/trace-events | 10 ++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 6cd624bd09..99b84a3817 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -32,6 +32,8 @@ #include "cpu.h" #include "qom/object.h" =20 +#include "trace.h" + /* debug only vmmouse */ //#define DEBUG_VMMOUSE =20 @@ -50,12 +52,6 @@ #define VMMOUSE_RIGHT_BUTTON 0x10 #define VMMOUSE_MIDDLE_BUTTON 0x08 =20 -#ifdef DEBUG_VMMOUSE -#define DPRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) do { } while (0) -#endif - #define TYPE_VMMOUSE "vmmouse" OBJECT_DECLARE_SIMPLE_TYPE(VMMouseState, VMMOUSE) =20 @@ -93,7 +89,8 @@ static void vmmouse_set_data(const uint32_t *data) =20 static uint32_t vmmouse_get_status(VMMouseState *s) { - DPRINTF("vmmouse_get_status()\n"); + trace_vmmouse_get_status(); + return (s->status << 16) | s->nb_queue; } =20 @@ -105,8 +102,7 @@ static void vmmouse_mouse_event(void *opaque, int x, in= t y, int dz, int buttons_ if (s->nb_queue > (VMMOUSE_QUEUE_SIZE - 4)) return; =20 - DPRINTF("vmmouse_mouse_event(%d, %d, %d, %d)\n", - x, y, dz, buttons_state); + trace_vmmouse_mouse_event(x, y, dz, buttons_state); =20 if ((buttons_state & MOUSE_EVENT_LBUTTON)) buttons |=3D VMMOUSE_LEFT_BUTTON; @@ -160,7 +156,7 @@ static void vmmouse_update_handler(VMMouseState *s, int= absolute) =20 static void vmmouse_read_id(VMMouseState *s) { - DPRINTF("vmmouse_read_id()\n"); + trace_vmmouse_read_id(); =20 if (s->nb_queue =3D=3D VMMOUSE_QUEUE_SIZE) return; @@ -172,19 +168,22 @@ static void vmmouse_read_id(VMMouseState *s) =20 static void vmmouse_request_relative(VMMouseState *s) { - DPRINTF("vmmouse_request_relative()\n"); + trace_vmmouse_request_relative(); + vmmouse_update_handler(s, 0); } =20 static void vmmouse_request_absolute(VMMouseState *s) { - DPRINTF("vmmouse_request_absolute()\n"); + trace_vmmouse_request_absolute(); + vmmouse_update_handler(s, 1); } =20 static void vmmouse_disable(VMMouseState *s) { - DPRINTF("vmmouse_disable()\n"); + trace_vmmouse_disable(); + s->status =3D 0xffff; vmmouse_remove_handler(s); } @@ -193,7 +192,7 @@ static void vmmouse_data(VMMouseState *s, uint32_t *dat= a, uint32_t size) { int i; =20 - DPRINTF("vmmouse_data(%d)\n", size); + trace_vmmouse_data(size); =20 if (size =3D=3D 0 || size > 6 || size > s->nb_queue) { printf("vmmouse: driver requested too much data %d\n", size); @@ -293,7 +292,7 @@ static void vmmouse_realizefn(DeviceState *dev, Error *= *errp) { VMMouseState *s =3D VMMOUSE(dev); =20 - DPRINTF("vmmouse_init\n"); + trace_vmmouse_init(); =20 if (!s->i8042) { error_setg(errp, "'i8042' link is not set"); diff --git a/hw/i386/trace-events b/hw/i386/trace-events index 04fd71bfc4..53c02d7ac8 100644 --- a/hw/i386/trace-events +++ b/hw/i386/trace-events @@ -121,3 +121,13 @@ x86_pic_interrupt(int irqn, int level) "PIC interrupt = #%d level:%d" # port92.c port92_read(uint8_t val) "port92: read 0x%02x" port92_write(uint8_t val) "port92: write 0x%02x" + +# vmmouse.c +vmmouse_get_status(void) "" +vmmouse_mouse_event(int x, int y, int dz, int buttons_state) "event: x=3D%= d y=3D%d dz=3D%d state=3D%d" +vmmouse_init(void) "" +vmmouse_read_id(void) "" +vmmouse_request_relative(void) "" +vmmouse_request_absolute(void) "" +vmmouse_disable(void) "" +vmmouse_data(uint32_t size) "data: size=3D%" PRIu32 --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515681; cv=none; d=zohomail.com; s=zohoarc; b=TvqLhfs6881jfut8qN8Q8dvK8Fj+XiOqHLfMXuJRKloeSjQ57YoY13DR5tQOrEjfVmwfUJU56C2TVDKH8lNz6EJvSTIqn+qt+JGeGb7bh3OPDwJ2BvY3dBOtS4itLiudIeOi+aUHoqtGq1n6aHtM4v6WbJTuwpN7Af855UXcq3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515681; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QgS3eTib63Zw6/2oK2ixcCCkorBcweBKJxfOk3mLhrg=; b=ZXPm9jZh59KscQHSfO2oJ+Xba0ONqJwZQP6MjY5BFow73jXNsOslUkxg80FoDdXzwzxTgAeiETybMko1P7O8Ufg/jJXd4npokR2qAbqM6Pra9axouyId6PUAohciybFKrFtMlw+WvTGZ4EpBMPGKSaQkgrtv+UXD2u3AOETRnNs= 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 1694515681937740.1716367961137; Tue, 12 Sep 2023 03:48:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vN-0002ur-Qz; Tue, 12 Sep 2023 06:47:17 -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 1qg0vM-0002uT-FJ for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vJ-0003F7-7W for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:16 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-bYC_X8KyOAW0es5F3YTRbg-1; Tue, 12 Sep 2023 06:47:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5169933863; Tue, 12 Sep 2023 10:47:10 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1708B2156721; Tue, 12 Sep 2023 10:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QgS3eTib63Zw6/2oK2ixcCCkorBcweBKJxfOk3mLhrg=; b=KtsyuvgwEylyBm/vuEPe+HKOF2gz3XBFQLVYU5EHOGGATsisPFnTvPG/lYrPNpgZBJe4nX y1iTzi820ixAF1VS7Itg5IWt+VLS1JmJW1IahKSpZHueq9ND9yGAL9ek2XqQokDtdJYn1F exFu22HDSc9tVtTUY5t3mvdSZqg0X6E= X-MC-Unique: bYC_X8KyOAW0es5F3YTRbg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 05/14] vmmouse: use explicit code Date: Tue, 12 Sep 2023 14:46:39 +0400 Message-ID: <20230912104649.1638640-6-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515682628100010 From: Marc-Andr=C3=A9 Lureau It's weird to shift x & y without obvious reason. Let's make this more explicit and future-proof. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/vmmouse.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/i386/vmmouse.c b/hw/i386/vmmouse.c index 99b84a3817..91320afa2f 100644 --- a/hw/i386/vmmouse.c +++ b/hw/i386/vmmouse.c @@ -52,6 +52,11 @@ #define VMMOUSE_RIGHT_BUTTON 0x10 #define VMMOUSE_MIDDLE_BUTTON 0x08 =20 +#define VMMOUSE_MIN_X 0 +#define VMMOUSE_MIN_Y 0 +#define VMMOUSE_MAX_X 0xFFFF +#define VMMOUSE_MAX_Y 0xFFFF + #define TYPE_VMMOUSE "vmmouse" OBJECT_DECLARE_SIMPLE_TYPE(VMMouseState, VMMOUSE) =20 @@ -112,8 +117,12 @@ static void vmmouse_mouse_event(void *opaque, int x, i= nt y, int dz, int buttons_ buttons |=3D VMMOUSE_MIDDLE_BUTTON; =20 if (s->absolute) { - x <<=3D 1; - y <<=3D 1; + x =3D qemu_input_scale_axis(x, + INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX, + VMMOUSE_MIN_X, VMMOUSE_MAX_X); + y =3D qemu_input_scale_axis(y, + INPUT_EVENT_ABS_MIN, INPUT_EVENT_ABS_MAX, + VMMOUSE_MIN_Y, VMMOUSE_MAX_Y); } else{ /* add for guest vmmouse driver to judge this is a relative packet= . */ buttons |=3D VMMOUSE_RELATIVE_PACKET; --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515728; cv=none; d=zohomail.com; s=zohoarc; b=jbPsIp2sIAZx/GNqMH3xZEmoztEMoSafVH1Sx3yrbGhO8v2EBtgaBm5iONMaw8Yl/BI0bbkre1WhfZ5aXoMz6TN9KAZhxjqSVj7LkIsYBSWuWQl3Nq1ZoGu+qYMlokB09eteuMX5YC/H9Eze37n8UpNXZvXwYQ7w7SRQDay3BDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515728; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3tNCg7/131/j8UlDEUuGwpZGI6/ApHpk0SlrjN6YlNA=; b=eGqYn/ltL053HF37+jB396zMKpTwpMYq5AOaHj0nF4ImcfYQWMn09BHXw0WKKSVnjzl3dxeHStPzsAEpvlHgXvPtAcqSmhV3z4HhRAvWL9qNYDMpRkJFBVdLxh/jx0Lj85B5IOB0woWsDjjpOYFxeDzwDXjscu/Uc+nVWGnIlkQ= 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 1694515728911449.17546528474634; Tue, 12 Sep 2023 03:48:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vT-0002z7-LS; Tue, 12 Sep 2023 06:47:23 -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 1qg0vR-0002yR-OK for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vP-0003GD-Bs for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:21 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-78-VtAZmBDbM4uUX9hDBVDPbg-1; Tue, 12 Sep 2023 06:47:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B035E3814E87; Tue, 12 Sep 2023 10:47:14 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EC8E63F9D; Tue, 12 Sep 2023 10:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3tNCg7/131/j8UlDEUuGwpZGI6/ApHpk0SlrjN6YlNA=; b=ijA/c+AftlJPpRIhx3DnCsf2fdtuVHDWVjBzCSe9y6ji+wJRdYFTQuaBAiqlQSdZptJAVq tOCetoZcKjchjOY6Yd8BXocOMccPBrzQ+JtYfXGmESIshSI9s4ulQ5XISRPfSgbut5o4Vz 5hSPSjmVCGrvFBWbywLbQINFVLXKk4A= X-MC-Unique: VtAZmBDbM4uUX9hDBVDPbg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PULL 06/14] ui/vc: remove kbd_put_keysym() and update function calls Date: Tue, 12 Sep 2023 14:46:40 +0400 Message-ID: <20230912104649.1638640-7-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515730140100001 From: Marc-Andr=C3=A9 Lureau The function calls to `kbd_put_keysym` have been updated to now call `kbd_put_keysym_console` with a NULL console parameter. Like most console functions, NULL argument is now for the active console. This will allow to rename the text console functions in a consistent manner. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Akihiko Odaki --- include/ui/console.h | 1 - ui/console.c | 14 ++++++------ ui/curses.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 1ccd432b4d..9c362f0e87 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -115,7 +115,6 @@ bool qemu_mouse_set(int index, Error **errp); void kbd_put_keysym_console(QemuTextConsole *s, int keysym); bool kbd_put_qcode_console(QemuTextConsole *s, int qcode, bool ctrl); void kbd_put_string_console(QemuTextConsole *s, const char *str, int len); -void kbd_put_keysym(int keysym); =20 /* Touch devices */ typedef struct touch_slot { diff --git a/ui/console.c b/ui/console.c index e4d61794bb..4c07791ac7 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1141,6 +1141,13 @@ void kbd_put_keysym_console(QemuTextConsole *s, int = keysym) int c; uint32_t num_free; =20 + if (!s) { + if (!QEMU_IS_TEXT_CONSOLE(active_console)) { + return; + } + s =3D QEMU_TEXT_CONSOLE(active_console); + } + switch(keysym) { case QEMU_KEY_CTRL_UP: console_scroll(s, -1); @@ -1231,13 +1238,6 @@ void kbd_put_string_console(QemuTextConsole *s, cons= t char *str, int len) } } =20 -void kbd_put_keysym(int keysym) -{ - if (QEMU_IS_TEXT_CONSOLE(active_console)) { - kbd_put_keysym_console(QEMU_TEXT_CONSOLE(active_console), keysym); - } -} - static void text_console_invalidate(void *opaque) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); diff --git a/ui/curses.c b/ui/curses.c index de962faa7c..4ddbbae7cd 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keysym =3D=3D -1) keysym =3D chr; =20 - kbd_put_keysym(keysym); + kbd_put_keysym_console(NULL, keysym); } } } diff --git a/ui/vnc.c b/ui/vnc.c index 92964dcc0c..1fa4456744 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1945,88 +1945,88 @@ static void do_key_event(VncState *vs, int down, in= t keycode, int sym) case 0xb8: /* Right ALT */ break; case 0xc8: - kbd_put_keysym(QEMU_KEY_UP); + kbd_put_keysym_console(NULL, QEMU_KEY_UP); break; case 0xd0: - kbd_put_keysym(QEMU_KEY_DOWN); + kbd_put_keysym_console(NULL, QEMU_KEY_DOWN); break; case 0xcb: - kbd_put_keysym(QEMU_KEY_LEFT); + kbd_put_keysym_console(NULL, QEMU_KEY_LEFT); break; case 0xcd: - kbd_put_keysym(QEMU_KEY_RIGHT); + kbd_put_keysym_console(NULL, QEMU_KEY_RIGHT); break; case 0xd3: - kbd_put_keysym(QEMU_KEY_DELETE); + kbd_put_keysym_console(NULL, QEMU_KEY_DELETE); break; case 0xc7: - kbd_put_keysym(QEMU_KEY_HOME); + kbd_put_keysym_console(NULL, QEMU_KEY_HOME); break; case 0xcf: - kbd_put_keysym(QEMU_KEY_END); + kbd_put_keysym_console(NULL, QEMU_KEY_END); break; case 0xc9: - kbd_put_keysym(QEMU_KEY_PAGEUP); + kbd_put_keysym_console(NULL, QEMU_KEY_PAGEUP); break; case 0xd1: - kbd_put_keysym(QEMU_KEY_PAGEDOWN); + kbd_put_keysym_console(NULL, QEMU_KEY_PAGEDOWN); break; =20 case 0x47: - kbd_put_keysym(numlock ? '7' : QEMU_KEY_HOME); + kbd_put_keysym_console(NULL, numlock ? '7' : QEMU_KEY_HOME= ); break; case 0x48: - kbd_put_keysym(numlock ? '8' : QEMU_KEY_UP); + kbd_put_keysym_console(NULL, numlock ? '8' : QEMU_KEY_UP); break; case 0x49: - kbd_put_keysym(numlock ? '9' : QEMU_KEY_PAGEUP); + kbd_put_keysym_console(NULL, numlock ? '9' : QEMU_KEY_PAGE= UP); break; case 0x4b: - kbd_put_keysym(numlock ? '4' : QEMU_KEY_LEFT); + kbd_put_keysym_console(NULL, numlock ? '4' : QEMU_KEY_LEFT= ); break; case 0x4c: - kbd_put_keysym('5'); + kbd_put_keysym_console(NULL, '5'); break; case 0x4d: - kbd_put_keysym(numlock ? '6' : QEMU_KEY_RIGHT); + kbd_put_keysym_console(NULL, numlock ? '6' : QEMU_KEY_RIGH= T); break; case 0x4f: - kbd_put_keysym(numlock ? '1' : QEMU_KEY_END); + kbd_put_keysym_console(NULL, numlock ? '1' : QEMU_KEY_END); break; case 0x50: - kbd_put_keysym(numlock ? '2' : QEMU_KEY_DOWN); + kbd_put_keysym_console(NULL, numlock ? '2' : QEMU_KEY_DOWN= ); break; case 0x51: - kbd_put_keysym(numlock ? '3' : QEMU_KEY_PAGEDOWN); + kbd_put_keysym_console(NULL, numlock ? '3' : QEMU_KEY_PAGE= DOWN); break; case 0x52: - kbd_put_keysym('0'); + kbd_put_keysym_console(NULL, '0'); break; case 0x53: - kbd_put_keysym(numlock ? '.' : QEMU_KEY_DELETE); + kbd_put_keysym_console(NULL, numlock ? '.' : QEMU_KEY_DELE= TE); break; =20 case 0xb5: - kbd_put_keysym('/'); + kbd_put_keysym_console(NULL, '/'); break; case 0x37: - kbd_put_keysym('*'); + kbd_put_keysym_console(NULL, '*'); break; case 0x4a: - kbd_put_keysym('-'); + kbd_put_keysym_console(NULL, '-'); break; case 0x4e: - kbd_put_keysym('+'); + kbd_put_keysym_console(NULL, '+'); break; case 0x9c: - kbd_put_keysym('\n'); + kbd_put_keysym_console(NULL, '\n'); break; =20 default: if (control) { - kbd_put_keysym(sym & 0x1f); + kbd_put_keysym_console(NULL, sym & 0x1f); } else { - kbd_put_keysym(sym); + kbd_put_keysym_console(NULL, sym); } break; } diff --git a/ui/cocoa.m b/ui/cocoa.m index 4d8989c4eb..90a89c5c8e 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } =20 if (keysym) { - kbd_put_keysym(keysym); + kbd_put_keysym_console(NULL, keysym); } } =20 --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515710; cv=none; d=zohomail.com; s=zohoarc; b=fw7J8mzfi+YxfYo1s/pJy0Mj9D4t/kgeb6DPIVGs8AAJIXqhjhzo0RtYWPPijVTnnqWjkqzIeCGAdLxQOPzUWPnK6jorLwTk8c64bHyVsQ/4fOj+kxf4PAXm5FwRBms0yvenI3SwUzcKfvKs/Yu0lbYitpJqdYvBSkCxCHvBSi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515710; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FGSX3VSTfowEWnReKm2v86qri4x0T7v1nFRl0NaKYuU=; b=fgoHPYHeJc54smTruZ5hNyWiHSPFlewOPiXj0c9o/csEXFe858RClo0bF7b9h7eh7sj+CnEHiur9YLmtMmPt+5D51ZW/MR7qGjqrfhM3HHrd+bpPVVJ7L43xSWVbJZ+BaiZMEGoXlH+rLPSW6LiapgwtIbkPa5ABYhIoQKomulM= 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 1694515710348618.1477616004381; Tue, 12 Sep 2023 03:48:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vV-0002zH-2C; Tue, 12 Sep 2023 06:47:25 -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 1qg0vU-0002z9-0e for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vR-0003GQ-Ed for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-139-H0sTwx0KNgeJ9t4YfJ1skg-1; Tue, 12 Sep 2023 06:47:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C206933862; Tue, 12 Sep 2023 10:47:18 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7753E40C6EBF; Tue, 12 Sep 2023 10:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FGSX3VSTfowEWnReKm2v86qri4x0T7v1nFRl0NaKYuU=; b=SkV49VgI7L2xZwtPcL++wjDD95kh4HDZs3TBSqQcjdJw3AMRojN5IT3z4G5ZsSaAheNSdJ BcXGx+8uvPdIsnMkRPDnZieW+PtiyOLvG7dgqGPHpIehdAKv4iTvWgNSLLZVyMylP2yl4f cbyIVihSYjTD2LTunzo19VW3xOTVvBk= X-MC-Unique: H0sTwx0KNgeJ9t4YfJ1skg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PULL 07/14] ui/vc: rename kbd_put to qemu_text_console functions Date: Tue, 12 Sep 2023 14:46:41 +0400 Message-ID: <20230912104649.1638640-8-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515711925100003 From: Marc-Andr=C3=A9 Lureau They are QemuTextConsole functions, let's make it clear. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/console.h | 6 ++--- ui/console.c | 10 ++++---- ui/curses.c | 2 +- ui/gtk.c | 6 ++--- ui/sdl2-input.c | 4 ++-- ui/sdl2.c | 2 +- ui/vnc.c | 54 ++++++++++++++++++++++---------------------- ui/cocoa.m | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 9c362f0e87..26d63d17a2 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -112,9 +112,9 @@ bool qemu_mouse_set(int index, Error **errp); #define QEMU_KEY_CTRL_PAGEUP 0xe406 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407 =20 -void kbd_put_keysym_console(QemuTextConsole *s, int keysym); -bool kbd_put_qcode_console(QemuTextConsole *s, int qcode, bool ctrl); -void kbd_put_string_console(QemuTextConsole *s, const char *str, int len); +void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym); +bool qemu_text_console_put_qcode(QemuTextConsole *s, int qcode, bool ctrl); +void qemu_text_console_put_string(QemuTextConsole *s, const char *str, int= len); =20 /* Touch devices */ typedef struct touch_slot { diff --git a/ui/console.c b/ui/console.c index 4c07791ac7..7c60fc7d18 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1135,7 +1135,7 @@ static void kbd_send_chars(QemuTextConsole *s) } =20 /* called when an ascii key is pressed */ -void kbd_put_keysym_console(QemuTextConsole *s, int keysym) +void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym) { uint8_t buf[16], *q; int c; @@ -1217,7 +1217,7 @@ static const int ctrl_qcode_to_keysym[Q_KEY_CODE__MAX= ] =3D { [Q_KEY_CODE_PGDN] =3D QEMU_KEY_CTRL_PAGEDOWN, }; =20 -bool kbd_put_qcode_console(QemuTextConsole *s, int qcode, bool ctrl) +bool qemu_text_console_put_qcode(QemuTextConsole *s, int qcode, bool ctrl) { int keysym; =20 @@ -1225,16 +1225,16 @@ bool kbd_put_qcode_console(QemuTextConsole *s, int = qcode, bool ctrl) if (keysym =3D=3D 0) { return false; } - kbd_put_keysym_console(s, keysym); + qemu_text_console_put_keysym(s, keysym); return true; } =20 -void kbd_put_string_console(QemuTextConsole *s, const char *str, int len) +void qemu_text_console_put_string(QemuTextConsole *s, const char *str, int= len) { int i; =20 for (i =3D 0; i < len && str[i]; i++) { - kbd_put_keysym_console(s, str[i]); + qemu_text_console_put_keysym(s, str[i]); } } =20 diff --git a/ui/curses.c b/ui/curses.c index 4ddbbae7cd..8bde8c5cf7 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -400,7 +400,7 @@ static void curses_refresh(DisplayChangeListener *dcl) if (keysym =3D=3D -1) keysym =3D chr; =20 - kbd_put_keysym_console(NULL, keysym); + qemu_text_console_put_keysym(NULL, keysym); } } } diff --git a/ui/gtk.c b/ui/gtk.c index a14d56168d..c05f9a3f83 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1190,12 +1190,12 @@ static gboolean gd_text_key_down(GtkWidget *widget, QemuTextConsole *con =3D QEMU_TEXT_CONSOLE(vc->gfx.dcl.con); =20 if (key->keyval =3D=3D GDK_KEY_Delete) { - kbd_put_qcode_console(con, Q_KEY_CODE_DELETE, false); + qemu_text_console_put_qcode(con, Q_KEY_CODE_DELETE, false); } else if (key->length) { - kbd_put_string_console(con, key->string, key->length); + qemu_text_console_put_string(con, key->string, key->length); } else { int qcode =3D gd_map_keycode(gd_get_keycode(key)); - kbd_put_qcode_console(con, qcode, false); + qemu_text_console_put_qcode(con, qcode, false); } return TRUE; } diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c index a318cc5867..b02a89ee7c 100644 --- a/ui/sdl2-input.c +++ b/ui/sdl2-input.c @@ -49,10 +49,10 @@ void sdl2_process_key(struct sdl2_console *scon, if (ev->type =3D=3D SDL_KEYDOWN) { switch (qcode) { case Q_KEY_CODE_RET: - kbd_put_keysym_console(s, '\n'); + qemu_text_console_put_keysym(s, '\n'); break; default: - kbd_put_qcode_console(s, qcode, ctrl); + qemu_text_console_put_qcode(s, qcode, ctrl); break; } } diff --git a/ui/sdl2.c b/ui/sdl2.c index dfa260a507..178cc054ab 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -484,7 +484,7 @@ static void handle_textinput(SDL_Event *ev) } =20 if (QEMU_IS_TEXT_CONSOLE(con)) { - kbd_put_string_console(QEMU_TEXT_CONSOLE(con), ev->text.text, strl= en(ev->text.text)); + qemu_text_console_put_string(QEMU_TEXT_CONSOLE(con), ev->text.text= , strlen(ev->text.text)); } } =20 diff --git a/ui/vnc.c b/ui/vnc.c index 1fa4456744..22894b7b1f 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1945,88 +1945,88 @@ static void do_key_event(VncState *vs, int down, in= t keycode, int sym) case 0xb8: /* Right ALT */ break; case 0xc8: - kbd_put_keysym_console(NULL, QEMU_KEY_UP); + qemu_text_console_put_keysym(NULL, QEMU_KEY_UP); break; case 0xd0: - kbd_put_keysym_console(NULL, QEMU_KEY_DOWN); + qemu_text_console_put_keysym(NULL, QEMU_KEY_DOWN); break; case 0xcb: - kbd_put_keysym_console(NULL, QEMU_KEY_LEFT); + qemu_text_console_put_keysym(NULL, QEMU_KEY_LEFT); break; case 0xcd: - kbd_put_keysym_console(NULL, QEMU_KEY_RIGHT); + qemu_text_console_put_keysym(NULL, QEMU_KEY_RIGHT); break; case 0xd3: - kbd_put_keysym_console(NULL, QEMU_KEY_DELETE); + qemu_text_console_put_keysym(NULL, QEMU_KEY_DELETE); break; case 0xc7: - kbd_put_keysym_console(NULL, QEMU_KEY_HOME); + qemu_text_console_put_keysym(NULL, QEMU_KEY_HOME); break; case 0xcf: - kbd_put_keysym_console(NULL, QEMU_KEY_END); + qemu_text_console_put_keysym(NULL, QEMU_KEY_END); break; case 0xc9: - kbd_put_keysym_console(NULL, QEMU_KEY_PAGEUP); + qemu_text_console_put_keysym(NULL, QEMU_KEY_PAGEUP); break; case 0xd1: - kbd_put_keysym_console(NULL, QEMU_KEY_PAGEDOWN); + qemu_text_console_put_keysym(NULL, QEMU_KEY_PAGEDOWN); break; =20 case 0x47: - kbd_put_keysym_console(NULL, numlock ? '7' : QEMU_KEY_HOME= ); + qemu_text_console_put_keysym(NULL, numlock ? '7' : QEMU_KE= Y_HOME); break; case 0x48: - kbd_put_keysym_console(NULL, numlock ? '8' : QEMU_KEY_UP); + qemu_text_console_put_keysym(NULL, numlock ? '8' : QEMU_KE= Y_UP); break; case 0x49: - kbd_put_keysym_console(NULL, numlock ? '9' : QEMU_KEY_PAGE= UP); + qemu_text_console_put_keysym(NULL, numlock ? '9' : QEMU_KE= Y_PAGEUP); break; case 0x4b: - kbd_put_keysym_console(NULL, numlock ? '4' : QEMU_KEY_LEFT= ); + qemu_text_console_put_keysym(NULL, numlock ? '4' : QEMU_KE= Y_LEFT); break; case 0x4c: - kbd_put_keysym_console(NULL, '5'); + qemu_text_console_put_keysym(NULL, '5'); break; case 0x4d: - kbd_put_keysym_console(NULL, numlock ? '6' : QEMU_KEY_RIGH= T); + qemu_text_console_put_keysym(NULL, numlock ? '6' : QEMU_KE= Y_RIGHT); break; case 0x4f: - kbd_put_keysym_console(NULL, numlock ? '1' : QEMU_KEY_END); + qemu_text_console_put_keysym(NULL, numlock ? '1' : QEMU_KE= Y_END); break; case 0x50: - kbd_put_keysym_console(NULL, numlock ? '2' : QEMU_KEY_DOWN= ); + qemu_text_console_put_keysym(NULL, numlock ? '2' : QEMU_KE= Y_DOWN); break; case 0x51: - kbd_put_keysym_console(NULL, numlock ? '3' : QEMU_KEY_PAGE= DOWN); + qemu_text_console_put_keysym(NULL, numlock ? '3' : QEMU_KE= Y_PAGEDOWN); break; case 0x52: - kbd_put_keysym_console(NULL, '0'); + qemu_text_console_put_keysym(NULL, '0'); break; case 0x53: - kbd_put_keysym_console(NULL, numlock ? '.' : QEMU_KEY_DELE= TE); + qemu_text_console_put_keysym(NULL, numlock ? '.' : QEMU_KE= Y_DELETE); break; =20 case 0xb5: - kbd_put_keysym_console(NULL, '/'); + qemu_text_console_put_keysym(NULL, '/'); break; case 0x37: - kbd_put_keysym_console(NULL, '*'); + qemu_text_console_put_keysym(NULL, '*'); break; case 0x4a: - kbd_put_keysym_console(NULL, '-'); + qemu_text_console_put_keysym(NULL, '-'); break; case 0x4e: - kbd_put_keysym_console(NULL, '+'); + qemu_text_console_put_keysym(NULL, '+'); break; case 0x9c: - kbd_put_keysym_console(NULL, '\n'); + qemu_text_console_put_keysym(NULL, '\n'); break; =20 default: if (control) { - kbd_put_keysym_console(NULL, sym & 0x1f); + qemu_text_console_put_keysym(NULL, sym & 0x1f); } else { - kbd_put_keysym_console(NULL, sym); + qemu_text_console_put_keysym(NULL, sym); } break; } diff --git a/ui/cocoa.m b/ui/cocoa.m index 90a89c5c8e..df6d13be38 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -784,7 +784,7 @@ - (void) handleMonitorInput:(NSEvent *)event } =20 if (keysym) { - kbd_put_keysym_console(NULL, keysym); + qemu_text_console_put_keysym(NULL, keysym); } } =20 --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515746; cv=none; d=zohomail.com; s=zohoarc; b=i8uH85dxEfYoTZfnsU/3oSBp0vLbdbubiBTt/agnSBaHvjyZ4eN7cPrZdCn8SGT63AkUQxNCersFyG75oKXPlZnE+rqt8FJh5tZhFa34ls9sTrBm858dg/Ziy2PKCxXgYvptCxbnmX2qqXwsvmNzJGmtZSk0ka38giAlYIN76Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515746; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4RHFQhWj/qbws01dq1YGH+JPZkqgaBC2OarH6ZVWsAQ=; b=DO6z4vfdb7wgBfVfD4NC30lEoUVJfyjcroEAmynGfcgDUPF0dj9n26bXX0Iqu9gDMKRvLqCx8klxcqJLMAn5KIwkL9RlAcr+5UU3z3cXVCgxTPDjPFpGmzOx2Wq2Qopp9KfYvPbZ28a+/aJ1NV5cxpM/nJxPF5vVjXQt0u7Ct1I= 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 1694515746462433.0650018479347; Tue, 12 Sep 2023 03:49:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0va-0003Oo-Du; Tue, 12 Sep 2023 06:47:30 -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 1qg0vZ-0003HN-8O for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vU-0003Go-Io for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-383-K-dv5w-dOuC558DoHWZOYQ-1; Tue, 12 Sep 2023 06:47:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E16B8019DC for ; Tue, 12 Sep 2023 10:47:22 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 215D721B2413; Tue, 12 Sep 2023 10:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4RHFQhWj/qbws01dq1YGH+JPZkqgaBC2OarH6ZVWsAQ=; b=fe/HJyWmxfDT6nqR8cLHhXqhBhopyKAmECb1JJ//bLSQv2QVYOcGm3Fz4BR556EDjhGYMW KJPLvOV51Oq3CQTiDDoee7pxMFUiJPDdMyjZNUmNnWbil7/PoYdsTvU6m7Q12wqOi8JuWH 5LDwGvLcjiZpzR1pNNApVZDfxDucz/0= X-MC-Unique: K-dv5w-dOuC558DoHWZOYQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 08/14] ui/console: remove redundant format field Date: Tue, 12 Sep 2023 14:46:42 +0400 Message-ID: <20230912104649.1638640-9-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515748694100003 From: Marc-Andr=C3=A9 Lureau It's already part of PIXMAN image. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/console.h | 15 +++++++-------- ui/console-gl.c | 2 +- ui/console.c | 4 +--- ui/gtk.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.c | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 26d63d17a2..93bb03a9e2 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -152,7 +152,6 @@ typedef struct ScanoutTexture { } ScanoutTexture; =20 typedef struct DisplaySurface { - pixman_format_code_t format; pixman_image_t *image; uint8_t flags; #ifdef CONFIG_OPENGL @@ -436,23 +435,23 @@ static inline int surface_height(DisplaySurface *s) return pixman_image_get_height(s->image); } =20 +static inline pixman_format_code_t surface_format(DisplaySurface *s) +{ + return pixman_image_get_format(s->image); +} + static inline int surface_bits_per_pixel(DisplaySurface *s) { - int bits =3D PIXMAN_FORMAT_BPP(s->format); + int bits =3D PIXMAN_FORMAT_BPP(surface_format(s)); return bits; } =20 static inline int surface_bytes_per_pixel(DisplaySurface *s) { - int bits =3D PIXMAN_FORMAT_BPP(s->format); + int bits =3D PIXMAN_FORMAT_BPP(surface_format(s)); return DIV_ROUND_UP(bits, 8); } =20 -static inline pixman_format_code_t surface_format(DisplaySurface *s) -{ - return s->format; -} - typedef uint32_t console_ch_t; =20 static inline void console_write_ch(console_ch_t *dest, uint32_t ch) diff --git a/ui/console-gl.c b/ui/console-gl.c index 8e3c9a3c8c..103b954017 100644 --- a/ui/console-gl.c +++ b/ui/console-gl.c @@ -53,7 +53,7 @@ void surface_gl_create_texture(QemuGLShader *gls, return; } =20 - switch (surface->format) { + switch (surface_format(surface)) { case PIXMAN_BE_b8g8r8x8: case PIXMAN_BE_b8g8r8a8: surface->glformat =3D GL_BGRA_EXT; diff --git a/ui/console.c b/ui/console.c index 7c60fc7d18..4ff9f8b6e7 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1493,8 +1493,7 @@ DisplaySurface *qemu_create_displaysurface_from(int w= idth, int height, DisplaySurface *surface =3D g_new0(DisplaySurface, 1); =20 trace_displaysurface_create_from(surface, width, height, format); - surface->format =3D format; - surface->image =3D pixman_image_create_bits(surface->format, + surface->image =3D pixman_image_create_bits(format, width, height, (void *)data, linesize); assert(surface->image !=3D NULL); @@ -1511,7 +1510,6 @@ DisplaySurface *qemu_create_displaysurface_pixman(pix= man_image_t *image) DisplaySurface *surface =3D g_new0(DisplaySurface, 1); =20 trace_displaysurface_create_pixman(surface); - surface->format =3D pixman_image_get_format(image); surface->image =3D pixman_image_ref(image); =20 return surface; diff --git a/ui/gtk.c b/ui/gtk.c index c05f9a3f83..e09f97a86b 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -514,7 +514,7 @@ static void gd_switch(DisplayChangeListener *dcl, } vc->gfx.ds =3D surface; =20 - if (surface->format =3D=3D PIXMAN_x8r8g8b8) { + if (surface_format(surface) =3D=3D PIXMAN_x8r8g8b8) { /* * PIXMAN_x8r8g8b8 =3D=3D CAIRO_FORMAT_RGB24 * diff --git a/ui/spice-display.c b/ui/spice-display.c index 0e2fbfb17c..5cc47bd668 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -437,7 +437,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, } if (ssd->ds) { ssd->surface =3D pixman_image_ref(ssd->ds->image); - ssd->mirror =3D qemu_pixman_mirror_create(ssd->ds->format, + ssd->mirror =3D qemu_pixman_mirror_create(surface_format(ssd->ds), ssd->ds->image); qemu_spice_create_host_primary(ssd); } diff --git a/ui/vnc.c b/ui/vnc.c index 22894b7b1f..6fd86996a5 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -833,7 +833,7 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, /* guest surface */ qemu_pixman_image_unref(vd->guest.fb); vd->guest.fb =3D pixman_image_ref(surface->image); - vd->guest.format =3D surface->format; + vd->guest.format =3D surface_format(surface); =20 =20 if (pageflip) { --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515716; cv=none; d=zohomail.com; s=zohoarc; b=iuaH42rwGE7n09rzD7oQHumr2yUEjiOgZW1hwU9Q5XAN43bd/EtwOgXAiJkgOOb9qPwL1k5CmI1E5XfXs4HfvbEqSdEdnZdk3fVqYZn5rqxIeVMoB996SqHVvxbtj0aZMsLbhUaIcoBxao4+gpia/R6I2LEuf/Sm3fedajpR/q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515716; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qa2jcaQfDlJDtXnaPen2+btiZcAuSAXw+JtO012REnw=; b=hmNbofpm2XezNaf20+i2WhU08mtkeQ1Ct+OMvTxK6hwFbnLIAnfQJzfStgKwxX3pqnIajXhpMQ9xTHISMSaM+GiQT3o1UR6reaLdaezG73TYK33Hw0hlk72DRN8K3vg7SoX9hruMw732yc63FGrOCBH9nf00W/ZiHfd1/E2Rbok= 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 1694515716633330.4988582541532; Tue, 12 Sep 2023 03:48:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vd-0003RG-84; Tue, 12 Sep 2023 06:47:33 -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 1qg0vb-0003QI-EP for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vY-0003HU-Nm for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:31 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-XTvo2so2PXCwWE7i8Ddbhw-1; Tue, 12 Sep 2023 06:47:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50C69101A529 for ; Tue, 12 Sep 2023 10:47:26 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C28340C2064; Tue, 12 Sep 2023 10:47:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Qa2jcaQfDlJDtXnaPen2+btiZcAuSAXw+JtO012REnw=; b=RlQX2ix+Il52sn/bsaJvxMStr1p87EqiOHhZFprhut4DRP/uTJND+BAA/2kk05hNgimsOy 0lft1AIMKNfRTRaUXa5tyTdLYO8TF6aYvm45T+4XkL4uPeMHl2I9KjhKIHdPMomwG0QjVx pufMwheu+C7XOZ6MyWOLBNwWStEIxwM= X-MC-Unique: XTvo2so2PXCwWE7i8Ddbhw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 09/14] ui/vc: preliminary QemuTextConsole changes before split Date: Tue, 12 Sep 2023 14:46:43 +0400 Message-ID: <20230912104649.1638640-10-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515717908100003 From: Marc-Andr=C3=A9 Lureau Those changes will help to split console.c unit in the following commit. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/console.c | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/ui/console.c b/ui/console.c index 4ff9f8b6e7..d9ac3717ff 100644 --- a/ui/console.c +++ b/ui/console.c @@ -174,7 +174,7 @@ static QEMUTimer *cursor_timer; =20 static void dpy_refresh(DisplayState *s); static DisplayState *get_alloc_displaystate(void); -static void text_console_update_cursor(void *opaque); +static void qemu_text_console_update_cursor(void *opaque); static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl); static bool console_compatible_with(QemuConsole *con, DisplayChangeListener *dcl, Error **er= rp); @@ -1065,6 +1065,13 @@ static void displaychangelistener_display_console(Di= splayChangeListener *dcl, } } =20 +static void +qemu_text_console_select(QemuTextConsole *c) +{ + dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height); + qemu_text_console_update_cursor(NULL); +} + void console_select(unsigned int index) { DisplayChangeListener *dcl; @@ -1084,8 +1091,7 @@ void console_select(unsigned int index) } =20 if (QEMU_IS_TEXT_CONSOLE(s)) { - dpy_text_resize(s, QEMU_TEXT_CONSOLE(s)->width, QEMU_TEXT_CONS= OLE(s)->height); - text_console_update_cursor(NULL); + qemu_text_console_select(QEMU_TEXT_CONSOLE(s)); } } } @@ -1135,19 +1141,12 @@ static void kbd_send_chars(QemuTextConsole *s) } =20 /* called when an ascii key is pressed */ -void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym) +static void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) { uint8_t buf[16], *q; int c; uint32_t num_free; =20 - if (!s) { - if (!QEMU_IS_TEXT_CONSOLE(active_console)) { - return; - } - s =3D QEMU_TEXT_CONSOLE(active_console); - } - switch(keysym) { case QEMU_KEY_CTRL_UP: console_scroll(s, -1); @@ -1192,6 +1191,18 @@ void qemu_text_console_put_keysym(QemuTextConsole *s= , int keysym) } } =20 +void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym) +{ + if (!s) { + if (!QEMU_IS_TEXT_CONSOLE(active_console)) { + return; + } + s =3D QEMU_TEXT_CONSOLE(active_console); + } + + qemu_text_console_handle_keysym(s, keysym); +} + static const int qcode_to_keysym[Q_KEY_CODE__MAX] =3D { [Q_KEY_CODE_UP] =3D QEMU_KEY_UP, [Q_KEY_CODE_DOWN] =3D QEMU_KEY_DOWN, @@ -1395,7 +1406,7 @@ qemu_text_console_class_init(ObjectClass *oc, void *d= ata) { if (!cursor_timer) { cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, - text_console_update_cursor, NULL); + qemu_text_console_update_cursor, NULL); } } =20 @@ -1701,7 +1712,7 @@ void register_displaychangelistener(DisplayChangeList= ener *dcl) if (QEMU_IS_GRAPHIC_CONSOLE(con)) { dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con)); } - text_console_update_cursor(NULL); + qemu_text_console_update_cursor(NULL); } =20 void update_displaychangelistener(DisplayChangeListener *dcl, @@ -2388,6 +2399,13 @@ bool qemu_console_is_multihead(DeviceState *dev) return false; } =20 + +static const char * +qemu_text_console_get_label(QemuTextConsole *c) +{ + return c->chr ? c->chr->label : NULL; +} + char *qemu_console_get_label(QemuConsole *con) { if (QEMU_IS_GRAPHIC_CONSOLE(con)) { @@ -2411,9 +2429,9 @@ char *qemu_console_get_label(QemuConsole *con) } return g_strdup("VGA"); } else if (QEMU_IS_TEXT_CONSOLE(con)) { - QemuTextConsole *c =3D QEMU_TEXT_CONSOLE(con); - if (c->chr && c->chr->label) { - return g_strdup(c->chr->label); + const char *label =3D qemu_text_console_get_label(QEMU_TEXT_CONSOL= E(con)); + if (label) { + return g_strdup(label); } } =20 @@ -2513,7 +2531,7 @@ int qemu_invalidate_text_consoles(void) return count; } =20 -static void text_console_update_cursor(void *opaque) +static void qemu_text_console_update_cursor(void *opaque) { cursor_visible_phase =3D !cursor_visible_phase; =20 --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515697; cv=none; d=zohomail.com; s=zohoarc; b=iTQEuV7GpW5StbGs4USV0Q9tlTFim6fSt5wcKNKtZTodlTlxjKFL8YKZ7RsORdyRi2HIMpEovHIvZUc1CKgG7TD34LzJ6W4ZNelTkf69p0+DUNAtKCjYMPlQMjjR0IFe8H/190ZezmOGYmEcFFsxwJxxvkwHxQcf2tGzgmB544E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515697; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=etjFkTda+TPc6OXFFHh2VnlfAWeRQge5EG+gbLcBw+M=; b=UmrqSRy+C4Zy5JYRcY2yrk1GJEsFeyocEymo6wRJcM2o1J6K9+uz+Fb35heDoSyR4Yreynxb4ztyjREYrA2wc2oHbJraritFKWDfFP+3XGUNjoO0HCeEm653+P8A3CMpcOARx8BnVJi7W0DzKZp7ViTL7fYNBkZ2f+8UOF7I/0E= 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 1694515697031474.0000626948505; Tue, 12 Sep 2023 03:48:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vk-0003uX-Ss; Tue, 12 Sep 2023 06:47:40 -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 1qg0vi-0003gE-LC for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vd-0003It-VE for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:38 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-8nR8KPayNgSrql5s1M7D_A-1; Tue, 12 Sep 2023 06:47:31 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC2F13806707 for ; Tue, 12 Sep 2023 10:47:31 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E74B10F1BE7; Tue, 12 Sep 2023 10:47:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=etjFkTda+TPc6OXFFHh2VnlfAWeRQge5EG+gbLcBw+M=; b=I67AwXGsmghPP/6twAsb4qsYG1N27JtsEkW+IqeT/r6Y2PZQPVnK0M0/Mw7YrCRmfkz2wE 9eO75dQ9nFcxJI6Ps5BFYdQTo2eF+SQ4ZqKLQiGTBb9yGu/g3yF35rJErbE7BoOD9goSNf g8FClBKGU28+q2aCEgvRjjCMR9GVB+c= X-MC-Unique: 8nR8KPayNgSrql5s1M7D_A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 10/14] ui/vc: split off the VC part from console.c Date: Tue, 12 Sep 2023 14:46:44 +0400 Message-ID: <20230912104649.1638640-11-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515699357100003 From: Marc-Andr=C3=A9 Lureau Move common declarations to console-priv.h, and add a new unit console-vc.c which will handle VC/chardev rendering, when pixman is available. (if necessary, the move could be done chunk by chunks) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- ui/console-priv.h | 43 ++ ui/console-vc.c | 1079 ++++++++++++++++++++++++++++++++++++++++++++ ui/console.c | 1096 +-------------------------------------------- ui/meson.build | 1 + 4 files changed, 1126 insertions(+), 1093 deletions(-) create mode 100644 ui/console-priv.h create mode 100644 ui/console-vc.c diff --git a/ui/console-priv.h b/ui/console-priv.h new file mode 100644 index 0000000000..88569ed2cc --- /dev/null +++ b/ui/console-priv.h @@ -0,0 +1,43 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * QEMU UI Console + */ +#ifndef CONSOLE_PRIV_H +#define CONSOLE_PRIV_H + +#include "ui/console.h" +#include "qemu/coroutine.h" +#include "qemu/timer.h" + +#include "vgafont.h" + +#define FONT_HEIGHT 16 +#define FONT_WIDTH 8 + +struct QemuConsole { + Object parent; + + int index; + DisplayState *ds; + DisplaySurface *surface; + DisplayScanout scanout; + int dcls; + DisplayGLCtx *gl; + int gl_block; + QEMUTimer *gl_unblock_timer; + int window_id; + QemuUIInfo ui_info; + QEMUTimer *ui_timer; + const GraphicHwOps *hw_ops; + void *hw; + CoQueue dump_queue; + + QTAILQ_ENTRY(QemuConsole) next; +}; + +void qemu_text_console_select(QemuTextConsole *c); +const char * qemu_text_console_get_label(QemuTextConsole *c); +void qemu_text_console_update_cursor(void); +void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym); + +#endif diff --git a/ui/console-vc.c b/ui/console-vc.c new file mode 100644 index 0000000000..9c13cc2981 --- /dev/null +++ b/ui/console-vc.c @@ -0,0 +1,1079 @@ +/* + * SPDX-License-Identifier: MIT + * QEMU VC + */ +#include "qemu/osdep.h" + +#include "chardev/char.h" +#include "qapi/error.h" +#include "qemu/fifo8.h" +#include "qemu/option.h" +#include "ui/console.h" + +#include "trace.h" +#include "console-priv.h" + +#define DEFAULT_BACKSCROLL 512 +#define CONSOLE_CURSOR_PERIOD 500 + +typedef struct TextAttributes { + uint8_t fgcol:4; + uint8_t bgcol:4; + uint8_t bold:1; + uint8_t uline:1; + uint8_t blink:1; + uint8_t invers:1; + uint8_t unvisible:1; +} TextAttributes; + +#define TEXT_ATTRIBUTES_DEFAULT ((TextAttributes) { \ + .fgcol =3D QEMU_COLOR_WHITE, \ + .bgcol =3D QEMU_COLOR_BLACK \ +}) + +typedef struct TextCell { + uint8_t ch; + TextAttributes t_attrib; +} TextCell; + +#define MAX_ESC_PARAMS 3 + +enum TTYState { + TTY_STATE_NORM, + TTY_STATE_ESC, + TTY_STATE_CSI, +}; + +typedef struct QemuTextConsole { + QemuConsole parent; + + int width; + int height; + int total_height; + int backscroll_height; + int x, y; + int y_displayed; + int y_base; + TextCell *cells; + int text_x[2], text_y[2], cursor_invalidate; + int echo; + + int update_x0; + int update_y0; + int update_x1; + int update_y1; + + Chardev *chr; + /* fifo for key pressed */ + Fifo8 out_fifo; +} QemuTextConsole; + +typedef QemuConsoleClass QemuTextConsoleClass; + +OBJECT_DEFINE_TYPE(QemuTextConsole, qemu_text_console, QEMU_TEXT_CONSOLE, = QEMU_CONSOLE) + +typedef struct QemuFixedTextConsole { + QemuTextConsole parent; +} QemuFixedTextConsole; + +typedef QemuTextConsoleClass QemuFixedTextConsoleClass; + +OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIX= ED_TEXT_CONSOLE, QEMU_TEXT_CONSOLE) + +struct VCChardev { + Chardev parent; + QemuTextConsole *console; + + enum TTYState state; + int esc_params[MAX_ESC_PARAMS]; + int nb_esc_params; + TextAttributes t_attrib; /* currently active text attributes */ + int x_saved, y_saved; +}; +typedef struct VCChardev VCChardev; + +static const pixman_color_t color_table_rgb[2][8] =3D { + { /* dark */ + [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, + [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xaa), /* = blue */ + [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0x00), /* = green */ + [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0xaa), /* = cyan */ + [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0x00), /* = red */ + [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0xaa), /* = magenta */ + [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0x00), /* = yellow */ + [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR_GRAY, + }, + { /* bright */ + [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, + [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xff), /* = blue */ + [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0x00), /* = green */ + [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0xff), /* = cyan */ + [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0x00), /* = red */ + [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0xff), /* = magenta */ + [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0x00), /* = yellow */ + [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0xff), /* = white */ + } +}; + +static bool cursor_visible_phase; +static QEMUTimer *cursor_timer; + +const char * +qemu_text_console_get_label(QemuTextConsole *c) +{ + return c->chr ? c->chr->label : NULL; +} + +static void qemu_console_fill_rect(QemuConsole *con, int posx, int posy, + int width, int height, pixman_color_t c= olor) +{ + DisplaySurface *surface =3D qemu_console_surface(con); + pixman_rectangle16_t rect =3D { + .x =3D posx, .y =3D posy, .width =3D width, .height =3D height + }; + + assert(surface); + pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface->image, + &color, 1, &rect); +} + +/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ +static void qemu_console_bitblt(QemuConsole *con, + int xs, int ys, int xd, int yd, int w, int= h) +{ + DisplaySurface *surface =3D qemu_console_surface(con); + + assert(surface); + pixman_image_composite(PIXMAN_OP_SRC, + surface->image, NULL, surface->image, + xs, ys, 0, 0, xd, yd, w, h); +} + +static void vga_putcharxy(QemuConsole *s, int x, int y, int ch, + TextAttributes *t_attrib) +{ + static pixman_image_t *glyphs[256]; + DisplaySurface *surface =3D qemu_console_surface(s); + pixman_color_t fgcol, bgcol; + + assert(surface); + if (t_attrib->invers) { + bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; + fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; + } else { + fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; + bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; + } + + if (!glyphs[ch]) { + glyphs[ch] =3D qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont= 16, ch); + } + qemu_pixman_glyph_render(glyphs[ch], surface->image, + &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT= ); +} + +static void invalidate_xy(QemuTextConsole *s, int x, int y) +{ + if (!qemu_console_is_visible(QEMU_CONSOLE(s))) { + return; + } + if (s->update_x0 > x * FONT_WIDTH) + s->update_x0 =3D x * FONT_WIDTH; + if (s->update_y0 > y * FONT_HEIGHT) + s->update_y0 =3D y * FONT_HEIGHT; + if (s->update_x1 < (x + 1) * FONT_WIDTH) + s->update_x1 =3D (x + 1) * FONT_WIDTH; + if (s->update_y1 < (y + 1) * FONT_HEIGHT) + s->update_y1 =3D (y + 1) * FONT_HEIGHT; +} + +static void console_show_cursor(QemuTextConsole *s, int show) +{ + TextCell *c; + int y, y1; + int x =3D s->x; + + s->cursor_invalidate =3D 1; + + if (x >=3D s->width) { + x =3D s->width - 1; + } + y1 =3D (s->y_base + s->y) % s->total_height; + y =3D y1 - s->y_displayed; + if (y < 0) { + y +=3D s->total_height; + } + if (y < s->height) { + c =3D &s->cells[y1 * s->width + x]; + if (show && cursor_visible_phase) { + TextAttributes t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + t_attrib.invers =3D !(t_attrib.invers); /* invert fg and bg */ + vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &t_attrib); + } else { + vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &(c->t_attrib)); + } + invalidate_xy(s, x, y); + } +} + +static void console_refresh(QemuTextConsole *s) +{ + DisplaySurface *surface =3D qemu_console_surface(QEMU_CONSOLE(s)); + TextCell *c; + int x, y, y1; + + assert(surface); + s->text_x[0] =3D 0; + s->text_y[0] =3D 0; + s->text_x[1] =3D s->width - 1; + s->text_y[1] =3D s->height - 1; + s->cursor_invalidate =3D 1; + + qemu_console_fill_rect(QEMU_CONSOLE(s), 0, 0, surface_width(surface), = surface_height(surface), + color_table_rgb[0][QEMU_COLOR_BLACK]); + y1 =3D s->y_displayed; + for (y =3D 0; y < s->height; y++) { + c =3D s->cells + y1 * s->width; + for (x =3D 0; x < s->width; x++) { + vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, + &(c->t_attrib)); + c++; + } + if (++y1 =3D=3D s->total_height) { + y1 =3D 0; + } + } + console_show_cursor(s, 1); + dpy_gfx_update(QEMU_CONSOLE(s), 0, 0, + surface_width(surface), surface_height(surface)); +} + +static void console_scroll(QemuTextConsole *s, int ydelta) +{ + int i, y1; + + if (ydelta > 0) { + for(i =3D 0; i < ydelta; i++) { + if (s->y_displayed =3D=3D s->y_base) + break; + if (++s->y_displayed =3D=3D s->total_height) + s->y_displayed =3D 0; + } + } else { + ydelta =3D -ydelta; + i =3D s->backscroll_height; + if (i > s->total_height - s->height) + i =3D s->total_height - s->height; + y1 =3D s->y_base - i; + if (y1 < 0) + y1 +=3D s->total_height; + for(i =3D 0; i < ydelta; i++) { + if (s->y_displayed =3D=3D y1) + break; + if (--s->y_displayed < 0) + s->y_displayed =3D s->total_height - 1; + } + } + console_refresh(s); +} + +static void kbd_send_chars(QemuTextConsole *s) +{ + uint32_t len, avail; + + len =3D qemu_chr_be_can_write(s->chr); + avail =3D fifo8_num_used(&s->out_fifo); + while (len > 0 && avail > 0) { + const uint8_t *buf; + uint32_t size; + + buf =3D fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size); + qemu_chr_be_write(s->chr, buf, size); + len =3D qemu_chr_be_can_write(s->chr); + avail -=3D size; + } +} + +/* called when an ascii key is pressed */ +void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) +{ + uint8_t buf[16], *q; + int c; + uint32_t num_free; + + switch(keysym) { + case QEMU_KEY_CTRL_UP: + console_scroll(s, -1); + break; + case QEMU_KEY_CTRL_DOWN: + console_scroll(s, 1); + break; + case QEMU_KEY_CTRL_PAGEUP: + console_scroll(s, -10); + break; + case QEMU_KEY_CTRL_PAGEDOWN: + console_scroll(s, 10); + break; + default: + /* convert the QEMU keysym to VT100 key string */ + q =3D buf; + if (keysym >=3D 0xe100 && keysym <=3D 0xe11f) { + *q++ =3D '\033'; + *q++ =3D '['; + c =3D keysym - 0xe100; + if (c >=3D 10) + *q++ =3D '0' + (c / 10); + *q++ =3D '0' + (c % 10); + *q++ =3D '~'; + } else if (keysym >=3D 0xe120 && keysym <=3D 0xe17f) { + *q++ =3D '\033'; + *q++ =3D '['; + *q++ =3D keysym & 0xff; + } else if (s->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n')) { + qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true); + *q++ =3D '\n'; + } else { + *q++ =3D keysym; + } + if (s->echo) { + qemu_chr_write(s->chr, buf, q - buf, true); + } + num_free =3D fifo8_num_free(&s->out_fifo); + fifo8_push_all(&s->out_fifo, buf, MIN(num_free, q - buf)); + kbd_send_chars(s); + break; + } +} + +static void text_console_update(void *opaque, console_ch_t *chardata) +{ + QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); + int i, j, src; + + if (s->text_x[0] <=3D s->text_x[1]) { + src =3D (s->y_base + s->text_y[0]) * s->width; + chardata +=3D s->text_y[0] * s->width; + for (i =3D s->text_y[0]; i <=3D s->text_y[1]; i ++) + for (j =3D 0; j < s->width; j++, src++) { + console_write_ch(chardata ++, + ATTR2CHTYPE(s->cells[src].ch, + s->cells[src].t_attrib.fgcol, + s->cells[src].t_attrib.bgcol, + s->cells[src].t_attrib.bold)); + } + dpy_text_update(QEMU_CONSOLE(s), s->text_x[0], s->text_y[0], + s->text_x[1] - s->text_x[0], i - s->text_y[0]); + s->text_x[0] =3D s->width; + s->text_y[0] =3D s->height; + s->text_x[1] =3D 0; + s->text_y[1] =3D 0; + } + if (s->cursor_invalidate) { + dpy_text_cursor(QEMU_CONSOLE(s), s->x, s->y); + s->cursor_invalidate =3D 0; + } +} + +static void text_console_resize(QemuTextConsole *t) +{ + QemuConsole *s =3D QEMU_CONSOLE(t); + TextCell *cells, *c, *c1; + int w1, x, y, last_width, w, h; + + assert(s->scanout.kind =3D=3D SCANOUT_SURFACE); + + w =3D surface_width(s->surface) / FONT_WIDTH; + h =3D surface_height(s->surface) / FONT_HEIGHT; + if (w =3D=3D t->width && h =3D=3D t->height) { + return; + } + + last_width =3D t->width; + t->width =3D w; + t->height =3D h; + + w1 =3D MIN(t->width, last_width); + + cells =3D g_new(TextCell, t->width * t->total_height + 1); + for (y =3D 0; y < t->total_height; y++) { + c =3D &cells[y * t->width]; + if (w1 > 0) { + c1 =3D &t->cells[y * last_width]; + for (x =3D 0; x < w1; x++) { + *c++ =3D *c1++; + } + } + for (x =3D w1; x < t->width; x++) { + c->ch =3D ' '; + c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + c++; + } + } + g_free(t->cells); + t->cells =3D cells; +} + +static void vc_put_lf(VCChardev *vc) +{ + QemuTextConsole *s =3D vc->console; + TextCell *c; + int x, y1; + + s->y++; + if (s->y >=3D s->height) { + s->y =3D s->height - 1; + + if (s->y_displayed =3D=3D s->y_base) { + if (++s->y_displayed =3D=3D s->total_height) + s->y_displayed =3D 0; + } + if (++s->y_base =3D=3D s->total_height) + s->y_base =3D 0; + if (s->backscroll_height < s->total_height) + s->backscroll_height++; + y1 =3D (s->y_base + s->height - 1) % s->total_height; + c =3D &s->cells[y1 * s->width]; + for(x =3D 0; x < s->width; x++) { + c->ch =3D ' '; + c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + c++; + } + if (s->y_displayed =3D=3D s->y_base) { + s->text_x[0] =3D 0; + s->text_y[0] =3D 0; + s->text_x[1] =3D s->width - 1; + s->text_y[1] =3D s->height - 1; + + qemu_console_bitblt(QEMU_CONSOLE(s), 0, FONT_HEIGHT, 0, 0, + s->width * FONT_WIDTH, + (s->height - 1) * FONT_HEIGHT); + qemu_console_fill_rect(QEMU_CONSOLE(s), 0, (s->height - 1) * F= ONT_HEIGHT, + s->width * FONT_WIDTH, FONT_HEIGHT, + color_table_rgb[0][TEXT_ATTRIBUTES_DEFA= ULT.bgcol]); + s->update_x0 =3D 0; + s->update_y0 =3D 0; + s->update_x1 =3D s->width * FONT_WIDTH; + s->update_y1 =3D s->height * FONT_HEIGHT; + } + } +} + +/* Set console attributes depending on the current escape codes. + * NOTE: I know this code is not very efficient (checking every color for = it + * self) but it is more readable and better maintainable. + */ +static void vc_handle_escape(VCChardev *vc) +{ + int i; + + for (i =3D 0; i < vc->nb_esc_params; i++) { + switch (vc->esc_params[i]) { + case 0: /* reset all console attributes to default */ + vc->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + break; + case 1: + vc->t_attrib.bold =3D 1; + break; + case 4: + vc->t_attrib.uline =3D 1; + break; + case 5: + vc->t_attrib.blink =3D 1; + break; + case 7: + vc->t_attrib.invers =3D 1; + break; + case 8: + vc->t_attrib.unvisible =3D 1; + break; + case 22: + vc->t_attrib.bold =3D 0; + break; + case 24: + vc->t_attrib.uline =3D 0; + break; + case 25: + vc->t_attrib.blink =3D 0; + break; + case 27: + vc->t_attrib.invers =3D 0; + break; + case 28: + vc->t_attrib.unvisible =3D 0; + break; + /* set foreground color */ + case 30: + vc->t_attrib.fgcol =3D QEMU_COLOR_BLACK; + break; + case 31: + vc->t_attrib.fgcol =3D QEMU_COLOR_RED; + break; + case 32: + vc->t_attrib.fgcol =3D QEMU_COLOR_GREEN; + break; + case 33: + vc->t_attrib.fgcol =3D QEMU_COLOR_YELLOW; + break; + case 34: + vc->t_attrib.fgcol =3D QEMU_COLOR_BLUE; + break; + case 35: + vc->t_attrib.fgcol =3D QEMU_COLOR_MAGENTA; + break; + case 36: + vc->t_attrib.fgcol =3D QEMU_COLOR_CYAN; + break; + case 37: + vc->t_attrib.fgcol =3D QEMU_COLOR_WHITE; + break; + /* set background color */ + case 40: + vc->t_attrib.bgcol =3D QEMU_COLOR_BLACK; + break; + case 41: + vc->t_attrib.bgcol =3D QEMU_COLOR_RED; + break; + case 42: + vc->t_attrib.bgcol =3D QEMU_COLOR_GREEN; + break; + case 43: + vc->t_attrib.bgcol =3D QEMU_COLOR_YELLOW; + break; + case 44: + vc->t_attrib.bgcol =3D QEMU_COLOR_BLUE; + break; + case 45: + vc->t_attrib.bgcol =3D QEMU_COLOR_MAGENTA; + break; + case 46: + vc->t_attrib.bgcol =3D QEMU_COLOR_CYAN; + break; + case 47: + vc->t_attrib.bgcol =3D QEMU_COLOR_WHITE; + break; + } + } +} + +static void vc_update_xy(VCChardev *vc, int x, int y) +{ + QemuTextConsole *s =3D vc->console; + TextCell *c; + int y1, y2; + + s->text_x[0] =3D MIN(s->text_x[0], x); + s->text_x[1] =3D MAX(s->text_x[1], x); + s->text_y[0] =3D MIN(s->text_y[0], y); + s->text_y[1] =3D MAX(s->text_y[1], y); + + y1 =3D (s->y_base + y) % s->total_height; + y2 =3D y1 - s->y_displayed; + if (y2 < 0) { + y2 +=3D s->total_height; + } + if (y2 < s->height) { + if (x >=3D s->width) { + x =3D s->width - 1; + } + c =3D &s->cells[y1 * s->width + x]; + vga_putcharxy(QEMU_CONSOLE(s), x, y2, c->ch, + &(c->t_attrib)); + invalidate_xy(s, x, y2); + } +} + +static void vc_clear_xy(VCChardev *vc, int x, int y) +{ + QemuTextConsole *s =3D vc->console; + int y1 =3D (s->y_base + y) % s->total_height; + if (x >=3D s->width) { + x =3D s->width - 1; + } + TextCell *c =3D &s->cells[y1 * s->width + x]; + c->ch =3D ' '; + c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + vc_update_xy(vc, x, y); +} + +static void vc_put_one(VCChardev *vc, int ch) +{ + QemuTextConsole *s =3D vc->console; + TextCell *c; + int y1; + if (s->x >=3D s->width) { + /* line wrap */ + s->x =3D 0; + vc_put_lf(vc); + } + y1 =3D (s->y_base + s->y) % s->total_height; + c =3D &s->cells[y1 * s->width + s->x]; + c->ch =3D ch; + c->t_attrib =3D vc->t_attrib; + vc_update_xy(vc, s->x, s->y); + s->x++; +} + +static void vc_respond_str(VCChardev *vc, const char *buf) +{ + while (*buf) { + vc_put_one(vc, *buf); + buf++; + } +} + +/* set cursor, checking bounds */ +static void vc_set_cursor(VCChardev *vc, int x, int y) +{ + QemuTextConsole *s =3D vc->console; + + if (x < 0) { + x =3D 0; + } + if (y < 0) { + y =3D 0; + } + if (y >=3D s->height) { + y =3D s->height - 1; + } + if (x >=3D s->width) { + x =3D s->width - 1; + } + + s->x =3D x; + s->y =3D y; +} + +static void vc_putchar(VCChardev *vc, int ch) +{ + QemuTextConsole *s =3D vc->console; + int i; + int x, y; + char response[40]; + + switch(vc->state) { + case TTY_STATE_NORM: + switch(ch) { + case '\r': /* carriage return */ + s->x =3D 0; + break; + case '\n': /* newline */ + vc_put_lf(vc); + break; + case '\b': /* backspace */ + if (s->x > 0) + s->x--; + break; + case '\t': /* tabspace */ + if (s->x + (8 - (s->x % 8)) > s->width) { + s->x =3D 0; + vc_put_lf(vc); + } else { + s->x =3D s->x + (8 - (s->x % 8)); + } + break; + case '\a': /* alert aka. bell */ + /* TODO: has to be implemented */ + break; + case 14: + /* SI (shift in), character set 0 (ignored) */ + break; + case 15: + /* SO (shift out), character set 1 (ignored) */ + break; + case 27: /* esc (introducing an escape sequence) */ + vc->state =3D TTY_STATE_ESC; + break; + default: + vc_put_one(vc, ch); + break; + } + break; + case TTY_STATE_ESC: /* check if it is a terminal escape sequence */ + if (ch =3D=3D '[') { + for(i=3D0;iesc_params[i] =3D 0; + vc->nb_esc_params =3D 0; + vc->state =3D TTY_STATE_CSI; + } else { + vc->state =3D TTY_STATE_NORM; + } + break; + case TTY_STATE_CSI: /* handle escape sequence parameters */ + if (ch >=3D '0' && ch <=3D '9') { + if (vc->nb_esc_params < MAX_ESC_PARAMS) { + int *param =3D &vc->esc_params[vc->nb_esc_params]; + int digit =3D (ch - '0'); + + *param =3D (*param <=3D (INT_MAX - digit) / 10) ? + *param * 10 + digit : INT_MAX; + } + } else { + if (vc->nb_esc_params < MAX_ESC_PARAMS) + vc->nb_esc_params++; + if (ch =3D=3D ';' || ch =3D=3D '?') { + break; + } + trace_console_putchar_csi(vc->esc_params[0], vc->esc_params[1], + ch, vc->nb_esc_params); + vc->state =3D TTY_STATE_NORM; + switch(ch) { + case 'A': + /* move cursor up */ + if (vc->esc_params[0] =3D=3D 0) { + vc->esc_params[0] =3D 1; + } + vc_set_cursor(vc, s->x, s->y - vc->esc_params[0]); + break; + case 'B': + /* move cursor down */ + if (vc->esc_params[0] =3D=3D 0) { + vc->esc_params[0] =3D 1; + } + vc_set_cursor(vc, s->x, s->y + vc->esc_params[0]); + break; + case 'C': + /* move cursor right */ + if (vc->esc_params[0] =3D=3D 0) { + vc->esc_params[0] =3D 1; + } + vc_set_cursor(vc, s->x + vc->esc_params[0], s->y); + break; + case 'D': + /* move cursor left */ + if (vc->esc_params[0] =3D=3D 0) { + vc->esc_params[0] =3D 1; + } + vc_set_cursor(vc, s->x - vc->esc_params[0], s->y); + break; + case 'G': + /* move cursor to column */ + vc_set_cursor(vc, vc->esc_params[0] - 1, s->y); + break; + case 'f': + case 'H': + /* move cursor to row, column */ + vc_set_cursor(vc, vc->esc_params[1] - 1, vc->esc_params[0]= - 1); + break; + case 'J': + switch (vc->esc_params[0]) { + case 0: + /* clear to end of screen */ + for (y =3D s->y; y < s->height; y++) { + for (x =3D 0; x < s->width; x++) { + if (y =3D=3D s->y && x < s->x) { + continue; + } + vc_clear_xy(vc, x, y); + } + } + break; + case 1: + /* clear from beginning of screen */ + for (y =3D 0; y <=3D s->y; y++) { + for (x =3D 0; x < s->width; x++) { + if (y =3D=3D s->y && x > s->x) { + break; + } + vc_clear_xy(vc, x, y); + } + } + break; + case 2: + /* clear entire screen */ + for (y =3D 0; y <=3D s->height; y++) { + for (x =3D 0; x < s->width; x++) { + vc_clear_xy(vc, x, y); + } + } + break; + } + break; + case 'K': + switch (vc->esc_params[0]) { + case 0: + /* clear to eol */ + for(x =3D s->x; x < s->width; x++) { + vc_clear_xy(vc, x, s->y); + } + break; + case 1: + /* clear from beginning of line */ + for (x =3D 0; x <=3D s->x && x < s->width; x++) { + vc_clear_xy(vc, x, s->y); + } + break; + case 2: + /* clear entire line */ + for(x =3D 0; x < s->width; x++) { + vc_clear_xy(vc, x, s->y); + } + break; + } + break; + case 'm': + vc_handle_escape(vc); + break; + case 'n': + switch (vc->esc_params[0]) { + case 5: + /* report console status (always succeed)*/ + vc_respond_str(vc, "\033[0n"); + break; + case 6: + /* report cursor position */ + sprintf(response, "\033[%d;%dR", + (s->y_base + s->y) % s->total_height + 1, + s->x + 1); + vc_respond_str(vc, response); + break; + } + break; + case 's': + /* save cursor position */ + vc->x_saved =3D s->x; + vc->y_saved =3D s->y; + break; + case 'u': + /* restore cursor position */ + s->x =3D vc->x_saved; + s->y =3D vc->y_saved; + break; + default: + trace_console_putchar_unhandled(ch); + break; + } + break; + } + } +} + +#define TYPE_CHARDEV_VC "chardev-vc" +DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV, + TYPE_CHARDEV_VC) + +static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) +{ + VCChardev *drv =3D VC_CHARDEV(chr); + QemuTextConsole *s =3D drv->console; + int i; + + s->update_x0 =3D s->width * FONT_WIDTH; + s->update_y0 =3D s->height * FONT_HEIGHT; + s->update_x1 =3D 0; + s->update_y1 =3D 0; + console_show_cursor(s, 0); + for(i =3D 0; i < len; i++) { + vc_putchar(drv, buf[i]); + } + console_show_cursor(s, 1); + if (s->update_x0 < s->update_x1) { + dpy_gfx_update(QEMU_CONSOLE(s), s->update_x0, s->update_y0, + s->update_x1 - s->update_x0, + s->update_y1 - s->update_y0); + } + return len; +} + +void qemu_text_console_update_cursor(void) +{ + cursor_visible_phase =3D !cursor_visible_phase; + + if (qemu_invalidate_text_consoles()) { + timer_mod(cursor_timer, + qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + CONSOLE_CURSOR_= PERIOD / 2); + } +} + +static void +cursor_timer_cb(void *opaque) +{ + qemu_text_console_update_cursor(); +} + +static void text_console_invalidate(void *opaque) +{ + QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); + + if (!QEMU_IS_FIXED_TEXT_CONSOLE(s)) { + text_console_resize(QEMU_TEXT_CONSOLE(s)); + } + console_refresh(s); +} + +static void +qemu_text_console_finalize(Object *obj) +{ +} + +static void +qemu_text_console_class_init(ObjectClass *oc, void *data) +{ + if (!cursor_timer) { + cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, cursor_timer_cb= , NULL); + } +} + +static const GraphicHwOps text_console_ops =3D { + .invalidate =3D text_console_invalidate, + .text_update =3D text_console_update, +}; + +static void +qemu_text_console_init(Object *obj) +{ + QemuTextConsole *c =3D QEMU_TEXT_CONSOLE(obj); + + fifo8_create(&c->out_fifo, 16); + c->total_height =3D DEFAULT_BACKSCROLL; + QEMU_CONSOLE(c)->hw_ops =3D &text_console_ops; + QEMU_CONSOLE(c)->hw =3D c; +} + +static void +qemu_fixed_text_console_finalize(Object *obj) +{ +} + +static void +qemu_fixed_text_console_class_init(ObjectClass *oc, void *data) +{ +} + +static void +qemu_fixed_text_console_init(Object *obj) +{ +} + +static void vc_chr_accept_input(Chardev *chr) +{ + VCChardev *drv =3D VC_CHARDEV(chr); + + kbd_send_chars(drv->console); +} + +static void vc_chr_set_echo(Chardev *chr, bool echo) +{ + VCChardev *drv =3D VC_CHARDEV(chr); + + drv->console->echo =3D echo; +} + +void qemu_text_console_select(QemuTextConsole *c) +{ + dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height); + qemu_text_console_update_cursor(); +} + +static void vc_chr_open(Chardev *chr, + ChardevBackend *backend, + bool *be_opened, + Error **errp) +{ + ChardevVC *vc =3D backend->u.vc.data; + VCChardev *drv =3D VC_CHARDEV(chr); + QemuTextConsole *s; + unsigned width =3D 0; + unsigned height =3D 0; + + if (vc->has_width) { + width =3D vc->width; + } else if (vc->has_cols) { + width =3D vc->cols * FONT_WIDTH; + } + + if (vc->has_height) { + height =3D vc->height; + } else if (vc->has_rows) { + height =3D vc->rows * FONT_HEIGHT; + } + + trace_console_txt_new(width, height); + if (width =3D=3D 0 || height =3D=3D 0) { + s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_TEXT_CONSOLE)); + width =3D qemu_console_get_width(NULL, 80 * FONT_WIDTH); + height =3D qemu_console_get_height(NULL, 24 * FONT_HEIGHT); + } else { + s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_FIXED_TEXT_CONSOLE)); + } + + dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(wi= dth, height)); + + s->chr =3D chr; + drv->console =3D s; + + /* set current text attributes to default */ + drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + text_console_resize(s); + + if (chr->label) { + char *msg; + + drv->t_attrib.bgcol =3D QEMU_COLOR_BLUE; + msg =3D g_strdup_printf("%s console\r\n", chr->label); + qemu_chr_write(chr, (uint8_t *)msg, strlen(msg), true); + g_free(msg); + drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + } + + *be_opened =3D true; +} + +static void vc_chr_parse(QemuOpts *opts, ChardevBackend *backend, Error **= errp) +{ + int val; + ChardevVC *vc; + + backend->type =3D CHARDEV_BACKEND_KIND_VC; + vc =3D backend->u.vc.data =3D g_new0(ChardevVC, 1); + qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc)); + + val =3D qemu_opt_get_number(opts, "width", 0); + if (val !=3D 0) { + vc->has_width =3D true; + vc->width =3D val; + } + + val =3D qemu_opt_get_number(opts, "height", 0); + if (val !=3D 0) { + vc->has_height =3D true; + vc->height =3D val; + } + + val =3D qemu_opt_get_number(opts, "cols", 0); + if (val !=3D 0) { + vc->has_cols =3D true; + vc->cols =3D val; + } + + val =3D qemu_opt_get_number(opts, "rows", 0); + if (val !=3D 0) { + vc->has_rows =3D true; + vc->rows =3D val; + } +} + +static void char_vc_class_init(ObjectClass *oc, void *data) +{ + ChardevClass *cc =3D CHARDEV_CLASS(oc); + + cc->parse =3D vc_chr_parse; + cc->open =3D vc_chr_open; + cc->chr_write =3D vc_chr_write; + cc->chr_accept_input =3D vc_chr_accept_input; + cc->chr_set_echo =3D vc_chr_set_echo; +} + +static const TypeInfo char_vc_type_info =3D { + .name =3D TYPE_CHARDEV_VC, + .parent =3D TYPE_CHARDEV, + .instance_size =3D sizeof(VCChardev), + .class_init =3D char_vc_class_init, +}; + +void qemu_console_early_init(void) +{ + /* set the default vc driver */ + if (!object_class_by_name(TYPE_CHARDEV_VC)) { + type_register(&char_vc_type_info); + } +} diff --git a/ui/console.c b/ui/console.c index d9ac3717ff..da341f08da 100644 --- a/ui/console.c +++ b/ui/console.c @@ -29,68 +29,16 @@ #include "qapi/qapi-commands-ui.h" #include "qapi/visitor.h" #include "qemu/coroutine.h" -#include "qemu/fifo8.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/option.h" -#include "qemu/timer.h" #include "chardev/char.h" #include "trace.h" #include "exec/memory.h" #include "qom/object.h" =20 -#define DEFAULT_BACKSCROLL 512 -#define CONSOLE_CURSOR_PERIOD 500 - -typedef struct TextAttributes { - uint8_t fgcol:4; - uint8_t bgcol:4; - uint8_t bold:1; - uint8_t uline:1; - uint8_t blink:1; - uint8_t invers:1; - uint8_t unvisible:1; -} TextAttributes; - -#define TEXT_ATTRIBUTES_DEFAULT ((TextAttributes) { \ - .fgcol =3D QEMU_COLOR_WHITE, \ - .bgcol =3D QEMU_COLOR_BLACK \ -}) - -typedef struct TextCell { - uint8_t ch; - TextAttributes t_attrib; -} TextCell; - -#define MAX_ESC_PARAMS 3 - -enum TTYState { - TTY_STATE_NORM, - TTY_STATE_ESC, - TTY_STATE_CSI, -}; - -struct QemuConsole { - Object parent; - - int index; - DisplayState *ds; - DisplaySurface *surface; - DisplayScanout scanout; - int dcls; - DisplayGLCtx *gl; - int gl_block; - QEMUTimer *gl_unblock_timer; - int window_id; - QemuUIInfo ui_info; - QEMUTimer *ui_timer; - const GraphicHwOps *hw_ops; - void *hw; - CoQueue dump_queue; - - QTAILQ_ENTRY(QemuConsole) next; -}; +#include "console-priv.h" =20 OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJEC= T) =20 @@ -108,54 +56,6 @@ typedef QemuConsoleClass QemuGraphicConsoleClass; =20 OBJECT_DEFINE_TYPE(QemuGraphicConsole, qemu_graphic_console, QEMU_GRAPHIC_= CONSOLE, QEMU_CONSOLE) =20 -typedef struct QemuTextConsole { - QemuConsole parent; - - int width; - int height; - int total_height; - int backscroll_height; - int x, y; - int y_displayed; - int y_base; - TextCell *cells; - int text_x[2], text_y[2], cursor_invalidate; - int echo; - - int update_x0; - int update_y0; - int update_x1; - int update_y1; - - Chardev *chr; - /* fifo for key pressed */ - Fifo8 out_fifo; -} QemuTextConsole; - -typedef QemuConsoleClass QemuTextConsoleClass; - -OBJECT_DEFINE_TYPE(QemuTextConsole, qemu_text_console, QEMU_TEXT_CONSOLE, = QEMU_CONSOLE) - -typedef struct QemuFixedTextConsole { - QemuTextConsole parent; -} QemuFixedTextConsole; - -typedef QemuTextConsoleClass QemuFixedTextConsoleClass; - -OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_text_console, QEMU_FIX= ED_TEXT_CONSOLE, QEMU_TEXT_CONSOLE) - -struct VCChardev { - Chardev parent; - QemuTextConsole *console; - - enum TTYState state; - int esc_params[MAX_ESC_PARAMS]; - int nb_esc_params; - TextAttributes t_attrib; /* currently active text attributes */ - int x_saved, y_saved; -}; -typedef struct VCChardev VCChardev; - struct DisplayState { QEMUTimer *gui_timer; uint64_t last_update; @@ -169,12 +69,9 @@ static DisplayState *display_state; static QemuConsole *active_console; static QTAILQ_HEAD(, QemuConsole) consoles =3D QTAILQ_HEAD_INITIALIZER(consoles); -static bool cursor_visible_phase; -static QEMUTimer *cursor_timer; =20 static void dpy_refresh(DisplayState *s); static DisplayState *get_alloc_displaystate(void); -static void qemu_text_console_update_cursor(void *opaque); static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl); static bool console_compatible_with(QemuConsole *con, DisplayChangeListener *dcl, Error **er= rp); @@ -330,663 +227,6 @@ void graphic_hw_text_update(QemuConsole *con, console= _ch_t *chardata) } } =20 -static void qemu_console_fill_rect(QemuConsole *con, int posx, int posy, - int width, int height, pixman_color_t c= olor) -{ - DisplaySurface *surface =3D qemu_console_surface(con); - pixman_rectangle16_t rect =3D { - .x =3D posx, .y =3D posy, .width =3D width, .height =3D height - }; - - assert(surface); - pixman_image_fill_rectangles(PIXMAN_OP_SRC, surface->image, - &color, 1, &rect); -} - -/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ -static void qemu_console_bitblt(QemuConsole *con, - int xs, int ys, int xd, int yd, int w, int= h) -{ - DisplaySurface *surface =3D qemu_console_surface(con); - - assert(surface); - pixman_image_composite(PIXMAN_OP_SRC, - surface->image, NULL, surface->image, - xs, ys, 0, 0, xd, yd, w, h); -} - -/***********************************************************/ -/* basic char display */ - -#define FONT_HEIGHT 16 -#define FONT_WIDTH 8 - -#include "vgafont.h" - -static const pixman_color_t color_table_rgb[2][8] =3D { - { /* dark */ - [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, - [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xaa), /* = blue */ - [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0x00), /* = green */ - [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0xaa), /* = cyan */ - [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0x00), /* = red */ - [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0xaa), /* = magenta */ - [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0x00), /* = yellow */ - [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR_GRAY, - }, - { /* bright */ - [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, - [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xff), /* = blue */ - [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0x00), /* = green */ - [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0xff), /* = cyan */ - [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0x00), /* = red */ - [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0xff), /* = magenta */ - [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0x00), /* = yellow */ - [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0xff), /* = white */ - } -}; - -static void vga_putcharxy(QemuConsole *s, int x, int y, int ch, - TextAttributes *t_attrib) -{ - static pixman_image_t *glyphs[256]; - DisplaySurface *surface =3D qemu_console_surface(s); - pixman_color_t fgcol, bgcol; - - assert(surface); - if (t_attrib->invers) { - bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; - fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; - } else { - fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; - bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; - } - - if (!glyphs[ch]) { - glyphs[ch] =3D qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont= 16, ch); - } - qemu_pixman_glyph_render(glyphs[ch], surface->image, - &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT= ); -} - -static void text_console_resize(QemuTextConsole *t) -{ - QemuConsole *s =3D QEMU_CONSOLE(t); - TextCell *cells, *c, *c1; - int w1, x, y, last_width, w, h; - - assert(s->scanout.kind =3D=3D SCANOUT_SURFACE); - - w =3D surface_width(s->surface) / FONT_WIDTH; - h =3D surface_height(s->surface) / FONT_HEIGHT; - if (w =3D=3D t->width && h =3D=3D t->height) { - return; - } - - last_width =3D t->width; - t->width =3D w; - t->height =3D h; - - w1 =3D MIN(t->width, last_width); - - cells =3D g_new(TextCell, t->width * t->total_height + 1); - for (y =3D 0; y < t->total_height; y++) { - c =3D &cells[y * t->width]; - if (w1 > 0) { - c1 =3D &t->cells[y * last_width]; - for (x =3D 0; x < w1; x++) { - *c++ =3D *c1++; - } - } - for (x =3D w1; x < t->width; x++) { - c->ch =3D ' '; - c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - c++; - } - } - g_free(t->cells); - t->cells =3D cells; -} - -static void invalidate_xy(QemuTextConsole *s, int x, int y) -{ - if (!qemu_console_is_visible(QEMU_CONSOLE(s))) { - return; - } - if (s->update_x0 > x * FONT_WIDTH) - s->update_x0 =3D x * FONT_WIDTH; - if (s->update_y0 > y * FONT_HEIGHT) - s->update_y0 =3D y * FONT_HEIGHT; - if (s->update_x1 < (x + 1) * FONT_WIDTH) - s->update_x1 =3D (x + 1) * FONT_WIDTH; - if (s->update_y1 < (y + 1) * FONT_HEIGHT) - s->update_y1 =3D (y + 1) * FONT_HEIGHT; -} - -static void vc_update_xy(VCChardev *vc, int x, int y) -{ - QemuTextConsole *s =3D vc->console; - TextCell *c; - int y1, y2; - - s->text_x[0] =3D MIN(s->text_x[0], x); - s->text_x[1] =3D MAX(s->text_x[1], x); - s->text_y[0] =3D MIN(s->text_y[0], y); - s->text_y[1] =3D MAX(s->text_y[1], y); - - y1 =3D (s->y_base + y) % s->total_height; - y2 =3D y1 - s->y_displayed; - if (y2 < 0) { - y2 +=3D s->total_height; - } - if (y2 < s->height) { - if (x >=3D s->width) { - x =3D s->width - 1; - } - c =3D &s->cells[y1 * s->width + x]; - vga_putcharxy(QEMU_CONSOLE(s), x, y2, c->ch, - &(c->t_attrib)); - invalidate_xy(s, x, y2); - } -} - -static void console_show_cursor(QemuTextConsole *s, int show) -{ - TextCell *c; - int y, y1; - int x =3D s->x; - - s->cursor_invalidate =3D 1; - - if (x >=3D s->width) { - x =3D s->width - 1; - } - y1 =3D (s->y_base + s->y) % s->total_height; - y =3D y1 - s->y_displayed; - if (y < 0) { - y +=3D s->total_height; - } - if (y < s->height) { - c =3D &s->cells[y1 * s->width + x]; - if (show && cursor_visible_phase) { - TextAttributes t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - t_attrib.invers =3D !(t_attrib.invers); /* invert fg and bg */ - vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &t_attrib); - } else { - vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, &(c->t_attrib)); - } - invalidate_xy(s, x, y); - } -} - -static void console_refresh(QemuTextConsole *s) -{ - DisplaySurface *surface =3D qemu_console_surface(QEMU_CONSOLE(s)); - TextCell *c; - int x, y, y1; - - assert(surface); - s->text_x[0] =3D 0; - s->text_y[0] =3D 0; - s->text_x[1] =3D s->width - 1; - s->text_y[1] =3D s->height - 1; - s->cursor_invalidate =3D 1; - - qemu_console_fill_rect(QEMU_CONSOLE(s), 0, 0, surface_width(surface), = surface_height(surface), - color_table_rgb[0][QEMU_COLOR_BLACK]); - y1 =3D s->y_displayed; - for (y =3D 0; y < s->height; y++) { - c =3D s->cells + y1 * s->width; - for (x =3D 0; x < s->width; x++) { - vga_putcharxy(QEMU_CONSOLE(s), x, y, c->ch, - &(c->t_attrib)); - c++; - } - if (++y1 =3D=3D s->total_height) { - y1 =3D 0; - } - } - console_show_cursor(s, 1); - dpy_gfx_update(QEMU_CONSOLE(s), 0, 0, - surface_width(surface), surface_height(surface)); -} - -static void console_scroll(QemuTextConsole *s, int ydelta) -{ - int i, y1; - - if (ydelta > 0) { - for(i =3D 0; i < ydelta; i++) { - if (s->y_displayed =3D=3D s->y_base) - break; - if (++s->y_displayed =3D=3D s->total_height) - s->y_displayed =3D 0; - } - } else { - ydelta =3D -ydelta; - i =3D s->backscroll_height; - if (i > s->total_height - s->height) - i =3D s->total_height - s->height; - y1 =3D s->y_base - i; - if (y1 < 0) - y1 +=3D s->total_height; - for(i =3D 0; i < ydelta; i++) { - if (s->y_displayed =3D=3D y1) - break; - if (--s->y_displayed < 0) - s->y_displayed =3D s->total_height - 1; - } - } - console_refresh(s); -} - -static void vc_put_lf(VCChardev *vc) -{ - QemuTextConsole *s =3D vc->console; - TextCell *c; - int x, y1; - - s->y++; - if (s->y >=3D s->height) { - s->y =3D s->height - 1; - - if (s->y_displayed =3D=3D s->y_base) { - if (++s->y_displayed =3D=3D s->total_height) - s->y_displayed =3D 0; - } - if (++s->y_base =3D=3D s->total_height) - s->y_base =3D 0; - if (s->backscroll_height < s->total_height) - s->backscroll_height++; - y1 =3D (s->y_base + s->height - 1) % s->total_height; - c =3D &s->cells[y1 * s->width]; - for(x =3D 0; x < s->width; x++) { - c->ch =3D ' '; - c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - c++; - } - if (s->y_displayed =3D=3D s->y_base) { - s->text_x[0] =3D 0; - s->text_y[0] =3D 0; - s->text_x[1] =3D s->width - 1; - s->text_y[1] =3D s->height - 1; - - qemu_console_bitblt(QEMU_CONSOLE(s), 0, FONT_HEIGHT, 0, 0, - s->width * FONT_WIDTH, - (s->height - 1) * FONT_HEIGHT); - qemu_console_fill_rect(QEMU_CONSOLE(s), 0, (s->height - 1) * F= ONT_HEIGHT, - s->width * FONT_WIDTH, FONT_HEIGHT, - color_table_rgb[0][TEXT_ATTRIBUTES_DEFA= ULT.bgcol]); - s->update_x0 =3D 0; - s->update_y0 =3D 0; - s->update_x1 =3D s->width * FONT_WIDTH; - s->update_y1 =3D s->height * FONT_HEIGHT; - } - } -} - -/* Set console attributes depending on the current escape codes. - * NOTE: I know this code is not very efficient (checking every color for = it - * self) but it is more readable and better maintainable. - */ -static void vc_handle_escape(VCChardev *vc) -{ - int i; - - for (i =3D 0; i < vc->nb_esc_params; i++) { - switch (vc->esc_params[i]) { - case 0: /* reset all console attributes to default */ - vc->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - break; - case 1: - vc->t_attrib.bold =3D 1; - break; - case 4: - vc->t_attrib.uline =3D 1; - break; - case 5: - vc->t_attrib.blink =3D 1; - break; - case 7: - vc->t_attrib.invers =3D 1; - break; - case 8: - vc->t_attrib.unvisible =3D 1; - break; - case 22: - vc->t_attrib.bold =3D 0; - break; - case 24: - vc->t_attrib.uline =3D 0; - break; - case 25: - vc->t_attrib.blink =3D 0; - break; - case 27: - vc->t_attrib.invers =3D 0; - break; - case 28: - vc->t_attrib.unvisible =3D 0; - break; - /* set foreground color */ - case 30: - vc->t_attrib.fgcol =3D QEMU_COLOR_BLACK; - break; - case 31: - vc->t_attrib.fgcol =3D QEMU_COLOR_RED; - break; - case 32: - vc->t_attrib.fgcol =3D QEMU_COLOR_GREEN; - break; - case 33: - vc->t_attrib.fgcol =3D QEMU_COLOR_YELLOW; - break; - case 34: - vc->t_attrib.fgcol =3D QEMU_COLOR_BLUE; - break; - case 35: - vc->t_attrib.fgcol =3D QEMU_COLOR_MAGENTA; - break; - case 36: - vc->t_attrib.fgcol =3D QEMU_COLOR_CYAN; - break; - case 37: - vc->t_attrib.fgcol =3D QEMU_COLOR_WHITE; - break; - /* set background color */ - case 40: - vc->t_attrib.bgcol =3D QEMU_COLOR_BLACK; - break; - case 41: - vc->t_attrib.bgcol =3D QEMU_COLOR_RED; - break; - case 42: - vc->t_attrib.bgcol =3D QEMU_COLOR_GREEN; - break; - case 43: - vc->t_attrib.bgcol =3D QEMU_COLOR_YELLOW; - break; - case 44: - vc->t_attrib.bgcol =3D QEMU_COLOR_BLUE; - break; - case 45: - vc->t_attrib.bgcol =3D QEMU_COLOR_MAGENTA; - break; - case 46: - vc->t_attrib.bgcol =3D QEMU_COLOR_CYAN; - break; - case 47: - vc->t_attrib.bgcol =3D QEMU_COLOR_WHITE; - break; - } - } -} - -static void vc_clear_xy(VCChardev *vc, int x, int y) -{ - QemuTextConsole *s =3D vc->console; - int y1 =3D (s->y_base + y) % s->total_height; - if (x >=3D s->width) { - x =3D s->width - 1; - } - TextCell *c =3D &s->cells[y1 * s->width + x]; - c->ch =3D ' '; - c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - vc_update_xy(vc, x, y); -} - -static void vc_put_one(VCChardev *vc, int ch) -{ - QemuTextConsole *s =3D vc->console; - TextCell *c; - int y1; - if (s->x >=3D s->width) { - /* line wrap */ - s->x =3D 0; - vc_put_lf(vc); - } - y1 =3D (s->y_base + s->y) % s->total_height; - c =3D &s->cells[y1 * s->width + s->x]; - c->ch =3D ch; - c->t_attrib =3D vc->t_attrib; - vc_update_xy(vc, s->x, s->y); - s->x++; -} - -static void vc_respond_str(VCChardev *vc, const char *buf) -{ - while (*buf) { - vc_put_one(vc, *buf); - buf++; - } -} - -/* set cursor, checking bounds */ -static void vc_set_cursor(VCChardev *vc, int x, int y) -{ - QemuTextConsole *s =3D vc->console; - - if (x < 0) { - x =3D 0; - } - if (y < 0) { - y =3D 0; - } - if (y >=3D s->height) { - y =3D s->height - 1; - } - if (x >=3D s->width) { - x =3D s->width - 1; - } - - s->x =3D x; - s->y =3D y; -} - -static void vc_putchar(VCChardev *vc, int ch) -{ - QemuTextConsole *s =3D vc->console; - int i; - int x, y; - char response[40]; - - switch(vc->state) { - case TTY_STATE_NORM: - switch(ch) { - case '\r': /* carriage return */ - s->x =3D 0; - break; - case '\n': /* newline */ - vc_put_lf(vc); - break; - case '\b': /* backspace */ - if (s->x > 0) - s->x--; - break; - case '\t': /* tabspace */ - if (s->x + (8 - (s->x % 8)) > s->width) { - s->x =3D 0; - vc_put_lf(vc); - } else { - s->x =3D s->x + (8 - (s->x % 8)); - } - break; - case '\a': /* alert aka. bell */ - /* TODO: has to be implemented */ - break; - case 14: - /* SI (shift in), character set 0 (ignored) */ - break; - case 15: - /* SO (shift out), character set 1 (ignored) */ - break; - case 27: /* esc (introducing an escape sequence) */ - vc->state =3D TTY_STATE_ESC; - break; - default: - vc_put_one(vc, ch); - break; - } - break; - case TTY_STATE_ESC: /* check if it is a terminal escape sequence */ - if (ch =3D=3D '[') { - for(i=3D0;iesc_params[i] =3D 0; - vc->nb_esc_params =3D 0; - vc->state =3D TTY_STATE_CSI; - } else { - vc->state =3D TTY_STATE_NORM; - } - break; - case TTY_STATE_CSI: /* handle escape sequence parameters */ - if (ch >=3D '0' && ch <=3D '9') { - if (vc->nb_esc_params < MAX_ESC_PARAMS) { - int *param =3D &vc->esc_params[vc->nb_esc_params]; - int digit =3D (ch - '0'); - - *param =3D (*param <=3D (INT_MAX - digit) / 10) ? - *param * 10 + digit : INT_MAX; - } - } else { - if (vc->nb_esc_params < MAX_ESC_PARAMS) - vc->nb_esc_params++; - if (ch =3D=3D ';' || ch =3D=3D '?') { - break; - } - trace_console_putchar_csi(vc->esc_params[0], vc->esc_params[1], - ch, vc->nb_esc_params); - vc->state =3D TTY_STATE_NORM; - switch(ch) { - case 'A': - /* move cursor up */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; - } - vc_set_cursor(vc, s->x, s->y - vc->esc_params[0]); - break; - case 'B': - /* move cursor down */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; - } - vc_set_cursor(vc, s->x, s->y + vc->esc_params[0]); - break; - case 'C': - /* move cursor right */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; - } - vc_set_cursor(vc, s->x + vc->esc_params[0], s->y); - break; - case 'D': - /* move cursor left */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; - } - vc_set_cursor(vc, s->x - vc->esc_params[0], s->y); - break; - case 'G': - /* move cursor to column */ - vc_set_cursor(vc, vc->esc_params[0] - 1, s->y); - break; - case 'f': - case 'H': - /* move cursor to row, column */ - vc_set_cursor(vc, vc->esc_params[1] - 1, vc->esc_params[0]= - 1); - break; - case 'J': - switch (vc->esc_params[0]) { - case 0: - /* clear to end of screen */ - for (y =3D s->y; y < s->height; y++) { - for (x =3D 0; x < s->width; x++) { - if (y =3D=3D s->y && x < s->x) { - continue; - } - vc_clear_xy(vc, x, y); - } - } - break; - case 1: - /* clear from beginning of screen */ - for (y =3D 0; y <=3D s->y; y++) { - for (x =3D 0; x < s->width; x++) { - if (y =3D=3D s->y && x > s->x) { - break; - } - vc_clear_xy(vc, x, y); - } - } - break; - case 2: - /* clear entire screen */ - for (y =3D 0; y <=3D s->height; y++) { - for (x =3D 0; x < s->width; x++) { - vc_clear_xy(vc, x, y); - } - } - break; - } - break; - case 'K': - switch (vc->esc_params[0]) { - case 0: - /* clear to eol */ - for(x =3D s->x; x < s->width; x++) { - vc_clear_xy(vc, x, s->y); - } - break; - case 1: - /* clear from beginning of line */ - for (x =3D 0; x <=3D s->x && x < s->width; x++) { - vc_clear_xy(vc, x, s->y); - } - break; - case 2: - /* clear entire line */ - for(x =3D 0; x < s->width; x++) { - vc_clear_xy(vc, x, s->y); - } - break; - } - break; - case 'm': - vc_handle_escape(vc); - break; - case 'n': - switch (vc->esc_params[0]) { - case 5: - /* report console status (always succeed)*/ - vc_respond_str(vc, "\033[0n"); - break; - case 6: - /* report cursor position */ - sprintf(response, "\033[%d;%dR", - (s->y_base + s->y) % s->total_height + 1, - s->x + 1); - vc_respond_str(vc, response); - break; - } - break; - case 's': - /* save cursor position */ - vc->x_saved =3D s->x; - vc->y_saved =3D s->y; - break; - case 'u': - /* restore cursor position */ - s->x =3D vc->x_saved; - s->y =3D vc->y_saved; - break; - default: - trace_console_putchar_unhandled(ch); - break; - } - break; - } - } -} - static void displaychangelistener_gfx_switch(DisplayChangeListener *dcl, struct DisplaySurface *new_su= rface, bool update) @@ -1065,13 +305,6 @@ static void displaychangelistener_display_console(Dis= playChangeListener *dcl, } } =20 -static void -qemu_text_console_select(QemuTextConsole *c) -{ - dpy_text_resize(QEMU_CONSOLE(c), c->width, c->height); - qemu_text_console_update_cursor(NULL); -} - void console_select(unsigned int index) { DisplayChangeListener *dcl; @@ -1096,101 +329,6 @@ void console_select(unsigned int index) } } =20 -#define TYPE_CHARDEV_VC "chardev-vc" -DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV, - TYPE_CHARDEV_VC) - -static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) -{ - VCChardev *drv =3D VC_CHARDEV(chr); - QemuTextConsole *s =3D drv->console; - int i; - - s->update_x0 =3D s->width * FONT_WIDTH; - s->update_y0 =3D s->height * FONT_HEIGHT; - s->update_x1 =3D 0; - s->update_y1 =3D 0; - console_show_cursor(s, 0); - for(i =3D 0; i < len; i++) { - vc_putchar(drv, buf[i]); - } - console_show_cursor(s, 1); - if (s->update_x0 < s->update_x1) { - dpy_gfx_update(QEMU_CONSOLE(s), s->update_x0, s->update_y0, - s->update_x1 - s->update_x0, - s->update_y1 - s->update_y0); - } - return len; -} - -static void kbd_send_chars(QemuTextConsole *s) -{ - uint32_t len, avail; - - len =3D qemu_chr_be_can_write(s->chr); - avail =3D fifo8_num_used(&s->out_fifo); - while (len > 0 && avail > 0) { - const uint8_t *buf; - uint32_t size; - - buf =3D fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size); - qemu_chr_be_write(s->chr, buf, size); - len =3D qemu_chr_be_can_write(s->chr); - avail -=3D size; - } -} - -/* called when an ascii key is pressed */ -static void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) -{ - uint8_t buf[16], *q; - int c; - uint32_t num_free; - - switch(keysym) { - case QEMU_KEY_CTRL_UP: - console_scroll(s, -1); - break; - case QEMU_KEY_CTRL_DOWN: - console_scroll(s, 1); - break; - case QEMU_KEY_CTRL_PAGEUP: - console_scroll(s, -10); - break; - case QEMU_KEY_CTRL_PAGEDOWN: - console_scroll(s, 10); - break; - default: - /* convert the QEMU keysym to VT100 key string */ - q =3D buf; - if (keysym >=3D 0xe100 && keysym <=3D 0xe11f) { - *q++ =3D '\033'; - *q++ =3D '['; - c =3D keysym - 0xe100; - if (c >=3D 10) - *q++ =3D '0' + (c / 10); - *q++ =3D '0' + (c % 10); - *q++ =3D '~'; - } else if (keysym >=3D 0xe120 && keysym <=3D 0xe17f) { - *q++ =3D '\033'; - *q++ =3D '['; - *q++ =3D keysym & 0xff; - } else if (s->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n')) { - qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true); - *q++ =3D '\n'; - } else { - *q++ =3D keysym; - } - if (s->echo) { - qemu_chr_write(s->chr, buf, q - buf, true); - } - num_free =3D fifo8_num_free(&s->out_fifo); - fifo8_push_all(&s->out_fifo, buf, MIN(num_free, q - buf)); - kbd_send_chars(s); - break; - } -} - void qemu_text_console_put_keysym(QemuTextConsole *s, int keysym) { if (!s) { @@ -1249,45 +387,6 @@ void qemu_text_console_put_string(QemuTextConsole *s,= const char *str, int len) } } =20 -static void text_console_invalidate(void *opaque) -{ - QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); - - if (!QEMU_IS_FIXED_TEXT_CONSOLE(s)) { - text_console_resize(QEMU_TEXT_CONSOLE(s)); - } - console_refresh(s); -} - -static void text_console_update(void *opaque, console_ch_t *chardata) -{ - QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); - int i, j, src; - - if (s->text_x[0] <=3D s->text_x[1]) { - src =3D (s->y_base + s->text_y[0]) * s->width; - chardata +=3D s->text_y[0] * s->width; - for (i =3D s->text_y[0]; i <=3D s->text_y[1]; i ++) - for (j =3D 0; j < s->width; j++, src++) { - console_write_ch(chardata ++, - ATTR2CHTYPE(s->cells[src].ch, - s->cells[src].t_attrib.fgcol, - s->cells[src].t_attrib.bgcol, - s->cells[src].t_attrib.bold)); - } - dpy_text_update(QEMU_CONSOLE(s), s->text_x[0], s->text_y[0], - s->text_x[1] - s->text_x[0], i - s->text_y[0]); - s->text_x[0] =3D s->width; - s->text_y[0] =3D s->height; - s->text_x[1] =3D 0; - s->text_y[1] =3D 0; - } - if (s->cursor_invalidate) { - dpy_text_cursor(QEMU_CONSOLE(s), s->x, s->y); - s->cursor_invalidate =3D 0; - } -} - static void qemu_console_register(QemuConsole *c) { @@ -1396,51 +495,6 @@ qemu_graphic_console_init(Object *obj) { } =20 -static void -qemu_text_console_finalize(Object *obj) -{ -} - -static void -qemu_text_console_class_init(ObjectClass *oc, void *data) -{ - if (!cursor_timer) { - cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, - qemu_text_console_update_cursor, NULL); - } -} - -static const GraphicHwOps text_console_ops =3D { - .invalidate =3D text_console_invalidate, - .text_update =3D text_console_update, -}; - -static void -qemu_text_console_init(Object *obj) -{ - QemuTextConsole *c =3D QEMU_TEXT_CONSOLE(obj); - - fifo8_create(&c->out_fifo, 16); - c->total_height =3D DEFAULT_BACKSCROLL; - QEMU_CONSOLE(c)->hw_ops =3D &text_console_ops; - QEMU_CONSOLE(c)->hw =3D c; -} - -static void -qemu_fixed_text_console_finalize(Object *obj) -{ -} - -static void -qemu_fixed_text_console_class_init(ObjectClass *oc, void *data) -{ -} - -static void -qemu_fixed_text_console_init(Object *obj) -{ -} - #ifdef WIN32 void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, HANDLE h, uint32_t offset) @@ -1692,6 +746,7 @@ dcl_set_graphic_cursor(DisplayChangeListener *dcl, Qem= uGraphicConsole *con) dcl->ops->dpy_mouse_set(dcl, con->cursor_x, con->cursor_y, con->cu= rsor_on); } } + void register_displaychangelistener(DisplayChangeListener *dcl) { QemuConsole *con; @@ -1712,7 +767,7 @@ void register_displaychangelistener(DisplayChangeListe= ner *dcl) if (QEMU_IS_GRAPHIC_CONSOLE(con)) { dcl_set_graphic_cursor(dcl, QEMU_GRAPHIC_CONSOLE(con)); } - qemu_text_console_update_cursor(NULL); + qemu_text_console_update_cursor(); } =20 void update_displaychangelistener(DisplayChangeListener *dcl, @@ -2399,13 +1454,6 @@ bool qemu_console_is_multihead(DeviceState *dev) return false; } =20 - -static const char * -qemu_text_console_get_label(QemuTextConsole *c) -{ - return c->chr ? c->chr->label : NULL; -} - char *qemu_console_get_label(QemuConsole *con) { if (QEMU_IS_GRAPHIC_CONSOLE(con)) { @@ -2500,20 +1548,6 @@ int qemu_console_get_height(QemuConsole *con, int fa= llback) } } =20 -static void vc_chr_accept_input(Chardev *chr) -{ - VCChardev *drv =3D VC_CHARDEV(chr); - - kbd_send_chars(drv->console); -} - -static void vc_chr_set_echo(Chardev *chr, bool echo) -{ - VCChardev *drv =3D VC_CHARDEV(chr); - - drv->console->echo =3D echo; -} - int qemu_invalidate_text_consoles(void) { QemuConsole *s; @@ -2531,70 +1565,6 @@ int qemu_invalidate_text_consoles(void) return count; } =20 -static void qemu_text_console_update_cursor(void *opaque) -{ - cursor_visible_phase =3D !cursor_visible_phase; - - if (qemu_invalidate_text_consoles()) { - timer_mod(cursor_timer, - qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + CONSOLE_CURSOR_= PERIOD / 2); - } -} - -static void vc_chr_open(Chardev *chr, - ChardevBackend *backend, - bool *be_opened, - Error **errp) -{ - ChardevVC *vc =3D backend->u.vc.data; - VCChardev *drv =3D VC_CHARDEV(chr); - QemuTextConsole *s; - unsigned width =3D 0; - unsigned height =3D 0; - - if (vc->has_width) { - width =3D vc->width; - } else if (vc->has_cols) { - width =3D vc->cols * FONT_WIDTH; - } - - if (vc->has_height) { - height =3D vc->height; - } else if (vc->has_rows) { - height =3D vc->rows * FONT_HEIGHT; - } - - trace_console_txt_new(width, height); - if (width =3D=3D 0 || height =3D=3D 0) { - s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_TEXT_CONSOLE)); - width =3D qemu_console_get_width(NULL, 80 * FONT_WIDTH); - height =3D qemu_console_get_height(NULL, 24 * FONT_HEIGHT); - } else { - s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_FIXED_TEXT_CONSOLE)); - } - - dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(wi= dth, height)); - - s->chr =3D chr; - drv->console =3D s; - - /* set current text attributes to default */ - drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - text_console_resize(s); - - if (chr->label) { - char *msg; - - drv->t_attrib.bgcol =3D QEMU_COLOR_BLUE; - msg =3D g_strdup_printf("%s console\r\n", chr->label); - qemu_chr_write(chr, (uint8_t *)msg, strlen(msg), true); - g_free(msg); - drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - } - - *be_opened =3D true; -} - void qemu_console_resize(QemuConsole *s, int width, int height) { DisplaySurface *surface =3D qemu_console_surface(s); @@ -2721,63 +1691,3 @@ void qemu_display_help(void) } } } - -static void vc_chr_parse(QemuOpts *opts, ChardevBackend *backend, Error **= errp) -{ - int val; - ChardevVC *vc; - - backend->type =3D CHARDEV_BACKEND_KIND_VC; - vc =3D backend->u.vc.data =3D g_new0(ChardevVC, 1); - qemu_chr_parse_common(opts, qapi_ChardevVC_base(vc)); - - val =3D qemu_opt_get_number(opts, "width", 0); - if (val !=3D 0) { - vc->has_width =3D true; - vc->width =3D val; - } - - val =3D qemu_opt_get_number(opts, "height", 0); - if (val !=3D 0) { - vc->has_height =3D true; - vc->height =3D val; - } - - val =3D qemu_opt_get_number(opts, "cols", 0); - if (val !=3D 0) { - vc->has_cols =3D true; - vc->cols =3D val; - } - - val =3D qemu_opt_get_number(opts, "rows", 0); - if (val !=3D 0) { - vc->has_rows =3D true; - vc->rows =3D val; - } -} - -static void char_vc_class_init(ObjectClass *oc, void *data) -{ - ChardevClass *cc =3D CHARDEV_CLASS(oc); - - cc->parse =3D vc_chr_parse; - cc->open =3D vc_chr_open; - cc->chr_write =3D vc_chr_write; - cc->chr_accept_input =3D vc_chr_accept_input; - cc->chr_set_echo =3D vc_chr_set_echo; -} - -static const TypeInfo char_vc_type_info =3D { - .name =3D TYPE_CHARDEV_VC, - .parent =3D TYPE_CHARDEV, - .instance_size =3D sizeof(VCChardev), - .class_init =3D char_vc_class_init, -}; - -void qemu_console_early_init(void) -{ - /* set the default vc driver */ - if (!object_class_by_name(TYPE_CHARDEV_VC)) { - type_register(&char_vc_type_info); - } -} diff --git a/ui/meson.build b/ui/meson.build index d81609fb0e..0a1e8272a3 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -6,6 +6,7 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', + 'console-vc.c', 'cursor.c', 'input-keymap.c', 'input-legacy.c', --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515739; cv=none; d=zohomail.com; s=zohoarc; b=b6GoNr8SyJFtOxVGZdifCb1wx5y4YCxnYZNhIPsFhs5gl/Ri6JaHLHJZF47rFbQwZCK1WBB3aMb2nEcj1kVFK7wAN9gLAbt3CgFWfQsyYs6EQ1ewW31F2zcftIq9IxxtdZS430ZKwz2r9RHAgYiZoZPwaD3ci2EDREp1N0jgkPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515739; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J3zyCaLXLSn7aURJ1i9gJSyv2fWZHcsTULvmprb5B6I=; b=GBo3EqO8S4bM4t/bCiQmFbBLld1vIy+i8+2L8eJ/PBvs5SvkP5QlVqYRWfONPZIPS8uO1sWMLNEMh6aSOXqjOt9atRIt7ycfWk6R0Pf73OFyRMQhUxZBvxOK17y31mDZ8FOMMCwPu3d8JLPePMX3/RVNj4utpBr0n2F+dK+9F74= 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 1694515739960748.4845443018144; Tue, 12 Sep 2023 03:48:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vo-00043k-1Z; Tue, 12 Sep 2023 06:47:44 -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 1qg0vm-000410-5w for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vj-0003JI-Mv for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:41 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-D7Gv-W2GORWrNFMPB6M64Q-1; Tue, 12 Sep 2023 06:47:35 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8ED3229DD9B2 for ; Tue, 12 Sep 2023 10:47:35 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A30440C2064; Tue, 12 Sep 2023 10:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J3zyCaLXLSn7aURJ1i9gJSyv2fWZHcsTULvmprb5B6I=; b=B2QuVZ29hceEQfklb52d0myq+2L5UwnbN4CjCZo+TXvcmedWYgeHsbSg5t79Oy/jf8Iz80 9sG6rl6PKnC3TVOYz32ZWa8ze12bIyFjDxmK5JmH1+jtbJXWuFVPFHly3zxx0R4v2a/K1F AhUp0QV3awU9MuWRR5z2SSQAxGWEShQ= X-MC-Unique: D7Gv-W2GORWrNFMPB6M64Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 11/14] ui/console: move DisplaySurface to its own header Date: Tue, 12 Sep 2023 14:46:45 +0400 Message-ID: <20230912104649.1638640-12-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515740676100007 From: Marc-Andr=C3=A9 Lureau Mostly for readability reasons. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/console.h | 84 +-------------------------------------- include/ui/surface.h | 95 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 83 deletions(-) create mode 100644 include/ui/surface.h diff --git a/include/ui/console.h b/include/ui/console.h index 93bb03a9e2..79e4702912 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -6,11 +6,7 @@ #include "qemu/notify.h" #include "qapi/qapi-types-ui.h" #include "ui/input.h" - -#ifdef CONFIG_OPENGL -# include -# include "ui/shader.h" -#endif +#include "ui/surface.h" =20 #define TYPE_QEMU_CONSOLE "qemu-console" OBJECT_DECLARE_TYPE(QemuConsole, QemuConsoleClass, QEMU_CONSOLE) @@ -136,9 +132,6 @@ struct QemuConsoleClass { ObjectClass parent_class; }; =20 -#define QEMU_ALLOCATED_FLAG 0x01 -#define QEMU_PLACEHOLDER_FLAG 0x02 - typedef struct ScanoutTexture { uint32_t backing_id; bool backing_y_0_top; @@ -151,20 +144,6 @@ typedef struct ScanoutTexture { void *d3d_tex2d; } ScanoutTexture; =20 -typedef struct DisplaySurface { - pixman_image_t *image; - uint8_t flags; -#ifdef CONFIG_OPENGL - GLenum glformat; - GLenum gltype; - GLuint texture; -#endif -#ifdef WIN32 - HANDLE handle; - uint32_t handle_offset; -#endif -} DisplaySurface; - typedef struct QemuUIInfo { /* physical dimension */ uint16_t width_mm; @@ -344,30 +323,6 @@ struct DisplayGLCtx { }; =20 DisplayState *init_displaystate(void); -DisplaySurface *qemu_create_displaysurface_from(int width, int height, - pixman_format_code_t forma= t, - int linesize, uint8_t *dat= a); -DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image); -DisplaySurface *qemu_create_placeholder_surface(int w, int h, - const char *msg); -#ifdef WIN32 -void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, - HANDLE h, uint32_t offset); -#endif -PixelFormat qemu_default_pixelformat(int bpp); - -DisplaySurface *qemu_create_displaysurface(int width, int height); -void qemu_free_displaysurface(DisplaySurface *surface); - -static inline int is_buffer_shared(DisplaySurface *surface) -{ - return !(surface->flags & QEMU_ALLOCATED_FLAG); -} - -static inline int is_placeholder(DisplaySurface *surface) -{ - return surface->flags & QEMU_PLACEHOLDER_FLAG; -} =20 void register_displaychangelistener(DisplayChangeListener *dcl); void update_displaychangelistener(DisplayChangeListener *dcl, @@ -415,43 +370,6 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLCo= ntext ctx); =20 bool console_has_gl(QemuConsole *con); =20 -static inline int surface_stride(DisplaySurface *s) -{ - return pixman_image_get_stride(s->image); -} - -static inline void *surface_data(DisplaySurface *s) -{ - return pixman_image_get_data(s->image); -} - -static inline int surface_width(DisplaySurface *s) -{ - return pixman_image_get_width(s->image); -} - -static inline int surface_height(DisplaySurface *s) -{ - return pixman_image_get_height(s->image); -} - -static inline pixman_format_code_t surface_format(DisplaySurface *s) -{ - return pixman_image_get_format(s->image); -} - -static inline int surface_bits_per_pixel(DisplaySurface *s) -{ - int bits =3D PIXMAN_FORMAT_BPP(surface_format(s)); - return bits; -} - -static inline int surface_bytes_per_pixel(DisplaySurface *s) -{ - int bits =3D PIXMAN_FORMAT_BPP(surface_format(s)); - return DIV_ROUND_UP(bits, 8); -} - typedef uint32_t console_ch_t; =20 static inline void console_write_ch(console_ch_t *dest, uint32_t ch) diff --git a/include/ui/surface.h b/include/ui/surface.h new file mode 100644 index 0000000000..4244e0ca4a --- /dev/null +++ b/include/ui/surface.h @@ -0,0 +1,95 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * QEMU UI Console + */ +#ifndef SURFACE_H +#define SURFACE_H + +#include "ui/qemu-pixman.h" + +#ifdef CONFIG_OPENGL +# include +# include "ui/shader.h" +#endif + +#define QEMU_ALLOCATED_FLAG 0x01 +#define QEMU_PLACEHOLDER_FLAG 0x02 + +typedef struct DisplaySurface { + pixman_image_t *image; + uint8_t flags; +#ifdef CONFIG_OPENGL + GLenum glformat; + GLenum gltype; + GLuint texture; +#endif +#ifdef WIN32 + HANDLE handle; + uint32_t handle_offset; +#endif +} DisplaySurface; + +PixelFormat qemu_default_pixelformat(int bpp); + +DisplaySurface *qemu_create_displaysurface_from(int width, int height, + pixman_format_code_t forma= t, + int linesize, uint8_t *dat= a); +DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image); +DisplaySurface *qemu_create_placeholder_surface(int w, int h, + const char *msg); +#ifdef WIN32 +void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, + HANDLE h, uint32_t offset); +#endif + +DisplaySurface *qemu_create_displaysurface(int width, int height); +void qemu_free_displaysurface(DisplaySurface *surface); + +static inline int is_buffer_shared(DisplaySurface *surface) +{ + return !(surface->flags & QEMU_ALLOCATED_FLAG); +} + +static inline int is_placeholder(DisplaySurface *surface) +{ + return surface->flags & QEMU_PLACEHOLDER_FLAG; +} + +static inline int surface_stride(DisplaySurface *s) +{ + return pixman_image_get_stride(s->image); +} + +static inline void *surface_data(DisplaySurface *s) +{ + return pixman_image_get_data(s->image); +} + +static inline int surface_width(DisplaySurface *s) +{ + return pixman_image_get_width(s->image); +} + +static inline int surface_height(DisplaySurface *s) +{ + return pixman_image_get_height(s->image); +} + +static inline pixman_format_code_t surface_format(DisplaySurface *s) +{ + return pixman_image_get_format(s->image); +} + +static inline int surface_bits_per_pixel(DisplaySurface *s) +{ + int bits =3D PIXMAN_FORMAT_BPP(surface_format(s)); + return bits; +} + +static inline int surface_bytes_per_pixel(DisplaySurface *s) +{ + int bits =3D PIXMAN_FORMAT_BPP(surface_format(s)); + return DIV_ROUND_UP(bits, 8); +} + +#endif --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515737; cv=none; d=zohomail.com; s=zohoarc; b=nAvm1EX8EX6SyMTRjx/6PRBULDKaD886V7rh4O1MP22Hkh/7iaCMdu3vWrpvISkbt/KELQMIsBOj3MxbE2SdRuDBUMkc6w06UpcsXRCcaqfrKrvh2yNSTpj+ggHvAebFg+ePrrlpMuwfsAtDVIu3G/rLUf/MRS6UMUKXLQMz07M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515737; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AStmV6LXYnxhp7vvVwK/x1N0N5UFul+CbvAhIDcf03k=; b=j/uvq1TnqJXOCSewO6kbBq3Wy2aKSR9PPyjbn2U+box5F6eWc8uo5ffo1MRwa9ye5AhR4XKVxE3faTnrSORUmcO4OEGY4bOx8HwmKn/242CHHQpjTZAalwQfLtPba4omL7EyZQXFL+dDO6oiCHC7OAqLTtAzOnqDbbvR5YK6Hsw= 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 1694515737152491.22908205763804; Tue, 12 Sep 2023 03:48:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vp-00045X-F2; Tue, 12 Sep 2023 06:47:45 -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 1qg0vo-00043q-3l for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vl-0003Jj-FW for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:43 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-b9-hj1_mNC2vp3W8xd4xXg-1; Tue, 12 Sep 2023 06:47:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 218C08019DC for ; Tue, 12 Sep 2023 10:47:39 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1321C1005E27; Tue, 12 Sep 2023 10:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AStmV6LXYnxhp7vvVwK/x1N0N5UFul+CbvAhIDcf03k=; b=OwMtHOVmQ0ZqGRGPSbvVtXfPgHN1RR7A8pjvPXxX6z8zqBkl5paWM+0ETD6cPMhe1hhcrX xxZuXzVg5ddqRWnIfaQg8yFNrfXrx1xxjafVzOxCQAJ2LMmETeU/fSh2eosWWOKpEF2+fJ 7IR552G7uRFSftngKVMpHh6jIdoamvg= X-MC-Unique: b9-hj1_mNC2vp3W8xd4xXg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PULL 12/14] virtio-gpu/win32: set the destroy function on load Date: Tue, 12 Sep 2023 14:46:46 +0400 Message-ID: <20230912104649.1638640-13-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515738294100001 From: Marc-Andr=C3=A9 Lureau Don't forget to unmap the resource memory. Fixes: commit 9462ff469 ("virtio-gpu/win32: allocate shareable 2d resources= /images") Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/display/virtio-gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index bbd5c6561a..93857ad523 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1283,7 +1283,9 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, g_free(res); return -EINVAL; } - +#ifdef WIN32 + pixman_image_set_destroy_function(res->image, win32_pixman_image_d= estroy, res->handle); +#endif =20 res->addrs =3D g_new(uint64_t, res->iov_cnt); res->iov =3D g_new(struct iovec, res->iov_cnt); --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515748; cv=none; d=zohomail.com; s=zohoarc; b=lAeNLtkumR9P5Iq5OfpnnZTYNddhMjfcy63zPHhLbdFPtIsE3K19tqJoy8djLb29XnIpz6imV0g3kXfRCm0A3GxpC3slu/JFsI92NKBWM0GyzCwsQGL0kLQi61cfWzzzWDavpguG3hHTaDy7Hdh02DOl6Wn2sdtaN3p3Nrj92fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515748; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xLQoj1vul6G8GOSg6lVTQCpllic5KWmQQLQVC+gMxaQ=; b=TLZKIc4kZrA94UGLKwZYqvt/QI2a5+iR15TsIfPs92HvjQguUMEiu+qoy4mk70ZCwdVzE7BfpwtoJdjYOrxJdNILF5UEXK1Kc76+Pf+UT1OwiRge34lNVo7oSxVvhlaHHePEoaudZm4/Tv78VgT8PpJMgXp693fOJpIlg5JyOjA= 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 1694515748939112.27996400352322; Tue, 12 Sep 2023 03:49:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vt-00046D-55; Tue, 12 Sep 2023 06:47:49 -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 1qg0vr-00045z-EB for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vp-0003Lp-65 for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:47 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-569-i6vLM9ipPRaHfOB0-FmPhw-1; Tue, 12 Sep 2023 06:47:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE7758279A5 for ; Tue, 12 Sep 2023 10:47:42 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id D67D163F9D; Tue, 12 Sep 2023 10:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xLQoj1vul6G8GOSg6lVTQCpllic5KWmQQLQVC+gMxaQ=; b=EC/zoGbT9r6Gp+VlG6xOXcNEDltjVspsdSmNYmof2uMRUqhK0B2PgCELFsYcHrmqOf8rBA BX/YGneTXmT3n07hxnCPDTg1NNX2uJ+hN/FWiPf6JhjT/3wBdZHCLduOirJRnosLl/SPT9 xp8bYyvTagXRAk5n0S3uZIKVkb/Wr5o= X-MC-Unique: i6vLM9ipPRaHfOB0-FmPhw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 13/14] ui: fix crash when there are no active_console Date: Tue, 12 Sep 2023 14:46:47 +0400 Message-ID: <20230912104649.1638640-14-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515750877100007 From: Marc-Andr=C3=A9 Lureau Thread 1 "qemu-system-x86" received signal SIGSEGV, Segmentation fault. 0x0000555555888630 in dpy_ui_info_supported (con=3D0x0) at ../ui/console.c:= 812 812 return con->hw_ops->ui_info !=3D NULL; (gdb) bt #0 0x0000555555888630 in dpy_ui_info_supported (con=3D0x0) at ../ui/consol= e.c:812 #1 0x00005555558a44b1 in protocol_client_msg (vs=3D0x5555578c76c0, data=3D= 0x5555581e93f0 , len=3D24) at ../ui/vnc.c:2585 #2 0x00005555558a19ac in vnc_client_read (vs=3D0x5555578c76c0) at ../ui/vn= c.c:1607 #3 0x00005555558a1ac2 in vnc_client_io (ioc=3D0x5555581eb0e0, condition=3D= G_IO_IN, opaque=3D0x5555578c76c0) at ../ui/vnc.c:1635 Fixes: https://issues.redhat.com/browse/RHEL-2600 Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Albert Esteve --- ui/console.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/console.c b/ui/console.c index da341f08da..aa1e09462c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -806,6 +806,9 @@ bool dpy_ui_info_supported(QemuConsole *con) if (con =3D=3D NULL) { con =3D active_console; } + if (con =3D=3D NULL) { + return false; + } =20 return con->hw_ops->ui_info !=3D NULL; } --=20 2.41.0 From nobody Mon May 13 03:03:59 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1694515698; cv=none; d=zohomail.com; s=zohoarc; b=E+cLviZv9v9DqAB8NxNhzfDD3tl5Yavt2ngJ++DYFIxEIaKUMT/jA1zNcXbx2jjvvEX/O7RYwTZYLNsHpOUAEE6Cd7kOC0YhTjIB1UxU3ucoHKi96SnGvu+PJGdHJK/eE/MDkAODOYLmGGGwxSD4JFefCekXKwLywGu0+XPBIdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694515698; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Il54V6ZHs1s2EXU94aKrX5SlbhPP9GSKtWAsuriUKBU=; b=CTpSh/TLIeu1QI4im+idnNP6h8RGQoYJltY/bU//k44bVnoJkLH8rsrRBeUW/7GWWoQFlD9OKe3MjjEUK83AG11BH3i0FpF5QeCsg0wl2B2/38eyNQPuDdcqyTYJHECtWTm+IabVoUXqnGXuM9ohGfK1EJ9XDMFsEM/1Ny2U/As= 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 1694515698263994.085961780457; Tue, 12 Sep 2023 03:48:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qg0vw-0004AW-06; Tue, 12 Sep 2023 06:47:52 -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 1qg0vu-00046d-Lf for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qg0vs-0003Mc-6D for qemu-devel@nongnu.org; Tue, 12 Sep 2023 06:47:50 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-369-5cbOYktgPJyQcfP9dZWh4w-1; Tue, 12 Sep 2023 06:47:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E75862932481 for ; Tue, 12 Sep 2023 10:47:45 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 495AB63A52; Tue, 12 Sep 2023 10:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694515667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Il54V6ZHs1s2EXU94aKrX5SlbhPP9GSKtWAsuriUKBU=; b=PMkG3u9oq77WX/+9CzYTO9rNjI4lOjW2azJyJHy2S7aGeMiqr0iGLqI7LCQaCu4ODk9IfJ 166ghMEz1yXCabd5dcWkPk4yycaON8P+H78yuSvkkEAv9Foz6oZMv0EDHsh7YqyjdsrJhc VwtmukbVgdIJKI780ORAE0PV5u2hi80= X-MC-Unique: 5cbOYktgPJyQcfP9dZWh4w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 14/14] ui: add precondition for dpy_get_ui_info() Date: Tue, 12 Sep 2023 14:46:48 +0400 Message-ID: <20230912104649.1638640-15-marcandre.lureau@redhat.com> In-Reply-To: <20230912104649.1638640-1-marcandre.lureau@redhat.com> References: <20230912104649.1638640-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @redhat.com) X-ZM-MESSAGEID: 1694515699572100006 From: Marc-Andr=C3=A9 Lureau Ensure that it only get called when dpy_ui_info_supported(). The function should always return a result. There should be a non-null console or active_console. Modify the argument to be const as well. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Albert Esteve --- include/ui/console.h | 2 +- ui/console.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 79e4702912..28882f15a5 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -329,7 +329,7 @@ void update_displaychangelistener(DisplayChangeListener= *dcl, uint64_t interval); void unregister_displaychangelistener(DisplayChangeListener *dcl); =20 -bool dpy_ui_info_supported(QemuConsole *con); +bool dpy_ui_info_supported(const QemuConsole *con); const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con); int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay); =20 diff --git a/ui/console.c b/ui/console.c index aa1e09462c..4a4f19ed33 100644 --- a/ui/console.c +++ b/ui/console.c @@ -801,7 +801,7 @@ static void dpy_set_ui_info_timer(void *opaque) con->hw_ops->ui_info(con->hw, head, &con->ui_info); } =20 -bool dpy_ui_info_supported(QemuConsole *con) +bool dpy_ui_info_supported(const QemuConsole *con) { if (con =3D=3D NULL) { con =3D active_console; @@ -815,6 +815,8 @@ bool dpy_ui_info_supported(QemuConsole *con) =20 const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con) { + assert(dpy_ui_info_supported(con)); + if (con =3D=3D NULL) { con =3D active_console; } --=20 2.41.0