android: framebuffer: Add HALFrameBuffer and replace FrameBuffer
HALFrameBuffer is derived from FrameBuffer with access to buffer_handle_t, which is needed for JEA usage. Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Han-Lin Chen <hanlinchen@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
4843bfa66d
commit
b64fa1363c
9 changed files with 72 additions and 15 deletions
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) \
|
||||
|
|
22
src/android/hal_framebuffer.cpp
Normal file
22
src/android/hal_framebuffer.cpp
Normal file
|
@ -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)
|
||||
{
|
||||
}
|
26
src/android/hal_framebuffer.h
Normal file
26
src/android/hal_framebuffer.h
Normal file
|
@ -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_;
|
||||
};
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue