diff options
Diffstat (limited to 'src/android/mm/generic_frame_buffer_allocator.cpp')
-rw-r--r-- | src/android/mm/generic_frame_buffer_allocator.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp index acb2fa2b..7ecef2c6 100644 --- a/src/android/mm/generic_frame_buffer_allocator.cpp +++ b/src/android/mm/generic_frame_buffer_allocator.cpp @@ -5,6 +5,7 @@ * generic_camera_buffer.cpp - Allocate FrameBuffer using gralloc API */ +#include <dlfcn.h> #include <memory> #include <vector> @@ -20,6 +21,7 @@ #include "../camera_device.h" #include "../frame_buffer_allocator.h" +#include "../hal_framebuffer.h" using namespace libcamera; @@ -32,8 +34,10 @@ class GenericFrameBufferData : public FrameBuffer::Private public: GenericFrameBufferData(struct alloc_device_t *allocDevice, - buffer_handle_t handle) - : allocDevice_(allocDevice), handle_(handle) + buffer_handle_t handle, + const std::vector<FrameBuffer::Plane> &planes) + : FrameBuffer::Private(planes), allocDevice_(allocDevice), + handle_(handle) { ASSERT(allocDevice_); ASSERT(handle_); @@ -69,20 +73,21 @@ class PlatformFrameBufferAllocator::Private : public Extensible::Private public: Private(CameraDevice *const cameraDevice) : cameraDevice_(cameraDevice), - hardwareModule_(cameraDevice->camera3Device()->common.module), + hardwareModule_(nullptr), allocDevice_(nullptr) { + hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hardwareModule_); ASSERT(hardwareModule_); } ~Private() override; - std::unique_ptr<libcamera::FrameBuffer> + std::unique_ptr<HALFrameBuffer> allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage); private: const CameraDevice *const cameraDevice_; - struct hw_module_t *const hardwareModule_; + const struct hw_module_t *hardwareModule_; struct alloc_device_t *allocDevice_; }; @@ -90,9 +95,10 @@ PlatformFrameBufferAllocator::Private::~Private() { if (allocDevice_) gralloc_close(allocDevice_); + dlclose(hardwareModule_->dso); } -std::unique_ptr<libcamera::FrameBuffer> +std::unique_ptr<HALFrameBuffer> PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage) @@ -135,9 +141,10 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat, offset += planeSize; } - return std::make_unique<FrameBuffer>( - std::make_unique<GenericFrameBufferData>(allocDevice_, handle), - planes); + return std::make_unique<HALFrameBuffer>( + std::make_unique<GenericFrameBufferData>( + allocDevice_, handle, planes), + handle); } PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION |