[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC QEMU PATCH 17/18] virtio-gpu: Add video hardware accelerate support for virgl
- To: Gerd Hoffmann <kraxel@xxxxxxxxxx>, "Michael S . Tsirkin" <mst@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Antonio Caggiano <antonio.caggiano@xxxxxxxxxxxxx>, "Dr . David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Robert Beckett <bob.beckett@xxxxxxxxxxxxx>, <qemu-devel@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Huang Rui <ray.huang@xxxxxxx>
- Date: Sun, 12 Mar 2023 17:22:43 +0800
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PChcqlgg/1AX3q5gkPO8/Y72dq7j51chPEAff/NNK80=; b=lXdc5YMeYO1ppf/oQVMMhIRyuNM0QL6cufQ3VZEoEsUstEMzv0ock2qoaj3bpdLHYKvbjLpuYnOK4zzdZuk90Bez8NoL73oHs/wR3bDn2k81evs7K3qPSOODeW10mkrLwH6HcNjMa+2SYZADsYxI/hI1UhvddTo8isDWT+k24cwL/Fo4LWlO7WngENw85HxNqk4FPHqjYGRpe9f0pQdODNgOTztc1lklKvGaHovjstCkhdsUGhZ18Ycur4KHQRXCTjbxQPuGNKvgQa1ugxgE5owFRdVsSBnLyCYnTZunFJw7A9unti1w3peeL3FOAYkOlSz1LsTipEB3oX61kkG4MA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EyaruosxKMOHK/NgDOANwot/s+BJKTphY4jfG9PIzm6YW5z9tpD7Rh6SC3J3QnXVm//0Eo1oFWOrqC/gpxuE6kovtSDGsPI2T7sssPrRJLRH21cI4J6Jkybzo9K5DKLnXsHpvAEfcDYkbJyhBggf+3VMEb36rVonbeHItYBMRVisJe2XaeFxS76U1JZwClg0QPe4TlUg1sSc1MQQKOrG9K4Qn6IG/NrBzqC0eulbzn+mviBBu2l6qd2t4DKVQMJfrrBQPnJsJ1JVikZ59pUPE6AkJ/WG0OtA00HHO04vzts01CNDsdFZY4QKEkuOvq7/HLsy599GfOZZr11rj4NDcg==
- Cc: Alex Deucher <alexander.deucher@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, "Stewart Hildebrand" <Stewart.Hildebrand@xxxxxxx>, Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, Honglei Huang <honglei1.huang@xxxxxxx>, Julia Zhang <julia.zhang@xxxxxxx>, Chen Jiqian <Jiqian.Chen@xxxxxxx>, Huang Rui <ray.huang@xxxxxxx>
- Delivery-date: Sun, 12 Mar 2023 09:29:10 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
From: Honglei Huang <honglei1.huang@xxxxxxx>
Add get_drm_fd callback let the guest OS can get render node to using hw accel
codec.
Signed-off-by: Honglei Huang <honglei1.huang@xxxxxxx>
Signed-off-by: Huang Rui <ray.huang@xxxxxxx>
---
hw/display/virtio-gpu-virgl.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index d5214e0f43..aef735a427 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "qemu/iov.h"
+#include "qemu/drm.h"
#include "trace.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-gpu.h"
@@ -827,12 +828,22 @@ static int virgl_make_context_current(void *opaque, int
scanout_idx,
qctx);
}
+static int virgl_get_drm_fd(void *opaque)
+{
+ int fd = -1;
+
+ fd = qemu_drm_rendernode_open(NULL);
+
+ return fd;
+}
+
static struct virgl_renderer_callbacks virtio_gpu_3d_cbs = {
.version = 1,
.write_fence = virgl_write_fence,
.create_gl_context = virgl_create_context,
.destroy_gl_context = virgl_destroy_context,
.make_current = virgl_make_context_current,
+ .get_drm_fd = virgl_get_drm_fd,
};
static void virtio_gpu_print_stats(void *opaque)
@@ -886,14 +897,20 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g)
virgl_renderer_reset();
}
+
+
int virtio_gpu_virgl_init(VirtIOGPU *g)
{
int ret;
+#ifndef VIRGL_RENDERER_USE_VIDEO
+#define VIRGL_RENDERER_USE_VIDEO (1 << 11)
+#endif
+
#ifdef VIRGL_RENDERER_VENUS
- ret = virgl_renderer_init(g, VIRGL_RENDERER_VENUS, &virtio_gpu_3d_cbs);
+ ret = virgl_renderer_init(g, VIRGL_RENDERER_VENUS |
VIRGL_RENDERER_USE_VIDEO, &virtio_gpu_3d_cbs);
#else
- ret = virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs);
+ ret = virgl_renderer_init(g, 0 | VIRGL_RENDERER_USE_VIDEO,
&virtio_gpu_3d_cbs);
#endif
if (ret != 0) {
error_report("virgl could not be initialized: %d", ret);
--
2.25.1
|