Skip to content

Focus using the media device

Draft: Not tested yet

Draft: Not squashed

This is a quick hack to start using the kernel framework for focus instead of banging raw i2c devices.

The main principle: the focus device node must be open as long as the program is running, or otherwise it will reset due to power saving.

The device is determined and commanded using v4l2-tools, because they expose a nice interface for it. For comparison, I previously created 200 lines of ugly code for the same before I realized the tools could do that already: https://source.puri.sm/dorota.czaplejewicz/nani/-/blob/master/media/main.rs

Following standard Megapixels resource management, the focus FD is released by the OS on program exit.

I wrote the extension in Rust just out of my proficiency with the relevant libraries (subprocess and string handling), reasoning that Millipixels is temporary anyway, and has relaxed readability requirements.

HACK: this presumes that the device is a Librem 5, and that this command returns a valid path: media-ctl -d platform:30b80000.csi -e "dw9714 3-000c".

Edited by Dorota Czaplejewicz

Merge request reports