Daniel Almeida of Collabora has released the Linux kernel** 4 rewritten VP9 codec library in the Linux 2 (V4L2) subsystem. By using rust instead of the existing c**, this should result in better memory safety and better resilience to potential issues in the existing **.
Request a comment"Port the VP9 library into Rust and convert the rkvdec and hantro drivers to use the Rust version.
Fluendo's Fluster tests have shown that the results are the same regardless of whether you use Rust or the C version of **.
Almeida commented on the RFC patch as follows:
We've said a lot about drivers on different occasions and I feel the current consensus is to wait. That's why I'm proposing a different approach: porting our codec library into Rust. In my opinion, these components could benefit greatly from Rust because they implement complex algorithms while also processing data received from user space via v4l2 control. These algorithms benefit from Rust's memory safety by using data received from user space to index large arrays.He went on to add in the patch cover letter:The first thing about ** is that it doesn't contain any binding layers.
Rust here also provides a C API for C drivers. This C API is automatically generated by cbindgen, and I've provided instructions on how to generate it. We can even use functions from both the C library and the Rust library, since ABI is the same.
The above is very useful because it means that we can convert a given library piece by section if necessary. The C driver will work fine via the C API, while any new Rust driver will benefit from the native Rust interface.
Finally, please note that this is only a proof of concept, and if the response is good, we can roll out an official patch (including all relevant content)."Those interested can find these RFC patches on the kernel mailing list, while awaiting feedback from other Linux kernel upstream stakeholders.