Skip to content

Conversation

@FreddyFunk
Copy link
Collaborator

@FreddyFunk FreddyFunk commented Dec 2, 2025

implements #93

@FreddyFunk FreddyFunk force-pushed the feature/libcamera-backend branch from 394aad9 to d2c58c1 Compare December 16, 2025 08:57
@FriederHannenheim
Copy link

FriederHannenheim commented Jan 6, 2026

I was able to test this on my Pixel 3a running PostmarketOS. During compilation I got a lot of errors like this

error[E0308]: mismatched types
    --> src/backends/camera/pipewire/enumeration.rs:276:43
     |
 276 | ...afe { libc::ioctl(fd, VIDIOC_QUERYCAP, &mut cap as *mut V4l2Capability) };
     |          -----------     ^^^^^^^^^^^^^^^ expected `i32`, found `u64`
     |          |
     |          arguments to this function are incorrect
     |
note: function defined here
    --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.178/src/unix/linux_like/mod.rs:1693:20
     |
1693 |             pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int;
     |                    ^^^^^
help: you can convert a `u64` to an `i32` and panic if the converted value doesn't fit
     |
 276 |     let result = unsafe { libc::ioctl(fd, VIDIOC_QUERYCAP.try_into().unwrap(), &mut cap as *mut V4l2Capability) };
     |             

which I just fixed with the suggested .try_into().unwrap(). After that I was able to run the app and get the front camera to work. I could take pictures and record video but I was unable to switch to the back camera.

Here a picture taken using the app (bad quality because low light and cameras not being fully supported on the Pixel 3a):
IMG_20260106_175827

The picture and the camera preview are sideways using libcamera

@FreddyFunk
Copy link
Collaborator Author

Glad to hear that! :) I have a few things on my backlog before working on libcamera support again, but they benefit phone cameras as well (like HDR+, raw Bayer sensor data support, some Linux kernel V4L2 improvements, etc).

If anyone can recommend a phone with decent Linux camera drivers for testing, this would be great. Or if a Linux phone company would like to send me a testing device, that would be even better. I already bought a used Pixel 3A and OnePlus 6T a few weeks ago for postmarketOS development.

@FriederHannenheim
Copy link

FriederHannenheim commented Jan 6, 2026

Very nice those two have good-ish camera support. The other option would be the Librem 5.

Why does the pipewire backend not work on phones though? Gnome camera uses pipewire and it works.

@FreddyFunk
Copy link
Collaborator Author

This could have many causes. Best case would some misconfiguration on the pipewire pipelines that are set up by this app. Unfortunately, direct pipewire configurations can sometimes be hard and not really documented. I spent literarily days getting pipewire to reliably work for MJPEG encoded webcam streams that have higher than 4K resolution.

@FriederHannenheim
Copy link

Looks like Gnome Camera is also written in Rust. Maybe you could see what they did to get it working: https://gitlab.gnome.org/GNOME/snapshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants