[libcamera-devel] [PATCH] android: Fix improper file descriptor enumeration

Nicholas Roth nicholas at rothemail.net
Sun Dec 18 21:00:02 CET 2022


> I've replied to the bug report in
> https://bugs.libcamera.org/show_bug.cgi?id=172#c5. I'd like to
> investigate this further, as numFds != buf.numPlanes() doesn't sound
> right.

My understanding from the differences between
android/mm/generic_camera_buffer.cpp (Android) and
android/mm/cros_camera_buffer.cpp (ChromeOS) is that camera3 on
Android each handle buffers differently. See also the comment in
generic_camera_buffer.cpp:
```
/*
* As Android doesn't offer an API to query buffer layouts, assume for
* now that the buffer is backed by a single dmabuf, with planes being
* stored contiguously.
*/
```
I can't easily find "cros-camera/camera_buffer_manager.h" on the
public internet so I can't comment about that here.

> This will break operation on Chrome OS.
In that case, would you be open to the following?
pseudocode:
```
if (camera3buffer->numFds == buf.numPlanes()) {
  // Act as if there's one buffer per plane (old behavior / ChromeOS)
} else if (camera3buffer->numFds == 1) {
  // Act as if planes are stored contiguously in a single dmabuf (Android)
} else {
  // Log Fatal: Unsupported state: number of FDs
{camera3buffer->numFds} is not 1 (contiguous planes) and does not
match number of planes {buf.numPlanes()}. Failed to infer buffer
layout.
}
```

Let me know!

Thanks,
-Nicholas

P.S. I'm moving, and the initial plan is short-term rentals. I may not
have access to my PC for awhile. I've tried to put the steps required
to replicate my development environment in
https://docs.google.com/document/d/1Sly_VH3w6wFIdE72WXijQegoHZh8IxEnJ9m0hH7GodU/edit#
and will continue to be active here. I'm also trying to use an IP-KVM
to maintain access to my desktop but can't guarantee that will work.


More information about the libcamera-devel mailing list