raymanfx / libv4l-rs

Video4Linux2 bindings for Rust
MIT License
155 stars 65 forks source link

Feature/custom userptr allocator to take into account special hardware-aligment requirements for some v4l devices #103

Open molysgaard opened 5 months ago

molysgaard commented 5 months ago

Hi there.

When using the userptr io-mode for V4L, the v4l driver can have special alignment requirements for the buffers that are given to it. I hit this limitation by experimenting with the V4L2 drivers for CSI cameras on Nvidia Tegra devices.

This PR tries to allow for specifying custom allocators for the crate in a backward compatible way, and I thought it would be nice to contribute it back to upstream. If there are any things you would like different, or require changes, please don't hesitate to mention it.

I was unsure where to base this change on, so I based it on the last released version of the crate. I see that main has moved since then.

Regards Morten

raymanfx commented 3 months ago

Hi, sorry for the delayed response. I agree something along these lines is needed for the cases you mention. Though I think I would prefer a less invasive approach - let the user provide the memory. The library should provide the memory constraints (e.g. size, caching etc) and take in memory provided by the application.

This mandates a minor re-architecture that I'm working on at the moment. There have been attempts in the past, but I never got around to finish the work and release it. Let's see whether it can be done this time without being drowned in other real-life events (or vacation ..)

molysgaard commented 3 months ago

Hi. Yeah, letting the client application supply the memory is a better overall architecture. The reason my MR is as it is is that I was afraid to create a large architectural change. I would be very happy if you are able to pull off such a change!