diff options
Diffstat (limited to 'src/android')
47 files changed, 376 insertions, 152 deletions
diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp index da836bae..a5ad2374 100644 --- a/src/android/camera3_hal.cpp +++ b/src/android/camera3_hal.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera3_hal.cpp - Android Camera HALv3 module + * Android Camera HALv3 module */ #include <hardware/camera_common.h> diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h index b4531c80..96669962 100644 --- a/src/android/camera_buffer.h +++ b/src/android/camera_buffer.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * camera_buffer.h - Frame buffer handling interface definition + * Frame buffer handling interface definition */ #pragma once diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6f197eb8..6f4d48de 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * camera_capabilities.cpp - Camera static properties manager + * Camera static properties manager */ #include "camera_capabilities.h" @@ -31,13 +31,20 @@ namespace { /* * \var camera3Resolutions - * \brief The list of image resolutions defined as mandatory to be supported by - * the Android Camera3 specification + * \brief The list of image resolutions commonly supported by Android + * + * The following are defined as mandatory to be supported by the Android + * Camera3 specification: (320x240), (640x480), (1280x720), (1920x1080). + * + * The following 4:3 resolutions are defined as optional, but commonly + * supported by Android devices: (1280x960), (1600x1200). */ const std::vector<Size> camera3Resolutions = { { 320, 240 }, { 640, 480 }, { 1280, 720 }, + { 1280, 960 }, + { 1600, 1200 }, { 1920, 1080 } }; @@ -367,14 +374,20 @@ void CameraCapabilities::computeHwLevel( camera_metadata_enum_android_info_supported_hardware_level hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL; - if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) + if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) { + LOG(HAL, Info) << noFull << "missing manual sensor"; hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } - if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING)) + if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING)) { + LOG(HAL, Info) << noFull << "missing manual post processing"; hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } - if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE)) + if (!caps.count(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE)) { + LOG(HAL, Info) << noFull << "missing burst capture"; hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } found = staticMetadata_->getEntry(ANDROID_SYNC_MAX_LATENCY, &entry); if (!found || *entry.data.i32 != 0) { @@ -475,7 +488,7 @@ int CameraCapabilities::initializeStreamConfigurations() * \todo Get this from the camera properties once defined */ std::unique_ptr<CameraConfiguration> cameraConfig = - camera_->generateConfiguration({ StillCapture }); + camera_->generateConfiguration({ StreamRole::StillCapture }); if (!cameraConfig) { LOG(HAL, Error) << "Failed to get maximum resolution"; return -EINVAL; @@ -492,8 +505,8 @@ int CameraCapabilities::initializeStreamConfigurations() /* * Build the list of supported image resolutions. * - * The resolutions listed in camera3Resolution are mandatory to be - * supported, up to the camera maximum resolution. + * The resolutions listed in camera3Resolution are supported, up to the + * camera maximum resolution. * * Augment the list by adding resolutions calculated from the camera * maximum one. @@ -687,6 +700,14 @@ int CameraCapabilities::initializeStreamConfigurations() minFrameDuration = minFrameDurationCap; } + /* + * Calculate FPS as CTS does and adjust the minimum + * frame duration accordingly: see + * Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration() + */ + minFrameDuration = + 1e9 / static_cast<unsigned int>(floor(1e9 / minFrameDuration + 0.05f)); + streamConfigurations_.push_back({ res, androidFormat, minFrameDuration, maxFrameDuration, }); @@ -1042,18 +1063,18 @@ int CameraCapabilities::initializeStaticMetadata() /* Sensor static metadata. */ std::array<int32_t, 2> pixelArraySize; { - const Size &size = properties.get(properties::PixelArraySize); + const Size &size = properties.get(properties::PixelArraySize).value_or(Size{}); pixelArraySize[0] = size.width; pixelArraySize[1] = size.height; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, pixelArraySize); } - if (properties.contains(properties::UnitCellSize)) { - const Size &cellSize = properties.get<Size>(properties::UnitCellSize); + const auto &cellSize = properties.get<Size>(properties::UnitCellSize); + if (cellSize) { std::array<float, 2> physicalSize{ - cellSize.width * pixelArraySize[0] / 1e6f, - cellSize.height * pixelArraySize[1] / 1e6f + cellSize->width * pixelArraySize[0] / 1e6f, + cellSize->height * pixelArraySize[1] / 1e6f }; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, physicalSize); @@ -1061,7 +1082,7 @@ int CameraCapabilities::initializeStaticMetadata() { const Span<const Rectangle> &rects = - properties.get(properties::PixelArrayActiveAreas); + properties.get(properties::PixelArrayActiveAreas).value_or(Span<const Rectangle>{}); std::vector<int32_t> data{ static_cast<int32_t>(rects[0].x), static_cast<int32_t>(rects[0].y), @@ -1079,11 +1100,10 @@ int CameraCapabilities::initializeStaticMetadata() sensitivityRange); /* Report the color filter arrangement if the camera reports it. */ - if (properties.contains(properties::draft::ColorFilterArrangement)) { - uint8_t filterArr = properties.get(properties::draft::ColorFilterArrangement); + const auto &filterArr = properties.get(properties::draft::ColorFilterArrangement); + if (filterArr) staticMetadata_->addEntry(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, - filterArr); - } + *filterArr); const auto &exposureInfo = controlsInfo.find(&controls::ExposureTime); if (exposureInfo != controlsInfo.end()) { @@ -1287,12 +1307,10 @@ int CameraCapabilities::initializeStaticMetadata() * recording profile. Inspecting the Intel IPU3 HAL * implementation confirms this but no reference has been found * in the metadata documentation. - * - * Calculate FPS as CTS does: see - * Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration() */ - unsigned int fps = static_cast<unsigned int> - (floor(1e9 / entry.minFrameDurationNsec + 0.05f)); + unsigned int fps = + static_cast<unsigned int>(floor(1e9 / entry.minFrameDurationNsec)); + if (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB && fps < 30) continue; diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index 6f66f221..56ac1efe 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * camera_capabilities.h - Camera static properties manager + * Camera static properties manager */ #pragma once diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 8c039fb9..493f66e7 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_device.cpp - libcamera Android Camera Device + * libcamera Android Camera Device */ #include "camera_device.h" @@ -30,6 +30,7 @@ #include "camera_hal_config.h" #include "camera_ops.h" #include "camera_request.h" +#include "hal_framebuffer.h" using namespace libcamera; @@ -305,9 +306,9 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData) */ const ControlList &properties = camera_->properties(); - if (properties.contains(properties::Location)) { - int32_t location = properties.get(properties::Location); - switch (location) { + const auto &location = properties.get(properties::Location); + if (location) { + switch (*location) { case properties::CameraLocationFront: facing_ = CAMERA_FACING_FRONT; break; @@ -355,9 +356,9 @@ int CameraDevice::initialize(const CameraConfigData *cameraConfigData) * value for clockwise direction as required by the Android orientation * metadata. */ - if (properties.contains(properties::Rotation)) { - int rotation = properties.get(properties::Rotation); - orientation_ = (360 - rotation) % 360; + const auto &rotation = properties.get(properties::Rotation); + if (rotation) { + orientation_ = (360 - *rotation) % 360; if (cameraConfigData && cameraConfigData->rotation != -1 && orientation_ != cameraConfigData->rotation) { LOG(HAL, Warning) @@ -432,8 +433,6 @@ void CameraDevice::flush() void CameraDevice::stop() { MutexLocker stateLock(stateMutex_); - if (state_ == State::Stopped) - return; camera_->stop(); @@ -771,7 +770,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 +793,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) @@ -951,8 +950,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques */ if (camera3Request->settings) lastSettings_ = camera3Request->settings; - else - descriptor->settings_ = lastSettings_; + + descriptor->settings_ = lastSettings_; LOG(HAL, Debug) << "Queueing request " << descriptor->request_->cookie() << " with " << descriptor->buffers_.size() << " streams"; @@ -1076,7 +1075,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques descriptor->request_->addBuffer(sourceStream->stream(), frameBuffer, nullptr); - requestedStreams.erase(sourceStream); + requestedStreams.insert(sourceStream); } /* @@ -1107,6 +1106,8 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques } if (state_ == State::Stopped) { + lastSettings_ = {}; + ret = camera_->start(); if (ret) { LOG(HAL, Error) << "Failed to start camera"; @@ -1181,7 +1182,8 @@ void CameraDevice::requestComplete(Request *request) * as soon as possible, earlier than request completion time. */ uint64_t sensorTimestamp = static_cast<uint64_t>(request->metadata() - .get(controls::SensorTimestamp)); + .get(controls::SensorTimestamp) + .value_or(0)); notifyShutter(descriptor->frameNumber_, sensorTimestamp); LOG(HAL, Debug) << "Request " << request->cookie() << " completed with " @@ -1560,29 +1562,27 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons rolling_shutter_skew); /* Add metadata tags reported by libcamera. */ - const int64_t timestamp = metadata.get(controls::SensorTimestamp); + const int64_t timestamp = metadata.get(controls::SensorTimestamp).value_or(0); resultMetadata->addEntry(ANDROID_SENSOR_TIMESTAMP, timestamp); - if (metadata.contains(controls::draft::PipelineDepth)) { - uint8_t pipeline_depth = - metadata.get<int32_t>(controls::draft::PipelineDepth); + const auto &pipelineDepth = metadata.get(controls::draft::PipelineDepth); + if (pipelineDepth) resultMetadata->addEntry(ANDROID_REQUEST_PIPELINE_DEPTH, - pipeline_depth); - } + *pipelineDepth); - if (metadata.contains(controls::ExposureTime)) { - int64_t exposure = metadata.get(controls::ExposureTime) * 1000ULL; - resultMetadata->addEntry(ANDROID_SENSOR_EXPOSURE_TIME, exposure); - } + const auto &exposureTime = metadata.get(controls::ExposureTime); + if (exposureTime) + resultMetadata->addEntry(ANDROID_SENSOR_EXPOSURE_TIME, + *exposureTime * 1000ULL); - if (metadata.contains(controls::FrameDuration)) { - int64_t duration = metadata.get(controls::FrameDuration) * 1000; + const auto &frameDuration = metadata.get(controls::FrameDuration); + if (frameDuration) resultMetadata->addEntry(ANDROID_SENSOR_FRAME_DURATION, - duration); - } + *frameDuration * 1000); - if (metadata.contains(controls::ScalerCrop)) { - Rectangle crop = metadata.get(controls::ScalerCrop); + const auto &scalerCrop = metadata.get(controls::ScalerCrop); + if (scalerCrop) { + const Rectangle &crop = *scalerCrop; int32_t cropRect[] = { crop.x, crop.y, static_cast<int32_t>(crop.width), static_cast<int32_t>(crop.height), @@ -1590,12 +1590,10 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, cropRect); } - if (metadata.contains(controls::draft::TestPatternMode)) { - const int32_t testPatternMode = - metadata.get(controls::draft::TestPatternMode); + const auto &testPatternMode = metadata.get(controls::draft::TestPatternMode); + if (testPatternMode) resultMetadata->addEntry(ANDROID_SENSOR_TEST_PATTERN_MODE, - testPatternMode); - } + *testPatternMode); /* * Return the result metadata pack even is not valid: get() will return diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 64050416..194ca303 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_device.h - libcamera Android Camera Device + * libcamera Android Camera Device */ #pragma once @@ -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_hal_config.cpp b/src/android/camera_hal_config.cpp index bacfe4b9..7ef451ef 100644 --- a/src/android/camera_hal_config.cpp +++ b/src/android/camera_hal_config.cpp @@ -2,11 +2,10 @@ /* * Copyright (C) 2021, Google Inc. * - * camera_hal_config.cpp - Camera HAL configuration file manager + * Camera HAL configuration file manager */ #include "camera_hal_config.h" -#include <filesystem> #include <stdlib.h> #include <string> @@ -160,15 +159,15 @@ CameraHalConfig::CameraHalConfig() */ int CameraHalConfig::parseConfigurationFile() { - std::filesystem::path filePath = LIBCAMERA_SYSCONF_DIR; - filePath /= "camera_hal.yaml"; - if (!std::filesystem::is_regular_file(filePath)) { + std::string filePath = LIBCAMERA_SYSCONF_DIR "/camera_hal.yaml"; + + File file(filePath); + if (!file.exists()) { LOG(HALConfig, Debug) << "Configuration file: \"" << filePath << "\" not found"; return -ENOENT; } - File file(filePath); if (!file.open(File::OpenModeFlag::ReadOnly)) { int ret = file.error(); LOG(HALConfig, Error) << "Failed to open configuration file " diff --git a/src/android/camera_hal_config.h b/src/android/camera_hal_config.h index 9df554f9..a4bedb6e 100644 --- a/src/android/camera_hal_config.h +++ b/src/android/camera_hal_config.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * camera_hal_config.h - Camera HAL configuration file manager + * Camera HAL configuration file manager */ #pragma once diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index 5f7bfe26..7500c749 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_hal_manager.cpp - libcamera Android Camera Manager + * libcamera Android Camera Manager */ #include "camera_hal_manager.h" @@ -140,7 +140,8 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam) */ if (!isCameraExternal && !halConfig_.exists()) { LOG(HAL, Error) - << "HAL configuration file is mandatory for internal cameras"; + << "HAL configuration file is mandatory for internal cameras." + << " Camera " << cam->id() << " failed to load"; return; } @@ -228,11 +229,7 @@ void CameraHalManager::cameraRemoved(std::shared_ptr<Camera> cam) int32_t CameraHalManager::cameraLocation(const Camera *cam) { - const ControlList &properties = cam->properties(); - if (!properties.contains(properties::Location)) - return -1; - - return properties.get(properties::Location); + return cam->properties().get(properties::Location).value_or(-1); } CameraDevice *CameraHalManager::cameraDeviceFromHalId(unsigned int id) diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h index a5f8b933..836a8daf 100644 --- a/src/android/camera_hal_manager.h +++ b/src/android/camera_hal_manager.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_hal_manager.h - libcamera Android Camera Manager + * libcamera Android Camera Manager */ #pragma once diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp index b3e515d2..99f033f9 100644 --- a/src/android/camera_metadata.cpp +++ b/src/android/camera_metadata.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_metadata.cpp - libcamera Android Camera Metadata Helper + * libcamera Android Camera Metadata Helper */ #include "camera_metadata.h" diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h index 0c31ec6b..474f280c 100644 --- a/src/android/camera_metadata.h +++ b/src/android/camera_metadata.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_metadata.h - libcamera Android Camera Metadata Helper + * libcamera Android Camera Metadata Helper */ #pragma once diff --git a/src/android/camera_ops.cpp b/src/android/camera_ops.cpp index 8a3cfa17..ecaac5a3 100644 --- a/src/android/camera_ops.cpp +++ b/src/android/camera_ops.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_ops.h - Android Camera HAL Operations + * Android Camera HAL Operations */ #include "camera_ops.h" diff --git a/src/android/camera_ops.h b/src/android/camera_ops.h index b501bb7e..750dc945 100644 --- a/src/android/camera_ops.h +++ b/src/android/camera_ops.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * camera_ops.h - Android Camera HAL Operations + * Android Camera HAL Operations */ #pragma once diff --git a/src/android/camera_request.cpp b/src/android/camera_request.cpp index 6c87adba..0d45960d 100644 --- a/src/android/camera_request.cpp +++ b/src/android/camera_request.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2019-2021, Google Inc. * - * camera_request.cpp - libcamera Android Camera Request Descriptor + * libcamera Android Camera Request Descriptor */ #include "camera_request.h" diff --git a/src/android/camera_request.h b/src/android/camera_request.h index 37b6ae32..5b479180 100644 --- a/src/android/camera_request.h +++ b/src/android/camera_request.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019-2021, Google Inc. * - * camera_request.h - libcamera Android Camera Request Descriptor + * libcamera Android Camera Request Descriptor */ #pragma once @@ -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/camera_stream.cpp b/src/android/camera_stream.cpp index 045e6006..1d68540d 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * camera_stream.cpp - Camera HAL stream + * Camera HAL stream */ #include "camera_stream.h" diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index 4c5078b2..395552da 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * camera_stream.h - Camera HAL stream + * Camera HAL stream */ #pragma once diff --git a/src/android/cros/camera3_hal.cpp b/src/android/cros/camera3_hal.cpp index fb863b5f..6010a5ad 100644 --- a/src/android/cros/camera3_hal.cpp +++ b/src/android/cros/camera3_hal.cpp @@ -2,15 +2,17 @@ /* * Copyright (C) 2021, Google Inc. * - * camera3_hal.cpp - cros-specific components of Android Camera HALv3 module + * cros-specific components of Android Camera HALv3 module */ #include <cros-camera/cros_camera_hal.h> #include "../camera_hal_manager.h" +#include "../cros_mojo_token.h" -static void set_up([[maybe_unused]] cros::CameraMojoChannelManagerToken *token) +static void set_up(cros::CameraMojoChannelManagerToken *token) { + gCrosMojoToken = token; } static void tear_down() diff --git a/src/android/cros_mojo_token.h b/src/android/cros_mojo_token.h new file mode 100644 index 00000000..d0baa80f --- /dev/null +++ b/src/android/cros_mojo_token.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * cros-specific mojo token + */ + +#pragma once + +#include <cros-camera/cros_camera_hal.h> + +inline cros::CameraMojoChannelManagerToken *gCrosMojoToken = nullptr; diff --git a/src/android/data/nautilus/camera_hal.yaml b/src/android/data/nautilus/camera_hal.yaml index faddd29e..2105fcca 100644 --- a/src/android/data/nautilus/camera_hal.yaml +++ b/src/android/data/nautilus/camera_hal.yaml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: CC0-1.0 + cameras: "\\_SB_.PCI0.I2C2.CAM0": location: back diff --git a/src/android/data/soraka/camera_hal.yaml b/src/android/data/soraka/camera_hal.yaml index 2e996403..d886af06 100644 --- a/src/android/data/soraka/camera_hal.yaml +++ b/src/android/data/soraka/camera_hal.yaml @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: CC0-1.0 + cameras: "\\_SB_.PCI0.I2C4.CAM1": location: front diff --git a/src/android/frame_buffer_allocator.h b/src/android/frame_buffer_allocator.h index 5d2eeda1..3e68641c 100644 --- a/src/android/frame_buffer_allocator.h +++ b/src/android/frame_buffer_allocator.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * frame_buffer_allocator.h - Interface definition to allocate Frame buffer in + * Interface definition to allocate Frame buffer in * platform dependent way. */ #ifndef __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..d4899f45 --- /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 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..cea49e2d --- /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 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/jpeg/encoder.h b/src/android/jpeg/encoder.h index b974d367..ed033c19 100644 --- a/src/android/jpeg/encoder.h +++ b/src/android/jpeg/encoder.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * encoder.h - Image encoding interface + * Image encoding interface */ #pragma once @@ -12,14 +12,15 @@ #include <libcamera/framebuffer.h> #include <libcamera/stream.h> +#include "../camera_request.h" + class Encoder { public: virtual ~Encoder() = default; virtual int configure(const libcamera::StreamConfiguration &cfg) = 0; - virtual int encode(const libcamera::FrameBuffer &source, - libcamera::Span<uint8_t> destination, + virtual int encode(Camera3RequestDescriptor::StreamBuffer *buffer, libcamera::Span<const uint8_t> exifData, unsigned int quality) = 0; }; diff --git a/src/android/jpeg/encoder_jea.cpp b/src/android/jpeg/encoder_jea.cpp new file mode 100644 index 00000000..25dc4317 --- /dev/null +++ b/src/android/jpeg/encoder_jea.cpp @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * JPEG encoding using CrOS JEA + */ + +#include "encoder_jea.h" + +#include "libcamera/internal/mapped_framebuffer.h" + +#include <cros-camera/camera_mojo_channel_manager_token.h> + +#include "../cros_mojo_token.h" +#include "../hal_framebuffer.h" + +EncoderJea::EncoderJea() = default; + +EncoderJea::~EncoderJea() = default; + +int EncoderJea::configure(const libcamera::StreamConfiguration &cfg) +{ + size_ = cfg.size; + + if (jpegCompressor_) + return 0; + + if (gCrosMojoToken == nullptr) + return -ENOTSUP; + + jpegCompressor_ = cros::JpegCompressor::GetInstance(gCrosMojoToken); + + return 0; +} + +int EncoderJea::encode(Camera3RequestDescriptor::StreamBuffer *buffer, + libcamera::Span<const uint8_t> exifData, + unsigned int quality) +{ + if (!jpegCompressor_) + return -ENOTSUP; + + uint32_t outDataSize = 0; + const HALFrameBuffer *fb = + dynamic_cast<const HALFrameBuffer *>(buffer->srcBuffer); + + if (!jpegCompressor_->CompressImageFromHandle(fb->handle(), + *buffer->camera3Buffer, + size_.width, size_.height, + quality, exifData.data(), + exifData.size(), + &outDataSize)) + return -EBUSY; + + return outDataSize; +} diff --git a/src/android/jpeg/encoder_jea.h b/src/android/jpeg/encoder_jea.h new file mode 100644 index 00000000..91115d2e --- /dev/null +++ b/src/android/jpeg/encoder_jea.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Google Inc. + * + * JPEG encoding using CrOS JEA + */ + +#pragma once + +#include <libcamera/geometry.h> + +#include <cros-camera/jpeg_compressor.h> + +#include "encoder.h" + +class EncoderJea : public Encoder +{ +public: + EncoderJea(); + ~EncoderJea(); + + int configure(const libcamera::StreamConfiguration &cfg) override; + int encode(Camera3RequestDescriptor::StreamBuffer *buffer, + libcamera::Span<const uint8_t> exifData, + unsigned int quality) override; + +private: + libcamera::Size size_; + + std::unique_ptr<cros::JpegCompressor> jpegCompressor_; +}; diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index fd62bd9c..7fc6287e 100644 --- a/src/android/jpeg/encoder_libjpeg.cpp +++ b/src/android/jpeg/encoder_libjpeg.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * encoder_libjpeg.cpp - JPEG encoding using libjpeg native API + * JPEG encoding using libjpeg native API */ #include "encoder_libjpeg.h" @@ -24,6 +24,8 @@ #include "libcamera/internal/formats.h" #include "libcamera/internal/mapped_framebuffer.h" +#include "../camera_buffer.h" + using namespace libcamera; LOG_DECLARE_CATEGORY(JPEG) @@ -178,17 +180,20 @@ void EncoderLibJpeg::compressNV(const std::vector<Span<uint8_t>> &planes) } } -int EncoderLibJpeg::encode(const FrameBuffer &source, Span<uint8_t> dest, - Span<const uint8_t> exifData, unsigned int quality) +int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *buffer, + libcamera::Span<const uint8_t> exifData, + unsigned int quality) { - MappedFrameBuffer frame(&source, MappedFrameBuffer::MapFlag::Read); + MappedFrameBuffer frame(buffer->srcBuffer, + MappedFrameBuffer::MapFlag::Read); if (!frame.isValid()) { LOG(JPEG, Error) << "Failed to map FrameBuffer : " << strerror(frame.error()); return frame.error(); } - return encode(frame.planes(), dest, exifData, quality); + return encode(frame.planes(), buffer->dstBuffer->plane(0), + exifData, quality); } int EncoderLibJpeg::encode(const std::vector<Span<uint8_t>> &src, diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h index 1b3ac067..4ac85c22 100644 --- a/src/android/jpeg/encoder_libjpeg.h +++ b/src/android/jpeg/encoder_libjpeg.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * encoder_libjpeg.h - JPEG encoding using libjpeg + * JPEG encoding using libjpeg */ #pragma once @@ -22,8 +22,7 @@ public: ~EncoderLibJpeg(); int configure(const libcamera::StreamConfiguration &cfg) override; - int encode(const libcamera::FrameBuffer &source, - libcamera::Span<uint8_t> destination, + int encode(Camera3RequestDescriptor::StreamBuffer *buffer, libcamera::Span<const uint8_t> exifData, unsigned int quality) override; int encode(const std::vector<libcamera::Span<uint8_t>> &planes, diff --git a/src/android/jpeg/exif.cpp b/src/android/jpeg/exif.cpp index 3220b458..b8c871df 100644 --- a/src/android/jpeg/exif.cpp +++ b/src/android/jpeg/exif.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * exif.cpp - EXIF tag creation using libexif + * EXIF tag creation using libexif */ #include "exif.h" @@ -430,16 +430,13 @@ void Exif::setOrientation(int orientation) setShort(EXIF_IFD_0, EXIF_TAG_ORIENTATION, value); } -/* - * The thumbnail data should remain valid until the Exif object is destroyed. - * Failing to do so, might result in no thumbnail data being set even after a - * call to Exif::setThumbnail(). - */ -void Exif::setThumbnail(Span<const unsigned char> thumbnail, +void Exif::setThumbnail(std::vector<unsigned char> &&thumbnail, Compression compression) { - data_->data = const_cast<unsigned char *>(thumbnail.data()); - data_->size = thumbnail.size(); + thumbnailData_ = std::move(thumbnail); + + data_->data = thumbnailData_.data(); + data_->size = thumbnailData_.size(); setShort(EXIF_IFD_0, EXIF_TAG_COMPRESSION, compression); } diff --git a/src/android/jpeg/exif.h b/src/android/jpeg/exif.h index 2ff8fb78..446d53f3 100644 --- a/src/android/jpeg/exif.h +++ b/src/android/jpeg/exif.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * exif.h - EXIF tag creator using libexif + * EXIF tag creator using libexif */ #pragma once @@ -10,6 +10,7 @@ #include <chrono> #include <string> #include <time.h> +#include <vector> #include <libexif/exif-data.h> @@ -60,7 +61,7 @@ public: void setOrientation(int orientation); void setSize(const libcamera::Size &size); - void setThumbnail(libcamera::Span<const unsigned char> thumbnail, + void setThumbnail(std::vector<unsigned char> &&thumbnail, Compression compression); void setTimestamp(time_t timestamp, std::chrono::milliseconds msec); @@ -106,4 +107,6 @@ private: unsigned char *exifData_; unsigned int size_; + + std::vector<unsigned char> thumbnailData_; }; diff --git a/src/android/jpeg/meson.build b/src/android/jpeg/meson.build new file mode 100644 index 00000000..3402e614 --- /dev/null +++ b/src/android/jpeg/meson.build @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: CC0-1.0 + +android_hal_sources += files([ + 'encoder_libjpeg.cpp', + 'exif.cpp', + 'post_processor_jpeg.cpp', + 'thumbnailer.cpp' +]) + +platform = get_option('android_platform') +if platform == 'cros' + android_hal_sources += files(['encoder_jea.cpp']) + android_deps += [dependency('libcros_camera')] +endif diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index d72ebc3c..89b8a401 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * post_processor_jpeg.cpp - JPEG Post Processor + * JPEG Post Processor */ #include "post_processor_jpeg.h" @@ -12,7 +12,11 @@ #include "../camera_device.h" #include "../camera_metadata.h" #include "../camera_request.h" +#if defined(OS_CHROMEOS) +#include "encoder_jea.h" +#else /* !defined(OS_CHROMEOS) */ #include "encoder_libjpeg.h" +#endif #include "exif.h" #include <libcamera/base/log.h> @@ -46,7 +50,11 @@ int PostProcessorJpeg::configure(const StreamConfiguration &inCfg, thumbnailer_.configure(inCfg.size, inCfg.pixelFormat); +#if defined(OS_CHROMEOS) + encoder_ = std::make_unique<EncoderJea>(); +#else /* !defined(OS_CHROMEOS) */ encoder_ = std::make_unique<EncoderLibJpeg>(); +#endif return encoder_->configure(inCfg); } @@ -166,7 +174,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu std::vector<unsigned char> thumbnail; generateThumbnail(source, thumbnailSize, quality, &thumbnail); if (!thumbnail.empty()) - exif.setThumbnail(thumbnail, Exif::Compression::JPEG); + exif.setThumbnail(std::move(thumbnail), Exif::Compression::JPEG); } resultMetadata->addEntry(ANDROID_JPEG_THUMBNAIL_SIZE, data, 2); @@ -194,8 +202,7 @@ void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBu const uint8_t quality = ret ? *entry.data.u8 : 95; resultMetadata->addEntry(ANDROID_JPEG_QUALITY, quality); - int jpeg_size = encoder_->encode(source, destination->plane(0), - exif.data(), quality); + int jpeg_size = encoder_->encode(streamBuffer, exif.data(), quality); if (jpeg_size < 0) { LOG(JPEG, Error) << "Failed to encode stream image"; processComplete.emit(streamBuffer, PostProcessor::Status::Error); diff --git a/src/android/jpeg/post_processor_jpeg.h b/src/android/jpeg/post_processor_jpeg.h index 98309b01..6fe21457 100644 --- a/src/android/jpeg/post_processor_jpeg.h +++ b/src/android/jpeg/post_processor_jpeg.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * post_processor_jpeg.h - JPEG Post Processor + * JPEG Post Processor */ #pragma once diff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp index 41c71c76..adafc468 100644 --- a/src/android/jpeg/thumbnailer.cpp +++ b/src/android/jpeg/thumbnailer.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * thumbnailer.cpp - Simple image thumbnailer + * Simple image thumbnailer */ #include "thumbnailer.h" diff --git a/src/android/jpeg/thumbnailer.h b/src/android/jpeg/thumbnailer.h index d933cf0e..1b836e59 100644 --- a/src/android/jpeg/thumbnailer.h +++ b/src/android/jpeg/thumbnailer.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * thumbnailer.h - Simple image thumbnailer + * Simple image thumbnailer */ #pragma once diff --git a/src/android/meson.build b/src/android/meson.build index 1bba54de..68646120 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -46,16 +46,14 @@ android_hal_sources = files([ 'camera_ops.cpp', 'camera_request.cpp', 'camera_stream.cpp', - 'jpeg/encoder_libjpeg.cpp', - 'jpeg/exif.cpp', - 'jpeg/post_processor_jpeg.cpp', - 'jpeg/thumbnailer.cpp', + 'hal_framebuffer.cpp', 'yuv/post_processor_yuv.cpp' ]) android_cpp_args = [] subdir('cros') +subdir('jpeg') subdir('mm') android_camera_metadata_sources = files([ diff --git a/src/android/mm/cros_camera_buffer.cpp b/src/android/mm/cros_camera_buffer.cpp index 2ac3dc4a..e2a44a2a 100644 --- a/src/android/mm/cros_camera_buffer.cpp +++ b/src/android/mm/cros_camera_buffer.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * cros_camera_buffer.cpp - Chromium OS buffer backend using CameraBufferManager + * Chromium OS buffer backend using CameraBufferManager */ #include "../camera_buffer.h" diff --git a/src/android/mm/cros_frame_buffer_allocator.cpp b/src/android/mm/cros_frame_buffer_allocator.cpp index 52e8c180..264c0d48 100644 --- a/src/android/mm/cros_frame_buffer_allocator.cpp +++ b/src/android/mm/cros_frame_buffer_allocator.cpp @@ -2,8 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * cros_frame_buffer.cpp - Allocate FrameBuffer for Chromium OS using - * CameraBufferManager + * Allocate FrameBuffer for Chromium OS using CameraBufferManager */ #include <memory> @@ -16,6 +15,7 @@ #include "../camera_device.h" #include "../frame_buffer_allocator.h" +#include "../hal_framebuffer.h" #include "cros-camera/camera_buffer_manager.h" using namespace libcamera; @@ -28,8 +28,9 @@ class CrosFrameBufferData : public FrameBuffer::Private LIBCAMERA_DECLARE_PUBLIC(FrameBuffer) public: - CrosFrameBufferData(cros::ScopedBufferHandle scopedHandle) - : FrameBuffer::Private(), scopedHandle_(std::move(scopedHandle)) + CrosFrameBufferData(cros::ScopedBufferHandle scopedHandle, + const std::vector<FrameBuffer::Plane> &planes) + : FrameBuffer::Private(planes), scopedHandle_(std::move(scopedHandle)) { } @@ -47,11 +48,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) @@ -80,9 +81,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_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp index 1bd7090d..0ffcb445 100644 --- a/src/android/mm/generic_camera_buffer.cpp +++ b/src/android/mm/generic_camera_buffer.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * generic_camera_buffer.cpp - Generic Android frame buffer backend + * Generic Android frame buffer backend */ #include "../camera_buffer.h" diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp index acb2fa2b..79625a9a 100644 --- a/src/android/mm/generic_frame_buffer_allocator.cpp +++ b/src/android/mm/generic_frame_buffer_allocator.cpp @@ -2,9 +2,10 @@ /* * Copyright (C) 2021, Google Inc. * - * generic_camera_buffer.cpp - Allocate FrameBuffer using gralloc API + * 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 diff --git a/src/android/mm/libhardware_stub.c b/src/android/mm/libhardware_stub.c new file mode 100644 index 00000000..28faa638 --- /dev/null +++ b/src/android/mm/libhardware_stub.c @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* + * Copyright (C) 2023, Ideas on Board + * + * Android libhardware stub for test compilation + */ + +#include <errno.h> + +#include <hardware/hardware.h> + +int hw_get_module(const char *id __attribute__((__unused__)), + const struct hw_module_t **module) +{ + *module = NULL; + return -ENOTSUP; +} diff --git a/src/android/mm/meson.build b/src/android/mm/meson.build index d40a3b0b..e3e0484c 100644 --- a/src/android/mm/meson.build +++ b/src/android/mm/meson.build @@ -4,6 +4,14 @@ platform = get_option('android_platform') if platform == 'generic' android_hal_sources += files(['generic_camera_buffer.cpp', 'generic_frame_buffer_allocator.cpp']) + android_deps += [libdl] + + libhardware = dependency('libhardware', required : false) + if libhardware.found() + android_deps += [libhardware] + else + android_hal_sources += files(['libhardware_stub.c']) + endif elif platform == 'cros' android_hal_sources += files(['cros_camera_buffer.cpp', 'cros_frame_buffer_allocator.cpp']) diff --git a/src/android/post_processor.h b/src/android/post_processor.h index 1a205b05..b504a379 100644 --- a/src/android/post_processor.h +++ b/src/android/post_processor.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2020, Google Inc. * - * post_processor.h - CameraStream Post Processing Interface + * CameraStream Post Processing Interface */ #pragma once diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index ed44e6fe..c998807b 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * post_processor_yuv.cpp - Post Processor using libyuv + * Post Processor using libyuv */ #include "post_processor_yuv.h" diff --git a/src/android/yuv/post_processor_yuv.h b/src/android/yuv/post_processor_yuv.h index a7ac17c5..ed7bb1fb 100644 --- a/src/android/yuv/post_processor_yuv.h +++ b/src/android/yuv/post_processor_yuv.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2021, Google Inc. * - * post_processor_yuv.h - Post Processor using libyuv + * Post Processor using libyuv */ #pragma once |