mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-15 16:35:06 +03:00
android: camera_device: Simplify FrameBuffer construction from a buffer_handle_t
Move the code which constructs a FrameBuffer from the Android buffer handle to it's own function to simplify the code flow and readability. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
0a9244ed37
commit
74ab442dcf
2 changed files with 20 additions and 16 deletions
|
@ -1011,6 +1011,24 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer)
|
||||||
|
{
|
||||||
|
std::vector<FrameBuffer::Plane> planes;
|
||||||
|
for (unsigned int i = 0; i < 3; i++) {
|
||||||
|
FrameBuffer::Plane plane;
|
||||||
|
plane.fd = FileDescriptor(camera3buffer->data[i]);
|
||||||
|
/*
|
||||||
|
* Setting length to zero here is OK as the length is only used
|
||||||
|
* to map the memory of the plane. Libcamera do not need to poke
|
||||||
|
* at the memory content queued by the HAL.
|
||||||
|
*/
|
||||||
|
plane.length = 0;
|
||||||
|
planes.push_back(std::move(plane));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FrameBuffer(std::move(planes));
|
||||||
|
}
|
||||||
|
|
||||||
int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)
|
int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)
|
||||||
{
|
{
|
||||||
StreamConfiguration *streamConfiguration = &config_->at(0);
|
StreamConfiguration *streamConfiguration = &config_->at(0);
|
||||||
|
@ -1064,22 +1082,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
|
||||||
* Create a libcamera buffer using the dmabuf descriptors of the first
|
* Create a libcamera buffer using the dmabuf descriptors of the first
|
||||||
* and (currently) only supported request buffer.
|
* and (currently) only supported request buffer.
|
||||||
*/
|
*/
|
||||||
const buffer_handle_t camera3Handle = *camera3Buffers[0].buffer;
|
FrameBuffer *buffer = createFrameBuffer(*camera3Buffers[0].buffer);
|
||||||
|
|
||||||
std::vector<FrameBuffer::Plane> planes;
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
FrameBuffer::Plane plane;
|
|
||||||
plane.fd = FileDescriptor(camera3Handle->data[i]);
|
|
||||||
/*
|
|
||||||
* Setting length to zero here is OK as the length is only used
|
|
||||||
* to map the memory of the plane. Libcamera do not need to poke
|
|
||||||
* at the memory content queued by the HAL.
|
|
||||||
*/
|
|
||||||
plane.length = 0;
|
|
||||||
planes.push_back(std::move(plane));
|
|
||||||
}
|
|
||||||
|
|
||||||
FrameBuffer *buffer = new FrameBuffer(std::move(planes));
|
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
LOG(HAL, Error) << "Failed to create buffer";
|
LOG(HAL, Error) << "Failed to create buffer";
|
||||||
delete descriptor;
|
delete descriptor;
|
||||||
|
|
|
@ -70,6 +70,7 @@ private:
|
||||||
|
|
||||||
int initializeStreamConfigurations();
|
int initializeStreamConfigurations();
|
||||||
std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();
|
std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();
|
||||||
|
libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);
|
||||||
void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
|
void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
|
||||||
void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
|
void notifyError(uint32_t frameNumber, camera3_stream_t *stream);
|
||||||
libcamera::PixelFormat toPixelFormat(int format);
|
libcamera::PixelFormat toPixelFormat(int format);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue