Peter Griffin <peter.grif...@linaro.org> writes:

> Signed-off-by: Peter Griffin <peter.grif...@linaro.org>
> ---
>  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 */

Is this a lifetime issue? 

Otherwise:

Reviewed-by: Alex Bennée <alex.ben...@linaro.org>

-- 
Alex Bennée

Reply via email to