android: Move buffer mapping to CameraStream

The destination buffer for the post-processing component is
currently first mapped in the CameraDevice class and then passed
to CameraStream which simply calls the post-processor interface.

Move the mapping to CameraStream::process() to tie the buffer
mapping to the lifetime of the CameraBuffer instance.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2021-02-24 12:50:40 +01:00
parent d5473c9626
commit a725baf4b3
4 changed files with 16 additions and 18 deletions

View file

@ -1857,19 +1857,8 @@ void CameraDevice::requestComplete(Request *request)
continue; continue;
} }
/* int ret = cameraStream->process(*src,
* \todo Buffer mapping and compression should be moved to a *descriptor->buffers_[i].buffer,
* separate thread.
*/
CameraBuffer dest(*descriptor->buffers_[i].buffer,
PROT_READ | PROT_WRITE);
if (!dest.isValid()) {
LOG(HAL, Error) << "Failed to map android blob buffer";
continue;
}
int ret = cameraStream->process(*src, &dest,
descriptor->settings_, descriptor->settings_,
resultMetadata.get()); resultMetadata.get());
if (ret) { if (ret) {

View file

@ -24,7 +24,6 @@
#include "libcamera/internal/log.h" #include "libcamera/internal/log.h"
#include "libcamera/internal/message.h" #include "libcamera/internal/message.h"
#include "camera_buffer.h"
#include "camera_metadata.h" #include "camera_metadata.h"
#include "camera_stream.h" #include "camera_stream.h"
#include "camera_worker.h" #include "camera_worker.h"

View file

@ -7,6 +7,7 @@
#include "camera_stream.h" #include "camera_stream.h"
#include "camera_buffer.h"
#include "camera_device.h" #include "camera_device.h"
#include "camera_metadata.h" #include "camera_metadata.h"
#include "jpeg/post_processor_jpeg.h" #include "jpeg/post_processor_jpeg.h"
@ -96,15 +97,24 @@ int CameraStream::configure()
} }
int CameraStream::process(const libcamera::FrameBuffer &source, int CameraStream::process(const libcamera::FrameBuffer &source,
libcamera::MappedBuffer *destination, buffer_handle_t camera3Dest,
const CameraMetadata &requestMetadata, const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata) CameraMetadata *resultMetadata)
{ {
if (!postProcessor_) if (!postProcessor_)
return 0; return 0;
return postProcessor_->process(source, destination, /*
requestMetadata, resultMetadata); * \todo Buffer mapping and processing should be moved to a
* separate thread.
*/
CameraBuffer dest(camera3Dest, PROT_READ | PROT_WRITE);
if (!dest.isValid()) {
LOG(HAL, Error) << "Failed to map android blob buffer";
return -EINVAL;
}
return postProcessor_->process(source, &dest, requestMetadata, resultMetadata);
} }
FrameBuffer *CameraStream::getBuffer() FrameBuffer *CameraStream::getBuffer()

View file

@ -120,7 +120,7 @@ public:
int configure(); int configure();
int process(const libcamera::FrameBuffer &source, int process(const libcamera::FrameBuffer &source,
libcamera::MappedBuffer *destination, buffer_handle_t camera3Dest,
const CameraMetadata &requestMetadata, const CameraMetadata &requestMetadata,
CameraMetadata *resultMetadata); CameraMetadata *resultMetadata);
libcamera::FrameBuffer *getBuffer(); libcamera::FrameBuffer *getBuffer();