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

Daniel Almeida posted 7 patches 1 month, 2 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 1 month, 2 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 Miguel Ojeda 1 month, 2 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