diff options
author | Michele Paolino <m.paolino@virtualopensystems.com> | 2023-11-14 18:07:09 +0100 |
---|---|---|
committer | Michele Paolino <m.paolino@virtualopensystems.com> | 2023-12-13 10:27:55 +0000 |
commit | b05512b81bbe1c90b71da9c571e742f162fc0575 (patch) | |
tree | dea9b67ff4dae3e227943382dd7b0b0565dc39d1 /meta-egvirt/recipes-kernel/kernel-module-virtio-video/files/virtio_video_helpers.c | |
parent | 31d4011207be008333c1945f18bb922b13816462 (diff) |
CAN, GPIO, RNG vhost-devices for virtio-loopback [v6]quillback_16.92.0quillback/16.92.016.92.0
This patch adds key components of the viritio-loopback architecture:
- kernel-module-virtio-loopback: the virtio loopback kernel driver
- CAN, GPIO and RNG vhost-user devices from meta-virtualization (commit a215d8320edee0a317a6511e7e2efa5bba867486)
Notes:
- libgpiod, comes from meta-openembedded commit 3029554ceb0b0bb52a8d8ec3f0a75c5113662fe6
- cleaned eg-virt from unused drivers (kernel-module-virtio-video)
Bug-AGL: SPEC-4834
V2 changes:
- related meta-virtualization commit message added in the cover letter
- updated libgpio recipe to v2.1
- SPEC reference added in cover letter
v3
- add vhost-device-can preliminary version. This is placed here with
the objective to share the link when proposing the new device to
the rust-vmm/vhost-device community
- remove cargo-update-recipe-crates includes in bb file because it is
not supported by the rust mixin layer
- vhost-device folder README changes
v4
- fixed libgpiod required version
- tested ref hw and qemu x86/64 builds
- vsock, scsi and i2c rust devices removed from the build as they
are not yet integrated in virtiod-loopback
- cleaned-up kernel modules kernel-module-virtio-video and
gstreamer1.0-plugins-bad
- virtio-loopback-driver set to 2-or-later
v5
- Merge with Jan-Simon version v4:
- remove broken kernel-module-virtio-video
- use FEATURE_PACKAGES instead of IMAGE_INSTALL:append
- rename virtio-loopback-driver.bb to
kernel-module-virtio-loopback_git.bb for consistency
v6
- adding version in the title
- removing MODULE_GIT_REPOSITORY in kernel-modules
Change-Id: Id6cc58e777b9edad03b6c50d0dddaac8601edeaf
Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Diffstat (limited to 'meta-egvirt/recipes-kernel/kernel-module-virtio-video/files/virtio_video_helpers.c')
-rw-r--r-- | meta-egvirt/recipes-kernel/kernel-module-virtio-video/files/virtio_video_helpers.c | 289 |
1 files changed, 0 insertions, 289 deletions
diff --git a/meta-egvirt/recipes-kernel/kernel-module-virtio-video/files/virtio_video_helpers.c b/meta-egvirt/recipes-kernel/kernel-module-virtio-video/files/virtio_video_helpers.c deleted file mode 100644 index ac487053..00000000 --- a/meta-egvirt/recipes-kernel/kernel-module-virtio-video/files/virtio_video_helpers.c +++ /dev/null @@ -1,289 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* Driver for virtio video device. - * - * Copyright 2020 OpenSynergy GmbH. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -#include "virtio_video.h" - -struct virtio_video_convert_table { - uint32_t virtio_value; - uint32_t v4l2_value; -}; - -static struct virtio_video_convert_table level_table[] = { - { VIRTIO_VIDEO_LEVEL_H264_1_0, V4L2_MPEG_VIDEO_H264_LEVEL_1_0 }, - { VIRTIO_VIDEO_LEVEL_H264_1_1, V4L2_MPEG_VIDEO_H264_LEVEL_1_1 }, - { VIRTIO_VIDEO_LEVEL_H264_1_2, V4L2_MPEG_VIDEO_H264_LEVEL_1_2 }, - { VIRTIO_VIDEO_LEVEL_H264_1_3, V4L2_MPEG_VIDEO_H264_LEVEL_1_3 }, - { VIRTIO_VIDEO_LEVEL_H264_2_0, V4L2_MPEG_VIDEO_H264_LEVEL_2_0 }, - { VIRTIO_VIDEO_LEVEL_H264_2_1, V4L2_MPEG_VIDEO_H264_LEVEL_2_1 }, - { VIRTIO_VIDEO_LEVEL_H264_2_2, V4L2_MPEG_VIDEO_H264_LEVEL_2_2 }, - { VIRTIO_VIDEO_LEVEL_H264_3_0, V4L2_MPEG_VIDEO_H264_LEVEL_3_0 }, - { VIRTIO_VIDEO_LEVEL_H264_3_1, V4L2_MPEG_VIDEO_H264_LEVEL_3_1 }, - { VIRTIO_VIDEO_LEVEL_H264_3_2, V4L2_MPEG_VIDEO_H264_LEVEL_3_2 }, - { VIRTIO_VIDEO_LEVEL_H264_4_0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0 }, - { VIRTIO_VIDEO_LEVEL_H264_4_1, V4L2_MPEG_VIDEO_H264_LEVEL_4_1 }, - { VIRTIO_VIDEO_LEVEL_H264_4_2, V4L2_MPEG_VIDEO_H264_LEVEL_4_2 }, - { VIRTIO_VIDEO_LEVEL_H264_5_0, V4L2_MPEG_VIDEO_H264_LEVEL_5_0 }, - { VIRTIO_VIDEO_LEVEL_H264_5_1, V4L2_MPEG_VIDEO_H264_LEVEL_5_1 }, - { 0 }, -}; - -uint32_t virtio_video_level_to_v4l2(uint32_t level) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(level_table); idx++) { - if (level_table[idx].virtio_value == level) - return level_table[idx].v4l2_value; - } - - return 0; -} - -uint32_t virtio_video_v4l2_level_to_virtio(uint32_t v4l2_level) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(level_table); idx++) { - if (level_table[idx].v4l2_value == v4l2_level) - return level_table[idx].virtio_value; - } - - return 0; -} - -static struct virtio_video_convert_table profile_table[] = { - { VIRTIO_VIDEO_PROFILE_H264_BASELINE, - V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE }, - { VIRTIO_VIDEO_PROFILE_H264_MAIN, V4L2_MPEG_VIDEO_H264_PROFILE_MAIN }, - { VIRTIO_VIDEO_PROFILE_H264_EXTENDED, - V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED }, - { VIRTIO_VIDEO_PROFILE_H264_HIGH, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH }, - { VIRTIO_VIDEO_PROFILE_H264_HIGH10PROFILE, - V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_10 }, - { VIRTIO_VIDEO_PROFILE_H264_HIGH422PROFILE, - V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_422}, - { VIRTIO_VIDEO_PROFILE_H264_HIGH444PREDICTIVEPROFILE, - V4L2_MPEG_VIDEO_H264_PROFILE_HIGH_444_PREDICTIVE }, - { VIRTIO_VIDEO_PROFILE_H264_SCALABLEBASELINE, - V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_BASELINE }, - { VIRTIO_VIDEO_PROFILE_H264_SCALABLEHIGH, - V4L2_MPEG_VIDEO_H264_PROFILE_SCALABLE_HIGH }, - { VIRTIO_VIDEO_PROFILE_H264_STEREOHIGH, - V4L2_MPEG_VIDEO_H264_PROFILE_STEREO_HIGH }, - { VIRTIO_VIDEO_PROFILE_H264_MULTIVIEWHIGH, - V4L2_MPEG_VIDEO_H264_PROFILE_MULTIVIEW_HIGH }, - { 0 }, -}; - -uint32_t virtio_video_profile_to_v4l2(uint32_t profile) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(profile_table); idx++) { - if (profile_table[idx].virtio_value == profile) - return profile_table[idx].v4l2_value; - } - - return 0; -} - -uint32_t virtio_video_v4l2_profile_to_virtio(uint32_t v4l2_profile) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(profile_table); idx++) { - if (profile_table[idx].v4l2_value == v4l2_profile) - return profile_table[idx].virtio_value; - } - - return 0; -} - -static struct virtio_video_convert_table format_table[] = { - { VIRTIO_VIDEO_FORMAT_ARGB8888, V4L2_PIX_FMT_ARGB32 }, - { VIRTIO_VIDEO_FORMAT_BGRA8888, V4L2_PIX_FMT_ABGR32 }, - { VIRTIO_VIDEO_FORMAT_RGBA8888, V4L2_PIX_FMT_RGB32 }, - { VIRTIO_VIDEO_FORMAT_NV12, V4L2_PIX_FMT_NV12 }, - { VIRTIO_VIDEO_FORMAT_YUV420, V4L2_PIX_FMT_YUV420 }, - { VIRTIO_VIDEO_FORMAT_YVU420, V4L2_PIX_FMT_YVU420 }, - { VIRTIO_VIDEO_FORMAT_YUV422, V4L2_PIX_FMT_YUYV }, - { VIRTIO_VIDEO_FORMAT_MPEG2, V4L2_PIX_FMT_MPEG2 }, - { VIRTIO_VIDEO_FORMAT_MPEG4, V4L2_PIX_FMT_MPEG4 }, - { VIRTIO_VIDEO_FORMAT_H264, V4L2_PIX_FMT_H264 }, - { VIRTIO_VIDEO_FORMAT_HEVC, V4L2_PIX_FMT_HEVC }, - { VIRTIO_VIDEO_FORMAT_VP8, V4L2_PIX_FMT_VP8 }, - { VIRTIO_VIDEO_FORMAT_VP9, V4L2_PIX_FMT_VP9 }, - { 0 }, -}; - -uint32_t virtio_video_format_to_v4l2(uint32_t format) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(format_table); idx++) { - if (format_table[idx].virtio_value == format) - return format_table[idx].v4l2_value; - } - - return 0; -} - -uint32_t virtio_video_v4l2_format_to_virtio(uint32_t v4l2_format) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(format_table); idx++) { - if (format_table[idx].v4l2_value == v4l2_format) - return format_table[idx].virtio_value; - } - - return 0; -} - -static struct virtio_video_convert_table control_table[] = { - { VIRTIO_VIDEO_CONTROL_BITRATE, V4L2_CID_MPEG_VIDEO_BITRATE }, - { VIRTIO_VIDEO_CONTROL_PROFILE, V4L2_CID_MPEG_VIDEO_H264_PROFILE }, - { VIRTIO_VIDEO_CONTROL_LEVEL, V4L2_CID_MPEG_VIDEO_H264_LEVEL }, - { 0 }, -}; - -uint32_t virtio_video_control_to_v4l2(uint32_t control) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(control_table); idx++) { - if (control_table[idx].virtio_value == control) - return control_table[idx].v4l2_value; - } - - return 0; -} - -uint32_t virtio_video_v4l2_control_to_virtio(uint32_t v4l2_control) -{ - size_t idx; - - for (idx = 0; idx < ARRAY_SIZE(control_table); idx++) { - if (control_table[idx].v4l2_value == v4l2_control) - return control_table[idx].virtio_value; - } - - return 0; -} - -uint32_t virtio_video_get_format_from_virtio_profile(uint32_t virtio_profile) -{ - if (virtio_profile >= VIRTIO_VIDEO_PROFILE_H264_MIN && - virtio_profile <= VIRTIO_VIDEO_PROFILE_H264_MAX) - return VIRTIO_VIDEO_FORMAT_H264; - else if (virtio_profile >= VIRTIO_VIDEO_PROFILE_HEVC_MIN && - virtio_profile <= VIRTIO_VIDEO_PROFILE_HEVC_MAX) - return VIRTIO_VIDEO_FORMAT_HEVC; - else if (virtio_profile >= VIRTIO_VIDEO_PROFILE_VP8_MIN && - virtio_profile <= VIRTIO_VIDEO_PROFILE_VP8_MAX) - return VIRTIO_VIDEO_FORMAT_VP8; - else if (virtio_profile >= VIRTIO_VIDEO_PROFILE_VP9_MIN && - virtio_profile <= VIRTIO_VIDEO_PROFILE_VP9_MAX) - return VIRTIO_VIDEO_FORMAT_VP9; - - return 0; -} - -struct video_format *virtio_video_find_video_format(struct list_head *fmts_list, - uint32_t format) -{ - struct video_format *fmt = NULL; - - list_for_each_entry(fmt, fmts_list, formats_list_entry) { - if (fmt->desc.format == format) - return fmt; - } - - return NULL; -} - -void virtio_video_format_from_info(struct video_format_info *info, - struct v4l2_pix_format_mplane *pix_mp) -{ - int i; - - pix_mp->width = info->frame_width; - pix_mp->height = info->frame_height; - pix_mp->field = V4L2_FIELD_NONE; - pix_mp->colorspace = V4L2_COLORSPACE_REC709; - pix_mp->xfer_func = 0; - pix_mp->ycbcr_enc = 0; - pix_mp->quantization = 0; - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); - memset(pix_mp->plane_fmt[0].reserved, 0, - sizeof(pix_mp->plane_fmt[0].reserved)); - - pix_mp->num_planes = info->num_planes; - pix_mp->pixelformat = info->fourcc_format; - - for (i = 0; i < info->num_planes; i++) { - pix_mp->plane_fmt[i].bytesperline = - info->plane_format[i].stride; - pix_mp->plane_fmt[i].sizeimage = - info->plane_format[i].plane_size; - } -} - -void virtio_video_format_fill_default_info(struct video_format_info *dst_info, - struct video_format_info *src_info) -{ - memcpy(dst_info, src_info, sizeof(*dst_info)); -} - -void virtio_video_pix_fmt_sp2mp(const struct v4l2_pix_format *pix, - struct v4l2_pix_format_mplane *pix_mp) -{ - memset(pix_mp->reserved, 0, sizeof(pix_mp->reserved)); - memset(&pix_mp->plane_fmt[0].reserved, 0, - sizeof(pix_mp->plane_fmt[0].reserved)); - pix_mp->num_planes = 1; - pix_mp->width = pix->width; - pix_mp->height = pix->height; - pix_mp->pixelformat = pix->pixelformat; - pix_mp->field = pix->field; - pix_mp->plane_fmt[0].bytesperline = pix->bytesperline; - pix_mp->plane_fmt[0].sizeimage = pix->sizeimage; - pix_mp->colorspace = pix->colorspace; - pix_mp->flags = pix->flags; - pix_mp->ycbcr_enc = pix->ycbcr_enc; - pix_mp->quantization = pix->quantization; - pix_mp->xfer_func = pix->xfer_func; -} - -void virtio_video_pix_fmt_mp2sp(const struct v4l2_pix_format_mplane *pix_mp, - struct v4l2_pix_format *pix) -{ - pix->width = pix_mp->width; - pix->height = pix_mp->height; - pix->pixelformat = pix_mp->pixelformat; - pix->field = pix_mp->field; - pix->bytesperline = pix_mp->plane_fmt[0].bytesperline; - pix->sizeimage = pix_mp->plane_fmt[0].sizeimage; - pix->colorspace = pix_mp->colorspace; - pix->priv = 0; - pix->flags = pix_mp->flags; - pix->ycbcr_enc = pix_mp->ycbcr_enc; - pix->quantization = pix_mp->quantization; - pix->xfer_func = pix_mp->xfer_func; -} |