[PATCH 0/7] rust: add initial v4l2 support

Daniel Almeida posted 7 patches 5 months, 3 weeks ago
MAINTAINERS                      |   8 ++
rust/bindings/bindings_helper.h  |   2 +
rust/helpers/helpers.c           |   1 +
rust/helpers/v4l2-device.c       |  30 +++++
rust/kernel/lib.rs               |   2 +
rust/kernel/media/mod.rs         |   9 ++
rust/kernel/media/v4l2/caps.rs   | 193 ++++++++++++++++++++++++++++
rust/kernel/media/v4l2/device.rs | 176 +++++++++++++++++++++++++
rust/kernel/media/v4l2/file.rs   | 164 ++++++++++++++++++++++++
rust/kernel/media/v4l2/ioctl.rs  |  92 +++++++++++++
rust/kernel/media/v4l2/mod.rs    |  20 +++
rust/kernel/media/v4l2/video.rs  | 269 +++++++++++++++++++++++++++++++++++++++
samples/rust/Kconfig             |  11 ++
samples/rust/Makefile            |   1 +
samples/rust/rust_driver_v4l2.rs | 145 +++++++++++++++++++++
15 files changed, 1123 insertions(+)
[PATCH 0/7] rust: add initial v4l2 support
Posted by Daniel Almeida 5 months, 3 weeks ago
Hi,

This topic has been discussed in the last two iterations of the Media
Summit and it has been dormant since. In my humble opinion, and owing
to all the progress that Rust in the kernel has seen since my last
attempts ([0], [1]), it is time to try again.

This series reduces the scope of the original attempt considerably. It
adds APIs to register v4l2 and video devices, and just enough to process
a single ioctl (VIDIOC_QUERYCAP), including basic support for v4l2_fh.
It was tested with v4l2-ctl.

It builds upon the platform work from Danilo and others in order to
offer a concise, platform-based driver sample that is currently the only
user of the abstractions. It draws from all the work done for DRM
devices and others and uses patterns that are known to work for other
subsystems.

I hope that we can all agree that there is little that can go wrong
here.

I've also added a separate MAINTAINERS entry, as the topic of
maintaining the Rust abstractions has been a major point of contention
so far. Hopefully this settles this issue in a satisfactory way for all
involved. In other words, no one is forced to contribute or alter their
workflow in any way, while those that want to contribute are invited to
do so. This approach has worked rather well so far.

I've decided to work on this once more after being told by a few people
that they would likely try to play with Rust v4l2 drivers if only they
did not have to write all of the infrastructure themselves. This work
(and subsequent patches) will pave the way for them.

Note: this is v1 and I'm aware that there are a few checkpatch and doc
issues which I will fix later.

[0]: https://lore.kernel.org/rust-for-linux/20230406215615.122099-1-daniel.almeida@collabora.com/
[1]: https://lore.kernel.org/rust-for-linux/20240227215146.46487-1-daniel.almeida@collabora.com/

---
Daniel Almeida (7):
      rust: media: add the media module
      rust: v4l2: add support for v4l2_device
      rust: v4l2: add support for video device nodes
      rust: v4l2: add support for v4l2 file handles
      rust: v4l2: add device capabilities
      rust: v4l2: add basic ioctl support
      rust: samples: add the v4l2 sample driver

 MAINTAINERS                      |   8 ++
 rust/bindings/bindings_helper.h  |   2 +
 rust/helpers/helpers.c           |   1 +
 rust/helpers/v4l2-device.c       |  30 +++++
 rust/kernel/lib.rs               |   2 +
 rust/kernel/media/mod.rs         |   9 ++
 rust/kernel/media/v4l2/caps.rs   | 193 ++++++++++++++++++++++++++++
 rust/kernel/media/v4l2/device.rs | 176 +++++++++++++++++++++++++
 rust/kernel/media/v4l2/file.rs   | 164 ++++++++++++++++++++++++
 rust/kernel/media/v4l2/ioctl.rs  |  92 +++++++++++++
 rust/kernel/media/v4l2/mod.rs    |  20 +++
 rust/kernel/media/v4l2/video.rs  | 269 +++++++++++++++++++++++++++++++++++++++
 samples/rust/Kconfig             |  11 ++
 samples/rust/Makefile            |   1 +
 samples/rust/rust_driver_v4l2.rs | 145 +++++++++++++++++++++
 15 files changed, 1123 insertions(+)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250815-v4l2-f7a80388cf70

Best regards,
-- 
Daniel Almeida <daniel.almeida@collabora.com>
Re: [PATCH 0/7] rust: add initial v4l2 support
Posted by Frederic Laing 1 month, 3 weeks ago
Hi all,

I’m new to contributing to the kernel and was reading through this 
thread. I would like to ask about the current status of this patch set. 
Is anyone still actively working on it?

If it’s unmaintained at the moment, I’d be happy to take over and work 
on addressing the review comments and resubmitting an updated version.

In case you're wondering why I am interested; I am currently working on 
camera software that utilizes the Microsoft Kinect 360 and V2 camera 
variants. Luckily there is already `drivers/media/usb/gspca/kinect.c` 
but it has some errors (like reporting invalid frame rates for color 
data) and design flaws that makes it impossible to stream depth and 
color data from a single device at the same time. I already got a new 
user space driver working in rust and would like to upstream it to the 
kernel to replace the older kinect driver written in C.

Thanks for your time,
Frederic Laing
Re: [PATCH 0/7] rust: add initial v4l2 support
Posted by Daniel Almeida 1 month, 3 weeks ago
Hi Frederic,

> On 16 Dec 2025, at 14:03, Frederic Laing <frederic.laing.development@gmail.com> wrote:
> 
> Hi all,
> 
> I’m new to contributing to the kernel and was reading through this thread. I would like to ask about the current status of this patch set. Is anyone still actively working on it?
> 
> If it’s unmaintained at the moment, I’d be happy to take over and work on addressing the review comments and resubmitting an updated version.
> 
> In case you're wondering why I am interested; I am currently working on camera software that utilizes the Microsoft Kinect 360 and V2 camera variants. Luckily there is already `drivers/media/usb/gspca/kinect.c` but it has some errors (like reporting invalid frame rates for color data) and design flaws that makes it impossible to stream depth and color data from a single device at the same time. I already got a new user space driver working in rust and would like to upstream it to the kernel to replace the older kinect driver written in C.
> 
> Thanks for your time,
> Frederic Laing

I did not hear anything from the media people so far.

Mauro, Hans?

— Daniel
Re: [PATCH 0/7] rust: add initial v4l2 support
Posted by Hans Verkuil 1 month, 3 weeks ago
On 17/12/2025 15:35, Daniel Almeida wrote:
> Hi Frederic,
> 
>> On 16 Dec 2025, at 14:03, Frederic Laing <frederic.laing.development@gmail.com> wrote:
>>
>> Hi all,
>>
>> I’m new to contributing to the kernel and was reading through this thread. I would like to ask about the current status of this patch set. Is anyone still actively working on it?
>>
>> If it’s unmaintained at the moment, I’d be happy to take over and work on addressing the review comments and resubmitting an updated version.
>>
>> In case you're wondering why I am interested; I am currently working on camera software that utilizes the Microsoft Kinect 360 and V2 camera variants. Luckily there is already `drivers/media/usb/gspca/kinect.c` but it has some errors (like reporting invalid frame rates for color data) and design flaws that makes it impossible to stream depth and color data from a single device at the same time. I already got a new user space driver working in rust and would like to upstream it to the kernel to replace the older kinect driver written in C.
>>
>> Thanks for your time,
>> Frederic Laing
> 
> I did not hear anything from the media people so far.
> 
> Mauro, Hans?

Speaking only for myself, there still isn't the time available for me at least
to support rust. We also need to get the multicommitter model started, which
is only pending on the documentation right now. That really should have been
done this year, and I really hope we can finish that early next year. We
need that up and running.

Basically the situation is unchanged from 2 (?) years ago: too much to do, not
enough time.

I don't see this changing for me for 2026.

Regards,

	Hans
Re: [PATCH 0/7] rust: add initial v4l2 support
Posted by Miguel Ojeda 5 months, 3 weeks ago
On Mon, Aug 18, 2025 at 7:51 AM Daniel Almeida
<daniel.almeida@collabora.com> wrote:
>
> I've decided to work on this once more after being told by a few people
> that they would likely try to play with Rust v4l2 drivers if only they
> did not have to write all of the infrastructure themselves. This work
> (and subsequent patches) will pave the way for them.

Glad to hear there is interest and to see you reviving this effort!

(Mentioning who is interested, if it is public, would be nice)

I see the media list Cc'd, but this should likely be sent to the
maintainers too.

Thanks!

Cheers,
Miguel