qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Albert Esteve <aesteve@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
	fmartine@redhat.com, "Gerd Hoffmann" <kraxel@redhat.com>,
	eballetb@redhat.com, "Albert Esteve" <aesteve@redhat.com>,
	alex.bennee@linaro.org, "Laurent Vivier" <lvivier@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	sgarzare@redhat.com,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	peter.griffin@linaro.org, "Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 10/12] vhost-user-video: add dev_type to CLI
Date: Wed, 22 Mar 2023 15:21:30 +0100	[thread overview]
Message-ID: <20230322142132.22909-11-aesteve@redhat.com> (raw)
In-Reply-To: <20230322142132.22909-1-aesteve@redhat.com>

Add dev_type to the command line interface.
This way we can select dev_type=encoder or
dev_type=decoder and assign the virtio ID
appropiately. If ommited, default virtio
ID used is decoder's ID.

Example:
-device vhost-user-video-pci,chardev=video,dev_type=encoder,id=video

Signed-off-by: Albert Esteve <aesteve@redhat.com>
---
 docs/system/devices/vhost-user-video.rst |  2 +-
 hw/display/vhost-user-video.c            | 13 +++++++++++--
 include/hw/virtio/vhost-user-video.h     |  1 +
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/docs/system/devices/vhost-user-video.rst b/docs/system/devices/vhost-user-video.rst
index ff0a8fe5c7..d428a773e2 100644
--- a/docs/system/devices/vhost-user-video.rst
+++ b/docs/system/devices/vhost-user-video.rst
@@ -72,7 +72,7 @@ use to communicate as well as share the guests memory over a memfd.
 ::
 
     host# qemu-system								\
-        -device vhost-user-video-pci,chardev=video,id=video                     \
+        -device vhost-user-video-pci,chardev=video,dev_type=decoder,id=video    \
         -chardev socket,path=/tmp//video.sock,id=video                          \
         -m 4096 		        					\
         -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on	\
diff --git a/hw/display/vhost-user-video.c b/hw/display/vhost-user-video.c
index 9cc6a717d5..469e9e7c89 100644
--- a/hw/display/vhost-user-video.c
+++ b/hw/display/vhost-user-video.c
@@ -300,8 +300,16 @@ static void vhost_user_video_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    /* TODO Implement VIDEO_ENC, currently only support VIDEO_DEC */
-    virtio_init(vdev, VIRTIO_ID_VIDEO_DECODER, sizeof(struct virtio_video_config));
+    if (video->conf.type == NULL || !strcmp(video->conf.type, "decoder")) {
+        virtio_init(vdev, VIRTIO_ID_VIDEO_DECODER,
+                    sizeof(struct virtio_video_config));
+    } else if (!strcmp(video->conf.type, "encoder")) {
+        virtio_init(vdev, VIRTIO_ID_VIDEO_ENCODER,
+                    sizeof(struct virtio_video_config));
+    } else {
+        error_report("invalid type received: %s", video->conf.type);
+        goto vhost_dev_init_failed;
+    }
 
     /* one command queue and one event queue */
     video->vhost_dev.nvqs = 2;
@@ -375,6 +383,7 @@ static const VMStateDescription vhost_user_video_vmstate = {
 
 static Property vhost_user_video_properties[] = {
     DEFINE_PROP_CHR("chardev", VHostUserVIDEO, conf.chardev),
+    DEFINE_PROP_STRING("dev_type", VHostUserVIDEO, conf.type),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/vhost-user-video.h b/include/hw/virtio/vhost-user-video.h
index f8329c3b36..3fe00b79a6 100644
--- a/include/hw/virtio/vhost-user-video.h
+++ b/include/hw/virtio/vhost-user-video.h
@@ -22,6 +22,7 @@
 
 typedef struct {
     CharBackend chardev;
+    char *type;
     struct virtio_video_config config;
 } VHostUserVIDEOConf;
 
-- 
2.39.2



  parent reply	other threads:[~2023-03-22 14:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22 14:21 [PATCH 00/12] [RFC PATCHv2] Add vhost-user Video decode Albert Esteve
2023-03-22 14:21 ` [PATCH 01/12] docs: Add a vhost-virtio-video rst file Albert Esteve
2023-03-22 14:21 ` [PATCH 02/12] MAINTAINERS: Add virtio-video section Albert Esteve
2023-03-22 14:45   ` Thomas Huth
2023-03-22 15:28     ` Albert Esteve
2023-03-22 14:21 ` [PATCH 03/12] vhost-user-video: boiler plate code for vhost-user-video device Albert Esteve
2023-03-22 14:21 ` [PATCH 04/12] vhost-user-video: add meson subdir build logic Albert Esteve
2023-03-22 14:21 ` [PATCH 05/12] standard-headers: Add virtio_video.h Albert Esteve
2023-03-22 14:21 ` [PATCH 06/12] hw/display: add vhost-user-video-pci Albert Esteve
2023-03-22 14:21 ` [PATCH 07/12] vhost-user.json: add video type Albert Esteve
2023-03-22 14:21 ` [PATCH 08/12] tools/vhost-user-video: Add initial vhost-user-video vmm Albert Esteve
2023-03-22 14:21 ` [PATCH 09/12] tests/qtest: add virtio-video test Albert Esteve
2023-03-22 14:21 ` Albert Esteve [this message]
2023-03-22 14:21 ` [PATCH 11/12] vhost-user-video-udmabuf: add udmabuf helpers Albert Esteve
2023-03-22 14:21 ` [PATCH 12/12] Add support for v4l2_memory_dmabuf Albert Esteve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230322142132.22909-11-aesteve@redhat.com \
    --to=aesteve@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=eballetb@redhat.com \
    --cc=fmartine@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.griffin@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).