summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/camera_device.cpp5
-rw-r--r--src/android/camera_device.h3
-rw-r--r--src/android/camera_request.h3
-rw-r--r--src/android/frame_buffer_allocator.h7
-rw-r--r--src/android/hal_framebuffer.cpp22
-rw-r--r--src/android/hal_framebuffer.h26
-rw-r--r--src/android/meson.build1
-rw-r--r--src/android/mm/cros_frame_buffer_allocator.cpp9
-rw-r--r--src/android/mm/generic_frame_buffer_allocator.cpp11
9 files changed, 72 insertions, 15 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index b20e389b..1f7ce440 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -30,6 +30,7 @@
#include "camera_hal_config.h"
#include "camera_ops.h"
#include "camera_request.h"
+#include "hal_framebuffer.h"
using namespace libcamera;
@@ -771,7 +772,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
return 0;
}
-std::unique_ptr<FrameBuffer>
+std::unique_ptr<HALFrameBuffer>
CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer,
PixelFormat pixelFormat, const Size &size)
{
@@ -794,7 +795,7 @@ CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer,
planes[i].length = buf.size(i);
}
- return std::make_unique<FrameBuffer>(planes);
+ return std::make_unique<HALFrameBuffer>(planes, camera3buffer);
}
int CameraDevice::processControls(Camera3RequestDescriptor *descriptor)
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 64050416..43ee0159 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -29,6 +29,7 @@
#include "camera_capabilities.h"
#include "camera_metadata.h"
#include "camera_stream.h"
+#include "hal_framebuffer.h"
#include "jpeg/encoder.h"
class Camera3RequestDescriptor;
@@ -83,7 +84,7 @@ private:
void stop() LIBCAMERA_TSA_EXCLUDES(stateMutex_);
- std::unique_ptr<libcamera::FrameBuffer>
+ std::unique_ptr<HALFrameBuffer>
createFrameBuffer(const buffer_handle_t camera3buffer,
libcamera::PixelFormat pixelFormat,
const libcamera::Size &size);
diff --git a/src/android/camera_request.h b/src/android/camera_request.h
index 37b6ae32..20aba79d 100644
--- a/src/android/camera_request.h
+++ b/src/android/camera_request.h
@@ -21,6 +21,7 @@
#include <hardware/camera3.h>
#include "camera_metadata.h"
+#include "hal_framebuffer.h"
class CameraBuffer;
class CameraStream;
@@ -44,7 +45,7 @@ public:
CameraStream *stream;
buffer_handle_t *camera3Buffer;
- std::unique_ptr<libcamera::FrameBuffer> frameBuffer;
+ std::unique_ptr<HALFrameBuffer> frameBuffer;
libcamera::UniqueFD fence;
Status status = Status::Success;
libcamera::FrameBuffer *internalBuffer = nullptr;
diff --git a/src/android/frame_buffer_allocator.h b/src/android/frame_buffer_allocator.h
index 5d2eeda1..e5c94922 100644
--- a/src/android/frame_buffer_allocator.h
+++ b/src/android/frame_buffer_allocator.h
@@ -13,9 +13,10 @@
#include <libcamera/base/class.h>
#include <libcamera/camera.h>
-#include <libcamera/framebuffer.h>
#include <libcamera/geometry.h>
+#include "hal_framebuffer.h"
+
class CameraDevice;
class PlatformFrameBufferAllocator : libcamera::Extensible
@@ -31,7 +32,7 @@ public:
* Note: The returned FrameBuffer needs to be destroyed before
* PlatformFrameBufferAllocator is destroyed.
*/
- std::unique_ptr<libcamera::FrameBuffer> allocate(
+ std::unique_ptr<HALFrameBuffer> allocate(
int halPixelFormat, const libcamera::Size &size, uint32_t usage);
};
@@ -44,7 +45,7 @@ PlatformFrameBufferAllocator::PlatformFrameBufferAllocator( \
PlatformFrameBufferAllocator::~PlatformFrameBufferAllocator() \
{ \
} \
-std::unique_ptr<libcamera::FrameBuffer> \
+std::unique_ptr<HALFrameBuffer> \
PlatformFrameBufferAllocator::allocate(int halPixelFormat, \
const libcamera::Size &size, \
uint32_t usage) \
diff --git a/src/android/hal_framebuffer.cpp b/src/android/hal_framebuffer.cpp
new file mode 100644
index 00000000..3f3d1ed1
--- /dev/null
+++ b/src/android/hal_framebuffer.cpp
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2022, Google Inc.
+ *
+ * hal_framebuffer.cpp - HAL Frame Buffer Handling
+ */
+
+#include "hal_framebuffer.h"
+
+#include <hardware/camera3.h>
+
+HALFrameBuffer::HALFrameBuffer(std::unique_ptr<Private> d,
+ buffer_handle_t handle)
+ : FrameBuffer(std::move(d)), handle_(handle)
+{
+}
+
+HALFrameBuffer::HALFrameBuffer(const std::vector<Plane> &planes,
+ buffer_handle_t handle)
+ : FrameBuffer(planes), handle_(handle)
+{
+}
diff --git a/src/android/hal_framebuffer.h b/src/android/hal_framebuffer.h
new file mode 100644
index 00000000..dc96a7e1
--- /dev/null
+++ b/src/android/hal_framebuffer.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2022, Google Inc.
+ *
+ * hal_framebuffer.h - HAL Frame Buffer Handling
+ */
+
+#pragma once
+
+#include "libcamera/internal/framebuffer.h"
+
+#include <hardware/camera3.h>
+
+class HALFrameBuffer final : public libcamera::FrameBuffer
+{
+public:
+ HALFrameBuffer(std::unique_ptr<Private> d,
+ buffer_handle_t handle);
+ HALFrameBuffer(const std::vector<Plane> &planes,
+ buffer_handle_t handle);
+
+ buffer_handle_t handle() const { return handle_; }
+
+private:
+ buffer_handle_t handle_;
+};
diff --git a/src/android/meson.build b/src/android/meson.build
index 1bba54de..b543c143 100644
--- a/src/android/meson.build
+++ b/src/android/meson.build
@@ -46,6 +46,7 @@ android_hal_sources = files([
'camera_ops.cpp',
'camera_request.cpp',
'camera_stream.cpp',
+ 'hal_framebuffer.cpp',
'jpeg/encoder_libjpeg.cpp',
'jpeg/exif.cpp',
'jpeg/post_processor_jpeg.cpp',
diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp
index 0665c77b..0a5c59f2 100644
--- a/src/android/mm/cros_frame_buffer_allocator.cpp
+++ b/src/android/mm/cros_frame_buffer_allocator.cpp
@@ -16,6 +16,7 @@
#include "../camera_device.h"
#include "../frame_buffer_allocator.h"
+#include "../hal_framebuffer.h"
#include "cros-camera/camera_buffer_manager.h"
using namespace libcamera;
@@ -48,11 +49,11 @@ public:
{
}
- std::unique_ptr<libcamera::FrameBuffer>
+ std::unique_ptr<HALFrameBuffer>
allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);
};
-std::unique_ptr<libcamera::FrameBuffer>
+std::unique_ptr<HALFrameBuffer>
PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
const libcamera::Size &size,
uint32_t usage)
@@ -81,8 +82,8 @@ PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
plane.length = cros::CameraBufferManager::GetPlaneSize(handle, i);
}
- return std::make_unique<FrameBuffer>(
- std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes));
+ return std::make_unique<HALFrameBuffer>(
+ std::make_unique<CrosFrameBufferData>(std::move(scopedHandle), planes), handle);
}
PUBLIC_FRAME_BUFFER_ALLOCATOR_IMPLEMENTATION
diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp
index 956623df..3750e1bf 100644
--- a/src/android/mm/generic_frame_buffer_allocator.cpp
+++ b/src/android/mm/generic_frame_buffer_allocator.cpp
@@ -20,6 +20,7 @@
#include "../camera_device.h"
#include "../frame_buffer_allocator.h"
+#include "../hal_framebuffer.h"
using namespace libcamera;
@@ -79,7 +80,7 @@ public:
~Private() override;
- std::unique_ptr<libcamera::FrameBuffer>
+ std::unique_ptr<HALFrameBuffer>
allocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);
private:
@@ -94,7 +95,7 @@ PlatformFrameBufferAllocator::Private::~Private()
gralloc_close(allocDevice_);
}
-std::unique_ptr<libcamera::FrameBuffer>
+std::unique_ptr<HALFrameBuffer>
PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,
const libcamera::Size &size,
uint32_t usage)
@@ -137,8 +138,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