From patchwork Thu Dec 9 14:55:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Griffin X-Patchwork-Id: 522504 Delivered-To: patch@linaro.org Received: by 2002:a05:6e04:2287:0:0:0:0 with SMTP id bl7csp1166109imb; Thu, 9 Dec 2021 07:09:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTGEVA6HJTP1O/sccZag531RlDiGV6/b3E2SnywX0TMD303eBClBEOCgZk5+SsonwzXeC8 X-Received: by 2002:a2e:a593:: with SMTP id m19mr7067438ljp.407.1639062553054; Thu, 09 Dec 2021 07:09:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639062552; cv=none; d=google.com; s=arc-20160816; b=dA8e/4XqQ8GV5jIziU9/BUbbSGMzqkEITyfwFSFIq3CoQHckcg/vFbiRxTgRZDN34m aiJK2pcvQVI6Ay3Y0AYL0QbDFJzUjig7X1x54XNzq9rMRxWYVsVA6BzLalXPul/yzBS/ +9yGGtNtiOTTNdJ0PhCoiHHf2J9sVHFjgV5NyeR3kh3tTHeXMO6nqNLaNiuwwogZlP05 nqlQ4jJFNA+cZnTxS8I6mtvbU0DUC7KBAVHuqLMwPzHOXPFeHWdrbFnfR1h0Iyn9dB7s UFRwVbSjEi0ncdNHLNyol1MjTSiTceokKlQ8QK00/i3D3fBTxvy9GfdHz0FfiWam/YA5 Z5TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0yXXniY95IkJujK31ekJh+HWJyF51d5WiUb5hhe8MAk=; b=u/WT6pg99/WLMiD544kqp/QpAkTbbW7SJPQHnXk/3rfMxijxyGV1WRmMebOAr5v0RV /lm0UJzdGb4lKN2KuphjKD2KPm0SVGNApGZ7jCcPuYmsdVzzztox3kC/DP8TZYtuQPtQ fwxogklWZNonRSgRQyDJ9v3LbnqGFtu3j/E0keQj8qPOWth2Y6LHZIoHmYGsplI5Z27W eQC/Mw6FsgoxyA3nyO7UW9GH1DUgglttMB4+JB9zP9r8gWOCu0b31cPATGbhmDPwfXHA 5H3ia6wcvAwVBX2h6tAhJYDlt9IErtgDBn8Mk99A16TXWlepF9unzOWYTDPbFcsRQVT7 edRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KC1+f1ET; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h25si59391uan.182.2021.12.09.07.09.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Dec 2021 07:09:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KC1+f1ET; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mvL2m-0003Rl-FF for patch@linaro.org; Thu, 09 Dec 2021 10:09:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mvKqj-0002bY-1D for qemu-devel@nongnu.org; Thu, 09 Dec 2021 09:56:45 -0500 Received: from [2a00:1450:4864:20::42b] (port=45656 helo=mail-wr1-x42b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mvKqe-0001Xs-Gv for qemu-devel@nongnu.org; Thu, 09 Dec 2021 09:56:44 -0500 Received: by mail-wr1-x42b.google.com with SMTP id o13so10098877wrs.12 for ; Thu, 09 Dec 2021 06:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0yXXniY95IkJujK31ekJh+HWJyF51d5WiUb5hhe8MAk=; b=KC1+f1ET47+q9q95fZK/81a2EiGWvHbJx4dasVFpkd+mj+y1cMBR7pRprwYoU+x353 fLJcA0nU1FTLKtvXArsl0ohiiQrssqvTePNZX+eYiwonNCkzxxm+MfFA7XjyyNtv8ovI rHOFtrFVlfjLGjyj2h/i6igipsY6GK/LNde0MEgX76r1EWceNpRcZLwA0V+9vJ1xmA3I cM4MjSj/QPQI7xGeocxYP7xGmS9Az2ixa3iOtCpFaBWx/uUaKKFtv2RlPNNcFgIG8Erw 4RFqPfx0KNYTmtiHJuMsu2y9ZKrbAtqsqCp1R+fMwqzM7mV0I8UJBk+W7I9O0oKyJJ0A 2liA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0yXXniY95IkJujK31ekJh+HWJyF51d5WiUb5hhe8MAk=; b=42CWIlyVTqHR+lNdoG9dsfekxGQyxmfmIVrYZE46NH0F4CSXC0+KFdeWKiMvRd10Gu deXp/+64XlXHqZUKR50NcTy5oo8mPOCODLED9d9qIYp9H/qNTR4S/p5b/bU4Sn1rHdMF BR3cfpjMfI9MtmXpZNKy7SPWg+dRbRfM9bLyWjon4lUcwLvQIU6ww4/hto8+E/eZEIIU i6axBB7x2hW7fj1o6nsi7FDD3SgS+HUbm/46ouI57vP0rvwYFBlsK3ID1xwzqZKblFrH pUTMzGrm78BMsZPSz8zNSzolQGxoivwLttBDNaXhJyYQM533vNe13/LxoXgPoCfq+NWc obPQ== X-Gm-Message-State: AOAM532/bMCMJunVeg8i4+TWe0g8a4awC3ULsGfo3fJR1B7sNlztU6e+ LweavBL3j2U/HGwKB+3/YhaBdntS7aBAqQ== X-Received: by 2002:adf:e109:: with SMTP id t9mr6801799wrz.387.1639061798715; Thu, 09 Dec 2021 06:56:38 -0800 (PST) Received: from xps15-9570.lan (host-92-16-105-103.as13285.net. [92.16.105.103]) by smtp.gmail.com with ESMTPSA id y142sm30845wmc.40.2021.12.09.06.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 06:56:38 -0800 (PST) From: Peter Griffin To: marcandre.lureau@redhat.com, mst@redhat.com, alex.bennee@linaro.org Subject: [PATCH 3/8] vhost-user-video: boiler plate code for vhost-user-video device Date: Thu, 9 Dec 2021 14:55:56 +0000 Message-Id: <20211209145601.331477-4-peter.griffin@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209145601.331477-1-peter.griffin@linaro.org> References: <20211209145601.331477-1-peter.griffin@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.griffin@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: Peter Griffin , qemu-devel@nongnu.org, stratos-dev@op-lists.linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Peter Griffin Reviewed-by: Alex Bennée --- hw/display/Kconfig | 5 + hw/display/meson.build | 3 + hw/display/vhost-user-video.c | 386 +++++++++++++++++++++++++++ include/hw/virtio/vhost-user-video.h | 41 +++ 4 files changed, 435 insertions(+) create mode 100644 hw/display/vhost-user-video.c create mode 100644 include/hw/virtio/vhost-user-video.h diff --git a/hw/display/Kconfig b/hw/display/Kconfig index a2306b67d8..186163b015 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -118,6 +118,11 @@ config VHOST_USER_VGA default y depends on VIRTIO_VGA && VHOST_USER_GPU +config VHOST_USER_VIDEO + bool + default y + depends on VIRTIO && VHOST_USER + config DPCD bool select AUX diff --git a/hw/display/meson.build b/hw/display/meson.build index 861c43ff98..48284528cf 100644 --- a/hw/display/meson.build +++ b/hw/display/meson.build @@ -37,6 +37,9 @@ softmmu_ss.add(when: 'CONFIG_MACFB', if_true: files('macfb.c')) softmmu_ss.add(when: 'CONFIG_NEXTCUBE', if_true: files('next-fb.c')) specific_ss.add(when: 'CONFIG_VGA', if_true: files('vga.c')) +specific_ss.add(when: 'CONFIG_VHOST_USER_VIDEO', if_true: files('vhost-user-video.c')) +specific_ss.add(when: ['CONFIG_VHOST_USER_VIDEO', 'CONFIG_VIRTIO_PCI' ], + if_true: files('vhost-user-video-pci.c')) if config_all_devices.has_key('CONFIG_QXL') qxl_ss = ss.source_set() diff --git a/hw/display/vhost-user-video.c b/hw/display/vhost-user-video.c new file mode 100644 index 0000000000..506e350365 --- /dev/null +++ b/hw/display/vhost-user-video.c @@ -0,0 +1,386 @@ +/* + * Vhost-user VIDEO virtio device + * + * This is the boilerplate for instantiating a vhost-user device + * implementing a virtio-video device. + * + * The virtio video decoder and encoder devices are virtual devices that + * support encoding and decoding respectively. + * + * The actual back-end for this driver is the vhost-user-video daemon. + * The code here just connects up the device in QEMU and allows it to + * be instantiated. + * + * Copyright (c) 2021 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-video.h" +#include "qemu/error-report.h" + +/* currently there is no VIDEO enc/dec defined in Linux virtio_ids.h */ +#define VIRTIO_ID_VIDEO_ENC 30 +#define VIRTIO_ID_VIDEO_DEC 31 +#define MAX_CAPS_LEN 4096 + +static void vhost_user_video_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + struct virtio_video_config *vconfig = (struct virtio_video_config *)config; + int ret; + Error *local_err = NULL; + + memset(config, 0, sizeof(struct virtio_video_config)); + + ret = vhost_dev_get_config(&video->vhost_dev, config, + sizeof(struct virtio_video_config), &local_err); + if (ret) { + error_report("vhost-user-video: get device config space failed"); + + /*TODO vhost_dev_get_config() fails so for now lets just set it here */ + vconfig = (struct virtio_video_config *)config; + vconfig->version = 0; + vconfig->max_caps_length = MAX_CAPS_LEN; + vconfig->max_resp_length = MAX_CAPS_LEN; + return; + } +} + +static void vhost_user_video_start(VirtIODevice *vdev) +{ + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + int i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret = vhost_dev_enable_notifiers(&video->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret = k->set_guest_notifiers(qbus->parent, video->vhost_dev.nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + video->vhost_dev.acked_features = vdev->guest_features; + + ret = vhost_dev_start(&video->vhost_dev, vdev); + if (ret < 0) { + error_report("Error starting vhost-user-video: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i = 0; i < video->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&video->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, video->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&video->vhost_dev, vdev); +} + +static void vhost_user_video_stop(VirtIODevice *vdev) +{ + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&video->vhost_dev, vdev); + + ret = k->set_guest_notifiers(qbus->parent, video->vhost_dev.nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&video->vhost_dev, vdev); +} + +static void vhost_user_video_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + bool should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; + + if (!vdev->vm_running) { + should_start = false; + } + + if (video->vhost_dev.started == should_start) { + return; + } + + if (should_start) { + vhost_user_video_start(vdev); + } else { + vhost_user_video_stop(vdev); + } +} + +static uint64_t vhost_user_video_get_features(VirtIODevice *vdev, + uint64_t requested_features, + Error **errp) +{ + /* currently only support guest pages */ + virtio_add_feature(&requested_features, + VIRTIO_VIDEO_F_RESOURCE_GUEST_PAGES); + + return requested_features; +} + +static void vhost_user_video_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void vhost_user_video_guest_notifier_mask(VirtIODevice *vdev, int idx, + bool mask) +{ + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + vhost_virtqueue_mask(&video->vhost_dev, vdev, idx, mask); +} + +static bool vhost_user_video_guest_notifier_pending(VirtIODevice *vdev, int idx) +{ + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + return vhost_virtqueue_pending(&video->vhost_dev, idx); +} + +/* + * Chardev connect/disconnect events + */ + +static int vhost_user_video_handle_config_change(struct vhost_dev *dev) +{ + int ret; + VHostUserVIDEO *video = VHOST_USER_VIDEO(dev->vdev); + Error *local_err = NULL; + + ret = vhost_dev_get_config(dev, (uint8_t *)&video->conf.config, + sizeof(struct virtio_video_config), &local_err); + if (ret < 0) { + error_report("get config space failed"); + return -1; + } + + return 0; +} + +const VhostDevConfigOps video_ops = { + .vhost_dev_config_notifier = vhost_user_video_handle_config_change, +}; + +static int vhost_user_video_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + + if (video->connected) { + return 0; + } + video->connected = true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vhost_user_video_start(vdev); + } + + return 0; +} + +static void vhost_user_video_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + + if (!video->connected) { + return; + } + video->connected = false; + + if (video->vhost_dev.started) { + vhost_user_video_stop(vdev); + } + + vhost_dev_cleanup(&video->vhost_dev); +} + +static void vhost_user_video_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserVIDEO *video = VHOST_USER_VIDEO(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vhost_user_video_connect(dev) < 0) { + qemu_chr_fe_disconnect(&video->conf.chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vhost_user_video_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserVIDEO *video) +{ + vhost_user_cleanup(&video->vhost_user); + virtio_delete_queue(video->command_vq); + virtio_delete_queue(video->event_vq); + virtio_cleanup(vdev); + g_free(video->vhost_dev.vqs); + video->vhost_dev.vqs = NULL; +} + + +static void vhost_user_video_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserVIDEO *video = VHOST_USER_VIDEO(dev); + int ret; + + if (!vhost_user_init(&video->vhost_user, &video->conf.chardev, errp)) { + return; + } + + /* TODO Implement VIDEO_ENC, currently only support VIDEO_DEC */ + virtio_init(vdev, "vhost-user-video", VIRTIO_ID_VIDEO_DEC, + sizeof(struct virtio_video_config)); + + /* one command queue and one event queue */ + video->vhost_dev.nvqs = 2; + video->vhost_dev.vqs = g_new0(struct vhost_virtqueue, + video->vhost_dev.nvqs); + + ret = vhost_dev_init(&video->vhost_dev, &video->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + error_report("vhost_dev_init failed: %s", strerror(-ret)); + goto vhost_dev_init_failed; + } + + /* One command queue, for sending commands */ + video->command_vq = virtio_add_queue(vdev, 128, + vhost_user_video_handle_output); + + if (!video->command_vq) { + error_setg_errno(errp, -1, "virtio_add_queue() failed"); + goto cmd_q_fail; + } + + /* One event queue, for sending events */ + video->event_vq = virtio_add_queue(vdev, 128, + vhost_user_video_handle_output); + + if (!video->command_vq) { + error_setg_errno(errp, -1, "virtio_add_queue() failed"); + goto event_q_fail; + } + + /* + * At this point the next event we will get is a connection from + * the daemon on the control socket. + */ + + qemu_chr_fe_set_handlers(&video->conf.chardev, NULL, + NULL, vhost_user_video_event, + NULL, (void *)dev, NULL, true); + + return; + +event_q_fail: + virtio_delete_queue(video->event_vq); +cmd_q_fail: + vhost_user_cleanup(&video->vhost_user); +vhost_dev_init_failed: + virtio_cleanup(vdev); + +} + +static void vhost_user_video_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserVIDEO *video = VHOST_USER_VIDEO(dev); + + /* This will stop vhost backend if appropriate. */ + vhost_user_video_set_status(vdev, 0); + + do_vhost_user_cleanup(vdev, video); +} + +static const VMStateDescription vhost_user_video_vmstate = { + .name = "vhost-user-video", + .unmigratable = 1, +}; + +static Property vhost_user_video_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserVIDEO, conf.chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vhost_user_video_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vhost_user_video_properties); + dc->vmsd = &vhost_user_video_vmstate; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + vdc->realize = vhost_user_video_device_realize; + vdc->unrealize = vhost_user_video_device_unrealize; + vdc->get_features = vhost_user_video_get_features; + vdc->get_config = vhost_user_video_get_config; + vdc->set_status = vhost_user_video_set_status; + vdc->guest_notifier_mask = vhost_user_video_guest_notifier_mask; + vdc->guest_notifier_pending = vhost_user_video_guest_notifier_pending; +} + +static const TypeInfo vhost_user_video_info = { + .name = TYPE_VHOST_USER_VIDEO, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserVIDEO), + .class_init = vhost_user_video_class_init, +}; + +static void vhost_user_video_register_types(void) +{ + type_register_static(&vhost_user_video_info); +} + +type_init(vhost_user_video_register_types) diff --git a/include/hw/virtio/vhost-user-video.h b/include/hw/virtio/vhost-user-video.h new file mode 100644 index 0000000000..09a4374ca6 --- /dev/null +++ b/include/hw/virtio/vhost-user-video.h @@ -0,0 +1,41 @@ +/* + * vhost-user-video virtio device + * + * Copyright (c) 2021 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _VHOST_USER_VIDEO_H_ +#define _VHOST_USER_VIDEO_H_ + +#include "standard-headers/linux/virtio_video.h" +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "chardev/char-fe.h" + +#define TYPE_VHOST_USER_VIDEO "vhost-user-video-device" +#define VHOST_USER_VIDEO(obj) \ + OBJECT_CHECK(VHostUserVIDEO, (obj), TYPE_VHOST_USER_VIDEO) + +typedef struct { + CharBackend chardev; + struct virtio_video_config config; +} VHostUserVIDEOConf; + +typedef struct { + /*< private >*/ + VirtIODevice parent; + VHostUserVIDEOConf conf; + struct vhost_virtqueue *vhost_vq; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *command_vq; + VirtQueue *event_vq; + bool connected; + /*< public >*/ +} VHostUserVIDEO; + + +#endif /* _VHOST_USER_VIDEO_H_ */