From nobody Mon Feb 9 16:19:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559105115; cv=none; d=zoho.com; s=zohoarc; b=b95zv6pV0T0hLFwXvHAhmD3awC1RDYVP3YjPjGZf56aqTwim5hZOgWeKuvSuaEmX/iF+jePZQwpr6Tohhh+a9/9BVLen6aLD7PSw9Qfm1Ubds1C9hm0QPDfuWKFrj9hCDbeKxS+r20tOWy6/ikVoi7G5AUTnXnp4fvGyggyXXCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559105115; 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:ARC-Authentication-Results; bh=ttsqQebVgI+v/sW2Zs3tcI9wGZa4lve9KVwpm9oXlPw=; b=ZIo1/i3deNfIGhFQ7ANDP+SVqGHoypLtlsyiX3nvxZUi18jrPlOkcc0+9gHYuqGuRI4iXXr3fWw5uq1Q34JaQnCRjkBtr58nAJgadhkXanFJg1XTDe+kMoCVLm3Yop2yXlivv1ZJgAgjckFjMsa9j1jpRBcYpAC/4vUQUqTmQCU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559105115408300.22608427499733; Tue, 28 May 2019 21:45:15 -0700 (PDT) Received: from localhost ([127.0.0.1]:47025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVqSb-0000EE-Bd for importer@patchew.org; Wed, 29 May 2019 00:45:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVqOB-0005DG-1P for qemu-devel@nongnu.org; Wed, 29 May 2019 00:40:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVqO9-00068f-Rg for qemu-devel@nongnu.org; Wed, 29 May 2019 00:40:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54050) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVqO9-00065A-FO for qemu-devel@nongnu.org; Wed, 29 May 2019 00:40:33 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AB9A3082134 for ; Wed, 29 May 2019 04:40:28 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E9A41001E71; Wed, 29 May 2019 04:40:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B3FF717512; Wed, 29 May 2019 06:40:20 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 29 May 2019 06:40:14 +0200 Message-Id: <20190529044020.27003-4-kraxel@redhat.com> In-Reply-To: <20190529044020.27003-1-kraxel@redhat.com> References: <20190529044020.27003-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 29 May 2019 04:40:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/9] virtio-gpu: add a pixman helper header X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau This will allow to share the format conversion function with vhost-user-gpu. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-id: 20190524130946.31736-4-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- include/hw/virtio/virtio-gpu-pixman.h | 45 +++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 29 ++--------------- 2 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 include/hw/virtio/virtio-gpu-pixman.h diff --git a/include/hw/virtio/virtio-gpu-pixman.h b/include/hw/virtio/virt= io-gpu-pixman.h new file mode 100644 index 000000000000..4dba782758dc --- /dev/null +++ b/include/hw/virtio/virtio-gpu-pixman.h @@ -0,0 +1,45 @@ +/* + * Virtio GPU Device + * + * Copyright Red Hat, Inc. 2013-2014 + * + * Authors: + * Dave Airlie + * Gerd Hoffmann + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_VIRTIO_GPU_PIXMAN_H +#define HW_VIRTIO_GPU_PIXMAN_H + +#include "ui/qemu-pixman.h" +#include "standard-headers/linux/virtio_gpu.h" + +static inline pixman_format_code_t +virtio_gpu_get_pixman_format(uint32_t virtio_gpu_format) +{ + switch (virtio_gpu_format) { + case VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM: + return PIXMAN_BE_b8g8r8x8; + case VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM: + return PIXMAN_BE_b8g8r8a8; + case VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM: + return PIXMAN_BE_x8r8g8b8; + case VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM: + return PIXMAN_BE_a8r8g8b8; + case VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM: + return PIXMAN_BE_r8g8b8x8; + case VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM: + return PIXMAN_BE_r8g8b8a8; + case VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM: + return PIXMAN_BE_x8b8g8r8; + case VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM: + return PIXMAN_BE_a8b8g8r8; + default: + return 0; + } +} + +#endif diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 571cecca75f7..a11853af09f6 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -21,6 +21,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" #include "hw/virtio/virtio-gpu-bswap.h" +#include "hw/virtio/virtio-gpu-pixman.h" #include "hw/virtio/virtio-bus.h" #include "hw/display/edid.h" #include "migration/blocker.h" @@ -298,30 +299,6 @@ void virtio_gpu_get_edid(VirtIOGPU *g, virtio_gpu_ctrl_response(g, cmd, &edid.hdr, sizeof(edid)); } =20 -static pixman_format_code_t get_pixman_format(uint32_t virtio_gpu_format) -{ - switch (virtio_gpu_format) { - case VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM: - return PIXMAN_BE_b8g8r8x8; - case VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM: - return PIXMAN_BE_b8g8r8a8; - case VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM: - return PIXMAN_BE_x8r8g8b8; - case VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM: - return PIXMAN_BE_a8r8g8b8; - case VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM: - return PIXMAN_BE_r8g8b8x8; - case VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM: - return PIXMAN_BE_r8g8b8a8; - case VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM: - return PIXMAN_BE_x8b8g8r8; - case VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM: - return PIXMAN_BE_a8b8g8r8; - default: - return 0; - } -} - static uint32_t calc_image_hostmem(pixman_format_code_t pformat, uint32_t width, uint32_t height) { @@ -368,7 +345,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, res->format =3D c2d.format; res->resource_id =3D c2d.resource_id; =20 - pformat =3D get_pixman_format(c2d.format); + pformat =3D virtio_gpu_get_pixman_format(c2d.format); if (!pformat) { qemu_log_mask(LOG_GUEST_ERROR, "%s: host couldn't handle guest format %d\n", @@ -1144,7 +1121,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, res->iov_cnt =3D qemu_get_be32(f); =20 /* allocate */ - pformat =3D get_pixman_format(res->format); + pformat =3D virtio_gpu_get_pixman_format(res->format); if (!pformat) { g_free(res); return -EINVAL; --=20 2.18.1