[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DARCGOT0TKN8.OC6467QNJA9O@gmail.com>
Date: Fri, 20 Jun 2025 21:03:34 +0900
From: "Alexandre Courbot" <gnurou@...il.com>
To: "Mauro Carvalho Chehab" <mchehab+huawei@...nel.org>
Cc: "Albert Esteve" <aesteve@...hat.com>, "Michael S. Tsirkin"
<mst@...hat.com>, "Mauro Carvalho Chehab" <mchehab@...nel.org>, "Hans
Verkuil" <hverkuil@...all.nl>, "Jason Wang" <jasowang@...hat.com>, "Xuan
Zhuo" <xuanzhuo@...ux.alibaba.com>, Eugenio Pérez
<eperezma@...hat.com>, <gurchetansingh@...gle.com>,
<daniel.almeida@...labora.com>, <adelva@...gle.com>,
<changyeon@...gle.com>, <nicolas.dufresne@...labora.com>,
<linux-kernel@...r.kernel.org>, <linux-media@...r.kernel.org>,
<virtualization@...ts.linux.dev>
Subject: Re: [PATCH v3] media: add virtio-media driver
Hi Mauro,
Really appreciating the time you are spending reviewing and testing
this! m(__)m Thanks also for sharing your script, I've learned a few
things I didn't know about crosvm. :P
On Thu Jun 19, 2025 at 12:05 AM JST, Mauro Carvalho Chehab wrote:
<snip>
>> > Found how to setup cpus and memory, but didn't find a way to setup
>> > network without running it as root. The gpu parameter has several
>> > options. Not sure what backend works well for media apps like qv4l2,
>> > camorama, X11, ...
>>
>> I'm afraid getting GPU and graphics in general to work is more involved
>> and tricky on a regular Linux setup (crosvm was primarily designed for
>> ChromeOS). If you really need it I can do some more research; most of my
>> tests have been done using v4l2-ctl or ffmpeg and saving the output on
>> disk for later inspection.
>
> It was actually easier than what I expected, but it had to run
> as root. Due to that, I had to move it to a test machine that I
> use just for such kind of tests. I updated it to the Ubuntu
> version 24.10, but crossvm refused to build even. I end needing
> to install rust via rustup, as only version 1.81.0 had what it is
> required to run with the needed features (network, media and gpu).
Yes, rustup is the preferred way (if not traditional from the point of
view of Linux distros) to get the latest Rust toolchain.
>
>> >> > Btw, on a quick test with v4l2-compliance, something looks weird:
>> >> > I started a camera application at the host. Still, v4l2-compliance
>> >> > said successfully excecuted mmap:
>> >> >
>> >> > Streaming ioctls:
>> >> > test read/write: OK (Not Supported)
>> >> > test blocking wait: OK
>> >> > test MMAP (no poll): OK
>> >> > test MMAP (select): OK
>> >> > Vide[2025-06-17T08:44:49.177972817+00:00 ERROR virtio_media::ioctl] VIDIOC_REQBUFS: memory type DmaBuf is currently unsupported
>> >> > [2025-06-17T08:44:49.178164554+00:00 ERROR virtio_media::ioctl] VIDIOC_REQBUFS: memory type DmaBuf is currently unsupported
>> >> > o Capturtest MMAP (epoll): OK
>> >> > test USERPTR (no poll): OK (Not Supported)
>> >> > test USERPTR (select): OK (Not Supported)
>> >> > test DMABUF (no poll): OK (Not Supported)
>> >> > test DMABUF (select): OK (Not Supported)
>> >> >
>> >> > Which doesn't make any sense, as the host OS should not allow access
>> >> > to mmap while streaming.
>> >>
>> >> Ah, this was with the "simple" device, not with the proxy one.
>> >> With the proxy one, I'm getting:
>> >>
>> >> # v4l2-ctl --all
>> >> Driver Info:
>> >> Driver name : virtio-media
>> >> Card type : usb video: usb video
>> >> Bus info : platform:virtio-media
>> >> Driver version : 6.15.0
>> >> Capabilities : 0x84200001
>> >> Video Capture
>> >> Streaming
>> >> Extended Pix Format
>> >> Device Capabilities
>> >> Device Caps : 0x04200001
>> >> Video Capture
>> >> Streaming
>> >> Extended Pix Format
>> >> Priority: 2
>> >> Video input : 0 (Camera 1: ok)
>> >> Format Video Capture:
>> >> Width/Height : 1280/720
>> >> Pixel Format : 'MJPG' (Motion-JPEG)
>> >> Field : None
>> >> Bytes per Line : 0
>> >> Size Image : 1843200
>> >> Colorspace : sRGB
>> >> Transfer Function : Rec. 709
>> >> YCbCr/HSV Encoding: ITU-R 601
>> >> Quantization : Default (maps to Full Range)
>> >> Flags :
>> >> Crop Capability Video Capture:
>> >> Bounds : Left 0, Top 0, Width 1280, Height 720
>> >> Default : Left 0, Top 0, Width 1280, Height 720
>> >> Pixel Aspect: 1/1
>> >> Selection Video Capture: crop_default, Left 0, Top 0, Width 1280, Height 720, Flags:
>> >> Selection Video Capture: crop_bounds, Left 0, Top 0, Width 1280, Height 720, Flags:
>> >> Streaming Parameters Video Capture:
>> >> Capabilities : timeperframe
>> >> Frames per second: 30.000 (30/1)
>> >> Read buffers : 0
>> >>
>> >> User Controls
>> >>
>> >> brightness 0x00980900 (int) : min=-128 max=127 step=1 default=-11 value=-11
>> >> contrast 0x00980901 (int) : min=0 max=255 step=1 default=148 value=148
>> >> saturation 0x00980902 (int) : min=0 max=255 step=1 default=180 value=180
>> >> hue 0x00980903 (int) : min=-128 max=127 step=1 default=0 value=0
>> >>
>> >> # v4l2-compliance -d0 -s
>> >>
>> >> Streaming ioctls:
>> >> test read/write: OK (Not Supported)
>> >> test blocking wait: OK
>> >> fail: v4l2-test-buffers.cpp(1345): node->streamon(q.g_type()) != EINVAL
>> >> test MMAP (no poll): FAIL
>> >> fail: v4l2-test-buffers.cpp(1345): node->streamon(q.g_type()) != EINVAL
>> >> test MMAP (select): FAIL
>> >> fail: v4l2-test-buffers.cpp(1345): node->streamon(q.g_type()) != EINVAL
>> >> test MMAP (epoll): FAIL
>> >> test USERPTR (no poll): OK (Not Supported)
>> >> test USERPTR (select): OK (Not Supported)
>> >> [2025-06-17T08:55:20.768760714+00:00 ERROR virtio_media::ioctl] VIDIOC_REQBUFS: memory type DmaBuf is currently unsupported
>> >> test DMABUF (no poll): OK (Not Supported)
>> >> [2025-06-17T08:55:20.769745707+00:00 ERROR virtio_media::ioctl] VIDIOC_REQBUFS: memory type DmaBuf is currently unsupported
>> >> test DMABUF (select): OK (Not Supported)
>> >>
>> >> At the host, I'm getting:
>> >>
>> >> Streaming ioctls:
>> >> test read/write: OK (Not Supported)
>> >> test blocking wait: OK
>> >> fail: ../utils/v4l2-compliance/v4l2-test-buffers.cpp(1346): node->streamon(q.g_type()) != EINVAL
>> >> test MMAP (no poll): FAIL
>> >> fail: ../utils/v4l2-compliance/v4l2-test-buffers.cpp(1346): node->streamon(q.g_type()) != EINVAL
>> >> test MMAP (select): FAIL
>> >> fail: ../utils/v4l2-compliance/v4l2-test-buffers.cpp(1346): node->streamon(q.g_type()) != EINVAL
>> >> test MMAP (epoll): FAIL
>> >> test USERPTR (no poll): OK
>> >> test USERPTR (select): OK
>> >> test DMABUF: Cannot test, specify --expbuf-device
>>
>> These logs look ok to me: the MMAP tests are failing on the host, so
>> they are also expected to fail on the guest (still I expect regular
>> streaming to work on both). USERPTR is not supported on the guest, as
>> per your request to not support this memory type in new drivers. DMABUF
>> is not supported at all at the moment.
>
> In the specific case of a virtio driver, while it is OK for the first
> versions to support MMAP only, USERPTR support could make sense, as
> this is not a real driver for a certain hardware, but instead it is
> replicating at the guest whatever the host driver has, which may or
> may not have MMAP.
There is a module parameter (allow_userptr) which you can set to enable
USERPTR buffers, in case you want to try this as well.
>
> That's said, I don't recall any driver with USERPTR and without MMAP
> those days. I did a quick check: VB2 devices always seem to have MMAP.
>
> -
>
> There is one case where only read ioctl is supported: pvrusb2, which
> is probably not interesting enough those days, but IMHO, for the few
> cases where a device can't be used at the guest due to the lack of a
> compatible streaming API, virtio-media should not expose it to the
> guest and/or issue an error or warning.
I've never tested virtio-media with a PVR driver, to be honest. :) Only
regular cameras and video accelerators. So I cannot guarantee other
kinds of devices will work properly - there may also be limitations in
the crosvm proxy device that will prevent these devices from working.
Just a heads-up.
Powered by blists - more mailing lists