From: Daniel Almeida <daniel.almeida@collabora.com>
To: wedsonaf@gmail.com, ojeda@kernel.org, mchehab@kernel.org,
hverkuil@xs4all.nl
Cc: Daniel Almeida <daniel.almeida@collabora.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org, kernel@collabora.com
Subject: [PATCH 0/6] Initial Rust V4L2 support
Date: Thu, 6 Apr 2023 18:56:09 -0300 [thread overview]
Message-ID: <20230406215615.122099-1-daniel.almeida@collabora.com> (raw)
Hi all, this is my first attempt at adding Rust support to the
media subsystem.
It adds just enough support to write a clone of the virtio-camera
prototype written by my colleague, Dmitry Osipenko, available at [0].
Basically, there's support for video_device_register,
v4l2_device_register and for some ioctls in v4l2_ioctl_ops. There is
also some initial vb2 support, alongside some wrappers for some types
found in videodev2.h.
I wrote a sample Rust driver just to prove that this probes, and
that you get a message on dmesg whenever an ioctl is called.
As there is no actual implementation for any of the ioctls, this module
can misbehave with some programs. I can work around this in a future
submission.
Note that this is based on the rust branch, as opposed to rust-next. The
reasoning is simple: I expect this series to just kickstart some
discussion around the subject. Actual upstreaming can come up much
later, at which point I can rebase on the rust branch.
Lastly, the origins of this series trace back to a v4l2 virtIO driver I
was writing in Rust. As the project was eventually shelved for other
reasons, I picked both the virtIO and the v4l2 bindings into their own
patches which I am now in the process of submitting. This is to say that
I tested this code with said driver and CrosVM in the past, and it
worked ok.
Please let me know your thoughts.
[0]: https://gitlab.collabora.com/dmitry.osipenko/linux-kernel-rd/-/commit/055a2c322e931a8b388f864f1db81bbdfd525602
Daniel Almeida (6):
rust: media: add the media module
rust: media: add initial videodev2.h abstractions
rust: sync: introduce FfiMutex
rust: media: videobuf2: add a videobuf2 abstraction
rust: media: add {video|v4l2}_device_register support
rust: media: add v4l2 rust sample
rust/bindings/bindings_helper.h | 8 +
rust/kernel/lib.rs | 2 +
rust/kernel/media/mod.rs | 6 +
rust/kernel/media/v4l2/capabilities.rs | 80 ++++
rust/kernel/media/v4l2/dev.rs | 369 +++++++++++++++
rust/kernel/media/v4l2/device.rs | 115 +++++
rust/kernel/media/v4l2/enums.rs | 135 ++++++
rust/kernel/media/v4l2/format.rs | 178 ++++++++
rust/kernel/media/v4l2/framesize.rs | 176 +++++++
rust/kernel/media/v4l2/inputs.rs | 104 +++++
rust/kernel/media/v4l2/ioctls.rs | 608 +++++++++++++++++++++++++
rust/kernel/media/v4l2/mmap.rs | 81 ++++
rust/kernel/media/v4l2/mod.rs | 13 +
rust/kernel/media/videobuf2/core.rs | 552 ++++++++++++++++++++++
rust/kernel/media/videobuf2/mod.rs | 5 +
rust/kernel/sync.rs | 1 +
rust/kernel/sync/ffi_mutex.rs | 70 +++
samples/rust/Kconfig | 11 +
samples/rust/Makefile | 1 +
samples/rust/rust_v4l2.rs | 403 ++++++++++++++++
20 files changed, 2918 insertions(+)
create mode 100644 rust/kernel/media/mod.rs
create mode 100644 rust/kernel/media/v4l2/capabilities.rs
create mode 100644 rust/kernel/media/v4l2/dev.rs
create mode 100644 rust/kernel/media/v4l2/device.rs
create mode 100644 rust/kernel/media/v4l2/enums.rs
create mode 100644 rust/kernel/media/v4l2/format.rs
create mode 100644 rust/kernel/media/v4l2/framesize.rs
create mode 100644 rust/kernel/media/v4l2/inputs.rs
create mode 100644 rust/kernel/media/v4l2/ioctls.rs
create mode 100644 rust/kernel/media/v4l2/mmap.rs
create mode 100644 rust/kernel/media/v4l2/mod.rs
create mode 100644 rust/kernel/media/videobuf2/core.rs
create mode 100644 rust/kernel/media/videobuf2/mod.rs
create mode 100644 rust/kernel/sync/ffi_mutex.rs
create mode 100644 samples/rust/rust_v4l2.rs
--
2.40.0
next reply other threads:[~2023-04-06 21:58 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 21:56 Daniel Almeida [this message]
2023-04-06 21:56 ` [PATCH 1/6] rust: media: add the media module Daniel Almeida
2023-04-06 21:56 ` [PATCH 2/6] rust: media: add initial videodev2.h abstractions Daniel Almeida
2023-04-06 21:56 ` [PATCH 3/6] rust: sync: introduce FfiMutex Daniel Almeida
2023-04-06 21:56 ` [PATCH 4/6] rust: media: videobuf2: add a videobuf2 abstraction Daniel Almeida
2023-04-06 21:56 ` [PATCH 5/6] rust: media: add {video|v4l2}_device_register support Daniel Almeida
2023-04-06 21:56 ` [PATCH 6/6] rust: media: add v4l2 rust sample Daniel Almeida
2023-04-08 19:06 ` [PATCH 0/6] Initial Rust V4L2 support Daniel Almeida
2023-04-08 19:43 ` Hans Petter Selasky
2023-04-09 14:10 ` Daniel Almeida
2023-04-10 18:59 ` Hans Petter Selasky
2023-04-10 23:41 ` Miguel Ojeda
2023-04-11 9:52 ` Hans Petter Selasky
2023-04-11 12:36 ` Miguel Ojeda
2023-04-11 13:15 ` Hans Petter Selasky
2023-04-11 14:19 ` Miguel Ojeda
2023-04-11 15:33 ` Hans Petter Selasky
2023-04-11 19:22 ` Miguel Ojeda
2023-04-12 10:00 ` Hans Petter Selasky
2023-04-12 10:13 ` Greg KH
2023-04-12 10:23 ` Hans Petter Selasky
2023-04-10 23:40 ` Miguel Ojeda
2023-04-26 14:31 ` Enrico Weigelt, metux IT consult
2023-04-10 22:46 ` Deborah Brouwer
2023-04-11 14:22 ` Miguel Ojeda
2023-04-12 2:58 ` Theodore Ts'o
2023-04-12 12:21 ` Miguel Ojeda
2023-04-12 12:38 ` Morten Linderud
2023-04-12 18:44 ` Nicolas Dufresne
[not found] ` <aae753d6-6874-4f91-e7ba-bd6c77f07b62@metux.net>
2023-04-26 15:33 ` Miguel Ojeda
2023-04-11 7:51 ` Hans Verkuil
2023-04-11 12:02 ` Miguel Ojeda
2023-04-11 12:49 ` Willy Tarreau
2023-04-11 14:01 ` Daniel Almeida
2023-04-11 14:13 ` Miguel Ojeda
2023-04-11 16:52 ` Willy Tarreau
2023-04-11 19:27 ` Miguel Ojeda
2023-04-11 20:26 ` Willy Tarreau
2023-04-11 22:14 ` Miguel Ojeda
[not found] ` <0da49a77-14d8-cb9d-e36d-985699746b6b@metux.net>
2023-04-26 16:05 ` Miguel Ojeda
2023-04-26 0:32 ` Laurent Pinchart
[not found] ` <57ec90ad-8535-fa7d-d6de-d5c1d06f37d3@metux.net>
2023-04-26 13:29 ` Laurent Pinchart
2023-04-26 16:18 ` Miguel Ojeda
2023-04-26 16:35 ` Laurent Pinchart
2023-04-26 17:14 ` Daniel Almeida
2023-04-26 17:25 ` Laurent Pinchart
2023-05-01 20:10 ` Nicolas Dufresne
2023-05-01 20:17 ` Asahi Lina
2023-05-01 20:19 ` Nicolas Dufresne
2023-05-02 19:13 ` Miguel Ojeda
2023-05-03 11:00 ` Daniel Almeida
2023-04-26 19:58 ` Sakari Ailus
2023-07-05 6:40 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230406215615.122099-1-daniel.almeida@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=hverkuil@xs4all.nl \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).