mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
android: camera_device: Don't assume all planes use the same fd
Now that libcamera correctly supports frame buffers with different dmabuf for each plane, remove the assumption that a single dmabuf is used. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
32635054bc
commit
a814205664
1 changed files with 6 additions and 19 deletions
|
@ -749,25 +749,6 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer
|
|||
PixelFormat pixelFormat,
|
||||
const Size &size)
|
||||
{
|
||||
FileDescriptor fd;
|
||||
/*
|
||||
* This assumes all the planes are in the same dmabuf.
|
||||
*
|
||||
* \todo Verify that this assumption holds, fstat() can be used to check
|
||||
* if two fds refer to the same dmabuf.
|
||||
*/
|
||||
for (int i = 0; i < camera3buffer->numFds; i++) {
|
||||
if (camera3buffer->data[i] != -1) {
|
||||
fd = FileDescriptor(camera3buffer->data[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fd.isValid()) {
|
||||
LOG(HAL, Fatal) << "No valid fd";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CameraBuffer buf(camera3buffer, pixelFormat, size, PROT_READ);
|
||||
if (!buf.isValid()) {
|
||||
LOG(HAL, Fatal) << "Failed to create CameraBuffer";
|
||||
|
@ -776,6 +757,12 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer
|
|||
|
||||
std::vector<FrameBuffer::Plane> planes(buf.numPlanes());
|
||||
for (size_t i = 0; i < buf.numPlanes(); ++i) {
|
||||
FileDescriptor fd{ camera3buffer->data[i] };
|
||||
if (!fd.isValid()) {
|
||||
LOG(HAL, Fatal) << "No valid fd";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
planes[i].fd = fd;
|
||||
planes[i].offset = buf.offset(i);
|
||||
planes[i].length = buf.size(i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue