[libcamera-devel] [PATCH 13/15] android: camera_device: Use CameraStream buffers
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon Oct 5 14:43:19 CEST 2020
Hi Jacopo,
Thank you for the patch.
On Mon, Oct 05, 2020 at 01:46:47PM +0300, Laurent Pinchart wrote:
> From: Jacopo Mondi <jacopo at jmondi.org>
>
> Now that CameraStream that require internal buffer allocation
> have been instrumented with a FrameBuffer pool, use them to create
> intermediate buffers in the CameraDevice.
>
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> src/android/camera_device.cpp | 50 ++++++++++++++++++++++++++++-------
> 1 file changed, 40 insertions(+), 10 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 62307726aea9..186c9f724c3e 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1390,24 +1390,47 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
> descriptor->buffers[i].stream = camera3Buffers[i].stream;
> descriptor->buffers[i].buffer = camera3Buffers[i].buffer;
>
> - /* Software streams are handled after hardware streams complete. */
> - if (cameraStream->outputFormat() == HAL_PIXEL_FORMAT_BLOB)
> - continue;
> -
> /*
> - * Create a libcamera buffer using the dmabuf descriptors of
> - * the camera3Buffer for each stream. The FrameBuffer is
> - * directly associated with the Camera3RequestDescriptor for
> - * lifetime management only.
> + * Inspect the camera stream type, create buffers opportunely
> + * and add them to the Request if required.
> */
> - FrameBuffer *buffer = createFrameBuffer(*camera3Buffers[i].buffer);
> + FrameBuffer *buffer;
> + switch (cameraStream->type()) {
> + case CameraStream::Type::Mapped:
> + /*
> + * Mapped streams don't need buffers added to the
> + * Request.
> + */
> + continue;
> +
> + case CameraStream::Type::Direct:
> + /*
> + * Create a libcamera buffer using the dmabuf
> + * descriptors of the camera3Buffer for each stream and
> + * associate it with the Camera3RequestDescriptor for
> + * lifetime management only.
> + */
> + buffer = createFrameBuffer(*camera3Buffers[i].buffer);
> + descriptor->frameBuffers.emplace_back(buffer);
> + break;
> +
> + case CameraStream::Type::Internal:
> + /*
> + * Get the frame buffer from the CameraStream internal
> + * buffer pool.
> + *
> + * The buffer has to be returned to the CameraStream
> + * once it has been processed.
> + */
> + buffer = cameraStream->getBuffer();
> + break;
> + }
Blank line here.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> if (!buffer) {
> LOG(HAL, Error) << "Failed to create buffer";
> delete request;
> delete descriptor;
> return -ENOMEM;
> }
> - descriptor->frameBuffers.emplace_back(buffer);
>
> request->addBuffer(cameraStream->stream(), buffer);
> }
> @@ -1479,6 +1502,13 @@ void CameraDevice::requestComplete(Request *request)
> status = CAMERA3_BUFFER_STATUS_ERROR;
> continue;
> }
> +
> + /*
> + * Return the FrameBuffer to the CameraStream now that we're
> + * done processing it.
> + */
> + if (cameraStream->type() == CameraStream::Type::Internal)
> + cameraStream->putBuffer(buffer);
> }
>
> /* Prepare to call back the Android camera stack. */
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list