From patchwork Thu Aug 1 15:54:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1722 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3BFDC615DF for ; Thu, 1 Aug 2019 17:53:05 +0200 (CEST) X-Originating-IP: 82.58.19.211 Received: from uno.homenet.telecomitalia.it (host211-19-dynamic.58-82-r.retail.telecomitalia.it [82.58.19.211]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 96B9EE0009; Thu, 1 Aug 2019 15:53:04 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Aug 2019 17:54:16 +0200 Message-Id: <20190801155420.24694-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801155420.24694-1-jacopo@jmondi.org> References: <20190801155420.24694-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] libcamera: camera: Make camera state accessible X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Aug 2019 15:53:05 -0000 Make the Camera state accessible by providing an accessor operation and moving the State enumeration definition in the public scope. Signed-off-by: Jacopo Mondi --- include/libcamera/camera.h | 16 +++++++++------- src/libcamera/camera.cpp | 33 +++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 21fac550f412..6e627943b3f1 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -66,6 +66,14 @@ protected: std::vector config_; }; +enum State { + CameraAvailable, + CameraAcquired, + CameraConfigured, + CameraPrepared, + CameraRunning, +}; + class Camera final : public std::enable_shared_from_this { public: @@ -77,6 +85,7 @@ public: Camera &operator=(const Camera &) = delete; const std::string &name() const; + State state() const { return state_; } Signal bufferCompleted; Signal &> requestCompleted; @@ -101,13 +110,6 @@ public: int stop(); private: - enum State { - CameraAvailable, - CameraAcquired, - CameraConfigured, - CameraPrepared, - CameraRunning, - }; Camera(PipelineHandler *pipe, const std::string &name); ~Camera(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 76c737cb9381..e924c2085816 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -253,6 +253,21 @@ std::size_t CameraConfiguration::size() const * \brief The vector of stream configurations */ +/** + * \enum State + * \brief Describe the Camera state as defined in \ref camera_states + * \var State::CameraAvailable + * See \ref camera_available + * \var State::CameraAcquired + * See \ref camera_acquired + * \var State::CameraConfigured + * See \ref camera_configured + * \var State::CameraPrepared + * See \ref camera_prepared + * \var State::CameraRunning + * See \ref camera_running + */ + /** * \class Camera * \brief Camera device @@ -284,7 +299,7 @@ std::size_t CameraConfiguration::size() const * not released. The camera may also be reconfigured provided that all * resources allocated are freed prior to the reconfiguration. * - * \subsection Camera States + * \subsection camera_states Camera States * * To help manage the sequence of operations needed to control the camera a set * of states are defined. Each state describes which operations may be performed @@ -318,27 +333,27 @@ std::size_t CameraConfiguration::size() const * } * \enddot * - * \subsubsection Available + * \subsubsection camera_available Available * The base state of a camera, an application can inspect the properties of the * camera to determine if it wishes to use it. If an application wishes to use * a camera it should acquire() it to proceed to the Acquired state. * - * \subsubsection Acquired + * \subsubsection camera_acquired Acquired * In the acquired state an application has exclusive access to the camera and * may modify the camera's parameters to configure it and proceed to the * Configured state. * - * \subsubsection Configured + * \subsubsection camera_configured Configured * The camera is configured and ready for the application to prepare it with * resources. The camera may be reconfigured multiple times until resources * are provided and the state progresses to Prepared. * - * \subsubsection Prepared + * \subsubsection camera_prepared Prepared * The camera has been configured and provided with resources and is ready to be * started. The application may free the camera's resources to get back to the * Configured state or start() it to progress to the Running state. * - * \subsubsection Running + * \subsubsection camera_running Running * The camera is running and ready to process requests queued by the * application. The camera remains in this state until it is stopped and moved * to the Prepared state. @@ -380,6 +395,12 @@ const std::string &Camera::name() const return name_; } +/** + * \fn Camera::state() + * \brief Retrieve the current camera state as defined in \ref camera_states + * \return The current camera state + */ + /** * \var Camera::bufferCompleted * \brief Signal emitted when a buffer for a request queued to the camera has From patchwork Thu Aug 1 15:54:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1723 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E6BEE61612 for ; Thu, 1 Aug 2019 17:53:05 +0200 (CEST) X-Originating-IP: 82.58.19.211 Received: from uno.homenet.telecomitalia.it (host211-19-dynamic.58-82-r.retail.telecomitalia.it [82.58.19.211]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 6A8F8E0008; Thu, 1 Aug 2019 15:53:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Aug 2019 17:54:17 +0200 Message-Id: <20190801155420.24694-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801155420.24694-1-jacopo@jmondi.org> References: <20190801155420.24694-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] meson: options: Add 'android' configuration option X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Aug 2019 15:53:06 -0000 Add an 'android' configuration option, set to false by default, which enables the compilation of the Android HAL adaption layer on top of libcamera. To enable compiling the Camera HAL wrapper in: $ meson configure -Dandroid=true Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- meson_options.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meson_options.txt b/meson_options.txt index 97efc85b4412..5fa8176b8e8b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,8 @@ +option('android', + type : 'boolean', + value : false, + description : 'Compile libcamera with Android Camera3 HAL interface') + option('documentation', type : 'boolean', description : 'Generate the project documentation') From patchwork Thu Aug 1 15:54:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1726 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1A4BF615DF for ; Thu, 1 Aug 2019 17:53:21 +0200 (CEST) X-Originating-IP: 82.58.19.211 Received: from uno.homenet.telecomitalia.it (host211-19-dynamic.58-82-r.retail.telecomitalia.it [82.58.19.211]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id BFA17E0008; Thu, 1 Aug 2019 15:53:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Aug 2019 17:54:18 +0200 Message-Id: <20190801155420.24694-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801155420.24694-1-jacopo@jmondi.org> References: <20190801155420.24694-1-jacopo@jmondi.org> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 01 Aug 2019 17:54:14 +0200 Subject: [libcamera-devel] [PATCH 3/5] include: android: Add Android headers from Cros X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Aug 2019 15:53:21 -0000 Copy the Android Camera3 HAL headers from the ChromiumOS build system and define a new inclusion directive in the meson build system for them. The header files have been copied from: https://chromium.googlesource.com/chromiumos/platform2 at revision ceb477360a8012ee38e80746258f4828aad6b4c7 and provide: 1) Android CameraHAL3 HAL headers in include/android/hardware/ 2) The Android system headers in include/android/system/ 3) The Android camera metadata headers in include/android/metadata/ The original path in the Cros platform2/ repository is, respectively: camera/android/header_files/include/hardware camera/android/header_files/include/system camera/android/libcamera_metadata/include/ Signed-off-by: Jacopo Mondi --- .../libhardware/include/hardware/camera3.h | 3093 +++++++++++++++++ .../include/hardware/camera_common.h | 916 +++++ .../libhardware/include/hardware/fb.h | 173 + .../libhardware/include/hardware/gralloc.h | 384 ++ .../libhardware/include/hardware/hardware.h | 238 ++ .../android/metadata/camera_metadata_hidden.h | 100 + .../android/metadata/system/camera_metadata.h | 580 ++++ .../metadata/system/camera_metadata_tags.h | 1005 ++++++ .../metadata/system/camera_vendor_tags.h | 158 + .../android/system/core/include/android/log.h | 144 + .../system/core/include/cutils/compiler.h | 44 + .../core/include/cutils/native_handle.h | 69 + .../system/core/include/system/camera.h | 298 ++ .../system/core/include/system/graphics.h | 763 ++++ .../system/core/include/system/window.h | 954 +++++ meson.build | 5 + 16 files changed, 8924 insertions(+) create mode 100644 include/android/hardware/libhardware/include/hardware/camera3.h create mode 100644 include/android/hardware/libhardware/include/hardware/camera_common.h create mode 100644 include/android/hardware/libhardware/include/hardware/fb.h create mode 100644 include/android/hardware/libhardware/include/hardware/gralloc.h create mode 100644 include/android/hardware/libhardware/include/hardware/hardware.h create mode 100644 include/android/metadata/camera_metadata_hidden.h create mode 100644 include/android/metadata/system/camera_metadata.h create mode 100644 include/android/metadata/system/camera_metadata_tags.h create mode 100644 include/android/metadata/system/camera_vendor_tags.h create mode 100644 include/android/system/core/include/android/log.h create mode 100644 include/android/system/core/include/cutils/compiler.h create mode 100644 include/android/system/core/include/cutils/native_handle.h create mode 100644 include/android/system/core/include/system/camera.h create mode 100644 include/android/system/core/include/system/graphics.h create mode 100644 include/android/system/core/include/system/window.h diff --git a/include/android/hardware/libhardware/include/hardware/camera3.h b/include/android/hardware/libhardware/include/hardware/camera3.h new file mode 100644 index 000000000000..49664dc3ceb6 --- /dev/null +++ b/include/android/hardware/libhardware/include/hardware/camera3.h @@ -0,0 +1,3093 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_INCLUDE_CAMERA3_H +#define ANDROID_INCLUDE_CAMERA3_H + +#include +#include "camera_common.h" + +/** + * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ] + * + * This is the current recommended version of the camera device HAL. + * + * Supports the android.hardware.Camera API, and as of v3.2, the + * android.hardware.camera2 API in LIMITED or FULL modes. + * + * Camera devices that support this version of the HAL must return + * CAMERA_DEVICE_API_VERSION_3_3 in camera_device_t.common.version and in + * camera_info_t.device_version (from camera_module_t.get_camera_info). + * + * CAMERA_DEVICE_API_VERSION_3_3: + * Camera modules that may contain version 3.3 devices must implement at + * least version 2.2 of the camera module interface (as defined by + * camera_module_t.common.module_api_version). + * + * CAMERA_DEVICE_API_VERSION_3_2: + * Camera modules that may contain version 3.2 devices must implement at + * least version 2.2 of the camera module interface (as defined by + * camera_module_t.common.module_api_version). + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * Camera modules that may contain version 3.1 (or 3.0) devices must + * implement at least version 2.0 of the camera module interface + * (as defined by camera_module_t.common.module_api_version). + * + * See camera_common.h for more versioning details. + * + * Documentation index: + * S1. Version history + * S2. Startup and operation sequencing + * S3. Operational modes + * S4. 3A modes and state machines + * S5. Cropping + * S6. Error management + * S7. Key Performance Indicator (KPI) glossary + * S8. Sample Use Cases + * S9. Notes on Controls and Metadata + * S10. Reprocessing flow and controls + */ + +/** + * S1. Version history: + * + * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: + * + * - Converted from C++ CameraHardwareInterface abstraction layer. + * + * - Supports android.hardware.Camera API. + * + * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: + * + * - Sufficient for implementing existing android.hardware.Camera API. + * + * - Allows for ZSL queue in camera service layer + * + * - Not tested for any new features such manual capture control, Bayer RAW + * capture, reprocessing of RAW data. + * + * 3.0: First revision of expanded-capability HAL: + * + * - Major version change since the ABI is completely different. No change to + * the required hardware capabilities or operational model from 2.0. + * + * - Reworked input request and stream queue interfaces: Framework calls into + * HAL with next request and stream buffers already dequeued. Sync framework + * support is included, necessary for efficient implementations. + * + * - Moved triggers into requests, most notifications into results. + * + * - Consolidated all callbacks into framework into one structure, and all + * setup methods into a single initialize() call. + * + * - Made stream configuration into a single call to simplify stream + * management. Bidirectional streams replace STREAM_FROM_STREAM construct. + * + * - Limited mode semantics for older/limited hardware devices. + * + * 3.1: Minor revision of expanded-capability HAL: + * + * - configure_streams passes consumer usage flags to the HAL. + * + * - flush call to drop all in-flight requests/buffers as fast as possible. + * + * 3.2: Minor revision of expanded-capability HAL: + * + * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops + * in camera_common.h instead. + * + * - register_stream_buffers deprecated. All gralloc buffers provided + * by framework to HAL in process_capture_request may be new at any time. + * + * - add partial result support. process_capture_result may be called + * multiple times with a subset of the available result before the full + * result is available. + * + * - add manual template to camera3_request_template. The applications may + * use this template to control the capture settings directly. + * + * - Rework the bidirectional and input stream specifications. + * + * - change the input buffer return path. The buffer is returned in + * process_capture_result instead of process_capture_request. + * + * 3.3: Minor revision of expanded-capability HAL: + * + * - OPAQUE and YUV reprocessing API updates. + * + * - Basic support for depth output buffers. + * + * - Addition of data_space field to camera3_stream_t. + * + * - Addition of rotation field to camera3_stream_t. + * + * - Addition of camera3 stream configuration operation mode to camera3_stream_configuration_t + * + */ + +/** + * S2. Startup and general expected operation sequence: + * + * 1. Framework calls camera_module_t->common.open(), which returns a + * hardware_device_t structure. + * + * 2. Framework inspects the hardware_device_t->version field, and instantiates + * the appropriate handler for that version of the camera hardware device. In + * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to + * a camera3_device_t. + * + * 3. Framework calls camera3_device_t->ops->initialize() with the framework + * callback function pointers. This will only be called this one time after + * open(), before any other functions in the ops structure are called. + * + * 4. The framework calls camera3_device_t->ops->configure_streams() with a list + * of input/output streams to the HAL device. + * + * 5. <= CAMERA_DEVICE_API_VERSION_3_1: + * + * The framework allocates gralloc buffers and calls + * camera3_device_t->ops->register_stream_buffers() for at least one of the + * output streams listed in configure_streams. The same stream is registered + * only once. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * camera3_device_t->ops->register_stream_buffers() is not called and must + * be NULL. + * + * 6. The framework requests default settings for some number of use cases with + * calls to camera3_device_t->ops->construct_default_request_settings(). This + * may occur any time after step 3. + * + * 7. The framework constructs and sends the first capture request to the HAL, + * with settings based on one of the sets of default settings, and with at + * least one output stream, which has been registered earlier by the + * framework. This is sent to the HAL with + * camera3_device_t->ops->process_capture_request(). The HAL must block the + * return of this call until it is ready for the next request to be sent. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * The buffer_handle_t provided in the camera3_stream_buffer_t array + * in the camera3_capture_request_t may be new and never-before-seen + * by the HAL on any given new request. + * + * 8. The framework continues to submit requests, and call + * construct_default_request_settings to get default settings buffers for + * other use cases. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * The framework may call register_stream_buffers() at this time for + * not-yet-registered streams. + * + * 9. When the capture of a request begins (sensor starts exposing for the + * capture) or processing a reprocess request begins, the HAL + * calls camera3_callback_ops_t->notify() with the SHUTTER event, including + * the frame number and the timestamp for start of exposure. For a reprocess + * request, the timestamp must be the start of exposure of the input image + * which can be looked up with android.sensor.timestamp from + * camera3_capture_request_t.settings when process_capture_request() is + * called. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * This notify call must be made before the first call to + * process_capture_result() for that frame number. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * The camera3_callback_ops_t->notify() call with the SHUTTER event should + * be made as early as possible since the framework will be unable to + * deliver gralloc buffers to the application layer (for that frame) until + * it has a valid timestamp for the start of exposure (or the input image's + * start of exposure for a reprocess request). + * + * Both partial metadata results and the gralloc buffers may be sent to the + * framework at any time before or after the SHUTTER event. + * + * 10. After some pipeline delay, the HAL begins to return completed captures to + * the framework with camera3_callback_ops_t->process_capture_result(). These + * are returned in the same order as the requests were submitted. Multiple + * requests can be in flight at once, depending on the pipeline depth of the + * camera HAL device. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Once a buffer is returned by process_capture_result as part of the + * camera3_stream_buffer_t array, and the fence specified by release_fence + * has been signaled (this is a no-op for -1 fences), the ownership of that + * buffer is considered to be transferred back to the framework. After that, + * the HAL must no longer retain that particular buffer, and the + * framework may clean up the memory for it immediately. + * + * process_capture_result may be called multiple times for a single frame, + * each time with a new disjoint piece of metadata and/or set of gralloc + * buffers. The framework will accumulate these partial metadata results + * into one result. + * + * In particular, it is legal for a process_capture_result to be called + * simultaneously for both a frame N and a frame N+1 as long as the + * above rule holds for gralloc buffers (both input and output). + * + * 11. After some time, the framework may stop submitting new requests, wait for + * the existing captures to complete (all buffers filled, all results + * returned), and then call configure_streams() again. This resets the camera + * hardware and pipeline for a new set of input/output streams. Some streams + * may be reused from the previous configuration; if these streams' buffers + * had already been registered with the HAL, they will not be registered + * again. The framework then continues from step 7, if at least one + * registered output stream remains (otherwise, step 5 is required first). + * + * 12. Alternatively, the framework may call camera3_device_t->common->close() + * to end the camera session. This may be called at any time when no other + * calls from the framework are active, although the call may block until all + * in-flight captures have completed (all results returned, all buffers + * filled). After the close call returns, no more calls to the + * camera3_callback_ops_t functions are allowed from the HAL. Once the + * close() call is underway, the framework may not call any other HAL device + * functions. + * + * 13. In case of an error or other asynchronous event, the HAL must call + * camera3_callback_ops_t->notify() with the appropriate error/event + * message. After returning from a fatal device-wide error notification, the + * HAL should act as if close() had been called on it. However, the HAL must + * either cancel or complete all outstanding captures before calling + * notify(), so that once notify() is called with a fatal error, the + * framework will not receive further callbacks from the device. Methods + * besides close() should return -ENODEV or NULL after the notify() method + * returns from a fatal error message. + */ + +/** + * S3. Operational modes: + * + * The camera 3 HAL device can implement one of two possible operational modes; + * limited and full. Full support is expected from new higher-end + * devices. Limited mode has hardware requirements roughly in line with those + * for a camera HAL device v1 implementation, and is expected from older or + * inexpensive devices. Full is a strict superset of limited, and they share the + * same essential operational flow, as documented above. + * + * The HAL must indicate its level of support with the + * android.info.supportedHardwareLevel static metadata entry, with 0 indicating + * limited mode, and 1 indicating full mode support. + * + * Roughly speaking, limited-mode devices do not allow for application control + * of capture settings (3A control only), high-rate capture of high-resolution + * images, raw sensor readout, or support for YUV output streams above maximum + * recording resolution (JPEG only for large images). + * + * ** Details of limited mode behavior: + * + * - Limited-mode devices do not need to implement accurate synchronization + * between capture request settings and the actual image data + * captured. Instead, changes to settings may take effect some time in the + * future, and possibly not for the same output frame for each settings + * entry. Rapid changes in settings may result in some settings never being + * used for a capture. However, captures that include high-resolution output + * buffers ( > 1080p ) have to use the settings as specified (but see below + * for processing rate). + * + * - Limited-mode devices do not need to support most of the + * settings/result/static info metadata. Specifically, only the following settings + * are expected to be consumed or produced by a limited-mode HAL device: + * + * android.control.aeAntibandingMode (controls and dynamic) + * android.control.aeExposureCompensation (controls and dynamic) + * android.control.aeLock (controls and dynamic) + * android.control.aeMode (controls and dynamic) + * android.control.aeRegions (controls and dynamic) + * android.control.aeTargetFpsRange (controls and dynamic) + * android.control.aePrecaptureTrigger (controls and dynamic) + * android.control.afMode (controls and dynamic) + * android.control.afRegions (controls and dynamic) + * android.control.awbLock (controls and dynamic) + * android.control.awbMode (controls and dynamic) + * android.control.awbRegions (controls and dynamic) + * android.control.captureIntent (controls and dynamic) + * android.control.effectMode (controls and dynamic) + * android.control.mode (controls and dynamic) + * android.control.sceneMode (controls and dynamic) + * android.control.videoStabilizationMode (controls and dynamic) + * android.control.aeAvailableAntibandingModes (static) + * android.control.aeAvailableModes (static) + * android.control.aeAvailableTargetFpsRanges (static) + * android.control.aeCompensationRange (static) + * android.control.aeCompensationStep (static) + * android.control.afAvailableModes (static) + * android.control.availableEffects (static) + * android.control.availableSceneModes (static) + * android.control.availableVideoStabilizationModes (static) + * android.control.awbAvailableModes (static) + * android.control.maxRegions (static) + * android.control.sceneModeOverrides (static) + * android.control.aeState (dynamic) + * android.control.afState (dynamic) + * android.control.awbState (dynamic) + * + * android.flash.mode (controls and dynamic) + * android.flash.info.available (static) + * + * android.info.supportedHardwareLevel (static) + * + * android.jpeg.gpsCoordinates (controls and dynamic) + * android.jpeg.gpsProcessingMethod (controls and dynamic) + * android.jpeg.gpsTimestamp (controls and dynamic) + * android.jpeg.orientation (controls and dynamic) + * android.jpeg.quality (controls and dynamic) + * android.jpeg.thumbnailQuality (controls and dynamic) + * android.jpeg.thumbnailSize (controls and dynamic) + * android.jpeg.availableThumbnailSizes (static) + * android.jpeg.maxSize (static) + * + * android.lens.info.minimumFocusDistance (static) + * + * android.request.id (controls and dynamic) + * + * android.scaler.cropRegion (controls and dynamic) + * android.scaler.availableStreamConfigurations (static) + * android.scaler.availableMinFrameDurations (static) + * android.scaler.availableStallDurations (static) + * android.scaler.availableMaxDigitalZoom (static) + * android.scaler.maxDigitalZoom (static) + * android.scaler.croppingType (static) + * + * android.sensor.orientation (static) + * android.sensor.timestamp (dynamic) + * + * android.statistics.faceDetectMode (controls and dynamic) + * android.statistics.info.availableFaceDetectModes (static) + * android.statistics.faceIds (dynamic) + * android.statistics.faceLandmarks (dynamic) + * android.statistics.faceRectangles (dynamic) + * android.statistics.faceScores (dynamic) + * + * android.sync.frameNumber (dynamic) + * android.sync.maxLatency (static) + * + * - Captures in limited mode that include high-resolution (> 1080p) output + * buffers may block in process_capture_request() until all the output buffers + * have been filled. A full-mode HAL device must process sequences of + * high-resolution requests at the rate indicated in the static metadata for + * that pixel format. The HAL must still call process_capture_result() to + * provide the output; the framework must simply be prepared for + * process_capture_request() to block until after process_capture_result() for + * that request completes for high-resolution captures for limited-mode + * devices. + * + * - Full-mode devices must support below additional capabilities: + * - 30fps at maximum resolution is preferred, more than 20fps is required. + * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL). + * - Sensor manual control metadata. See MANUAL_SENSOR defined in + * android.request.availableCapabilities. + * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined + * in android.request.availableCapabilities. + * + */ + +/** + * S4. 3A modes and state machines: + * + * While the actual 3A algorithms are up to the HAL implementation, a high-level + * state machine description is defined by the HAL interface, to allow the HAL + * device and the framework to communicate about the current state of 3A, and to + * trigger 3A events. + * + * When the device is opened, all the individual 3A states must be + * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked + * focus must be maintained across the configure() call. + * + * Triggering a 3A action involves simply setting the relevant trigger entry in + * the settings for the next request to indicate start of trigger. For example, + * the trigger for starting an autofocus scan is setting the entry + * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one + * request, and cancelling an autofocus scan is triggered by setting + * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, + * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each + * request with a trigger entry set to a non-IDLE value will be treated as an + * independent triggering event. + * + * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which + * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode + * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting + * (ANDROID_CONTROL_USE_SCENE_MODE). + * + * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, + * and none of the capture controls may be overridden by the 3A routines. + * + * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run + * their own independent algorithms, and have their own mode, state, and + * trigger metadata entries, as listed in the next section. + * + * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must + * be used to determine the behavior of 3A routines. In SCENE_MODEs other than + * FACE_PRIORITY, the HAL must override the values of + * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected + * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use + * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene + * must be ignored for these scene modes. + * + * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in + * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering + * and focusing on any detected faces in the scene. + * + * S4.1. Auto-focus settings and result entries: + * + * Main metadata entries: + * + * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus + * mode. Set by the framework in the request settings. + * + * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens + * position. + * + * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is + * triggered. + * + * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless + * AF is triggered. + * + * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording + * video. Triggering immediately locks focus in current + * position. Canceling resumes cotinuous focusing. + * + * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for + * zero-shutter-lag still capture. Triggering locks focus once currently + * active sweep concludes. Canceling resumes continuous focusing. + * + * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no + * autofocus scan, so triggering one or canceling one has no effect. + * Images are focused automatically by the HAL. + * + * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF + * algorithm state, reported by the HAL in the result metadata. + * + * AF_STATE_INACTIVE: No focusing has been done, or algorithm was + * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. + * When the device is opened, it must start in this state. + * + * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning + * for good focus. The lens is moving. + * + * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is + * well focused. The lens is not moving. The HAL may spontaneously leave + * this state. + * + * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is + * not well focused. The lens is not moving. The HAL may spontaneously + * leave this state. + * + * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. + * + * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The + * lens is not moving. + * + * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to + * focus. The lens is not moving. + * + * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the + * meaning of which is mode- and state- dependent. Set by the framework in + * the request settings. + * + * AF_TRIGGER_IDLE: No current trigger. + * + * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state + * dependent. + * + * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to + * default. + * + * Additional metadata entries: + * + * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV + * that should be used to determine good focus. This applies to all AF + * modes that scan for focus. Set by the framework in the request + * settings. + * + * S4.2. Auto-exposure settings and result entries: + * + * Main metadata entries: + * + * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure + * mode. Set by the framework in the request settings. + * + * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, + * frame duration, and flash. + * + * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may + * set flash to fire or to torch mode. + * + * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's + * discretion for precapture and still capture. User control of flash + * disabled. + * + * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired + * for capture, and at HAL's discretion for precapture.. User control of + * flash disabled. + * + * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at + * HAL's discretion for precapture and still capture. Use a flash burst + * at end of precapture sequence to reduce redeye in the final + * picture. User control of flash disabled. + * + * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE + * algorithm state, reported by the HAL in the result metadata. + * + * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is + * opened, it must start in this state. + * + * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting + * exposure parameters. + * + * AE_STATE_CONVERGED: AE has found good exposure values for the current + * scene, and the exposure parameters are not changing. HAL may + * spontaneously leave this state to search for better solution. + * + * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure + * values are not changing. + * + * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes + * flash is required for a sufficiently bright picture. Used for + * determining if a zero-shutter-lag frame can be used. + * + * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture + * sequence. Depending on AE mode, this mode may involve firing the + * flash for metering, or a burst of flash pulses for redeye reduction. + * + * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering + * sequence before capturing a high-quality image. Set by the framework in + * the request settings. + * + * PRECAPTURE_TRIGGER_IDLE: No current trigger. + * + * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should + * use the subsequent requests to measure good exposure/white balance + * for an upcoming high-resolution capture. + * + * Additional metadata entries: + * + * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current + * values + * + * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE + * algorithm target brightness point. + * + * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame + * rate range for the AE algorithm. The AE routine cannot change the frame + * rate to be outside these bounds. + * + * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV + * that should be used to determine good exposure levels. This applies to + * all AE modes besides OFF. + * + * S4.3. Auto-whitebalance settings and result entries: + * + * Main metadata entries: + * + * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance + * mode. + * + * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. + * + * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color + * transform, possibly using more complex transforms than a simple + * matrix. + * + * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor + * incandescent (tungsten) lighting, roughly 2700K. + * + * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent + * lighting, roughly 5000K. + * + * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for + * fluorescent lighting, roughly 3000K. + * + * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, + * roughly 5500K. + * + * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded + * daylight, roughly 6500K. + * + * AWB_MODE_TWILIGHT: Fixed white balance settings good for + * near-sunset/sunrise, roughly 15000K. + * + * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly + * lit by the sun, roughly 7500K. + * + * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB + * algorithm state, reported by the HAL in the result metadata. + * + * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device + * is opened, it must start in this state. + * + * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is + * changing color adjustment parameters. + * + * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the + * current scene, and the parameters are not changing. HAL may + * spontaneously leave this state to search for better solution. + * + * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color + * adjustment values are not changing. + * + * Additional metadata entries: + * + * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to + * their current values. + * + * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV + * that should be used to determine good color balance. This applies only + * to auto-WB mode. + * + * S4.4. General state machine transition notes + * + * Switching between AF, AE, or AWB modes always resets the algorithm's state + * to INACTIVE. Similarly, switching between CONTROL_MODE or + * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the + * algorithm states to INACTIVE. + * + * The tables below are per-mode. + * + * S4.5. AF state machines + * + * when enabling AF or changing AF mode + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| Any | AF mode change| INACTIVE | | + *+--------------------+---------------+--------------------+------------------+ + * + * mode = AF_MODE_OFF or AF_MODE_EDOF + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | | INACTIVE | Never changes | + *+--------------------+---------------+--------------------+------------------+ + * + * mode = AF_MODE_AUTO or AF_MODE_MACRO + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | + *| | | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | + *+--------------------+---------------+--------------------+------------------+ + *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | + *| | | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | + *+--------------------+---------------+--------------------+------------------+ + *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | + *| | | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| All states | mode change | INACTIVE | | + *+--------------------+---------------+--------------------+------------------+ + * + * mode = AF_MODE_CONTINUOUS_VIDEO + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | + *| | new scan | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | + *| | current scan | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | + *| | current scan | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | + *| | | | if focus is good | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | + *| | | | if focus is bad | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | + *| | | | position | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | + *| | new scan | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | + *| | new scan | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | + *+--------------------+---------------+--------------------+------------------+ + *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | + *+--------------------+---------------+--------------------+------------------+ + *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | + *+--------------------+---------------+--------------------+------------------+ + *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | + *+--------------------+---------------+--------------------+------------------+ + * + * mode = AF_MODE_CONTINUOUS_PICTURE + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | + *| | new scan | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | + *| | current scan | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | + *| | current scan | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | + *| | | | once focus good | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | + *| | | | if cannot focus | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | + *| | | | position | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | + *| | new scan | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | + *| | new scan | | Lens now moving | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | + *| | | | Lens now locked | + *+--------------------+---------------+--------------------+------------------+ + *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | + *+--------------------+---------------+--------------------+------------------+ + *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | + *+--------------------+---------------+--------------------+------------------+ + *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | + *+--------------------+---------------+--------------------+------------------+ + *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | + *+--------------------+---------------+--------------------+------------------+ + * + * S4.6. AE and AWB state machines + * + * The AE and AWB state machines are mostly identical. AE has additional + * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two + * states should be ignored for the AWB state machine. + * + * when enabling AE/AWB or changing AE/AWB mode + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| Any | mode change | INACTIVE | | + *+--------------------+---------------+--------------------+------------------+ + * + * mode = AE_MODE_OFF / AWB mode not AUTO + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | | INACTIVE | AE/AWB disabled | + *+--------------------+---------------+--------------------+------------------+ + * + * mode = AE_MODE_ON_* / AWB_MODE_AUTO + *| state | trans. cause | new state | notes | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | HAL initiates | SEARCHING | | + *| | AE/AWB scan | | | + *+--------------------+---------------+--------------------+------------------+ + *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | + *| | on | | | + *+--------------------+---------------+--------------------+------------------+ + *| SEARCHING | HAL finishes | CONVERGED | good values, not | + *| | AE/AWB scan | | changing | + *+--------------------+---------------+--------------------+------------------+ + *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| + *| | AE scan | | dark w/o flash | + *+--------------------+---------------+--------------------+------------------+ + *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | + *| | on | | | + *+--------------------+---------------+--------------------+------------------+ + *| CONVERGED | HAL initiates | SEARCHING | values locked | + *| | AE/AWB scan | | | + *+--------------------+---------------+--------------------+------------------+ + *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | + *| | on | | | + *+--------------------+---------------+--------------------+------------------+ + *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | + *| | AE/AWB scan | | | + *+--------------------+---------------+--------------------+------------------+ + *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | + *| | on | | | + *+--------------------+---------------+--------------------+------------------+ + *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | + *| | off | | after unlock | + *+--------------------+---------------+--------------------+------------------+ + *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | + *| | off | | after unlock | + *+--------------------+---------------+--------------------+------------------+ + *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | + *| | off | | but too dark | + *+--------------------+---------------+--------------------+------------------+ + *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | + *| | START | | sequence | + *+--------------------+---------------+--------------------+------------------+ + *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | + *| | AE_LOCK off | | quality capture | + *+--------------------+---------------+--------------------+------------------+ + *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | + *| | AE_LOCK on | | quality capture | + *+--------------------+---------------+--------------------+------------------+ + * + */ + +/** + * S5. Cropping: + * + * Cropping of the full pixel array (for digital zoom and other use cases where + * a smaller FOV is desirable) is communicated through the + * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can + * change on a per-request basis, which is critical for implementing smooth + * digital zoom. + * + * The region is defined as a rectangle (x, y, width, height), with (x, y) + * describing the top-left corner of the rectangle. The rectangle is defined on + * the coordinate system of the sensor active pixel array, with (0,0) being the + * top-left pixel of the active pixel array. Therefore, the width and height + * cannot be larger than the dimensions reported in the + * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed + * width and height are reported by the HAL through the + * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the + * maximum supported zoom factor. Therefore, the minimum crop region width and + * height are: + * + * {width, height} = + * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / + * ANDROID_SCALER_MAX_DIGITAL_ZOOM), + * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / + * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } + * + * If the crop region needs to fulfill specific requirements (for example, it + * needs to start on even coordinates, and its width/height needs to be even), + * the HAL must do the necessary rounding and write out the final crop region + * used in the output result metadata. Similarly, if the HAL implements video + * stabilization, it must adjust the result crop region to describe the region + * actually included in the output after video stabilization is applied. In + * general, a camera-using application must be able to determine the field of + * view it is receiving based on the crop region, the dimensions of the image + * sensor, and the lens focal length. + * + * It is assumed that the cropping is applied after raw to other color space + * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage, + * and are not croppable. Therefore, the crop region must be ignored by the HAL + * for raw streams. + * + * Since the crop region applies to all non-raw streams, which may have different aspect + * ratios than the crop region, the exact sensor region used for each stream may + * be smaller than the crop region. Specifically, each stream should maintain + * square pixels and its aspect ratio by minimally further cropping the defined + * crop region. If the stream's aspect ratio is wider than the crop region, the + * stream should be further cropped vertically, and if the stream's aspect ratio + * is narrower than the crop region, the stream should be further cropped + * horizontally. + * + * In all cases, the stream crop must be centered within the full crop region, + * and each stream is only either cropped horizontally or vertical relative to + * the full crop region, never both. + * + * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a + * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions + * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x + * 1500 pixel array) sensor. + * + * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) + * + * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) + * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) + * + * 0 1000 2000 + * +---------+---------+---------+----------+ + * | Active pixel array | + * | | + * | | + * + +-------------------+ + 375 + * | | | | + * | O===================O | + * | I 1280x720 stream I | + * + I I + 750 + * | I I | + * | O===================O | + * | | | | + * + +-------------------+ + 1125 + * | Crop region, 640x480 stream | + * | | + * | | + * +---------+---------+---------+----------+ 1500 + * + * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) + * + * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) + * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) + * + * 0 1000 2000 + * +---------+---------+---------+----------+ + * | Active pixel array | + * | | + * | | + * + +---O==================O---+ + 375 + * | | I 640x480 stream I | | + * | | I I | | + * | | I I | | + * + | I I | + 750 + * | | I I | | + * | | I I | | + * | | I I | | + * + +---O==================O---+ + 1125 + * | Crop region, 1280x720 stream | + * | | + * | | + * +---------+---------+---------+----------+ 1500 + * + * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) + * + * 640x480 stream crop: (500, 469, 750, 562) (marked with =) + * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) + * + * 0 1000 2000 + * +---------+---------+---------+----------+ + * | Active pixel array | + * | | + * | | + * + +--------------+ + 375 + * | O==============O | + * | ################ | + * | # # | + * + # # + 750 + * | # # | + * | ################ 1280x720 | + * | O==============O 640x480 | + * + +--------------+ + 1125 + * | Crop region | + * | | + * | | + * +---------+---------+---------+----------+ 1500 + * + * And a final example, a 1024x1024 square aspect ratio stream instead of the + * 480p stream: + * + * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) + * + * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) + * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) + * + * 0 1000 2000 + * +---------+---------+---------+----------+ + * | Active pixel array | + * | | + * | 1024x1024 stream | + * + +--###############--+ + 375 + * | | # # | | + * | O===================O | + * | I 1280x720 stream I | + * + I I + 750 + * | I I | + * | O===================O | + * | | # # | | + * + +--###############--+ + 1125 + * | Crop region | + * | | + * | | + * +---------+---------+---------+----------+ 1500 + * + */ + +/** + * S6. Error management: + * + * Camera HAL device ops functions that have a return value will all return + * -ENODEV / NULL in case of a serious error. This means the device cannot + * continue operation, and must be closed by the framework. Once this error is + * returned by some method, or if notify() is called with ERROR_DEVICE, only + * the close() method can be called successfully. All other methods will return + * -ENODEV / NULL. + * + * If a device op is called in the wrong sequence, for example if the framework + * calls configure_streams() is called before initialize(), the device must + * return -ENOSYS from the call, and do nothing. + * + * Transient errors in image capture must be reported through notify() as follows: + * + * - The failure of an entire capture to occur must be reported by the HAL by + * calling notify() with ERROR_REQUEST. Individual errors for the result + * metadata or the output buffers must not be reported in this case. + * + * - If the metadata for a capture cannot be produced, but some image buffers + * were filled, the HAL must call notify() with ERROR_RESULT. + * + * - If an output image buffer could not be filled, but either the metadata was + * produced or some other buffers were filled, the HAL must call notify() with + * ERROR_BUFFER for each failed buffer. + * + * In each of these transient failure cases, the HAL must still call + * process_capture_result, with valid output and input (if an input buffer was + * submitted) buffer_handle_t. If the result metadata could not be produced, it + * should be NULL. If some buffers could not be filled, they must be returned with + * process_capture_result in the error state, their release fences must be set to + * the acquire fences passed by the framework, or -1 if they have been waited on by + * the HAL already. + * + * Invalid input arguments result in -EINVAL from the appropriate methods. In + * that case, the framework must act as if that call had never been made. + * + */ + +/** + * S7. Key Performance Indicator (KPI) glossary: + * + * This includes some critical definitions that are used by KPI metrics. + * + * Pipeline Latency: + * For a given capture request, the duration from the framework calling + * process_capture_request to the HAL sending capture result and all buffers + * back by process_capture_result call. To make the Pipeline Latency measure + * independent of frame rate, it is measured by frame count. + * + * For example, when frame rate is 30 (fps), the frame duration (time interval + * between adjacent frame capture time) is 33 (ms). + * If it takes 5 frames for framework to get the result and buffers back for + * a given request, then the Pipeline Latency is 5 (frames), instead of + * 5 x 33 = 165 (ms). + * + * The Pipeline Latency is determined by android.request.pipelineDepth and + * android.request.pipelineMaxDepth, see their definitions for more details. + * + */ + +/** + * S8. Sample Use Cases: + * + * This includes some typical use case examples the camera HAL may support. + * + * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream. + * + * For this use case, the bidirectional stream will be used by the framework as follows: + * + * 1. The framework includes a buffer from this stream as output buffer in a + * request as normal. + * + * 2. Once the HAL device returns a filled output buffer to the framework, + * the framework may do one of two things with the filled buffer: + * + * 2. a. The framework uses the filled data, and returns the now-used buffer + * to the stream queue for reuse. This behavior exactly matches the + * OUTPUT type of stream. + * + * 2. b. The framework wants to reprocess the filled data, and uses the + * buffer as an input buffer for a request. Once the HAL device has + * used the reprocessing buffer, it then returns it to the + * framework. The framework then returns the now-used buffer to the + * stream queue for reuse. + * + * 3. The HAL device will be given the buffer again as an output buffer for + * a request at some future point. + * + * For ZSL use case, the pixel format for bidirectional stream will be + * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it + * is listed in android.scaler.availableInputOutputFormatsMap. When + * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc + * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL. + * A configuration stream list that has BIDIRECTIONAL stream used as input, will + * usually also have a distinct OUTPUT stream to get the reprocessing data. For example, + * for the ZSL use case, the stream list might be configured with the following: + * + * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used + * as input. + * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream. + * + * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream. + * + * CAMERA_DEVICE_API_VERSION_3_3: + * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream + * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL). + * This kind of stream will be used by the framework as follows: + * + * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is + * used to produce the ZSL output buffers. The stream pixel format will be + * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. + * + * 2. Application/framework configures an opaque format input stream that is used to + * send the reprocessing ZSL buffers to the HAL. The stream pixel format will + * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. + * + * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the + * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. + * + * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is + * issued by the application, and sends the data back as an input buffer in a + * reprocessing request, then sends to the HAL for reprocessing. + * + * 5. The HAL sends back the output YUV/JPEG result to framework. + * + * The HAL can select the actual opaque buffer format and configure the ISP pipeline + * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and + * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL. + + * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream. + * + * When YUV reprocessing is supported by the HAL, the INPUT stream + * can be used for the YUV reprocessing use cases like lucky-shot and image fusion. + * This kind of stream will be used by the framework as follows: + * + * 1. Application/framework configures an YCbCr_420 format output stream that is + * used to produce the output buffers. + * + * 2. Application/framework configures an YCbCr_420 format input stream that is used to + * send the reprocessing YUV buffers to the HAL. + * + * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the + * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. + * + * 4. Application/framework processes the output buffers (could be as simple as picking + * an output buffer directly) from the output stream when a capture is issued, and sends + * the data back as an input buffer in a reprocessing request, then sends to the HAL + * for reprocessing. + * + * 5. The HAL sends back the output YUV/JPEG result to framework. + * + */ + +/** + * S9. Notes on Controls and Metadata + * + * This section contains notes about the interpretation and usage of various metadata tags. + * + * S9.1 HIGH_QUALITY and FAST modes. + * + * Many camera post-processing blocks may be listed as having HIGH_QUALITY, + * FAST, and OFF operating modes. These blocks will typically also have an + * 'available modes' tag representing which of these operating modes are + * available on a given device. The general policy regarding implementing + * these modes is as follows: + * + * 1. Operating mode controls of hardware blocks that cannot be disabled + * must not list OFF in their corresponding 'available modes' tags. + * + * 2. OFF will always be included in their corresponding 'available modes' + * tag if it is possible to disable that hardware block. + * + * 3. FAST must always be included in the 'available modes' tags for all + * post-processing blocks supported on the device. If a post-processing + * block also has a slower and higher quality operating mode that does + * not meet the framerate requirements for FAST mode, HIGH_QUALITY should + * be included in the 'available modes' tag to represent this operating + * mode. + */ + +/** + * S10. Reprocessing flow and controls + * + * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing + * uses an opaque format that is not directly application-visible, and the application can + * only select some of the output buffers and send back to HAL for reprocessing, while YUV + * reprocessing gives the application opportunity to process the buffers before reprocessing. + * + * S8 gives the stream configurations for the typical reprocessing uses cases, + * this section specifies the buffer flow and controls in more details. + * + * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls + * + * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific + * output and input streams, runtime buffer flow and controls are specified as below: + * + * 1. Application starts output streaming by sending repeating requests for output + * opaque buffers and preview. The buffers are held by an application + * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG + * capture template, which should have all necessary settings that guarantee output + * frame rate is not slowed down relative to sensor output frame rate. + * + * 2. When a capture is issued, the application selects one output buffer based + * on application buffer selection logic, e.g. good AE and AF statistics etc. + * Application then creates an reprocess request based on the capture result associated + * with this selected buffer. The selected output buffer is now added to this reprocess + * request as an input buffer, the output buffer of this reprocess request should be + * either JPEG output buffer or YUV output buffer, or both, depending on the application + * choice. + * + * 3. Application then alters the reprocess settings to get best image quality. The HAL must + * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability: + * - android.jpeg.* (if JPEG buffer is included as one of the output) + * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported) + * - android.edge.mode (change to HIGH_QUALITY if it is supported) + * All other controls must be ignored by the HAL. + * 4. HAL processed the input buffer and return the output buffers in the capture results + * as normal. + * + * S10.2 YUV reprocessing flow and controls + * + * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference: + * + * 1. Application may want to have finer granularity control of the intermediate YUV images + * (before reprocessing). For example, application may choose + * - android.noiseReduction.mode == MINIMAL + * to make sure the no YUV domain noise reduction has applied to the output YUV buffers, + * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this + * doesn't matter, as long as the final reprocessed image has the best quality. + * 2. Application may modify the YUV output buffer data. For example, for image fusion use + * case, where multiple output images are merged together to improve the signal-to-noise + * ratio (SNR). The input buffer may be generated from multiple buffers by the application. + * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement + * being applied to the input buffer, the application can hint the HAL how much effective + * exposure time improvement has been done by the application, then the HAL can adjust the + * noise reduction and edge enhancement paramters to get best reprocessed image quality. + * Below tag can be used for this purpose: + * - android.reprocess.effectiveExposureFactor + * The value would be exposure time increase factor applied to the original output image, + * for example, if there are N image merged, the exposure time increase factor would be up + * to sqrt(N). See this tag spec for more details. + * + * S10.3 Reprocessing pipeline characteristics + * + * Reprocessing pipeline has below different characteristics comparing with normal output + * pipeline: + * + * 1. The reprocessing result can be returned ahead of the pending normal output results. But + * the FIFO ordering must be maintained for all reprocessing results. For example, there are + * below requests (A stands for output requests, B stands for reprocessing requests) + * being processed by the HAL: + * A1, A2, A3, A4, B1, A5, B2, A6... + * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1. + * 2. Single input rule: For a given reprocessing request, all output buffers must be from the + * input buffer, rather than sensor output. For example, if a reprocess request include both + * JPEG and preview buffers, all output buffers must be produced from the input buffer + * included by the reprocessing request, rather than sensor. The HAL must not output preview + * buffers from sensor, while output JPEG buffer from the input buffer. + * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion + * case). For the case where buffer is modified, the size will remain same. The HAL can + * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent. + * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy + * of one of the output results with minor allowed setting changes. The HAL can notify + * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued. + * 5. Output buffers may not be used as inputs across the configure stream boundary, This is + * because an opaque stream like the ZSL output stream may have different actual image size + * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture. + * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs. + * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified + * by flush() method. + * + */ + +__BEGIN_DECLS + +struct camera3_device; + +/********************************************************************** + * + * Camera3 stream and stream buffer definitions. + * + * These structs and enums define the handles and contents of the input and + * output streams connecting the HAL to various framework and application buffer + * consumers. Each stream is backed by a gralloc buffer queue. + * + */ + +/** + * camera3_stream_type_t: + * + * The type of the camera stream, which defines whether the camera HAL device is + * the producer or the consumer for that stream, and how the buffers of the + * stream relate to the other streams. + */ +typedef enum camera3_stream_type { + /** + * This stream is an output stream; the camera HAL device will be + * responsible for filling buffers from this stream with newly captured or + * reprocessed image data. + */ + CAMERA3_STREAM_OUTPUT = 0, + + /** + * This stream is an input stream; the camera HAL device will be responsible + * for reading buffers from this stream and sending them through the camera + * processing pipeline, as if the buffer was a newly captured image from the + * imager. + * + * The pixel format for input stream can be any format reported by + * android.scaler.availableInputOutputFormatsMap. The pixel format of the + * output stream that is used to produce the reprocessing data may be any + * format reported by android.scaler.availableStreamConfigurations. The + * supported input/output stream combinations depends the camera device + * capabilities, see android.scaler.availableInputOutputFormatsMap for + * stream map details. + * + * This kind of stream is generally used to reprocess data into higher + * quality images (that otherwise would cause a frame rate performance + * loss), or to do off-line reprocessing. + * + * CAMERA_DEVICE_API_VERSION_3_3: + * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing, + * see S8.2, S8.3 and S10 for more details. + */ + CAMERA3_STREAM_INPUT = 1, + + /** + * This stream can be used for input and output. Typically, the stream is + * used as an output stream, but occasionally one already-filled buffer may + * be sent back to the HAL device for reprocessing. + * + * This kind of stream is meant generally for Zero Shutter Lag (ZSL) + * features, where copying the captured image from the output buffer to the + * reprocessing input buffer would be expensive. See S8.1 for more details. + * + * Note that the HAL will always be reprocessing data it produced. + * + */ + CAMERA3_STREAM_BIDIRECTIONAL = 2, + + /** + * Total number of framework-defined stream types + */ + CAMERA3_NUM_STREAM_TYPES + +} camera3_stream_type_t; + +/** + * camera3_stream_rotation_t: + * + * The required counterclockwise rotation of camera stream. + */ +typedef enum camera3_stream_rotation { + /* No rotation */ + CAMERA3_STREAM_ROTATION_0 = 0, + + /* Rotate by 90 degree counterclockwise */ + CAMERA3_STREAM_ROTATION_90 = 1, + + /* Rotate by 180 degree counterclockwise */ + CAMERA3_STREAM_ROTATION_180 = 2, + + /* Rotate by 270 degree counterclockwise */ + CAMERA3_STREAM_ROTATION_270 = 3 +} camera3_stream_rotation_t; + +/** + * camera3_stream_configuration_mode_t: + * + * This defines the general operation mode for the HAL (for a given stream configuration), where + * modes besides NORMAL have different semantics, and usually limit the generality of the API in + * exchange for higher performance in some particular area. + */ +typedef enum camera3_stream_configuration_mode { + /** + * Normal stream configuration operation mode. This is the default camera operation mode, + * where all semantics of HAL APIs and metadata controls apply. + */ + CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, + + /** + * Special constrained high speed operation mode for devices that can not support high + * speed output in NORMAL mode. All streams in this configuration are operating at high speed + * mode and have different characteristics and limitations to achieve high speed output. + * The NORMAL mode can still be used for high speed output if the HAL can support high speed + * output while satisfying all the semantics of HAL APIs and metadata controls. It is + * recommended for the HAL to support high speed output in NORMAL mode (by advertising the high + * speed FPS ranges in android.control.aeAvailableTargetFpsRanges) if possible. + * + * This mode has below limitations/requirements: + * + * 1. The HAL must support up to 2 streams with sizes reported by + * android.control.availableHighSpeedVideoConfigurations. + * 2. In this mode, the HAL is expected to output up to 120fps or higher. This mode must + * support the targeted FPS range and size configurations reported by + * android.control.availableHighSpeedVideoConfigurations. + * 3. The HAL must support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED output stream format. + * 4. To achieve efficient high speed streaming, the HAL may have to aggregate + * multiple frames together and send to camera device for processing where the request + * controls are same for all the frames in this batch (batch mode). The HAL must support + * max batch size and the max batch size requirements defined by + * android.control.availableHighSpeedVideoConfigurations. + * 5. In this mode, the HAL must override aeMode, awbMode, and afMode to ON, ON, and + * CONTINUOUS_VIDEO, respectively. All post-processing block mode controls must be + * overridden to be FAST. Therefore, no manual control of capture and post-processing + * parameters is possible. All other controls operate the same as when + * android.control.mode == AUTO. This means that all other android.control.* fields + * must continue to work, such as + * + * android.control.aeTargetFpsRange + * android.control.aeExposureCompensation + * android.control.aeLock + * android.control.awbLock + * android.control.effectMode + * android.control.aeRegions + * android.control.afRegions + * android.control.awbRegions + * android.control.afTrigger + * android.control.aePrecaptureTrigger + * + * Outside of android.control.*, the following controls must work: + * + * android.flash.mode (TORCH mode only, automatic flash for still capture will not work + * since aeMode is ON) + * android.lens.opticalStabilizationMode (if it is supported) + * android.scaler.cropRegion + * android.statistics.faceDetectMode (if it is supported) + * + * For more details about high speed stream requirements, see + * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO + * capability defined in android.request.availableCapabilities. + * + * This mode only needs to be supported by HALs that include CONSTRAINED_HIGH_SPEED_VIDEO in + * the android.request.availableCapabilities static metadata. + */ + CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1, + + /** + * First value for vendor-defined stream configuration modes. + */ + CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000 +} camera3_stream_configuration_mode_t; + +/** + * camera3_stream_t: + * + * A handle to a single camera input or output stream. A stream is defined by + * the framework by its buffer resolution and format, and additionally by the + * HAL with the gralloc usage flags and the maximum in-flight buffer count. + * + * The stream structures are owned by the framework, but pointers to a + * camera3_stream passed into the HAL by configure_streams() are valid until the + * end of the first subsequent configure_streams() call that _does not_ include + * that camera3_stream as an argument, or until the end of the close() call. + * + * All camera3_stream framework-controlled members are immutable once the + * camera3_stream is passed into configure_streams(). The HAL may only change + * the HAL-controlled parameters during a configure_streams() call, except for + * the contents of the private pointer. + * + * If a configure_streams() call returns a non-fatal error, all active streams + * remain valid as if configure_streams() had not been called. + * + * The endpoint of the stream is not visible to the camera HAL device. + * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags + * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream + * types) see the usage field below. + */ +typedef struct camera3_stream { + + /***** + * Set by framework before configure_streams() + */ + + /** + * The type of the stream, one of the camera3_stream_type_t values. + */ + int stream_type; + + /** + * The width in pixels of the buffers in this stream + */ + uint32_t width; + + /** + * The height in pixels of the buffers in this stream + */ + uint32_t height; + + /** + * The pixel format for the buffers in this stream. Format is a value from + * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or + * from device-specific headers. + * + * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform + * gralloc module will select a format based on the usage flags provided by + * the camera device and the other endpoint of the stream. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * The camera HAL device must inspect the buffers handed to it in the + * subsequent register_stream_buffers() call to obtain the + * implementation-specific format details, if necessary. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * register_stream_buffers() won't be called by the framework, so the HAL + * should configure the ISP and sensor pipeline based purely on the sizes, + * usage flags, and formats for the configured streams. + */ + int format; + + /***** + * Set by HAL during configure_streams(). + */ + + /** + * The gralloc usage flags for this stream, as needed by the HAL. The usage + * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific + * headers. + * + * For output streams, these are the HAL's producer usage flags. For input + * streams, these are the HAL's consumer usage flags. The usage flags from + * the producer and the consumer will be combined together and then passed + * to the platform gralloc HAL module for allocating the gralloc buffers for + * each stream. + * + * Version information: + * + * == CAMERA_DEVICE_API_VERSION_3_0: + * + * No initial value guaranteed when passed via configure_streams(). + * HAL may not use this field as input, and must write over this field + * with its usage flags. + * + * >= CAMERA_DEVICE_API_VERSION_3_1: + * + * For stream_type OUTPUT and BIDIRECTIONAL, when passed via + * configure_streams(), the initial value of this is the consumer's + * usage flags. The HAL may use these consumer flags to decide stream + * configuration. + * For stream_type INPUT, when passed via configure_streams(), the initial + * value of this is 0. + * For all streams passed via configure_streams(), the HAL must write + * over this field with its usage flags. + */ + uint32_t usage; + + /** + * The maximum number of buffers the HAL device may need to have dequeued at + * the same time. The HAL device may not have more buffers in-flight from + * this stream than this value. + */ + uint32_t max_buffers; + + /** + * A handle to HAL-private information for the stream. Will not be inspected + * by the framework code. + */ + void *priv; + + /** + * A field that describes the contents of the buffer. The format and buffer + * dimensions define the memory layout and structure of the stream buffers, + * while dataSpace defines the meaning of the data within the buffer. + * + * For most formats, dataSpace defines the color space of the image data. + * In addition, for some formats, dataSpace indicates whether image- or + * depth-based data is requested. See system/core/include/system/graphics.h + * for details of formats and valid dataSpace values for each format. + * + * Version information: + * + * < CAMERA_DEVICE_API_VERSION_3_3: + * + * Not defined and should not be accessed. dataSpace should be assumed to + * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should + * be determined from the usage flags and the format. + * + * >= CAMERA_DEVICE_API_VERSION_3_3: + * + * Always set by the camera service. HAL must use this dataSpace to + * configure the stream to the correct colorspace, or to select between + * color and depth outputs if supported. + */ + android_dataspace_t data_space; + + /** + * The required output rotation of the stream, one of + * the camera3_stream_rotation_t values. This must be inspected by HAL along + * with stream width and height. For example, if the rotation is 90 degree + * and the stream width and height is 720 and 1280 respectively, camera service + * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image + * and rotate the image by 90 degree counterclockwise. The rotation field is + * no-op when the stream type is input. Camera HAL must ignore the rotation + * field for an input stream. + * + * <= CAMERA_DEVICE_API_VERSION_3_2: + * + * Not defined and must not be accessed. HAL must not apply any rotation + * on output images. + * + * >= CAMERA_DEVICE_API_VERSION_3_3: + * + * Always set by camera service. HAL must inspect this field during stream + * configuration and returns -EINVAL if HAL cannot perform such rotation. + * HAL must always support CAMERA3_STREAM_ROTATION_0, so a + * configure_streams() call must not fail for unsupported rotation if + * rotation field of all streams is CAMERA3_STREAM_ROTATION_0. + * + */ + int rotation; + + /** + * This should be one of the camera3_stream_rotation_t values except for + * CAMERA3_STREAM_ROTATION_180. + * When setting to CAMERA3_STREAM_ROTATION_90 or CAMERA3_STREAM_ROTATION_270, HAL would crop, + * rotate the frame by the specified degrees clockwise and scale it up to original size. + * In Chrome OS, it's possible to have a portrait activity run in a landscape screen with + * landscape-mounted camera. The activity would show stretched or rotated preview because it + * does not expect to receive landscape preview frames. To solve this problem, we ask HAL to + * crop, rotate and scale the frames and modify CameraCharacteristics.SENSOR_ORIENTATION + * accordingly to imitate a portrait camera. + * Setting it to CAMERA3_STREAM_ROTATION_0 means no crop-rotate-scale would be performed. + * |cros_rotate_scale_degrees| in all camera3_stream_t of a configure_streams() call must be + * identical. The HAL should return -EINVAL if the degrees are not the same for all the streams. + */ + int crop_rotate_scale_degrees; + + /* reserved for future use */ + void *reserved[6]; + +} camera3_stream_t; + +/** + * camera3_stream_configuration_t: + * + * A structure of stream definitions, used by configure_streams(). This + * structure defines all the output streams and the reprocessing input + * stream for the current camera use case. + */ +typedef struct camera3_stream_configuration { + /** + * The total number of streams requested by the framework. This includes + * both input and output streams. The number of streams will be at least 1, + * and there will be at least one output-capable stream. + */ + uint32_t num_streams; + + /** + * An array of camera stream pointers, defining the input/output + * configuration for the camera HAL device. + * + * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) + * in a single configuration. + * + * At least one output-capable stream must be defined (OUTPUT or + * BIDIRECTIONAL). + */ + camera3_stream_t **streams; + + /** + * >= CAMERA_DEVICE_API_VERSION_3_3: + * + * The operation mode of streams in this configuration, one of the value defined in + * camera3_stream_configuration_mode_t. + * The HAL can use this mode as an indicator to set the stream property (e.g., + * camera3_stream->max_buffers) appropriately. For example, if the configuration is + * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may want to set aside more + * buffers for batch mode operation (see android.control.availableHighSpeedVideoConfigurations + * for batch mode definition). + * + */ + uint32_t operation_mode; +} camera3_stream_configuration_t; + +/** + * camera3_buffer_status_t: + * + * The current status of a single stream buffer. + */ +typedef enum camera3_buffer_status { + /** + * The buffer is in a normal state, and can be used after waiting on its + * sync fence. + */ + CAMERA3_BUFFER_STATUS_OK = 0, + + /** + * The buffer does not contain valid data, and the data in it should not be + * used. The sync fence must still be waited on before reusing the buffer. + */ + CAMERA3_BUFFER_STATUS_ERROR = 1 + +} camera3_buffer_status_t; + +/** + * camera3_stream_buffer_t: + * + * A single buffer from a camera3 stream. It includes a handle to its parent + * stream, the handle to the gralloc buffer itself, and sync fences + * + * The buffer does not specify whether it is to be used for input or output; + * that is determined by its parent stream type and how the buffer is passed to + * the HAL device. + */ +typedef struct camera3_stream_buffer { + /** + * The handle of the stream this buffer is associated with + */ + camera3_stream_t *stream; + + /** + * The native handle to the buffer + */ + buffer_handle_t *buffer; + + /** + * Current state of the buffer, one of the camera3_buffer_status_t + * values. The framework will not pass buffers to the HAL that are in an + * error state. In case a buffer could not be filled by the HAL, it must + * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the + * framework with process_capture_result(). + */ + int status; + + /** + * The acquire sync fence for this buffer. The HAL must wait on this fence + * fd before attempting to read from or write to this buffer. + * + * The framework may be set to -1 to indicate that no waiting is necessary + * for this buffer. + * + * When the HAL returns an output buffer to the framework with + * process_capture_result(), the acquire_fence must be set to -1. If the HAL + * never waits on the acquire_fence due to an error in filling a buffer, + * when calling process_capture_result() the HAL must set the release_fence + * of the buffer to be the acquire_fence passed to it by the framework. This + * will allow the framework to wait on the fence before reusing the buffer. + * + * For input buffers, the HAL must not change the acquire_fence field during + * the process_capture_request() call. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * When the HAL returns an input buffer to the framework with + * process_capture_result(), the acquire_fence must be set to -1. If the HAL + * never waits on input buffer acquire fence due to an error, the sync + * fences should be handled similarly to the way they are handled for output + * buffers. + */ + int acquire_fence; + + /** + * The release sync fence for this buffer. The HAL must set this fence when + * returning buffers to the framework, or write -1 to indicate that no + * waiting is required for this buffer. + * + * For the output buffers, the fences must be set in the output_buffers + * array passed to process_capture_result(). + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * For the input buffer, the release fence must be set by the + * process_capture_request() call. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * For the input buffer, the fences must be set in the input_buffer + * passed to process_capture_result(). + * + * After signaling the release_fence for this buffer, the HAL + * should not make any further attempts to access this buffer as the + * ownership has been fully transferred back to the framework. + * + * If a fence of -1 was specified then the ownership of this buffer + * is transferred back immediately upon the call of process_capture_result. + */ + int release_fence; + +} camera3_stream_buffer_t; + +/** + * camera3_stream_buffer_set_t: + * + * The complete set of gralloc buffers for a stream. This structure is given to + * register_stream_buffers() to allow the camera HAL device to register/map/etc + * newly allocated stream buffers. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Deprecated (and not used). In particular, + * register_stream_buffers is also deprecated and will never be invoked. + * + */ +typedef struct camera3_stream_buffer_set { + /** + * The stream handle for the stream these buffers belong to + */ + camera3_stream_t *stream; + + /** + * The number of buffers in this stream. It is guaranteed to be at least + * stream->max_buffers. + */ + uint32_t num_buffers; + + /** + * The array of gralloc buffer handles for this stream. If the stream format + * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device + * should inspect the passed-in buffers to determine any platform-private + * pixel format information. + */ + buffer_handle_t **buffers; + +} camera3_stream_buffer_set_t; + +/** + * camera3_jpeg_blob: + * + * Transport header for compressed JPEG buffers in output streams. + * + * To capture JPEG images, a stream is created using the pixel format + * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the + * framework, based on the static metadata field android.jpeg.maxSize. Since + * compressed JPEG images are of variable size, the HAL needs to include the + * final size of the compressed image using this structure inside the output + * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID. + * + * Transport header should be at the end of the JPEG output stream buffer. That + * means the jpeg_blob_id must start at byte[buffer_size - + * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer. + * Any HAL using this transport header must account for it in android.jpeg.maxSize + * The JPEG data itself starts at the beginning of the buffer and should be + * jpeg_size bytes long. + */ +typedef struct camera3_jpeg_blob { + uint16_t jpeg_blob_id; + uint32_t jpeg_size; +} camera3_jpeg_blob_t; + +enum { + CAMERA3_JPEG_BLOB_ID = 0x00FF +}; + +/********************************************************************** + * + * Message definitions for the HAL notify() callback. + * + * These definitions are used for the HAL notify callback, to signal + * asynchronous events from the HAL device to the Android framework. + * + */ + +/** + * camera3_msg_type: + * + * Indicates the type of message sent, which specifies which member of the + * message union is valid. + * + */ +typedef enum camera3_msg_type { + /** + * An error has occurred. camera3_notify_msg.message.error contains the + * error information. + */ + CAMERA3_MSG_ERROR = 1, + + /** + * The exposure of a given request or processing a reprocess request has + * begun. camera3_notify_msg.message.shutter contains the information + * the capture. + */ + CAMERA3_MSG_SHUTTER = 2, + + /** + * Number of framework message types + */ + CAMERA3_NUM_MESSAGES + +} camera3_msg_type_t; + +/** + * Defined error codes for CAMERA_MSG_ERROR + */ +typedef enum camera3_error_msg_code { + /** + * A serious failure occured. No further frames or buffer streams will + * be produced by the device. Device should be treated as closed. The + * client must reopen the device to use it again. The frame_number field + * is unused. + */ + CAMERA3_MSG_ERROR_DEVICE = 1, + + /** + * An error has occurred in processing a request. No output (metadata or + * buffers) will be produced for this request. The frame_number field + * specifies which request has been dropped. Subsequent requests are + * unaffected, and the device remains operational. + */ + CAMERA3_MSG_ERROR_REQUEST = 2, + + /** + * An error has occurred in producing an output result metadata buffer + * for a request, but output stream buffers for it will still be + * available. Subsequent requests are unaffected, and the device remains + * operational. The frame_number field specifies the request for which + * result metadata won't be available. + */ + CAMERA3_MSG_ERROR_RESULT = 3, + + /** + * An error has occurred in placing an output buffer into a stream for a + * request. The frame metadata and other buffers may still be + * available. Subsequent requests are unaffected, and the device remains + * operational. The frame_number field specifies the request for which the + * buffer was dropped, and error_stream contains a pointer to the stream + * that dropped the frame.u + */ + CAMERA3_MSG_ERROR_BUFFER = 4, + + /** + * Number of error types + */ + CAMERA3_MSG_NUM_ERRORS + +} camera3_error_msg_code_t; + +/** + * camera3_error_msg_t: + * + * Message contents for CAMERA3_MSG_ERROR + */ +typedef struct camera3_error_msg { + /** + * Frame number of the request the error applies to. 0 if the frame number + * isn't applicable to the error. + */ + uint32_t frame_number; + + /** + * Pointer to the stream that had a failure. NULL if the stream isn't + * applicable to the error. + */ + camera3_stream_t *error_stream; + + /** + * The code for this error; one of the CAMERA_MSG_ERROR enum values. + */ + int error_code; + +} camera3_error_msg_t; + +/** + * camera3_shutter_msg_t: + * + * Message contents for CAMERA3_MSG_SHUTTER + */ +typedef struct camera3_shutter_msg { + /** + * Frame number of the request that has begun exposure or reprocessing. + */ + uint32_t frame_number; + + /** + * Timestamp for the start of capture. For a reprocess request, this must + * be input image's start of capture. This must match the capture result + * metadata's sensor exposure start timestamp. + */ + uint64_t timestamp; + +} camera3_shutter_msg_t; + +/** + * camera3_notify_msg_t: + * + * The message structure sent to camera3_callback_ops_t.notify() + */ +typedef struct camera3_notify_msg { + + /** + * The message type. One of camera3_notify_msg_type, or a private extension. + */ + int type; + + union { + /** + * Error message contents. Valid if type is CAMERA3_MSG_ERROR + */ + camera3_error_msg_t error; + + /** + * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER + */ + camera3_shutter_msg_t shutter; + + /** + * Generic message contents. Used to ensure a minimum size for custom + * message types. + */ + uint8_t generic[32]; + } message; + +} camera3_notify_msg_t; + +/********************************************************************** + * + * Capture request/result definitions for the HAL process_capture_request() + * method, and the process_capture_result() callback. + * + */ + +/** + * camera3_request_template_t: + * + * Available template types for + * camera3_device_ops.construct_default_request_settings() + */ +typedef enum camera3_request_template { + /** + * Standard camera preview operation with 3A on auto. + */ + CAMERA3_TEMPLATE_PREVIEW = 1, + + /** + * Standard camera high-quality still capture with 3A and flash on auto. + */ + CAMERA3_TEMPLATE_STILL_CAPTURE = 2, + + /** + * Standard video recording plus preview with 3A on auto, torch off. + */ + CAMERA3_TEMPLATE_VIDEO_RECORD = 3, + + /** + * High-quality still capture while recording video. Application will + * include preview, video record, and full-resolution YUV or JPEG streams in + * request. Must not cause stuttering on video stream. 3A on auto. + */ + CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, + + /** + * Zero-shutter-lag mode. Application will request preview and + * full-resolution data for each frame, and reprocess it to JPEG when a + * still image is requested by user. Settings should provide highest-quality + * full-resolution images without compromising preview frame rate. 3A on + * auto. + */ + CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, + + /** + * A basic template for direct application control of capture + * parameters. All automatic control is disabled (auto-exposure, auto-white + * balance, auto-focus), and post-processing parameters are set to preview + * quality. The manual capture parameters (exposure, sensitivity, etc.) + * are set to reasonable defaults, but should be overridden by the + * application depending on the intended use case. + */ + CAMERA3_TEMPLATE_MANUAL = 6, + + /* Total number of templates */ + CAMERA3_TEMPLATE_COUNT, + + /** + * First value for vendor-defined request templates + */ + CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 + +} camera3_request_template_t; + +/** + * camera3_capture_request_t: + * + * A single request for image capture/buffer reprocessing, sent to the Camera + * HAL device by the framework in process_capture_request(). + * + * The request contains the settings to be used for this capture, and the set of + * output buffers to write the resulting image data in. It may optionally + * contain an input buffer, in which case the request is for reprocessing that + * input buffer instead of capturing a new image with the camera sensor. The + * capture is identified by the frame_number. + * + * In response, the camera HAL device must send a camera3_capture_result + * structure asynchronously to the framework, using the process_capture_result() + * callback. + */ +typedef struct camera3_capture_request { + /** + * The frame number is an incrementing integer set by the framework to + * uniquely identify this capture. It needs to be returned in the result + * call, and is also used to identify the request in asynchronous + * notifications sent to camera3_callback_ops_t.notify(). + */ + uint32_t frame_number; + + /** + * The settings buffer contains the capture and processing parameters for + * the request. As a special case, a NULL settings buffer indicates that the + * settings are identical to the most-recently submitted capture request. A + * NULL buffer cannot be used as the first submitted request after a + * configure_streams() call. + */ + const camera_metadata_t *settings; + + /** + * The input stream buffer to use for this request, if any. + * + * If input_buffer is NULL, then the request is for a new capture from the + * imager. If input_buffer is valid, the request is for reprocessing the + * image contained in input_buffer. + * + * In the latter case, the HAL must set the release_fence of the + * input_buffer to a valid sync fence, or to -1 if the HAL does not support + * sync, before process_capture_request() returns. + * + * The HAL is required to wait on the acquire sync fence of the input buffer + * before accessing it. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * Any input buffer included here will have been registered with the HAL + * through register_stream_buffers() before its inclusion in a request. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * The buffers will not have been pre-registered with the HAL. + * Subsequent requests may reuse buffers, or provide entirely new buffers. + */ + camera3_stream_buffer_t *input_buffer; + + /** + * The number of output buffers for this capture request. Must be at least + * 1. + */ + uint32_t num_output_buffers; + + /** + * An array of num_output_buffers stream buffers, to be filled with image + * data from this capture/reprocess. The HAL must wait on the acquire fences + * of each stream buffer before writing to them. + * + * The HAL takes ownership of the actual buffer_handle_t entries in + * output_buffers; the framework does not access them until they are + * returned in a camera3_capture_result_t. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * All the buffers included here will have been registered with the HAL + * through register_stream_buffers() before their inclusion in a request. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Any or all of the buffers included here may be brand new in this + * request (having never before seen by the HAL). + */ + const camera3_stream_buffer_t *output_buffers; + +} camera3_capture_request_t; + +/** + * camera3_capture_result_t: + * + * The result of a single capture/reprocess by the camera HAL device. This is + * sent to the framework asynchronously with process_capture_result(), in + * response to a single capture request sent to the HAL with + * process_capture_request(). Multiple process_capture_result() calls may be + * performed by the HAL for each request. + * + * Each call, all with the same frame + * number, may contain some subset of the output buffers, and/or the result + * metadata. The metadata may only be provided once for a given frame number; + * all other calls must set the result metadata to NULL. + * + * The result structure contains the output metadata from this capture, and the + * set of output buffers that have been/will be filled for this capture. Each + * output buffer may come with a release sync fence that the framework will wait + * on before reading, in case the buffer has not yet been filled by the HAL. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * The metadata may be provided multiple times for a single frame number. The + * framework will accumulate together the final result set by combining each + * partial result together into the total result set. + * + * If an input buffer is given in a request, the HAL must return it in one of + * the process_capture_result calls, and the call may be to just return the input + * buffer, without metadata and output buffers; the sync fences must be handled + * the same way they are done for output buffers. + * + * + * Performance considerations: + * + * Applications will also receive these partial results immediately, so sending + * partial results is a highly recommended performance optimization to avoid + * the total pipeline latency before sending the results for what is known very + * early on in the pipeline. + * + * A typical use case might be calculating the AF state halfway through the + * pipeline; by sending the state back to the framework immediately, we get a + * 50% performance increase and perceived responsiveness of the auto-focus. + * + */ +typedef struct camera3_capture_result { + /** + * The frame number is an incrementing integer set by the framework in the + * submitted request to uniquely identify this capture. It is also used to + * identify the request in asynchronous notifications sent to + * camera3_callback_ops_t.notify(). + */ + uint32_t frame_number; + + /** + * The result metadata for this capture. This contains information about the + * final capture parameters, the state of the capture and post-processing + * hardware, the state of the 3A algorithms, if enabled, and the output of + * any enabled statistics units. + * + * Only one call to process_capture_result() with a given frame_number may + * include the result metadata. All other calls for the same frame_number + * must set this to NULL. + * + * If there was an error producing the result metadata, result must be an + * empty metadata buffer, and notify() must be called with ERROR_RESULT. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Multiple calls to process_capture_result() with a given frame_number + * may include the result metadata. + * + * Partial metadata submitted should not include any metadata key returned + * in a previous partial result for a given frame. Each new partial result + * for that frame must also set a distinct partial_result value. + * + * If notify has been called with ERROR_RESULT, all further partial + * results for that frame are ignored by the framework. + */ + const camera_metadata_t *result; + + /** + * The number of output buffers returned in this result structure. Must be + * less than or equal to the matching capture request's count. If this is + * less than the buffer count in the capture request, at least one more call + * to process_capture_result with the same frame_number must be made, to + * return the remaining output buffers to the framework. This may only be + * zero if the structure includes valid result metadata or an input buffer + * is returned in this result. + */ + uint32_t num_output_buffers; + + /** + * The handles for the output stream buffers for this capture. They may not + * yet be filled at the time the HAL calls process_capture_result(); the + * framework will wait on the release sync fences provided by the HAL before + * reading the buffers. + * + * The HAL must set the stream buffer's release sync fence to a valid sync + * fd, or to -1 if the buffer has already been filled. + * + * If the HAL encounters an error while processing the buffer, and the + * buffer is not filled, the buffer's status field must be set to + * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence + * before encountering the error, the acquire fence should be copied into + * the release fence, to allow the framework to wait on the fence before + * reusing the buffer. + * + * The acquire fence must be set to -1 for all output buffers. If + * num_output_buffers is zero, this may be NULL. In that case, at least one + * more process_capture_result call must be made by the HAL to provide the + * output buffers. + * + * When process_capture_result is called with a new buffer for a frame, + * all previous frames' buffers for that corresponding stream must have been + * already delivered (the fences need not have yet been signaled). + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Gralloc buffers for a frame may be sent to framework before the + * corresponding SHUTTER-notify. + * + * Performance considerations: + * + * Buffers delivered to the framework will not be dispatched to the + * application layer until a start of exposure timestamp has been received + * via a SHUTTER notify() call. It is highly recommended to + * dispatch that call as early as possible. + */ + const camera3_stream_buffer_t *output_buffers; + + /** + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * The handle for the input stream buffer for this capture. It may not + * yet be consumed at the time the HAL calls process_capture_result(); the + * framework will wait on the release sync fences provided by the HAL before + * reusing the buffer. + * + * The HAL should handle the sync fences the same way they are done for + * output_buffers. + * + * Only one input buffer is allowed to be sent per request. Similarly to + * output buffers, the ordering of returned input buffers must be + * maintained by the HAL. + * + * Performance considerations: + * + * The input buffer should be returned as early as possible. If the HAL + * supports sync fences, it can call process_capture_result to hand it back + * with sync fences being set appropriately. If the sync fences are not + * supported, the buffer can only be returned when it is consumed, which + * may take long time; the HAL may choose to copy this input buffer to make + * the buffer return sooner. + */ + const camera3_stream_buffer_t *input_buffer; + + /** + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * In order to take advantage of partial results, the HAL must set the + * static metadata android.request.partialResultCount to the number of + * partial results it will send for each frame. + * + * Each new capture result with a partial result must set + * this field (partial_result) to a distinct inclusive value between + * 1 and android.request.partialResultCount. + * + * HALs not wishing to take advantage of this feature must not + * set an android.request.partialResultCount or partial_result to a value + * other than 1. + * + * This value must be set to 0 when a capture result contains buffers only + * and no metadata. + */ + uint32_t partial_result; + +} camera3_capture_result_t; + +/********************************************************************** + * + * Callback methods for the HAL to call into the framework. + * + * These methods are used to return metadata and image buffers for a completed + * or failed captures, and to notify the framework of asynchronous events such + * as errors. + * + * The framework will not call back into the HAL from within these callbacks, + * and these calls will not block for extended periods. + * + */ +typedef struct camera3_callback_ops { + + /** + * process_capture_result: + * + * Send results from a completed capture to the framework. + * process_capture_result() may be invoked multiple times by the HAL in + * response to a single capture request. This allows, for example, the + * metadata and low-resolution buffers to be returned in one call, and + * post-processed JPEG buffers in a later call, once it is available. Each + * call must include the frame number of the request it is returning + * metadata or buffers for. + * + * A component (buffer or metadata) of the complete result may only be + * included in one process_capture_result call. A buffer for each stream, + * and the result metadata, must be returned by the HAL for each request in + * one of the process_capture_result calls, even in case of errors producing + * some of the output. A call to process_capture_result() with neither + * output buffers or result metadata is not allowed. + * + * The order of returning metadata and buffers for a single result does not + * matter, but buffers for a given stream must be returned in FIFO order. So + * the buffer for request 5 for stream A must always be returned before the + * buffer for request 6 for stream A. This also applies to the result + * metadata; the metadata for request 5 must be returned before the metadata + * for request 6. + * + * However, different streams are independent of each other, so it is + * acceptable and expected that the buffer for request 5 for stream A may be + * returned after the buffer for request 6 for stream B is. And it is + * acceptable that the result metadata for request 6 for stream B is + * returned before the buffer for request 5 for stream A is. + * + * The HAL retains ownership of result structure, which only needs to be + * valid to access during this call. The framework will copy whatever it + * needs before this call returns. + * + * The output buffers do not need to be filled yet; the framework will wait + * on the stream buffer release sync fence before reading the buffer + * data. Therefore, this method should be called by the HAL as soon as + * possible, even if some or all of the output buffers are still in + * being filled. The HAL must include valid release sync fences into each + * output_buffers stream buffer entry, or -1 if that stream buffer is + * already filled. + * + * If the result buffer cannot be constructed for a request, the HAL should + * return an empty metadata buffer, but still provide the output buffers and + * their sync fences. In addition, notify() must be called with an + * ERROR_RESULT message. + * + * If an output buffer cannot be filled, its status field must be set to + * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER + * message. + * + * If the entire capture has failed, then this method still needs to be + * called to return the output buffers to the framework. All the buffer + * statuses should be STATUS_ERROR, and the result metadata should be an + * empty buffer. In addition, notify() must be called with a ERROR_REQUEST + * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages + * should not be sent. + * + * Performance requirements: + * + * This is a non-blocking call. The framework will return this call in 5ms. + * + * The pipeline latency (see S7 for definition) should be less than or equal to + * 4 frame intervals, and must be less than or equal to 8 frame intervals. + * + */ + void (*process_capture_result)(const struct camera3_callback_ops *, + const camera3_capture_result_t *result); + + /** + * notify: + * + * Asynchronous notification callback from the HAL, fired for various + * reasons. Only for information independent of frame capture, or that + * require specific timing. The ownership of the message structure remains + * with the HAL, and the msg only needs to be valid for the duration of this + * call. + * + * Multiple threads may call notify() simultaneously. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * The notification for the start of exposure for a given request must be + * sent by the HAL before the first call to process_capture_result() for + * that request is made. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Buffers delivered to the framework will not be dispatched to the + * application layer until a start of exposure timestamp (or input image's + * start of exposure timestamp for a reprocess request) has been received + * via a SHUTTER notify() call. It is highly recommended to dispatch this + * call as early as possible. + * + * ------------------------------------------------------------------------ + * Performance requirements: + * + * This is a non-blocking call. The framework will return this call in 5ms. + */ + void (*notify)(const struct camera3_callback_ops *, + const camera3_notify_msg_t *msg); + +} camera3_callback_ops_t; + +/********************************************************************** + * + * Camera device operations + * + */ +typedef struct camera3_device_ops { + + /** + * initialize: + * + * One-time initialization to pass framework callback function pointers to + * the HAL. Will be called once after a successful open() call, before any + * other functions are called on the camera3_device_ops structure. + * + * Performance requirements: + * + * This should be a non-blocking call. The HAL should return from this call + * in 5ms, and must return from this call in 10ms. + * + * Return values: + * + * 0: On successful initialization + * + * -ENODEV: If initialization fails. Only close() can be called successfully + * by the framework after this. + */ + int (*initialize)(const struct camera3_device *, + const camera3_callback_ops_t *callback_ops); + + /********************************************************************** + * Stream management + */ + + /** + * configure_streams: + * + * CAMERA_DEVICE_API_VERSION_3_0 only: + * + * Reset the HAL camera device processing pipeline and set up new input and + * output streams. This call replaces any existing stream configuration with + * the streams defined in the stream_list. This method will be called at + * least once after initialize() before a request is submitted with + * process_capture_request(). + * + * The stream_list must contain at least one output-capable stream, and may + * not contain more than one input-capable stream. + * + * The stream_list may contain streams that are also in the currently-active + * set of streams (from the previous call to configure_stream()). These + * streams will already have valid values for usage, max_buffers, and the + * private pointer. + * + * If such a stream has already had its buffers registered, + * register_stream_buffers() will not be called again for the stream, and + * buffers from the stream can be immediately included in input requests. + * + * If the HAL needs to change the stream configuration for an existing + * stream due to the new configuration, it may rewrite the values of usage + * and/or max_buffers during the configure call. + * + * The framework will detect such a change, and will then reallocate the + * stream buffers, and call register_stream_buffers() again before using + * buffers from that stream in a request. + * + * If a currently-active stream is not included in stream_list, the HAL may + * safely remove any references to that stream. It will not be reused in a + * later configure() call by the framework, and all the gralloc buffers for + * it will be freed after the configure_streams() call returns. + * + * The stream_list structure is owned by the framework, and may not be + * accessed once this call completes. The address of an individual + * camera3_stream_t structure will remain valid for access by the HAL until + * the end of the first configure_stream() call which no longer includes + * that camera3_stream_t in the stream_list argument. The HAL may not change + * values in the stream structure outside of the private pointer, except for + * the usage and max_buffers members during the configure_streams() call + * itself. + * + * If the stream is new, the usage, max_buffer, and private pointer fields + * of the stream structure will all be set to 0. The HAL device must set + * these fields before the configure_streams() call returns. These fields + * are then used by the framework and the platform gralloc module to + * allocate the gralloc buffers for each stream. + * + * Before such a new stream can have its buffers included in a capture + * request, the framework will call register_stream_buffers() with that + * stream. However, the framework is not required to register buffers for + * _all_ streams before submitting a request. This allows for quick startup + * of (for example) a preview stream, with allocation for other streams + * happening later or concurrently. + * + * ------------------------------------------------------------------------ + * CAMERA_DEVICE_API_VERSION_3_1 only: + * + * Reset the HAL camera device processing pipeline and set up new input and + * output streams. This call replaces any existing stream configuration with + * the streams defined in the stream_list. This method will be called at + * least once after initialize() before a request is submitted with + * process_capture_request(). + * + * The stream_list must contain at least one output-capable stream, and may + * not contain more than one input-capable stream. + * + * The stream_list may contain streams that are also in the currently-active + * set of streams (from the previous call to configure_stream()). These + * streams will already have valid values for usage, max_buffers, and the + * private pointer. + * + * If such a stream has already had its buffers registered, + * register_stream_buffers() will not be called again for the stream, and + * buffers from the stream can be immediately included in input requests. + * + * If the HAL needs to change the stream configuration for an existing + * stream due to the new configuration, it may rewrite the values of usage + * and/or max_buffers during the configure call. + * + * The framework will detect such a change, and will then reallocate the + * stream buffers, and call register_stream_buffers() again before using + * buffers from that stream in a request. + * + * If a currently-active stream is not included in stream_list, the HAL may + * safely remove any references to that stream. It will not be reused in a + * later configure() call by the framework, and all the gralloc buffers for + * it will be freed after the configure_streams() call returns. + * + * The stream_list structure is owned by the framework, and may not be + * accessed once this call completes. The address of an individual + * camera3_stream_t structure will remain valid for access by the HAL until + * the end of the first configure_stream() call which no longer includes + * that camera3_stream_t in the stream_list argument. The HAL may not change + * values in the stream structure outside of the private pointer, except for + * the usage and max_buffers members during the configure_streams() call + * itself. + * + * If the stream is new, max_buffer, and private pointer fields of the + * stream structure will all be set to 0. The usage will be set to the + * consumer usage flags. The HAL device must set these fields before the + * configure_streams() call returns. These fields are then used by the + * framework and the platform gralloc module to allocate the gralloc + * buffers for each stream. + * + * Before such a new stream can have its buffers included in a capture + * request, the framework will call register_stream_buffers() with that + * stream. However, the framework is not required to register buffers for + * _all_ streams before submitting a request. This allows for quick startup + * of (for example) a preview stream, with allocation for other streams + * happening later or concurrently. + * + * ------------------------------------------------------------------------ + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * Reset the HAL camera device processing pipeline and set up new input and + * output streams. This call replaces any existing stream configuration with + * the streams defined in the stream_list. This method will be called at + * least once after initialize() before a request is submitted with + * process_capture_request(). + * + * The stream_list must contain at least one output-capable stream, and may + * not contain more than one input-capable stream. + * + * The stream_list may contain streams that are also in the currently-active + * set of streams (from the previous call to configure_stream()). These + * streams will already have valid values for usage, max_buffers, and the + * private pointer. + * + * If the HAL needs to change the stream configuration for an existing + * stream due to the new configuration, it may rewrite the values of usage + * and/or max_buffers during the configure call. + * + * The framework will detect such a change, and may then reallocate the + * stream buffers before using buffers from that stream in a request. + * + * If a currently-active stream is not included in stream_list, the HAL may + * safely remove any references to that stream. It will not be reused in a + * later configure() call by the framework, and all the gralloc buffers for + * it will be freed after the configure_streams() call returns. + * + * The stream_list structure is owned by the framework, and may not be + * accessed once this call completes. The address of an individual + * camera3_stream_t structure will remain valid for access by the HAL until + * the end of the first configure_stream() call which no longer includes + * that camera3_stream_t in the stream_list argument. The HAL may not change + * values in the stream structure outside of the private pointer, except for + * the usage and max_buffers members during the configure_streams() call + * itself. + * + * If the stream is new, max_buffer, and private pointer fields of the + * stream structure will all be set to 0. The usage will be set to the + * consumer usage flags. The HAL device must set these fields before the + * configure_streams() call returns. These fields are then used by the + * framework and the platform gralloc module to allocate the gralloc + * buffers for each stream. + * + * Newly allocated buffers may be included in a capture request at any time + * by the framework. Once a gralloc buffer is returned to the framework + * with process_capture_result (and its respective release_fence has been + * signaled) the framework may free or reuse it at any time. + * + * ------------------------------------------------------------------------ + * + * Preconditions: + * + * The framework will only call this method when no captures are being + * processed. That is, all results have been returned to the framework, and + * all in-flight input and output buffers have been returned and their + * release sync fences have been signaled by the HAL. The framework will not + * submit new requests for capture while the configure_streams() call is + * underway. + * + * Postconditions: + * + * The HAL device must configure itself to provide maximum possible output + * frame rate given the sizes and formats of the output streams, as + * documented in the camera device's static metadata. + * + * Performance requirements: + * + * This call is expected to be heavyweight and possibly take several hundred + * milliseconds to complete, since it may require resetting and + * reconfiguring the image sensor and the camera processing pipeline. + * Nevertheless, the HAL device should attempt to minimize the + * reconfiguration delay to minimize the user-visible pauses during + * application operational mode changes (such as switching from still + * capture to video recording). + * + * The HAL should return from this call in 500ms, and must return from this + * call in 1000ms. + * + * Return values: + * + * 0: On successful stream configuration + * + * -EINVAL: If the requested stream configuration is invalid. Some examples + * of invalid stream configurations include: + * + * - Including more than 1 input-capable stream (INPUT or + * BIDIRECTIONAL) + * + * - Not including any output-capable streams (OUTPUT or + * BIDIRECTIONAL) + * + * - Including streams with unsupported formats, or an unsupported + * size for that format. + * + * - Including too many output streams of a certain format. + * + * - Unsupported rotation configuration (only applies to + * devices with version >= CAMERA_DEVICE_API_VERSION_3_3) + * + * - Stream sizes/formats don't satisfy the + * camera3_stream_configuration_t->operation_mode requirements for non-NORMAL mode, + * or the requested operation_mode is not supported by the HAL. + * (only applies to devices with version >= CAMERA_DEVICE_API_VERSION_3_3) + * + * Note that the framework submitting an invalid stream + * configuration is not normal operation, since stream + * configurations are checked before configure. An invalid + * configuration means that a bug exists in the framework code, or + * there is a mismatch between the HAL's static metadata and the + * requirements on streams. + * + * -ENODEV: If there has been a fatal error and the device is no longer + * operational. Only close() can be called successfully by the + * framework after this error is returned. + */ + int (*configure_streams)(const struct camera3_device *, + camera3_stream_configuration_t *stream_list); + + /** + * register_stream_buffers: + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * DEPRECATED. This will not be called and must be set to NULL. + * + * <= CAMERA_DEVICE_API_VERSION_3_1: + * + * Register buffers for a given stream with the HAL device. This method is + * called by the framework after a new stream is defined by + * configure_streams, and before buffers from that stream are included in a + * capture request. If the same stream is listed in a subsequent + * configure_streams() call, register_stream_buffers will _not_ be called + * again for that stream. + * + * The framework does not need to register buffers for all configured + * streams before it submits the first capture request. This allows quick + * startup for preview (or similar use cases) while other streams are still + * being allocated. + * + * This method is intended to allow the HAL device to map or otherwise + * prepare the buffers for later use. The buffers passed in will already be + * locked for use. At the end of the call, all the buffers must be ready to + * be returned to the stream. The buffer_set argument is only valid for the + * duration of this call. + * + * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, + * the camera HAL should inspect the passed-in buffers here to determine any + * platform-private pixel format information. + * + * Performance requirements: + * + * This should be a non-blocking call. The HAL should return from this call + * in 1ms, and must return from this call in 5ms. + * + * Return values: + * + * 0: On successful registration of the new stream buffers + * + * -EINVAL: If the stream_buffer_set does not refer to a valid active + * stream, or if the buffers array is invalid. + * + * -ENOMEM: If there was a failure in registering the buffers. The framework + * must consider all the stream buffers to be unregistered, and can + * try to register again later. + * + * -ENODEV: If there is a fatal error, and the device is no longer + * operational. Only close() can be called successfully by the + * framework after this error is returned. + */ + int (*register_stream_buffers)(const struct camera3_device *, + const camera3_stream_buffer_set_t *buffer_set); + + /********************************************************************** + * Request creation and submission + */ + + /** + * construct_default_request_settings: + * + * Create capture settings for standard camera use cases. + * + * The device must return a settings buffer that is configured to meet the + * requested use case, which must be one of the CAMERA3_TEMPLATE_* + * enums. All request control fields must be included. + * + * The HAL retains ownership of this structure, but the pointer to the + * structure must be valid until the device is closed. The framework and the + * HAL may not modify the buffer once it is returned by this call. The same + * buffer may be returned for subsequent calls for the same template, or for + * other templates. + * + * Performance requirements: + * + * This should be a non-blocking call. The HAL should return from this call + * in 1ms, and must return from this call in 5ms. + * + * Return values: + * + * Valid metadata: On successful creation of a default settings + * buffer. + * + * NULL: In case of a fatal error. After this is returned, only + * the close() method can be called successfully by the + * framework. + */ + const camera_metadata_t* (*construct_default_request_settings)( + const struct camera3_device *, + int type); + + /** + * process_capture_request: + * + * Send a new capture request to the HAL. The HAL should not return from + * this call until it is ready to accept the next request to process. Only + * one call to process_capture_request() will be made at a time by the + * framework, and the calls will all be from the same thread. The next call + * to process_capture_request() will be made as soon as a new request and + * its associated buffers are available. In a normal preview scenario, this + * means the function will be called again by the framework almost + * instantly. + * + * The actual request processing is asynchronous, with the results of + * capture being returned by the HAL through the process_capture_result() + * call. This call requires the result metadata to be available, but output + * buffers may simply provide sync fences to wait on. Multiple requests are + * expected to be in flight at once, to maintain full output frame rate. + * + * The framework retains ownership of the request structure. It is only + * guaranteed to be valid during this call. The HAL device must make copies + * of the information it needs to retain for the capture processing. The HAL + * is responsible for waiting on and closing the buffers' fences and + * returning the buffer handles to the framework. + * + * The HAL must write the file descriptor for the input buffer's release + * sync fence into input_buffer->release_fence, if input_buffer is not + * NULL. If the HAL returns -1 for the input buffer release sync fence, the + * framework is free to immediately reuse the input buffer. Otherwise, the + * framework will wait on the sync fence before refilling and reusing the + * input buffer. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * + * The input/output buffers provided by the framework in each request + * may be brand new (having never before seen by the HAL). + * + * ------------------------------------------------------------------------ + * Performance considerations: + * + * Handling a new buffer should be extremely lightweight and there should be + * no frame rate degradation or frame jitter introduced. + * + * This call must return fast enough to ensure that the requested frame + * rate can be sustained, especially for streaming cases (post-processing + * quality settings set to FAST). The HAL should return this call in 1 + * frame interval, and must return from this call in 4 frame intervals. + * + * Return values: + * + * 0: On a successful start to processing the capture request + * + * -EINVAL: If the input is malformed (the settings are NULL when not + * allowed, there are 0 output buffers, etc) and capture processing + * cannot start. Failures during request processing should be + * handled by calling camera3_callback_ops_t.notify(). In case of + * this error, the framework will retain responsibility for the + * stream buffers' fences and the buffer handles; the HAL should + * not close the fences or return these buffers with + * process_capture_result. + * + * -ENODEV: If the camera device has encountered a serious error. After this + * error is returned, only the close() method can be successfully + * called by the framework. + * + */ + int (*process_capture_request)(const struct camera3_device *, + camera3_capture_request_t *request); + + /********************************************************************** + * Miscellaneous methods + */ + + /** + * get_metadata_vendor_tag_ops: + * + * Get methods to query for vendor extension metadata tag information. The + * HAL should fill in all the vendor tag operation methods, or leave ops + * unchanged if no vendor tags are defined. + * + * The definition of vendor_tag_query_ops_t can be found in + * system/media/camera/include/system/camera_metadata.h. + * + * >= CAMERA_DEVICE_API_VERSION_3_2: + * DEPRECATED. This function has been deprecated and should be set to + * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h + * instead. + */ + void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, + vendor_tag_query_ops_t* ops); + + /** + * dump: + * + * Print out debugging state for the camera device. This will be called by + * the framework when the camera service is asked for a debug dump, which + * happens when using the dumpsys tool, or when capturing a bugreport. + * + * The passed-in file descriptor can be used to write debugging text using + * dprintf() or write(). The text should be in ASCII encoding only. + * + * Performance requirements: + * + * This must be a non-blocking call. The HAL should return from this call + * in 1ms, must return from this call in 10ms. This call must avoid + * deadlocks, as it may be called at any point during camera operation. + * Any synchronization primitives used (such as mutex locks or semaphores) + * should be acquired with a timeout. + */ + void (*dump)(const struct camera3_device *, int fd); + + /** + * flush: + * + * Flush all currently in-process captures and all buffers in the pipeline + * on the given device. The framework will use this to dump all state as + * quickly as possible in order to prepare for a configure_streams() call. + * + * No buffers are required to be successfully returned, so every buffer + * held at the time of flush() (whether successfully filled or not) may be + * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed + * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, + * provided they are successfully filled. + * + * All requests currently in the HAL are expected to be returned as soon as + * possible. Not-in-process requests should return errors immediately. Any + * interruptible hardware blocks should be stopped, and any uninterruptible + * blocks should be waited on. + * + * flush() may be called concurrently to process_capture_request(), with the expectation that + * process_capture_request will return quickly and the request submitted in that + * process_capture_request call is treated like all other in-flight requests. Due to + * concurrency issues, it is possible that from the HAL's point of view, a + * process_capture_request() call may be started after flush has been invoked but has not + * returned yet. If such a call happens before flush() returns, the HAL should treat the new + * capture request like other in-flight pending requests (see #4 below). + * + * More specifically, the HAL must follow below requirements for various cases: + * + * 1. For captures that are too late for the HAL to cancel/stop, and will be + * completed normally by the HAL; i.e. the HAL can send shutter/notify and + * process_capture_result and buffers as normal. + * + * 2. For pending requests that have not done any processing, the HAL must call notify + * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with + * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR). + * The HAL must not place the release fence into an error state, instead, + * the release fences must be set to the acquire fences passed by the framework, + * or -1 if they have been waited on by the HAL already. This is also the path + * to follow for any captures for which the HAL already called notify() with + * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for. + * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with + * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or + * process_capture_result with non-null metadata is allowed. + * + * 3. For partially completed pending requests that will not have all the output + * buffers or perhaps missing metadata, the HAL should follow below: + * + * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result + * metadata (i.e. one or more partial metadata) won't be available for the capture. + * + * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't + * be produced for the capture. + * + * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before + * any buffers/metadata are returned with process_capture_result. + * + * 3.4 For captures that will produce some results, the HAL must not call + * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure. + * + * 3.5. Valid buffers/metadata should be passed to the framework as normal. + * + * 3.6. Failed buffers should be returned to the framework as described for case 2. + * But failed buffers do not have to follow the strict ordering valid buffers do, + * and may be out-of-order with respect to valid buffers. For example, if buffers + * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable + * return order. + * + * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no + * need to call process_capture_result with NULL metadata or equivalent. + * + * 4. If a flush() is invoked while a process_capture_request() invocation is active, that + * process call should return as soon as possible. In addition, if a process_capture_request() + * call is made after flush() has been invoked but before flush() has returned, the + * capture request provided by the late process_capture_request call should be treated like + * a pending request in case #2 above. + * + * flush() should only return when there are no more outstanding buffers or + * requests left in the HAL. The framework may call configure_streams (as + * the HAL state is now quiesced) or may issue new requests. + * + * Note that it's sufficient to only support fully-succeeded and fully-failed result cases. + * However, it is highly desirable to support the partial failure cases as well, as it + * could help improve the flush call overall performance. + * + * Performance requirements: + * + * The HAL should return from this call in 100ms, and must return from this + * call in 1000ms. And this call must not be blocked longer than pipeline + * latency (see S7 for definition). + * + * Version information: + * + * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. + * + * Return values: + * + * 0: On a successful flush of the camera HAL. + * + * -EINVAL: If the input is malformed (the device is not valid). + * + * -ENODEV: If the camera device has encountered a serious error. After this + * error is returned, only the close() method can be successfully + * called by the framework. + */ + int (*flush)(const struct camera3_device *); + + /* reserved for future use */ + void *reserved[8]; +} camera3_device_ops_t; + +/********************************************************************** + * + * Camera device definition + * + */ +typedef struct camera3_device { + /** + * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this + * device as implementing version 3.0 of the camera device HAL. + * + * Performance requirements: + * + * Camera open (common.module->common.methods->open) should return in 200ms, and must return + * in 500ms. + * Camera close (common.close) should return in 200ms, and must return in 500ms. + * + */ + hw_device_t common; + camera3_device_ops_t *ops; + void *priv; +} camera3_device_t; + +__END_DECLS + +#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ diff --git a/include/android/hardware/libhardware/include/hardware/camera_common.h b/include/android/hardware/libhardware/include/hardware/camera_common.h new file mode 100644 index 000000000000..7658dd4062f3 --- /dev/null +++ b/include/android/hardware/libhardware/include/hardware/camera_common.h @@ -0,0 +1,916 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// FIXME: add well-defined names for cameras + +#ifndef ANDROID_INCLUDE_CAMERA_COMMON_H +#define ANDROID_INCLUDE_CAMERA_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/** + * The id of this module + */ +#define CAMERA_HARDWARE_MODULE_ID "camera" + +/** + * Module versioning information for the Camera hardware module, based on + * camera_module_t.common.module_api_version. The two most significant hex + * digits represent the major version, and the two least significant represent + * the minor version. + * + ******************************************************************************* + * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] + * + * Camera modules that report these version numbers implement the initial + * camera module HAL interface. All camera devices openable through this + * module support only version 1 of the camera device HAL. The device_version + * and static_camera_characteristics fields of camera_info are not valid. Only + * the android.hardware.Camera API can be supported by this module and its + * devices. + * + ******************************************************************************* + * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] + * + * Camera modules that report this version number implement the second version + * of the camera module HAL interface. Camera devices openable through this + * module may support either version 1.0 or version 2.0 of the camera device + * HAL interface. The device_version field of camera_info is always valid; the + * static_camera_characteristics field of camera_info is valid if the + * device_version field is 2.0 or higher. + * + ******************************************************************************* + * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] + * + * This camera module version adds support for asynchronous callbacks to the + * framework from the camera HAL module, which is used to notify the framework + * about changes to the camera module state. Modules that provide a valid + * set_callbacks() method must report at least this version number. + * + ******************************************************************************* + * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] + * + * This camera module version adds vendor tag support from the module, and + * deprecates the old vendor_tag_query_ops that were previously only + * accessible with a device open. + * + ******************************************************************************* + * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] + * + * This camera module version adds open legacy camera HAL device support. + * Framework can use it to open the camera device as lower device HAL version + * HAL device if the same device can support multiple device API versions. + * The standard hardware module open call (common.methods->open) continues + * to open the camera device with the latest supported version, which is + * also the version listed in camera_info_t.device_version. + * + ******************************************************************************* + * Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4] + * + * This camera module version adds below API changes: + * + * 1. Torch mode support. The framework can use it to turn on torch mode for + * any camera device that has a flash unit, without opening a camera device. The + * camera device has a higher priority accessing the flash unit than the camera + * module; opening a camera device will turn off the torch if it had been enabled + * through the module interface. When there are any resource conflicts, such as + * open() is called to open a camera device, the camera HAL module must notify the + * framework through the torch mode status callback that the torch mode has been + * turned off. + * + * 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that + * the camera static info is only available when camera is connected and ready to + * use for external hot-plug cameras. Calls to get static info will be invalid + * calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks + * will only count on device status change callbacks to manage the available external + * camera list. + * + * 3. Camera arbitration hints. This module version adds support for explicitly + * indicating the number of camera devices that can be simultaneously opened and used. + * To specify valid combinations of devices, the resource_cost and conflicting_devices + * fields should always be set in the camera_info structure returned by the + * get_camera_info call. + * + * 4. Module initialization method. This will be called by the camera service + * right after the HAL module is loaded, to allow for one-time initialization + * of the HAL. It is called before any other module methods are invoked. + */ + +/** + * Predefined macros for currently-defined version numbers + */ + +/** + * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated + * as CAMERA_MODULE_API_VERSION_1_0 + */ +#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) +#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) +#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) +#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) +#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) +#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4) + +#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4 + +/** + * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated + * as CAMERA_DEVICE_API_VERSION_1_0 + */ +#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) +#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) +#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) +#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) +#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) +#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2) +#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) + +// Device version 3.3 is current, older HAL camera device versions are not +// recommended for new devices. +#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3 + +/** + * Defined in /system/media/camera/include/system/camera_metadata.h + */ +typedef struct camera_metadata camera_metadata_t; + +typedef struct camera_info { + /** + * The direction that the camera faces to. See system/core/include/system/camera.h + * for camera facing definitions. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT. + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or + * CAMERA_FACING_EXTERNAL. + */ + int facing; + + /** + * The orientation of the camera image. The value is the angle that the + * camera image needs to be rotated clockwise so it shows correctly on the + * display in its natural orientation. It should be 0, 90, 180, or 270. + * + * For example, suppose a device has a naturally tall screen. The + * back-facing camera sensor is mounted in landscape. You are looking at the + * screen. If the top side of the camera sensor is aligned with the right + * edge of the screen in natural orientation, the value should be 90. If the + * top side of a front-facing camera sensor is aligned with the right of the + * screen, the value should be 270. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * Valid in all camera_module versions. + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT, + * not valid if camera facing is CAMERA_FACING_EXTERNAL. + */ + int orientation; + + /** + * The value of camera_device_t.common.version. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_0: + * + * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do + * not read this field. + * + * CAMERA_MODULE_API_VERSION_2_0 or higher: + * + * Always valid + * + */ + uint32_t device_version; + + /** + * The camera's fixed characteristics, which include all static camera metadata + * specified in system/media/camera/docs/docs.html. This should be a sorted metadata + * buffer, and may not be modified or freed by the caller. The pointer should remain + * valid for the lifetime of the camera module, and values in it may not + * change after it is returned by get_camera_info(). + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_0: + * + * Not valid. Extra characteristics are not available. Do not read this + * field. + * + * CAMERA_MODULE_API_VERSION_2_0 or higher: + * + * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read + * otherwise. + * + */ + const camera_metadata_t *static_camera_characteristics; + + /** + * The total resource "cost" of using this camera, represented as an integer + * value in the range [0, 100] where 100 represents total usage of the shared + * resource that is the limiting bottleneck of the camera subsystem. This may + * be a very rough estimate, and is used as a hint to the camera service to + * determine when to disallow multiple applications from simultaneously + * opening different cameras advertised by the camera service. + * + * The camera service must be able to simultaneously open and use any + * combination of camera devices exposed by the HAL where the sum of + * the resource costs of these cameras is <= 100. For determining cost, + * each camera device must be assumed to be configured and operating at + * the maximally resource-consuming framerate and stream size settings + * available in the configuration settings exposed for that device through + * the camera metadata. + * + * The camera service may still attempt to simultaneously open combinations + * of camera devices with a total resource cost > 100. This may succeed or + * fail. If this succeeds, combinations of configurations that are not + * supported due to resource constraints from having multiple open devices + * should fail during the configure calls. If the total resource cost is + * <= 100, open and configure should never fail for any stream configuration + * settings or other device capabilities that would normally succeed for a + * device when it is the only open camera device. + * + * This field will be used to determine whether background applications are + * allowed to use this camera device while other applications are using other + * camera devices. Note: multiple applications will never be allowed by the + * camera service to simultaneously open the same camera device. + * + * Example use cases: + * + * Ex. 1: Camera Device 0 = Back Camera + * Camera Device 1 = Front Camera + * - Using both camera devices causes a large framerate slowdown due to + * limited ISP bandwidth. + * + * Configuration: + * + * Camera Device 0 - resource_cost = 51 + * conflicting_devices = null + * Camera Device 1 - resource_cost = 51 + * conflicting_devices = null + * + * Result: + * + * Since the sum of the resource costs is > 100, if a higher-priority + * application has either device open, no lower-priority applications will be + * allowed by the camera service to open either device. If a lower-priority + * application is using a device that a higher-priority subsequently attempts + * to open, the lower-priority application will be forced to disconnect the + * the device. + * + * If the highest-priority application chooses, it may still attempt to open + * both devices (since these devices are not listed as conflicting in the + * conflicting_devices fields), but usage of these devices may fail in the + * open or configure calls. + * + * Ex. 2: Camera Device 0 = Left Back Camera + * Camera Device 1 = Right Back Camera + * Camera Device 2 = Combined stereo camera using both right and left + * back camera sensors used by devices 0, and 1 + * Camera Device 3 = Front Camera + * - Due to do hardware constraints, up to two cameras may be open at once. The + * combined stereo camera may never be used at the same time as either of the + * two back camera devices (device 0, 1), and typically requires too much + * bandwidth to use at the same time as the front camera (device 3). + * + * Configuration: + * + * Camera Device 0 - resource_cost = 50 + * conflicting_devices = { 2 } + * Camera Device 1 - resource_cost = 50 + * conflicting_devices = { 2 } + * Camera Device 2 - resource_cost = 100 + * conflicting_devices = { 0, 1 } + * Camera Device 3 - resource_cost = 50 + * conflicting_devices = null + * + * Result: + * + * Based on the conflicting_devices fields, the camera service guarantees that + * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }. + * + * Based on the resource_cost fields, if a high-priority foreground application + * is using camera device 0, a background application would be allowed to open + * camera device 1 or 3 (but would be forced to disconnect it again if the + * foreground application opened another device). + * + * The highest priority application may still attempt to simultaneously open + * devices 0, 2, and 3, but the HAL may fail in open or configure calls for + * this combination. + * + * Ex. 3: Camera Device 0 = Back Camera + * Camera Device 1 = Front Camera + * Camera Device 2 = Low-power Front Camera that uses the same + * sensor as device 1, but only exposes image stream + * resolutions that can be used in low-power mode + * - Using both front cameras (device 1, 2) at the same time is impossible due + * a shared physical sensor. Using the back and "high-power" front camera + * (device 1) may be impossible for some stream configurations due to hardware + * limitations, but the "low-power" front camera option may always be used as + * it has special dedicated hardware. + * + * Configuration: + * + * Camera Device 0 - resource_cost = 100 + * conflicting_devices = null + * Camera Device 1 - resource_cost = 100 + * conflicting_devices = { 2 } + * Camera Device 2 - resource_cost = 0 + * conflicting_devices = { 1 } + * Result: + * + * Based on the conflicting_devices fields, the camera service guarantees that + * the following sets of open devices will never be allowed: { 1, 2 }. + * + * Based on the resource_cost fields, only the highest priority application + * may attempt to open both device 0 and 1 at the same time. If a higher-priority + * application is not using device 1 or 2, a low-priority background application + * may open device 2 (but will be forced to disconnect it if a higher-priority + * application subsequently opens device 1 or 2). + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * Not valid. Can be assumed to be 100. Do not read this field. + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * Always valid. + */ + int resource_cost; + + /** + * An array of camera device IDs represented as NULL-terminated strings + * indicating other devices that cannot be simultaneously opened while this + * camera device is in use. + * + * This field is intended to be used to indicate that this camera device + * is a composite of several other camera devices, or otherwise has + * hardware dependencies that prohibit simultaneous usage. If there are no + * dependencies, a NULL may be returned in this field to indicate this. + * + * The camera service will never simultaneously open any of the devices + * in this list while this camera device is open. + * + * The strings pointed to in this field will not be cleaned up by the camera + * service, and must remain while this device is plugged in. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * Not valid. Can be assumed to be NULL. Do not read this field. + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * Always valid. + */ + char** conflicting_devices; + + /** + * The length of the array given in the conflicting_devices field. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * Not valid. Can be assumed to be 0. Do not read this field. + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * Always valid. + */ + size_t conflicting_devices_length; + +} camera_info_t; + +/** + * camera_device_status_t: + * + * The current status of the camera device, as provided by the HAL through the + * camera_module_callbacks.camera_device_status_change() call. + * + * At module load time, the framework will assume all camera devices are in the + * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke + * camera_module_callbacks::camera_device_status_change to inform the framework + * of any initially NOT_PRESENT devices. + * + * Allowed transitions: + * PRESENT -> NOT_PRESENT + * NOT_PRESENT -> ENUMERATING + * NOT_PRESENT -> PRESENT + * ENUMERATING -> PRESENT + * ENUMERATING -> NOT_PRESENT + */ +typedef enum camera_device_status { + /** + * The camera device is not currently connected, and opening it will return + * failure. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * Calls to get_camera_info must still succeed, and provide the same information + * it would if the camera were connected. + * + * CAMERA_MODULE_API_VERSION_2_4: + * + * The camera device at this status must return -EINVAL for get_camera_info call, + * as the device is not connected. + */ + CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, + + /** + * The camera device is connected, and opening it will succeed. + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * The information returned by get_camera_info cannot change due to this status + * change. By default, the framework will assume all devices are in this state. + * + * CAMERA_MODULE_API_VERSION_2_4: + * + * The information returned by get_camera_info will become valid after a device's + * status changes to this. By default, the framework will assume all devices are in + * this state. + */ + CAMERA_DEVICE_STATUS_PRESENT = 1, + + /** + * The camera device is connected, but it is undergoing an enumeration and + * so opening the device will return -EBUSY. + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * Calls to get_camera_info must still succeed, as if the camera was in the + * PRESENT status. + * + * CAMERA_MODULE_API_VERSION_2_4: + * + * The camera device at this status must return -EINVAL for get_camera_info for call, + * as the device is not ready. + */ + CAMERA_DEVICE_STATUS_ENUMERATING = 2, + +} camera_device_status_t; + +/** + * torch_mode_status_t: + * + * The current status of the torch mode, as provided by the HAL through the + * camera_module_callbacks.torch_mode_status_change() call. + * + * The torch mode status of a camera device is applicable only when the camera + * device is present. The framework will not call set_torch_mode() to turn on + * torch mode of a camera device if the camera device is not present. At module + * load time, the framework will assume torch modes are in the + * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and + * android.flash.info.available is reported as true via get_camera_info() call. + * + * The behaviors of the camera HAL module that the framework expects in the + * following situations when a camera device's status changes: + * 1. A previously-disconnected camera device becomes connected. + * After camera_module_callbacks::camera_device_status_change() is invoked + * to inform the framework that the camera device is present, the framework + * will assume the camera device's torch mode is in + * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need + * to invoke camera_module_callbacks::torch_mode_status_change() unless the + * flash unit is unavailable to use by set_torch_mode(). + * + * 2. A previously-connected camera becomes disconnected. + * After camera_module_callbacks::camera_device_status_change() is invoked + * to inform the framework that the camera device is not present, the + * framework will not call set_torch_mode() for the disconnected camera + * device until its flash unit becomes available again. The camera HAL + * module does not need to invoke + * camera_module_callbacks::torch_mode_status_change() separately to inform + * that the flash unit has become unavailable. + * + * 3. open() is called to open a camera device. + * The camera HAL module must invoke + * camera_module_callbacks::torch_mode_status_change() for all flash units + * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be + * turned on by calling set_torch_mode() anymore due to this open() call. + * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before + * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become + * unavailable. + * + * 4. close() is called to close a camera device. + * The camera HAL module must invoke + * camera_module_callbacks::torch_mode_status_change() for all flash units + * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned + * on by calling set_torch_mode() again because of enough resources freed + * up by this close() call. + * + * Note that the framework calling set_torch_mode() successfully must trigger + * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback + * for the given camera device. Additionally it must trigger + * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch + * modes if HAL cannot keep multiple torch modes on simultaneously. + */ +typedef enum torch_mode_status { + + /** + * The flash unit is no longer available and the torch mode can not be + * turned on by calling set_torch_mode(). If the torch mode is on, it + * will be turned off by HAL before HAL calls torch_mode_status_change(). + */ + TORCH_MODE_STATUS_NOT_AVAILABLE = 0, + + /** + * A torch mode has become off and available to be turned on via + * set_torch_mode(). This may happen in the following + * cases: + * 1. After the resources to turn on the torch mode have become available. + * 2. After set_torch_mode() is called to turn off the torch mode. + * 3. After the framework turned on the torch mode of some other camera + * device and HAL had to turn off the torch modes of any camera devices + * that were previously on. + */ + TORCH_MODE_STATUS_AVAILABLE_OFF = 1, + + /** + * A torch mode has become on and available to be turned off via + * set_torch_mode(). This can happen only after set_torch_mode() is called + * to turn on the torch mode. + */ + TORCH_MODE_STATUS_AVAILABLE_ON = 2, + +} torch_mode_status_t; + +/** + * Callback functions for the camera HAL module to use to inform the framework + * of changes to the camera subsystem. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * Each callback is called only by HAL modules implementing the indicated + * version or higher of the HAL module API interface. + * + * CAMERA_MODULE_API_VERSION_2_1: + * camera_device_status_change() + * + * CAMERA_MODULE_API_VERSION_2_4: + * torch_mode_status_change() + + */ +typedef struct camera_module_callbacks { + + /** + * camera_device_status_change: + * + * Callback to the framework to indicate that the state of a specific camera + * device has changed. At module load time, the framework will assume all + * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL + * must call this method to inform the framework of any initially + * NOT_PRESENT devices. + * + * This callback is added for CAMERA_MODULE_API_VERSION_2_1. + * + * camera_module_callbacks: The instance of camera_module_callbacks_t passed + * to the module with set_callbacks. + * + * camera_id: The ID of the camera device that has a new status. + * + * new_status: The new status code, one of the camera_device_status_t enums, + * or a platform-specific status. + * + */ + void (*camera_device_status_change)(const struct camera_module_callbacks*, + int camera_id, + int new_status); + + /** + * torch_mode_status_change: + * + * Callback to the framework to indicate that the state of the torch mode + * of the flash unit associated with a specific camera device has changed. + * At module load time, the framework will assume the torch modes are in + * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available + * is reported as true via get_camera_info() call. + * + * This callback is added for CAMERA_MODULE_API_VERSION_2_4. + * + * camera_module_callbacks: The instance of camera_module_callbacks_t + * passed to the module with set_callbacks. + * + * camera_id: The ID of camera device whose flash unit has a new torch mode + * status. + * + * new_status: The new status code, one of the torch_mode_status_t enums. + */ + void (*torch_mode_status_change)(const struct camera_module_callbacks*, + const char* camera_id, + int new_status); + + +} camera_module_callbacks_t; + +typedef struct camera_module { + /** + * Common methods of the camera module. This *must* be the first member of + * camera_module as users of this structure will cast a hw_module_t to + * camera_module pointer in contexts where it's known the hw_module_t + * references a camera_module. + * + * The return values for common.methods->open for camera_module are: + * + * 0: On a successful open of the camera device. + * + * -ENODEV: The camera device cannot be opened due to an internal + * error. + * + * -EINVAL: The input arguments are invalid, i.e. the id is invalid, + * and/or the module is invalid. + * + * -EBUSY: The camera device was already opened for this camera id + * (by using this method or open_legacy), + * regardless of the device HAL version it was opened as. + * + * -EUSERS: The maximal number of camera devices that can be + * opened concurrently were opened already, either by + * this method or the open_legacy method. + * + * All other return values from common.methods->open will be treated as + * -ENODEV. + */ + hw_module_t common; + + /** + * get_number_of_cameras: + * + * Returns the number of camera devices accessible through the camera + * module. The camera devices are numbered 0 through N-1, where N is the + * value returned by this call. The name of the camera device for open() is + * simply the number converted to a string. That is, "0" for camera ID 0, + * "1" for camera ID 1. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_3 or lower: + * + * The value here must be static, and cannot change after the first call + * to this method. + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * The value here must be static, and must count only built-in cameras, + * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values + * (camera_info.facing). The HAL must not include the external cameras + * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value + * of this call. Frameworks will use camera_device_status_change callback + * to manage number of external cameras. + */ + int (*get_number_of_cameras)(void); + + /** + * get_camera_info: + * + * Return the static camera information for a given camera device. This + * information may not change for a camera device. + * + * Return values: + * + * 0: On a successful operation + * + * -ENODEV: The information cannot be provided due to an internal + * error. + * + * -EINVAL: The input arguments are invalid, i.e. the id is invalid, + * and/or the module is invalid. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_2_4 or higher: + * + * When a camera is disconnected, its camera id becomes invalid. Calling this + * this method with this invalid camera id will get -EINVAL and NULL camera + * static metadata (camera_info.static_camera_characteristics). + */ + int (*get_camera_info)(int camera_id, struct camera_info *info); + + /** + * set_callbacks: + * + * Provide callback function pointers to the HAL module to inform framework + * of asynchronous camera module events. The framework will call this + * function once after initial camera HAL module load, after the + * get_number_of_cameras() method is called for the first time, and before + * any other calls to the module. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: + * + * Not provided by HAL module. Framework may not call this function. + * + * CAMERA_MODULE_API_VERSION_2_1: + * + * Valid to be called by the framework. + * + * Return values: + * + * 0: On a successful operation + * + * -ENODEV: The operation cannot be completed due to an internal + * error. + * + * -EINVAL: The input arguments are invalid, i.e. the callbacks are + * null + */ + int (*set_callbacks)(const camera_module_callbacks_t *callbacks); + + /** + * get_vendor_tag_ops: + * + * Get methods to query for vendor extension metadata tag information. The + * HAL should fill in all the vendor tag operation methods, or leave ops + * unchanged if no vendor tags are defined. + * + * The vendor_tag_ops structure used here is defined in: + * system/media/camera/include/system/vendor_tags.h + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: + * Not provided by HAL module. Framework may not call this function. + * + * CAMERA_MODULE_API_VERSION_2_2: + * Valid to be called by the framework. + */ + void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); + + /** + * open_legacy: + * + * Open a specific legacy camera HAL device if multiple device HAL API + * versions are supported by this camera HAL module. For example, if the + * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and + * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, + * framework can call this function to open the camera device as + * CAMERA_DEVICE_API_VERSION_1_0 device. + * + * This is an optional method. A Camera HAL module does not need to support + * more than one device HAL version per device, and such modules may return + * -ENOSYS for all calls to this method. For all older HAL device API + * versions that are not supported, it may return -EOPNOTSUPP. When above + * cases occur, The normal open() method (common.methods->open) will be + * used by the framework instead. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: + * Not provided by HAL module. Framework will not call this function. + * + * CAMERA_MODULE_API_VERSION_2_3: + * Valid to be called by the framework. + * + * Return values: + * + * 0: On a successful open of the camera device. + * + * -ENOSYS This method is not supported. + * + * -EOPNOTSUPP: The requested HAL version is not supported by this method. + * + * -EINVAL: The input arguments are invalid, i.e. the id is invalid, + * and/or the module is invalid. + * + * -EBUSY: The camera device was already opened for this camera id + * (by using this method or common.methods->open method), + * regardless of the device HAL version it was opened as. + * + * -EUSERS: The maximal number of camera devices that can be + * opened concurrently were opened already, either by + * this method or common.methods->open method. + */ + int (*open_legacy)(const struct hw_module_t* module, const char* id, + uint32_t halVersion, struct hw_device_t** device); + + /** + * set_torch_mode: + * + * Turn on or off the torch mode of the flash unit associated with a given + * camera ID. If the operation is successful, HAL must notify the framework + * torch state by invoking + * camera_module_callbacks.torch_mode_status_change() with the new state. + * + * The camera device has a higher priority accessing the flash unit. When + * there are any resource conflicts, such as open() is called to open a + * camera device, HAL module must notify the framework through + * camera_module_callbacks.torch_mode_status_change() that the + * torch mode has been turned off and the torch mode state has become + * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode + * become available again, HAL module must notify the framework through + * camera_module_callbacks.torch_mode_status_change() that the torch mode + * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to + * be called. + * + * When the framework calls set_torch_mode() to turn on the torch mode of a + * flash unit, if HAL cannot keep multiple torch modes on simultaneously, + * HAL should turn off the torch mode that was turned on by + * a previous set_torch_mode() call and notify the framework that the torch + * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: + * Not provided by HAL module. Framework will not call this function. + * + * CAMERA_MODULE_API_VERSION_2_4: + * Valid to be called by the framework. + * + * Return values: + * + * 0: On a successful operation. + * + * -ENOSYS: The camera device does not support this operation. It is + * returned if and only if android.flash.info.available is + * false. + * + * -EBUSY: The camera device is already in use. + * + * -EUSERS: The resources needed to turn on the torch mode are not + * available, typically because other camera devices are + * holding the resources to make using the flash unit not + * possible. + * + * -EINVAL: camera_id is invalid. + * + */ + int (*set_torch_mode)(const char* camera_id, bool enabled); + + /** + * init: + * + * This method is called by the camera service before any other methods + * are invoked, right after the camera HAL library has been successfully + * loaded. It may be left as NULL by the HAL module, if no initialization + * in needed. + * + * It can be used by HAL implementations to perform initialization and + * other one-time operations. + * + * Version information (based on camera_module_t.common.module_api_version): + * + * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: + * Not provided by HAL module. Framework will not call this function. + * + * CAMERA_MODULE_API_VERSION_2_4: + * If not NULL, will always be called by the framework once after the HAL + * module is loaded, before any other HAL module method is called. + * + * Return values: + * + * 0: On a successful operation. + * + * -ENODEV: Initialization cannot be completed due to an internal + * error. The HAL must be assumed to be in a nonfunctional + * state. + * + */ + int (*init)(); + + /* reserved for future use */ + void* reserved[5]; +} camera_module_t; + +__END_DECLS + +#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ diff --git a/include/android/hardware/libhardware/include/hardware/fb.h b/include/android/hardware/libhardware/include/hardware/fb.h new file mode 100644 index 000000000000..9df94165b9b1 --- /dev/null +++ b/include/android/hardware/libhardware/include/hardware/fb.h @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_FB_INTERFACE_H +#define ANDROID_FB_INTERFACE_H + +#include +#include +#include + +#include + +#include + +__BEGIN_DECLS + +#define GRALLOC_HARDWARE_FB0 "fb0" + +/*****************************************************************************/ + + +/*****************************************************************************/ + +typedef struct framebuffer_device_t { + /** + * Common methods of the framebuffer device. This *must* be the first member of + * framebuffer_device_t as users of this structure will cast a hw_device_t to + * framebuffer_device_t pointer in contexts where it's known the hw_device_t references a + * framebuffer_device_t. + */ + struct hw_device_t common; + + /* flags describing some attributes of the framebuffer */ + const uint32_t flags; + + /* dimensions of the framebuffer in pixels */ + const uint32_t width; + const uint32_t height; + + /* frambuffer stride in pixels */ + const int stride; + + /* framebuffer pixel format */ + const int format; + + /* resolution of the framebuffer's display panel in pixel per inch*/ + const float xdpi; + const float ydpi; + + /* framebuffer's display panel refresh rate in frames per second */ + const float fps; + + /* min swap interval supported by this framebuffer */ + const int minSwapInterval; + + /* max swap interval supported by this framebuffer */ + const int maxSwapInterval; + + /* Number of framebuffers supported*/ + const int numFramebuffers; + + int reserved[7]; + + /* + * requests a specific swap-interval (same definition than EGL) + * + * Returns 0 on success or -errno on error. + */ + int (*setSwapInterval)(struct framebuffer_device_t* window, + int interval); + + /* + * This hook is OPTIONAL. + * + * It is non NULL If the framebuffer driver supports "update-on-demand" + * and the given rectangle is the area of the screen that gets + * updated during (*post)(). + * + * This is useful on devices that are able to DMA only a portion of + * the screen to the display panel, upon demand -- as opposed to + * constantly refreshing the panel 60 times per second, for instance. + * + * Only the area defined by this rectangle is guaranteed to be valid, that + * is, the driver is not allowed to post anything outside of this + * rectangle. + * + * The rectangle evaluated during (*post)() and specifies which area + * of the buffer passed in (*post)() shall to be posted. + * + * return -EINVAL if width or height <=0, or if left or top < 0 + */ + int (*setUpdateRect)(struct framebuffer_device_t* window, + int left, int top, int width, int height); + + /* + * Post to the display (display it on the screen) + * The buffer must have been allocated with the + * GRALLOC_USAGE_HW_FB usage flag. + * buffer must be the same width and height as the display and must NOT + * be locked. + * + * The buffer is shown during the next VSYNC. + * + * If the same buffer is posted again (possibly after some other buffer), + * post() will block until the the first post is completed. + * + * Internally, post() is expected to lock the buffer so that a + * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or + * USAGE_*_WRITE will block until it is safe; that is typically once this + * buffer is shown and another buffer has been posted. + * + * Returns 0 on success or -errno on error. + */ + int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); + + + /* + * The (*compositionComplete)() method must be called after the + * compositor has finished issuing GL commands for client buffers. + */ + + int (*compositionComplete)(struct framebuffer_device_t* dev); + + /* + * This hook is OPTIONAL. + * + * If non NULL it will be caused by SurfaceFlinger on dumpsys + */ + void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); + + /* + * (*enableScreen)() is used to either blank (enable=0) or + * unblank (enable=1) the screen this framebuffer is attached to. + * + * Returns 0 on success or -errno on error. + */ + int (*enableScreen)(struct framebuffer_device_t* dev, int enable); + + void* reserved_proc[6]; + +} framebuffer_device_t; + + +/** convenience API for opening and closing a supported device */ + +static inline int framebuffer_open(const struct hw_module_t* module, + struct framebuffer_device_t** device) { + return module->methods->open(module, + GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device); +} + +static inline int framebuffer_close(struct framebuffer_device_t* device) { + return device->common.close(&device->common); +} + + +__END_DECLS + +#endif // ANDROID_FB_INTERFACE_H diff --git a/include/android/hardware/libhardware/include/hardware/gralloc.h b/include/android/hardware/libhardware/include/hardware/gralloc.h new file mode 100644 index 000000000000..ef86f9039395 --- /dev/null +++ b/include/android/hardware/libhardware/include/hardware/gralloc.h @@ -0,0 +1,384 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_GRALLOC_INTERFACE_H +#define ANDROID_GRALLOC_INTERFACE_H + +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +__BEGIN_DECLS + +/** + * Module versioning information for the Gralloc hardware module, based on + * gralloc_module_t.common.module_api_version. + * + * Version History: + * + * GRALLOC_MODULE_API_VERSION_0_1: + * Initial Gralloc hardware module API. + * + * GRALLOC_MODULE_API_VERSION_0_2: + * Add support for flexible YCbCr format with (*lock_ycbcr)() method. + * + * GRALLOC_MODULE_API_VERSION_0_3: + * Add support for fence passing to/from lock/unlock. + */ + +#define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) +#define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) +#define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) + +#define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) + +/** + * The id of this module + */ +#define GRALLOC_HARDWARE_MODULE_ID "gralloc" + +/** + * Name of the graphics device to open + */ + +#define GRALLOC_HARDWARE_GPU0 "gpu0" + +enum { + /* buffer is never read in software */ + GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, + /* buffer is rarely read in software */ + GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, + /* buffer is often read in software */ + GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, + /* mask for the software read values */ + GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, + + /* buffer is never written in software */ + GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, + /* buffer is rarely written in software */ + GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, + /* buffer is often written in software */ + GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, + /* mask for the software write values */ + GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, + + /* buffer will be used as an OpenGL ES texture */ + GRALLOC_USAGE_HW_TEXTURE = 0x00000100, + /* buffer will be used as an OpenGL ES render target */ + GRALLOC_USAGE_HW_RENDER = 0x00000200, + /* buffer will be used by the 2D hardware blitter */ + GRALLOC_USAGE_HW_2D = 0x00000400, + /* buffer will be used by the HWComposer HAL module */ + GRALLOC_USAGE_HW_COMPOSER = 0x00000800, + /* buffer will be used with the framebuffer device */ + GRALLOC_USAGE_HW_FB = 0x00001000, + + /* buffer should be displayed full-screen on an external display when + * possible */ + GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, + + /* Must have a hardware-protected path to external display sink for + * this buffer. If a hardware-protected path is not available, then + * either don't composite only this buffer (preferred) to the + * external sink, or (less desirable) do not route the entire + * composition to the external sink. */ + GRALLOC_USAGE_PROTECTED = 0x00004000, + + /* buffer may be used as a cursor */ + GRALLOC_USAGE_CURSOR = 0x00008000, + + /* buffer will be used with the HW video encoder */ + GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, + /* buffer will be written by the HW camera pipeline */ + GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, + /* buffer will be read by the HW camera pipeline */ + GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, + /* buffer will be used as part of zero-shutter-lag queue */ + GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, + /* mask for the camera access values */ + GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, + /* mask for the software usage bit-mask */ + GRALLOC_USAGE_HW_MASK = 0x00071F00, + + /* buffer will be used as a RenderScript Allocation */ + GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, + + /* Set by the consumer to indicate to the producer that they may attach a + * buffer that they did not detach from the BufferQueue. Will be filtered + * out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to + * handle this flag. */ + GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000, + + /* Mask of all flags which could be passed to a gralloc module for buffer + * allocation. Any flags not in this mask do not need to be handled by + * gralloc modules. */ + GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS), + + /* implementation-specific private usage flags */ + GRALLOC_USAGE_PRIVATE_0 = 0x10000000, + GRALLOC_USAGE_PRIVATE_1 = 0x20000000, + GRALLOC_USAGE_PRIVATE_2 = 0x40000000, + GRALLOC_USAGE_PRIVATE_3 = 0x80000000, + GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000, +}; + +/*****************************************************************************/ + +/** + * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM + * and the fields of this data structure must begin with hw_module_t + * followed by module specific information. + */ +typedef struct gralloc_module_t { + struct hw_module_t common; + + /* + * (*registerBuffer)() must be called before a buffer_handle_t that has not + * been created with (*alloc_device_t::alloc)() can be used. + * + * This is intended to be used with buffer_handle_t's that have been + * received in this process through IPC. + * + * This function checks that the handle is indeed a valid one and prepares + * it for use with (*lock)() and (*unlock)(). + * + * It is not necessary to call (*registerBuffer)() on a handle created + * with (*alloc_device_t::alloc)(). + * + * returns an error if this buffer_handle_t is not valid. + */ + int (*registerBuffer)(struct gralloc_module_t const* module, + buffer_handle_t handle); + + /* + * (*unregisterBuffer)() is called once this handle is no longer needed in + * this process. After this call, it is an error to call (*lock)(), + * (*unlock)(), or (*registerBuffer)(). + * + * This function doesn't close or free the handle itself; this is done + * by other means, usually through libcutils's native_handle_close() and + * native_handle_free(). + * + * It is an error to call (*unregisterBuffer)() on a buffer that wasn't + * explicitly registered first. + */ + int (*unregisterBuffer)(struct gralloc_module_t const* module, + buffer_handle_t handle); + + /* + * The (*lock)() method is called before a buffer is accessed for the + * specified usage. This call may block, for instance if the h/w needs + * to finish rendering or if CPU caches need to be synchronized. + * + * The caller promises to modify only pixels in the area specified + * by (l,t,w,h). + * + * The content of the buffer outside of the specified area is NOT modified + * by this call. + * + * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address + * of the buffer in virtual memory. + * + * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail + * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() + * instead. + * + * THREADING CONSIDERATIONS: + * + * It is legal for several different threads to lock a buffer from + * read access, none of the threads are blocked. + * + * However, locking a buffer simultaneously for write or read/write is + * undefined, but: + * - shall not result in termination of the process + * - shall not block the caller + * It is acceptable to return an error or to leave the buffer's content + * into an indeterminate state. + * + * If the buffer was created with a usage mask incompatible with the + * requested usage flags here, -EINVAL is returned. + * + */ + + int (*lock)(struct gralloc_module_t const* module, + buffer_handle_t handle, int usage, + int l, int t, int w, int h, + void** vaddr); + + + /* + * The (*unlock)() method must be called after all changes to the buffer + * are completed. + */ + + int (*unlock)(struct gralloc_module_t const* module, + buffer_handle_t handle); + + + /* reserved for future use */ + int (*perform)(struct gralloc_module_t const* module, + int operation, ... ); + + /* + * The (*lock_ycbcr)() method is like the (*lock)() method, with the + * difference that it fills a struct ycbcr with a description of the buffer + * layout, and zeroes out the reserved fields. + * + * If the buffer format is not compatible with a flexible YUV format (e.g. + * the buffer layout cannot be represented with the ycbcr struct), it + * will return -EINVAL. + * + * This method must work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888 + * if supported by the device, as well as with any other format that is + * requested by the multimedia codecs when they are configured with a + * flexible-YUV-compatible color-format with android native buffers. + * + * Note that this method may also be called on buffers of other formats, + * including non-YUV formats. + * + * Added in GRALLOC_MODULE_API_VERSION_0_2. + */ + + int (*lock_ycbcr)(struct gralloc_module_t const* module, + buffer_handle_t handle, int usage, + int l, int t, int w, int h, + struct android_ycbcr *ycbcr); + + /* + * The (*lockAsync)() method is like the (*lock)() method except + * that the buffer's sync fence object is passed into the lock + * call instead of requiring the caller to wait for completion. + * + * The gralloc implementation takes ownership of the fenceFd and + * is responsible for closing it when no longer needed. + * + * Added in GRALLOC_MODULE_API_VERSION_0_3. + */ + int (*lockAsync)(struct gralloc_module_t const* module, + buffer_handle_t handle, int usage, + int l, int t, int w, int h, + void** vaddr, int fenceFd); + + /* + * The (*unlockAsync)() method is like the (*unlock)() method + * except that a buffer sync fence object is returned from the + * lock call, representing the completion of any pending work + * performed by the gralloc implementation. + * + * The caller takes ownership of the fenceFd and is responsible + * for closing it when no longer needed. + * + * Added in GRALLOC_MODULE_API_VERSION_0_3. + */ + int (*unlockAsync)(struct gralloc_module_t const* module, + buffer_handle_t handle, int* fenceFd); + + /* + * The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)() + * method except that the buffer's sync fence object is passed + * into the lock call instead of requiring the caller to wait for + * completion. + * + * The gralloc implementation takes ownership of the fenceFd and + * is responsible for closing it when no longer needed. + * + * Added in GRALLOC_MODULE_API_VERSION_0_3. + */ + int (*lockAsync_ycbcr)(struct gralloc_module_t const* module, + buffer_handle_t handle, int usage, + int l, int t, int w, int h, + struct android_ycbcr *ycbcr, int fenceFd); + + /* reserved for future use */ + void* reserved_proc[3]; +} gralloc_module_t; + +/*****************************************************************************/ + +/** + * Every device data structure must begin with hw_device_t + * followed by module specific public methods and attributes. + */ + +typedef struct alloc_device_t { + struct hw_device_t common; + + /* + * (*alloc)() Allocates a buffer in graphic memory with the requested + * parameters and returns a buffer_handle_t and the stride in pixels to + * allow the implementation to satisfy hardware constraints on the width + * of a pixmap (eg: it may have to be multiple of 8 pixels). + * The CALLER TAKES OWNERSHIP of the buffer_handle_t. + * + * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be + * 0, since the actual strides are available from the android_ycbcr + * structure. + * + * Returns 0 on success or -errno on error. + */ + + int (*alloc)(struct alloc_device_t* dev, + int w, int h, int format, int usage, + buffer_handle_t* handle, int* stride); + + /* + * (*free)() Frees a previously allocated buffer. + * Behavior is undefined if the buffer is still mapped in any process, + * but shall not result in termination of the program or security breaches + * (allowing a process to get access to another process' buffers). + * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes + * invalid after the call. + * + * Returns 0 on success or -errno on error. + */ + int (*free)(struct alloc_device_t* dev, + buffer_handle_t handle); + + /* This hook is OPTIONAL. + * + * If non NULL it will be caused by SurfaceFlinger on dumpsys + */ + void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); + + void* reserved_proc[7]; +} alloc_device_t; + + +/** convenience API for opening and closing a supported device */ + +static inline int gralloc_open(const struct hw_module_t* module, + struct alloc_device_t** device) { + return module->methods->open(module, + GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device); +} + +static inline int gralloc_close(struct alloc_device_t* device) { + return device->common.close(&device->common); +} + +__END_DECLS + +#endif // ANDROID_GRALLOC_INTERFACE_H diff --git a/include/android/hardware/libhardware/include/hardware/hardware.h b/include/android/hardware/libhardware/include/hardware/hardware.h new file mode 100644 index 000000000000..74f57aa4c28f --- /dev/null +++ b/include/android/hardware/libhardware/include/hardware/hardware.h @@ -0,0 +1,238 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H +#define ANDROID_INCLUDE_HARDWARE_HARDWARE_H + +#include +#include + +#include +#include + +__BEGIN_DECLS + +/* + * Value for the hw_module_t.tag field + */ + +#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) + +#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') +#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') + +#define HARDWARE_MAKE_API_VERSION(maj,min) \ + ((((maj) & 0xff) << 8) | ((min) & 0xff)) + +#define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ + ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) +#define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 +#define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff + + +/* + * The current HAL API version. + * + * All module implementations must set the hw_module_t.hal_api_version field + * to this value when declaring the module with HAL_MODULE_INFO_SYM. + * + * Note that previous implementations have always set this field to 0. + * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 + * to be 100% binary compatible. + * + */ +#define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) + +/* + * Helper macros for module implementors. + * + * The derived modules should provide convenience macros for supported + * versions so that implementations can explicitly specify module/device + * versions at definition time. + * + * Use this macro to set the hw_module_t.module_api_version field. + */ +#define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) +#define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) + +/* + * Use this macro to set the hw_device_t.version field + */ +#define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) +#define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) + +struct hw_module_t; +struct hw_module_methods_t; +struct hw_device_t; + +/** + * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM + * and the fields of this data structure must begin with hw_module_t + * followed by module specific information. + */ +typedef struct hw_module_t { + /** tag must be initialized to HARDWARE_MODULE_TAG */ + uint32_t tag; + + /** + * The API version of the implemented module. The module owner is + * responsible for updating the version when a module interface has + * changed. + * + * The derived modules such as gralloc and audio own and manage this field. + * The module user must interpret the version field to decide whether or + * not to inter-operate with the supplied module implementation. + * For example, SurfaceFlinger is responsible for making sure that + * it knows how to manage different versions of the gralloc-module API, + * and AudioFlinger must know how to do the same for audio-module API. + * + * The module API version should include a major and a minor component. + * For example, version 1.0 could be represented as 0x0100. This format + * implies that versions 0x0100-0x01ff are all API-compatible. + * + * In the future, libhardware will expose a hw_get_module_version() + * (or equivalent) function that will take minimum/maximum supported + * versions as arguments and would be able to reject modules with + * versions outside of the supplied range. + */ + uint16_t module_api_version; +#define version_major module_api_version + /** + * version_major/version_minor defines are supplied here for temporary + * source code compatibility. They will be removed in the next version. + * ALL clients must convert to the new version format. + */ + + /** + * The API version of the HAL module interface. This is meant to + * version the hw_module_t, hw_module_methods_t, and hw_device_t + * structures and definitions. + * + * The HAL interface owns this field. Module users/implementations + * must NOT rely on this value for version information. + * + * Presently, 0 is the only valid value. + */ + uint16_t hal_api_version; +#define version_minor hal_api_version + + /** Identifier of module */ + const char *id; + + /** Name of this module */ + const char *name; + + /** Author/owner/implementor of the module */ + const char *author; + + /** Modules methods */ + struct hw_module_methods_t* methods; + + /** module's dso */ + void* dso; + +#ifdef __LP64__ + uint64_t reserved[32-7]; +#else + /** padding to 128 bytes, reserved for future use */ + uint32_t reserved[32-7]; +#endif + +} hw_module_t; + +typedef struct hw_module_methods_t { + /** Open a specific device */ + int (*open)(const struct hw_module_t* module, const char* id, + struct hw_device_t** device); + +} hw_module_methods_t; + +/** + * Every device data structure must begin with hw_device_t + * followed by module specific public methods and attributes. + */ +typedef struct hw_device_t { + /** tag must be initialized to HARDWARE_DEVICE_TAG */ + uint32_t tag; + + /** + * Version of the module-specific device API. This value is used by + * the derived-module user to manage different device implementations. + * + * The module user is responsible for checking the module_api_version + * and device version fields to ensure that the user is capable of + * communicating with the specific module implementation. + * + * One module can support multiple devices with different versions. This + * can be useful when a device interface changes in an incompatible way + * but it is still necessary to support older implementations at the same + * time. One such example is the Camera 2.0 API. + * + * This field is interpreted by the module user and is ignored by the + * HAL interface itself. + */ + uint32_t version; + + /** reference to the module this device belongs to */ + struct hw_module_t* module; + + /** padding reserved for future use */ +#ifdef __LP64__ + uint64_t reserved[12]; +#else + uint32_t reserved[12]; +#endif + + /** Close this device */ + int (*close)(struct hw_device_t* device); + +} hw_device_t; + +/** + * Name of the hal_module_info + */ +#define HAL_MODULE_INFO_SYM HMI + +/** + * Name of the hal_module_info as a string + */ +#define HAL_MODULE_INFO_SYM_AS_STR "HMI" + +/** + * Get the module info associated with a module by id. + * + * @return: 0 == success, <0 == error and *module == NULL + */ +int hw_get_module(const char *id, const struct hw_module_t **module); + +/** + * Get the module info associated with a module instance by class 'class_id' + * and instance 'inst'. + * + * Some modules types necessitate multiple instances. For example audio supports + * multiple concurrent interfaces and thus 'audio' is the module class + * and 'primary' or 'a2dp' are module interfaces. This implies that the files + * providing these modules would be named audio.primary..so and + * audio.a2dp..so + * + * @return: 0 == success, <0 == error and *module == NULL + */ +int hw_get_module_by_class(const char *class_id, const char *inst, + const struct hw_module_t **module); + +__END_DECLS + +#endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ diff --git a/include/android/metadata/camera_metadata_hidden.h b/include/android/metadata/camera_metadata_hidden.h new file mode 100644 index 000000000000..31f1ad19e868 --- /dev/null +++ b/include/android/metadata/camera_metadata_hidden.h @@ -0,0 +1,100 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_MEDIA_PRIVATE_INCLUDE_CAMERA_METADATA_HIDDEN_H +#define SYSTEM_MEDIA_PRIVATE_INCLUDE_CAMERA_METADATA_HIDDEN_H + +#include + +/** + * Error codes returned by vendor tags ops operations. These are intended + * to be used by all framework code that uses the return values from the + * vendor operations object. + */ +#define VENDOR_SECTION_NAME_ERR NULL +#define VENDOR_TAG_NAME_ERR NULL +#define VENDOR_TAG_COUNT_ERR (-1) +#define VENDOR_TAG_TYPE_ERR (-1) + +#ifdef __cplusplus +extern "C" { +#endif +/** **These are private functions for use only by the camera framework.** **/ + +/** + * Set the global vendor tag operations object used to define vendor tag + * structure when parsing camera metadata with functions defined in + * system/media/camera/include/camera_metadata.h. + */ +ANDROID_API +int set_camera_metadata_vendor_ops(const vendor_tag_ops_t *query_ops); + +/** + * Set the global vendor tag cache operations object used to define vendor tag + * structure when parsing camera metadata with functions defined in + * system/media/camera/include/camera_metadata.h. + */ +ANDROID_API +int set_camera_metadata_vendor_cache_ops( + const struct vendor_tag_cache_ops *query_cache_ops); + +/** + * Set the vendor id for a particular metadata buffer. + */ +ANDROID_API +void set_camera_metadata_vendor_id(camera_metadata_t *meta, + metadata_vendor_id_t id); + +/** + * Retrieve the vendor id for a particular metadata buffer. + */ +ANDROID_API +metadata_vendor_id_t get_camera_metadata_vendor_id( + const camera_metadata_t *meta); + +/** + * Retrieve the type of a tag. Returns -1 if no such tag is defined. + */ +ANDROID_API +int get_local_camera_metadata_tag_type_vendor_id(uint32_t tag, + metadata_vendor_id_t id); + +/** + * Retrieve the name of a tag. Returns NULL if no such tag is defined. + */ +ANDROID_API +const char *get_local_camera_metadata_tag_name_vendor_id(uint32_t tag, + metadata_vendor_id_t id); + +/** + * Retrieve the name of a tag section. Returns NULL if no such tag is defined. + */ +ANDROID_API +const char *get_local_camera_metadata_section_name_vendor_id(uint32_t tag, + metadata_vendor_id_t id); + +/** + * Retrieve the type of a tag. Returns -1 if no such tag is defined. + */ +ANDROID_API +int get_local_camera_metadata_tag_type_vendor_id(uint32_t tag, + metadata_vendor_id_t id); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SYSTEM_MEDIA_PRIVATE_INCLUDE_CAMERA_METADATA_HIDDEN_H */ diff --git a/include/android/metadata/system/camera_metadata.h b/include/android/metadata/system/camera_metadata.h new file mode 100644 index 000000000000..46e7ac000298 --- /dev/null +++ b/include/android/metadata/system/camera_metadata.h @@ -0,0 +1,580 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_METADATA_H +#define SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_METADATA_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Tag hierarchy and enum definitions for camera_metadata_entry + * ============================================================================= + */ + +/** + * Main enum definitions are in a separate file to make it easy to + * maintain + */ +#include "camera_metadata_tags.h" + +/** + * Enum range for each top-level category + */ +ANDROID_API +extern unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2]; +ANDROID_API +extern const char *camera_metadata_section_names[ANDROID_SECTION_COUNT]; + +/** + * Type definitions for camera_metadata_entry + * ============================================================================= + */ +enum { + // Unsigned 8-bit integer (uint8_t) + TYPE_BYTE = 0, + // Signed 32-bit integer (int32_t) + TYPE_INT32 = 1, + // 32-bit float (float) + TYPE_FLOAT = 2, + // Signed 64-bit integer (int64_t) + TYPE_INT64 = 3, + // 64-bit float (double) + TYPE_DOUBLE = 4, + // A 64-bit fraction (camera_metadata_rational_t) + TYPE_RATIONAL = 5, + // Number of type fields + NUM_TYPES +}; + +typedef struct camera_metadata_rational { + int32_t numerator; + int32_t denominator; +} camera_metadata_rational_t; + +/** + * A reference to a metadata entry in a buffer. + * + * The data union pointers point to the real data in the buffer, and can be + * modified in-place if the count does not need to change. The count is the + * number of entries in data of the entry's type, not a count of bytes. + */ +typedef struct camera_metadata_entry { + size_t index; + uint32_t tag; + uint8_t type; + size_t count; + union { + uint8_t *u8; + int32_t *i32; + float *f; + int64_t *i64; + double *d; + camera_metadata_rational_t *r; + } data; +} camera_metadata_entry_t; + +/** + * A read-only reference to a metadata entry in a buffer. Identical to + * camera_metadata_entry in layout + */ +typedef struct camera_metadata_ro_entry { + size_t index; + uint32_t tag; + uint8_t type; + size_t count; + union { + const uint8_t *u8; + const int32_t *i32; + const float *f; + const int64_t *i64; + const double *d; + const camera_metadata_rational_t *r; + } data; +} camera_metadata_ro_entry_t; + +/** + * Size in bytes of each entry type + */ +ANDROID_API +extern const size_t camera_metadata_type_size[NUM_TYPES]; + +/** + * Human-readable name of each entry type + */ +ANDROID_API +extern const char* camera_metadata_type_names[NUM_TYPES]; + +/** + * Main definitions for the metadata entry and array structures + * ============================================================================= + */ + +/** + * A packet of metadata. This is a list of metadata entries, each of which has + * an integer tag to identify its meaning, 'type' and 'count' field, and the + * data, which contains a 'count' number of entries of type 'type'. The packet + * has a fixed capacity for entries and for extra data. A new entry uses up one + * entry slot, and possibly some amount of data capacity; the function + * calculate_camera_metadata_entry_data_size() provides the amount of data + * capacity that would be used up by an entry. + * + * Entries are not sorted by default, and are not forced to be unique - multiple + * entries with the same tag are allowed. The packet will not dynamically resize + * when full. + * + * The packet is contiguous in memory, with size in bytes given by + * get_camera_metadata_size(). Therefore, it can be copied safely with memcpy() + * to a buffer of sufficient size. The copy_camera_metadata() function is + * intended for eliminating unused capacity in the destination packet. + */ +struct camera_metadata; +typedef struct camera_metadata camera_metadata_t; + +/** + * Functions for manipulating camera metadata + * ============================================================================= + * + * NOTE: Unless otherwise specified, functions that return type "int" + * return 0 on success, and non-0 value on error. + */ + +/** + * Allocate a new camera_metadata structure, with some initial space for entries + * and extra data. The entry_capacity is measured in entry counts, and + * data_capacity in bytes. The resulting structure is all contiguous in memory, + * and can be freed with free_camera_metadata(). + */ +ANDROID_API +camera_metadata_t *allocate_camera_metadata(size_t entry_capacity, + size_t data_capacity); + +/** + * Get the required alignment of a packet of camera metadata, which is the + * maximal alignment of the embedded camera_metadata, camera_metadata_buffer_entry, + * and camera_metadata_data. + */ +ANDROID_API +size_t get_camera_metadata_alignment(); + +/** + * Allocate a new camera_metadata structure of size src_size. Copy the data, + * ignoring alignment, and then attempt validation. If validation + * fails, free the memory and return NULL. Otherwise return the pointer. + * + * The resulting pointer can be freed with free_camera_metadata(). + */ +ANDROID_API +camera_metadata_t *allocate_copy_camera_metadata_checked( + const camera_metadata_t *src, + size_t src_size); + +/** + * Place a camera metadata structure into an existing buffer. Returns NULL if + * the buffer is too small for the requested number of reserved entries and + * bytes of data. The entry_capacity is measured in entry counts, and + * data_capacity in bytes. If the buffer is larger than the required space, + * unused space will be left at the end. If successful, returns a pointer to the + * metadata header placed at the start of the buffer. It is the caller's + * responsibility to free the original buffer; do not call + * free_camera_metadata() with the returned pointer. + */ +ANDROID_API +camera_metadata_t *place_camera_metadata(void *dst, size_t dst_size, + size_t entry_capacity, + size_t data_capacity); + +/** + * Free a camera_metadata structure. Should only be used with structures + * allocated with allocate_camera_metadata(). + */ +ANDROID_API +void free_camera_metadata(camera_metadata_t *metadata); + +/** + * Calculate the buffer size needed for a metadata structure of entry_count + * metadata entries, needing a total of data_count bytes of extra data storage. + */ +ANDROID_API +size_t calculate_camera_metadata_size(size_t entry_count, + size_t data_count); + +/** + * Get current size of entire metadata structure in bytes, including reserved + * but unused space. + */ +ANDROID_API +size_t get_camera_metadata_size(const camera_metadata_t *metadata); + +/** + * Get size of entire metadata buffer in bytes, not including reserved but + * unused space. This is the amount of space needed by copy_camera_metadata for + * its dst buffer. + */ +ANDROID_API +size_t get_camera_metadata_compact_size(const camera_metadata_t *metadata); + +/** + * Get the current number of entries in the metadata packet. + * + * metadata packet must be valid, which can be checked before the call with + * validate_camera_metadata_structure(). + */ +ANDROID_API +size_t get_camera_metadata_entry_count(const camera_metadata_t *metadata); + +/** + * Get the maximum number of entries that could fit in the metadata packet. + */ +ANDROID_API +size_t get_camera_metadata_entry_capacity(const camera_metadata_t *metadata); + +/** + * Get the current count of bytes used for value storage in the metadata packet. + */ +ANDROID_API +size_t get_camera_metadata_data_count(const camera_metadata_t *metadata); + +/** + * Get the maximum count of bytes that could be used for value storage in the + * metadata packet. + */ +ANDROID_API +size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata); + +/** + * Copy a metadata structure to a memory buffer, compacting it along the + * way. That is, in the copied structure, entry_count == entry_capacity, and + * data_count == data_capacity. + * + * If dst_size > get_camera_metadata_compact_size(), the unused bytes are at the + * end of the buffer. If dst_size < get_camera_metadata_compact_size(), returns + * NULL. Otherwise returns a pointer to the metadata structure header placed at + * the start of dst. + * + * Since the buffer was not allocated by allocate_camera_metadata, the caller is + * responsible for freeing the underlying buffer when needed; do not call + * free_camera_metadata. + */ +ANDROID_API +camera_metadata_t *copy_camera_metadata(void *dst, size_t dst_size, + const camera_metadata_t *src); + + +// Non-zero return values for validate_camera_metadata_structure +enum { + CAMERA_METADATA_VALIDATION_ERROR = 1, + CAMERA_METADATA_VALIDATION_SHIFTED = 2, +}; + +/** + * Validate that a metadata is structurally sane. That is, its internal + * state is such that we won't get buffer overflows or run into other + * 'impossible' issues when calling the other API functions. + * + * This is useful in particular after copying the binary metadata blob + * from an untrusted source, since passing this check means the data is at least + * consistent. + * + * The expected_size argument is optional. + * + * Returns 0: on success + * CAMERA_METADATA_VALIDATION_ERROR: on error + * CAMERA_METADATA_VALIDATION_SHIFTED: when the data is not properly aligned, but can be + * used as input of clone_camera_metadata and the returned metadata will be valid. + * + */ +ANDROID_API +int validate_camera_metadata_structure(const camera_metadata_t *metadata, + const size_t *expected_size); + +/** + * Append camera metadata in src to an existing metadata structure in dst. This + * does not resize the destination structure, so if it is too small, a non-zero + * value is returned. On success, 0 is returned. Appending onto a sorted + * structure results in a non-sorted combined structure. + */ +ANDROID_API +int append_camera_metadata(camera_metadata_t *dst, const camera_metadata_t *src); + +/** + * Clone an existing metadata buffer, compacting along the way. This is + * equivalent to allocating a new buffer of the minimum needed size, then + * appending the buffer to be cloned into the new buffer. The resulting buffer + * can be freed with free_camera_metadata(). Returns NULL if cloning failed. + */ +ANDROID_API +camera_metadata_t *clone_camera_metadata(const camera_metadata_t *src); + +/** + * Calculate the number of bytes of extra data a given metadata entry will take + * up. That is, if entry of 'type' with a payload of 'data_count' values is + * added, how much will the value returned by get_camera_metadata_data_count() + * be increased? This value may be zero, if no extra data storage is needed. + */ +ANDROID_API +size_t calculate_camera_metadata_entry_data_size(uint8_t type, + size_t data_count); + +/** + * Add a metadata entry to a metadata structure. Returns 0 if the addition + * succeeded. Returns a non-zero value if there is insufficient reserved space + * left to add the entry, or if the tag is unknown. data_count is the number of + * entries in the data array of the tag's type, not a count of + * bytes. Vendor-defined tags can not be added using this method, unless + * set_vendor_tag_query_ops() has been called first. Entries are always added to + * the end of the structure (highest index), so after addition, a + * previously-sorted array will be marked as unsorted. + * + * Returns 0 on success. A non-0 value is returned on error. + */ +ANDROID_API +int add_camera_metadata_entry(camera_metadata_t *dst, + uint32_t tag, + const void *data, + size_t data_count); + +/** + * Sort the metadata buffer for fast searching. If already marked as sorted, + * does nothing. Adding or appending entries to the buffer will place the buffer + * back into an unsorted state. + * + * Returns 0 on success. A non-0 value is returned on error. + */ +ANDROID_API +int sort_camera_metadata(camera_metadata_t *dst); + +/** + * Get metadata entry at position index in the metadata buffer. + * Index must be less than entry count, which is returned by + * get_camera_metadata_entry_count(). + * + * src and index are inputs; the passed-in entry is updated with the details of + * the entry. The data pointer points to the real data in the buffer, and can be + * updated as long as the data count does not change. + * + * Returns 0 on success. A non-0 value is returned on error. + */ +ANDROID_API +int get_camera_metadata_entry(camera_metadata_t *src, + size_t index, + camera_metadata_entry_t *entry); + +/** + * Get metadata entry at position index, but disallow editing the data. + */ +ANDROID_API +int get_camera_metadata_ro_entry(const camera_metadata_t *src, + size_t index, + camera_metadata_ro_entry_t *entry); + +/** + * Find an entry with given tag value. If not found, returns -ENOENT. Otherwise, + * returns entry contents like get_camera_metadata_entry. + * + * If multiple entries with the same tag exist, does not have any guarantees on + * which is returned. To speed up searching for tags, sort the metadata + * structure first by calling sort_camera_metadata(). + */ +ANDROID_API +int find_camera_metadata_entry(camera_metadata_t *src, + uint32_t tag, + camera_metadata_entry_t *entry); + +/** + * Find an entry with given tag value, but disallow editing the data + */ +ANDROID_API +int find_camera_metadata_ro_entry(const camera_metadata_t *src, + uint32_t tag, + camera_metadata_ro_entry_t *entry); + +/** + * Delete an entry at given index. This is an expensive operation, since it + * requires repacking entries and possibly entry data. This also invalidates any + * existing camera_metadata_entry.data pointers to this buffer. Sorting is + * maintained. + */ +ANDROID_API +int delete_camera_metadata_entry(camera_metadata_t *dst, + size_t index); + +/** + * Updates a metadata entry with new data. If the data size is changing, may + * need to adjust the data array, making this an O(N) operation. If the data + * size is the same or still fits in the entry space, this is O(1). Maintains + * sorting, but invalidates camera_metadata_entry instances that point to the + * updated entry. If a non-NULL value is passed in to entry, the entry structure + * is updated to match the new buffer state. Returns a non-zero value if there + * is no room for the new data in the buffer. + */ +ANDROID_API +int update_camera_metadata_entry(camera_metadata_t *dst, + size_t index, + const void *data, + size_t data_count, + camera_metadata_entry_t *updated_entry); + +/** + * Retrieve human-readable name of section the tag is in. Returns NULL if + * no such tag is defined. Returns NULL for tags in the vendor section, unless + * set_vendor_tag_query_ops() has been used. + */ +ANDROID_API +const char *get_camera_metadata_section_name(uint32_t tag); + +/** + * Retrieve human-readable name of tag (not including section). Returns NULL if + * no such tag is defined. Returns NULL for tags in the vendor section, unless + * set_vendor_tag_query_ops() has been used. + */ +ANDROID_API +const char *get_camera_metadata_tag_name(uint32_t tag); + +/** + * Retrieve the type of a tag. Returns -1 if no such tag is defined. Returns -1 + * for tags in the vendor section, unless set_vendor_tag_query_ops() has been + * used. + */ +ANDROID_API +int get_camera_metadata_tag_type(uint32_t tag); + +/** + * Retrieve human-readable name of section the tag is in. Returns NULL if + * no such tag is defined. + */ +ANDROID_API +const char *get_local_camera_metadata_section_name(uint32_t tag, + const camera_metadata_t *meta); + +/** + * Retrieve human-readable name of tag (not including section). Returns NULL if + * no such tag is defined. + */ +ANDROID_API +const char *get_local_camera_metadata_tag_name(uint32_t tag, + const camera_metadata_t *meta); + +/** + * Retrieve the type of a tag. Returns -1 if no such tag is defined. + */ +ANDROID_API +int get_local_camera_metadata_tag_type(uint32_t tag, + const camera_metadata_t *meta); + +/** + * Set up vendor-specific tag query methods. These are needed to properly add + * entries with vendor-specified tags and to use the + * get_camera_metadata_section_name, _tag_name, and _tag_type methods with + * vendor tags. Returns 0 on success. + * + * **DEPRECATED** - Please use vendor_tag_ops defined in camera_vendor_tags.h + * instead. + */ +typedef struct vendor_tag_query_ops vendor_tag_query_ops_t; +struct vendor_tag_query_ops { + /** + * Get vendor section name for a vendor-specified entry tag. Only called for + * tags >= 0x80000000. The section name must start with the name of the + * vendor in the Java package style. For example, CameraZoom inc must prefix + * their sections with "com.camerazoom." Must return NULL if the tag is + * outside the bounds of vendor-defined sections. + */ + const char *(*get_camera_vendor_section_name)( + const vendor_tag_query_ops_t *v, + uint32_t tag); + /** + * Get tag name for a vendor-specified entry tag. Only called for tags >= + * 0x80000000. Must return NULL if the tag is outside the bounds of + * vendor-defined sections. + */ + const char *(*get_camera_vendor_tag_name)( + const vendor_tag_query_ops_t *v, + uint32_t tag); + /** + * Get tag type for a vendor-specified entry tag. Only called for tags >= + * 0x80000000. Must return -1 if the tag is outside the bounds of + * vendor-defined sections. + */ + int (*get_camera_vendor_tag_type)( + const vendor_tag_query_ops_t *v, + uint32_t tag); + /** + * Get the number of vendor tags supported on this platform. Used to + * calculate the size of buffer needed for holding the array of all tags + * returned by get_camera_vendor_tags(). + */ + int (*get_camera_vendor_tag_count)( + const vendor_tag_query_ops_t *v); + /** + * Fill an array with all the supported vendor tags on this platform. + * get_camera_vendor_tag_count() returns the number of tags supported, and + * tag_array should be allocated with enough space to hold all of the tags. + */ + void (*get_camera_vendor_tags)( + const vendor_tag_query_ops_t *v, + uint32_t *tag_array); +}; + +/** + * **DEPRECATED** - This should only be used by the camera framework. Camera + * metadata will transition to using vendor_tag_ops defined in + * camera_vendor_tags.h instead. + */ +ANDROID_API +int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t *query_ops); + +/** + * Print fields in the metadata to the log. + * verbosity = 0: Only tag entry information + * verbosity = 1: Tag entry information plus at most 16 data values + * verbosity = 2: All information + */ +ANDROID_API +void dump_camera_metadata(const camera_metadata_t *metadata, + int fd, + int verbosity); + +/** + * Print fields in the metadata to the log; adds indentation parameter, which + * specifies the number of spaces to insert before each line of the dump + */ +ANDROID_API +void dump_indented_camera_metadata(const camera_metadata_t *metadata, + int fd, + int verbosity, + int indentation); + +/** + * Prints the specified tag value as a string. Only works for enum tags. + * Returns 0 on success, -1 on failure. + */ +ANDROID_API +int camera_metadata_enum_snprint(uint32_t tag, + uint32_t value, + char *dst, + size_t size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/android/metadata/system/camera_metadata_tags.h b/include/android/metadata/system/camera_metadata_tags.h new file mode 100644 index 000000000000..adf18b8f4c2f --- /dev/null +++ b/include/android/metadata/system/camera_metadata_tags.h @@ -0,0 +1,1005 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * !! Do not include this file directly !! + * + * Include camera_metadata.h instead. + */ + +/** + * ! Do not edit this file directly ! + * + * Generated automatically from camera_metadata_tags.mako + */ + +/** TODO: Nearly every enum in this file needs a description */ + +/** + * Top level hierarchy definitions for camera metadata. *_INFO sections are for + * the static metadata that can be retrived without opening the camera device. + * New sections must be added right before ANDROID_SECTION_COUNT to maintain + * existing enumerations. + */ +typedef enum camera_metadata_section { + ANDROID_COLOR_CORRECTION, + ANDROID_CONTROL, + ANDROID_DEMOSAIC, + ANDROID_EDGE, + ANDROID_FLASH, + ANDROID_FLASH_INFO, + ANDROID_HOT_PIXEL, + ANDROID_JPEG, + ANDROID_LENS, + ANDROID_LENS_INFO, + ANDROID_NOISE_REDUCTION, + ANDROID_QUIRKS, + ANDROID_REQUEST, + ANDROID_SCALER, + ANDROID_SENSOR, + ANDROID_SENSOR_INFO, + ANDROID_SHADING, + ANDROID_STATISTICS, + ANDROID_STATISTICS_INFO, + ANDROID_TONEMAP, + ANDROID_LED, + ANDROID_INFO, + ANDROID_BLACK_LEVEL, + ANDROID_SYNC, + ANDROID_REPROCESS, + ANDROID_DEPTH, + ANDROID_LOGICAL_MULTI_CAMERA, + ANDROID_DISTORTION_CORRECTION, + ANDROID_SECTION_COUNT, + + VENDOR_SECTION = 0x8000 +} camera_metadata_section_t; + +/** + * Hierarchy positions in enum space. All vendor extension tags must be + * defined with tag >= VENDOR_SECTION_START + */ +typedef enum camera_metadata_section_start { + ANDROID_COLOR_CORRECTION_START = ANDROID_COLOR_CORRECTION << 16, + ANDROID_CONTROL_START = ANDROID_CONTROL << 16, + ANDROID_DEMOSAIC_START = ANDROID_DEMOSAIC << 16, + ANDROID_EDGE_START = ANDROID_EDGE << 16, + ANDROID_FLASH_START = ANDROID_FLASH << 16, + ANDROID_FLASH_INFO_START = ANDROID_FLASH_INFO << 16, + ANDROID_HOT_PIXEL_START = ANDROID_HOT_PIXEL << 16, + ANDROID_JPEG_START = ANDROID_JPEG << 16, + ANDROID_LENS_START = ANDROID_LENS << 16, + ANDROID_LENS_INFO_START = ANDROID_LENS_INFO << 16, + ANDROID_NOISE_REDUCTION_START = ANDROID_NOISE_REDUCTION << 16, + ANDROID_QUIRKS_START = ANDROID_QUIRKS << 16, + ANDROID_REQUEST_START = ANDROID_REQUEST << 16, + ANDROID_SCALER_START = ANDROID_SCALER << 16, + ANDROID_SENSOR_START = ANDROID_SENSOR << 16, + ANDROID_SENSOR_INFO_START = ANDROID_SENSOR_INFO << 16, + ANDROID_SHADING_START = ANDROID_SHADING << 16, + ANDROID_STATISTICS_START = ANDROID_STATISTICS << 16, + ANDROID_STATISTICS_INFO_START = ANDROID_STATISTICS_INFO << 16, + ANDROID_TONEMAP_START = ANDROID_TONEMAP << 16, + ANDROID_LED_START = ANDROID_LED << 16, + ANDROID_INFO_START = ANDROID_INFO << 16, + ANDROID_BLACK_LEVEL_START = ANDROID_BLACK_LEVEL << 16, + ANDROID_SYNC_START = ANDROID_SYNC << 16, + ANDROID_REPROCESS_START = ANDROID_REPROCESS << 16, + ANDROID_DEPTH_START = ANDROID_DEPTH << 16, + ANDROID_LOGICAL_MULTI_CAMERA_START + = ANDROID_LOGICAL_MULTI_CAMERA + << 16, + ANDROID_DISTORTION_CORRECTION_START + = ANDROID_DISTORTION_CORRECTION + << 16, + VENDOR_SECTION_START = VENDOR_SECTION << 16 +} camera_metadata_section_start_t; + +/** + * Main enum for defining camera metadata tags. New entries must always go + * before the section _END tag to preserve existing enumeration values. In + * addition, the name and type of the tag needs to be added to + * system/media/camera/src/camera_metadata_tag_info.c + */ +typedef enum camera_metadata_tag { + ANDROID_COLOR_CORRECTION_MODE = // enum | public | HIDL v3.2 + ANDROID_COLOR_CORRECTION_START, + ANDROID_COLOR_CORRECTION_TRANSFORM, // rational[] | public | HIDL v3.2 + ANDROID_COLOR_CORRECTION_GAINS, // float[] | public | HIDL v3.2 + ANDROID_COLOR_CORRECTION_ABERRATION_MODE, // enum | public | HIDL v3.2 + ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, + // byte[] | public | HIDL v3.2 + ANDROID_COLOR_CORRECTION_END, + + ANDROID_CONTROL_AE_ANTIBANDING_MODE = // enum | public | HIDL v3.2 + ANDROID_CONTROL_START, + ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, // int32 | public | HIDL v3.2 + ANDROID_CONTROL_AE_LOCK, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AE_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AE_REGIONS, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_AE_TARGET_FPS_RANGE, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AF_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AF_REGIONS, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_AF_TRIGGER, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AWB_LOCK, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AWB_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AWB_REGIONS, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT, // enum | public | HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_AE_AVAILABLE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_AE_COMPENSATION_RANGE, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_AE_COMPENSATION_STEP, // rational | public | HIDL v3.2 + ANDROID_CONTROL_AF_AVAILABLE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_AVAILABLE_EFFECTS, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_AVAILABLE_SCENE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, + // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_AWB_AVAILABLE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_MAX_REGIONS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_OVERRIDES, // byte[] | system | HIDL v3.2 + ANDROID_CONTROL_AE_PRECAPTURE_ID, // int32 | system | HIDL v3.2 + ANDROID_CONTROL_AE_STATE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AF_STATE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AF_TRIGGER_ID, // int32 | system | HIDL v3.2 + ANDROID_CONTROL_AWB_STATE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS, + // int32[] | hidden | HIDL v3.2 + ANDROID_CONTROL_AE_LOCK_AVAILABLE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AWB_LOCK_AVAILABLE, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AVAILABLE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE, // int32[] | public | HIDL v3.2 + ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST, // int32 | public | HIDL v3.2 + ANDROID_CONTROL_ENABLE_ZSL, // enum | public | HIDL v3.2 + ANDROID_CONTROL_AF_SCENE_CHANGE, // enum | public | HIDL v3.3 + ANDROID_CONTROL_END, + + ANDROID_DEMOSAIC_MODE = // enum | system | HIDL v3.2 + ANDROID_DEMOSAIC_START, + ANDROID_DEMOSAIC_END, + + ANDROID_EDGE_MODE = // enum | public | HIDL v3.2 + ANDROID_EDGE_START, + ANDROID_EDGE_STRENGTH, // byte | system | HIDL v3.2 + ANDROID_EDGE_AVAILABLE_EDGE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_EDGE_END, + + ANDROID_FLASH_FIRING_POWER = // byte | system | HIDL v3.2 + ANDROID_FLASH_START, + ANDROID_FLASH_FIRING_TIME, // int64 | system | HIDL v3.2 + ANDROID_FLASH_MODE, // enum | public | HIDL v3.2 + ANDROID_FLASH_COLOR_TEMPERATURE, // byte | system | HIDL v3.2 + ANDROID_FLASH_MAX_ENERGY, // byte | system | HIDL v3.2 + ANDROID_FLASH_STATE, // enum | public | HIDL v3.2 + ANDROID_FLASH_END, + + ANDROID_FLASH_INFO_AVAILABLE = // enum | public | HIDL v3.2 + ANDROID_FLASH_INFO_START, + ANDROID_FLASH_INFO_CHARGE_DURATION, // int64 | system | HIDL v3.2 + ANDROID_FLASH_INFO_END, + + ANDROID_HOT_PIXEL_MODE = // enum | public | HIDL v3.2 + ANDROID_HOT_PIXEL_START, + ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES, // byte[] | public | HIDL v3.2 + ANDROID_HOT_PIXEL_END, + + ANDROID_JPEG_GPS_COORDINATES = // double[] | ndk_public | HIDL v3.2 + ANDROID_JPEG_START, + ANDROID_JPEG_GPS_PROCESSING_METHOD, // byte | ndk_public | HIDL v3.2 + ANDROID_JPEG_GPS_TIMESTAMP, // int64 | ndk_public | HIDL v3.2 + ANDROID_JPEG_ORIENTATION, // int32 | public | HIDL v3.2 + ANDROID_JPEG_QUALITY, // byte | public | HIDL v3.2 + ANDROID_JPEG_THUMBNAIL_QUALITY, // byte | public | HIDL v3.2 + ANDROID_JPEG_THUMBNAIL_SIZE, // int32[] | public | HIDL v3.2 + ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, // int32[] | public | HIDL v3.2 + ANDROID_JPEG_MAX_SIZE, // int32 | system | HIDL v3.2 + ANDROID_JPEG_SIZE, // int32 | system | HIDL v3.2 + ANDROID_JPEG_END, + + ANDROID_LENS_APERTURE = // float | public | HIDL v3.2 + ANDROID_LENS_START, + ANDROID_LENS_FILTER_DENSITY, // float | public | HIDL v3.2 + ANDROID_LENS_FOCAL_LENGTH, // float | public | HIDL v3.2 + ANDROID_LENS_FOCUS_DISTANCE, // float | public | HIDL v3.2 + ANDROID_LENS_OPTICAL_STABILIZATION_MODE, // enum | public | HIDL v3.2 + ANDROID_LENS_FACING, // enum | public | HIDL v3.2 + ANDROID_LENS_POSE_ROTATION, // float[] | public | HIDL v3.2 + ANDROID_LENS_POSE_TRANSLATION, // float[] | public | HIDL v3.2 + ANDROID_LENS_FOCUS_RANGE, // float[] | public | HIDL v3.2 + ANDROID_LENS_STATE, // enum | public | HIDL v3.2 + ANDROID_LENS_INTRINSIC_CALIBRATION, // float[] | public | HIDL v3.2 + ANDROID_LENS_RADIAL_DISTORTION, // float[] | public | HIDL v3.2 + ANDROID_LENS_POSE_REFERENCE, // enum | public | HIDL v3.3 + ANDROID_LENS_DISTORTION, // float[] | public | HIDL v3.3 + ANDROID_LENS_END, + + ANDROID_LENS_INFO_AVAILABLE_APERTURES = // float[] | public | HIDL v3.2 + ANDROID_LENS_INFO_START, + ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES, // float[] | public | HIDL v3.2 + ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, // float[] | public | HIDL v3.2 + ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,// byte[] | public | HIDL v3.2 + ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, // float | public | HIDL v3.2 + ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, // float | public | HIDL v3.2 + ANDROID_LENS_INFO_SHADING_MAP_SIZE, // int32[] | ndk_public | HIDL v3.2 + ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION, // enum | public | HIDL v3.2 + ANDROID_LENS_INFO_END, + + ANDROID_NOISE_REDUCTION_MODE = // enum | public | HIDL v3.2 + ANDROID_NOISE_REDUCTION_START, + ANDROID_NOISE_REDUCTION_STRENGTH, // byte | system | HIDL v3.2 + ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + // byte[] | public | HIDL v3.2 + ANDROID_NOISE_REDUCTION_END, + + ANDROID_QUIRKS_METERING_CROP_REGION = // byte | system | HIDL v3.2 + ANDROID_QUIRKS_START, + ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO, // byte | system | HIDL v3.2 + ANDROID_QUIRKS_USE_ZSL_FORMAT, // byte | system | HIDL v3.2 + ANDROID_QUIRKS_USE_PARTIAL_RESULT, // byte | hidden | HIDL v3.2 + ANDROID_QUIRKS_PARTIAL_RESULT, // enum | hidden | HIDL v3.2 + ANDROID_QUIRKS_END, + + ANDROID_REQUEST_FRAME_COUNT = // int32 | hidden | HIDL v3.2 + ANDROID_REQUEST_START, + ANDROID_REQUEST_ID, // int32 | hidden | HIDL v3.2 + ANDROID_REQUEST_INPUT_STREAMS, // int32[] | system | HIDL v3.2 + ANDROID_REQUEST_METADATA_MODE, // enum | system | HIDL v3.2 + ANDROID_REQUEST_OUTPUT_STREAMS, // int32[] | system | HIDL v3.2 + ANDROID_REQUEST_TYPE, // enum | system | HIDL v3.2 + ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_REQUEST_MAX_NUM_REPROCESS_STREAMS, // int32[] | system | HIDL v3.2 + ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, // int32 | java_public | HIDL v3.2 + ANDROID_REQUEST_PIPELINE_DEPTH, // byte | public | HIDL v3.2 + ANDROID_REQUEST_PIPELINE_MAX_DEPTH, // byte | public | HIDL v3.2 + ANDROID_REQUEST_PARTIAL_RESULT_COUNT, // int32 | public | HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES, // enum[] | public | HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_SESSION_KEYS, // int32[] | ndk_public | HIDL v3.3 + ANDROID_REQUEST_AVAILABLE_PHYSICAL_CAMERA_REQUEST_KEYS, + // int32[] | hidden | HIDL v3.3 + ANDROID_REQUEST_END, + + ANDROID_SCALER_CROP_REGION = // int32[] | public | HIDL v3.2 + ANDROID_SCALER_START, + ANDROID_SCALER_AVAILABLE_FORMATS, // enum[] | hidden | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS, // int64[] | hidden | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_JPEG_SIZES, // int32[] | hidden | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, // float | public | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS, // int64[] | hidden | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, // int32[] | hidden | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS, // int64[] | system | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_RAW_SIZES, // int32[] | system | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP,// int32 | hidden | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, // enum[] | ndk_public | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, // int64[] | ndk_public | HIDL v3.2 + ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, // int64[] | ndk_public | HIDL v3.2 + ANDROID_SCALER_CROPPING_TYPE, // enum | public | HIDL v3.2 + ANDROID_SCALER_END, + + ANDROID_SENSOR_EXPOSURE_TIME = // int64 | public | HIDL v3.2 + ANDROID_SENSOR_START, + ANDROID_SENSOR_FRAME_DURATION, // int64 | public | HIDL v3.2 + ANDROID_SENSOR_SENSITIVITY, // int32 | public | HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1, // enum | public | HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT2, // byte | public | HIDL v3.2 + ANDROID_SENSOR_CALIBRATION_TRANSFORM1, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_CALIBRATION_TRANSFORM2, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_COLOR_TRANSFORM1, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_COLOR_TRANSFORM2, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_FORWARD_MATRIX1, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_FORWARD_MATRIX2, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_BASE_GAIN_FACTOR, // rational | system | HIDL v3.2 + ANDROID_SENSOR_BLACK_LEVEL_PATTERN, // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY, // int32 | public | HIDL v3.2 + ANDROID_SENSOR_ORIENTATION, // int32 | public | HIDL v3.2 + ANDROID_SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS, // int32[] | system | HIDL v3.2 + ANDROID_SENSOR_TIMESTAMP, // int64 | public | HIDL v3.2 + ANDROID_SENSOR_TEMPERATURE, // float | system | HIDL v3.2 + ANDROID_SENSOR_NEUTRAL_COLOR_POINT, // rational[] | public | HIDL v3.2 + ANDROID_SENSOR_NOISE_PROFILE, // double[] | public | HIDL v3.2 + ANDROID_SENSOR_PROFILE_HUE_SAT_MAP, // float[] | system | HIDL v3.2 + ANDROID_SENSOR_PROFILE_TONE_CURVE, // float[] | system | HIDL v3.2 + ANDROID_SENSOR_GREEN_SPLIT, // float | public | HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_DATA, // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_MODE, // enum | public | HIDL v3.2 + ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, // int64 | public | HIDL v3.2 + ANDROID_SENSOR_OPTICAL_BLACK_REGIONS, // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL, // float[] | public | HIDL v3.2 + ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL, // int32 | public | HIDL v3.2 + ANDROID_SENSOR_OPAQUE_RAW_SIZE, // int32[] | system | HIDL v3.2 + ANDROID_SENSOR_END, + + ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE = // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_INFO_START, + ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, // enum | public | HIDL v3.2 + ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, // int64[] | public | HIDL v3.2 + ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, // int64 | public | HIDL v3.2 + ANDROID_SENSOR_INFO_PHYSICAL_SIZE, // float[] | public | HIDL v3.2 + ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_INFO_WHITE_LEVEL, // int32 | public | HIDL v3.2 + ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, // enum | public | HIDL v3.2 + ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED, // enum | public | HIDL v3.2 + ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE, + // int32[] | public | HIDL v3.2 + ANDROID_SENSOR_INFO_END, + + ANDROID_SHADING_MODE = // enum | public | HIDL v3.2 + ANDROID_SHADING_START, + ANDROID_SHADING_STRENGTH, // byte | system | HIDL v3.2 + ANDROID_SHADING_AVAILABLE_MODES, // byte[] | public | HIDL v3.2 + ANDROID_SHADING_END, + + ANDROID_STATISTICS_FACE_DETECT_MODE = // enum | public | HIDL v3.2 + ANDROID_STATISTICS_START, + ANDROID_STATISTICS_HISTOGRAM_MODE, // enum | system | HIDL v3.2 + ANDROID_STATISTICS_SHARPNESS_MAP_MODE, // enum | system | HIDL v3.2 + ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, // enum | public | HIDL v3.2 + ANDROID_STATISTICS_FACE_IDS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_STATISTICS_FACE_LANDMARKS, // int32[] | ndk_public | HIDL v3.2 + ANDROID_STATISTICS_FACE_RECTANGLES, // int32[] | ndk_public | HIDL v3.2 + ANDROID_STATISTICS_FACE_SCORES, // byte[] | ndk_public | HIDL v3.2 + ANDROID_STATISTICS_HISTOGRAM, // int32[] | system | HIDL v3.2 + ANDROID_STATISTICS_SHARPNESS_MAP, // int32[] | system | HIDL v3.2 + ANDROID_STATISTICS_LENS_SHADING_CORRECTION_MAP, // byte | java_public | HIDL v3.2 + ANDROID_STATISTICS_LENS_SHADING_MAP, // float[] | ndk_public | HIDL v3.2 + ANDROID_STATISTICS_PREDICTED_COLOR_GAINS, // float[] | hidden | HIDL v3.2 + ANDROID_STATISTICS_PREDICTED_COLOR_TRANSFORM, // rational[] | hidden | HIDL v3.2 + ANDROID_STATISTICS_SCENE_FLICKER, // enum | public | HIDL v3.2 + ANDROID_STATISTICS_HOT_PIXEL_MAP, // int32[] | public | HIDL v3.2 + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, // enum | public | HIDL v3.2 + ANDROID_STATISTICS_OIS_DATA_MODE, // enum | public | HIDL v3.3 + ANDROID_STATISTICS_OIS_TIMESTAMPS, // int64[] | ndk_public | HIDL v3.3 + ANDROID_STATISTICS_OIS_X_SHIFTS, // float[] | ndk_public | HIDL v3.3 + ANDROID_STATISTICS_OIS_Y_SHIFTS, // float[] | ndk_public | HIDL v3.3 + ANDROID_STATISTICS_END, + + ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES = + // byte[] | public | HIDL v3.2 + ANDROID_STATISTICS_INFO_START, + ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT, // int32 | system | HIDL v3.2 + ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, // int32 | public | HIDL v3.2 + ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT, // int32 | system | HIDL v3.2 + ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE, // int32 | system | HIDL v3.2 + ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE, // int32[] | system | HIDL v3.2 + ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES, + // byte[] | public | HIDL v3.2 + ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES, + // byte[] | public | HIDL v3.2 + ANDROID_STATISTICS_INFO_AVAILABLE_OIS_DATA_MODES, // byte[] | public | HIDL v3.3 + ANDROID_STATISTICS_INFO_END, + + ANDROID_TONEMAP_CURVE_BLUE = // float[] | ndk_public | HIDL v3.2 + ANDROID_TONEMAP_START, + ANDROID_TONEMAP_CURVE_GREEN, // float[] | ndk_public | HIDL v3.2 + ANDROID_TONEMAP_CURVE_RED, // float[] | ndk_public | HIDL v3.2 + ANDROID_TONEMAP_MODE, // enum | public | HIDL v3.2 + ANDROID_TONEMAP_MAX_CURVE_POINTS, // int32 | public | HIDL v3.2 + ANDROID_TONEMAP_AVAILABLE_TONE_MAP_MODES, // byte[] | public | HIDL v3.2 + ANDROID_TONEMAP_GAMMA, // float | public | HIDL v3.2 + ANDROID_TONEMAP_PRESET_CURVE, // enum | public | HIDL v3.2 + ANDROID_TONEMAP_END, + + ANDROID_LED_TRANSMIT = // enum | hidden | HIDL v3.2 + ANDROID_LED_START, + ANDROID_LED_AVAILABLE_LEDS, // enum[] | hidden | HIDL v3.2 + ANDROID_LED_END, + + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL = // enum | public | HIDL v3.2 + ANDROID_INFO_START, + ANDROID_INFO_VERSION, // byte | public | HIDL v3.3 + ANDROID_INFO_END, + + ANDROID_BLACK_LEVEL_LOCK = // enum | public | HIDL v3.2 + ANDROID_BLACK_LEVEL_START, + ANDROID_BLACK_LEVEL_END, + + ANDROID_SYNC_FRAME_NUMBER = // enum | ndk_public | HIDL v3.2 + ANDROID_SYNC_START, + ANDROID_SYNC_MAX_LATENCY, // enum | public | HIDL v3.2 + ANDROID_SYNC_END, + + ANDROID_REPROCESS_EFFECTIVE_EXPOSURE_FACTOR = // float | java_public | HIDL v3.2 + ANDROID_REPROCESS_START, + ANDROID_REPROCESS_MAX_CAPTURE_STALL, // int32 | java_public | HIDL v3.2 + ANDROID_REPROCESS_END, + + ANDROID_DEPTH_MAX_DEPTH_SAMPLES = // int32 | system | HIDL v3.2 + ANDROID_DEPTH_START, + ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, + // enum[] | ndk_public | HIDL v3.2 + ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS,// int64[] | ndk_public | HIDL v3.2 + ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS, // int64[] | ndk_public | HIDL v3.2 + ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE, // enum | public | HIDL v3.2 + ANDROID_DEPTH_END, + + ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS = // byte[] | hidden | HIDL v3.3 + ANDROID_LOGICAL_MULTI_CAMERA_START, + ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE, // enum | public | HIDL v3.3 + ANDROID_LOGICAL_MULTI_CAMERA_END, + + ANDROID_DISTORTION_CORRECTION_MODE = // enum | public | HIDL v3.3 + ANDROID_DISTORTION_CORRECTION_START, + ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES, // byte[] | public | HIDL v3.3 + ANDROID_DISTORTION_CORRECTION_END, + +} camera_metadata_tag_t; + +/** + * Enumeration definitions for the various entries that need them + */ + +// ANDROID_COLOR_CORRECTION_MODE +typedef enum camera_metadata_enum_android_color_correction_mode { + ANDROID_COLOR_CORRECTION_MODE_TRANSFORM_MATRIX , // HIDL v3.2 + ANDROID_COLOR_CORRECTION_MODE_FAST , // HIDL v3.2 + ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY , // HIDL v3.2 +} camera_metadata_enum_android_color_correction_mode_t; + +// ANDROID_COLOR_CORRECTION_ABERRATION_MODE +typedef enum camera_metadata_enum_android_color_correction_aberration_mode { + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF , // HIDL v3.2 + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST , // HIDL v3.2 + ANDROID_COLOR_CORRECTION_ABERRATION_MODE_HIGH_QUALITY , // HIDL v3.2 +} camera_metadata_enum_android_color_correction_aberration_mode_t; + + +// ANDROID_CONTROL_AE_ANTIBANDING_MODE +typedef enum camera_metadata_enum_android_control_ae_antibanding_mode { + ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ , // HIDL v3.2 + ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ , // HIDL v3.2 + ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO , // HIDL v3.2 +} camera_metadata_enum_android_control_ae_antibanding_mode_t; + +// ANDROID_CONTROL_AE_LOCK +typedef enum camera_metadata_enum_android_control_ae_lock { + ANDROID_CONTROL_AE_LOCK_OFF , // HIDL v3.2 + ANDROID_CONTROL_AE_LOCK_ON , // HIDL v3.2 +} camera_metadata_enum_android_control_ae_lock_t; + +// ANDROID_CONTROL_AE_MODE +typedef enum camera_metadata_enum_android_control_ae_mode { + ANDROID_CONTROL_AE_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_AE_MODE_ON , // HIDL v3.2 + ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH , // HIDL v3.2 + ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH , // HIDL v3.2 + ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE , // HIDL v3.2 + ANDROID_CONTROL_AE_MODE_ON_EXTERNAL_FLASH , // HIDL v3.3 +} camera_metadata_enum_android_control_ae_mode_t; + +// ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER +typedef enum camera_metadata_enum_android_control_ae_precapture_trigger { + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE , // HIDL v3.2 + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_START , // HIDL v3.2 + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL , // HIDL v3.2 +} camera_metadata_enum_android_control_ae_precapture_trigger_t; + +// ANDROID_CONTROL_AF_MODE +typedef enum camera_metadata_enum_android_control_af_mode { + ANDROID_CONTROL_AF_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_AF_MODE_AUTO , // HIDL v3.2 + ANDROID_CONTROL_AF_MODE_MACRO , // HIDL v3.2 + ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO , // HIDL v3.2 + ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE , // HIDL v3.2 + ANDROID_CONTROL_AF_MODE_EDOF , // HIDL v3.2 +} camera_metadata_enum_android_control_af_mode_t; + +// ANDROID_CONTROL_AF_TRIGGER +typedef enum camera_metadata_enum_android_control_af_trigger { + ANDROID_CONTROL_AF_TRIGGER_IDLE , // HIDL v3.2 + ANDROID_CONTROL_AF_TRIGGER_START , // HIDL v3.2 + ANDROID_CONTROL_AF_TRIGGER_CANCEL , // HIDL v3.2 +} camera_metadata_enum_android_control_af_trigger_t; + +// ANDROID_CONTROL_AWB_LOCK +typedef enum camera_metadata_enum_android_control_awb_lock { + ANDROID_CONTROL_AWB_LOCK_OFF , // HIDL v3.2 + ANDROID_CONTROL_AWB_LOCK_ON , // HIDL v3.2 +} camera_metadata_enum_android_control_awb_lock_t; + +// ANDROID_CONTROL_AWB_MODE +typedef enum camera_metadata_enum_android_control_awb_mode { + ANDROID_CONTROL_AWB_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_AUTO , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_INCANDESCENT , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_FLUORESCENT , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_DAYLIGHT , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_TWILIGHT , // HIDL v3.2 + ANDROID_CONTROL_AWB_MODE_SHADE , // HIDL v3.2 +} camera_metadata_enum_android_control_awb_mode_t; + +// ANDROID_CONTROL_CAPTURE_INTENT +typedef enum camera_metadata_enum_android_control_capture_intent { + ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_MANUAL , // HIDL v3.2 + ANDROID_CONTROL_CAPTURE_INTENT_MOTION_TRACKING , // HIDL v3.3 +} camera_metadata_enum_android_control_capture_intent_t; + +// ANDROID_CONTROL_EFFECT_MODE +typedef enum camera_metadata_enum_android_control_effect_mode { + ANDROID_CONTROL_EFFECT_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_MONO , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_NEGATIVE , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_SOLARIZE , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_SEPIA , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_POSTERIZE , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_WHITEBOARD , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_BLACKBOARD , // HIDL v3.2 + ANDROID_CONTROL_EFFECT_MODE_AQUA , // HIDL v3.2 +} camera_metadata_enum_android_control_effect_mode_t; + +// ANDROID_CONTROL_MODE +typedef enum camera_metadata_enum_android_control_mode { + ANDROID_CONTROL_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_MODE_AUTO , // HIDL v3.2 + ANDROID_CONTROL_MODE_USE_SCENE_MODE , // HIDL v3.2 + ANDROID_CONTROL_MODE_OFF_KEEP_STATE , // HIDL v3.2 +} camera_metadata_enum_android_control_mode_t; + +// ANDROID_CONTROL_SCENE_MODE +typedef enum camera_metadata_enum_android_control_scene_mode { + ANDROID_CONTROL_SCENE_MODE_DISABLED = 0, // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_ACTION , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_PORTRAIT , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_LANDSCAPE , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_NIGHT , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_NIGHT_PORTRAIT , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_THEATRE , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_BEACH , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_SNOW , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_SUNSET , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_STEADYPHOTO , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_FIREWORKS , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_SPORTS , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_PARTY , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_BARCODE , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_HDR , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY_LOW_LIGHT , // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_START = 100, // HIDL v3.2 + ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_END = 127, // HIDL v3.2 +} camera_metadata_enum_android_control_scene_mode_t; + +// ANDROID_CONTROL_VIDEO_STABILIZATION_MODE +typedef enum camera_metadata_enum_android_control_video_stabilization_mode { + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF , // HIDL v3.2 + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON , // HIDL v3.2 +} camera_metadata_enum_android_control_video_stabilization_mode_t; + +// ANDROID_CONTROL_AE_STATE +typedef enum camera_metadata_enum_android_control_ae_state { + ANDROID_CONTROL_AE_STATE_INACTIVE , // HIDL v3.2 + ANDROID_CONTROL_AE_STATE_SEARCHING , // HIDL v3.2 + ANDROID_CONTROL_AE_STATE_CONVERGED , // HIDL v3.2 + ANDROID_CONTROL_AE_STATE_LOCKED , // HIDL v3.2 + ANDROID_CONTROL_AE_STATE_FLASH_REQUIRED , // HIDL v3.2 + ANDROID_CONTROL_AE_STATE_PRECAPTURE , // HIDL v3.2 +} camera_metadata_enum_android_control_ae_state_t; + +// ANDROID_CONTROL_AF_STATE +typedef enum camera_metadata_enum_android_control_af_state { + ANDROID_CONTROL_AF_STATE_INACTIVE , // HIDL v3.2 + ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN , // HIDL v3.2 + ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED , // HIDL v3.2 + ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN , // HIDL v3.2 + ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED , // HIDL v3.2 + ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED , // HIDL v3.2 + ANDROID_CONTROL_AF_STATE_PASSIVE_UNFOCUSED , // HIDL v3.2 +} camera_metadata_enum_android_control_af_state_t; + +// ANDROID_CONTROL_AWB_STATE +typedef enum camera_metadata_enum_android_control_awb_state { + ANDROID_CONTROL_AWB_STATE_INACTIVE , // HIDL v3.2 + ANDROID_CONTROL_AWB_STATE_SEARCHING , // HIDL v3.2 + ANDROID_CONTROL_AWB_STATE_CONVERGED , // HIDL v3.2 + ANDROID_CONTROL_AWB_STATE_LOCKED , // HIDL v3.2 +} camera_metadata_enum_android_control_awb_state_t; + +// ANDROID_CONTROL_AE_LOCK_AVAILABLE +typedef enum camera_metadata_enum_android_control_ae_lock_available { + ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE , // HIDL v3.2 + ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE , // HIDL v3.2 +} camera_metadata_enum_android_control_ae_lock_available_t; + +// ANDROID_CONTROL_AWB_LOCK_AVAILABLE +typedef enum camera_metadata_enum_android_control_awb_lock_available { + ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE , // HIDL v3.2 + ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE , // HIDL v3.2 +} camera_metadata_enum_android_control_awb_lock_available_t; + +// ANDROID_CONTROL_ENABLE_ZSL +typedef enum camera_metadata_enum_android_control_enable_zsl { + ANDROID_CONTROL_ENABLE_ZSL_FALSE , // HIDL v3.2 + ANDROID_CONTROL_ENABLE_ZSL_TRUE , // HIDL v3.2 +} camera_metadata_enum_android_control_enable_zsl_t; + +// ANDROID_CONTROL_AF_SCENE_CHANGE +typedef enum camera_metadata_enum_android_control_af_scene_change { + ANDROID_CONTROL_AF_SCENE_CHANGE_NOT_DETECTED , // HIDL v3.3 + ANDROID_CONTROL_AF_SCENE_CHANGE_DETECTED , // HIDL v3.3 +} camera_metadata_enum_android_control_af_scene_change_t; + + +// ANDROID_DEMOSAIC_MODE +typedef enum camera_metadata_enum_android_demosaic_mode { + ANDROID_DEMOSAIC_MODE_FAST , // HIDL v3.2 + ANDROID_DEMOSAIC_MODE_HIGH_QUALITY , // HIDL v3.2 +} camera_metadata_enum_android_demosaic_mode_t; + + +// ANDROID_EDGE_MODE +typedef enum camera_metadata_enum_android_edge_mode { + ANDROID_EDGE_MODE_OFF , // HIDL v3.2 + ANDROID_EDGE_MODE_FAST , // HIDL v3.2 + ANDROID_EDGE_MODE_HIGH_QUALITY , // HIDL v3.2 + ANDROID_EDGE_MODE_ZERO_SHUTTER_LAG , // HIDL v3.2 +} camera_metadata_enum_android_edge_mode_t; + + +// ANDROID_FLASH_MODE +typedef enum camera_metadata_enum_android_flash_mode { + ANDROID_FLASH_MODE_OFF , // HIDL v3.2 + ANDROID_FLASH_MODE_SINGLE , // HIDL v3.2 + ANDROID_FLASH_MODE_TORCH , // HIDL v3.2 +} camera_metadata_enum_android_flash_mode_t; + +// ANDROID_FLASH_STATE +typedef enum camera_metadata_enum_android_flash_state { + ANDROID_FLASH_STATE_UNAVAILABLE , // HIDL v3.2 + ANDROID_FLASH_STATE_CHARGING , // HIDL v3.2 + ANDROID_FLASH_STATE_READY , // HIDL v3.2 + ANDROID_FLASH_STATE_FIRED , // HIDL v3.2 + ANDROID_FLASH_STATE_PARTIAL , // HIDL v3.2 +} camera_metadata_enum_android_flash_state_t; + + +// ANDROID_FLASH_INFO_AVAILABLE +typedef enum camera_metadata_enum_android_flash_info_available { + ANDROID_FLASH_INFO_AVAILABLE_FALSE , // HIDL v3.2 + ANDROID_FLASH_INFO_AVAILABLE_TRUE , // HIDL v3.2 +} camera_metadata_enum_android_flash_info_available_t; + + +// ANDROID_HOT_PIXEL_MODE +typedef enum camera_metadata_enum_android_hot_pixel_mode { + ANDROID_HOT_PIXEL_MODE_OFF , // HIDL v3.2 + ANDROID_HOT_PIXEL_MODE_FAST , // HIDL v3.2 + ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY , // HIDL v3.2 +} camera_metadata_enum_android_hot_pixel_mode_t; + + + +// ANDROID_LENS_OPTICAL_STABILIZATION_MODE +typedef enum camera_metadata_enum_android_lens_optical_stabilization_mode { + ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF , // HIDL v3.2 + ANDROID_LENS_OPTICAL_STABILIZATION_MODE_ON , // HIDL v3.2 +} camera_metadata_enum_android_lens_optical_stabilization_mode_t; + +// ANDROID_LENS_FACING +typedef enum camera_metadata_enum_android_lens_facing { + ANDROID_LENS_FACING_FRONT , // HIDL v3.2 + ANDROID_LENS_FACING_BACK , // HIDL v3.2 + ANDROID_LENS_FACING_EXTERNAL , // HIDL v3.2 +} camera_metadata_enum_android_lens_facing_t; + +// ANDROID_LENS_STATE +typedef enum camera_metadata_enum_android_lens_state { + ANDROID_LENS_STATE_STATIONARY , // HIDL v3.2 + ANDROID_LENS_STATE_MOVING , // HIDL v3.2 +} camera_metadata_enum_android_lens_state_t; + +// ANDROID_LENS_POSE_REFERENCE +typedef enum camera_metadata_enum_android_lens_pose_reference { + ANDROID_LENS_POSE_REFERENCE_PRIMARY_CAMERA , // HIDL v3.3 + ANDROID_LENS_POSE_REFERENCE_GYROSCOPE , // HIDL v3.3 +} camera_metadata_enum_android_lens_pose_reference_t; + + +// ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION +typedef enum camera_metadata_enum_android_lens_info_focus_distance_calibration { + ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED , // HIDL v3.2 + ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE , // HIDL v3.2 + ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED , // HIDL v3.2 +} camera_metadata_enum_android_lens_info_focus_distance_calibration_t; + + +// ANDROID_NOISE_REDUCTION_MODE +typedef enum camera_metadata_enum_android_noise_reduction_mode { + ANDROID_NOISE_REDUCTION_MODE_OFF , // HIDL v3.2 + ANDROID_NOISE_REDUCTION_MODE_FAST , // HIDL v3.2 + ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY , // HIDL v3.2 + ANDROID_NOISE_REDUCTION_MODE_MINIMAL , // HIDL v3.2 + ANDROID_NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG , // HIDL v3.2 +} camera_metadata_enum_android_noise_reduction_mode_t; + + +// ANDROID_QUIRKS_PARTIAL_RESULT +typedef enum camera_metadata_enum_android_quirks_partial_result { + ANDROID_QUIRKS_PARTIAL_RESULT_FINAL , // HIDL v3.2 + ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL , // HIDL v3.2 +} camera_metadata_enum_android_quirks_partial_result_t; + + +// ANDROID_REQUEST_METADATA_MODE +typedef enum camera_metadata_enum_android_request_metadata_mode { + ANDROID_REQUEST_METADATA_MODE_NONE , // HIDL v3.2 + ANDROID_REQUEST_METADATA_MODE_FULL , // HIDL v3.2 +} camera_metadata_enum_android_request_metadata_mode_t; + +// ANDROID_REQUEST_TYPE +typedef enum camera_metadata_enum_android_request_type { + ANDROID_REQUEST_TYPE_CAPTURE , // HIDL v3.2 + ANDROID_REQUEST_TYPE_REPROCESS , // HIDL v3.2 +} camera_metadata_enum_android_request_type_t; + +// ANDROID_REQUEST_AVAILABLE_CAPABILITIES +typedef enum camera_metadata_enum_android_request_available_capabilities { + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO + , // HIDL v3.2 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING , // HIDL v3.3 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA , // HIDL v3.3 + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME , // HIDL v3.3 +} camera_metadata_enum_android_request_available_capabilities_t; + + +// ANDROID_SCALER_AVAILABLE_FORMATS +typedef enum camera_metadata_enum_android_scaler_available_formats { + ANDROID_SCALER_AVAILABLE_FORMATS_RAW16 = 0x20, // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_FORMATS_RAW_OPAQUE = 0x24, // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_FORMATS_YV12 = 0x32315659, // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_FORMATS_YCrCb_420_SP = 0x11, // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED = 0x22, // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888 = 0x23, // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_FORMATS_BLOB = 0x21, // HIDL v3.2 +} camera_metadata_enum_android_scaler_available_formats_t; + +// ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS +typedef enum camera_metadata_enum_android_scaler_available_stream_configurations { + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT , // HIDL v3.2 + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT , // HIDL v3.2 +} camera_metadata_enum_android_scaler_available_stream_configurations_t; + +// ANDROID_SCALER_CROPPING_TYPE +typedef enum camera_metadata_enum_android_scaler_cropping_type { + ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY , // HIDL v3.2 + ANDROID_SCALER_CROPPING_TYPE_FREEFORM , // HIDL v3.2 +} camera_metadata_enum_android_scaler_cropping_type_t; + + +// ANDROID_SENSOR_REFERENCE_ILLUMINANT1 +typedef enum camera_metadata_enum_android_sensor_reference_illuminant1 { + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT = 1, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLUORESCENT = 2, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_TUNGSTEN = 3, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLASH = 4, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FINE_WEATHER = 9, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_CLOUDY_WEATHER = 10, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_SHADE = 11, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT_FLUORESCENT = 12, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAY_WHITE_FLUORESCENT = 13, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_COOL_WHITE_FLUORESCENT = 14, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_WHITE_FLUORESCENT = 15, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_A = 17, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_B = 18, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_C = 19, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D55 = 20, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D65 = 21, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D75 = 22, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D50 = 23, // HIDL v3.2 + ANDROID_SENSOR_REFERENCE_ILLUMINANT1_ISO_STUDIO_TUNGSTEN = 24, // HIDL v3.2 +} camera_metadata_enum_android_sensor_reference_illuminant1_t; + +// ANDROID_SENSOR_TEST_PATTERN_MODE +typedef enum camera_metadata_enum_android_sensor_test_pattern_mode { + ANDROID_SENSOR_TEST_PATTERN_MODE_OFF , // HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR , // HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS , // HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY , // HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_MODE_PN9 , // HIDL v3.2 + ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1 = 256, // HIDL v3.2 +} camera_metadata_enum_android_sensor_test_pattern_mode_t; + + +// ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT +typedef enum camera_metadata_enum_android_sensor_info_color_filter_arrangement { + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB , // HIDL v3.2 + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG , // HIDL v3.2 + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GBRG , // HIDL v3.2 + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_BGGR , // HIDL v3.2 + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGB , // HIDL v3.2 +} camera_metadata_enum_android_sensor_info_color_filter_arrangement_t; + +// ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE +typedef enum camera_metadata_enum_android_sensor_info_timestamp_source { + ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN , // HIDL v3.2 + ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME , // HIDL v3.2 +} camera_metadata_enum_android_sensor_info_timestamp_source_t; + +// ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED +typedef enum camera_metadata_enum_android_sensor_info_lens_shading_applied { + ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED_FALSE , // HIDL v3.2 + ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED_TRUE , // HIDL v3.2 +} camera_metadata_enum_android_sensor_info_lens_shading_applied_t; + + +// ANDROID_SHADING_MODE +typedef enum camera_metadata_enum_android_shading_mode { + ANDROID_SHADING_MODE_OFF , // HIDL v3.2 + ANDROID_SHADING_MODE_FAST , // HIDL v3.2 + ANDROID_SHADING_MODE_HIGH_QUALITY , // HIDL v3.2 +} camera_metadata_enum_android_shading_mode_t; + + +// ANDROID_STATISTICS_FACE_DETECT_MODE +typedef enum camera_metadata_enum_android_statistics_face_detect_mode { + ANDROID_STATISTICS_FACE_DETECT_MODE_OFF , // HIDL v3.2 + ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE , // HIDL v3.2 + ANDROID_STATISTICS_FACE_DETECT_MODE_FULL , // HIDL v3.2 +} camera_metadata_enum_android_statistics_face_detect_mode_t; + +// ANDROID_STATISTICS_HISTOGRAM_MODE +typedef enum camera_metadata_enum_android_statistics_histogram_mode { + ANDROID_STATISTICS_HISTOGRAM_MODE_OFF , // HIDL v3.2 + ANDROID_STATISTICS_HISTOGRAM_MODE_ON , // HIDL v3.2 +} camera_metadata_enum_android_statistics_histogram_mode_t; + +// ANDROID_STATISTICS_SHARPNESS_MAP_MODE +typedef enum camera_metadata_enum_android_statistics_sharpness_map_mode { + ANDROID_STATISTICS_SHARPNESS_MAP_MODE_OFF , // HIDL v3.2 + ANDROID_STATISTICS_SHARPNESS_MAP_MODE_ON , // HIDL v3.2 +} camera_metadata_enum_android_statistics_sharpness_map_mode_t; + +// ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE +typedef enum camera_metadata_enum_android_statistics_hot_pixel_map_mode { + ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF , // HIDL v3.2 + ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_ON , // HIDL v3.2 +} camera_metadata_enum_android_statistics_hot_pixel_map_mode_t; + +// ANDROID_STATISTICS_SCENE_FLICKER +typedef enum camera_metadata_enum_android_statistics_scene_flicker { + ANDROID_STATISTICS_SCENE_FLICKER_NONE , // HIDL v3.2 + ANDROID_STATISTICS_SCENE_FLICKER_50HZ , // HIDL v3.2 + ANDROID_STATISTICS_SCENE_FLICKER_60HZ , // HIDL v3.2 +} camera_metadata_enum_android_statistics_scene_flicker_t; + +// ANDROID_STATISTICS_LENS_SHADING_MAP_MODE +typedef enum camera_metadata_enum_android_statistics_lens_shading_map_mode { + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF , // HIDL v3.2 + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_ON , // HIDL v3.2 +} camera_metadata_enum_android_statistics_lens_shading_map_mode_t; + +// ANDROID_STATISTICS_OIS_DATA_MODE +typedef enum camera_metadata_enum_android_statistics_ois_data_mode { + ANDROID_STATISTICS_OIS_DATA_MODE_OFF , // HIDL v3.3 + ANDROID_STATISTICS_OIS_DATA_MODE_ON , // HIDL v3.3 +} camera_metadata_enum_android_statistics_ois_data_mode_t; + + + +// ANDROID_TONEMAP_MODE +typedef enum camera_metadata_enum_android_tonemap_mode { + ANDROID_TONEMAP_MODE_CONTRAST_CURVE , // HIDL v3.2 + ANDROID_TONEMAP_MODE_FAST , // HIDL v3.2 + ANDROID_TONEMAP_MODE_HIGH_QUALITY , // HIDL v3.2 + ANDROID_TONEMAP_MODE_GAMMA_VALUE , // HIDL v3.2 + ANDROID_TONEMAP_MODE_PRESET_CURVE , // HIDL v3.2 +} camera_metadata_enum_android_tonemap_mode_t; + +// ANDROID_TONEMAP_PRESET_CURVE +typedef enum camera_metadata_enum_android_tonemap_preset_curve { + ANDROID_TONEMAP_PRESET_CURVE_SRGB , // HIDL v3.2 + ANDROID_TONEMAP_PRESET_CURVE_REC709 , // HIDL v3.2 +} camera_metadata_enum_android_tonemap_preset_curve_t; + + +// ANDROID_LED_TRANSMIT +typedef enum camera_metadata_enum_android_led_transmit { + ANDROID_LED_TRANSMIT_OFF , // HIDL v3.2 + ANDROID_LED_TRANSMIT_ON , // HIDL v3.2 +} camera_metadata_enum_android_led_transmit_t; + +// ANDROID_LED_AVAILABLE_LEDS +typedef enum camera_metadata_enum_android_led_available_leds { + ANDROID_LED_AVAILABLE_LEDS_TRANSMIT , // HIDL v3.2 +} camera_metadata_enum_android_led_available_leds_t; + + +// ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL +typedef enum camera_metadata_enum_android_info_supported_hardware_level { + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED , // HIDL v3.2 + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL , // HIDL v3.2 + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY , // HIDL v3.2 + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3 , // HIDL v3.2 + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL , // HIDL v3.3 +} camera_metadata_enum_android_info_supported_hardware_level_t; + + +// ANDROID_BLACK_LEVEL_LOCK +typedef enum camera_metadata_enum_android_black_level_lock { + ANDROID_BLACK_LEVEL_LOCK_OFF , // HIDL v3.2 + ANDROID_BLACK_LEVEL_LOCK_ON , // HIDL v3.2 +} camera_metadata_enum_android_black_level_lock_t; + + +// ANDROID_SYNC_FRAME_NUMBER +typedef enum camera_metadata_enum_android_sync_frame_number { + ANDROID_SYNC_FRAME_NUMBER_CONVERGING = -1, // HIDL v3.2 + ANDROID_SYNC_FRAME_NUMBER_UNKNOWN = -2, // HIDL v3.2 +} camera_metadata_enum_android_sync_frame_number_t; + +// ANDROID_SYNC_MAX_LATENCY +typedef enum camera_metadata_enum_android_sync_max_latency { + ANDROID_SYNC_MAX_LATENCY_PER_FRAME_CONTROL = 0, // HIDL v3.2 + ANDROID_SYNC_MAX_LATENCY_UNKNOWN = -1, // HIDL v3.2 +} camera_metadata_enum_android_sync_max_latency_t; + + + +// ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS +typedef enum camera_metadata_enum_android_depth_available_depth_stream_configurations { + ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT , // HIDL v3.2 + ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_INPUT , // HIDL v3.2 +} camera_metadata_enum_android_depth_available_depth_stream_configurations_t; + +// ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE +typedef enum camera_metadata_enum_android_depth_depth_is_exclusive { + ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_FALSE , // HIDL v3.2 + ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_TRUE , // HIDL v3.2 +} camera_metadata_enum_android_depth_depth_is_exclusive_t; + + +// ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE +typedef enum camera_metadata_enum_android_logical_multi_camera_sensor_sync_type { + ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_APPROXIMATE , // HIDL v3.3 + ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_CALIBRATED , // HIDL v3.3 +} camera_metadata_enum_android_logical_multi_camera_sensor_sync_type_t; + + +// ANDROID_DISTORTION_CORRECTION_MODE +typedef enum camera_metadata_enum_android_distortion_correction_mode { + ANDROID_DISTORTION_CORRECTION_MODE_OFF , // HIDL v3.3 + ANDROID_DISTORTION_CORRECTION_MODE_FAST , // HIDL v3.3 + ANDROID_DISTORTION_CORRECTION_MODE_HIGH_QUALITY , // HIDL v3.3 +} camera_metadata_enum_android_distortion_correction_mode_t; + + diff --git a/include/android/metadata/system/camera_vendor_tags.h b/include/android/metadata/system/camera_vendor_tags.h new file mode 100644 index 000000000000..0bb542608c91 --- /dev/null +++ b/include/android/metadata/system/camera_vendor_tags.h @@ -0,0 +1,158 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_VENDOR_TAGS_H +#define SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_VENDOR_TAGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define CAMERA_METADATA_VENDOR_TAG_BOUNDARY 0x80000000u +#define CAMERA_METADATA_INVALID_VENDOR_ID UINT64_MAX + +typedef uint64_t metadata_vendor_id_t; + +/** + * Vendor tags: + * + * This structure contains basic functions for enumerating an immutable set of + * vendor-defined camera metadata tags, and querying static information about + * their structure/type. The intended use of this information is to validate + * the structure of metadata returned by the camera HAL, and to allow vendor- + * defined metadata tags to be visible in application facing camera API. + */ +typedef struct vendor_tag_ops vendor_tag_ops_t; +struct vendor_tag_ops { + /** + * Get the number of vendor tags supported on this platform. Used to + * calculate the size of buffer needed for holding the array of all tags + * returned by get_all_tags(). This must return -1 on error. + */ + int (*get_tag_count)(const vendor_tag_ops_t *v); + + /** + * Fill an array with all of the supported vendor tags on this platform. + * get_tag_count() must return the number of tags supported, and + * tag_array will be allocated with enough space to hold the number of tags + * returned by get_tag_count(). + */ + void (*get_all_tags)(const vendor_tag_ops_t *v, uint32_t *tag_array); + + /** + * Get the vendor section name for a vendor-specified entry tag. This will + * only be called for vendor-defined tags. + * + * The naming convention for the vendor-specific section names should + * follow a style similar to the Java package style. For example, + * CameraZoom Inc. must prefix their sections with "com.camerazoom." + * This must return NULL if the tag is outside the bounds of + * vendor-defined sections. + * + * There may be different vendor-defined tag sections, for example the + * phone maker, the chipset maker, and the camera module maker may each + * have their own "com.vendor."-prefixed section. + * + * The memory pointed to by the return value must remain valid for the + * lifetime of the module, and is owned by the module. + */ + const char *(*get_section_name)(const vendor_tag_ops_t *v, uint32_t tag); + + /** + * Get the tag name for a vendor-specified entry tag. This is only called + * for vendor-defined tags, and must return NULL if it is not a + * vendor-defined tag. + * + * The memory pointed to by the return value must remain valid for the + * lifetime of the module, and is owned by the module. + */ + const char *(*get_tag_name)(const vendor_tag_ops_t *v, uint32_t tag); + + /** + * Get tag type for a vendor-specified entry tag. The type returned must be + * a valid type defined in camera_metadata.h. This method is only called + * for tags >= CAMERA_METADATA_VENDOR_TAG_BOUNDARY, and must return + * -1 if the tag is outside the bounds of the vendor-defined sections. + */ + int (*get_tag_type)(const vendor_tag_ops_t *v, uint32_t tag); + + /* Reserved for future use. These must be initialized to NULL. */ + void* reserved[8]; +}; + +struct vendor_tag_cache_ops { + /** + * Get the number of vendor tags supported on this platform. Used to + * calculate the size of buffer needed for holding the array of all tags + * returned by get_all_tags(). This must return -1 on error. + */ + int (*get_tag_count)(metadata_vendor_id_t id); + + /** + * Fill an array with all of the supported vendor tags on this platform. + * get_tag_count() must return the number of tags supported, and + * tag_array will be allocated with enough space to hold the number of tags + * returned by get_tag_count(). + */ + void (*get_all_tags)(uint32_t *tag_array, metadata_vendor_id_t id); + + /** + * Get the vendor section name for a vendor-specified entry tag. This will + * only be called for vendor-defined tags. + * + * The naming convention for the vendor-specific section names should + * follow a style similar to the Java package style. For example, + * CameraZoom Inc. must prefix their sections with "com.camerazoom." + * This must return NULL if the tag is outside the bounds of + * vendor-defined sections. + * + * There may be different vendor-defined tag sections, for example the + * phone maker, the chipset maker, and the camera module maker may each + * have their own "com.vendor."-prefixed section. + * + * The memory pointed to by the return value must remain valid for the + * lifetime of the module, and is owned by the module. + */ + const char *(*get_section_name)(uint32_t tag, metadata_vendor_id_t id); + + /** + * Get the tag name for a vendor-specified entry tag. This is only called + * for vendor-defined tags, and must return NULL if it is not a + * vendor-defined tag. + * + * The memory pointed to by the return value must remain valid for the + * lifetime of the module, and is owned by the module. + */ + const char *(*get_tag_name)(uint32_t tag, metadata_vendor_id_t id); + + /** + * Get tag type for a vendor-specified entry tag. The type returned must be + * a valid type defined in camera_metadata.h. This method is only called + * for tags >= CAMERA_METADATA_VENDOR_TAG_BOUNDARY, and must return + * -1 if the tag is outside the bounds of the vendor-defined sections. + */ + int (*get_tag_type)(uint32_t tag, metadata_vendor_id_t id); + + /* Reserved for future use. These must be initialized to NULL. */ + void* reserved[8]; +}; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* SYSTEM_MEDIA_INCLUDE_ANDROID_CAMERA_VENDOR_TAGS_H */ + diff --git a/include/android/system/core/include/android/log.h b/include/android/system/core/include/android/log.h new file mode 100644 index 000000000000..1c171b7bf2b5 --- /dev/null +++ b/include/android/system/core/include/android/log.h @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ANDROID_LOG_H +#define _ANDROID_LOG_H + +/****************************************************************** + * + * IMPORTANT NOTICE: + * + * This file is part of Android's set of stable system headers + * exposed by the Android NDK (Native Development Kit) since + * platform release 1.5 + * + * Third-party source AND binary code relies on the definitions + * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. + * + * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) + * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS + * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY + * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES + */ + +/* + * Support routines to send messages to the Android in-kernel log buffer, + * which can later be accessed through the 'logcat' utility. + * + * Each log message must have + * - a priority + * - a log tag + * - some text + * + * The tag normally corresponds to the component that emits the log message, + * and should be reasonably small. + * + * Log message text may be truncated to less than an implementation-specific + * limit (e.g. 1023 characters max). + * + * Note that a newline character ("\n") will be appended automatically to your + * log message, if not already there. It is not possible to send several messages + * and have them appear on a single line in logcat. + * + * PLEASE USE LOGS WITH MODERATION: + * + * - Sending log messages eats CPU and slow down your application and the + * system. + * + * - The circular log buffer is pretty small (<64KB), sending many messages + * might push off other important log messages from the rest of the system. + * + * - In release builds, only send log messages to account for exceptional + * conditions. + * + * NOTE: These functions MUST be implemented by /system/lib/liblog.so + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Android log priority values, in ascending priority order. + */ +typedef enum android_LogPriority { + ANDROID_LOG_UNKNOWN = 0, + ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ + ANDROID_LOG_VERBOSE, + ANDROID_LOG_DEBUG, + ANDROID_LOG_INFO, + ANDROID_LOG_WARN, + ANDROID_LOG_ERROR, + ANDROID_LOG_FATAL, + ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ +} android_LogPriority; + +/* + * Send a simple string to the log. + */ +int __android_log_write(int prio, const char *tag, const char *text); + +/* + * Send a formatted string to the log, used like printf(fmt,...) + */ +int __android_log_print(int prio, const char *tag, const char *fmt, ...) +#if defined(__GNUC__) +#ifdef __USE_MINGW_ANSI_STDIO +#if __USE_MINGW_ANSI_STDIO + __attribute__ ((format(gnu_printf, 3, 4))) +#else + __attribute__ ((format(printf, 3, 4))) +#endif +#else + __attribute__ ((format(printf, 3, 4))) +#endif +#endif + ; + +/* + * A variant of __android_log_print() that takes a va_list to list + * additional parameters. + */ +int __android_log_vprint(int prio, const char *tag, + const char *fmt, va_list ap); + +/* + * Log an assertion failure and abort the process to have a chance + * to inspect it if a debugger is attached. This uses the FATAL priority. + */ +void __android_log_assert(const char *cond, const char *tag, + const char *fmt, ...) +#if defined(__GNUC__) + __attribute__ ((noreturn)) +#ifdef __USE_MINGW_ANSI_STDIO +#if __USE_MINGW_ANSI_STDIO + __attribute__ ((format(gnu_printf, 3, 4))) +#else + __attribute__ ((format(printf, 3, 4))) +#endif +#else + __attribute__ ((format(printf, 3, 4))) +#endif +#endif + ; + +#ifdef __cplusplus +} +#endif + +#endif /* _ANDROID_LOG_H */ diff --git a/include/android/system/core/include/cutils/compiler.h b/include/android/system/core/include/cutils/compiler.h new file mode 100644 index 000000000000..70f884a1e701 --- /dev/null +++ b/include/android/system/core/include/cutils/compiler.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_CUTILS_COMPILER_H +#define ANDROID_CUTILS_COMPILER_H + +/* + * helps the compiler's optimizer predicting branches + */ + +#ifdef __cplusplus +# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) +# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) +#else +# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) +# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) +#endif + +/** + * exports marked symbols + * + * if used on a C++ class declaration, this macro must be inserted + * after the "class" keyword. For instance: + * + * template + * class ANDROID_API Singleton { } + */ + +#define ANDROID_API __attribute__((visibility("default"))) + +#endif // ANDROID_CUTILS_COMPILER_H diff --git a/include/android/system/core/include/cutils/native_handle.h b/include/android/system/core/include/cutils/native_handle.h new file mode 100644 index 000000000000..268c5d3f51b7 --- /dev/null +++ b/include/android/system/core/include/cutils/native_handle.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_HANDLE_H_ +#define NATIVE_HANDLE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct native_handle +{ + int version; /* sizeof(native_handle_t) */ + int numFds; /* number of file-descriptors at &data[0] */ + int numInts; /* number of ints at &data[numFds] */ + int data[0]; /* numFds + numInts ints */ +} native_handle_t; + +/* + * native_handle_close + * + * closes the file descriptors contained in this native_handle_t + * + * return 0 on success, or a negative error code on failure + * + */ +int native_handle_close(const native_handle_t* h); + + +/* + * native_handle_create + * + * creates a native_handle_t and initializes it. must be destroyed with + * native_handle_delete(). + * + */ +native_handle_t* native_handle_create(int numFds, int numInts); + +/* + * native_handle_delete + * + * frees a native_handle_t allocated with native_handle_create(). + * This ONLY frees the memory allocated for the native_handle_t, but doesn't + * close the file descriptors; which can be achieved with native_handle_close(). + * + * return 0 on success, or a negative error code on failure + * + */ +int native_handle_delete(native_handle_t* h); + + +#ifdef __cplusplus +} +#endif + +#endif /* NATIVE_HANDLE_H_ */ diff --git a/include/android/system/core/include/system/camera.h b/include/android/system/core/include/system/camera.h new file mode 100644 index 000000000000..5d0873ac42a6 --- /dev/null +++ b/include/android/system/core/include/system/camera.h @@ -0,0 +1,298 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H +#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H + +#include +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/** + * A set of bit masks for specifying how the received preview frames are + * handled before the previewCallback() call. + * + * The least significant 3 bits of an "int" value are used for this purpose: + * + * ..... 0 0 0 + * ^ ^ ^ + * | | |---------> determine whether the callback is enabled or not + * | |-----------> determine whether the callback is one-shot or not + * |-------------> determine whether the frame is copied out or not + * + * WARNING: When a frame is sent directly without copying, it is the frame + * receiver's responsiblity to make sure that the frame data won't get + * corrupted by subsequent preview frames filled by the camera. This flag is + * recommended only when copying out data brings significant performance price + * and the handling/processing of the received frame data is always faster than + * the preview frame rate so that data corruption won't occur. + * + * For instance, + * 1. 0x00 disables the callback. In this case, copy out and one shot bits + * are ignored. + * 2. 0x01 enables a callback without copying out the received frames. A + * typical use case is the Camcorder application to avoid making costly + * frame copies. + * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical + * use case is the Camera application. + * 4. 0x07 is enabling a callback with frame copied out only once. A typical + * use case is the Barcode scanner application. + */ + +enum { + CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, + CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, + CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, + /** Typical use cases */ + CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, + CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, + CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, + CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 +}; + +/** msgType in notifyCallback and dataCallback functions */ +enum { + CAMERA_MSG_ERROR = 0x0001, // notifyCallback + CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback + CAMERA_MSG_FOCUS = 0x0004, // notifyCallback + CAMERA_MSG_ZOOM = 0x0008, // notifyCallback + CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback + CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback + CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback + CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback + CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback + CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback + // Preview frame metadata. This can be combined with + // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can + // request FRAME and METADATA. Or the apps can request only FRAME or only + // METADATA. + CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback + // Notify on autofocus start and stop. This is useful in continuous + // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. + CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback + CAMERA_MSG_ALL_MSGS = 0xFFFF +}; + +/** cmdType in sendCommand functions */ +enum { + CAMERA_CMD_START_SMOOTH_ZOOM = 1, + CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, + + /** + * Set the clockwise rotation of preview display (setPreviewDisplay) in + * degrees. This affects the preview frames and the picture displayed after + * snapshot. This method is useful for portrait mode applications. Note + * that preview display of front-facing cameras is flipped horizontally + * before the rotation, that is, the image is reflected along the central + * vertical axis of the camera sensor. So the users can see themselves as + * looking into a mirror. + * + * This does not affect the order of byte array of + * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, + * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or + * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview + * since API level 14. + */ + CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, + + /** + * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = + * 0 will disable, while passing arg1 = 1 will enable the shutter sound. + */ + CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, + + /* cmdType to play recording sound */ + CAMERA_CMD_PLAY_RECORDING_SOUND = 5, + + /** + * Start the face detection. This should be called after preview is started. + * The camera will notify the listener of CAMERA_MSG_FACE and the detected + * faces in the preview frame. The detected faces may be the same as the + * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop + * the face detection. This method is supported if CameraParameters + * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is + * bigger than 0. Hardware and software face detection should not be running + * at the same time. If the face detection has started, apps should not send + * this again. + * + * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, + * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. + * + * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or + * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not + * supported, the HAL must return BAD_VALUE. + */ + CAMERA_CMD_START_FACE_DETECTION = 6, + + /** + * Stop the face detection. + */ + CAMERA_CMD_STOP_FACE_DETECTION = 7, + + /** + * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing + * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. + */ + CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, + + /** + * Ping camera service to see if camera hardware is released. + * + * When any camera method returns error, the client can use ping command + * to see if the camera has been taken away by other clients. If the result + * is NO_ERROR, it means the camera hardware is not released. If the result + * is not NO_ERROR, the camera has been released and the existing client + * can silently finish itself or show a dialog. + */ + CAMERA_CMD_PING = 9, + + /** + * Configure the number of video buffers used for recording. The intended + * video buffer count for recording is passed as arg1, which must be + * greater than 0. This command must be sent before recording is started. + * This command returns INVALID_OPERATION error if it is sent after video + * recording is started, or the command is not supported at all. This + * command also returns a BAD_VALUE error if the intended video buffer + * count is non-positive or too big to be realized. + */ + CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, + + /** + * Configure an explicit format to use for video recording metadata mode. + * This can be used to switch the format from the + * default IMPLEMENTATION_DEFINED gralloc format to some other + * device-supported format, and the default dataspace from the BT_709 color + * space to some other device-supported dataspace. arg1 is the HAL pixel + * format, and arg2 is the HAL dataSpace. This command returns + * INVALID_OPERATION error if it is sent after video recording is started, + * or the command is not supported at all. + * + * If the gralloc format is set to a format other than + * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags + * of SW_READ_OFTEN. + */ + CAMERA_CMD_SET_VIDEO_FORMAT = 11 +}; + +/** camera fatal errors */ +enum { + CAMERA_ERROR_UNKNOWN = 1, + /** + * Camera was released because another client has connected to the camera. + * The original client should call Camera::disconnect immediately after + * getting this notification. Otherwise, the camera will be released by + * camera service in a short time. The client should not call any method + * (except disconnect and sending CAMERA_CMD_PING) after getting this. + */ + CAMERA_ERROR_RELEASED = 2, + CAMERA_ERROR_SERVER_DIED = 100 +}; + +enum { + /** The facing of the camera is opposite to that of the screen. */ + CAMERA_FACING_BACK = 0, + /** The facing of the camera is the same as that of the screen. */ + CAMERA_FACING_FRONT = 1, + /** + * The facing of the camera is not fixed relative to the screen. + * The cameras with this facing are external cameras, e.g. USB cameras. + */ + CAMERA_FACING_EXTERNAL = 2 +}; + +enum { + /** Hardware face detection. It does not use much CPU. */ + CAMERA_FACE_DETECTION_HW = 0, + /** + * Software face detection. It uses some CPU. Applications must use + * Camera.setPreviewTexture for preview in this mode. + */ + CAMERA_FACE_DETECTION_SW = 1 +}; + +/** + * The information of a face from camera face detection. + */ +typedef struct camera_face { + /** + * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents + * the top-left of the camera field of view, and (1000, 1000) represents the + * bottom-right of the field of view. The width and height cannot be 0 or + * negative. This is supported by both hardware and software face detection. + * + * The direction is relative to the sensor orientation, that is, what the + * sensor sees. The direction is not affected by the rotation or mirroring + * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. + */ + int32_t rect[4]; + + /** + * The confidence level of the face. The range is 1 to 100. 100 is the + * highest confidence. This is supported by both hardware and software + * face detection. + */ + int32_t score; + + /** + * An unique id per face while the face is visible to the tracker. If + * the face leaves the field-of-view and comes back, it will get a new + * id. If the value is 0, id is not supported. + */ + int32_t id; + + /** + * The coordinates of the center of the left eye. The range is -1000 to + * 1000. -2000, -2000 if this is not supported. + */ + int32_t left_eye[2]; + + /** + * The coordinates of the center of the right eye. The range is -1000 to + * 1000. -2000, -2000 if this is not supported. + */ + int32_t right_eye[2]; + + /** + * The coordinates of the center of the mouth. The range is -1000 to 1000. + * -2000, -2000 if this is not supported. + */ + int32_t mouth[2]; + +} camera_face_t; + +/** + * The metadata of the frame data. + */ +typedef struct camera_frame_metadata { + /** + * The number of detected faces in the frame. + */ + int32_t number_of_faces; + + /** + * An array of the detected faces. The length is number_of_faces. + */ + camera_face_t *faces; +} camera_frame_metadata_t; + +__END_DECLS + +#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ diff --git a/include/android/system/core/include/system/graphics.h b/include/android/system/core/include/system/graphics.h new file mode 100644 index 000000000000..afd9f7bdb32f --- /dev/null +++ b/include/android/system/core/include/system/graphics.h @@ -0,0 +1,763 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H +#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * If the HAL needs to create service threads to handle graphics related + * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority + * if they can block the main rendering thread in any way. + * + * the priority of the current thread can be set with: + * + * #include + * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); + * + */ + +#define HAL_PRIORITY_URGENT_DISPLAY (-8) + +/** + * pixel format definitions + */ + +enum { + /* + * "linear" color pixel formats: + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. + * + * The color space determines, for example, if the formats are linear or + * gamma-corrected; or whether any special operations are performed when + * reading or writing into a buffer in one of these formats. + */ + HAL_PIXEL_FORMAT_RGBA_8888 = 1, + HAL_PIXEL_FORMAT_RGBX_8888 = 2, + HAL_PIXEL_FORMAT_RGB_888 = 3, + HAL_PIXEL_FORMAT_RGB_565 = 4, + HAL_PIXEL_FORMAT_BGRA_8888 = 5, + + /* + * 0x100 - 0x1FF + * + * This range is reserved for pixel formats that are specific to the HAL + * implementation. Implementations can use any value in this range to + * communicate video pixel formats between their HAL modules. These formats + * must not have an alpha channel. Additionally, an EGLimage created from a + * gralloc buffer of one of these formats must be supported for use with the + * GL_OES_EGL_image_external OpenGL ES extension. + */ + + /* + * Android YUV format: + * + * This format is exposed outside of the HAL to software decoders and + * applications. EGLImageKHR must support it in conjunction with the + * OES_EGL_image_external extension. + * + * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed + * by (W/2) x (H/2) Cr and Cb planes. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * + * y_size = stride * height + * c_stride = ALIGN(stride/2, 16) + * c_size = c_stride * height/2 + * size = y_size + c_size * 2 + * cr_offset = y_size + * cb_offset = y_size + c_size + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. + */ + HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar + + + /* + * Android Y8 format: + * + * This format is exposed outside of the HAL to the framework. + * The expected gralloc usage flags are SW_* and HW_CAMERA_*, + * and no other HW_ flags will be used. + * + * Y8 is a YUV planar format comprised of a WxH Y plane, + * with each pixel being represented by 8 bits. + * + * It is equivalent to just the Y plane from YV12. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * + * size = stride * height + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. + */ + HAL_PIXEL_FORMAT_Y8 = 0x20203859, + + /* + * Android Y16 format: + * + * This format is exposed outside of the HAL to the framework. + * The expected gralloc usage flags are SW_* and HW_CAMERA_*, + * and no other HW_ flags will be used. + * + * Y16 is a YUV planar format comprised of a WxH Y plane, + * with each pixel being represented by 16 bits. + * + * It is just like Y8, but has double the bits per pixel (little endian). + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * - strides are specified in pixels, not in bytes + * + * size = stride * height * 2 + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer, except that dataSpace field + * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth + * image where each sample is a distance value measured by a depth camera, + * plus an associated confidence value. + */ + HAL_PIXEL_FORMAT_Y16 = 0x20363159, + + /* + * Android RAW sensor format: + * + * This format is exposed outside of the camera HAL to applications. + * + * RAW16 is a single-channel, 16-bit, little endian format, typically + * representing raw Bayer-pattern images from an image sensor, with minimal + * processing. + * + * The exact pixel layout of the data in the buffer is sensor-dependent, and + * needs to be queried from the camera device. + * + * Generally, not all 16 bits are used; more common values are 10 or 12 + * bits. If not all bits are used, the lower-order bits are filled first. + * All parameters to interpret the raw data (black and white points, + * color space, etc) must be queried from the camera device. + * + * This format assumes + * - an even width + * - an even height + * - a horizontal stride multiple of 16 pixels + * - a vertical stride equal to the height + * - strides are specified in pixels, not in bytes + * + * size = stride * height * 2 + * + * This format must be accepted by the gralloc module when used with the + * following usage flags: + * - GRALLOC_USAGE_HW_CAMERA_* + * - GRALLOC_USAGE_SW_* + * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. + */ + HAL_PIXEL_FORMAT_RAW16 = 0x20, + + /* + * Android RAW10 format: + * + * This format is exposed outside of the camera HAL to applications. + * + * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, + * unprocessed format, usually representing raw Bayer-pattern images coming from + * an image sensor. + * + * In an image buffer with this format, starting from the first pixel of each + * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one + * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte + * contains the 2 least significant bits of the 4 pixels, the exact layout data + * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth + * bit of the ith pixel): + * + * bit 7 bit 0 + * =====|=====|=====|=====|=====|=====|=====|=====| + * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| + * |-----|-----|-----|-----|-----|-----|-----|-----| + * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| + * =============================================== + * + * This format assumes + * - a width multiple of 4 pixels + * - an even height + * - a vertical stride equal to the height + * - strides are specified in bytes, not in pixels + * + * size = stride * height + * + * When stride is equal to width * (10 / 8), there will be no padding bytes at + * the end of each row, the entire image data is densely packed. When stride is + * larger than width * (10 / 8), padding bytes will be present at the end of each + * row (including the last row). + * + * This format must be accepted by the gralloc module when used with the + * following usage flags: + * - GRALLOC_USAGE_HW_CAMERA_* + * - GRALLOC_USAGE_SW_* + * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace field should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. + */ + HAL_PIXEL_FORMAT_RAW10 = 0x25, + + /* + * Android RAW12 format: + * + * This format is exposed outside of camera HAL to applications. + * + * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, + * unprocessed format, usually representing raw Bayer-pattern images coming from + * an image sensor. + * + * In an image buffer with this format, starting from the first pixel of each + * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first + * and second byte contains the top 8 bits of first and second pixel. The third + * byte contains the 4 least significant bits of the two pixels, the exact layout + * data for each two consecutive pixels is illustrated below (Pi[j] stands for + * the jth bit of the ith pixel): + * + * bit 7 bit 0 + * ======|======|======|======|======|======|======|======| + * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| + * |------|------|------|------|------|------|------|------| + * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| + * |------|------|------|------|------|------|------|------| + * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| + * ======================================================= + * + * This format assumes: + * - a width multiple of 4 pixels + * - an even height + * - a vertical stride equal to the height + * - strides are specified in bytes, not in pixels + * + * size = stride * height + * + * When stride is equal to width * (12 / 8), there will be no padding bytes at + * the end of each row, the entire image data is densely packed. When stride is + * larger than width * (12 / 8), padding bytes will be present at the end of + * each row (including the last row). + * + * This format must be accepted by the gralloc module when used with the + * following usage flags: + * - GRALLOC_USAGE_HW_CAMERA_* + * - GRALLOC_USAGE_SW_* + * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace field should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. + */ + HAL_PIXEL_FORMAT_RAW12 = 0x26, + + /* + * Android opaque RAW format: + * + * This format is exposed outside of the camera HAL to applications. + * + * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an + * image sensor. The actual structure of buffers of this format is + * implementation-dependent. + * + * This format must be accepted by the gralloc module when used with the + * following usage flags: + * - GRALLOC_USAGE_HW_CAMERA_* + * - GRALLOC_USAGE_SW_* + * - GRALLOC_USAGE_RENDERSCRIPT + * + * When used with ANativeWindow, the dataSpace field should be + * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial + * extra metadata to define. + */ + HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24, + + /* + * Android binary blob graphics buffer format: + * + * This format is used to carry task-specific data which does not have a + * standard image structure. The details of the format are left to the two + * endpoints. + * + * A typical use case is for transporting JPEG-compressed images from the + * Camera HAL to the framework or to applications. + * + * Buffers of this format must have a height of 1, and width equal to their + * size in bytes. + * + * When used with ANativeWindow, the mapping of the dataSpace field to + * buffer contents for BLOB is as follows: + * + * dataSpace value | Buffer contents + * -------------------------------+----------------------------------------- + * HAL_DATASPACE_JFIF | An encoded JPEG image + * HAL_DATASPACE_DEPTH | An android_depth_points buffer + * Other | Unsupported + * + */ + HAL_PIXEL_FORMAT_BLOB = 0x21, + + /* + * Android format indicating that the choice of format is entirely up to the + * device-specific Gralloc implementation. + * + * The Gralloc implementation should examine the usage bits passed in when + * allocating a buffer with this format, and it should derive the pixel + * format from those usage flags. This format will never be used with any + * of the GRALLOC_USAGE_SW_* usage flags. + * + * If a buffer of this format is to be used as an OpenGL ES texture, the + * framework will assume that sampling the texture will always return an + * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values). + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. + */ + HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, + + /* + * Android flexible YCbCr 4:2:0 formats + * + * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 + * buffer layout, while still describing the general format in a + * layout-independent manner. While called YCbCr, it can be + * used to describe formats with either chromatic ordering, as well as + * whole planar or semiplanar layouts. + * + * struct android_ycbcr (below) is the the struct used to describe it. + * + * This format must be accepted by the gralloc module when + * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set. + * + * This format is locked for use by gralloc's (*lock_ycbcr) method, and + * locking with the (*lock) method will return an error. + * + * When used with ANativeWindow, the dataSpace field describes the color + * space of the buffer. + */ + HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, + + /* + * Android flexible YCbCr 4:2:2 formats + * + * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2 + * buffer layout, while still describing the general format in a + * layout-independent manner. While called YCbCr, it can be + * used to describe formats with either chromatic ordering, as well as + * whole planar or semiplanar layouts. + * + * This format is currently only used by SW readable buffers + * produced by MediaCodecs, so the gralloc module can ignore this format. + */ + HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27, + + /* + * Android flexible YCbCr 4:4:4 formats + * + * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4 + * buffer layout, while still describing the general format in a + * layout-independent manner. While called YCbCr, it can be + * used to describe formats with either chromatic ordering, as well as + * whole planar or semiplanar layouts. + * + * This format is currently only used by SW readable buffers + * produced by MediaCodecs, so the gralloc module can ignore this format. + */ + HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28, + + /* + * Android flexible RGB 888 formats + * + * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX + * buffer layout, while still describing the general format in a + * layout-independent manner. While called RGB, it can be + * used to describe formats with either color ordering and optional + * padding, as well as whole planar layout. + * + * This format is currently only used by SW readable buffers + * produced by MediaCodecs, so the gralloc module can ignore this format. + */ + HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29, + + /* + * Android flexible RGBA 8888 formats + * + * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR + * buffer layout, while still describing the general format in a + * layout-independent manner. While called RGBA, it can be + * used to describe formats with any of the component orderings, as + * well as whole planar layout. + * + * This format is currently only used by SW readable buffers + * produced by MediaCodecs, so the gralloc module can ignore this format. + */ + HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A, + + /* Legacy formats (deprecated), used by ImageFormat.java */ + HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 + HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 + HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 +}; + +/* + * Structure for describing YCbCr formats for consumption by applications. + * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. + * + * Buffer chroma subsampling is defined in the format. + * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. + * + * Buffers must have a 8 bit depth. + * + * @y, @cb, and @cr point to the first byte of their respective planes. + * + * Stride describes the distance in bytes from the first value of one row of + * the image to the first value of the next row. It includes the width of the + * image plus padding. + * @ystride is the stride of the luma plane. + * @cstride is the stride of the chroma planes. + * + * @chroma_step is the distance in bytes from one chroma pixel value to the + * next. This is 2 bytes for semiplanar (because chroma values are interleaved + * and each chroma value is one byte) and 1 for planar. + */ + +struct android_ycbcr { + void *y; + void *cb; + void *cr; + size_t ystride; + size_t cstride; + size_t chroma_step; + + /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ + uint32_t reserved[8]; +}; + +/** + * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB + * with dataSpace value of HAL_DATASPACE_DEPTH. + * When locking a native buffer of the above format and dataSpace value, + * the vaddr pointer can be cast to this structure. + * + * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y, + * z) represents a measured point's position, with the coordinate system defined + * by the data source. Confidence represents the estimated likelihood that this + * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f == + * 100% confidence. + * + * @num_points is the number of points in the list + * + * @xyz_points is the flexible array of floating-point values. + * It contains (num_points) * 4 floats. + * + * For example: + * android_depth_points d = get_depth_buffer(); + * struct { + * float x; float y; float z; float confidence; + * } firstPoint, lastPoint; + * + * firstPoint.x = d.xyzc_points[0]; + * firstPoint.y = d.xyzc_points[1]; + * firstPoint.z = d.xyzc_points[2]; + * firstPoint.confidence = d.xyzc_points[3]; + * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0]; + * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1]; + * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2]; + * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3]; + */ + +struct android_depth_points { + uint32_t num_points; + + /** reserved for future use, set to 0 by gralloc's (*lock)() */ + uint32_t reserved[8]; + + float xyzc_points[]; +}; + +/** + * Transformation definitions + * + * IMPORTANT NOTE: + * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. + * + */ + +enum { + /* flip source image horizontally (around the vertical axis) */ + HAL_TRANSFORM_FLIP_H = 0x01, + /* flip source image vertically (around the horizontal axis)*/ + HAL_TRANSFORM_FLIP_V = 0x02, + /* rotate source image 90 degrees clockwise */ + HAL_TRANSFORM_ROT_90 = 0x04, + /* rotate source image 180 degrees */ + HAL_TRANSFORM_ROT_180 = 0x03, + /* rotate source image 270 degrees clockwise */ + HAL_TRANSFORM_ROT_270 = 0x07, + /* don't use. see system/window.h */ + HAL_TRANSFORM_RESERVED = 0x08, +}; + +/** + * Dataspace Definitions + * ====================== + * + * Dataspace is the definition of how pixel values should be interpreted. + * + * For many formats, this is the colorspace of the image data, which includes + * primaries (including white point) and the transfer characteristic function, + * which describes both gamma curve and numeric range (within the bit depth). + * + * Other dataspaces include depth measurement data from a depth camera. + */ + +typedef enum android_dataspace { + /* + * Default-assumption data space, when not explicitly specified. + * + * It is safest to assume the buffer is an image with sRGB primaries and + * encoding ranges, but the consumer and/or the producer of the data may + * simply be using defaults. No automatic gamma transform should be + * expected, except for a possible display gamma transform when drawn to a + * screen. + */ + HAL_DATASPACE_UNKNOWN = 0x0, + + /* + * Arbitrary dataspace with manually defined characteristics. Definition + * for colorspaces or other meaning must be communicated separately. + * + * This is used when specifying primaries, transfer characteristics, + * etc. separately. + * + * A typical use case is in video encoding parameters (e.g. for H.264), + * where a colorspace can have separately defined primaries, transfer + * characteristics, etc. + */ + HAL_DATASPACE_ARBITRARY = 0x1, + + /* + * RGB Colorspaces + * ----------------- + * + * Primaries are given using (x,y) coordinates in the CIE 1931 definition + * of x and y specified by ISO 11664-1. + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + */ + + /* + * sRGB linear encoding: + * + * The red, green, and blue components are stored in sRGB space, but + * are linear, not gamma-encoded. + * The RGB primaries and the white point are the same as BT.709. + * + * The values are encoded using the full range ([0,255] for 8-bit) for all + * components. + */ + HAL_DATASPACE_SRGB_LINEAR = 0x200, + + /* + * sRGB gamma encoding: + * + * The red, green and blue components are stored in sRGB space, and + * converted to linear space when read, using the standard sRGB to linear + * equation: + * + * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 + * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 + * + * When written the inverse transformation is performed: + * + * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 + * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 + * + * + * The alpha component, if present, is always stored in linear space and + * is left unmodified when read or written. + * + * The RGB primaries and the white point are the same as BT.709. + * + * The values are encoded using the full range ([0,255] for 8-bit) for all + * components. + * + */ + HAL_DATASPACE_SRGB = 0x201, + + /* + * YCbCr Colorspaces + * ----------------- + * + * Primaries are given using (x,y) coordinates in the CIE 1931 definition + * of x and y specified by ISO 11664-1. + * + * Transfer characteristics are the opto-electronic transfer characteristic + * at the source as a function of linear optical intensity (luminance). + */ + + /* + * JPEG File Interchange Format (JFIF) + * + * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 + * + * Transfer characteristic curve: + * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 + * E = 4.500 L, 0.018 > L >= 0 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + * + * Primaries: x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + */ + HAL_DATASPACE_JFIF = 0x101, + + /* + * ITU-R Recommendation 601 (BT.601) - 625-line + * + * Standard-definition television, 625 Lines (PAL) + * + * For 8-bit-depth formats: + * Luma (Y) samples should range from 16 to 235, inclusive + * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive + * + * For 10-bit-depth formats: + * Luma (Y) samples should range from 64 to 940, inclusive + * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive + * + * Transfer characteristic curve: + * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 + * E = 4.500 L, 0.018 > L >= 0 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + * + * Primaries: x y + * green 0.290 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + */ + HAL_DATASPACE_BT601_625 = 0x102, + + /* + * ITU-R Recommendation 601 (BT.601) - 525-line + * + * Standard-definition television, 525 Lines (NTSC) + * + * For 8-bit-depth formats: + * Luma (Y) samples should range from 16 to 235, inclusive + * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive + * + * For 10-bit-depth formats: + * Luma (Y) samples should range from 64 to 940, inclusive + * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive + * + * Transfer characteristic curve: + * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 + * E = 4.500 L, 0.018 > L >= 0 + * L - luminance of image 0 <= L <= 1 for conventional colorimetry + * E - corresponding electrical signal + * + * Primaries: x y + * green 0.310 0.595 + * blue 0.155 0.070 + * red 0.630 0.340 + * white (D65) 0.3127 0.3290 + */ + HAL_DATASPACE_BT601_525 = 0x103, + + /* + * ITU-R Recommendation 709 (BT.709) + * + * High-definition television + * + * For 8-bit-depth formats: + * Luma (Y) samples should range from 16 to 235, inclusive + * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive + * + * For 10-bit-depth formats: + * Luma (Y) samples should range from 64 to 940, inclusive + * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive + * + * Primaries: x y + * green 0.300 0.600 + * blue 0.150 0.060 + * red 0.640 0.330 + * white (D65) 0.3127 0.3290 + */ + HAL_DATASPACE_BT709 = 0x104, + + /* + * The buffer contains depth ranging measurements from a depth camera. + * This value is valid with formats: + * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement + * and an associated confidence value. The 3 MSBs of the sample make + * up the confidence value, and the low 13 LSBs of the sample make up + * the depth measurement. + * For the confidence section, 0 means 100% confidence, 1 means 0% + * confidence. The mapping to a linear float confidence value between + * 0.f and 1.f can be obtained with + * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; + * The depth measurement can be extracted simply with + * uint16_t range = (depthSample & 0x1FFF); + * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as + * a variable-length float (x,y,z, confidence) coordinate point list. + * The point cloud will be represented with the android_depth_points + * structure. + */ + HAL_DATASPACE_DEPTH = 0x1000 + +} android_dataspace_t; + +#ifdef __cplusplus +} +#endif + +#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ diff --git a/include/android/system/core/include/system/window.h b/include/android/system/core/include/system/window.h new file mode 100644 index 000000000000..508ce00bacec --- /dev/null +++ b/include/android/system/core/include/system/window.h @@ -0,0 +1,954 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H +#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __UNUSED +#define __UNUSED __attribute__((__unused__)) +#endif +#ifndef __deprecated +#define __deprecated __attribute__((__deprecated__)) +#endif + +__BEGIN_DECLS + +/*****************************************************************************/ + +#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ + (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d)) + +#define ANDROID_NATIVE_WINDOW_MAGIC \ + ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') + +#define ANDROID_NATIVE_BUFFER_MAGIC \ + ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') + +// --------------------------------------------------------------------------- + +// This #define may be used to conditionally compile device-specific code to +// support either the prior ANativeWindow interface, which did not pass libsync +// fences around, or the new interface that does. This #define is only present +// when the ANativeWindow interface does include libsync support. +#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 + +// --------------------------------------------------------------------------- + +typedef const native_handle_t* buffer_handle_t; + +// --------------------------------------------------------------------------- + +typedef struct android_native_rect_t +{ + int32_t left; + int32_t top; + int32_t right; + int32_t bottom; +} android_native_rect_t; + +// --------------------------------------------------------------------------- + +typedef struct android_native_base_t +{ + /* a magic value defined by the actual EGL native type */ + int magic; + + /* the sizeof() of the actual EGL native type */ + int version; + + void* reserved[4]; + + /* reference-counting interface */ + void (*incRef)(struct android_native_base_t* base); + void (*decRef)(struct android_native_base_t* base); +} android_native_base_t; + +typedef struct ANativeWindowBuffer +{ +#ifdef __cplusplus + ANativeWindowBuffer() { + common.magic = ANDROID_NATIVE_BUFFER_MAGIC; + common.version = sizeof(ANativeWindowBuffer); + memset(common.reserved, 0, sizeof(common.reserved)); + } + + // Implement the methods that sp expects so that it + // can be used to automatically refcount ANativeWindowBuffer's. + void incStrong(const void* /*id*/) const { + common.incRef(const_cast(&common)); + } + void decStrong(const void* /*id*/) const { + common.decRef(const_cast(&common)); + } +#endif + + struct android_native_base_t common; + + int width; + int height; + int stride; + int format; + int usage; + + void* reserved[2]; + + buffer_handle_t handle; + + void* reserved_proc[8]; +} ANativeWindowBuffer_t; + +// Old typedef for backwards compatibility. +typedef ANativeWindowBuffer_t android_native_buffer_t; + +// --------------------------------------------------------------------------- + +/* attributes queriable with query() */ +enum { + NATIVE_WINDOW_WIDTH = 0, + NATIVE_WINDOW_HEIGHT = 1, + NATIVE_WINDOW_FORMAT = 2, + + /* The minimum number of buffers that must remain un-dequeued after a buffer + * has been queued. This value applies only if set_buffer_count was used to + * override the number of buffers and if a buffer has since been queued. + * Users of the set_buffer_count ANativeWindow method should query this + * value before calling set_buffer_count. If it is necessary to have N + * buffers simultaneously dequeued as part of the steady-state operation, + * and this query returns M then N+M buffers should be requested via + * native_window_set_buffer_count. + * + * Note that this value does NOT apply until a single buffer has been + * queued. In particular this means that it is possible to: + * + * 1. Query M = min undequeued buffers + * 2. Set the buffer count to N + M + * 3. Dequeue all N + M buffers + * 4. Cancel M buffers + * 5. Queue, dequeue, queue, dequeue, ad infinitum + */ + NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, + + /* Check whether queueBuffer operations on the ANativeWindow send the buffer + * to the window compositor. The query sets the returned 'value' argument + * to 1 if the ANativeWindow DOES send queued buffers directly to the window + * compositor and 0 if the buffers do not go directly to the window + * compositor. + * + * This can be used to determine whether protected buffer content should be + * sent to the ANativeWindow. Note, however, that a result of 1 does NOT + * indicate that queued buffers will be protected from applications or users + * capturing their contents. If that behavior is desired then some other + * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in + * conjunction with this query. + */ + NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, + + /* Get the concrete type of a ANativeWindow. See below for the list of + * possible return values. + * + * This query should not be used outside the Android framework and will + * likely be removed in the near future. + */ + NATIVE_WINDOW_CONCRETE_TYPE = 5, + + + /* + * Default width and height of ANativeWindow buffers, these are the + * dimensions of the window buffers irrespective of the + * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window + * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. + */ + NATIVE_WINDOW_DEFAULT_WIDTH = 6, + NATIVE_WINDOW_DEFAULT_HEIGHT = 7, + + /* + * transformation that will most-likely be applied to buffers. This is only + * a hint, the actual transformation applied might be different. + * + * INTENDED USE: + * + * The transform hint can be used by a producer, for instance the GLES + * driver, to pre-rotate the rendering such that the final transformation + * in the composer is identity. This can be very useful when used in + * conjunction with the h/w composer HAL, in situations where it + * cannot handle arbitrary rotations. + * + * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) + * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. + * + * 2. The GL driver overrides the width and height of the ANW to + * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying + * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions + * according to NATIVE_WINDOW_TRANSFORM_HINT and calling + * native_window_set_buffers_dimensions(). + * + * 3. The GL driver dequeues a buffer of the new pre-rotated size. + * + * 4. The GL driver renders to the buffer such that the image is + * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT + * to the rendering. + * + * 5. The GL driver calls native_window_set_transform to apply + * inverse transformation to the buffer it just rendered. + * In order to do this, the GL driver needs + * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is + * done easily: + * + * int hintTransform, inverseTransform; + * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); + * inverseTransform = hintTransform; + * if (hintTransform & HAL_TRANSFORM_ROT_90) + * inverseTransform ^= HAL_TRANSFORM_ROT_180; + * + * + * 6. The GL driver queues the pre-transformed buffer. + * + * 7. The composer combines the buffer transform with the display + * transform. If the buffer transform happens to cancel out the + * display transform then no rotation is needed. + * + */ + NATIVE_WINDOW_TRANSFORM_HINT = 8, + + /* + * Boolean that indicates whether the consumer is running more than + * one buffer behind the producer. + */ + NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, + + /* + * The consumer gralloc usage bits currently set by the consumer. + * The values are defined in hardware/libhardware/include/gralloc.h. + */ + NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, + + /** + * Transformation that will by applied to buffers by the hwcomposer. + * This must not be set or checked by producer endpoints, and will + * disable the transform hint set in SurfaceFlinger (see + * NATIVE_WINDOW_TRANSFORM_HINT). + * + * INTENDED USE: + * Temporary - Please do not use this. This is intended only to be used + * by the camera's LEGACY mode. + * + * In situations where a SurfaceFlinger client wishes to set a transform + * that is not visible to the producer, and will always be applied in the + * hardware composer, the client can set this flag with + * native_window_set_buffers_sticky_transform. This can be used to rotate + * and flip buffers consumed by hardware composer without actually changing + * the aspect ratio of the buffers produced. + */ + NATIVE_WINDOW_STICKY_TRANSFORM = 11, + + /** + * The default data space for the buffers as set by the consumer. + * The values are defined in graphics.h. + */ + NATIVE_WINDOW_DEFAULT_DATASPACE = 12, + + /* + * Returns the age of the contents of the most recently dequeued buffer as + * the number of frames that have elapsed since it was last queued. For + * example, if the window is double-buffered, the age of any given buffer in + * steady state will be 2. If the dequeued buffer has never been queued, its + * age will be 0. + */ + NATIVE_WINDOW_BUFFER_AGE = 13, +}; + +/* Valid operations for the (*perform)() hook. + * + * Values marked as 'deprecated' are supported, but have been superceded by + * other functionality. + * + * Values marked as 'private' should be considered private to the framework. + * HAL implementation code with access to an ANativeWindow should not use these, + * as it may not interact properly with the framework's use of the + * ANativeWindow. + */ +enum { + NATIVE_WINDOW_SET_USAGE = 0, + NATIVE_WINDOW_CONNECT = 1, /* deprecated */ + NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ + NATIVE_WINDOW_SET_CROP = 3, /* private */ + NATIVE_WINDOW_SET_BUFFER_COUNT = 4, + NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ + NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, + NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, + NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, + NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, + NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ + NATIVE_WINDOW_LOCK = 11, /* private */ + NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ + NATIVE_WINDOW_API_CONNECT = 13, /* private */ + NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ + NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ + NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ + NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ + NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, + NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, + NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ +}; + +/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ +enum { + /* Buffers will be queued by EGL via eglSwapBuffers after being filled using + * OpenGL ES. + */ + NATIVE_WINDOW_API_EGL = 1, + + /* Buffers will be queued after being filled using the CPU + */ + NATIVE_WINDOW_API_CPU = 2, + + /* Buffers will be queued by Stagefright after being filled by a video + * decoder. The video decoder can either be a software or hardware decoder. + */ + NATIVE_WINDOW_API_MEDIA = 3, + + /* Buffers will be queued by the the camera HAL. + */ + NATIVE_WINDOW_API_CAMERA = 4, +}; + +/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ +enum { + /* flip source image horizontally */ + NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , + /* flip source image vertically */ + NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, + /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ + NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, + /* rotate source image 180 degrees */ + NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, + /* rotate source image 270 degrees clock-wise */ + NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, + /* transforms source by the inverse transform of the screen it is displayed onto. This + * transform is applied last */ + NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 +}; + +/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ +enum { + /* the window content is not updated (frozen) until a buffer of + * the window size is received (enqueued) + */ + NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, + /* the buffer is scaled in both dimensions to match the window size */ + NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, + /* the buffer is scaled uniformly such that the smaller dimension + * of the buffer matches the window size (cropping in the process) + */ + NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, + /* the window is clipped to the size of the buffer's crop rectangle; pixels + * outside the crop rectangle are treated as if they are completely + * transparent. + */ + NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, +}; + +/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ +enum { + NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ + NATIVE_WINDOW_SURFACE = 1, /* Surface */ +}; + +/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP + * + * Special timestamp value to indicate that timestamps should be auto-generated + * by the native window when queueBuffer is called. This is equal to INT64_MIN, + * defined directly to avoid problems with C99/C++ inclusion of stdint.h. + */ +static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); + +struct ANativeWindow +{ +#ifdef __cplusplus + ANativeWindow() + : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) + { + common.magic = ANDROID_NATIVE_WINDOW_MAGIC; + common.version = sizeof(ANativeWindow); + memset(common.reserved, 0, sizeof(common.reserved)); + } + + /* Implement the methods that sp expects so that it + can be used to automatically refcount ANativeWindow's. */ + void incStrong(const void* /*id*/) const { + common.incRef(const_cast(&common)); + } + void decStrong(const void* /*id*/) const { + common.decRef(const_cast(&common)); + } +#endif + + struct android_native_base_t common; + + /* flags describing some attributes of this surface or its updater */ + const uint32_t flags; + + /* min swap interval supported by this updated */ + const int minSwapInterval; + + /* max swap interval supported by this updated */ + const int maxSwapInterval; + + /* horizontal and vertical resolution in DPI */ + const float xdpi; + const float ydpi; + + /* Some storage reserved for the OEM's driver. */ + intptr_t oem[4]; + + /* + * Set the swap interval for this surface. + * + * Returns 0 on success or -errno on error. + */ + int (*setSwapInterval)(struct ANativeWindow* window, + int interval); + + /* + * Hook called by EGL to acquire a buffer. After this call, the buffer + * is not locked, so its content cannot be modified. This call may block if + * no buffers are available. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * Returns 0 on success or -errno on error. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but the new dequeueBuffer function that + * outputs a fence file descriptor should be used in its place. + */ + int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, + struct ANativeWindowBuffer** buffer); + + /* + * hook called by EGL to lock a buffer. This MUST be called before modifying + * the content of a buffer. The buffer must have been acquired with + * dequeueBuffer first. + * + * Returns 0 on success or -errno on error. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but it is essentially a no-op, and calls + * to it should be removed. + */ + int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer); + + /* + * Hook called by EGL when modifications to the render buffer are done. + * This unlocks and post the buffer. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * Buffers MUST be queued in the same order than they were dequeued. + * + * Returns 0 on success or -errno on error. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but the new queueBuffer function that + * takes a fence file descriptor should be used in its place (pass a value + * of -1 for the fence file descriptor if there is no valid one to pass). + */ + int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer); + + /* + * hook used to retrieve information about the native window. + * + * Returns 0 on success or -errno on error. + */ + int (*query)(const struct ANativeWindow* window, + int what, int* value); + + /* + * hook used to perform various operations on the surface. + * (*perform)() is a generic mechanism to add functionality to + * ANativeWindow while keeping backward binary compatibility. + * + * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions + * defined below. + * + * (*perform)() returns -ENOENT if the 'what' parameter is not supported + * by the surface's implementation. + * + * See above for a list of valid operations, such as + * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT + */ + int (*perform)(struct ANativeWindow* window, + int operation, ... ); + + /* + * Hook used to cancel a buffer that has been dequeued. + * No synchronization is performed between dequeue() and cancel(), so + * either external synchronization is needed, or these functions must be + * called from the same thread. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * XXX: This function is deprecated. It will continue to work for some + * time for binary compatibility, but the new cancelBuffer function that + * takes a fence file descriptor should be used in its place (pass a value + * of -1 for the fence file descriptor if there is no valid one to pass). + */ + int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer); + + /* + * Hook called by EGL to acquire a buffer. This call may block if no + * buffers are available. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The libsync fence file descriptor returned in the int pointed to by the + * fenceFd argument will refer to the fence that must signal before the + * dequeued buffer may be written to. A value of -1 indicates that the + * caller may access the buffer immediately without waiting on a fence. If + * a valid file descriptor is returned (i.e. any value except -1) then the + * caller is responsible for closing the file descriptor. + * + * Returns 0 on success or -errno on error. + */ + int (*dequeueBuffer)(struct ANativeWindow* window, + struct ANativeWindowBuffer** buffer, int* fenceFd); + + /* + * Hook called by EGL when modifications to the render buffer are done. + * This unlocks and post the buffer. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The fenceFd argument specifies a libsync fence file descriptor for a + * fence that must signal before the buffer can be accessed. If the buffer + * can be accessed immediately then a value of -1 should be used. The + * caller must not use the file descriptor after it is passed to + * queueBuffer, and the ANativeWindow implementation is responsible for + * closing it. + * + * Returns 0 on success or -errno on error. + */ + int (*queueBuffer)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer, int fenceFd); + + /* + * Hook used to cancel a buffer that has been dequeued. + * No synchronization is performed between dequeue() and cancel(), so + * either external synchronization is needed, or these functions must be + * called from the same thread. + * + * The window holds a reference to the buffer between dequeueBuffer and + * either queueBuffer or cancelBuffer, so clients only need their own + * reference if they might use the buffer after queueing or canceling it. + * Holding a reference to a buffer after queueing or canceling it is only + * allowed if a specific buffer count has been set. + * + * The fenceFd argument specifies a libsync fence file decsriptor for a + * fence that must signal before the buffer can be accessed. If the buffer + * can be accessed immediately then a value of -1 should be used. + * + * Note that if the client has not waited on the fence that was returned + * from dequeueBuffer, that same fence should be passed to cancelBuffer to + * ensure that future uses of the buffer are preceded by a wait on that + * fence. The caller must not use the file descriptor after it is passed + * to cancelBuffer, and the ANativeWindow implementation is responsible for + * closing it. + * + * Returns 0 on success or -errno on error. + */ + int (*cancelBuffer)(struct ANativeWindow* window, + struct ANativeWindowBuffer* buffer, int fenceFd); +}; + + /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). + * android_native_window_t is deprecated. + */ +typedef struct ANativeWindow ANativeWindow; +typedef struct ANativeWindow android_native_window_t __deprecated; + +/* + * native_window_set_usage(..., usage) + * Sets the intended usage flags for the next buffers + * acquired with (*lockBuffer)() and on. + * By default (if this function is never called), a usage of + * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE + * is assumed. + * Calling this function will usually cause following buffers to be + * reallocated. + */ + +static inline int native_window_set_usage( + struct ANativeWindow* window, int usage) +{ + return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); +} + +/* deprecated. Always returns 0. Don't call. */ +static inline int native_window_connect( + struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; + +static inline int native_window_connect( + struct ANativeWindow* window __UNUSED, int api __UNUSED) { + return 0; +} + +/* deprecated. Always returns 0. Don't call. */ +static inline int native_window_disconnect( + struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; + +static inline int native_window_disconnect( + struct ANativeWindow* window __UNUSED, int api __UNUSED) { + return 0; +} + +/* + * native_window_set_crop(..., crop) + * Sets which region of the next queued buffers needs to be considered. + * Depending on the scaling mode, a buffer's crop region is scaled and/or + * cropped to match the surface's size. This function sets the crop in + * pre-transformed buffer pixel coordinates. + * + * The specified crop region applies to all buffers queued after it is called. + * + * If 'crop' is NULL, subsequently queued buffers won't be cropped. + * + * An error is returned if for instance the crop region is invalid, out of the + * buffer's bound or if the window is invalid. + */ +static inline int native_window_set_crop( + struct ANativeWindow* window, + android_native_rect_t const * crop) +{ + return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); +} + +/* + * native_window_set_post_transform_crop(..., crop) + * Sets which region of the next queued buffers needs to be considered. + * Depending on the scaling mode, a buffer's crop region is scaled and/or + * cropped to match the surface's size. This function sets the crop in + * post-transformed pixel coordinates. + * + * The specified crop region applies to all buffers queued after it is called. + * + * If 'crop' is NULL, subsequently queued buffers won't be cropped. + * + * An error is returned if for instance the crop region is invalid, out of the + * buffer's bound or if the window is invalid. + */ +static inline int native_window_set_post_transform_crop( + struct ANativeWindow* window, + android_native_rect_t const * crop) +{ + return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); +} + +/* + * native_window_set_active_rect(..., active_rect) + * + * This function is deprecated and will be removed soon. For now it simply + * sets the post-transform crop for compatibility while multi-project commits + * get checked. + */ +static inline int native_window_set_active_rect( + struct ANativeWindow* window, + android_native_rect_t const * active_rect) __deprecated; + +static inline int native_window_set_active_rect( + struct ANativeWindow* window, + android_native_rect_t const * active_rect) +{ + return native_window_set_post_transform_crop(window, active_rect); +} + +/* + * native_window_set_buffer_count(..., count) + * Sets the number of buffers associated with this native window. + */ +static inline int native_window_set_buffer_count( + struct ANativeWindow* window, + size_t bufferCount) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); +} + +/* + * native_window_set_buffers_geometry(..., int w, int h, int format) + * All buffers dequeued after this call will have the dimensions and format + * specified. A successful call to this function has the same effect as calling + * native_window_set_buffers_size and native_window_set_buffers_format. + * + * XXX: This function is deprecated. The native_window_set_buffers_dimensions + * and native_window_set_buffers_format functions should be used instead. + */ +static inline int native_window_set_buffers_geometry( + struct ANativeWindow* window, + int w, int h, int format) __deprecated; + +static inline int native_window_set_buffers_geometry( + struct ANativeWindow* window, + int w, int h, int format) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, + w, h, format); +} + +/* + * native_window_set_buffers_dimensions(..., int w, int h) + * All buffers dequeued after this call will have the dimensions specified. + * In particular, all buffers will have a fixed-size, independent from the + * native-window size. They will be scaled according to the scaling mode + * (see native_window_set_scaling_mode) upon window composition. + * + * If w and h are 0, the normal behavior is restored. That is, dequeued buffers + * following this call will be sized to match the window's size. + * + * Calling this function will reset the window crop to a NULL value, which + * disables cropping of the buffers. + */ +static inline int native_window_set_buffers_dimensions( + struct ANativeWindow* window, + int w, int h) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, + w, h); +} + +/* + * native_window_set_buffers_user_dimensions(..., int w, int h) + * + * Sets the user buffer size for the window, which overrides the + * window's size. All buffers dequeued after this call will have the + * dimensions specified unless overridden by + * native_window_set_buffers_dimensions. All buffers will have a + * fixed-size, independent from the native-window size. They will be + * scaled according to the scaling mode (see + * native_window_set_scaling_mode) upon window composition. + * + * If w and h are 0, the normal behavior is restored. That is, the + * default buffer size will match the windows's size. + * + * Calling this function will reset the window crop to a NULL value, which + * disables cropping of the buffers. + */ +static inline int native_window_set_buffers_user_dimensions( + struct ANativeWindow* window, + int w, int h) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, + w, h); +} + +/* + * native_window_set_buffers_format(..., int format) + * All buffers dequeued after this call will have the format specified. + * + * If the specified format is 0, the default buffer format will be used. + */ +static inline int native_window_set_buffers_format( + struct ANativeWindow* window, + int format) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); +} + +/* + * native_window_set_buffers_data_space(..., int dataSpace) + * All buffers queued after this call will be associated with the dataSpace + * parameter specified. + * + * dataSpace specifies additional information about the buffer that's dependent + * on the buffer format and the endpoints. For example, it can be used to convey + * the color space of the image data in the buffer, or it can be used to + * indicate that the buffers contain depth measurement data instead of color + * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been + * overridden by the consumer. + */ +static inline int native_window_set_buffers_data_space( + struct ANativeWindow* window, + android_dataspace_t dataSpace) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, + dataSpace); +} + +/* + * native_window_set_buffers_transform(..., int transform) + * All buffers queued after this call will be displayed transformed according + * to the transform parameter specified. + */ +static inline int native_window_set_buffers_transform( + struct ANativeWindow* window, + int transform) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, + transform); +} + +/* + * native_window_set_buffers_sticky_transform(..., int transform) + * All buffers queued after this call will be displayed transformed according + * to the transform parameter specified applied on top of the regular buffer + * transform. Setting this transform will disable the transform hint. + * + * Temporary - This is only intended to be used by the LEGACY camera mode, do + * not use this for anything else. + */ +static inline int native_window_set_buffers_sticky_transform( + struct ANativeWindow* window, + int transform) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, + transform); +} + +/* + * native_window_set_buffers_timestamp(..., int64_t timestamp) + * All buffers queued after this call will be associated with the timestamp + * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO + * (the default), timestamps will be generated automatically when queueBuffer is + * called. The timestamp is measured in nanoseconds, and is normally monotonically + * increasing. The timestamp should be unaffected by time-of-day adjustments, + * and for a camera should be strictly monotonic but for a media player may be + * reset when the position is set. + */ +static inline int native_window_set_buffers_timestamp( + struct ANativeWindow* window, + int64_t timestamp) +{ + return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, + timestamp); +} + +/* + * native_window_set_scaling_mode(..., int mode) + * All buffers queued after this call will be associated with the scaling mode + * specified. + */ +static inline int native_window_set_scaling_mode( + struct ANativeWindow* window, + int mode) +{ + return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, + mode); +} + +/* + * native_window_api_connect(..., int api) + * connects an API to this window. only one API can be connected at a time. + * Returns -EINVAL if for some reason the window cannot be connected, which + * can happen if it's connected to some other API. + */ +static inline int native_window_api_connect( + struct ANativeWindow* window, int api) +{ + return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); +} + +/* + * native_window_api_disconnect(..., int api) + * disconnect the API from this window. + * An error is returned if for instance the window wasn't connected in the + * first place. + */ +static inline int native_window_api_disconnect( + struct ANativeWindow* window, int api) +{ + return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); +} + +/* + * native_window_dequeue_buffer_and_wait(...) + * Dequeue a buffer and wait on the fence associated with that buffer. The + * buffer may safely be accessed immediately upon this function returning. An + * error is returned if either of the dequeue or the wait operations fail. + */ +static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, + struct ANativeWindowBuffer** anb) { + return anw->dequeueBuffer_DEPRECATED(anw, anb); +} + +/* + * native_window_set_sideband_stream(..., native_handle_t*) + * Attach a sideband buffer stream to a native window. + */ +static inline int native_window_set_sideband_stream( + struct ANativeWindow* window, + native_handle_t* sidebandHandle) +{ + return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, + sidebandHandle); +} + +/* + * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) + * Set the surface damage (i.e., the region of the surface that has changed + * since the previous frame). The damage set by this call will be reset (to the + * default of full-surface damage) after calling queue, so this must be called + * prior to every frame with damage that does not cover the whole surface if the + * caller desires downstream consumers to use this optimization. + * + * The damage region is specified as an array of rectangles, with the important + * caveat that the origin of the surface is considered to be the bottom-left + * corner, as in OpenGL ES. + * + * If numRects is set to 0, rects may be NULL, and the surface damage will be + * set to the full surface (the same as if this function had not been called for + * this frame). + */ +static inline int native_window_set_surface_damage( + struct ANativeWindow* window, + const android_native_rect_t* rects, size_t numRects) +{ + return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, + rects, numRects); +} + +__END_DECLS + +#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ diff --git a/meson.build b/meson.build index 13d0605f903c..2575d0abb334 100644 --- a/meson.build +++ b/meson.build @@ -51,6 +51,11 @@ add_project_arguments(cpp_arguments, language : 'cpp') add_project_link_arguments(cpp_arguments, language : 'cpp') libcamera_includes = include_directories('include') +android_includes = ([ + include_directories('include/android/hardware/libhardware/include/'), + include_directories('include/android/system/core/include'), + include_directories('include/android/metadata/'), +]) subdir('include') subdir('src') From patchwork Thu Aug 1 15:54:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1724 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5F84F615FF for ; Thu, 1 Aug 2019 17:53:27 +0200 (CEST) X-Originating-IP: 82.58.19.211 Received: from uno.homenet.telecomitalia.it (host211-19-dynamic.58-82-r.retail.telecomitalia.it [82.58.19.211]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 4C12DE0003; Thu, 1 Aug 2019 15:53:21 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Aug 2019 17:54:19 +0200 Message-Id: <20190801155420.24694-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801155420.24694-1-jacopo@jmondi.org> References: <20190801155420.24694-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] android: Add camera metadata library X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Aug 2019 15:53:27 -0000 Import the Android camera metadata library from the ChromiumOS build system. The camera metadata library has been copied from https://chromium.googlesource.com/chromiumos/platform2 at revision ceb477360a8012ee38e80746258f4828aad6b4c7. The original path in the Cros platform2/ repository is: camera/android/libcamera_metadata/src Create a new build target for the camera metadata library to compile the libcamera Android HAL implementation against it. Signed-off-by: Jacopo Mondi --- src/android/meson.build | 10 + src/android/metadata/camera_metadata.c | 1204 +++++++ .../metadata/camera_metadata_tag_info.c | 2811 +++++++++++++++++ 3 files changed, 4025 insertions(+) create mode 100644 src/android/meson.build create mode 100644 src/android/metadata/camera_metadata.c create mode 100644 src/android/metadata/camera_metadata_tag_info.c diff --git a/src/android/meson.build b/src/android/meson.build new file mode 100644 index 000000000000..e988dfa9ee63 --- /dev/null +++ b/src/android/meson.build @@ -0,0 +1,10 @@ +android_camera_metadata_sources = files([ + 'metadata/camera_metadata.c', +]) + +# Do not install by default as the target systems (Android, ChromeOS) already +# ship a libcamera_metadata.so library. +android_camera_metadata = shared_library('camera_metadata', + android_camera_metadata_sources, + install : false, + include_directories : android_includes) diff --git a/src/android/metadata/camera_metadata.c b/src/android/metadata/camera_metadata.c new file mode 100644 index 000000000000..6bfd02da29c7 --- /dev/null +++ b/src/android/metadata/camera_metadata.c @@ -0,0 +1,1204 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "camera_metadata" + +/* + * Replace ALOGE() with a fprintf to stderr so that we don't need to + * re-implement Android's logging system. The log/log.h header file is no + * longer necessary once we removed dependency on ALOGE(). + */ +#define ALOGE(...) fprintf(stderr, LOG_TAG __VA_ARGS__) + +#include +#include + +#include +#include +#include +#include // for offsetof +#include +#include + +#define OK 0 +#define ERROR 1 +#define NOT_FOUND (-ENOENT) +#define SN_EVENT_LOG_ID 0x534e4554 + +#define ALIGN_TO(val, alignment) \ + (((uintptr_t)(val) + ((alignment) - 1)) & ~((alignment) - 1)) + +/** + * A single metadata entry, storing an array of values of a given type. If the + * array is no larger than 4 bytes in size, it is stored in the data.value[] + * array; otherwise, it can found in the parent's data array at index + * data.offset. + */ +#define ENTRY_ALIGNMENT ((size_t) 4) +typedef struct camera_metadata_buffer_entry { + uint32_t tag; + uint32_t count; + union { + uint32_t offset; + uint8_t value[4]; + } data; + uint8_t type; + uint8_t reserved[3]; +} camera_metadata_buffer_entry_t; + +typedef uint32_t metadata_uptrdiff_t; +typedef uint32_t metadata_size_t; + +/** + * A packet of metadata. This is a list of entries, each of which may point to + * its values stored at an offset in data. + * + * It is assumed by the utility functions that the memory layout of the packet + * is as follows: + * + * |-----------------------------------------------| + * | camera_metadata_t | + * | | + * |-----------------------------------------------| + * | reserved for future expansion | + * |-----------------------------------------------| + * | camera_metadata_buffer_entry_t #0 | + * |-----------------------------------------------| + * | .... | + * |-----------------------------------------------| + * | camera_metadata_buffer_entry_t #entry_count-1 | + * |-----------------------------------------------| + * | free space for | + * | (entry_capacity-entry_count) entries | + * |-----------------------------------------------| + * | start of camera_metadata.data | + * | | + * |-----------------------------------------------| + * | free space for | + * | (data_capacity-data_count) bytes | + * |-----------------------------------------------| + * + * With the total length of the whole packet being camera_metadata.size bytes. + * + * In short, the entries and data are contiguous in memory after the metadata + * header. + */ +#define METADATA_ALIGNMENT ((size_t) 4) +struct camera_metadata { + metadata_size_t size; + uint32_t version; + uint32_t flags; + metadata_size_t entry_count; + metadata_size_t entry_capacity; + metadata_uptrdiff_t entries_start; // Offset from camera_metadata + metadata_size_t data_count; + metadata_size_t data_capacity; + metadata_uptrdiff_t data_start; // Offset from camera_metadata + uint32_t padding; // padding to 8 bytes boundary + metadata_vendor_id_t vendor_id; +}; + +/** + * A datum of metadata. This corresponds to camera_metadata_entry_t::data + * with the difference that each element is not a pointer. We need to have a + * non-pointer type description in order to figure out the largest alignment + * requirement for data (DATA_ALIGNMENT). + */ +#define DATA_ALIGNMENT ((size_t) 8) +typedef union camera_metadata_data { + uint8_t u8; + int32_t i32; + float f; + int64_t i64; + double d; + camera_metadata_rational_t r; +} camera_metadata_data_t; + +_Static_assert(sizeof(metadata_size_t) == 4, + "Size of metadata_size_t must be 4"); +_Static_assert(sizeof(metadata_uptrdiff_t) == 4, + "Size of metadata_uptrdiff_t must be 4"); +_Static_assert(sizeof(metadata_vendor_id_t) == 8, + "Size of metadata_vendor_id_t must be 8"); +_Static_assert(sizeof(camera_metadata_data_t) == 8, + "Size of camera_metadata_data_t must be 8"); + +_Static_assert(offsetof(camera_metadata_buffer_entry_t, tag) == 0, + "Offset of tag must be 0"); +_Static_assert(offsetof(camera_metadata_buffer_entry_t, count) == 4, + "Offset of count must be 4"); +_Static_assert(offsetof(camera_metadata_buffer_entry_t, data) == 8, + "Offset of data must be 8"); +_Static_assert(offsetof(camera_metadata_buffer_entry_t, type) == 12, + "Offset of type must be 12"); +_Static_assert(sizeof(camera_metadata_buffer_entry_t) == 16, + "Size of camera_metadata_buffer_entry_t must be 16"); + +_Static_assert(offsetof(camera_metadata_t, size) == 0, + "Offset of size must be 0"); +_Static_assert(offsetof(camera_metadata_t, version) == 4, + "Offset of version must be 4"); +_Static_assert(offsetof(camera_metadata_t, flags) == 8, + "Offset of flags must be 8"); +_Static_assert(offsetof(camera_metadata_t, entry_count) == 12, + "Offset of entry_count must be 12"); +_Static_assert(offsetof(camera_metadata_t, entry_capacity) == 16, + "Offset of entry_capacity must be 16"); +_Static_assert(offsetof(camera_metadata_t, entries_start) == 20, + "Offset of entries_start must be 20"); +_Static_assert(offsetof(camera_metadata_t, data_count) == 24, + "Offset of data_count must be 24"); +_Static_assert(offsetof(camera_metadata_t, data_capacity) == 28, + "Offset of data_capacity must be 28"); +_Static_assert(offsetof(camera_metadata_t, data_start) == 32, + "Offset of data_start must be 32"); +_Static_assert(offsetof(camera_metadata_t, vendor_id) == 40, + "Offset of vendor_id must be 40"); +_Static_assert(sizeof(camera_metadata_t) == 48, + "Size of camera_metadata_t must be 48"); + +/** + * The preferred alignment of a packet of camera metadata. In general, + * this is the lowest common multiple of the constituents of a metadata + * package, i.e, of DATA_ALIGNMENT and ENTRY_ALIGNMENT. + */ +#define MAX_ALIGNMENT(A, B) (((A) > (B)) ? (A) : (B)) +#define METADATA_PACKET_ALIGNMENT \ + MAX_ALIGNMENT(MAX_ALIGNMENT(DATA_ALIGNMENT, METADATA_ALIGNMENT), ENTRY_ALIGNMENT) + +/** Versioning information */ +#define CURRENT_METADATA_VERSION 1 + +/** Flag definitions */ +#define FLAG_SORTED 0x00000001 + +/** Tag information */ + +typedef struct tag_info { + const char *tag_name; + uint8_t tag_type; +} tag_info_t; + +#include "camera_metadata_tag_info.c" + +const size_t camera_metadata_type_size[NUM_TYPES] = { + [TYPE_BYTE] = sizeof(uint8_t), + [TYPE_INT32] = sizeof(int32_t), + [TYPE_FLOAT] = sizeof(float), + [TYPE_INT64] = sizeof(int64_t), + [TYPE_DOUBLE] = sizeof(double), + [TYPE_RATIONAL] = sizeof(camera_metadata_rational_t) +}; + +const char *camera_metadata_type_names[NUM_TYPES] = { + [TYPE_BYTE] = "byte", + [TYPE_INT32] = "int32", + [TYPE_FLOAT] = "float", + [TYPE_INT64] = "int64", + [TYPE_DOUBLE] = "double", + [TYPE_RATIONAL] = "rational" +}; + +static camera_metadata_buffer_entry_t *get_entries( + const camera_metadata_t *metadata) { + return (camera_metadata_buffer_entry_t*) + ((uint8_t*)metadata + metadata->entries_start); +} + +static uint8_t *get_data(const camera_metadata_t *metadata) { + return (uint8_t*)metadata + metadata->data_start; +} + +size_t get_camera_metadata_alignment() { + return METADATA_PACKET_ALIGNMENT; +} + +camera_metadata_t *allocate_copy_camera_metadata_checked( + const camera_metadata_t *src, + size_t src_size) { + + if (src == NULL) { + return NULL; + } + + if (src_size < sizeof(camera_metadata_t)) { + ALOGE("%s: Source size too small!", __FUNCTION__); + // android_errorWriteLog(0x534e4554, "67782345"); + return NULL; + } + + void *buffer = malloc(src_size); + memcpy(buffer, src, src_size); + + camera_metadata_t *metadata = (camera_metadata_t*) buffer; + if (validate_camera_metadata_structure(metadata, &src_size) != OK) { + free(buffer); + return NULL; + } + + return metadata; +} + +camera_metadata_t *allocate_camera_metadata(size_t entry_capacity, + size_t data_capacity) { + + size_t memory_needed = calculate_camera_metadata_size(entry_capacity, + data_capacity); + void *buffer = malloc(memory_needed); + camera_metadata_t *metadata = place_camera_metadata( + buffer, memory_needed, entry_capacity, data_capacity); + if (!metadata) { + /* This should not happen when memory_needed is the same + * calculated in this function and in place_camera_metadata. + */ + free(buffer); + } + return metadata; +} + +camera_metadata_t *place_camera_metadata(void *dst, + size_t dst_size, + size_t entry_capacity, + size_t data_capacity) { + if (dst == NULL) return NULL; + + size_t memory_needed = calculate_camera_metadata_size(entry_capacity, + data_capacity); + if (memory_needed > dst_size) return NULL; + + camera_metadata_t *metadata = (camera_metadata_t*)dst; + metadata->version = CURRENT_METADATA_VERSION; + metadata->flags = 0; + metadata->entry_count = 0; + metadata->entry_capacity = entry_capacity; + metadata->entries_start = + ALIGN_TO(sizeof(camera_metadata_t), ENTRY_ALIGNMENT); + metadata->data_count = 0; + metadata->data_capacity = data_capacity; + metadata->size = memory_needed; + size_t data_unaligned = (uint8_t*)(get_entries(metadata) + + metadata->entry_capacity) - (uint8_t*)metadata; + metadata->data_start = ALIGN_TO(data_unaligned, DATA_ALIGNMENT); + metadata->vendor_id = CAMERA_METADATA_INVALID_VENDOR_ID; + + assert(validate_camera_metadata_structure(metadata, NULL) == OK); + return metadata; +} +void free_camera_metadata(camera_metadata_t *metadata) { + free(metadata); +} + +size_t calculate_camera_metadata_size(size_t entry_count, + size_t data_count) { + size_t memory_needed = sizeof(camera_metadata_t); + // Start entry list at aligned boundary + memory_needed = ALIGN_TO(memory_needed, ENTRY_ALIGNMENT); + memory_needed += sizeof(camera_metadata_buffer_entry_t[entry_count]); + // Start buffer list at aligned boundary + memory_needed = ALIGN_TO(memory_needed, DATA_ALIGNMENT); + memory_needed += sizeof(uint8_t[data_count]); + // Make sure camera metadata can be stacked in continuous memory + memory_needed = ALIGN_TO(memory_needed, METADATA_PACKET_ALIGNMENT); + return memory_needed; +} + +size_t get_camera_metadata_size(const camera_metadata_t *metadata) { + if (metadata == NULL) return ERROR; + + return metadata->size; +} + +size_t get_camera_metadata_compact_size(const camera_metadata_t *metadata) { + if (metadata == NULL) return ERROR; + + return calculate_camera_metadata_size(metadata->entry_count, + metadata->data_count); +} + +size_t get_camera_metadata_entry_count(const camera_metadata_t *metadata) { + return metadata->entry_count; +} + +size_t get_camera_metadata_entry_capacity(const camera_metadata_t *metadata) { + return metadata->entry_capacity; +} + +size_t get_camera_metadata_data_count(const camera_metadata_t *metadata) { + return metadata->data_count; +} + +size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata) { + return metadata->data_capacity; +} + +camera_metadata_t* copy_camera_metadata(void *dst, size_t dst_size, + const camera_metadata_t *src) { + size_t memory_needed = get_camera_metadata_compact_size(src); + + if (dst == NULL) return NULL; + if (dst_size < memory_needed) return NULL; + + camera_metadata_t *metadata = + place_camera_metadata(dst, dst_size, src->entry_count, src->data_count); + + metadata->flags = src->flags; + metadata->entry_count = src->entry_count; + metadata->data_count = src->data_count; + metadata->vendor_id = src->vendor_id; + + memcpy(get_entries(metadata), get_entries(src), + sizeof(camera_metadata_buffer_entry_t[metadata->entry_count])); + memcpy(get_data(metadata), get_data(src), + sizeof(uint8_t[metadata->data_count])); + + assert(validate_camera_metadata_structure(metadata, NULL) == OK); + return metadata; +} + +// This method should be used when the camera metadata cannot be trusted. For example, when it's +// read from Parcel. +static int validate_and_calculate_camera_metadata_entry_data_size(size_t *data_size, uint8_t type, + size_t data_count) { + if (type >= NUM_TYPES) return ERROR; + + // Check for overflow + if (data_count != 0 && + camera_metadata_type_size[type] > (SIZE_MAX - DATA_ALIGNMENT + 1) / data_count) { + // android_errorWriteLog(SN_EVENT_LOG_ID, "30741779"); + return ERROR; + } + + size_t data_bytes = data_count * camera_metadata_type_size[type]; + + if (data_size) { + *data_size = data_bytes <= 4 ? 0 : ALIGN_TO(data_bytes, DATA_ALIGNMENT); + } + + return OK; +} + +size_t calculate_camera_metadata_entry_data_size(uint8_t type, + size_t data_count) { + if (type >= NUM_TYPES) return 0; + + size_t data_bytes = data_count * + camera_metadata_type_size[type]; + + return data_bytes <= 4 ? 0 : ALIGN_TO(data_bytes, DATA_ALIGNMENT); +} + +int validate_camera_metadata_structure(const camera_metadata_t *metadata, + const size_t *expected_size) { + + if (metadata == NULL) { + ALOGE("%s: metadata is null!", __FUNCTION__); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + uintptr_t aligned_ptr = ALIGN_TO(metadata, METADATA_PACKET_ALIGNMENT); + const uintptr_t alignmentOffset = aligned_ptr - (uintptr_t) metadata; + + // Check that the metadata pointer is well-aligned first. + { + static const struct { + const char *name; + size_t alignment; + } alignments[] = { + { + .name = "camera_metadata", + .alignment = METADATA_ALIGNMENT + }, + { + .name = "camera_metadata_buffer_entry", + .alignment = ENTRY_ALIGNMENT + }, + { + .name = "camera_metadata_data", + .alignment = DATA_ALIGNMENT + }, + }; + + for (size_t i = 0; i < sizeof(alignments)/sizeof(alignments[0]); ++i) { + uintptr_t aligned_ptr = ALIGN_TO((uintptr_t) metadata + alignmentOffset, + alignments[i].alignment); + + if ((uintptr_t)metadata + alignmentOffset != aligned_ptr) { + ALOGE("%s: Metadata pointer is not aligned (actual %p, " + "expected %p, offset %" PRIuPTR ") to type %s", + __FUNCTION__, metadata, + (void*)aligned_ptr, alignmentOffset, alignments[i].name); + return CAMERA_METADATA_VALIDATION_ERROR; + } + } + } + + /** + * Check that the metadata contents are correct + */ + + if (expected_size != NULL && metadata->size > *expected_size) { + ALOGE("%s: Metadata size (%" PRIu32 ") should be <= expected size (%zu)", + __FUNCTION__, metadata->size, *expected_size); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + if (metadata->entry_count > metadata->entry_capacity) { + ALOGE("%s: Entry count (%" PRIu32 ") should be <= entry capacity " + "(%" PRIu32 ")", + __FUNCTION__, metadata->entry_count, metadata->entry_capacity); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + if (metadata->data_count > metadata->data_capacity) { + ALOGE("%s: Data count (%" PRIu32 ") should be <= data capacity " + "(%" PRIu32 ")", + __FUNCTION__, metadata->data_count, metadata->data_capacity); + // android_errorWriteLog(SN_EVENT_LOG_ID, "30591838"); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + const metadata_uptrdiff_t entries_end = + metadata->entries_start + metadata->entry_capacity; + if (entries_end < metadata->entries_start || // overflow check + entries_end > metadata->data_start) { + + ALOGE("%s: Entry start + capacity (%" PRIu32 ") should be <= data start " + "(%" PRIu32 ")", + __FUNCTION__, + (metadata->entries_start + metadata->entry_capacity), + metadata->data_start); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + const metadata_uptrdiff_t data_end = + metadata->data_start + metadata->data_capacity; + if (data_end < metadata->data_start || // overflow check + data_end > metadata->size) { + + ALOGE("%s: Data start + capacity (%" PRIu32 ") should be <= total size " + "(%" PRIu32 ")", + __FUNCTION__, + (metadata->data_start + metadata->data_capacity), + metadata->size); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + // Validate each entry + const metadata_size_t entry_count = metadata->entry_count; + camera_metadata_buffer_entry_t *entries = get_entries(metadata); + + for (size_t i = 0; i < entry_count; ++i) { + + if ((uintptr_t)&entries[i] + alignmentOffset != + ALIGN_TO((uintptr_t)&entries[i] + alignmentOffset, ENTRY_ALIGNMENT)) { + ALOGE("%s: Entry index %zu had bad alignment (address %p)," + " expected alignment %zu", + __FUNCTION__, i, &entries[i], ENTRY_ALIGNMENT); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + camera_metadata_buffer_entry_t entry = entries[i]; + + if (entry.type >= NUM_TYPES) { + ALOGE("%s: Entry index %zu had a bad type %d", + __FUNCTION__, i, entry.type); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + // TODO: fix vendor_tag_ops across processes so we don't need to special + // case vendor-specific tags + uint32_t tag_section = entry.tag >> 16; + int tag_type = get_local_camera_metadata_tag_type(entry.tag, metadata); + if (tag_type != (int)entry.type && tag_section < VENDOR_SECTION) { + ALOGE("%s: Entry index %zu had tag type %d, but the type was %d", + __FUNCTION__, i, tag_type, entry.type); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + size_t data_size; + if (validate_and_calculate_camera_metadata_entry_data_size(&data_size, entry.type, + entry.count) != OK) { + ALOGE("%s: Entry data size is invalid. type: %u count: %u", __FUNCTION__, entry.type, + entry.count); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + if (data_size != 0) { + camera_metadata_data_t *data = + (camera_metadata_data_t*) (get_data(metadata) + + entry.data.offset); + + if ((uintptr_t)data + alignmentOffset != + ALIGN_TO((uintptr_t)data + alignmentOffset, DATA_ALIGNMENT)) { + ALOGE("%s: Entry index %zu had bad data alignment (address %p)," + " expected align %zu, (tag name %s, data size %zu)", + __FUNCTION__, i, data, DATA_ALIGNMENT, + get_local_camera_metadata_tag_name(entry.tag, metadata) ? + : "unknown", data_size); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + size_t data_entry_end = entry.data.offset + data_size; + if (data_entry_end < entry.data.offset || // overflow check + data_entry_end > metadata->data_capacity) { + + ALOGE("%s: Entry index %zu data ends (%zu) beyond the capacity " + "%" PRIu32, __FUNCTION__, i, data_entry_end, + metadata->data_capacity); + return CAMERA_METADATA_VALIDATION_ERROR; + } + + } else if (entry.count == 0) { + if (entry.data.offset != 0) { + ALOGE("%s: Entry index %zu had 0 items, but offset was non-0 " + "(%" PRIu32 "), tag name: %s", __FUNCTION__, i, entry.data.offset, + get_local_camera_metadata_tag_name(entry.tag, metadata) ? : "unknown"); + return CAMERA_METADATA_VALIDATION_ERROR; + } + } // else data stored inline, so we look at value which can be anything. + } + + if (alignmentOffset == 0) { + return OK; + } + return CAMERA_METADATA_VALIDATION_SHIFTED; +} + +int append_camera_metadata(camera_metadata_t *dst, + const camera_metadata_t *src) { + if (dst == NULL || src == NULL ) return ERROR; + + // Check for overflow + if (src->entry_count + dst->entry_count < src->entry_count) return ERROR; + if (src->data_count + dst->data_count < src->data_count) return ERROR; + // Check for space + if (dst->entry_capacity < src->entry_count + dst->entry_count) return ERROR; + if (dst->data_capacity < src->data_count + dst->data_count) return ERROR; + + if ((dst->vendor_id != CAMERA_METADATA_INVALID_VENDOR_ID) && + (src->vendor_id != CAMERA_METADATA_INVALID_VENDOR_ID)) { + if (dst->vendor_id != src->vendor_id) { + ALOGE("%s: Append for metadata from different vendors is" + "not supported!", __func__); + return ERROR; + } + } + + memcpy(get_entries(dst) + dst->entry_count, get_entries(src), + sizeof(camera_metadata_buffer_entry_t[src->entry_count])); + memcpy(get_data(dst) + dst->data_count, get_data(src), + sizeof(uint8_t[src->data_count])); + if (dst->data_count != 0) { + camera_metadata_buffer_entry_t *entry = get_entries(dst) + dst->entry_count; + for (size_t i = 0; i < src->entry_count; i++, entry++) { + if ( calculate_camera_metadata_entry_data_size(entry->type, + entry->count) > 0 ) { + entry->data.offset += dst->data_count; + } + } + } + if (dst->entry_count == 0) { + // Appending onto empty buffer, keep sorted state + dst->flags |= src->flags & FLAG_SORTED; + } else if (src->entry_count != 0) { + // Both src, dst are nonempty, cannot assume sort remains + dst->flags &= ~FLAG_SORTED; + } else { + // Src is empty, keep dst sorted state + } + dst->entry_count += src->entry_count; + dst->data_count += src->data_count; + + if (dst->vendor_id == CAMERA_METADATA_INVALID_VENDOR_ID) { + dst->vendor_id = src->vendor_id; + } + + assert(validate_camera_metadata_structure(dst, NULL) == OK); + return OK; +} + +camera_metadata_t *clone_camera_metadata(const camera_metadata_t *src) { + int res; + if (src == NULL) return NULL; + camera_metadata_t *clone = allocate_camera_metadata( + get_camera_metadata_entry_count(src), + get_camera_metadata_data_count(src)); + if (clone != NULL) { + res = append_camera_metadata(clone, src); + if (res != OK) { + free_camera_metadata(clone); + clone = NULL; + } + } + assert(validate_camera_metadata_structure(clone, NULL) == OK); + return clone; +} + +static int add_camera_metadata_entry_raw(camera_metadata_t *dst, + uint32_t tag, + uint8_t type, + const void *data, + size_t data_count) { + + if (dst == NULL) return ERROR; + if (dst->entry_count == dst->entry_capacity) return ERROR; + if (data_count && data == NULL) return ERROR; + + size_t data_bytes = + calculate_camera_metadata_entry_data_size(type, data_count); + if (data_bytes + dst->data_count > dst->data_capacity) return ERROR; + + size_t data_payload_bytes = + data_count * camera_metadata_type_size[type]; + camera_metadata_buffer_entry_t *entry = get_entries(dst) + dst->entry_count; + memset(entry, 0, sizeof(camera_metadata_buffer_entry_t)); + entry->tag = tag; + entry->type = type; + entry->count = data_count; + + if (data_bytes == 0) { + memcpy(entry->data.value, data, + data_payload_bytes); + } else { + entry->data.offset = dst->data_count; + memcpy(get_data(dst) + entry->data.offset, data, + data_payload_bytes); + dst->data_count += data_bytes; + } + dst->entry_count++; + dst->flags &= ~FLAG_SORTED; + assert(validate_camera_metadata_structure(dst, NULL) == OK); + return OK; +} + +int add_camera_metadata_entry(camera_metadata_t *dst, + uint32_t tag, + const void *data, + size_t data_count) { + + int type = get_local_camera_metadata_tag_type(tag, dst); + if (type == -1) { + ALOGE("%s: Unknown tag %04x.", __FUNCTION__, tag); + return ERROR; + } + + return add_camera_metadata_entry_raw(dst, + tag, + type, + data, + data_count); +} + +static int compare_entry_tags(const void *p1, const void *p2) { + uint32_t tag1 = ((camera_metadata_buffer_entry_t*)p1)->tag; + uint32_t tag2 = ((camera_metadata_buffer_entry_t*)p2)->tag; + return tag1 < tag2 ? -1 : + tag1 == tag2 ? 0 : + 1; +} + +int sort_camera_metadata(camera_metadata_t *dst) { + if (dst == NULL) return ERROR; + if (dst->flags & FLAG_SORTED) return OK; + + qsort(get_entries(dst), dst->entry_count, + sizeof(camera_metadata_buffer_entry_t), + compare_entry_tags); + dst->flags |= FLAG_SORTED; + + assert(validate_camera_metadata_structure(dst, NULL) == OK); + return OK; +} + +int get_camera_metadata_entry(camera_metadata_t *src, + size_t index, + camera_metadata_entry_t *entry) { + if (src == NULL || entry == NULL) return ERROR; + if (index >= src->entry_count) return ERROR; + + camera_metadata_buffer_entry_t *buffer_entry = get_entries(src) + index; + + entry->index = index; + entry->tag = buffer_entry->tag; + entry->type = buffer_entry->type; + entry->count = buffer_entry->count; + if (buffer_entry->count * + camera_metadata_type_size[buffer_entry->type] > 4) { + entry->data.u8 = get_data(src) + buffer_entry->data.offset; + } else { + entry->data.u8 = buffer_entry->data.value; + } + return OK; +} + +int get_camera_metadata_ro_entry(const camera_metadata_t *src, + size_t index, + camera_metadata_ro_entry_t *entry) { + return get_camera_metadata_entry((camera_metadata_t*)src, index, + (camera_metadata_entry_t*)entry); +} + +int find_camera_metadata_entry(camera_metadata_t *src, + uint32_t tag, + camera_metadata_entry_t *entry) { + if (src == NULL) return ERROR; + + uint32_t index; + if (src->flags & FLAG_SORTED) { + // Sorted entries, do a binary search + camera_metadata_buffer_entry_t *search_entry = NULL; + camera_metadata_buffer_entry_t key; + key.tag = tag; + search_entry = bsearch(&key, + get_entries(src), + src->entry_count, + sizeof(camera_metadata_buffer_entry_t), + compare_entry_tags); + if (search_entry == NULL) return NOT_FOUND; + index = search_entry - get_entries(src); + } else { + // Not sorted, linear search + camera_metadata_buffer_entry_t *search_entry = get_entries(src); + for (index = 0; index < src->entry_count; index++, search_entry++) { + if (search_entry->tag == tag) { + break; + } + } + if (index == src->entry_count) return NOT_FOUND; + } + + return get_camera_metadata_entry(src, index, + entry); +} + +int find_camera_metadata_ro_entry(const camera_metadata_t *src, + uint32_t tag, + camera_metadata_ro_entry_t *entry) { + return find_camera_metadata_entry((camera_metadata_t*)src, tag, + (camera_metadata_entry_t*)entry); +} + + +int delete_camera_metadata_entry(camera_metadata_t *dst, + size_t index) { + if (dst == NULL) return ERROR; + if (index >= dst->entry_count) return ERROR; + + camera_metadata_buffer_entry_t *entry = get_entries(dst) + index; + size_t data_bytes = calculate_camera_metadata_entry_data_size(entry->type, + entry->count); + + if (data_bytes > 0) { + // Shift data buffer to overwrite deleted data + uint8_t *start = get_data(dst) + entry->data.offset; + uint8_t *end = start + data_bytes; + size_t length = dst->data_count - entry->data.offset - data_bytes; + memmove(start, end, length); + + // Update all entry indices to account for shift + camera_metadata_buffer_entry_t *e = get_entries(dst); + size_t i; + for (i = 0; i < dst->entry_count; i++) { + if (calculate_camera_metadata_entry_data_size( + e->type, e->count) > 0 && + e->data.offset > entry->data.offset) { + e->data.offset -= data_bytes; + } + ++e; + } + dst->data_count -= data_bytes; + } + // Shift entry array + memmove(entry, entry + 1, + sizeof(camera_metadata_buffer_entry_t) * + (dst->entry_count - index - 1) ); + dst->entry_count -= 1; + + assert(validate_camera_metadata_structure(dst, NULL) == OK); + return OK; +} + +int update_camera_metadata_entry(camera_metadata_t *dst, + size_t index, + const void *data, + size_t data_count, + camera_metadata_entry_t *updated_entry) { + if (dst == NULL) return ERROR; + if (index >= dst->entry_count) return ERROR; + + camera_metadata_buffer_entry_t *entry = get_entries(dst) + index; + + size_t data_bytes = + calculate_camera_metadata_entry_data_size(entry->type, + data_count); + size_t data_payload_bytes = + data_count * camera_metadata_type_size[entry->type]; + + size_t entry_bytes = + calculate_camera_metadata_entry_data_size(entry->type, + entry->count); + if (data_bytes != entry_bytes) { + // May need to shift/add to data array + if (dst->data_capacity < dst->data_count + data_bytes - entry_bytes) { + // No room + return ERROR; + } + if (entry_bytes != 0) { + // Remove old data + uint8_t *start = get_data(dst) + entry->data.offset; + uint8_t *end = start + entry_bytes; + size_t length = dst->data_count - entry->data.offset - entry_bytes; + memmove(start, end, length); + dst->data_count -= entry_bytes; + + // Update all entry indices to account for shift + camera_metadata_buffer_entry_t *e = get_entries(dst); + size_t i; + for (i = 0; i < dst->entry_count; i++) { + if (calculate_camera_metadata_entry_data_size( + e->type, e->count) > 0 && + e->data.offset > entry->data.offset) { + e->data.offset -= entry_bytes; + } + ++e; + } + } + + if (data_bytes != 0) { + // Append new data + entry->data.offset = dst->data_count; + + memcpy(get_data(dst) + entry->data.offset, data, data_payload_bytes); + dst->data_count += data_bytes; + } + } else if (data_bytes != 0) { + // data size unchanged, reuse same data location + memcpy(get_data(dst) + entry->data.offset, data, data_payload_bytes); + } + + if (data_bytes == 0) { + // Data fits into entry + memcpy(entry->data.value, data, + data_payload_bytes); + } + + entry->count = data_count; + + if (updated_entry != NULL) { + get_camera_metadata_entry(dst, + index, + updated_entry); + } + + assert(validate_camera_metadata_structure(dst, NULL) == OK); + return OK; +} + +static const vendor_tag_ops_t *vendor_tag_ops = NULL; +static const struct vendor_tag_cache_ops *vendor_cache_ops = NULL; + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +const char *get_local_camera_metadata_section_name_vendor_id(uint32_t tag, + metadata_vendor_id_t id) { + uint32_t tag_section = tag >> 16; + if (tag_section >= VENDOR_SECTION && vendor_cache_ops != NULL && + id != CAMERA_METADATA_INVALID_VENDOR_ID) { + return vendor_cache_ops->get_section_name(tag, id); + } else if (tag_section >= VENDOR_SECTION && vendor_tag_ops != NULL) { + return vendor_tag_ops->get_section_name( + vendor_tag_ops, + tag); + } + if (tag_section >= ANDROID_SECTION_COUNT) { + return NULL; + } + return camera_metadata_section_names[tag_section]; +} + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +const char *get_local_camera_metadata_tag_name_vendor_id(uint32_t tag, + metadata_vendor_id_t id) { + uint32_t tag_section = tag >> 16; + if (tag_section >= VENDOR_SECTION && vendor_cache_ops != NULL && + id != CAMERA_METADATA_INVALID_VENDOR_ID) { + return vendor_cache_ops->get_tag_name(tag, id); + } else if (tag_section >= VENDOR_SECTION && vendor_tag_ops != NULL) { + return vendor_tag_ops->get_tag_name( + vendor_tag_ops, + tag); + } + if (tag_section >= ANDROID_SECTION_COUNT || + tag >= camera_metadata_section_bounds[tag_section][1] ) { + return NULL; + } + uint32_t tag_index = tag & 0xFFFF; + return tag_info[tag_section][tag_index].tag_name; +} + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +int get_local_camera_metadata_tag_type_vendor_id(uint32_t tag, + metadata_vendor_id_t id) { + uint32_t tag_section = tag >> 16; + if (tag_section >= VENDOR_SECTION && vendor_cache_ops != NULL && + id != CAMERA_METADATA_INVALID_VENDOR_ID) { + return vendor_cache_ops->get_tag_type(tag, id); + } else if (tag_section >= VENDOR_SECTION && vendor_tag_ops != NULL) { + return vendor_tag_ops->get_tag_type( + vendor_tag_ops, + tag); + } + if (tag_section >= ANDROID_SECTION_COUNT || + tag >= camera_metadata_section_bounds[tag_section][1] ) { + return -1; + } + uint32_t tag_index = tag & 0xFFFF; + return tag_info[tag_section][tag_index].tag_type; +} + +const char *get_camera_metadata_section_name(uint32_t tag) { + return get_local_camera_metadata_section_name(tag, NULL); +} + +const char *get_camera_metadata_tag_name(uint32_t tag) { + return get_local_camera_metadata_tag_name(tag, NULL); +} + +int get_camera_metadata_tag_type(uint32_t tag) { + return get_local_camera_metadata_tag_type(tag, NULL); +} + +const char *get_local_camera_metadata_section_name(uint32_t tag, + const camera_metadata_t *meta) { + metadata_vendor_id_t id = (NULL == meta) ? CAMERA_METADATA_INVALID_VENDOR_ID : + meta->vendor_id; + + return get_local_camera_metadata_section_name_vendor_id(tag, id); +} + +const char *get_local_camera_metadata_tag_name(uint32_t tag, + const camera_metadata_t *meta) { + metadata_vendor_id_t id = (NULL == meta) ? CAMERA_METADATA_INVALID_VENDOR_ID : + meta->vendor_id; + + return get_local_camera_metadata_tag_name_vendor_id(tag, id); +} + +int get_local_camera_metadata_tag_type(uint32_t tag, + const camera_metadata_t *meta) { + metadata_vendor_id_t id = (NULL == meta) ? CAMERA_METADATA_INVALID_VENDOR_ID : + meta->vendor_id; + + return get_local_camera_metadata_tag_type_vendor_id(tag, id); +} + +int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t* ops) { + // **DEPRECATED** + (void) ops; + ALOGE("%s: This function has been deprecated", __FUNCTION__); + return ERROR; +} + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +int set_camera_metadata_vendor_ops(const vendor_tag_ops_t* ops) { + vendor_tag_ops = ops; + return OK; +} + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +int set_camera_metadata_vendor_cache_ops( + const struct vendor_tag_cache_ops *query_cache_ops) { + vendor_cache_ops = query_cache_ops; + return OK; +} + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +void set_camera_metadata_vendor_id(camera_metadata_t *meta, + metadata_vendor_id_t id) { + if (NULL != meta) { + meta->vendor_id = id; + } +} + +// Declared in system/media/private/camera/include/camera_metadata_hidden.h +metadata_vendor_id_t get_camera_metadata_vendor_id( + const camera_metadata_t *meta) { + metadata_vendor_id_t ret = CAMERA_METADATA_INVALID_VENDOR_ID; + + if (NULL != meta) { + ret = meta->vendor_id; + } + + return ret; +} + +static void print_data(int fd, const uint8_t *data_ptr, uint32_t tag, int type, + int count, + int indentation); + +void dump_camera_metadata(const camera_metadata_t *metadata, + int fd, + int verbosity) { + dump_indented_camera_metadata(metadata, fd, verbosity, 0); +} + +void dump_indented_camera_metadata(const camera_metadata_t *metadata, + int fd, + int verbosity, + int indentation) { + if (metadata == NULL) { + dprintf(fd, "%*sDumping camera metadata array: Not allocated\n", + indentation, ""); + return; + } + unsigned int i; + dprintf(fd, + "%*sDumping camera metadata array: %" PRIu32 " / %" PRIu32 " entries, " + "%" PRIu32 " / %" PRIu32 " bytes of extra data.\n", indentation, "", + metadata->entry_count, metadata->entry_capacity, + metadata->data_count, metadata->data_capacity); + dprintf(fd, "%*sVersion: %d, Flags: %08x\n", + indentation + 2, "", + metadata->version, metadata->flags); + camera_metadata_buffer_entry_t *entry = get_entries(metadata); + for (i=0; i < metadata->entry_count; i++, entry++) { + + const char *tag_name, *tag_section; + tag_section = get_local_camera_metadata_section_name(entry->tag, metadata); + if (tag_section == NULL) { + tag_section = "unknownSection"; + } + tag_name = get_local_camera_metadata_tag_name(entry->tag, metadata); + if (tag_name == NULL) { + tag_name = "unknownTag"; + } + const char *type_name; + if (entry->type >= NUM_TYPES) { + type_name = "unknown"; + } else { + type_name = camera_metadata_type_names[entry->type]; + } + dprintf(fd, "%*s%s.%s (%05x): %s[%" PRIu32 "]\n", + indentation + 2, "", + tag_section, + tag_name, + entry->tag, + type_name, + entry->count); + + if (verbosity < 1) continue; + + if (entry->type >= NUM_TYPES) continue; + + size_t type_size = camera_metadata_type_size[entry->type]; + uint8_t *data_ptr; + if ( type_size * entry->count > 4 ) { + if (entry->data.offset >= metadata->data_count) { + ALOGE("%s: Malformed entry data offset: %" PRIu32 " (max %" PRIu32 ")", + __FUNCTION__, + entry->data.offset, + metadata->data_count); + continue; + } + data_ptr = get_data(metadata) + entry->data.offset; + } else { + data_ptr = entry->data.value; + } + int count = entry->count; + if (verbosity < 2 && count > 16) count = 16; + + print_data(fd, data_ptr, entry->tag, entry->type, count, indentation); + } +} + +static void print_data(int fd, const uint8_t *data_ptr, uint32_t tag, + int type, int count, int indentation) { + static int values_per_line[NUM_TYPES] = { + [TYPE_BYTE] = 16, + [TYPE_INT32] = 4, + [TYPE_FLOAT] = 8, + [TYPE_INT64] = 2, + [TYPE_DOUBLE] = 4, + [TYPE_RATIONAL] = 2, + }; + size_t type_size = camera_metadata_type_size[type]; + char value_string_tmp[CAMERA_METADATA_ENUM_STRING_MAX_SIZE]; + uint32_t value; + + int lines = count / values_per_line[type]; + if (count % values_per_line[type] != 0) lines++; + + int index = 0; + int j, k; + for (j = 0; j < lines; j++) { + dprintf(fd, "%*s[", indentation + 4, ""); + for (k = 0; + k < values_per_line[type] && count > 0; + k++, count--, index += type_size) { + + switch (type) { + case TYPE_BYTE: + value = *(data_ptr + index); + if (camera_metadata_enum_snprint(tag, + value, + value_string_tmp, + sizeof(value_string_tmp)) + == OK) { + dprintf(fd, "%s ", value_string_tmp); + } else { + dprintf(fd, "%hhu ", + *(data_ptr + index)); + } + break; + case TYPE_INT32: + value = + *(int32_t*)(data_ptr + index); + if (camera_metadata_enum_snprint(tag, + value, + value_string_tmp, + sizeof(value_string_tmp)) + == OK) { + dprintf(fd, "%s ", value_string_tmp); + } else { + dprintf(fd, "%" PRId32 " ", + *(int32_t*)(data_ptr + index)); + } + break; + case TYPE_FLOAT: + dprintf(fd, "%0.8f ", + *(float*)(data_ptr + index)); + break; + case TYPE_INT64: + dprintf(fd, "%" PRId64 " ", + *(int64_t*)(data_ptr + index)); + break; + case TYPE_DOUBLE: + dprintf(fd, "%0.8f ", + *(double*)(data_ptr + index)); + break; + case TYPE_RATIONAL: { + int32_t numerator = *(int32_t*)(data_ptr + index); + int32_t denominator = *(int32_t*)(data_ptr + index + 4); + dprintf(fd, "(%d / %d) ", + numerator, denominator); + break; + } + default: + dprintf(fd, "??? "); + } + } + dprintf(fd, "]\n"); + } +} diff --git a/src/android/metadata/camera_metadata_tag_info.c b/src/android/metadata/camera_metadata_tag_info.c new file mode 100644 index 000000000000..75ad1f4ca244 --- /dev/null +++ b/src/android/metadata/camera_metadata_tag_info.c @@ -0,0 +1,2811 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * !! Do not reference this file directly !! + * + * It is logically a part of camera_metadata.c. It is broken out for ease of + * maintaining the tag info. + * + * Array assignments are done using specified-index syntax to keep things in + * sync with camera_metadata_tags.h + */ + +/** + * ! Do not edit this file directly ! + * + * Generated automatically from camera_metadata_tag_info.mako + */ + +const char *camera_metadata_section_names[ANDROID_SECTION_COUNT] = { + [ANDROID_COLOR_CORRECTION] = "android.colorCorrection", + [ANDROID_CONTROL] = "android.control", + [ANDROID_DEMOSAIC] = "android.demosaic", + [ANDROID_EDGE] = "android.edge", + [ANDROID_FLASH] = "android.flash", + [ANDROID_FLASH_INFO] = "android.flash.info", + [ANDROID_HOT_PIXEL] = "android.hotPixel", + [ANDROID_JPEG] = "android.jpeg", + [ANDROID_LENS] = "android.lens", + [ANDROID_LENS_INFO] = "android.lens.info", + [ANDROID_NOISE_REDUCTION] = "android.noiseReduction", + [ANDROID_QUIRKS] = "android.quirks", + [ANDROID_REQUEST] = "android.request", + [ANDROID_SCALER] = "android.scaler", + [ANDROID_SENSOR] = "android.sensor", + [ANDROID_SENSOR_INFO] = "android.sensor.info", + [ANDROID_SHADING] = "android.shading", + [ANDROID_STATISTICS] = "android.statistics", + [ANDROID_STATISTICS_INFO] = "android.statistics.info", + [ANDROID_TONEMAP] = "android.tonemap", + [ANDROID_LED] = "android.led", + [ANDROID_INFO] = "android.info", + [ANDROID_BLACK_LEVEL] = "android.blackLevel", + [ANDROID_SYNC] = "android.sync", + [ANDROID_REPROCESS] = "android.reprocess", + [ANDROID_DEPTH] = "android.depth", + [ANDROID_LOGICAL_MULTI_CAMERA] = "android.logicalMultiCamera", + [ANDROID_DISTORTION_CORRECTION] + = "android.distortionCorrection", +}; + +unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2] = { + [ANDROID_COLOR_CORRECTION] = { ANDROID_COLOR_CORRECTION_START, + ANDROID_COLOR_CORRECTION_END }, + [ANDROID_CONTROL] = { ANDROID_CONTROL_START, + ANDROID_CONTROL_END }, + [ANDROID_DEMOSAIC] = { ANDROID_DEMOSAIC_START, + ANDROID_DEMOSAIC_END }, + [ANDROID_EDGE] = { ANDROID_EDGE_START, + ANDROID_EDGE_END }, + [ANDROID_FLASH] = { ANDROID_FLASH_START, + ANDROID_FLASH_END }, + [ANDROID_FLASH_INFO] = { ANDROID_FLASH_INFO_START, + ANDROID_FLASH_INFO_END }, + [ANDROID_HOT_PIXEL] = { ANDROID_HOT_PIXEL_START, + ANDROID_HOT_PIXEL_END }, + [ANDROID_JPEG] = { ANDROID_JPEG_START, + ANDROID_JPEG_END }, + [ANDROID_LENS] = { ANDROID_LENS_START, + ANDROID_LENS_END }, + [ANDROID_LENS_INFO] = { ANDROID_LENS_INFO_START, + ANDROID_LENS_INFO_END }, + [ANDROID_NOISE_REDUCTION] = { ANDROID_NOISE_REDUCTION_START, + ANDROID_NOISE_REDUCTION_END }, + [ANDROID_QUIRKS] = { ANDROID_QUIRKS_START, + ANDROID_QUIRKS_END }, + [ANDROID_REQUEST] = { ANDROID_REQUEST_START, + ANDROID_REQUEST_END }, + [ANDROID_SCALER] = { ANDROID_SCALER_START, + ANDROID_SCALER_END }, + [ANDROID_SENSOR] = { ANDROID_SENSOR_START, + ANDROID_SENSOR_END }, + [ANDROID_SENSOR_INFO] = { ANDROID_SENSOR_INFO_START, + ANDROID_SENSOR_INFO_END }, + [ANDROID_SHADING] = { ANDROID_SHADING_START, + ANDROID_SHADING_END }, + [ANDROID_STATISTICS] = { ANDROID_STATISTICS_START, + ANDROID_STATISTICS_END }, + [ANDROID_STATISTICS_INFO] = { ANDROID_STATISTICS_INFO_START, + ANDROID_STATISTICS_INFO_END }, + [ANDROID_TONEMAP] = { ANDROID_TONEMAP_START, + ANDROID_TONEMAP_END }, + [ANDROID_LED] = { ANDROID_LED_START, + ANDROID_LED_END }, + [ANDROID_INFO] = { ANDROID_INFO_START, + ANDROID_INFO_END }, + [ANDROID_BLACK_LEVEL] = { ANDROID_BLACK_LEVEL_START, + ANDROID_BLACK_LEVEL_END }, + [ANDROID_SYNC] = { ANDROID_SYNC_START, + ANDROID_SYNC_END }, + [ANDROID_REPROCESS] = { ANDROID_REPROCESS_START, + ANDROID_REPROCESS_END }, + [ANDROID_DEPTH] = { ANDROID_DEPTH_START, + ANDROID_DEPTH_END }, + [ANDROID_LOGICAL_MULTI_CAMERA] = { ANDROID_LOGICAL_MULTI_CAMERA_START, + ANDROID_LOGICAL_MULTI_CAMERA_END }, + [ANDROID_DISTORTION_CORRECTION] + = { ANDROID_DISTORTION_CORRECTION_START, + ANDROID_DISTORTION_CORRECTION_END }, +}; + +static tag_info_t android_color_correction[ANDROID_COLOR_CORRECTION_END - + ANDROID_COLOR_CORRECTION_START] = { + [ ANDROID_COLOR_CORRECTION_MODE - ANDROID_COLOR_CORRECTION_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_COLOR_CORRECTION_TRANSFORM - ANDROID_COLOR_CORRECTION_START ] = + { "transform", TYPE_RATIONAL + }, + [ ANDROID_COLOR_CORRECTION_GAINS - ANDROID_COLOR_CORRECTION_START ] = + { "gains", TYPE_FLOAT }, + [ ANDROID_COLOR_CORRECTION_ABERRATION_MODE - ANDROID_COLOR_CORRECTION_START ] = + { "aberrationMode", TYPE_BYTE }, + [ ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES - ANDROID_COLOR_CORRECTION_START ] = + { "availableAberrationModes", TYPE_BYTE }, +}; + +static tag_info_t android_control[ANDROID_CONTROL_END - + ANDROID_CONTROL_START] = { + [ ANDROID_CONTROL_AE_ANTIBANDING_MODE - ANDROID_CONTROL_START ] = + { "aeAntibandingMode", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION - ANDROID_CONTROL_START ] = + { "aeExposureCompensation", TYPE_INT32 }, + [ ANDROID_CONTROL_AE_LOCK - ANDROID_CONTROL_START ] = + { "aeLock", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_MODE - ANDROID_CONTROL_START ] = + { "aeMode", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_REGIONS - ANDROID_CONTROL_START ] = + { "aeRegions", TYPE_INT32 }, + [ ANDROID_CONTROL_AE_TARGET_FPS_RANGE - ANDROID_CONTROL_START ] = + { "aeTargetFpsRange", TYPE_INT32 }, + [ ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER - ANDROID_CONTROL_START ] = + { "aePrecaptureTrigger", TYPE_BYTE }, + [ ANDROID_CONTROL_AF_MODE - ANDROID_CONTROL_START ] = + { "afMode", TYPE_BYTE }, + [ ANDROID_CONTROL_AF_REGIONS - ANDROID_CONTROL_START ] = + { "afRegions", TYPE_INT32 }, + [ ANDROID_CONTROL_AF_TRIGGER - ANDROID_CONTROL_START ] = + { "afTrigger", TYPE_BYTE }, + [ ANDROID_CONTROL_AWB_LOCK - ANDROID_CONTROL_START ] = + { "awbLock", TYPE_BYTE }, + [ ANDROID_CONTROL_AWB_MODE - ANDROID_CONTROL_START ] = + { "awbMode", TYPE_BYTE }, + [ ANDROID_CONTROL_AWB_REGIONS - ANDROID_CONTROL_START ] = + { "awbRegions", TYPE_INT32 }, + [ ANDROID_CONTROL_CAPTURE_INTENT - ANDROID_CONTROL_START ] = + { "captureIntent", TYPE_BYTE }, + [ ANDROID_CONTROL_EFFECT_MODE - ANDROID_CONTROL_START ] = + { "effectMode", TYPE_BYTE }, + [ ANDROID_CONTROL_MODE - ANDROID_CONTROL_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_CONTROL_SCENE_MODE - ANDROID_CONTROL_START ] = + { "sceneMode", TYPE_BYTE }, + [ ANDROID_CONTROL_VIDEO_STABILIZATION_MODE - ANDROID_CONTROL_START ] = + { "videoStabilizationMode", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES - ANDROID_CONTROL_START ] = + { "aeAvailableAntibandingModes", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_AVAILABLE_MODES - ANDROID_CONTROL_START ] = + { "aeAvailableModes", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES - ANDROID_CONTROL_START ] = + { "aeAvailableTargetFpsRanges", TYPE_INT32 }, + [ ANDROID_CONTROL_AE_COMPENSATION_RANGE - ANDROID_CONTROL_START ] = + { "aeCompensationRange", TYPE_INT32 }, + [ ANDROID_CONTROL_AE_COMPENSATION_STEP - ANDROID_CONTROL_START ] = + { "aeCompensationStep", TYPE_RATIONAL + }, + [ ANDROID_CONTROL_AF_AVAILABLE_MODES - ANDROID_CONTROL_START ] = + { "afAvailableModes", TYPE_BYTE }, + [ ANDROID_CONTROL_AVAILABLE_EFFECTS - ANDROID_CONTROL_START ] = + { "availableEffects", TYPE_BYTE }, + [ ANDROID_CONTROL_AVAILABLE_SCENE_MODES - ANDROID_CONTROL_START ] = + { "availableSceneModes", TYPE_BYTE }, + [ ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES - ANDROID_CONTROL_START ] = + { "availableVideoStabilizationModes", + TYPE_BYTE }, + [ ANDROID_CONTROL_AWB_AVAILABLE_MODES - ANDROID_CONTROL_START ] = + { "awbAvailableModes", TYPE_BYTE }, + [ ANDROID_CONTROL_MAX_REGIONS - ANDROID_CONTROL_START ] = + { "maxRegions", TYPE_INT32 }, + [ ANDROID_CONTROL_SCENE_MODE_OVERRIDES - ANDROID_CONTROL_START ] = + { "sceneModeOverrides", TYPE_BYTE }, + [ ANDROID_CONTROL_AE_PRECAPTURE_ID - ANDROID_CONTROL_START ] = + { "aePrecaptureId", TYPE_INT32 }, + [ ANDROID_CONTROL_AE_STATE - ANDROID_CONTROL_START ] = + { "aeState", TYPE_BYTE }, + [ ANDROID_CONTROL_AF_STATE - ANDROID_CONTROL_START ] = + { "afState", TYPE_BYTE }, + [ ANDROID_CONTROL_AF_TRIGGER_ID - ANDROID_CONTROL_START ] = + { "afTriggerId", TYPE_INT32 }, + [ ANDROID_CONTROL_AWB_STATE - ANDROID_CONTROL_START ] = + { "awbState", TYPE_BYTE }, + [ ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS - ANDROID_CONTROL_START ] = + { "availableHighSpeedVideoConfigurations", + TYPE_INT32 }, + [ ANDROID_CONTROL_AE_LOCK_AVAILABLE - ANDROID_CONTROL_START ] = + { "aeLockAvailable", TYPE_BYTE }, + [ ANDROID_CONTROL_AWB_LOCK_AVAILABLE - ANDROID_CONTROL_START ] = + { "awbLockAvailable", TYPE_BYTE }, + [ ANDROID_CONTROL_AVAILABLE_MODES - ANDROID_CONTROL_START ] = + { "availableModes", TYPE_BYTE }, + [ ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE - ANDROID_CONTROL_START ] = + { "postRawSensitivityBoostRange", TYPE_INT32 }, + [ ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST - ANDROID_CONTROL_START ] = + { "postRawSensitivityBoost", TYPE_INT32 }, + [ ANDROID_CONTROL_ENABLE_ZSL - ANDROID_CONTROL_START ] = + { "enableZsl", TYPE_BYTE }, + [ ANDROID_CONTROL_AF_SCENE_CHANGE - ANDROID_CONTROL_START ] = + { "afSceneChange", TYPE_BYTE }, +}; + +static tag_info_t android_demosaic[ANDROID_DEMOSAIC_END - + ANDROID_DEMOSAIC_START] = { + [ ANDROID_DEMOSAIC_MODE - ANDROID_DEMOSAIC_START ] = + { "mode", TYPE_BYTE }, +}; + +static tag_info_t android_edge[ANDROID_EDGE_END - + ANDROID_EDGE_START] = { + [ ANDROID_EDGE_MODE - ANDROID_EDGE_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_EDGE_STRENGTH - ANDROID_EDGE_START ] = + { "strength", TYPE_BYTE }, + [ ANDROID_EDGE_AVAILABLE_EDGE_MODES - ANDROID_EDGE_START ] = + { "availableEdgeModes", TYPE_BYTE }, +}; + +static tag_info_t android_flash[ANDROID_FLASH_END - + ANDROID_FLASH_START] = { + [ ANDROID_FLASH_FIRING_POWER - ANDROID_FLASH_START ] = + { "firingPower", TYPE_BYTE }, + [ ANDROID_FLASH_FIRING_TIME - ANDROID_FLASH_START ] = + { "firingTime", TYPE_INT64 }, + [ ANDROID_FLASH_MODE - ANDROID_FLASH_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_FLASH_COLOR_TEMPERATURE - ANDROID_FLASH_START ] = + { "colorTemperature", TYPE_BYTE }, + [ ANDROID_FLASH_MAX_ENERGY - ANDROID_FLASH_START ] = + { "maxEnergy", TYPE_BYTE }, + [ ANDROID_FLASH_STATE - ANDROID_FLASH_START ] = + { "state", TYPE_BYTE }, +}; + +static tag_info_t android_flash_info[ANDROID_FLASH_INFO_END - + ANDROID_FLASH_INFO_START] = { + [ ANDROID_FLASH_INFO_AVAILABLE - ANDROID_FLASH_INFO_START ] = + { "available", TYPE_BYTE }, + [ ANDROID_FLASH_INFO_CHARGE_DURATION - ANDROID_FLASH_INFO_START ] = + { "chargeDuration", TYPE_INT64 }, +}; + +static tag_info_t android_hot_pixel[ANDROID_HOT_PIXEL_END - + ANDROID_HOT_PIXEL_START] = { + [ ANDROID_HOT_PIXEL_MODE - ANDROID_HOT_PIXEL_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES - ANDROID_HOT_PIXEL_START ] = + { "availableHotPixelModes", TYPE_BYTE }, +}; + +static tag_info_t android_jpeg[ANDROID_JPEG_END - + ANDROID_JPEG_START] = { + [ ANDROID_JPEG_GPS_COORDINATES - ANDROID_JPEG_START ] = + { "gpsCoordinates", TYPE_DOUBLE }, + [ ANDROID_JPEG_GPS_PROCESSING_METHOD - ANDROID_JPEG_START ] = + { "gpsProcessingMethod", TYPE_BYTE }, + [ ANDROID_JPEG_GPS_TIMESTAMP - ANDROID_JPEG_START ] = + { "gpsTimestamp", TYPE_INT64 }, + [ ANDROID_JPEG_ORIENTATION - ANDROID_JPEG_START ] = + { "orientation", TYPE_INT32 }, + [ ANDROID_JPEG_QUALITY - ANDROID_JPEG_START ] = + { "quality", TYPE_BYTE }, + [ ANDROID_JPEG_THUMBNAIL_QUALITY - ANDROID_JPEG_START ] = + { "thumbnailQuality", TYPE_BYTE }, + [ ANDROID_JPEG_THUMBNAIL_SIZE - ANDROID_JPEG_START ] = + { "thumbnailSize", TYPE_INT32 }, + [ ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES - ANDROID_JPEG_START ] = + { "availableThumbnailSizes", TYPE_INT32 }, + [ ANDROID_JPEG_MAX_SIZE - ANDROID_JPEG_START ] = + { "maxSize", TYPE_INT32 }, + [ ANDROID_JPEG_SIZE - ANDROID_JPEG_START ] = + { "size", TYPE_INT32 }, +}; + +static tag_info_t android_lens[ANDROID_LENS_END - + ANDROID_LENS_START] = { + [ ANDROID_LENS_APERTURE - ANDROID_LENS_START ] = + { "aperture", TYPE_FLOAT }, + [ ANDROID_LENS_FILTER_DENSITY - ANDROID_LENS_START ] = + { "filterDensity", TYPE_FLOAT }, + [ ANDROID_LENS_FOCAL_LENGTH - ANDROID_LENS_START ] = + { "focalLength", TYPE_FLOAT }, + [ ANDROID_LENS_FOCUS_DISTANCE - ANDROID_LENS_START ] = + { "focusDistance", TYPE_FLOAT }, + [ ANDROID_LENS_OPTICAL_STABILIZATION_MODE - ANDROID_LENS_START ] = + { "opticalStabilizationMode", TYPE_BYTE }, + [ ANDROID_LENS_FACING - ANDROID_LENS_START ] = + { "facing", TYPE_BYTE }, + [ ANDROID_LENS_POSE_ROTATION - ANDROID_LENS_START ] = + { "poseRotation", TYPE_FLOAT }, + [ ANDROID_LENS_POSE_TRANSLATION - ANDROID_LENS_START ] = + { "poseTranslation", TYPE_FLOAT }, + [ ANDROID_LENS_FOCUS_RANGE - ANDROID_LENS_START ] = + { "focusRange", TYPE_FLOAT }, + [ ANDROID_LENS_STATE - ANDROID_LENS_START ] = + { "state", TYPE_BYTE }, + [ ANDROID_LENS_INTRINSIC_CALIBRATION - ANDROID_LENS_START ] = + { "intrinsicCalibration", TYPE_FLOAT }, + [ ANDROID_LENS_RADIAL_DISTORTION - ANDROID_LENS_START ] = + { "radialDistortion", TYPE_FLOAT }, + [ ANDROID_LENS_POSE_REFERENCE - ANDROID_LENS_START ] = + { "poseReference", TYPE_BYTE }, + [ ANDROID_LENS_DISTORTION - ANDROID_LENS_START ] = + { "distortion", TYPE_FLOAT }, +}; + +static tag_info_t android_lens_info[ANDROID_LENS_INFO_END - + ANDROID_LENS_INFO_START] = { + [ ANDROID_LENS_INFO_AVAILABLE_APERTURES - ANDROID_LENS_INFO_START ] = + { "availableApertures", TYPE_FLOAT }, + [ ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES - ANDROID_LENS_INFO_START ] = + { "availableFilterDensities", TYPE_FLOAT }, + [ ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS - ANDROID_LENS_INFO_START ] = + { "availableFocalLengths", TYPE_FLOAT }, + [ ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION - ANDROID_LENS_INFO_START ] = + { "availableOpticalStabilization", TYPE_BYTE }, + [ ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE - ANDROID_LENS_INFO_START ] = + { "hyperfocalDistance", TYPE_FLOAT }, + [ ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE - ANDROID_LENS_INFO_START ] = + { "minimumFocusDistance", TYPE_FLOAT }, + [ ANDROID_LENS_INFO_SHADING_MAP_SIZE - ANDROID_LENS_INFO_START ] = + { "shadingMapSize", TYPE_INT32 }, + [ ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION - ANDROID_LENS_INFO_START ] = + { "focusDistanceCalibration", TYPE_BYTE }, +}; + +static tag_info_t android_noise_reduction[ANDROID_NOISE_REDUCTION_END - + ANDROID_NOISE_REDUCTION_START] = { + [ ANDROID_NOISE_REDUCTION_MODE - ANDROID_NOISE_REDUCTION_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_NOISE_REDUCTION_STRENGTH - ANDROID_NOISE_REDUCTION_START ] = + { "strength", TYPE_BYTE }, + [ ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES - ANDROID_NOISE_REDUCTION_START ] = + { "availableNoiseReductionModes", TYPE_BYTE }, +}; + +static tag_info_t android_quirks[ANDROID_QUIRKS_END - + ANDROID_QUIRKS_START] = { + [ ANDROID_QUIRKS_METERING_CROP_REGION - ANDROID_QUIRKS_START ] = + { "meteringCropRegion", TYPE_BYTE }, + [ ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO - ANDROID_QUIRKS_START ] = + { "triggerAfWithAuto", TYPE_BYTE }, + [ ANDROID_QUIRKS_USE_ZSL_FORMAT - ANDROID_QUIRKS_START ] = + { "useZslFormat", TYPE_BYTE }, + [ ANDROID_QUIRKS_USE_PARTIAL_RESULT - ANDROID_QUIRKS_START ] = + { "usePartialResult", TYPE_BYTE }, + [ ANDROID_QUIRKS_PARTIAL_RESULT - ANDROID_QUIRKS_START ] = + { "partialResult", TYPE_BYTE }, +}; + +static tag_info_t android_request[ANDROID_REQUEST_END - + ANDROID_REQUEST_START] = { + [ ANDROID_REQUEST_FRAME_COUNT - ANDROID_REQUEST_START ] = + { "frameCount", TYPE_INT32 }, + [ ANDROID_REQUEST_ID - ANDROID_REQUEST_START ] = + { "id", TYPE_INT32 }, + [ ANDROID_REQUEST_INPUT_STREAMS - ANDROID_REQUEST_START ] = + { "inputStreams", TYPE_INT32 }, + [ ANDROID_REQUEST_METADATA_MODE - ANDROID_REQUEST_START ] = + { "metadataMode", TYPE_BYTE }, + [ ANDROID_REQUEST_OUTPUT_STREAMS - ANDROID_REQUEST_START ] = + { "outputStreams", TYPE_INT32 }, + [ ANDROID_REQUEST_TYPE - ANDROID_REQUEST_START ] = + { "type", TYPE_BYTE }, + [ ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS - ANDROID_REQUEST_START ] = + { "maxNumOutputStreams", TYPE_INT32 }, + [ ANDROID_REQUEST_MAX_NUM_REPROCESS_STREAMS - ANDROID_REQUEST_START ] = + { "maxNumReprocessStreams", TYPE_INT32 }, + [ ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS - ANDROID_REQUEST_START ] = + { "maxNumInputStreams", TYPE_INT32 }, + [ ANDROID_REQUEST_PIPELINE_DEPTH - ANDROID_REQUEST_START ] = + { "pipelineDepth", TYPE_BYTE }, + [ ANDROID_REQUEST_PIPELINE_MAX_DEPTH - ANDROID_REQUEST_START ] = + { "pipelineMaxDepth", TYPE_BYTE }, + [ ANDROID_REQUEST_PARTIAL_RESULT_COUNT - ANDROID_REQUEST_START ] = + { "partialResultCount", TYPE_INT32 }, + [ ANDROID_REQUEST_AVAILABLE_CAPABILITIES - ANDROID_REQUEST_START ] = + { "availableCapabilities", TYPE_BYTE }, + [ ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS - ANDROID_REQUEST_START ] = + { "availableRequestKeys", TYPE_INT32 }, + [ ANDROID_REQUEST_AVAILABLE_RESULT_KEYS - ANDROID_REQUEST_START ] = + { "availableResultKeys", TYPE_INT32 }, + [ ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS - ANDROID_REQUEST_START ] = + { "availableCharacteristicsKeys", TYPE_INT32 }, + [ ANDROID_REQUEST_AVAILABLE_SESSION_KEYS - ANDROID_REQUEST_START ] = + { "availableSessionKeys", TYPE_INT32 }, + [ ANDROID_REQUEST_AVAILABLE_PHYSICAL_CAMERA_REQUEST_KEYS - ANDROID_REQUEST_START ] = + { "availablePhysicalCameraRequestKeys", + TYPE_INT32 }, +}; + +static tag_info_t android_scaler[ANDROID_SCALER_END - + ANDROID_SCALER_START] = { + [ ANDROID_SCALER_CROP_REGION - ANDROID_SCALER_START ] = + { "cropRegion", TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_FORMATS - ANDROID_SCALER_START ] = + { "availableFormats", TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS - ANDROID_SCALER_START ] = + { "availableJpegMinDurations", TYPE_INT64 }, + [ ANDROID_SCALER_AVAILABLE_JPEG_SIZES - ANDROID_SCALER_START ] = + { "availableJpegSizes", TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM - ANDROID_SCALER_START ] = + { "availableMaxDigitalZoom", TYPE_FLOAT }, + [ ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS - ANDROID_SCALER_START ] = + { "availableProcessedMinDurations", + TYPE_INT64 }, + [ ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES - ANDROID_SCALER_START ] = + { "availableProcessedSizes", TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS - ANDROID_SCALER_START ] = + { "availableRawMinDurations", TYPE_INT64 }, + [ ANDROID_SCALER_AVAILABLE_RAW_SIZES - ANDROID_SCALER_START ] = + { "availableRawSizes", TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP - ANDROID_SCALER_START ] = + { "availableInputOutputFormatsMap", + TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS - ANDROID_SCALER_START ] = + { "availableStreamConfigurations", TYPE_INT32 }, + [ ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS - ANDROID_SCALER_START ] = + { "availableMinFrameDurations", TYPE_INT64 }, + [ ANDROID_SCALER_AVAILABLE_STALL_DURATIONS - ANDROID_SCALER_START ] = + { "availableStallDurations", TYPE_INT64 }, + [ ANDROID_SCALER_CROPPING_TYPE - ANDROID_SCALER_START ] = + { "croppingType", TYPE_BYTE }, +}; + +static tag_info_t android_sensor[ANDROID_SENSOR_END - + ANDROID_SENSOR_START] = { + [ ANDROID_SENSOR_EXPOSURE_TIME - ANDROID_SENSOR_START ] = + { "exposureTime", TYPE_INT64 }, + [ ANDROID_SENSOR_FRAME_DURATION - ANDROID_SENSOR_START ] = + { "frameDuration", TYPE_INT64 }, + [ ANDROID_SENSOR_SENSITIVITY - ANDROID_SENSOR_START ] = + { "sensitivity", TYPE_INT32 }, + [ ANDROID_SENSOR_REFERENCE_ILLUMINANT1 - ANDROID_SENSOR_START ] = + { "referenceIlluminant1", TYPE_BYTE }, + [ ANDROID_SENSOR_REFERENCE_ILLUMINANT2 - ANDROID_SENSOR_START ] = + { "referenceIlluminant2", TYPE_BYTE }, + [ ANDROID_SENSOR_CALIBRATION_TRANSFORM1 - ANDROID_SENSOR_START ] = + { "calibrationTransform1", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_CALIBRATION_TRANSFORM2 - ANDROID_SENSOR_START ] = + { "calibrationTransform2", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_COLOR_TRANSFORM1 - ANDROID_SENSOR_START ] = + { "colorTransform1", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_COLOR_TRANSFORM2 - ANDROID_SENSOR_START ] = + { "colorTransform2", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_FORWARD_MATRIX1 - ANDROID_SENSOR_START ] = + { "forwardMatrix1", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_FORWARD_MATRIX2 - ANDROID_SENSOR_START ] = + { "forwardMatrix2", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_BASE_GAIN_FACTOR - ANDROID_SENSOR_START ] = + { "baseGainFactor", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_BLACK_LEVEL_PATTERN - ANDROID_SENSOR_START ] = + { "blackLevelPattern", TYPE_INT32 }, + [ ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY - ANDROID_SENSOR_START ] = + { "maxAnalogSensitivity", TYPE_INT32 }, + [ ANDROID_SENSOR_ORIENTATION - ANDROID_SENSOR_START ] = + { "orientation", TYPE_INT32 }, + [ ANDROID_SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS - ANDROID_SENSOR_START ] = + { "profileHueSatMapDimensions", TYPE_INT32 }, + [ ANDROID_SENSOR_TIMESTAMP - ANDROID_SENSOR_START ] = + { "timestamp", TYPE_INT64 }, + [ ANDROID_SENSOR_TEMPERATURE - ANDROID_SENSOR_START ] = + { "temperature", TYPE_FLOAT }, + [ ANDROID_SENSOR_NEUTRAL_COLOR_POINT - ANDROID_SENSOR_START ] = + { "neutralColorPoint", TYPE_RATIONAL + }, + [ ANDROID_SENSOR_NOISE_PROFILE - ANDROID_SENSOR_START ] = + { "noiseProfile", TYPE_DOUBLE }, + [ ANDROID_SENSOR_PROFILE_HUE_SAT_MAP - ANDROID_SENSOR_START ] = + { "profileHueSatMap", TYPE_FLOAT }, + [ ANDROID_SENSOR_PROFILE_TONE_CURVE - ANDROID_SENSOR_START ] = + { "profileToneCurve", TYPE_FLOAT }, + [ ANDROID_SENSOR_GREEN_SPLIT - ANDROID_SENSOR_START ] = + { "greenSplit", TYPE_FLOAT }, + [ ANDROID_SENSOR_TEST_PATTERN_DATA - ANDROID_SENSOR_START ] = + { "testPatternData", TYPE_INT32 }, + [ ANDROID_SENSOR_TEST_PATTERN_MODE - ANDROID_SENSOR_START ] = + { "testPatternMode", TYPE_INT32 }, + [ ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES - ANDROID_SENSOR_START ] = + { "availableTestPatternModes", TYPE_INT32 }, + [ ANDROID_SENSOR_ROLLING_SHUTTER_SKEW - ANDROID_SENSOR_START ] = + { "rollingShutterSkew", TYPE_INT64 }, + [ ANDROID_SENSOR_OPTICAL_BLACK_REGIONS - ANDROID_SENSOR_START ] = + { "opticalBlackRegions", TYPE_INT32 }, + [ ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL - ANDROID_SENSOR_START ] = + { "dynamicBlackLevel", TYPE_FLOAT }, + [ ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL - ANDROID_SENSOR_START ] = + { "dynamicWhiteLevel", TYPE_INT32 }, + [ ANDROID_SENSOR_OPAQUE_RAW_SIZE - ANDROID_SENSOR_START ] = + { "opaqueRawSize", TYPE_INT32 }, +}; + +static tag_info_t android_sensor_info[ANDROID_SENSOR_INFO_END - + ANDROID_SENSOR_INFO_START] = { + [ ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE - ANDROID_SENSOR_INFO_START ] = + { "activeArraySize", TYPE_INT32 }, + [ ANDROID_SENSOR_INFO_SENSITIVITY_RANGE - ANDROID_SENSOR_INFO_START ] = + { "sensitivityRange", TYPE_INT32 }, + [ ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT - ANDROID_SENSOR_INFO_START ] = + { "colorFilterArrangement", TYPE_BYTE }, + [ ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE - ANDROID_SENSOR_INFO_START ] = + { "exposureTimeRange", TYPE_INT64 }, + [ ANDROID_SENSOR_INFO_MAX_FRAME_DURATION - ANDROID_SENSOR_INFO_START ] = + { "maxFrameDuration", TYPE_INT64 }, + [ ANDROID_SENSOR_INFO_PHYSICAL_SIZE - ANDROID_SENSOR_INFO_START ] = + { "physicalSize", TYPE_FLOAT }, + [ ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE - ANDROID_SENSOR_INFO_START ] = + { "pixelArraySize", TYPE_INT32 }, + [ ANDROID_SENSOR_INFO_WHITE_LEVEL - ANDROID_SENSOR_INFO_START ] = + { "whiteLevel", TYPE_INT32 }, + [ ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE - ANDROID_SENSOR_INFO_START ] = + { "timestampSource", TYPE_BYTE }, + [ ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED - ANDROID_SENSOR_INFO_START ] = + { "lensShadingApplied", TYPE_BYTE }, + [ ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE - ANDROID_SENSOR_INFO_START ] = + { "preCorrectionActiveArraySize", TYPE_INT32 }, +}; + +static tag_info_t android_shading[ANDROID_SHADING_END - + ANDROID_SHADING_START] = { + [ ANDROID_SHADING_MODE - ANDROID_SHADING_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_SHADING_STRENGTH - ANDROID_SHADING_START ] = + { "strength", TYPE_BYTE }, + [ ANDROID_SHADING_AVAILABLE_MODES - ANDROID_SHADING_START ] = + { "availableModes", TYPE_BYTE }, +}; + +static tag_info_t android_statistics[ANDROID_STATISTICS_END - + ANDROID_STATISTICS_START] = { + [ ANDROID_STATISTICS_FACE_DETECT_MODE - ANDROID_STATISTICS_START ] = + { "faceDetectMode", TYPE_BYTE }, + [ ANDROID_STATISTICS_HISTOGRAM_MODE - ANDROID_STATISTICS_START ] = + { "histogramMode", TYPE_BYTE }, + [ ANDROID_STATISTICS_SHARPNESS_MAP_MODE - ANDROID_STATISTICS_START ] = + { "sharpnessMapMode", TYPE_BYTE }, + [ ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE - ANDROID_STATISTICS_START ] = + { "hotPixelMapMode", TYPE_BYTE }, + [ ANDROID_STATISTICS_FACE_IDS - ANDROID_STATISTICS_START ] = + { "faceIds", TYPE_INT32 }, + [ ANDROID_STATISTICS_FACE_LANDMARKS - ANDROID_STATISTICS_START ] = + { "faceLandmarks", TYPE_INT32 }, + [ ANDROID_STATISTICS_FACE_RECTANGLES - ANDROID_STATISTICS_START ] = + { "faceRectangles", TYPE_INT32 }, + [ ANDROID_STATISTICS_FACE_SCORES - ANDROID_STATISTICS_START ] = + { "faceScores", TYPE_BYTE }, + [ ANDROID_STATISTICS_HISTOGRAM - ANDROID_STATISTICS_START ] = + { "histogram", TYPE_INT32 }, + [ ANDROID_STATISTICS_SHARPNESS_MAP - ANDROID_STATISTICS_START ] = + { "sharpnessMap", TYPE_INT32 }, + [ ANDROID_STATISTICS_LENS_SHADING_CORRECTION_MAP - ANDROID_STATISTICS_START ] = + { "lensShadingCorrectionMap", TYPE_BYTE }, + [ ANDROID_STATISTICS_LENS_SHADING_MAP - ANDROID_STATISTICS_START ] = + { "lensShadingMap", TYPE_FLOAT }, + [ ANDROID_STATISTICS_PREDICTED_COLOR_GAINS - ANDROID_STATISTICS_START ] = + { "predictedColorGains", TYPE_FLOAT }, + [ ANDROID_STATISTICS_PREDICTED_COLOR_TRANSFORM - ANDROID_STATISTICS_START ] = + { "predictedColorTransform", TYPE_RATIONAL + }, + [ ANDROID_STATISTICS_SCENE_FLICKER - ANDROID_STATISTICS_START ] = + { "sceneFlicker", TYPE_BYTE }, + [ ANDROID_STATISTICS_HOT_PIXEL_MAP - ANDROID_STATISTICS_START ] = + { "hotPixelMap", TYPE_INT32 }, + [ ANDROID_STATISTICS_LENS_SHADING_MAP_MODE - ANDROID_STATISTICS_START ] = + { "lensShadingMapMode", TYPE_BYTE }, + [ ANDROID_STATISTICS_OIS_DATA_MODE - ANDROID_STATISTICS_START ] = + { "oisDataMode", TYPE_BYTE }, + [ ANDROID_STATISTICS_OIS_TIMESTAMPS - ANDROID_STATISTICS_START ] = + { "oisTimestamps", TYPE_INT64 }, + [ ANDROID_STATISTICS_OIS_X_SHIFTS - ANDROID_STATISTICS_START ] = + { "oisXShifts", TYPE_FLOAT }, + [ ANDROID_STATISTICS_OIS_Y_SHIFTS - ANDROID_STATISTICS_START ] = + { "oisYShifts", TYPE_FLOAT }, +}; + +static tag_info_t android_statistics_info[ANDROID_STATISTICS_INFO_END - + ANDROID_STATISTICS_INFO_START] = { + [ ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES - ANDROID_STATISTICS_INFO_START ] = + { "availableFaceDetectModes", TYPE_BYTE }, + [ ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT - ANDROID_STATISTICS_INFO_START ] = + { "histogramBucketCount", TYPE_INT32 }, + [ ANDROID_STATISTICS_INFO_MAX_FACE_COUNT - ANDROID_STATISTICS_INFO_START ] = + { "maxFaceCount", TYPE_INT32 }, + [ ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT - ANDROID_STATISTICS_INFO_START ] = + { "maxHistogramCount", TYPE_INT32 }, + [ ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE - ANDROID_STATISTICS_INFO_START ] = + { "maxSharpnessMapValue", TYPE_INT32 }, + [ ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE - ANDROID_STATISTICS_INFO_START ] = + { "sharpnessMapSize", TYPE_INT32 }, + [ ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES - ANDROID_STATISTICS_INFO_START ] = + { "availableHotPixelMapModes", TYPE_BYTE }, + [ ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES - ANDROID_STATISTICS_INFO_START ] = + { "availableLensShadingMapModes", TYPE_BYTE }, + [ ANDROID_STATISTICS_INFO_AVAILABLE_OIS_DATA_MODES - ANDROID_STATISTICS_INFO_START ] = + { "availableOisDataModes", TYPE_BYTE }, +}; + +static tag_info_t android_tonemap[ANDROID_TONEMAP_END - + ANDROID_TONEMAP_START] = { + [ ANDROID_TONEMAP_CURVE_BLUE - ANDROID_TONEMAP_START ] = + { "curveBlue", TYPE_FLOAT }, + [ ANDROID_TONEMAP_CURVE_GREEN - ANDROID_TONEMAP_START ] = + { "curveGreen", TYPE_FLOAT }, + [ ANDROID_TONEMAP_CURVE_RED - ANDROID_TONEMAP_START ] = + { "curveRed", TYPE_FLOAT }, + [ ANDROID_TONEMAP_MODE - ANDROID_TONEMAP_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_TONEMAP_MAX_CURVE_POINTS - ANDROID_TONEMAP_START ] = + { "maxCurvePoints", TYPE_INT32 }, + [ ANDROID_TONEMAP_AVAILABLE_TONE_MAP_MODES - ANDROID_TONEMAP_START ] = + { "availableToneMapModes", TYPE_BYTE }, + [ ANDROID_TONEMAP_GAMMA - ANDROID_TONEMAP_START ] = + { "gamma", TYPE_FLOAT }, + [ ANDROID_TONEMAP_PRESET_CURVE - ANDROID_TONEMAP_START ] = + { "presetCurve", TYPE_BYTE }, +}; + +static tag_info_t android_led[ANDROID_LED_END - + ANDROID_LED_START] = { + [ ANDROID_LED_TRANSMIT - ANDROID_LED_START ] = + { "transmit", TYPE_BYTE }, + [ ANDROID_LED_AVAILABLE_LEDS - ANDROID_LED_START ] = + { "availableLeds", TYPE_BYTE }, +}; + +static tag_info_t android_info[ANDROID_INFO_END - + ANDROID_INFO_START] = { + [ ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL - ANDROID_INFO_START ] = + { "supportedHardwareLevel", TYPE_BYTE }, + [ ANDROID_INFO_VERSION - ANDROID_INFO_START ] = + { "version", TYPE_BYTE }, +}; + +static tag_info_t android_black_level[ANDROID_BLACK_LEVEL_END - + ANDROID_BLACK_LEVEL_START] = { + [ ANDROID_BLACK_LEVEL_LOCK - ANDROID_BLACK_LEVEL_START ] = + { "lock", TYPE_BYTE }, +}; + +static tag_info_t android_sync[ANDROID_SYNC_END - + ANDROID_SYNC_START] = { + [ ANDROID_SYNC_FRAME_NUMBER - ANDROID_SYNC_START ] = + { "frameNumber", TYPE_INT64 }, + [ ANDROID_SYNC_MAX_LATENCY - ANDROID_SYNC_START ] = + { "maxLatency", TYPE_INT32 }, +}; + +static tag_info_t android_reprocess[ANDROID_REPROCESS_END - + ANDROID_REPROCESS_START] = { + [ ANDROID_REPROCESS_EFFECTIVE_EXPOSURE_FACTOR - ANDROID_REPROCESS_START ] = + { "effectiveExposureFactor", TYPE_FLOAT }, + [ ANDROID_REPROCESS_MAX_CAPTURE_STALL - ANDROID_REPROCESS_START ] = + { "maxCaptureStall", TYPE_INT32 }, +}; + +static tag_info_t android_depth[ANDROID_DEPTH_END - + ANDROID_DEPTH_START] = { + [ ANDROID_DEPTH_MAX_DEPTH_SAMPLES - ANDROID_DEPTH_START ] = + { "maxDepthSamples", TYPE_INT32 }, + [ ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS - ANDROID_DEPTH_START ] = + { "availableDepthStreamConfigurations", + TYPE_INT32 }, + [ ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS - ANDROID_DEPTH_START ] = + { "availableDepthMinFrameDurations", + TYPE_INT64 }, + [ ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS - ANDROID_DEPTH_START ] = + { "availableDepthStallDurations", TYPE_INT64 }, + [ ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE - ANDROID_DEPTH_START ] = + { "depthIsExclusive", TYPE_BYTE }, +}; + +static tag_info_t android_logical_multi_camera[ANDROID_LOGICAL_MULTI_CAMERA_END - + ANDROID_LOGICAL_MULTI_CAMERA_START] = { + [ ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS - ANDROID_LOGICAL_MULTI_CAMERA_START ] = + { "physicalIds", TYPE_BYTE }, + [ ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE - ANDROID_LOGICAL_MULTI_CAMERA_START ] = + { "sensorSyncType", TYPE_BYTE }, +}; + +static tag_info_t android_distortion_correction[ANDROID_DISTORTION_CORRECTION_END - + ANDROID_DISTORTION_CORRECTION_START] = { + [ ANDROID_DISTORTION_CORRECTION_MODE - ANDROID_DISTORTION_CORRECTION_START ] = + { "mode", TYPE_BYTE }, + [ ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES - ANDROID_DISTORTION_CORRECTION_START ] = + { "availableModes", TYPE_BYTE }, +}; + + +tag_info_t *tag_info[ANDROID_SECTION_COUNT] = { + android_color_correction, + android_control, + android_demosaic, + android_edge, + android_flash, + android_flash_info, + android_hot_pixel, + android_jpeg, + android_lens, + android_lens_info, + android_noise_reduction, + android_quirks, + android_request, + android_scaler, + android_sensor, + android_sensor_info, + android_shading, + android_statistics, + android_statistics_info, + android_tonemap, + android_led, + android_info, + android_black_level, + android_sync, + android_reprocess, + android_depth, + android_logical_multi_camera, + android_distortion_correction, +}; + +int camera_metadata_enum_snprint(uint32_t tag, + uint32_t value, + char *dst, + size_t size) { + const char *msg = "error: not an enum"; + int ret = -1; + + switch(tag) { + case ANDROID_COLOR_CORRECTION_MODE: { + switch (value) { + case ANDROID_COLOR_CORRECTION_MODE_TRANSFORM_MATRIX: + msg = "TRANSFORM_MATRIX"; + ret = 0; + break; + case ANDROID_COLOR_CORRECTION_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_COLOR_CORRECTION_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_COLOR_CORRECTION_TRANSFORM: { + break; + } + case ANDROID_COLOR_CORRECTION_GAINS: { + break; + } + case ANDROID_COLOR_CORRECTION_ABERRATION_MODE: { + switch (value) { + case ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_COLOR_CORRECTION_ABERRATION_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_COLOR_CORRECTION_ABERRATION_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES: { + break; + } + + case ANDROID_CONTROL_AE_ANTIBANDING_MODE: { + switch (value) { + case ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ: + msg = "50HZ"; + ret = 0; + break; + case ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ: + msg = "60HZ"; + ret = 0; + break; + case ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO: + msg = "AUTO"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: { + break; + } + case ANDROID_CONTROL_AE_LOCK: { + switch (value) { + case ANDROID_CONTROL_AE_LOCK_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_AE_LOCK_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AE_MODE: { + switch (value) { + case ANDROID_CONTROL_AE_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_AE_MODE_ON: + msg = "ON"; + ret = 0; + break; + case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH: + msg = "ON_AUTO_FLASH"; + ret = 0; + break; + case ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH: + msg = "ON_ALWAYS_FLASH"; + ret = 0; + break; + case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE: + msg = "ON_AUTO_FLASH_REDEYE"; + ret = 0; + break; + case ANDROID_CONTROL_AE_MODE_ON_EXTERNAL_FLASH: + msg = "ON_EXTERNAL_FLASH"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AE_REGIONS: { + break; + } + case ANDROID_CONTROL_AE_TARGET_FPS_RANGE: { + break; + } + case ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: { + switch (value) { + case ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE: + msg = "IDLE"; + ret = 0; + break; + case ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_START: + msg = "START"; + ret = 0; + break; + case ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL: + msg = "CANCEL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AF_MODE: { + switch (value) { + case ANDROID_CONTROL_AF_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_AF_MODE_AUTO: + msg = "AUTO"; + ret = 0; + break; + case ANDROID_CONTROL_AF_MODE_MACRO: + msg = "MACRO"; + ret = 0; + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO: + msg = "CONTINUOUS_VIDEO"; + ret = 0; + break; + case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE: + msg = "CONTINUOUS_PICTURE"; + ret = 0; + break; + case ANDROID_CONTROL_AF_MODE_EDOF: + msg = "EDOF"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AF_REGIONS: { + break; + } + case ANDROID_CONTROL_AF_TRIGGER: { + switch (value) { + case ANDROID_CONTROL_AF_TRIGGER_IDLE: + msg = "IDLE"; + ret = 0; + break; + case ANDROID_CONTROL_AF_TRIGGER_START: + msg = "START"; + ret = 0; + break; + case ANDROID_CONTROL_AF_TRIGGER_CANCEL: + msg = "CANCEL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AWB_LOCK: { + switch (value) { + case ANDROID_CONTROL_AWB_LOCK_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_LOCK_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AWB_MODE: { + switch (value) { + case ANDROID_CONTROL_AWB_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_AUTO: + msg = "AUTO"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_INCANDESCENT: + msg = "INCANDESCENT"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_FLUORESCENT: + msg = "FLUORESCENT"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT: + msg = "WARM_FLUORESCENT"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_DAYLIGHT: + msg = "DAYLIGHT"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT: + msg = "CLOUDY_DAYLIGHT"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_TWILIGHT: + msg = "TWILIGHT"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_MODE_SHADE: + msg = "SHADE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AWB_REGIONS: { + break; + } + case ANDROID_CONTROL_CAPTURE_INTENT: { + switch (value) { + case ANDROID_CONTROL_CAPTURE_INTENT_CUSTOM: + msg = "CUSTOM"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW: + msg = "PREVIEW"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE: + msg = "STILL_CAPTURE"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD: + msg = "VIDEO_RECORD"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT: + msg = "VIDEO_SNAPSHOT"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG: + msg = "ZERO_SHUTTER_LAG"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_MANUAL: + msg = "MANUAL"; + ret = 0; + break; + case ANDROID_CONTROL_CAPTURE_INTENT_MOTION_TRACKING: + msg = "MOTION_TRACKING"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_EFFECT_MODE: { + switch (value) { + case ANDROID_CONTROL_EFFECT_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_MONO: + msg = "MONO"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_NEGATIVE: + msg = "NEGATIVE"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_SOLARIZE: + msg = "SOLARIZE"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_SEPIA: + msg = "SEPIA"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_POSTERIZE: + msg = "POSTERIZE"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_WHITEBOARD: + msg = "WHITEBOARD"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_BLACKBOARD: + msg = "BLACKBOARD"; + ret = 0; + break; + case ANDROID_CONTROL_EFFECT_MODE_AQUA: + msg = "AQUA"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_MODE: { + switch (value) { + case ANDROID_CONTROL_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_MODE_AUTO: + msg = "AUTO"; + ret = 0; + break; + case ANDROID_CONTROL_MODE_USE_SCENE_MODE: + msg = "USE_SCENE_MODE"; + ret = 0; + break; + case ANDROID_CONTROL_MODE_OFF_KEEP_STATE: + msg = "OFF_KEEP_STATE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_SCENE_MODE: { + switch (value) { + case ANDROID_CONTROL_SCENE_MODE_DISABLED: + msg = "DISABLED"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY: + msg = "FACE_PRIORITY"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_ACTION: + msg = "ACTION"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_PORTRAIT: + msg = "PORTRAIT"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_LANDSCAPE: + msg = "LANDSCAPE"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_NIGHT: + msg = "NIGHT"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_NIGHT_PORTRAIT: + msg = "NIGHT_PORTRAIT"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_THEATRE: + msg = "THEATRE"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_BEACH: + msg = "BEACH"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_SNOW: + msg = "SNOW"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_SUNSET: + msg = "SUNSET"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_STEADYPHOTO: + msg = "STEADYPHOTO"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_FIREWORKS: + msg = "FIREWORKS"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_SPORTS: + msg = "SPORTS"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_PARTY: + msg = "PARTY"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT: + msg = "CANDLELIGHT"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_BARCODE: + msg = "BARCODE"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_HIGH_SPEED_VIDEO: + msg = "HIGH_SPEED_VIDEO"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_HDR: + msg = "HDR"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY_LOW_LIGHT: + msg = "FACE_PRIORITY_LOW_LIGHT"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_START: + msg = "DEVICE_CUSTOM_START"; + ret = 0; + break; + case ANDROID_CONTROL_SCENE_MODE_DEVICE_CUSTOM_END: + msg = "DEVICE_CUSTOM_END"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_VIDEO_STABILIZATION_MODE: { + switch (value) { + case ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES: { + break; + } + case ANDROID_CONTROL_AE_AVAILABLE_MODES: { + break; + } + case ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES: { + break; + } + case ANDROID_CONTROL_AE_COMPENSATION_RANGE: { + break; + } + case ANDROID_CONTROL_AE_COMPENSATION_STEP: { + break; + } + case ANDROID_CONTROL_AF_AVAILABLE_MODES: { + break; + } + case ANDROID_CONTROL_AVAILABLE_EFFECTS: { + break; + } + case ANDROID_CONTROL_AVAILABLE_SCENE_MODES: { + break; + } + case ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES: { + break; + } + case ANDROID_CONTROL_AWB_AVAILABLE_MODES: { + break; + } + case ANDROID_CONTROL_MAX_REGIONS: { + break; + } + case ANDROID_CONTROL_SCENE_MODE_OVERRIDES: { + break; + } + case ANDROID_CONTROL_AE_PRECAPTURE_ID: { + break; + } + case ANDROID_CONTROL_AE_STATE: { + switch (value) { + case ANDROID_CONTROL_AE_STATE_INACTIVE: + msg = "INACTIVE"; + ret = 0; + break; + case ANDROID_CONTROL_AE_STATE_SEARCHING: + msg = "SEARCHING"; + ret = 0; + break; + case ANDROID_CONTROL_AE_STATE_CONVERGED: + msg = "CONVERGED"; + ret = 0; + break; + case ANDROID_CONTROL_AE_STATE_LOCKED: + msg = "LOCKED"; + ret = 0; + break; + case ANDROID_CONTROL_AE_STATE_FLASH_REQUIRED: + msg = "FLASH_REQUIRED"; + ret = 0; + break; + case ANDROID_CONTROL_AE_STATE_PRECAPTURE: + msg = "PRECAPTURE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AF_STATE: { + switch (value) { + case ANDROID_CONTROL_AF_STATE_INACTIVE: + msg = "INACTIVE"; + ret = 0; + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN: + msg = "PASSIVE_SCAN"; + ret = 0; + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED: + msg = "PASSIVE_FOCUSED"; + ret = 0; + break; + case ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN: + msg = "ACTIVE_SCAN"; + ret = 0; + break; + case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED: + msg = "FOCUSED_LOCKED"; + ret = 0; + break; + case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED: + msg = "NOT_FOCUSED_LOCKED"; + ret = 0; + break; + case ANDROID_CONTROL_AF_STATE_PASSIVE_UNFOCUSED: + msg = "PASSIVE_UNFOCUSED"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AF_TRIGGER_ID: { + break; + } + case ANDROID_CONTROL_AWB_STATE: { + switch (value) { + case ANDROID_CONTROL_AWB_STATE_INACTIVE: + msg = "INACTIVE"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_STATE_SEARCHING: + msg = "SEARCHING"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_STATE_CONVERGED: + msg = "CONVERGED"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_STATE_LOCKED: + msg = "LOCKED"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AVAILABLE_HIGH_SPEED_VIDEO_CONFIGURATIONS: { + break; + } + case ANDROID_CONTROL_AE_LOCK_AVAILABLE: { + switch (value) { + case ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE: + msg = "FALSE"; + ret = 0; + break; + case ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE: + msg = "TRUE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AWB_LOCK_AVAILABLE: { + switch (value) { + case ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE: + msg = "FALSE"; + ret = 0; + break; + case ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE: + msg = "TRUE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AVAILABLE_MODES: { + break; + } + case ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE: { + break; + } + case ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST: { + break; + } + case ANDROID_CONTROL_ENABLE_ZSL: { + switch (value) { + case ANDROID_CONTROL_ENABLE_ZSL_FALSE: + msg = "FALSE"; + ret = 0; + break; + case ANDROID_CONTROL_ENABLE_ZSL_TRUE: + msg = "TRUE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_CONTROL_AF_SCENE_CHANGE: { + switch (value) { + case ANDROID_CONTROL_AF_SCENE_CHANGE_NOT_DETECTED: + msg = "NOT_DETECTED"; + ret = 0; + break; + case ANDROID_CONTROL_AF_SCENE_CHANGE_DETECTED: + msg = "DETECTED"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_DEMOSAIC_MODE: { + switch (value) { + case ANDROID_DEMOSAIC_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_DEMOSAIC_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_EDGE_MODE: { + switch (value) { + case ANDROID_EDGE_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_EDGE_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_EDGE_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + case ANDROID_EDGE_MODE_ZERO_SHUTTER_LAG: + msg = "ZERO_SHUTTER_LAG"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_EDGE_STRENGTH: { + break; + } + case ANDROID_EDGE_AVAILABLE_EDGE_MODES: { + break; + } + + case ANDROID_FLASH_FIRING_POWER: { + break; + } + case ANDROID_FLASH_FIRING_TIME: { + break; + } + case ANDROID_FLASH_MODE: { + switch (value) { + case ANDROID_FLASH_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_FLASH_MODE_SINGLE: + msg = "SINGLE"; + ret = 0; + break; + case ANDROID_FLASH_MODE_TORCH: + msg = "TORCH"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_FLASH_COLOR_TEMPERATURE: { + break; + } + case ANDROID_FLASH_MAX_ENERGY: { + break; + } + case ANDROID_FLASH_STATE: { + switch (value) { + case ANDROID_FLASH_STATE_UNAVAILABLE: + msg = "UNAVAILABLE"; + ret = 0; + break; + case ANDROID_FLASH_STATE_CHARGING: + msg = "CHARGING"; + ret = 0; + break; + case ANDROID_FLASH_STATE_READY: + msg = "READY"; + ret = 0; + break; + case ANDROID_FLASH_STATE_FIRED: + msg = "FIRED"; + ret = 0; + break; + case ANDROID_FLASH_STATE_PARTIAL: + msg = "PARTIAL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_FLASH_INFO_AVAILABLE: { + switch (value) { + case ANDROID_FLASH_INFO_AVAILABLE_FALSE: + msg = "FALSE"; + ret = 0; + break; + case ANDROID_FLASH_INFO_AVAILABLE_TRUE: + msg = "TRUE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_FLASH_INFO_CHARGE_DURATION: { + break; + } + + case ANDROID_HOT_PIXEL_MODE: { + switch (value) { + case ANDROID_HOT_PIXEL_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_HOT_PIXEL_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_HOT_PIXEL_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES: { + break; + } + + case ANDROID_JPEG_GPS_COORDINATES: { + break; + } + case ANDROID_JPEG_GPS_PROCESSING_METHOD: { + break; + } + case ANDROID_JPEG_GPS_TIMESTAMP: { + break; + } + case ANDROID_JPEG_ORIENTATION: { + break; + } + case ANDROID_JPEG_QUALITY: { + break; + } + case ANDROID_JPEG_THUMBNAIL_QUALITY: { + break; + } + case ANDROID_JPEG_THUMBNAIL_SIZE: { + break; + } + case ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES: { + break; + } + case ANDROID_JPEG_MAX_SIZE: { + break; + } + case ANDROID_JPEG_SIZE: { + break; + } + + case ANDROID_LENS_APERTURE: { + break; + } + case ANDROID_LENS_FILTER_DENSITY: { + break; + } + case ANDROID_LENS_FOCAL_LENGTH: { + break; + } + case ANDROID_LENS_FOCUS_DISTANCE: { + break; + } + case ANDROID_LENS_OPTICAL_STABILIZATION_MODE: { + switch (value) { + case ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_LENS_OPTICAL_STABILIZATION_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_LENS_FACING: { + switch (value) { + case ANDROID_LENS_FACING_FRONT: + msg = "FRONT"; + ret = 0; + break; + case ANDROID_LENS_FACING_BACK: + msg = "BACK"; + ret = 0; + break; + case ANDROID_LENS_FACING_EXTERNAL: + msg = "EXTERNAL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_LENS_POSE_ROTATION: { + break; + } + case ANDROID_LENS_POSE_TRANSLATION: { + break; + } + case ANDROID_LENS_FOCUS_RANGE: { + break; + } + case ANDROID_LENS_STATE: { + switch (value) { + case ANDROID_LENS_STATE_STATIONARY: + msg = "STATIONARY"; + ret = 0; + break; + case ANDROID_LENS_STATE_MOVING: + msg = "MOVING"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_LENS_INTRINSIC_CALIBRATION: { + break; + } + case ANDROID_LENS_RADIAL_DISTORTION: { + break; + } + case ANDROID_LENS_POSE_REFERENCE: { + switch (value) { + case ANDROID_LENS_POSE_REFERENCE_PRIMARY_CAMERA: + msg = "PRIMARY_CAMERA"; + ret = 0; + break; + case ANDROID_LENS_POSE_REFERENCE_GYROSCOPE: + msg = "GYROSCOPE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_LENS_DISTORTION: { + break; + } + + case ANDROID_LENS_INFO_AVAILABLE_APERTURES: { + break; + } + case ANDROID_LENS_INFO_AVAILABLE_FILTER_DENSITIES: { + break; + } + case ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS: { + break; + } + case ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION: { + break; + } + case ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE: { + break; + } + case ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE: { + break; + } + case ANDROID_LENS_INFO_SHADING_MAP_SIZE: { + break; + } + case ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION: { + switch (value) { + case ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED: + msg = "UNCALIBRATED"; + ret = 0; + break; + case ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_APPROXIMATE: + msg = "APPROXIMATE"; + ret = 0; + break; + case ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_CALIBRATED: + msg = "CALIBRATED"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_NOISE_REDUCTION_MODE: { + switch (value) { + case ANDROID_NOISE_REDUCTION_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_NOISE_REDUCTION_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + case ANDROID_NOISE_REDUCTION_MODE_MINIMAL: + msg = "MINIMAL"; + ret = 0; + break; + case ANDROID_NOISE_REDUCTION_MODE_ZERO_SHUTTER_LAG: + msg = "ZERO_SHUTTER_LAG"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_NOISE_REDUCTION_STRENGTH: { + break; + } + case ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES: { + break; + } + + case ANDROID_QUIRKS_METERING_CROP_REGION: { + break; + } + case ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO: { + break; + } + case ANDROID_QUIRKS_USE_ZSL_FORMAT: { + break; + } + case ANDROID_QUIRKS_USE_PARTIAL_RESULT: { + break; + } + case ANDROID_QUIRKS_PARTIAL_RESULT: { + switch (value) { + case ANDROID_QUIRKS_PARTIAL_RESULT_FINAL: + msg = "FINAL"; + ret = 0; + break; + case ANDROID_QUIRKS_PARTIAL_RESULT_PARTIAL: + msg = "PARTIAL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_REQUEST_FRAME_COUNT: { + break; + } + case ANDROID_REQUEST_ID: { + break; + } + case ANDROID_REQUEST_INPUT_STREAMS: { + break; + } + case ANDROID_REQUEST_METADATA_MODE: { + switch (value) { + case ANDROID_REQUEST_METADATA_MODE_NONE: + msg = "NONE"; + ret = 0; + break; + case ANDROID_REQUEST_METADATA_MODE_FULL: + msg = "FULL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_REQUEST_OUTPUT_STREAMS: { + break; + } + case ANDROID_REQUEST_TYPE: { + switch (value) { + case ANDROID_REQUEST_TYPE_CAPTURE: + msg = "CAPTURE"; + ret = 0; + break; + case ANDROID_REQUEST_TYPE_REPROCESS: + msg = "REPROCESS"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS: { + break; + } + case ANDROID_REQUEST_MAX_NUM_REPROCESS_STREAMS: { + break; + } + case ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS: { + break; + } + case ANDROID_REQUEST_PIPELINE_DEPTH: { + break; + } + case ANDROID_REQUEST_PIPELINE_MAX_DEPTH: { + break; + } + case ANDROID_REQUEST_PARTIAL_RESULT_COUNT: { + break; + } + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES: { + switch (value) { + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE: + msg = "BACKWARD_COMPATIBLE"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR: + msg = "MANUAL_SENSOR"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING: + msg = "MANUAL_POST_PROCESSING"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW: + msg = "RAW"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING: + msg = "PRIVATE_REPROCESSING"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_READ_SENSOR_SETTINGS: + msg = "READ_SENSOR_SETTINGS"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE: + msg = "BURST_CAPTURE"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING: + msg = "YUV_REPROCESSING"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT: + msg = "DEPTH_OUTPUT"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_CONSTRAINED_HIGH_SPEED_VIDEO: + msg = "CONSTRAINED_HIGH_SPEED_VIDEO"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING: + msg = "MOTION_TRACKING"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA: + msg = "LOGICAL_MULTI_CAMERA"; + ret = 0; + break; + case ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MONOCHROME: + msg = "MONOCHROME"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS: { + break; + } + case ANDROID_REQUEST_AVAILABLE_RESULT_KEYS: { + break; + } + case ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS: { + break; + } + case ANDROID_REQUEST_AVAILABLE_SESSION_KEYS: { + break; + } + case ANDROID_REQUEST_AVAILABLE_PHYSICAL_CAMERA_REQUEST_KEYS: { + break; + } + + case ANDROID_SCALER_CROP_REGION: { + break; + } + case ANDROID_SCALER_AVAILABLE_FORMATS: { + switch (value) { + case ANDROID_SCALER_AVAILABLE_FORMATS_RAW16: + msg = "RAW16"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_FORMATS_RAW_OPAQUE: + msg = "RAW_OPAQUE"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_FORMATS_YV12: + msg = "YV12"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_FORMATS_YCrCb_420_SP: + msg = "YCrCb_420_SP"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED: + msg = "IMPLEMENTATION_DEFINED"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888: + msg = "YCbCr_420_888"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_FORMATS_BLOB: + msg = "BLOB"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SCALER_AVAILABLE_JPEG_MIN_DURATIONS: { + break; + } + case ANDROID_SCALER_AVAILABLE_JPEG_SIZES: { + break; + } + case ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM: { + break; + } + case ANDROID_SCALER_AVAILABLE_PROCESSED_MIN_DURATIONS: { + break; + } + case ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES: { + break; + } + case ANDROID_SCALER_AVAILABLE_RAW_MIN_DURATIONS: { + break; + } + case ANDROID_SCALER_AVAILABLE_RAW_SIZES: { + break; + } + case ANDROID_SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP: { + break; + } + case ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS: { + switch (value) { + case ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT: + msg = "OUTPUT"; + ret = 0; + break; + case ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT: + msg = "INPUT"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS: { + break; + } + case ANDROID_SCALER_AVAILABLE_STALL_DURATIONS: { + break; + } + case ANDROID_SCALER_CROPPING_TYPE: { + switch (value) { + case ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY: + msg = "CENTER_ONLY"; + ret = 0; + break; + case ANDROID_SCALER_CROPPING_TYPE_FREEFORM: + msg = "FREEFORM"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_SENSOR_EXPOSURE_TIME: { + break; + } + case ANDROID_SENSOR_FRAME_DURATION: { + break; + } + case ANDROID_SENSOR_SENSITIVITY: { + break; + } + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1: { + switch (value) { + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT: + msg = "DAYLIGHT"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLUORESCENT: + msg = "FLUORESCENT"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_TUNGSTEN: + msg = "TUNGSTEN"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FLASH: + msg = "FLASH"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_FINE_WEATHER: + msg = "FINE_WEATHER"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_CLOUDY_WEATHER: + msg = "CLOUDY_WEATHER"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_SHADE: + msg = "SHADE"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAYLIGHT_FLUORESCENT: + msg = "DAYLIGHT_FLUORESCENT"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_DAY_WHITE_FLUORESCENT: + msg = "DAY_WHITE_FLUORESCENT"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_COOL_WHITE_FLUORESCENT: + msg = "COOL_WHITE_FLUORESCENT"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_WHITE_FLUORESCENT: + msg = "WHITE_FLUORESCENT"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_A: + msg = "STANDARD_A"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_B: + msg = "STANDARD_B"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_STANDARD_C: + msg = "STANDARD_C"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D55: + msg = "D55"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D65: + msg = "D65"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D75: + msg = "D75"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_D50: + msg = "D50"; + ret = 0; + break; + case ANDROID_SENSOR_REFERENCE_ILLUMINANT1_ISO_STUDIO_TUNGSTEN: + msg = "ISO_STUDIO_TUNGSTEN"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SENSOR_REFERENCE_ILLUMINANT2: { + break; + } + case ANDROID_SENSOR_CALIBRATION_TRANSFORM1: { + break; + } + case ANDROID_SENSOR_CALIBRATION_TRANSFORM2: { + break; + } + case ANDROID_SENSOR_COLOR_TRANSFORM1: { + break; + } + case ANDROID_SENSOR_COLOR_TRANSFORM2: { + break; + } + case ANDROID_SENSOR_FORWARD_MATRIX1: { + break; + } + case ANDROID_SENSOR_FORWARD_MATRIX2: { + break; + } + case ANDROID_SENSOR_BASE_GAIN_FACTOR: { + break; + } + case ANDROID_SENSOR_BLACK_LEVEL_PATTERN: { + break; + } + case ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY: { + break; + } + case ANDROID_SENSOR_ORIENTATION: { + break; + } + case ANDROID_SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS: { + break; + } + case ANDROID_SENSOR_TIMESTAMP: { + break; + } + case ANDROID_SENSOR_TEMPERATURE: { + break; + } + case ANDROID_SENSOR_NEUTRAL_COLOR_POINT: { + break; + } + case ANDROID_SENSOR_NOISE_PROFILE: { + break; + } + case ANDROID_SENSOR_PROFILE_HUE_SAT_MAP: { + break; + } + case ANDROID_SENSOR_PROFILE_TONE_CURVE: { + break; + } + case ANDROID_SENSOR_GREEN_SPLIT: { + break; + } + case ANDROID_SENSOR_TEST_PATTERN_DATA: { + break; + } + case ANDROID_SENSOR_TEST_PATTERN_MODE: { + switch (value) { + case ANDROID_SENSOR_TEST_PATTERN_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_SENSOR_TEST_PATTERN_MODE_SOLID_COLOR: + msg = "SOLID_COLOR"; + ret = 0; + break; + case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS: + msg = "COLOR_BARS"; + ret = 0; + break; + case ANDROID_SENSOR_TEST_PATTERN_MODE_COLOR_BARS_FADE_TO_GRAY: + msg = "COLOR_BARS_FADE_TO_GRAY"; + ret = 0; + break; + case ANDROID_SENSOR_TEST_PATTERN_MODE_PN9: + msg = "PN9"; + ret = 0; + break; + case ANDROID_SENSOR_TEST_PATTERN_MODE_CUSTOM1: + msg = "CUSTOM1"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES: { + break; + } + case ANDROID_SENSOR_ROLLING_SHUTTER_SKEW: { + break; + } + case ANDROID_SENSOR_OPTICAL_BLACK_REGIONS: { + break; + } + case ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL: { + break; + } + case ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL: { + break; + } + case ANDROID_SENSOR_OPAQUE_RAW_SIZE: { + break; + } + + case ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE: { + break; + } + case ANDROID_SENSOR_INFO_SENSITIVITY_RANGE: { + break; + } + case ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT: { + switch (value) { + case ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGGB: + msg = "RGGB"; + ret = 0; + break; + case ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG: + msg = "GRBG"; + ret = 0; + break; + case ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GBRG: + msg = "GBRG"; + ret = 0; + break; + case ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_BGGR: + msg = "BGGR"; + ret = 0; + break; + case ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_RGB: + msg = "RGB"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE: { + break; + } + case ANDROID_SENSOR_INFO_MAX_FRAME_DURATION: { + break; + } + case ANDROID_SENSOR_INFO_PHYSICAL_SIZE: { + break; + } + case ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE: { + break; + } + case ANDROID_SENSOR_INFO_WHITE_LEVEL: { + break; + } + case ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE: { + switch (value) { + case ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN: + msg = "UNKNOWN"; + ret = 0; + break; + case ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_REALTIME: + msg = "REALTIME"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED: { + switch (value) { + case ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED_FALSE: + msg = "FALSE"; + ret = 0; + break; + case ANDROID_SENSOR_INFO_LENS_SHADING_APPLIED_TRUE: + msg = "TRUE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE: { + break; + } + + case ANDROID_SHADING_MODE: { + switch (value) { + case ANDROID_SHADING_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_SHADING_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_SHADING_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SHADING_STRENGTH: { + break; + } + case ANDROID_SHADING_AVAILABLE_MODES: { + break; + } + + case ANDROID_STATISTICS_FACE_DETECT_MODE: { + switch (value) { + case ANDROID_STATISTICS_FACE_DETECT_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE: + msg = "SIMPLE"; + ret = 0; + break; + case ANDROID_STATISTICS_FACE_DETECT_MODE_FULL: + msg = "FULL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_HISTOGRAM_MODE: { + switch (value) { + case ANDROID_STATISTICS_HISTOGRAM_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_STATISTICS_HISTOGRAM_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_SHARPNESS_MAP_MODE: { + switch (value) { + case ANDROID_STATISTICS_SHARPNESS_MAP_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_STATISTICS_SHARPNESS_MAP_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE: { + switch (value) { + case ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_FACE_IDS: { + break; + } + case ANDROID_STATISTICS_FACE_LANDMARKS: { + break; + } + case ANDROID_STATISTICS_FACE_RECTANGLES: { + break; + } + case ANDROID_STATISTICS_FACE_SCORES: { + break; + } + case ANDROID_STATISTICS_HISTOGRAM: { + break; + } + case ANDROID_STATISTICS_SHARPNESS_MAP: { + break; + } + case ANDROID_STATISTICS_LENS_SHADING_CORRECTION_MAP: { + break; + } + case ANDROID_STATISTICS_LENS_SHADING_MAP: { + break; + } + case ANDROID_STATISTICS_PREDICTED_COLOR_GAINS: { + break; + } + case ANDROID_STATISTICS_PREDICTED_COLOR_TRANSFORM: { + break; + } + case ANDROID_STATISTICS_SCENE_FLICKER: { + switch (value) { + case ANDROID_STATISTICS_SCENE_FLICKER_NONE: + msg = "NONE"; + ret = 0; + break; + case ANDROID_STATISTICS_SCENE_FLICKER_50HZ: + msg = "50HZ"; + ret = 0; + break; + case ANDROID_STATISTICS_SCENE_FLICKER_60HZ: + msg = "60HZ"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_HOT_PIXEL_MAP: { + break; + } + case ANDROID_STATISTICS_LENS_SHADING_MAP_MODE: { + switch (value) { + case ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_OIS_DATA_MODE: { + switch (value) { + case ANDROID_STATISTICS_OIS_DATA_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_STATISTICS_OIS_DATA_MODE_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_STATISTICS_OIS_TIMESTAMPS: { + break; + } + case ANDROID_STATISTICS_OIS_X_SHIFTS: { + break; + } + case ANDROID_STATISTICS_OIS_Y_SHIFTS: { + break; + } + + case ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES: { + break; + } + case ANDROID_STATISTICS_INFO_HISTOGRAM_BUCKET_COUNT: { + break; + } + case ANDROID_STATISTICS_INFO_MAX_FACE_COUNT: { + break; + } + case ANDROID_STATISTICS_INFO_MAX_HISTOGRAM_COUNT: { + break; + } + case ANDROID_STATISTICS_INFO_MAX_SHARPNESS_MAP_VALUE: { + break; + } + case ANDROID_STATISTICS_INFO_SHARPNESS_MAP_SIZE: { + break; + } + case ANDROID_STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES: { + break; + } + case ANDROID_STATISTICS_INFO_AVAILABLE_LENS_SHADING_MAP_MODES: { + break; + } + case ANDROID_STATISTICS_INFO_AVAILABLE_OIS_DATA_MODES: { + break; + } + + case ANDROID_TONEMAP_CURVE_BLUE: { + break; + } + case ANDROID_TONEMAP_CURVE_GREEN: { + break; + } + case ANDROID_TONEMAP_CURVE_RED: { + break; + } + case ANDROID_TONEMAP_MODE: { + switch (value) { + case ANDROID_TONEMAP_MODE_CONTRAST_CURVE: + msg = "CONTRAST_CURVE"; + ret = 0; + break; + case ANDROID_TONEMAP_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_TONEMAP_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + case ANDROID_TONEMAP_MODE_GAMMA_VALUE: + msg = "GAMMA_VALUE"; + ret = 0; + break; + case ANDROID_TONEMAP_MODE_PRESET_CURVE: + msg = "PRESET_CURVE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_TONEMAP_MAX_CURVE_POINTS: { + break; + } + case ANDROID_TONEMAP_AVAILABLE_TONE_MAP_MODES: { + break; + } + case ANDROID_TONEMAP_GAMMA: { + break; + } + case ANDROID_TONEMAP_PRESET_CURVE: { + switch (value) { + case ANDROID_TONEMAP_PRESET_CURVE_SRGB: + msg = "SRGB"; + ret = 0; + break; + case ANDROID_TONEMAP_PRESET_CURVE_REC709: + msg = "REC709"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_LED_TRANSMIT: { + switch (value) { + case ANDROID_LED_TRANSMIT_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_LED_TRANSMIT_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_LED_AVAILABLE_LEDS: { + switch (value) { + case ANDROID_LED_AVAILABLE_LEDS_TRANSMIT: + msg = "TRANSMIT"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL: { + switch (value) { + case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED: + msg = "LIMITED"; + ret = 0; + break; + case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL: + msg = "FULL"; + ret = 0; + break; + case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY: + msg = "LEGACY"; + ret = 0; + break; + case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3: + msg = "3"; + ret = 0; + break; + case ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL: + msg = "EXTERNAL"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_INFO_VERSION: { + break; + } + + case ANDROID_BLACK_LEVEL_LOCK: { + switch (value) { + case ANDROID_BLACK_LEVEL_LOCK_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_BLACK_LEVEL_LOCK_ON: + msg = "ON"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_SYNC_FRAME_NUMBER: { + switch (value) { + case ANDROID_SYNC_FRAME_NUMBER_CONVERGING: + msg = "CONVERGING"; + ret = 0; + break; + case ANDROID_SYNC_FRAME_NUMBER_UNKNOWN: + msg = "UNKNOWN"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_SYNC_MAX_LATENCY: { + switch (value) { + case ANDROID_SYNC_MAX_LATENCY_PER_FRAME_CONTROL: + msg = "PER_FRAME_CONTROL"; + ret = 0; + break; + case ANDROID_SYNC_MAX_LATENCY_UNKNOWN: + msg = "UNKNOWN"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_REPROCESS_EFFECTIVE_EXPOSURE_FACTOR: { + break; + } + case ANDROID_REPROCESS_MAX_CAPTURE_STALL: { + break; + } + + case ANDROID_DEPTH_MAX_DEPTH_SAMPLES: { + break; + } + case ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS: { + switch (value) { + case ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT: + msg = "OUTPUT"; + ret = 0; + break; + case ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_INPUT: + msg = "INPUT"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_DEPTH_AVAILABLE_DEPTH_MIN_FRAME_DURATIONS: { + break; + } + case ANDROID_DEPTH_AVAILABLE_DEPTH_STALL_DURATIONS: { + break; + } + case ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE: { + switch (value) { + case ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_FALSE: + msg = "FALSE"; + ret = 0; + break; + case ANDROID_DEPTH_DEPTH_IS_EXCLUSIVE_TRUE: + msg = "TRUE"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS: { + break; + } + case ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE: { + switch (value) { + case ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_APPROXIMATE: + msg = "APPROXIMATE"; + ret = 0; + break; + case ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_CALIBRATED: + msg = "CALIBRATED"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + + case ANDROID_DISTORTION_CORRECTION_MODE: { + switch (value) { + case ANDROID_DISTORTION_CORRECTION_MODE_OFF: + msg = "OFF"; + ret = 0; + break; + case ANDROID_DISTORTION_CORRECTION_MODE_FAST: + msg = "FAST"; + ret = 0; + break; + case ANDROID_DISTORTION_CORRECTION_MODE_HIGH_QUALITY: + msg = "HIGH_QUALITY"; + ret = 0; + break; + default: + msg = "error: enum value out of range"; + } + break; + } + case ANDROID_DISTORTION_CORRECTION_AVAILABLE_MODES: { + break; + } + + } + + strncpy(dst, msg, size - 1); + dst[size - 1] = '\0'; + + return ret; +} + + +#define CAMERA_METADATA_ENUM_STRING_MAX_SIZE 29 From patchwork Thu Aug 1 15:54:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 1725 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5AFC615FF for ; Thu, 1 Aug 2019 17:53:31 +0200 (CEST) X-Originating-IP: 82.58.19.211 Received: from uno.homenet.telecomitalia.it (host211-19-dynamic.58-82-r.retail.telecomitalia.it [82.58.19.211]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 91E44E000A; Thu, 1 Aug 2019 15:53:27 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Aug 2019 17:54:20 +0200 Message-Id: <20190801155420.24694-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190801155420.24694-1-jacopo@jmondi.org> References: <20190801155420.24694-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] android: hal: Add Camera3 HAL X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Aug 2019 15:53:32 -0000 Add Libcamera Android Camerav3 HAL implementation. Signed-off-by: Jacopo Mondi --- src/android/camera3_hal.cpp | 130 +++++ src/android/camera_hal_manager.cpp | 173 +++++++ src/android/camera_hal_manager.h | 56 ++ src/android/camera_module.cpp | 795 +++++++++++++++++++++++++++++ src/android/camera_module.h | 69 +++ src/android/camera_proxy.cpp | 181 +++++++ src/android/camera_proxy.h | 41 ++ src/android/meson.build | 8 + src/android/tags | 424 +++++++++++++++ src/android/thread_rpc.cpp | 41 ++ src/android/thread_rpc.h | 56 ++ src/libcamera/meson.build | 22 +- src/meson.build | 4 + 13 files changed, 1995 insertions(+), 5 deletions(-) create mode 100644 src/android/camera3_hal.cpp create mode 100644 src/android/camera_hal_manager.cpp create mode 100644 src/android/camera_hal_manager.h create mode 100644 src/android/camera_module.cpp create mode 100644 src/android/camera_module.h create mode 100644 src/android/camera_proxy.cpp create mode 100644 src/android/camera_proxy.h create mode 100644 src/android/tags create mode 100644 src/android/thread_rpc.cpp create mode 100644 src/android/thread_rpc.h diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp new file mode 100644 index 000000000000..0a97a9333d20 --- /dev/null +++ b/src/android/camera3_hal.cpp @@ -0,0 +1,130 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera3_hal.cpp - Android Camera3 HAL module + */ + +#include +#include +#include + +#include +#include + +#include + +#include "log.h" + +#include "camera_hal_manager.h" +#include "camera_module.h" +#include "camera_proxy.h" + +using namespace libcamera; + +LOG_DEFINE_CATEGORY(HAL) + +static CameraHalManager cameraManager; + +/*------------------------------------------------------------------------------ + * Android Camera HAL callbacks + */ + +static int hal_get_number_of_cameras(void) +{ + return cameraManager.numCameras(); +} + +static int hal_get_camera_info(int id, struct camera_info *info) +{ + return cameraManager.getCameraInfo(id, info); +} + +static int hal_set_callbacks(const camera_module_callbacks_t *callbacks) +{ + return 0; +} + +static int hal_open_legacy(const struct hw_module_t *module, const char *id, + uint32_t halVersion, struct hw_device_t **device) +{ + return -ENOSYS; +} + +static int hal_set_torch_mode(const char *camera_id, bool enabled) +{ + return -ENOSYS; +} + +/* + * First entry point of the camera HAL module. + * + * Initialize the HAL but does not open any camera device yet (see hal_dev_open) + */ +static int hal_init() +{ + LOG(HAL, Info) << "Initialising Android camera HAL"; + + cameraManager.initialize(); + + return 0; +} + +/*------------------------------------------------------------------------------ + * Android Camera Device + */ + +static int hal_dev_close(hw_device_t *hw_device) +{ + if (!hw_device) + return -EINVAL; + + camera3_device_t *dev = reinterpret_cast(hw_device); + CameraProxy *cameraModule = reinterpret_cast(dev->priv); + + return cameraManager.close(cameraModule); +} + +static int hal_dev_open(const hw_module_t* module, const char* name, + hw_device_t** device) +{ + LOG(HAL, Debug) << "Open camera: " << name; + + int id = atoi(name); + CameraProxy *proxy = cameraManager.open(id, module); + if (!proxy) { + LOG(HAL, Error) << "Failed to open camera module " << id; + return -ENODEV; + } + proxy->device()->common.close = hal_dev_close; + *device = &proxy->device()->common; + + return 0; +} + +static struct hw_module_methods_t hal_module_methods = { + .open = hal_dev_open, +}; + +camera_module_t HAL_MODULE_INFO_SYM = { + .common = { + .tag = HARDWARE_MODULE_TAG, + .module_api_version = CAMERA_MODULE_API_VERSION_2_4, + .hal_api_version = HARDWARE_HAL_API_VERSION, + .id = CAMERA_HARDWARE_MODULE_ID, + .name = "Libcamera Camera3HAL Module", + .author = "libcamera", + .methods = &hal_module_methods, + .dso = nullptr, + .reserved = {}, + }, + + .get_number_of_cameras = hal_get_number_of_cameras, + .get_camera_info = hal_get_camera_info, + .set_callbacks = hal_set_callbacks, + .get_vendor_tag_ops = nullptr, + .open_legacy = hal_open_legacy, + .set_torch_mode = hal_set_torch_mode, + .init = hal_init, + .reserved = {}, +}; diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp new file mode 100644 index 000000000000..734b5eebd9a5 --- /dev/null +++ b/src/android/camera_hal_manager.cpp @@ -0,0 +1,173 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_hal_manager.cpp - Libcamera Android Camera Manager + */ + +#include "camera_hal_manager.h" + +#include + +#include +#include + +#include +#include + +#include "log.h" + +#include "camera_module.h" +#include "camera_proxy.h" + +using namespace libcamera; +LOG_DECLARE_CATEGORY(HAL); + +CameraHalManager::~CameraHalManager() +{ + for (auto metadata : staticMetadataMap_) + free_camera_metadata(metadata.second); +} + +int CameraHalManager::initialize() +{ + /* + * Thread::start() will create a std::thread which will execute + * CameraHalManager::run() + */ + start(); + + /* + * Wait for run() to notify us before returning to the caller to + * make sure libcamera is fully initialized before we start handling + * calls from the camera stack. + */ + MutexLocker locker(mutex_); + cv_.wait(locker); + + return 0; +} + +void CameraHalManager::run() +{ + /* + * The run() operation is scheduled in its own thread; + * It exec() to run the even dispatcher loop and initialize libcamera. + * + * All the libcamera components initialized from here will be tied to + * the same thread as the here below run event dispatcher. + */ + libcameraManager_ = libcamera::CameraManager::instance(); + + int ret = libcameraManager_->start(); + if (ret) { + LOG(HAL, Error) << "Failed to start camera manager: " + << strerror(-ret); + return; + } + + /* + * For each Camera registered in the system, a CameraModule + * get created here with an associated Camera and a proxy. + * + * \todo Support camera hotplug. + */ + unsigned int cameraIndex = 0; + for (auto camera : libcameraManager_->cameras()) { + cameras_.push_back(camera); + + CameraModule *module = new CameraModule(cameraIndex, + camera.get()); + modules_.emplace_back(module); + + CameraProxy *proxy = new CameraProxy(cameraIndex, + module); + proxies_.emplace_back(proxy); + + ++cameraIndex; + } + + /* + * libcamera has been initialized! Unlock the initialize() caller + * as we're now ready to handle calls from the framework. + */ + cv_.notify_one(); + + /* Now start processing events and messages! */ + exec(); +} + +CameraProxy *CameraHalManager::open(unsigned int id, + const hw_module_t *hardwareModule) +{ + if (id < 0 || id >= numCameras()) { + LOG(HAL, Error) << "Invalid camera id '" << id << "'"; + return nullptr; + } + + CameraProxy *proxy = proxies_[id].get(); + if (proxy->open(hardwareModule)) + return proxy; + + LOG(HAL, Info) << "Camera: '" << id << "' opened"; + + return proxy; +} + +int CameraHalManager::close(CameraProxy *proxy) +{ + proxy->close(); + LOG(HAL, Info) << "Close camera: " << proxy->id(); + + return 0; +} + +unsigned int CameraHalManager::numCameras() const +{ + return libcameraManager_->cameras().size(); +} + +/* + * Before the camera framework even tries to open a camera device with + * hal_dev_open() it requires the camera HAL to report a list of static + * informations on the camera device with id \a id in the hal_get_camera_info() + * method. + * + * The static metadata should be then generated probably from a + * platform-specific module, as we cannot operate on the camera at this time as + * it has not yet been open by the framework. + * + * This is what the Intel XML file is used for, it is parsed and the data there + * combined with informations from the PSL service (which I -think- it's what + * our IPA is) to generate a list of static metadata per-camera device. + */ +int CameraHalManager::getCameraInfo(int id, struct camera_info *info) +{ + int cameras = numCameras(); + if (id >= cameras || id < 0 || !info) { + LOG(HAL, Error) << "Invalid camera id: " << id; + return -EINVAL; + } + + camera_metadata_t *staticMetadata; + auto it = staticMetadataMap_.find(id); + if (it != staticMetadataMap_.end()) { + staticMetadata = it->second; + } else { + CameraModule *cameraModule = modules_[id].get(); + + staticMetadata = cameraModule->getStaticMetadata(); + staticMetadataMap_[id] = staticMetadata; + } + + /* \todo: Get these info dynamically inspecting the camera module. */ + info->facing = id ? CAMERA_FACING_FRONT : CAMERA_FACING_BACK; + info->orientation = 0; + info->device_version = 0; + info->resource_cost = 0; + info->static_camera_characteristics = staticMetadata; + info->conflicting_devices = nullptr; + info->conflicting_devices_length = 0; + + return 0; +} diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h new file mode 100644 index 000000000000..65d6fa3150ef --- /dev/null +++ b/src/android/camera_hal_manager.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_hal_manager.h - Libcamera Android Camera Manager + */ +#ifndef __ANDROID_CAMERA_MANAGER_H__ +#define __ANDROID_CAMERA_MANAGER_H__ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "thread.h" +#include "thread_rpc.h" + +class CameraModule; +class CameraProxy; + +class CameraHalManager : public libcamera::Thread +{ +public: + ~CameraHalManager(); + + int initialize(); + + CameraProxy *open(unsigned int id, const hw_module_t *module); + int close(CameraProxy *proxy); + + unsigned int numCameras() const; + int getCameraInfo(int id, struct camera_info *info); + +private: + void run() override; + camera_metadata_t *getStaticMetadata(unsigned int id); + + libcamera::CameraManager *libcameraManager_; + + std::mutex mutex_; + std::condition_variable cv_; + + std::vector> cameras_; + std::vector> modules_; + std::vector> proxies_; + + std::map staticMetadataMap_; +}; + +#endif /* __ANDROID_CAMERA_MANAGER_H__ */ diff --git a/src/android/camera_module.cpp b/src/android/camera_module.cpp new file mode 100644 index 000000000000..1d7e007f62c0 --- /dev/null +++ b/src/android/camera_module.cpp @@ -0,0 +1,795 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_module.cpp - Libcamera Android Camera Module + */ + +#include "camera_module.h" + +#include +#include + +#include + +#include +#include + +#include "message.h" + +#include "log.h" + +using namespace libcamera; + +LOG_DECLARE_CATEGORY(HAL); + +CameraModule::CameraModule(unsigned int id, libcamera::Camera *camera) + : id_(id), camera_(camera), requestTemplate_(nullptr) +{ + camera_->requestCompleted.connect(this, + &CameraModule::requestComplete); +} + +CameraModule::~CameraModule() +{ + if (requestTemplate_) + free_camera_metadata(requestTemplate_); + requestTemplate_ = nullptr; +} + +void CameraModule::message(Message *message) +{ + ThreadRpcMessage *rpcMessage = static_cast + (message); + + if (rpcMessage->type() != ThreadRpcMessage::type()) + return Object::message(message); + + ThreadRpc *rpc = rpcMessage->rpc; + + switch (rpc->tag) { + case ThreadRpc::ProcessCaptureRequest: + processCaptureRequest(rpc->request); + break; + case ThreadRpc::Close: + close(); + break; + default: + LOG(HAL, Error) << "Unknown RPC operation: " << rpc->tag; + } + + rpc->notifyReception(); +} + +int CameraModule::open() +{ + int ret = camera_->acquire(); + if (ret) { + LOG(HAL, Error) << "Failed to acquire the camera"; + return ret; + } + + return 0; +} + +void CameraModule::close() +{ + if (camera_->state() >= CameraRunning) + camera_->stop(); + + camera_->freeBuffers(); + camera_->release(); +} + +void CameraModule::setCallbacks(const struct camera3_device *camera3Device, + const camera3_callback_ops_t *callbacks) +{ + camera3Device_ = camera3Device; + callbacks_ = callbacks; +} + +camera_metadata_t *CameraModule::getStaticMetadata() +{ + int ret; + + /* + * The below metadata has been added by inspecting the Intel XML + * file and it's associated parsing routines in the Intel IPU3 HAL. + * + * The here below metadata are enough to satisfy the camera3-test + * provided by ChromeOS, but a real camera implementation might require + * more. + * + * See CameraConf::AiqConf class implementation in the Intel HAL + * to get a list of the static metadata registered by parsing the + * XML config file in AiqConf::fillStaticMetadataFromCMC + */ + + /* + * FIXME: this sizes come from the Intel IPU3 HAL, and are way too large for + * this intial HAL version. + */ + #define STATIC_ENTRY_CAP 256 + #define STATIC_DATA_CAP 6688 + camera_metadata_t *staticMetadata = + allocate_camera_metadata(STATIC_ENTRY_CAP, STATIC_DATA_CAP); + + /* Sensor static metadata. */ + int32_t pixelArraySize[] = { + 2592, 1944, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, + &pixelArraySize, 2); + METADATA_ASSERT(ret); + + int32_t sensorSizes[] = { + 0, 0, 2560, 1920, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, + &sensorSizes, 4); + METADATA_ASSERT(ret); + + int32_t sensitivityRange[] = { + 32, 2400, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, + &sensitivityRange, 2); + METADATA_ASSERT(ret); + + uint16_t filterArr = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, + &filterArr, 1); + METADATA_ASSERT(ret); + + int64_t exposureTimeRange[] = { + 100000, 200000000, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, + &exposureTimeRange, 2); + METADATA_ASSERT(ret); + + int32_t orientation = 0; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SENSOR_ORIENTATION, + &orientation, 1); + METADATA_ASSERT(ret); + + /* Flash static metadata. */ + char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_FLASH_INFO_AVAILABLE, + &flashAvailable, 1); + METADATA_ASSERT(ret); + + /* Lens static metadata. */ + float fn = 2.53 / 100; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_LENS_INFO_AVAILABLE_APERTURES, &fn, 1); + METADATA_ASSERT(ret); + + /* Control metadata. */ + char controlMetadata = ANDROID_CONTROL_MODE_AUTO; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_CONTROL_AVAILABLE_MODES, + &controlMetadata, 1); + METADATA_ASSERT(ret); + + char availableAntiBandingModes[] = { + ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF, + ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ, + ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ, + ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, + availableAntiBandingModes, 4); + METADATA_ASSERT(ret); + + char aeAvailableModes[] = { + ANDROID_CONTROL_AE_MODE_ON, + ANDROID_CONTROL_AE_MODE_OFF, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_CONTROL_AE_AVAILABLE_MODES, + aeAvailableModes, 2); + METADATA_ASSERT(ret); + + controlMetadata = ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_CONTROL_AE_LOCK_AVAILABLE, + &controlMetadata, 1); + METADATA_ASSERT(ret); + + uint8_t awbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + &awbLockAvailable, 1); + + /* Scaler static metadata. */ + std::vector availableStreamFormats = { + ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, + ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, + ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SCALER_AVAILABLE_FORMATS, + availableStreamFormats.data(), + availableStreamFormats.size()); + METADATA_ASSERT(ret); + + std::vector availableStreamConfigurations = { + ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, 2560, 1920, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, 2560, 1920, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, + availableStreamConfigurations.data(), + availableStreamConfigurations.size()); + METADATA_ASSERT(ret); + + std::vector availableStallDurations = { + ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, + availableStallDurations.data(), + availableStallDurations.size()); + METADATA_ASSERT(ret); + + std::vector minFrameDurations = { + ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333, + ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, 2560, 1920, 33333333, + ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, 2560, 1920, 33333333, + }; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, + minFrameDurations.data(), minFrameDurations.size()); + METADATA_ASSERT(ret); + + /* Info static metadata. */ + uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + ret = add_camera_metadata_entry(staticMetadata, + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, + &supportedHWLevel, 1); + + return staticMetadata; +} + +const camera_metadata_t *CameraModule::constructDefaultRequestMetadata(int type) +{ + int ret; + + /* + * TODO: inspect type and pick the right metadata pack. + * As of now just use a single one for all templates + */ + uint8_t captureIntent; + switch (type) { + case CAMERA3_TEMPLATE_PREVIEW: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW; + break; + case CAMERA3_TEMPLATE_STILL_CAPTURE: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE; + break; + case CAMERA3_TEMPLATE_VIDEO_RECORD: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; + break; + case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; + break; + case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG; + break; + case CAMERA3_TEMPLATE_MANUAL: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL; + break; + default: + LOG(HAL, Error) << "Invalid template request type: " << type; + return nullptr; + } + + if (requestTemplate_) + return requestTemplate_; + + /* FIXME: this sizes are quite arbitrary ones */ + #define REQUEST_TEMPLATE_ENTRIES 30 + #define REQUEST_TEMPLATE_DATA 2048 + requestTemplate_ = allocate_camera_metadata(REQUEST_TEMPLATE_ENTRIES, + REQUEST_TEMPLATE_DATA); + if (!requestTemplate_) { + LOG(HAL, Error) << "Failed to allocate template metadata"; + return nullptr; + } + + /* + * Fill in the required Request metadata. + * + * Part (most?) of this entries comes from inspecting the Intel's IPU3 + * HAL xml configuration file. + */ + + /* Set to 0 the number of 'processed and stalling' streams (ie JPEG). */ + int32_t maxOutStream[] = { 0, 2, 0 }; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, + maxOutStream, 3); + METADATA_ASSERT(ret); + + uint8_t maxPipelineDepth = 5; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_PIPELINE_MAX_DEPTH, + &maxPipelineDepth, 1); + METADATA_ASSERT(ret); + + int32_t inputStreams = 0; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, + &inputStreams, 1); + METADATA_ASSERT(ret); + + int32_t partialResultCount = 1; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_PARTIAL_RESULT_COUNT, + &partialResultCount, 1); + METADATA_ASSERT(ret); + + uint8_t availableCapabilities[] = { + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, + }; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES, + availableCapabilities, 1); + METADATA_ASSERT(ret); + + uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AE_MODE, + &aeMode, 1); + METADATA_ASSERT(ret); + + int32_t aeExposureCompensation = 0; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, + &aeExposureCompensation, 1); + METADATA_ASSERT(ret); + + uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, + &aePrecaptureTrigger, 1); + METADATA_ASSERT(ret); + + uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AE_LOCK, + &aeLock, 1); + METADATA_ASSERT(ret); + + uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AF_TRIGGER, + &afTrigger, 1); + METADATA_ASSERT(ret); + + uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AWB_MODE, + &awbMode, 1); + METADATA_ASSERT(ret); + + uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AWB_LOCK, + &awbLock, 1); + METADATA_ASSERT(ret); + + uint8_t awbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + &awbLockAvailable, 1); + METADATA_ASSERT(ret); + + uint8_t flashMode = ANDROID_FLASH_MODE_OFF; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_FLASH_MODE, + &flashMode, 1); + METADATA_ASSERT(ret); + + uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_STATISTICS_FACE_DETECT_MODE, + &faceDetectMode, 1); + METADATA_ASSERT(ret); + + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_CONTROL_CAPTURE_INTENT, + &captureIntent, 1); + METADATA_ASSERT(ret); + + /* + * This is quite hard to list at the moment wihtout knowing what + * we could control. + * + * For now, just list in the available Request keys and in the available + * result keys the control and reporting of the AE algorithm. + */ + std::vector availableRequestKeys = { + ANDROID_CONTROL_AE_MODE, + ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, + ANDROID_CONTROL_AE_LOCK, + ANDROID_CONTROL_AF_TRIGGER, + ANDROID_CONTROL_AWB_MODE, + ANDROID_CONTROL_AWB_LOCK, + ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + ANDROID_CONTROL_CAPTURE_INTENT, + ANDROID_FLASH_MODE, + ANDROID_STATISTICS_FACE_DETECT_MODE, + }; + + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, + availableRequestKeys.data(), + availableRequestKeys.size()); + METADATA_ASSERT(ret); + + std::vector availableResultKeys = { + ANDROID_CONTROL_AE_MODE, + ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, + ANDROID_CONTROL_AE_LOCK, + ANDROID_CONTROL_AF_TRIGGER, + ANDROID_CONTROL_AWB_MODE, + ANDROID_CONTROL_AWB_LOCK, + ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + ANDROID_CONTROL_CAPTURE_INTENT, + ANDROID_FLASH_MODE, + ANDROID_STATISTICS_FACE_DETECT_MODE, + }; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, + availableResultKeys.data(), + availableResultKeys.size()); + METADATA_ASSERT(ret); + + /* + * The available characteristics should be the tags reported + * as part of the static metadata reported at hal_get_camera_info() + * time. The xml file sets those to 0 though. + */ + std::vector availableCharacteristicsKeys = {}; + ret = add_camera_metadata_entry(requestTemplate_, + ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, + availableCharacteristicsKeys.data(), + availableCharacteristicsKeys.size()); + METADATA_ASSERT(ret); + + return requestTemplate_; +} + +/** + * Inspect the stream_list to produce a list of StreamConfiguration to + * be use to configure the Camera. + */ +int CameraModule::configureStreams(camera3_stream_configuration_t *stream_list) +{ + + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { + camera3_stream_t *stream = stream_list->streams[i]; + + LOG(HAL, Info) << "Stream #" << i + << ": direction: " << stream->stream_type + << " - width: " << stream->width + << " - height: " << stream->height + << " - format: " << std::hex << stream->format; + } + + /* Hardcode viewfinder role, collecting sizes from the stream config. */ + if (stream_list->num_streams != 1) { + LOG(HAL, Error) << "Only one stream supported"; + return -EINVAL; + } + + StreamRoles roles = {}; + roles.push_back(StreamRole::StillCapture); + + config_ = camera_->generateConfiguration(roles); + if (!config_ || config_->empty()) { + LOG(HAL, Error) << "Failed to generate camera configuration"; + return -EINVAL; + } + + /* Only one stream is supported. */ + camera3_stream_t *camera3Stream = stream_list->streams[0]; + StreamConfiguration *streamConfiguration = &config_->at(0); + streamConfiguration->size.width = camera3Stream->width; + streamConfiguration->size.height = camera3Stream->height; + streamConfiguration->memoryType = ExternalMemory; + + /* + * FIXME: do not change the pixel format from the one returned + * from the Camera::generateConfiguration(); + * + * We'll need to translate from Android defined pixel format codes + * to whatever libcamera will use. + */ + + switch (config_->validate()) { + case CameraConfiguration::Valid: + break; + case CameraConfiguration::Adjusted: + LOG(HAL, Info) << "Camera configuration adjusted"; + return -EINVAL; + case CameraConfiguration::Invalid: + LOG(HAL, Info) << "Camera configuration invalid"; + config_.reset(); + return -EINVAL; + } + + camera3Stream->max_buffers = streamConfiguration->bufferCount; + + /* + * Once the CameraConfiguration has been adjusted/validated + * it can be applied to the camera. + */ + int ret = camera_->configure(config_.get()); + if (ret) { + LOG(HAL, Error) << "Failed to configure camera '" + << camera_->name() << "'"; + return ret; + } + + return 0; +} + +int CameraModule::processCaptureRequest(camera3_capture_request_t *camera3Request) +{ + StreamConfiguration *streamConfiguration = &config_->at(0); + Stream *stream = streamConfiguration->stream(); + + if (camera3Request->num_output_buffers != 1) { + LOG(HAL, Error) << "Invalid number of output buffers: " + << camera3Request->num_output_buffers; + return -EINVAL; + } + + /* Start the camera if that's the first request we handle. */ + if (camera_->state() < CameraRunning) { + int ret = camera_->allocateBuffers(); + if (ret) { + LOG(HAL, Error) << "Failed to allocate buffers"; + return ret; + } + + ret = camera_->start(); + if (ret) { + LOG(HAL, Error) << "Failed to start camera"; + camera_->freeBuffers(); + return ret; + } + } + + /* + * Queue a request for the Camera with the provided dmabuf file + * descriptors. + */ + const camera3_stream_buffer_t *camera3Buffer = + &camera3Request->output_buffers[0]; + const buffer_handle_t camera3Handle = *camera3Buffer->buffer; + + std::array fds = { + camera3Handle->data[0], + camera3Handle->data[1], + camera3Handle->data[2], + }; + std::unique_ptr buffer = stream->createBuffer(fds); + if (!buffer) { + LOG(HAL, Error) << "Failed to create buffer"; + return -EINVAL; + } + + Request *request = camera_->createRequest(); + request->addBuffer(std::move(buffer)); + int ret = camera_->queueRequest(request); + if (ret) { + LOG(HAL, Error) << "Failed to queue request"; + return ret; + } + + /* Save the request descriptors for use at completion time. */ + Camera3RequestDescriptor descriptor = {}; + descriptor.frameNumber = camera3Request->frame_number, + descriptor.numBuffers = camera3Request->num_output_buffers, + descriptor.buffers = new camera3_stream_buffer_t[descriptor.numBuffers]; + for (unsigned int i = 0; i < descriptor.numBuffers; ++i) { + camera3_stream_buffer_t &buffer = descriptor.buffers[i]; + buffer = camera3Request->output_buffers[i]; + } + + requestMap_[request] = descriptor; + + return 0; +} + +void CameraModule::requestComplete(Request *request, + const std::map &buffers) +{ + Buffer *libcameraBuffer = buffers.begin()->second; + camera3_buffer_status status = CAMERA3_BUFFER_STATUS_OK; + camera_metadata_t *resultMetadata = nullptr; + + if (request->status() != Request::RequestComplete) { + LOG(HAL, Error) << "Request not succesfully completed: " + << request->status(); + status = CAMERA3_BUFFER_STATUS_ERROR; + } + + /* Prepare to call back the Android camera stack. */ + Camera3RequestDescriptor &descriptor = requestMap_[request]; + + camera3_capture_result_t captureResult = {}; + captureResult.frame_number = descriptor.frameNumber; + captureResult.num_output_buffers = descriptor.numBuffers; + + camera3_stream_buffer_t *resultBuffers = + new camera3_stream_buffer_t[descriptor.numBuffers]; + for (unsigned int i = 0; i < descriptor.numBuffers; ++i) { + camera3_stream_buffer_t resultBuffer; + + resultBuffer = descriptor.buffers[i]; + resultBuffer.acquire_fence = -1; + resultBuffer.release_fence = -1; + resultBuffer.status = status; + + resultBuffers[i] = resultBuffer; + } + captureResult.output_buffers = + const_cast(resultBuffers); + + if (status == CAMERA3_BUFFER_STATUS_ERROR) { + /* \todo Improve error handling. */ + notifyError(descriptor.frameNumber, resultBuffers->stream); + } else { + notifyShutter(descriptor.frameNumber, libcameraBuffer->timestamp()); + + captureResult.partial_result = 1; + resultMetadata = getResultMetadata(descriptor.frameNumber, + libcameraBuffer->timestamp()); + captureResult.result = resultMetadata; + } + + callbacks_->process_capture_result(callbacks_, &captureResult); + + if (resultMetadata) + free_camera_metadata(resultMetadata); + + delete[] resultBuffers; + delete[] descriptor.buffers; + requestMap_.erase(request); + + return; +} + +void CameraModule::notifyShutter(uint32_t frameNumber, uint64_t timestamp) +{ + camera3_notify_msg_t notify = {}; + + notify.type = CAMERA3_MSG_SHUTTER; + notify.message.shutter.frame_number = frameNumber; + notify.message.shutter.timestamp = timestamp; + + callbacks_->notify(callbacks_, ¬ify); +} + +void CameraModule::notifyError(uint32_t frameNumber, camera3_stream_t *stream) +{ + camera3_notify_msg_t notify = {}; + + notify.type = CAMERA3_MSG_ERROR; + notify.message.error.error_stream = stream; + notify.message.error.frame_number = frameNumber; + notify.message.error.error_code = CAMERA3_MSG_ERROR_REQUEST; + + callbacks_->notify(callbacks_, ¬ify); +} + +/* + * Fixed result metadata, mostly imported from the UVC camera HAL, which + * does not produces metadata and thus needs to generate a fixed set. + */ +camera_metadata_t *CameraModule::getResultMetadata(int frame_number, + int64_t timestamp) +{ + int ret; + + /* FIXME: random "big enough" values. */ + #define RESULT_ENTRY_CAP 256 + #define RESULT_DATA_CAP 6688 + camera_metadata_t *resultMetadata = + allocate_camera_metadata(STATIC_ENTRY_CAP, STATIC_DATA_CAP); + + const uint8_t ae_state = ANDROID_CONTROL_AE_STATE_CONVERGED; + ret = add_camera_metadata_entry(resultMetadata, ANDROID_CONTROL_AE_STATE, + &ae_state, 1); + METADATA_ASSERT(ret); + + const uint8_t ae_lock = ANDROID_CONTROL_AE_LOCK_OFF; + ret = add_camera_metadata_entry(resultMetadata, ANDROID_CONTROL_AE_LOCK, + &ae_lock, 1); + METADATA_ASSERT(ret); + + uint8_t af_state = ANDROID_CONTROL_AF_STATE_INACTIVE; + ret = add_camera_metadata_entry(resultMetadata, ANDROID_CONTROL_AF_STATE, + &af_state, 1); + METADATA_ASSERT(ret); + + const uint8_t awb_state = ANDROID_CONTROL_AWB_STATE_CONVERGED; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_CONTROL_AWB_STATE, + &awb_state, 1); + METADATA_ASSERT(ret); + + const uint8_t awb_lock = ANDROID_CONTROL_AWB_LOCK_OFF; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_CONTROL_AWB_LOCK, + &awb_lock, 1); + METADATA_ASSERT(ret); + + const uint8_t lens_state = ANDROID_LENS_STATE_STATIONARY; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_LENS_STATE, + &lens_state, 1); + METADATA_ASSERT(ret); + + int32_t sensorSizes[] = { + 0, 0, 2560, 1920, + }; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_SCALER_CROP_REGION, + sensorSizes, 4); + METADATA_ASSERT(ret); + + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_SENSOR_TIMESTAMP, + ×tamp, 1); + + METADATA_ASSERT(ret); + + /* 33.3 msec */ + const int64_t rolling_shutter_skew = 33300000; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, + &rolling_shutter_skew, 1); + METADATA_ASSERT(ret); + + /* 16.6 msec */ + const int64_t exposure_time = 16600000; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_SENSOR_EXPOSURE_TIME, + &exposure_time, 1); + METADATA_ASSERT(ret); + + const uint8_t lens_shading_map_mode = + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, + &lens_shading_map_mode, 1); + METADATA_ASSERT(ret); + + const uint8_t scene_flicker = ANDROID_STATISTICS_SCENE_FLICKER_NONE; + ret = add_camera_metadata_entry(resultMetadata, + ANDROID_STATISTICS_SCENE_FLICKER, + &scene_flicker, 1); + METADATA_ASSERT(ret); + + return resultMetadata; +} diff --git a/src/android/camera_module.h b/src/android/camera_module.h new file mode 100644 index 000000000000..c33fde590cdc --- /dev/null +++ b/src/android/camera_module.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_module.h - Libcamera Android Camera Module + */ +#ifndef __ANDROID_CAMERA_MODULE_H__ +#define __ANDROID_CAMERA_MODULE_H__ + +#include + +#include +#include + +#include "message.h" + +#include "camera_hal_manager.h" + +#define METADATA_ASSERT(_r) \ + do { \ + if (!(_r)) break; \ + LOG(HAL, Error) << "Error: " << __func__ << ":" << __LINE__; \ + return nullptr; \ + } while(0); + +class CameraModule : public libcamera::Object +{ +public: + CameraModule(unsigned int id, libcamera::Camera *camera); + ~CameraModule(); + + void message(libcamera::Message *message); + + int open(); + void close(); + void setCallbacks(const struct camera3_device *cameraDevice, + const camera3_callback_ops_t *callbacks); + camera_metadata_t *getStaticMetadata(); + const camera_metadata_t *constructDefaultRequestMetadata(int type); + int configureStreams(camera3_stream_configuration_t *stream_list); + int processCaptureRequest(camera3_capture_request_t *request); + void requestComplete(libcamera::Request *request, + const std::map &buffers); + + unsigned int id() const { return id_; } + +private: + struct Camera3RequestDescriptor { + uint32_t frameNumber; + uint32_t numBuffers; + camera3_stream_buffer_t *buffers; + }; + + void notifyShutter(uint32_t frameNumber, uint64_t timestamp); + void notifyError(uint32_t frameNumber, camera3_stream_t *stream); + camera_metadata_t *getResultMetadata(int frame_number, int64_t timestamp); + + unsigned int id_; + libcamera::Camera *camera_; + std::unique_ptr config_; + + camera_metadata_t *requestTemplate_; + const camera3_callback_ops_t *callbacks_; + const struct camera3_device *camera3Device_; + + std::map requestMap_; +}; + +#endif /* __ANDROID_CAMERA_MODULE_H__ */ diff --git a/src/android/camera_proxy.cpp b/src/android/camera_proxy.cpp new file mode 100644 index 000000000000..af7817f29137 --- /dev/null +++ b/src/android/camera_proxy.cpp @@ -0,0 +1,181 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_proxy.cpp - Proxy to camera module instances + */ + +#include "camera_proxy.h" + +#include +#include +#include + +#include + +#include "log.h" +#include "message.h" +#include "thread_rpc.h" +#include "utils.h" + +using namespace libcamera; + +LOG_DECLARE_CATEGORY(HAL); + +#define LIBCAMERA_HAL_FUNC_DBG \ + LOG(HAL, Debug); + +static int hal_dev_initialize(const struct camera3_device *dev, + const camera3_callback_ops_t *callback_ops) +{ + LIBCAMERA_HAL_FUNC_DBG + + if (!dev) + return -EINVAL; + + CameraProxy *proxy = reinterpret_cast(dev->priv); + proxy->setCallbacks(callback_ops); + + return 0; +} + +static int hal_dev_configure_streams(const struct camera3_device *dev, + camera3_stream_configuration_t *stream_list) +{ + LIBCAMERA_HAL_FUNC_DBG + + if (!dev) + return -EINVAL; + + CameraProxy *proxy = reinterpret_cast(dev->priv); + proxy->configureStreams(stream_list); + + return 0; +} + +static const camera_metadata_t * +hal_dev_construct_default_request_settings(const struct camera3_device *dev, + int type) +{ + LIBCAMERA_HAL_FUNC_DBG + + if (!dev) + return nullptr; + + CameraProxy *proxy = reinterpret_cast(dev->priv); + return proxy->constructDefaultRequest(type); +} + +static int hal_dev_process_capture_request(const struct camera3_device *dev, + camera3_capture_request_t *request) +{ + LIBCAMERA_HAL_FUNC_DBG + + if (!dev) + return -EINVAL; + + CameraProxy *proxy = reinterpret_cast(dev->priv); + return proxy->processCaptureRequest(request); +} + +static void hal_dev_dump(const struct camera3_device *dev, int fd) +{ + LIBCAMERA_HAL_FUNC_DBG +} + +static int hal_dev_flush(const struct camera3_device *dev) +{ + LIBCAMERA_HAL_FUNC_DBG + + return 0; +} + +static camera3_device_ops hal_dev_ops = { + .initialize = hal_dev_initialize, + .configure_streams = hal_dev_configure_streams, + .register_stream_buffers = nullptr, + .construct_default_request_settings = hal_dev_construct_default_request_settings, + .process_capture_request = hal_dev_process_capture_request, + .get_metadata_vendor_tag_ops = nullptr, + .dump = hal_dev_dump, + .flush = hal_dev_flush, + .reserved = { 0 }, +}; + +CameraProxy::CameraProxy(unsigned int id, CameraModule *cameraModule) + : open_(false), id_(id), cameraModule_(cameraModule) +{ +} + +int CameraProxy::open(const hw_module_t *hardwareModule) +{ + int ret = cameraModule_->open(); + if (ret) + return ret; + + /* Initialize the hw_device_t in the instance camera3_module_t. */ + cameraDevice_.common.tag = HARDWARE_DEVICE_TAG; + cameraDevice_.common.version = CAMERA_DEVICE_API_VERSION_3_3; + cameraDevice_.common.module = (hw_module_t *)hardwareModule; + + /* + * The camera device operations. These actually implement + * the Android Camera HALv3 interface. + */ + cameraDevice_.ops = &hal_dev_ops; + cameraDevice_.priv = this; + + open_ = true; + + return 0; +} + +void CameraProxy::close() +{ + LIBCAMERA_HAL_FUNC_DBG + + ThreadRpc rpcRequest; + rpcRequest.tag = ThreadRpc::Close; + + threadRpcCall(rpcRequest); + + open_ = false; +} + +void CameraProxy::setCallbacks(const camera3_callback_ops_t *callbacks) +{ + LIBCAMERA_HAL_FUNC_DBG + + cameraModule_->setCallbacks(&cameraDevice_, callbacks); +} + +const camera_metadata_t *CameraProxy::constructDefaultRequest(int type) +{ + return cameraModule_->constructDefaultRequestMetadata(type); +} + +int CameraProxy::configureStreams(camera3_stream_configuration_t *stream_list) +{ + return cameraModule_->configureStreams(stream_list); +} + +int CameraProxy::processCaptureRequest(camera3_capture_request_t *request) +{ + ThreadRpc rpcRequest; + rpcRequest.tag = ThreadRpc::ProcessCaptureRequest; + rpcRequest.request = request; + + threadRpcCall(rpcRequest); + + return 0; +} + +void CameraProxy::threadRpcCall(ThreadRpc &rpcRequest) +{ + std::unique_ptr message = + utils::make_unique(); + message->rpc = &rpcRequest; + + cameraModule_->postMessage(std::move(message)); + rpcRequest.waitDelivery(); +} diff --git a/src/android/camera_proxy.h b/src/android/camera_proxy.h new file mode 100644 index 000000000000..69e6878c4352 --- /dev/null +++ b/src/android/camera_proxy.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * camera_proxy.h - Proxy to camera module instances + */ +#ifndef __ANDROID_CAMERA_PROXY_H__ +#define __ANDROID_CAMERA_PROXY_H__ + +#include +#include + +#include "camera_module.h" + +class CameraProxy +{ +public: + CameraProxy(unsigned int id, CameraModule *cameraModule); + + int open(const hw_module_t *hardwareModule); + void close(); + + void setCallbacks(const camera3_callback_ops_t *callbacks); + const camera_metadata_t *constructDefaultRequest(int type); + int configureStreams(camera3_stream_configuration_t *stream_list); + int processCaptureRequest(camera3_capture_request_t *request); + + bool isOpen() const { return open_; } + unsigned int id() const { return id_; } + camera3_device_t *device() { return &cameraDevice_; } + +private: + void threadRpcCall(ThreadRpc &rpcRequest); + + bool open_; + unsigned int id_; + CameraModule *cameraModule_; + camera3_device_t cameraDevice_; +}; + +#endif /* __ANDROID_CAMERA_PROXY_H__ */ diff --git a/src/android/meson.build b/src/android/meson.build index e988dfa9ee63..eb0b6fce39da 100644 --- a/src/android/meson.build +++ b/src/android/meson.build @@ -1,3 +1,11 @@ +android_hal_sources = files([ + 'camera3_hal.cpp', + 'camera_hal_manager.cpp', + 'camera_module.cpp', + 'camera_proxy.cpp', + 'thread_rpc.cpp' +]) + android_camera_metadata_sources = files([ 'metadata/camera_metadata.c', ]) diff --git a/src/android/tags b/src/android/tags new file mode 100644 index 000000000000..0ef3ad649604 --- /dev/null +++ b/src/android/tags @@ -0,0 +1,424 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ +!_TAG_PROGRAM_AUTHOR Universal Ctags Team // +!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ +!_TAG_PROGRAM_URL https://ctags.io/ /official site/ +!_TAG_PROGRAM_VERSION 0.0.0 /3fdf28bc/ +ALIGN_TO metadata/camera_metadata.c /^#define ALIGN_TO(/;" d file: signature:(val,alignment) +ALOGE metadata/camera_metadata.c /^#define ALOGE(/;" d file: signature:(...) +CAMERA_METADATA_ENUM_STRING_MAX_SIZE metadata/camera_metadata_tag_info.c /^#define CAMERA_METADATA_ENUM_STRING_MAX_SIZE /;" d file: +CURRENT_METADATA_VERSION metadata/camera_metadata.c /^#define CURRENT_METADATA_VERSION /;" d file: +CameraModule camera_module.cpp /^CameraModule::CameraModule(unsigned int id, const hw_module_t *module,$/;" f class:CameraModule signature:(unsigned int id,const hw_module_t * module,CameraManager * cameraManager) +CameraModule camera_module.h /^ CameraModule(unsigned int id, const hw_module_t *module,$/;" p class:CameraModule access:public signature:(unsigned int id,const hw_module_t * module,libcamera::CameraManager * cameraManager) +CameraModule camera_module.h /^class CameraModule : public libcamera::Thread$/;" c inherits:libcamera::Thread +CameraModule::CameraModule camera_module.cpp /^CameraModule::CameraModule(unsigned int id, const hw_module_t *module,$/;" f class:CameraModule signature:(unsigned int id,const hw_module_t * module,CameraManager * cameraManager) +CameraModule::CameraModule camera_module.h /^ CameraModule(unsigned int id, const hw_module_t *module,$/;" p class:CameraModule access:public signature:(unsigned int id,const hw_module_t * module,libcamera::CameraManager * cameraManager) +CameraModule::callbacks_ camera_module.h /^ const camera3_callback_ops_t *callbacks_;$/;" m class:CameraModule typeref:typename:const camera3_callback_ops_t * access:private +CameraModule::cameraDevice camera_module.h /^ camera3_device_t *cameraDevice() { return &cameraDevice_; }$/;" f class:CameraModule typeref:typename:camera3_device_t * access:public signature:() +CameraModule::cameraDevice_ camera_module.h /^ camera3_device_t cameraDevice_;$/;" m class:CameraModule typeref:typename:camera3_device_t access:private +CameraModule::cameraManager_ camera_module.h /^ libcamera::CameraManager *cameraManager_;$/;" m class:CameraModule typeref:typename:libcamera::CameraManager * access:private +CameraModule::camera_ camera_module.h /^ std::shared_ptr camera_;$/;" m class:CameraModule typeref:typename:std::shared_ptr access:private +CameraModule::close camera_module.cpp /^void CameraModule::close()$/;" f class:CameraModule typeref:typename:void signature:() +CameraModule::close camera_module.h /^ void close();$/;" p class:CameraModule typeref:typename:void access:public signature:() +CameraModule::config_ camera_module.h /^ std::unique_ptr config_;$/;" m class:CameraModule typeref:typename:std::unique_ptr access:private +CameraModule::configureStreams camera_module.cpp /^int CameraModule::configureStreams(camera3_stream_configuration_t *stream_list)$/;" f class:CameraModule typeref:typename:int signature:(camera3_stream_configuration_t * stream_list) +CameraModule::configureStreams camera_module.h /^ int configureStreams(camera3_stream_configuration_t *stream_list);$/;" p class:CameraModule typeref:typename:int access:public signature:(camera3_stream_configuration_t * stream_list) +CameraModule::generateDefaultRequestMetadata camera_module.cpp /^const camera_metadata_t *CameraModule::generateDefaultRequestMetadata(int type)$/;" f class:CameraModule typeref:typename:const camera_metadata_t * signature:(int type) +CameraModule::generateDefaultRequestMetadata camera_module.h /^ const camera_metadata_t *generateDefaultRequestMetadata(int type);$/;" p class:CameraModule typeref:typename:const camera_metadata_t * access:public signature:(int type) +CameraModule::id camera_module.h /^ unsigned int id() const { return id_; }$/;" f class:CameraModule typeref:typename:unsigned int access:public signature:() const +CameraModule::id_ camera_module.h /^ unsigned int id_;$/;" m class:CameraModule typeref:typename:unsigned int access:private +CameraModule::init camera_module.cpp /^int CameraModule::init()$/;" f class:CameraModule typeref:typename:int signature:() +CameraModule::init camera_module.h /^ int init();$/;" p class:CameraModule typeref:typename:int access:public signature:() +CameraModule::module_ camera_module.h /^ const hw_module_t *module_;$/;" m class:CameraModule typeref:typename:const hw_module_t * access:private +CameraModule::processCaptureRequest camera_module.cpp /^int CameraModule::processCaptureRequest(camera3_capture_request_t *camera3Request)$/;" f class:CameraModule typeref:typename:int signature:(camera3_capture_request_t * camera3Request) +CameraModule::processCaptureRequest camera_module.h /^ int processCaptureRequest(camera3_capture_request_t *request);$/;" p class:CameraModule typeref:typename:int access:public signature:(camera3_capture_request_t * request) +CameraModule::requestComplete camera_module.cpp /^void CameraModule::requestComplete(Request *request,$/;" f class:CameraModule typeref:typename:void signature:(Request * request,const std::map & buffers) +CameraModule::requestComplete camera_module.h /^ void requestComplete(libcamera::Request *request,$/;" p class:CameraModule typeref:typename:void access:public signature:(libcamera::Request * request,const std::map & buffers) +CameraModule::requestTemplate_ camera_module.h /^ camera_metadata_t *requestTemplate_;$/;" m class:CameraModule typeref:typename:camera_metadata_t * access:private +CameraModule::run camera_module.cpp /^void CameraModule::run()$/;" f class:CameraModule typeref:typename:void signature:() +CameraModule::run camera_module.h /^ void run();$/;" p class:CameraModule typeref:typename:void access:public signature:() +CameraModule::setCallbacks camera_module.h /^ void setCallbacks(const camera3_callback_ops_t *callbacks)$/;" f class:CameraModule typeref:typename:void access:public signature:(const camera3_callback_ops_t * callbacks) +DATA_ALIGNMENT metadata/camera_metadata.c /^#define DATA_ALIGNMENT /;" d file: +ENTRY_ALIGNMENT metadata/camera_metadata.c /^#define ENTRY_ALIGNMENT /;" d file: +ERROR metadata/camera_metadata.c /^#define ERROR /;" d file: +FLAG_SORTED metadata/camera_metadata.c /^#define FLAG_SORTED /;" d file: +HAL_MODULE_INFO_SYM camera3_hal.cpp /^camera_module_t HAL_MODULE_INFO_SYM = {$/;" v typeref:typename:camera_module_t +LIBCAMERA_HAL_FUNC_DBG camera_module.h /^#define LIBCAMERA_HAL_FUNC_DBG /;" d +LOG camera3_hal.cpp /^ LOG(HAL, Debug) << "Open camera: " << name;$/;" l function:hal_dev_open typeref:typename:LIBCAMERA_HAL_FUNC_DBG file: +LOG_DECLARE_CATEGORY camera_module.cpp /^LOG_DECLARE_CATEGORY(HAL);$/;" p file: signature:(HAL) +LOG_DEFINE_CATEGORY camera3_hal.cpp /^LOG_DEFINE_CATEGORY(HAL);$/;" p file: signature:(HAL) +LOG_TAG metadata/camera_metadata.c /^#define LOG_TAG /;" d file: +MAX_ALIGNMENT metadata/camera_metadata.c /^#define MAX_ALIGNMENT(/;" d file: signature:(A,B) +METADATA_ALIGNMENT metadata/camera_metadata.c /^#define METADATA_ALIGNMENT /;" d file: +METADATA_ASSERT camera_module.h /^#define METADATA_ASSERT(/;" d signature:(_r) +METADATA_PACKET_ALIGNMENT metadata/camera_metadata.c /^#define METADATA_PACKET_ALIGNMENT /;" d file: +NOT_FOUND metadata/camera_metadata.c /^#define NOT_FOUND /;" d file: +OK metadata/camera_metadata.c /^#define OK /;" d file: +REQUEST_TEMPLATE_DATA camera_module.h /^#define REQUEST_TEMPLATE_DATA /;" d +REQUEST_TEMPLATE_ENTRIES camera_module.h /^#define REQUEST_TEMPLATE_ENTRIES /;" d +SN_EVENT_LOG_ID metadata/camera_metadata.c /^#define SN_EVENT_LOG_ID /;" d file: +STATIC_DATA_CAP camera3_hal.cpp /^#define STATIC_DATA_CAP /;" d file: +STATIC_ENTRY_CAP camera3_hal.cpp /^#define STATIC_ENTRY_CAP /;" d file: +__ANDROID_LIBCAMERA_HAL_H__ camera_module.h /^#define __ANDROID_LIBCAMERA_HAL_H__$/;" d +__anon2a3e460f010a metadata/camera_metadata.c /^ union {$/;" u struct:camera_metadata_buffer_entry file: access:public +__anon2a3e460f0208 metadata/camera_metadata.c /^ static const struct {$/;" s function:validate_camera_metadata_structure file: +add_camera_metadata_entry metadata/camera_metadata.c /^int add_camera_metadata_entry(camera_metadata_t *dst,$/;" f typeref:typename:int signature:(camera_metadata_t * dst,uint32_t tag,const void * data,size_t data_count) +add_camera_metadata_entry_raw metadata/camera_metadata.c /^static int add_camera_metadata_entry_raw(camera_metadata_t *dst,$/;" f typeref:typename:int file: signature:(camera_metadata_t * dst,uint32_t tag,uint8_t type,const void * data,size_t data_count) +aeAvailableModes camera3_hal.cpp /^ char aeAvailableModes[] = {$/;" l function:getStaticMetadata typeref:typename:char[] file: +aeExposureCompensation camera_module.cpp /^ int32_t aeExposureCompensation = 0;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:int32_t file: +aeLock camera_module.cpp /^ uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +aeMode camera_module.cpp /^ uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +aePrecaptureTrigger camera_module.cpp /^ uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +afTrigger camera_module.cpp /^ uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +aligned_ptr metadata/camera_metadata.c /^ uintptr_t aligned_ptr = ALIGN_TO((uintptr_t) metadata + alignmentOffset,$/;" l function:validate_camera_metadata_structure typeref:typename:uintptr_t file: +aligned_ptr metadata/camera_metadata.c /^ uintptr_t aligned_ptr = ALIGN_TO(metadata, METADATA_PACKET_ALIGNMENT);$/;" l function:validate_camera_metadata_structure typeref:typename:uintptr_t file: +alignment metadata/camera_metadata.c /^ size_t alignment;$/;" m struct:validate_camera_metadata_structure::__anon2a3e460f0208 typeref:typename:size_t file: access:public +alignmentOffset metadata/camera_metadata.c /^ const uintptr_t alignmentOffset = aligned_ptr - (uintptr_t) metadata;$/;" l function:validate_camera_metadata_structure typeref:typename:const uintptr_t file: +alignments metadata/camera_metadata.c /^ } alignments[] = {$/;" l function:validate_camera_metadata_structure typeref:typename:const struct validate_camera_metadata_structure::__anon2a3e460f0208[] file: +allocate_camera_metadata metadata/camera_metadata.c /^camera_metadata_t *allocate_camera_metadata(size_t entry_capacity,$/;" f typeref:typename:camera_metadata_t * signature:(size_t entry_capacity,size_t data_capacity) +allocate_copy_camera_metadata_checked metadata/camera_metadata.c /^camera_metadata_t *allocate_copy_camera_metadata_checked($/;" f typeref:typename:camera_metadata_t * signature:(const camera_metadata_t * src,size_t src_size) +android_black_level metadata/camera_metadata_tag_info.c /^static tag_info_t android_black_level[ANDROID_BLACK_LEVEL_END -$/;" v typeref:typename:tag_info_t[] file: +android_color_correction metadata/camera_metadata_tag_info.c /^static tag_info_t android_color_correction[ANDROID_COLOR_CORRECTION_END -$/;" v typeref:typename:tag_info_t[] file: +android_control metadata/camera_metadata_tag_info.c /^static tag_info_t android_control[ANDROID_CONTROL_END -$/;" v typeref:typename:tag_info_t[] file: +android_demosaic metadata/camera_metadata_tag_info.c /^static tag_info_t android_demosaic[ANDROID_DEMOSAIC_END -$/;" v typeref:typename:tag_info_t[] file: +android_depth metadata/camera_metadata_tag_info.c /^static tag_info_t android_depth[ANDROID_DEPTH_END -$/;" v typeref:typename:tag_info_t[] file: +android_distortion_correction metadata/camera_metadata_tag_info.c /^static tag_info_t android_distortion_correction[ANDROID_DISTORTION_CORRECTION_END -$/;" v typeref:typename:tag_info_t[] file: +android_edge metadata/camera_metadata_tag_info.c /^static tag_info_t android_edge[ANDROID_EDGE_END -$/;" v typeref:typename:tag_info_t[] file: +android_flash metadata/camera_metadata_tag_info.c /^static tag_info_t android_flash[ANDROID_FLASH_END -$/;" v typeref:typename:tag_info_t[] file: +android_flash_info metadata/camera_metadata_tag_info.c /^static tag_info_t android_flash_info[ANDROID_FLASH_INFO_END -$/;" v typeref:typename:tag_info_t[] file: +android_hot_pixel metadata/camera_metadata_tag_info.c /^static tag_info_t android_hot_pixel[ANDROID_HOT_PIXEL_END -$/;" v typeref:typename:tag_info_t[] file: +android_info metadata/camera_metadata_tag_info.c /^static tag_info_t android_info[ANDROID_INFO_END -$/;" v typeref:typename:tag_info_t[] file: +android_jpeg metadata/camera_metadata_tag_info.c /^static tag_info_t android_jpeg[ANDROID_JPEG_END -$/;" v typeref:typename:tag_info_t[] file: +android_led metadata/camera_metadata_tag_info.c /^static tag_info_t android_led[ANDROID_LED_END -$/;" v typeref:typename:tag_info_t[] file: +android_lens metadata/camera_metadata_tag_info.c /^static tag_info_t android_lens[ANDROID_LENS_END -$/;" v typeref:typename:tag_info_t[] file: +android_lens_info metadata/camera_metadata_tag_info.c /^static tag_info_t android_lens_info[ANDROID_LENS_INFO_END -$/;" v typeref:typename:tag_info_t[] file: +android_logical_multi_camera metadata/camera_metadata_tag_info.c /^static tag_info_t android_logical_multi_camera[ANDROID_LOGICAL_MULTI_CAMERA_END -$/;" v typeref:typename:tag_info_t[] file: +android_noise_reduction metadata/camera_metadata_tag_info.c /^static tag_info_t android_noise_reduction[ANDROID_NOISE_REDUCTION_END -$/;" v typeref:typename:tag_info_t[] file: +android_quirks metadata/camera_metadata_tag_info.c /^static tag_info_t android_quirks[ANDROID_QUIRKS_END -$/;" v typeref:typename:tag_info_t[] file: +android_reprocess metadata/camera_metadata_tag_info.c /^static tag_info_t android_reprocess[ANDROID_REPROCESS_END -$/;" v typeref:typename:tag_info_t[] file: +android_request metadata/camera_metadata_tag_info.c /^static tag_info_t android_request[ANDROID_REQUEST_END -$/;" v typeref:typename:tag_info_t[] file: +android_scaler metadata/camera_metadata_tag_info.c /^static tag_info_t android_scaler[ANDROID_SCALER_END -$/;" v typeref:typename:tag_info_t[] file: +android_sensor metadata/camera_metadata_tag_info.c /^static tag_info_t android_sensor[ANDROID_SENSOR_END -$/;" v typeref:typename:tag_info_t[] file: +android_sensor_info metadata/camera_metadata_tag_info.c /^static tag_info_t android_sensor_info[ANDROID_SENSOR_INFO_END -$/;" v typeref:typename:tag_info_t[] file: +android_shading metadata/camera_metadata_tag_info.c /^static tag_info_t android_shading[ANDROID_SHADING_END -$/;" v typeref:typename:tag_info_t[] file: +android_statistics metadata/camera_metadata_tag_info.c /^static tag_info_t android_statistics[ANDROID_STATISTICS_END -$/;" v typeref:typename:tag_info_t[] file: +android_statistics_info metadata/camera_metadata_tag_info.c /^static tag_info_t android_statistics_info[ANDROID_STATISTICS_INFO_END -$/;" v typeref:typename:tag_info_t[] file: +android_sync metadata/camera_metadata_tag_info.c /^static tag_info_t android_sync[ANDROID_SYNC_END -$/;" v typeref:typename:tag_info_t[] file: +android_tonemap metadata/camera_metadata_tag_info.c /^static tag_info_t android_tonemap[ANDROID_TONEMAP_END -$/;" v typeref:typename:tag_info_t[] file: +append_camera_metadata metadata/camera_metadata.c /^int append_camera_metadata(camera_metadata_t *dst,$/;" f typeref:typename:int signature:(camera_metadata_t * dst,const camera_metadata_t * src) +availableAntiBandingModes camera3_hal.cpp /^ char availableAntiBandingModes[] = {$/;" l function:getStaticMetadata typeref:typename:char[] file: +availableCapabilities camera_module.cpp /^ uint8_t availableCapabilities[] = {$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t[] file: +availableCharacteristicsKeys camera_module.cpp /^ std::vector availableCharacteristicsKeys = {$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:std::vector file: +availableRequestKeys camera_module.cpp /^ std::vector availableRequestKeys = {$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:std::vector file: +availableResultKeys camera_module.cpp /^ std::vector availableResultKeys = {$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:std::vector file: +availableStallDurations camera3_hal.cpp /^ std::vector availableStallDurations = {$/;" l function:getStaticMetadata typeref:typename:std::vector file: +availableStreamConfigurations camera3_hal.cpp /^ std::vector availableStreamConfigurations = {$/;" l function:getStaticMetadata typeref:typename:std::vector file: +availableStreamFormats camera3_hal.cpp /^ std::vector availableStreamFormats = {$/;" l function:getStaticMetadata typeref:typename:std::vector file: +awbLock camera_module.cpp /^ uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +awbLockAvailable camera3_hal.cpp /^ uint8_t awbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE;$/;" l function:getStaticMetadata typeref:typename:uint8_t file: +awbLockAvailable camera_module.cpp /^ uint8_t awbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +awbMode camera_module.cpp /^ uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +buffer metadata/camera_metadata.c /^ void *buffer = malloc(memory_needed);$/;" l function:allocate_camera_metadata typeref:typename:void * file: +buffer metadata/camera_metadata.c /^ void *buffer = malloc(src_size);$/;" l function:allocate_copy_camera_metadata_checked typeref:typename:void * file: +buffer_entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *buffer_entry = get_entries(src) + index;$/;" l function:get_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +calculate_camera_metadata_entry_data_size metadata/camera_metadata.c /^size_t calculate_camera_metadata_entry_data_size(uint8_t type,$/;" f typeref:typename:size_t signature:(uint8_t type,size_t data_count) +calculate_camera_metadata_size metadata/camera_metadata.c /^size_t calculate_camera_metadata_size(size_t entry_count,$/;" f typeref:typename:size_t signature:(size_t entry_count,size_t data_count) +callbacks_ camera_module.h /^ const camera3_callback_ops_t *callbacks_;$/;" m class:CameraModule typeref:typename:const camera3_callback_ops_t * access:private +camera camera3_hal.cpp /^ std::shared_ptr camera = cameraManager->cameras()[id];$/;" l function:hal_get_camera_info typeref:typename:std::shared_ptr file: +camera3Stream camera_module.cpp /^ camera3_stream_t *camera3Stream = stream_list->streams[0];$/;" l function:CameraModule::configureStreams typeref:typename:camera3_stream_t * file: +cameraDevice camera_module.h /^ camera3_device_t *cameraDevice() { return &cameraDevice_; }$/;" f class:CameraModule typeref:typename:camera3_device_t * access:public signature:() +cameraDevice_ camera_module.h /^ camera3_device_t cameraDevice_;$/;" m class:CameraModule typeref:typename:camera3_device_t access:private +cameraManager camera3_hal.cpp /^static libcamera::CameraManager *cameraManager;$/;" v typeref:typename:libcamera::CameraManager * file: +cameraManager_ camera_module.h /^ libcamera::CameraManager *cameraManager_;$/;" m class:CameraModule typeref:typename:libcamera::CameraManager * access:private +cameraMap camera3_hal.cpp /^static std::map cameraMap;$/;" v typeref:typename:std::map file: +cameraModule camera3_hal.cpp /^ CameraModule *cameraModule = new CameraHal(id, module, cameraManager);$/;" l function:hal_dev_open typeref:typename:CameraModule * file: +cameraModule camera3_hal.cpp /^ CameraModule *cameraModule = reinterpret_cast(dev->priv);$/;" l function:hal_dev_close typeref:typename:CameraModule * file: +camera_ camera_module.h /^ std::shared_ptr camera_;$/;" m class:CameraModule typeref:typename:std::shared_ptr access:private +camera_metadata metadata/camera_metadata.c /^struct camera_metadata {$/;" s file: +camera_metadata::data_capacity metadata/camera_metadata.c /^ metadata_size_t data_capacity;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +camera_metadata::data_count metadata/camera_metadata.c /^ metadata_size_t data_count;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +camera_metadata::data_start metadata/camera_metadata.c /^ metadata_uptrdiff_t data_start; \/\/ Offset from camera_metadata$/;" m struct:camera_metadata typeref:typename:metadata_uptrdiff_t file: access:public +camera_metadata::entries_start metadata/camera_metadata.c /^ metadata_uptrdiff_t entries_start; \/\/ Offset from camera_metadata$/;" m struct:camera_metadata typeref:typename:metadata_uptrdiff_t file: access:public +camera_metadata::entry_capacity metadata/camera_metadata.c /^ metadata_size_t entry_capacity;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +camera_metadata::entry_count metadata/camera_metadata.c /^ metadata_size_t entry_count;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +camera_metadata::flags metadata/camera_metadata.c /^ uint32_t flags;$/;" m struct:camera_metadata typeref:typename:uint32_t file: access:public +camera_metadata::padding metadata/camera_metadata.c /^ uint32_t padding; \/\/ padding to 8 bytes boundary$/;" m struct:camera_metadata typeref:typename:uint32_t file: access:public +camera_metadata::size metadata/camera_metadata.c /^ metadata_size_t size;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +camera_metadata::vendor_id metadata/camera_metadata.c /^ metadata_vendor_id_t vendor_id;$/;" m struct:camera_metadata typeref:typename:metadata_vendor_id_t file: access:public +camera_metadata::version metadata/camera_metadata.c /^ uint32_t version;$/;" m struct:camera_metadata typeref:typename:uint32_t file: access:public +camera_metadata_buffer_entry metadata/camera_metadata.c /^typedef struct camera_metadata_buffer_entry {$/;" s file: +camera_metadata_buffer_entry::__anon2a3e460f010a metadata/camera_metadata.c /^ union {$/;" u struct:camera_metadata_buffer_entry file: access:public +camera_metadata_buffer_entry::__anon2a3e460f010a::offset metadata/camera_metadata.c /^ uint32_t offset;$/;" m union:camera_metadata_buffer_entry::__anon2a3e460f010a typeref:typename:uint32_t file: access:public +camera_metadata_buffer_entry::__anon2a3e460f010a::value metadata/camera_metadata.c /^ uint8_t value[4];$/;" m union:camera_metadata_buffer_entry::__anon2a3e460f010a typeref:typename:uint8_t[4] file: access:public +camera_metadata_buffer_entry::count metadata/camera_metadata.c /^ uint32_t count;$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint32_t file: access:public +camera_metadata_buffer_entry::data metadata/camera_metadata.c /^ } data;$/;" m struct:camera_metadata_buffer_entry typeref:union:camera_metadata_buffer_entry::__anon2a3e460f010a file: access:public +camera_metadata_buffer_entry::reserved metadata/camera_metadata.c /^ uint8_t reserved[3];$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint8_t[3] file: access:public +camera_metadata_buffer_entry::tag metadata/camera_metadata.c /^ uint32_t tag;$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint32_t file: access:public +camera_metadata_buffer_entry::type metadata/camera_metadata.c /^ uint8_t type;$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint8_t file: access:public +camera_metadata_buffer_entry_t metadata/camera_metadata.c /^} camera_metadata_buffer_entry_t;$/;" t typeref:struct:camera_metadata_buffer_entry file: +camera_metadata_data metadata/camera_metadata.c /^typedef union camera_metadata_data {$/;" u file: +camera_metadata_data::d metadata/camera_metadata.c /^ double d;$/;" m union:camera_metadata_data typeref:typename:double file: access:public +camera_metadata_data::f metadata/camera_metadata.c /^ float f;$/;" m union:camera_metadata_data typeref:typename:float file: access:public +camera_metadata_data::i32 metadata/camera_metadata.c /^ int32_t i32;$/;" m union:camera_metadata_data typeref:typename:int32_t file: access:public +camera_metadata_data::i64 metadata/camera_metadata.c /^ int64_t i64;$/;" m union:camera_metadata_data typeref:typename:int64_t file: access:public +camera_metadata_data::r metadata/camera_metadata.c /^ camera_metadata_rational_t r;$/;" m union:camera_metadata_data typeref:typename:camera_metadata_rational_t file: access:public +camera_metadata_data::u8 metadata/camera_metadata.c /^ uint8_t u8;$/;" m union:camera_metadata_data typeref:typename:uint8_t file: access:public +camera_metadata_data_t metadata/camera_metadata.c /^} camera_metadata_data_t;$/;" t typeref:union:camera_metadata_data file: +camera_metadata_enum_snprint metadata/camera_metadata_tag_info.c /^int camera_metadata_enum_snprint(uint32_t tag,$/;" f typeref:typename:int signature:(uint32_t tag,uint32_t value,char * dst,size_t size) +camera_metadata_section_bounds metadata/camera_metadata_tag_info.c /^unsigned int camera_metadata_section_bounds[ANDROID_SECTION_COUNT][2] = {$/;" v typeref:typename:unsigned int[][2] +camera_metadata_section_names metadata/camera_metadata_tag_info.c /^const char *camera_metadata_section_names[ANDROID_SECTION_COUNT] = {$/;" v typeref:typename:const char * [] +camera_metadata_type_names metadata/camera_metadata.c /^const char *camera_metadata_type_names[NUM_TYPES] = {$/;" v typeref:typename:const char * [] +camera_metadata_type_size metadata/camera_metadata.c /^const size_t camera_metadata_type_size[NUM_TYPES] = {$/;" v typeref:typename:const size_t[] +captureIntent camera_module.cpp /^ uint8_t captureIntent;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +clone metadata/camera_metadata.c /^ camera_metadata_t *clone = allocate_camera_metadata($/;" l function:clone_camera_metadata typeref:typename:camera_metadata_t * file: +clone_camera_metadata metadata/camera_metadata.c /^camera_metadata_t *clone_camera_metadata(const camera_metadata_t *src) {$/;" f typeref:typename:camera_metadata_t * signature:(const camera_metadata_t * src) +close camera_module.cpp /^void CameraModule::close()$/;" f class:CameraModule typeref:typename:void signature:() +close camera_module.h /^ void close();$/;" p class:CameraModule typeref:typename:void access:public signature:() +compare_entry_tags metadata/camera_metadata.c /^static int compare_entry_tags(const void *p1, const void *p2) {$/;" f typeref:typename:int file: signature:(const void * p1,const void * p2) +config_ camera_module.h /^ std::unique_ptr config_;$/;" m class:CameraModule typeref:typename:std::unique_ptr access:private +configureStreams camera_module.cpp /^int CameraModule::configureStreams(camera3_stream_configuration_t *stream_list)$/;" f class:CameraModule typeref:typename:int signature:(camera3_stream_configuration_t * stream_list) +configureStreams camera_module.h /^ int configureStreams(camera3_stream_configuration_t *stream_list);$/;" p class:CameraModule typeref:typename:int access:public signature:(camera3_stream_configuration_t * stream_list) +controlMetadata camera3_hal.cpp /^ char controlMetadata = ANDROID_CONTROL_MODE_AUTO;$/;" l function:getStaticMetadata typeref:typename:char file: +copy_camera_metadata metadata/camera_metadata.c /^camera_metadata_t* copy_camera_metadata(void *dst, size_t dst_size,$/;" f typeref:typename:camera_metadata_t * signature:(void * dst,size_t dst_size,const camera_metadata_t * src) +count metadata/camera_metadata.c /^ int count = entry->count;$/;" l function:dump_indented_camera_metadata typeref:typename:int file: +count metadata/camera_metadata.c /^ uint32_t count;$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint32_t file: access:public +d metadata/camera_metadata.c /^ double d;$/;" m union:camera_metadata_data typeref:typename:double file: access:public +data metadata/camera_metadata.c /^ camera_metadata_data_t *data =$/;" l function:validate_camera_metadata_structure typeref:typename:camera_metadata_data_t * file: +data metadata/camera_metadata.c /^ } data;$/;" m struct:camera_metadata_buffer_entry typeref:union:camera_metadata_buffer_entry::__anon2a3e460f010a file: access:public +data_bytes metadata/camera_metadata.c /^ size_t data_bytes = calculate_camera_metadata_entry_data_size(entry->type,$/;" l function:delete_camera_metadata_entry typeref:typename:size_t file: +data_bytes metadata/camera_metadata.c /^ size_t data_bytes = data_count * camera_metadata_type_size[type];$/;" l function:validate_and_calculate_camera_metadata_entry_data_size typeref:typename:size_t file: +data_bytes metadata/camera_metadata.c /^ size_t data_bytes = data_count *$/;" l function:calculate_camera_metadata_entry_data_size typeref:typename:size_t file: +data_bytes metadata/camera_metadata.c /^ size_t data_bytes =$/;" l function:add_camera_metadata_entry_raw typeref:typename:size_t file: +data_bytes metadata/camera_metadata.c /^ size_t data_bytes =$/;" l function:update_camera_metadata_entry typeref:typename:size_t file: +data_capacity metadata/camera_metadata.c /^ metadata_size_t data_capacity;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +data_count metadata/camera_metadata.c /^ metadata_size_t data_count;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +data_end metadata/camera_metadata.c /^ const metadata_uptrdiff_t data_end =$/;" l function:validate_camera_metadata_structure typeref:typename:const metadata_uptrdiff_t file: +data_entry_end metadata/camera_metadata.c /^ size_t data_entry_end = entry.data.offset + data_size;$/;" l function:validate_camera_metadata_structure typeref:typename:size_t file: +data_payload_bytes metadata/camera_metadata.c /^ size_t data_payload_bytes =$/;" l function:add_camera_metadata_entry_raw typeref:typename:size_t file: +data_payload_bytes metadata/camera_metadata.c /^ size_t data_payload_bytes =$/;" l function:update_camera_metadata_entry typeref:typename:size_t file: +data_ptr metadata/camera_metadata.c /^ uint8_t *data_ptr;$/;" l function:dump_indented_camera_metadata typeref:typename:uint8_t * file: +data_size metadata/camera_metadata.c /^ size_t data_size;$/;" l function:validate_camera_metadata_structure typeref:typename:size_t file: +data_start metadata/camera_metadata.c /^ metadata_uptrdiff_t data_start; \/\/ Offset from camera_metadata$/;" m struct:camera_metadata typeref:typename:metadata_uptrdiff_t file: access:public +data_unaligned metadata/camera_metadata.c /^ size_t data_unaligned = (uint8_t*)(get_entries(metadata) +$/;" l function:place_camera_metadata typeref:typename:size_t file: +delete_camera_metadata_entry metadata/camera_metadata.c /^int delete_camera_metadata_entry(camera_metadata_t *dst,$/;" f typeref:typename:int signature:(camera_metadata_t * dst,size_t index) +denominator metadata/camera_metadata.c /^ int32_t denominator = *(int32_t*)(data_ptr + index + 4);$/;" l function:print_data typeref:typename:int32_t file: +dev camera3_hal.cpp /^ camera3_device_t *dev = reinterpret_cast(hw_device);$/;" l function:hal_dev_close typeref:typename:camera3_device_t * file: +dispatcher camera_module.cpp /^ EventDispatcher *dispatcher = cameraManager_->eventDispatcher();$/;" l function:CameraModule::run typeref:typename:EventDispatcher * file: +dump_camera_metadata metadata/camera_metadata.c /^void dump_camera_metadata(const camera_metadata_t *metadata,$/;" f typeref:typename:void signature:(const camera_metadata_t * metadata,int fd,int verbosity) +dump_indented_camera_metadata metadata/camera_metadata.c /^void dump_indented_camera_metadata(const camera_metadata_t *metadata,$/;" f typeref:typename:void signature:(const camera_metadata_t * metadata,int fd,int verbosity,int indentation) +e metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *e = get_entries(dst);$/;" l function:update_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +e metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *e = get_entries(dst);$/;" l function:delete_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +end metadata/camera_metadata.c /^ uint8_t *end = start + entry_bytes;$/;" l function:update_camera_metadata_entry typeref:typename:uint8_t * file: +end metadata/camera_metadata.c /^ uint8_t *end = start + data_bytes;$/;" l function:delete_camera_metadata_entry typeref:typename:uint8_t * file: +entries metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *entries = get_entries(metadata);$/;" l function:validate_camera_metadata_structure typeref:typename:camera_metadata_buffer_entry_t * file: +entries_end metadata/camera_metadata.c /^ const metadata_uptrdiff_t entries_end =$/;" l function:validate_camera_metadata_structure typeref:typename:const metadata_uptrdiff_t file: +entries_start metadata/camera_metadata.c /^ metadata_uptrdiff_t entries_start; \/\/ Offset from camera_metadata$/;" m struct:camera_metadata typeref:typename:metadata_uptrdiff_t file: access:public +entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *entry = get_entries(dst) + dst->entry_count;$/;" l function:append_camera_metadata typeref:typename:camera_metadata_buffer_entry_t * file: +entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t entry = entries[i];$/;" l function:validate_camera_metadata_structure typeref:typename:camera_metadata_buffer_entry_t file: +entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *entry = get_entries(dst) + dst->entry_count;$/;" l function:add_camera_metadata_entry_raw typeref:typename:camera_metadata_buffer_entry_t * file: +entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *entry = get_entries(dst) + index;$/;" l function:delete_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *entry = get_entries(dst) + index;$/;" l function:update_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *entry = get_entries(metadata);$/;" l function:dump_indented_camera_metadata typeref:typename:camera_metadata_buffer_entry_t * file: +entry_bytes metadata/camera_metadata.c /^ size_t entry_bytes =$/;" l function:update_camera_metadata_entry typeref:typename:size_t file: +entry_capacity metadata/camera_metadata.c /^ metadata_size_t entry_capacity;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +entry_count metadata/camera_metadata.c /^ const metadata_size_t entry_count = metadata->entry_count;$/;" l function:validate_camera_metadata_structure typeref:typename:const metadata_size_t file: +entry_count metadata/camera_metadata.c /^ metadata_size_t entry_count;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +exposureTimeRange camera3_hal.cpp /^ int64_t exposureTimeRange[] = {$/;" l function:getStaticMetadata typeref:typename:int64_t[] file: +f metadata/camera_metadata.c /^ float f;$/;" m union:camera_metadata_data typeref:typename:float file: access:public +faceDetectMode camera_module.cpp /^ uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +filterArr camera3_hal.cpp /^ uint16_t filterArr = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG;$/;" l function:getStaticMetadata typeref:typename:uint16_t file: +find_camera_metadata_entry metadata/camera_metadata.c /^int find_camera_metadata_entry(camera_metadata_t *src,$/;" f typeref:typename:int signature:(camera_metadata_t * src,uint32_t tag,camera_metadata_entry_t * entry) +find_camera_metadata_ro_entry metadata/camera_metadata.c /^int find_camera_metadata_ro_entry(const camera_metadata_t *src,$/;" f typeref:typename:int signature:(const camera_metadata_t * src,uint32_t tag,camera_metadata_ro_entry_t * entry) +flags metadata/camera_metadata.c /^ uint32_t flags;$/;" m struct:camera_metadata typeref:typename:uint32_t file: access:public +flashAvailable camera3_hal.cpp /^ char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE;$/;" l function:getStaticMetadata typeref:typename:char file: +flashMode camera_module.cpp /^ uint8_t flashMode = ANDROID_FLASH_MODE_OFF;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +fn camera3_hal.cpp /^ float fn = 2.53 \/ 100;$/;" l function:getStaticMetadata typeref:typename:float file: +free_camera_metadata metadata/camera_metadata.c /^void free_camera_metadata(camera_metadata_t *metadata) {$/;" f typeref:typename:void signature:(camera_metadata_t * metadata) +generateDefaultRequestMetadata camera_module.cpp /^const camera_metadata_t *CameraModule::generateDefaultRequestMetadata(int type)$/;" f class:CameraModule typeref:typename:const camera_metadata_t * signature:(int type) +generateDefaultRequestMetadata camera_module.h /^ const camera_metadata_t *generateDefaultRequestMetadata(int type);$/;" p class:CameraModule typeref:typename:const camera_metadata_t * access:public signature:(int type) +getStaticMetadata camera3_hal.cpp /^static camera_metadata_t *getStaticMetadata(unsigned int id)$/;" f typeref:typename:camera_metadata_t * file: signature:(unsigned int id) +get_camera_metadata_alignment metadata/camera_metadata.c /^size_t get_camera_metadata_alignment() {$/;" f typeref:typename:size_t signature:() +get_camera_metadata_compact_size metadata/camera_metadata.c /^size_t get_camera_metadata_compact_size(const camera_metadata_t *metadata) {$/;" f typeref:typename:size_t signature:(const camera_metadata_t * metadata) +get_camera_metadata_data_capacity metadata/camera_metadata.c /^size_t get_camera_metadata_data_capacity(const camera_metadata_t *metadata) {$/;" f typeref:typename:size_t signature:(const camera_metadata_t * metadata) +get_camera_metadata_data_count metadata/camera_metadata.c /^size_t get_camera_metadata_data_count(const camera_metadata_t *metadata) {$/;" f typeref:typename:size_t signature:(const camera_metadata_t * metadata) +get_camera_metadata_entry metadata/camera_metadata.c /^int get_camera_metadata_entry(camera_metadata_t *src,$/;" f typeref:typename:int signature:(camera_metadata_t * src,size_t index,camera_metadata_entry_t * entry) +get_camera_metadata_entry_capacity metadata/camera_metadata.c /^size_t get_camera_metadata_entry_capacity(const camera_metadata_t *metadata) {$/;" f typeref:typename:size_t signature:(const camera_metadata_t * metadata) +get_camera_metadata_entry_count metadata/camera_metadata.c /^size_t get_camera_metadata_entry_count(const camera_metadata_t *metadata) {$/;" f typeref:typename:size_t signature:(const camera_metadata_t * metadata) +get_camera_metadata_ro_entry metadata/camera_metadata.c /^int get_camera_metadata_ro_entry(const camera_metadata_t *src,$/;" f typeref:typename:int signature:(const camera_metadata_t * src,size_t index,camera_metadata_ro_entry_t * entry) +get_camera_metadata_section_name metadata/camera_metadata.c /^const char *get_camera_metadata_section_name(uint32_t tag) {$/;" f typeref:typename:const char * signature:(uint32_t tag) +get_camera_metadata_size metadata/camera_metadata.c /^size_t get_camera_metadata_size(const camera_metadata_t *metadata) {$/;" f typeref:typename:size_t signature:(const camera_metadata_t * metadata) +get_camera_metadata_tag_name metadata/camera_metadata.c /^const char *get_camera_metadata_tag_name(uint32_t tag) {$/;" f typeref:typename:const char * signature:(uint32_t tag) +get_camera_metadata_tag_type metadata/camera_metadata.c /^int get_camera_metadata_tag_type(uint32_t tag) {$/;" f typeref:typename:int signature:(uint32_t tag) +get_camera_metadata_vendor_id metadata/camera_metadata.c /^metadata_vendor_id_t get_camera_metadata_vendor_id($/;" f typeref:typename:metadata_vendor_id_t signature:(const camera_metadata_t * meta) +get_data metadata/camera_metadata.c /^static uint8_t *get_data(const camera_metadata_t *metadata) {$/;" f typeref:typename:uint8_t * file: signature:(const camera_metadata_t * metadata) +get_entries metadata/camera_metadata.c /^static camera_metadata_buffer_entry_t *get_entries($/;" f typeref:typename:camera_metadata_buffer_entry_t * file: signature:(const camera_metadata_t * metadata) +get_local_camera_metadata_section_name metadata/camera_metadata.c /^const char *get_local_camera_metadata_section_name(uint32_t tag,$/;" f typeref:typename:const char * signature:(uint32_t tag,const camera_metadata_t * meta) +get_local_camera_metadata_section_name_vendor_id metadata/camera_metadata.c /^const char *get_local_camera_metadata_section_name_vendor_id(uint32_t tag,$/;" f typeref:typename:const char * signature:(uint32_t tag,metadata_vendor_id_t id) +get_local_camera_metadata_tag_name metadata/camera_metadata.c /^const char *get_local_camera_metadata_tag_name(uint32_t tag,$/;" f typeref:typename:const char * signature:(uint32_t tag,const camera_metadata_t * meta) +get_local_camera_metadata_tag_name_vendor_id metadata/camera_metadata.c /^const char *get_local_camera_metadata_tag_name_vendor_id(uint32_t tag,$/;" f typeref:typename:const char * signature:(uint32_t tag,metadata_vendor_id_t id) +get_local_camera_metadata_tag_type metadata/camera_metadata.c /^int get_local_camera_metadata_tag_type(uint32_t tag,$/;" f typeref:typename:int signature:(uint32_t tag,const camera_metadata_t * meta) +get_local_camera_metadata_tag_type_vendor_id metadata/camera_metadata.c /^int get_local_camera_metadata_tag_type_vendor_id(uint32_t tag,$/;" f typeref:typename:int signature:(uint32_t tag,metadata_vendor_id_t id) +hal_dev_close camera3_hal.cpp /^static int hal_dev_close(hw_device_t *hw_device)$/;" f typeref:typename:int file: signature:(hw_device_t * hw_device) +hal_dev_configure_streams camera_module.cpp /^static int hal_dev_configure_streams(const struct camera3_device *dev,$/;" f typeref:typename:int file: signature:(const struct camera3_device * dev,camera3_stream_configuration_t * stream_list) +hal_dev_construct_default_request_settings camera_module.cpp /^hal_dev_construct_default_request_settings(const struct camera3_device *dev,$/;" f typeref:typename:const camera_metadata_t * file: signature:(const struct camera3_device * dev,int type) +hal_dev_dump camera_module.cpp /^static void hal_dev_dump(const struct camera3_device *dev, int fd)$/;" f typeref:typename:void file: signature:(const struct camera3_device * dev,int fd) +hal_dev_flush camera_module.cpp /^static int hal_dev_flush(const struct camera3_device *dev)$/;" f typeref:typename:int file: signature:(const struct camera3_device * dev) +hal_dev_initialize camera_module.cpp /^static int hal_dev_initialize(const struct camera3_device *dev,$/;" f typeref:typename:int file: signature:(const struct camera3_device * dev,const camera3_callback_ops_t * callback_ops) +hal_dev_open camera3_hal.cpp /^static int hal_dev_open(const hw_module_t* module, const char* name,$/;" f typeref:typename:int file: signature:(const hw_module_t * module,const char * name,hw_device_t ** device) +hal_dev_ops camera_module.cpp /^static camera3_device_ops hal_dev_ops = {$/;" v typeref:typename:camera3_device_ops file: +hal_dev_process_capture_request camera_module.cpp /^static int hal_dev_process_capture_request(const struct camera3_device *dev,$/;" f typeref:typename:int file: signature:(const struct camera3_device * dev,camera3_capture_request_t * request) +hal_get_camera_info camera3_hal.cpp /^static int hal_get_camera_info(int id, struct camera_info *info)$/;" f typeref:typename:int file: signature:(int id,struct camera_info * info) +hal_get_number_of_cameras camera3_hal.cpp /^static int hal_get_number_of_cameras(void)$/;" f typeref:typename:int file: signature:(void) +hal_init camera3_hal.cpp /^static int hal_init()$/;" f typeref:typename:int file: signature:() +hal_module_methods camera3_hal.cpp /^static struct hw_module_methods_t hal_module_methods = {$/;" v typeref:struct:hw_module_methods_t file: +hal_open_legacy camera3_hal.cpp /^static int hal_open_legacy(const struct hw_module_t* module, const char* id,$/;" f typeref:typename:int file: signature:(const struct hw_module_t * module,const char * id,uint32_t halVersion,struct hw_device_t ** device) +hal_set_callbacks camera3_hal.cpp /^static int hal_set_callbacks(const camera_module_callbacks_t *callbacks)$/;" f typeref:typename:int file: signature:(const camera_module_callbacks_t * callbacks) +hal_set_torch_mode camera3_hal.cpp /^static int hal_set_torch_mode(const char* camera_id, bool enabled)$/;" f typeref:typename:int file: signature:(const char * camera_id,bool enabled) +i camera_module.cpp /^ for (unsigned int i = 0; i < stream_list->num_streams; ++i) {$/;" l function:hal_dev_configure_streams typeref:typename:unsigned int file: +i metadata/camera_metadata.c /^ size_t i;$/;" l function:update_camera_metadata_entry typeref:typename:size_t file: +i metadata/camera_metadata.c /^ for (size_t i = 0; i < sizeof(alignments)\/sizeof(alignments[0]); ++i) {$/;" l function:validate_camera_metadata_structure typeref:typename:size_t file: +i metadata/camera_metadata.c /^ for (size_t i = 0; i < src->entry_count; i++, entry++) {$/;" l function:append_camera_metadata typeref:typename:size_t file: +i metadata/camera_metadata.c /^ size_t i;$/;" l function:delete_camera_metadata_entry typeref:typename:size_t file: +i metadata/camera_metadata.c /^ for (size_t i = 0; i < entry_count; ++i) {$/;" l function:validate_camera_metadata_structure typeref:typename:size_t file: +i metadata/camera_metadata.c /^ unsigned int i;$/;" l function:dump_indented_camera_metadata typeref:typename:unsigned int file: +i32 metadata/camera_metadata.c /^ int32_t i32;$/;" m union:camera_metadata_data typeref:typename:int32_t file: access:public +i64 metadata/camera_metadata.c /^ int64_t i64;$/;" m union:camera_metadata_data typeref:typename:int64_t file: access:public +id camera3_hal.cpp /^ int id = atoi(name);$/;" l function:hal_dev_open typeref:typename:int file: +id camera3_hal.cpp /^ unsigned int id = cameraModule->id();$/;" l function:hal_dev_close typeref:typename:unsigned int file: +id camera_module.h /^ unsigned int id() const { return id_; }$/;" f class:CameraModule typeref:typename:unsigned int access:public signature:() const +id metadata/camera_metadata.c /^ metadata_vendor_id_t id = (NULL == meta) ? CAMERA_METADATA_INVALID_VENDOR_ID :$/;" l function:get_local_camera_metadata_section_name typeref:typename:metadata_vendor_id_t file: +id metadata/camera_metadata.c /^ metadata_vendor_id_t id = (NULL == meta) ? CAMERA_METADATA_INVALID_VENDOR_ID :$/;" l function:get_local_camera_metadata_tag_name typeref:typename:metadata_vendor_id_t file: +id metadata/camera_metadata.c /^ metadata_vendor_id_t id = (NULL == meta) ? CAMERA_METADATA_INVALID_VENDOR_ID :$/;" l function:get_local_camera_metadata_tag_type typeref:typename:metadata_vendor_id_t file: +id_ camera_module.h /^ unsigned int id_;$/;" m class:CameraModule typeref:typename:unsigned int access:private +index metadata/camera_metadata.c /^ int index = 0;$/;" l function:print_data typeref:typename:int file: +index metadata/camera_metadata.c /^ uint32_t index;$/;" l function:find_camera_metadata_entry typeref:typename:uint32_t file: +init camera_module.cpp /^int CameraModule::init()$/;" f class:CameraModule typeref:typename:int signature:() +init camera_module.h /^ int init();$/;" p class:CameraModule typeref:typename:int access:public signature:() +inputStreams camera_module.cpp /^ int32_t inputStreams = 0;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:int32_t file: +it camera_module.cpp /^ for (const auto &it : buffers)$/;" l function:CameraModule::requestComplete typeref:typename:const auto & file: +j metadata/camera_metadata.c /^ int j, k;$/;" l function:print_data typeref:typename:int file: +k metadata/camera_metadata.c /^ int j, k;$/;" l function:print_data typeref:typename:int file: +key metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t key;$/;" l function:find_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t file: +length metadata/camera_metadata.c /^ size_t length = dst->data_count - entry->data.offset - entry_bytes;$/;" l function:update_camera_metadata_entry typeref:typename:size_t file: +length metadata/camera_metadata.c /^ size_t length = dst->data_count - entry->data.offset - data_bytes;$/;" l function:delete_camera_metadata_entry typeref:typename:size_t file: +libcameraHal camera_module.cpp /^ CameraModule *libcameraHal = reinterpret_cast(dev->priv);$/;" l function:hal_dev_configure_streams typeref:typename:CameraModule * file: +libcameraHal camera_module.cpp /^ CameraModule *libcameraHal = reinterpret_cast(dev->priv);$/;" l function:hal_dev_construct_default_request_settings typeref:typename:CameraModule * file: +libcameraHal camera_module.cpp /^ CameraModule *libcameraHal = reinterpret_cast(dev->priv);$/;" l function:hal_dev_initialize typeref:typename:CameraModule * file: +libcameraHal camera_module.cpp /^ CameraModule *libcameraHal = reinterpret_cast(dev->priv);$/;" l function:hal_dev_process_capture_request typeref:typename:CameraModule * file: +lines metadata/camera_metadata.c /^ int lines = count \/ values_per_line[type];$/;" l function:print_data typeref:typename:int file: +maxOutStream camera_module.cpp /^ int32_t maxOutStream[] = { 0, 2, 0};$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:int32_t[] file: +maxPipelineDepth camera_module.cpp /^ uint8_t maxPipelineDepth = 5;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:uint8_t file: +memory_needed metadata/camera_metadata.c /^ size_t memory_needed = calculate_camera_metadata_size(entry_capacity,$/;" l function:allocate_camera_metadata typeref:typename:size_t file: +memory_needed metadata/camera_metadata.c /^ size_t memory_needed = calculate_camera_metadata_size(entry_capacity,$/;" l function:place_camera_metadata typeref:typename:size_t file: +memory_needed metadata/camera_metadata.c /^ size_t memory_needed = get_camera_metadata_compact_size(src);$/;" l function:copy_camera_metadata typeref:typename:size_t file: +memory_needed metadata/camera_metadata.c /^ size_t memory_needed = sizeof(camera_metadata_t);$/;" l function:calculate_camera_metadata_size typeref:typename:size_t file: +metadata metadata/camera_metadata.c /^ camera_metadata_t *metadata = (camera_metadata_t*) buffer;$/;" l function:allocate_copy_camera_metadata_checked typeref:typename:camera_metadata_t * file: +metadata metadata/camera_metadata.c /^ camera_metadata_t *metadata = (camera_metadata_t*)dst;$/;" l function:place_camera_metadata typeref:typename:camera_metadata_t * file: +metadata metadata/camera_metadata.c /^ camera_metadata_t *metadata = place_camera_metadata($/;" l function:allocate_camera_metadata typeref:typename:camera_metadata_t * file: +metadata metadata/camera_metadata.c /^ camera_metadata_t *metadata =$/;" l function:copy_camera_metadata typeref:typename:camera_metadata_t * file: +metadataMap camera3_hal.cpp /^static std::map metadataMap;$/;" v typeref:typename:std::map file: +metadata_size_t metadata/camera_metadata.c /^typedef uint32_t metadata_size_t;$/;" t typeref:typename:uint32_t file: +metadata_uptrdiff_t metadata/camera_metadata.c /^typedef uint32_t metadata_uptrdiff_t;$/;" t typeref:typename:uint32_t file: +minFrameDurations camera3_hal.cpp /^ std::vector minFrameDurations = {$/;" l function:getStaticMetadata typeref:typename:std::vector file: +module_ camera_module.h /^ const hw_module_t *module_;$/;" m class:CameraModule typeref:typename:const hw_module_t * access:private +msg metadata/camera_metadata_tag_info.c /^ const char *msg = "error: not an enum";$/;" l function:camera_metadata_enum_snprint typeref:typename:const char * file: +name metadata/camera_metadata.c /^ const char *name;$/;" m struct:validate_camera_metadata_structure::__anon2a3e460f0208 typeref:typename:const char * file: access:public +numCameras camera3_hal.cpp /^ int numCameras = cameraManager->cameras().size();$/;" l function:hal_get_camera_info typeref:typename:LIBCAMERA_HAL_FUNC_DBG int file: +numerator metadata/camera_metadata.c /^ int32_t numerator = *(int32_t*)(data_ptr + index);$/;" l function:print_data typeref:typename:int32_t file: +offset metadata/camera_metadata.c /^ uint32_t offset;$/;" m union:camera_metadata_buffer_entry::__anon2a3e460f010a typeref:typename:uint32_t file: access:public +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_buffer_entry_t, count) == 4,$/;" p typeref:typename:_Static_assert (==4,"Offset of count must be 4") file: signature:(camera_metadata_buffer_entry_t,count) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_buffer_entry_t, data) == 8,$/;" p typeref:typename:_Static_assert (==8,"Offset of data must be 8") file: signature:(camera_metadata_buffer_entry_t,data) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_buffer_entry_t, tag) == 0,$/;" p typeref:typename:_Static_assert (==0,"Offset of tag must be 0") file: signature:(camera_metadata_buffer_entry_t,tag) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_buffer_entry_t, type) == 12,$/;" p typeref:typename:_Static_assert (==12,"Offset of type must be 12") file: signature:(camera_metadata_buffer_entry_t,type) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, data_capacity) == 28,$/;" p typeref:typename:_Static_assert (==28,"Offset of data_capacity must be 28") file: signature:(camera_metadata_t,data_capacity) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, data_count) == 24,$/;" p typeref:typename:_Static_assert (==24,"Offset of data_count must be 24") file: signature:(camera_metadata_t,data_count) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, data_start) == 32,$/;" p typeref:typename:_Static_assert (==32,"Offset of data_start must be 32") file: signature:(camera_metadata_t,data_start) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, entries_start) == 20,$/;" p typeref:typename:_Static_assert (==20,"Offset of entries_start must be 20") file: signature:(camera_metadata_t,entries_start) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, entry_capacity) == 16,$/;" p typeref:typename:_Static_assert (==16,"Offset of entry_capacity must be 16") file: signature:(camera_metadata_t,entry_capacity) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, entry_count) == 12,$/;" p typeref:typename:_Static_assert (==12,"Offset of entry_count must be 12") file: signature:(camera_metadata_t,entry_count) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, flags) == 8,$/;" p typeref:typename:_Static_assert (==8,"Offset of flags must be 8") file: signature:(camera_metadata_t,flags) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, size) == 0,$/;" p typeref:typename:_Static_assert (==0,"Offset of size must be 0") file: signature:(camera_metadata_t,size) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, vendor_id) == 40,$/;" p typeref:typename:_Static_assert (==40,"Offset of vendor_id must be 40") file: signature:(camera_metadata_t,vendor_id) +offsetof metadata/camera_metadata.c /^_Static_assert(offsetof(camera_metadata_t, version) == 4,$/;" p typeref:typename:_Static_assert (==4,"Offset of version must be 4") file: signature:(camera_metadata_t,version) +orientation camera3_hal.cpp /^ int32_t orientation = 0;$/;" l function:getStaticMetadata typeref:typename:int32_t file: +padding metadata/camera_metadata.c /^ uint32_t padding; \/\/ padding to 8 bytes boundary$/;" m struct:camera_metadata typeref:typename:uint32_t file: access:public +partialResultCount camera_module.cpp /^ int32_t partialResultCount = 1;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:int32_t file: +pixelArraySize camera3_hal.cpp /^ int32_t pixelArraySize[] = {$/;" l function:getStaticMetadata typeref:typename:int32_t[] file: +place_camera_metadata metadata/camera_metadata.c /^camera_metadata_t *place_camera_metadata(void *dst,$/;" f typeref:typename:camera_metadata_t * signature:(void * dst,size_t dst_size,size_t entry_capacity,size_t data_capacity) +print_data metadata/camera_metadata.c /^static void print_data(int fd, const uint8_t *data_ptr, uint32_t tag, int type,$/;" p typeref:typename:void file: signature:(int fd,const uint8_t * data_ptr,uint32_t tag,int type,int count,int indentation) +print_data metadata/camera_metadata.c /^static void print_data(int fd, const uint8_t *data_ptr, uint32_t tag,$/;" f typeref:typename:void file: signature:(int fd,const uint8_t * data_ptr,uint32_t tag,int type,int count,int indentation) +processCaptureRequest camera_module.cpp /^int CameraModule::processCaptureRequest(camera3_capture_request_t *camera3Request)$/;" f class:CameraModule typeref:typename:int signature:(camera3_capture_request_t * camera3Request) +processCaptureRequest camera_module.h /^ int processCaptureRequest(camera3_capture_request_t *request);$/;" p class:CameraModule typeref:typename:int access:public signature:(camera3_capture_request_t * request) +r metadata/camera_metadata.c /^ camera_metadata_rational_t r;$/;" m union:camera_metadata_data typeref:typename:camera_metadata_rational_t file: access:public +requestComplete camera_module.cpp /^void CameraModule::requestComplete(Request *request,$/;" f class:CameraModule typeref:typename:void signature:(Request * request,const std::map & buffers) +requestComplete camera_module.h /^ void requestComplete(libcamera::Request *request,$/;" p class:CameraModule typeref:typename:void access:public signature:(libcamera::Request * request,const std::map & buffers) +requestTemplate_ camera_module.h /^ camera_metadata_t *requestTemplate_;$/;" m class:CameraModule typeref:typename:camera_metadata_t * access:private +res metadata/camera_metadata.c /^ int res;$/;" l function:clone_camera_metadata typeref:typename:int file: +reserved metadata/camera_metadata.c /^ uint8_t reserved[3];$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint8_t[3] file: access:public +ret camera3_hal.cpp /^ int ret = cameraManager->start();$/;" l function:hal_init typeref:typename:int file: +ret camera3_hal.cpp /^ int ret;$/;" l function:getStaticMetadata typeref:typename:int file: +ret camera_module.cpp /^ int ret = camera_->allocateBuffers();$/;" l function:CameraModule::processCaptureRequest typeref:typename:int file: +ret camera_module.cpp /^ int ret = camera_->configure(config_.get());$/;" l function:CameraModule::configureStreams typeref:typename:int file: +ret camera_module.cpp /^ int ret;$/;" l function:CameraModule::generateDefaultRequestMetadata typeref:typename:int file: +ret metadata/camera_metadata.c /^ metadata_vendor_id_t ret = CAMERA_METADATA_INVALID_VENDOR_ID;$/;" l function:get_camera_metadata_vendor_id typeref:typename:metadata_vendor_id_t file: +ret metadata/camera_metadata_tag_info.c /^ int ret = -1;$/;" l function:camera_metadata_enum_snprint typeref:typename:int file: +roles camera_module.cpp /^ StreamRoles roles = {};$/;" l function:CameraModule::configureStreams typeref:typename:StreamRoles file: +run camera_module.cpp /^void CameraModule::run()$/;" f class:CameraModule typeref:typename:void signature:() +run camera_module.h /^ void run();$/;" p class:CameraModule typeref:typename:void access:public signature:() +search_entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *search_entry = NULL;$/;" l function:find_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +search_entry metadata/camera_metadata.c /^ camera_metadata_buffer_entry_t *search_entry = get_entries(src);$/;" l function:find_camera_metadata_entry typeref:typename:camera_metadata_buffer_entry_t * file: +sensitivityRange camera3_hal.cpp /^ int32_t sensitivityRange[] = {$/;" l function:getStaticMetadata typeref:typename:int32_t[] file: +sensorSizes camera3_hal.cpp /^ int32_t sensorSizes[] = {$/;" l function:getStaticMetadata typeref:typename:int32_t[] file: +setCallbacks camera_module.h /^ void setCallbacks(const camera3_callback_ops_t *callbacks)$/;" f class:CameraModule typeref:typename:void access:public signature:(const camera3_callback_ops_t * callbacks) +set_camera_metadata_vendor_cache_ops metadata/camera_metadata.c /^int set_camera_metadata_vendor_cache_ops($/;" f typeref:typename:int signature:(const struct vendor_tag_cache_ops * query_cache_ops) +set_camera_metadata_vendor_id metadata/camera_metadata.c /^void set_camera_metadata_vendor_id(camera_metadata_t *meta,$/;" f typeref:typename:void signature:(camera_metadata_t * meta,metadata_vendor_id_t id) +set_camera_metadata_vendor_ops metadata/camera_metadata.c /^int set_camera_metadata_vendor_ops(const vendor_tag_ops_t* ops) {$/;" f typeref:typename:int signature:(const vendor_tag_ops_t * ops) +set_camera_metadata_vendor_tag_ops metadata/camera_metadata.c /^int set_camera_metadata_vendor_tag_ops(const vendor_tag_query_ops_t* ops) {$/;" f typeref:typename:int signature:(const vendor_tag_query_ops_t * ops) +size metadata/camera_metadata.c /^ metadata_size_t size;$/;" m struct:camera_metadata typeref:typename:metadata_size_t file: access:public +sort_camera_metadata metadata/camera_metadata.c /^int sort_camera_metadata(camera_metadata_t *dst) {$/;" f typeref:typename:int signature:(camera_metadata_t * dst) +start metadata/camera_metadata.c /^ uint8_t *start = get_data(dst) + entry->data.offset;$/;" l function:update_camera_metadata_entry typeref:typename:uint8_t * file: +start metadata/camera_metadata.c /^ uint8_t *start = get_data(dst) + entry->data.offset;$/;" l function:delete_camera_metadata_entry typeref:typename:uint8_t * file: +staticMetadata camera3_hal.cpp /^ camera_metadata_t *staticMetadata = allocate_camera_metadata(STATIC_ENTRY_CAP,$/;" l function:getStaticMetadata typeref:typename:camera_metadata_t * file: +staticMetadata camera3_hal.cpp /^ camera_metadata_t *staticMetadata = getStaticMetadata(id);$/;" l function:hal_get_camera_info typeref:typename:camera_metadata_t * file: +stream camera_module.cpp /^ camera3_stream_t *stream = stream_list->streams[i];$/;" l function:hal_dev_configure_streams typeref:typename:camera3_stream_t * file: +streamConfiguration camera_module.cpp /^ StreamConfiguration *streamConfiguration = &config_->at(0);$/;" l function:CameraModule::configureStreams typeref:typename:StreamConfiguration * file: +supportedHWLevel camera3_hal.cpp /^ uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;$/;" l function:getStaticMetadata typeref:typename:uint8_t file: +tag metadata/camera_metadata.c /^ uint32_t tag;$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint32_t file: access:public +tag1 metadata/camera_metadata.c /^ uint32_t tag1 = ((camera_metadata_buffer_entry_t*)p1)->tag;$/;" l function:compare_entry_tags typeref:typename:uint32_t file: +tag2 metadata/camera_metadata.c /^ uint32_t tag2 = ((camera_metadata_buffer_entry_t*)p2)->tag;$/;" l function:compare_entry_tags typeref:typename:uint32_t file: +tag_index metadata/camera_metadata.c /^ uint32_t tag_index = tag & 0xFFFF;$/;" l function:get_local_camera_metadata_tag_name_vendor_id typeref:typename:uint32_t file: +tag_index metadata/camera_metadata.c /^ uint32_t tag_index = tag & 0xFFFF;$/;" l function:get_local_camera_metadata_tag_type_vendor_id typeref:typename:uint32_t file: +tag_info metadata/camera_metadata.c /^typedef struct tag_info {$/;" s file: +tag_info metadata/camera_metadata_tag_info.c /^tag_info_t *tag_info[ANDROID_SECTION_COUNT] = {$/;" v typeref:typename:tag_info_t * [] +tag_info::tag_name metadata/camera_metadata.c /^ const char *tag_name;$/;" m struct:tag_info typeref:typename:const char * file: access:public +tag_info::tag_type metadata/camera_metadata.c /^ uint8_t tag_type;$/;" m struct:tag_info typeref:typename:uint8_t file: access:public +tag_info_t metadata/camera_metadata.c /^} tag_info_t;$/;" t typeref:struct:tag_info file: +tag_name metadata/camera_metadata.c /^ const char *tag_name, *tag_section;$/;" l function:dump_indented_camera_metadata typeref:typename:const char * file: +tag_name metadata/camera_metadata.c /^ const char *tag_name;$/;" m struct:tag_info typeref:typename:const char * file: access:public +tag_section metadata/camera_metadata.c /^ const char *tag_name, *tag_section;$/;" l function:dump_indented_camera_metadata typeref:typename:const char ** file: +tag_section metadata/camera_metadata.c /^ uint32_t tag_section = entry.tag >> 16;$/;" l function:validate_camera_metadata_structure typeref:typename:uint32_t file: +tag_section metadata/camera_metadata.c /^ uint32_t tag_section = tag >> 16;$/;" l function:get_local_camera_metadata_section_name_vendor_id typeref:typename:uint32_t file: +tag_section metadata/camera_metadata.c /^ uint32_t tag_section = tag >> 16;$/;" l function:get_local_camera_metadata_tag_name_vendor_id typeref:typename:uint32_t file: +tag_section metadata/camera_metadata.c /^ uint32_t tag_section = tag >> 16;$/;" l function:get_local_camera_metadata_tag_type_vendor_id typeref:typename:uint32_t file: +tag_type metadata/camera_metadata.c /^ int tag_type = get_local_camera_metadata_tag_type(entry.tag, metadata);$/;" l function:validate_camera_metadata_structure typeref:typename:int file: +tag_type metadata/camera_metadata.c /^ uint8_t tag_type;$/;" m struct:tag_info typeref:typename:uint8_t file: access:public +type metadata/camera_metadata.c /^ int type = get_local_camera_metadata_tag_type(tag, dst);$/;" l function:add_camera_metadata_entry typeref:typename:int file: +type metadata/camera_metadata.c /^ uint8_t type;$/;" m struct:camera_metadata_buffer_entry typeref:typename:uint8_t file: access:public +type_name metadata/camera_metadata.c /^ const char *type_name;$/;" l function:dump_indented_camera_metadata typeref:typename:const char * file: +type_size metadata/camera_metadata.c /^ size_t type_size = camera_metadata_type_size[entry->type];$/;" l function:dump_indented_camera_metadata typeref:typename:size_t file: +type_size metadata/camera_metadata.c /^ size_t type_size = camera_metadata_type_size[type];$/;" l function:print_data typeref:typename:size_t file: +u8 metadata/camera_metadata.c /^ uint8_t u8;$/;" m union:camera_metadata_data typeref:typename:uint8_t file: access:public +update_camera_metadata_entry metadata/camera_metadata.c /^int update_camera_metadata_entry(camera_metadata_t *dst,$/;" f typeref:typename:int signature:(camera_metadata_t * dst,size_t index,const void * data,size_t data_count,camera_metadata_entry_t * updated_entry) +validate_and_calculate_camera_metadata_entry_data_size metadata/camera_metadata.c /^static int validate_and_calculate_camera_metadata_entry_data_size(size_t *data_size, uint8_t typ/;" f typeref:typename:int file: signature:(size_t * data_size,uint8_t type,size_t data_count) +validate_camera_metadata_structure metadata/camera_metadata.c /^int validate_camera_metadata_structure(const camera_metadata_t *metadata,$/;" f typeref:typename:int signature:(const camera_metadata_t * metadata,const size_t * expected_size) +validate_camera_metadata_structure::__anon2a3e460f0208::alignment metadata/camera_metadata.c /^ size_t alignment;$/;" m struct:validate_camera_metadata_structure::__anon2a3e460f0208 typeref:typename:size_t file: access:public +validate_camera_metadata_structure::__anon2a3e460f0208::name metadata/camera_metadata.c /^ const char *name;$/;" m struct:validate_camera_metadata_structure::__anon2a3e460f0208 typeref:typename:const char * file: access:public +value metadata/camera_metadata.c /^ uint8_t value[4];$/;" m union:camera_metadata_buffer_entry::__anon2a3e460f010a typeref:typename:uint8_t[4] file: access:public +value metadata/camera_metadata.c /^ uint32_t value;$/;" l function:print_data typeref:typename:uint32_t file: +value_string_tmp metadata/camera_metadata.c /^ char value_string_tmp[CAMERA_METADATA_ENUM_STRING_MAX_SIZE];$/;" l function:print_data typeref:typename:char[] file: +values_per_line metadata/camera_metadata.c /^ static int values_per_line[NUM_TYPES] = {$/;" l function:print_data typeref:typename:int[] file: +vendor_cache_ops metadata/camera_metadata.c /^static const struct vendor_tag_cache_ops *vendor_cache_ops = NULL;$/;" v typeref:typename:const struct vendor_tag_cache_ops * file: +vendor_id metadata/camera_metadata.c /^ metadata_vendor_id_t vendor_id;$/;" m struct:camera_metadata typeref:typename:metadata_vendor_id_t file: access:public +vendor_tag_ops metadata/camera_metadata.c /^static const vendor_tag_ops_t *vendor_tag_ops = NULL;$/;" v typeref:typename:const vendor_tag_ops_t * file: +version metadata/camera_metadata.c /^ uint32_t version;$/;" m struct:camera_metadata typeref:typename:uint32_t file: access:public diff --git a/src/android/thread_rpc.cpp b/src/android/thread_rpc.cpp new file mode 100644 index 000000000000..f13db59d0d75 --- /dev/null +++ b/src/android/thread_rpc.cpp @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * thread_call.cpp - Inter-thread procedure call + */ + +#include "message.h" +#include "thread_rpc.h" + +using namespace libcamera; + +libcamera::Message::Type ThreadRpcMessage::rpcType_ = Message::Type::None; + +ThreadRpcMessage::ThreadRpcMessage() + : Message(type()) +{ +} + +void ThreadRpc::notifyReception() +{ + { + libcamera::MutexLocker locker(mutex_); + delivered_ = true; + } + cv_.notify_one(); +} + +void ThreadRpc::waitDelivery() +{ + libcamera::MutexLocker locker(mutex_); + cv_.wait(locker, [&]{ return delivered_; }); +} + +Message::Type ThreadRpcMessage::type() +{ + if (ThreadRpcMessage::rpcType_ == Message::Type::None) + rpcType_ = Message::registerMessageType(); + + return rpcType_; +} diff --git a/src/android/thread_rpc.h b/src/android/thread_rpc.h new file mode 100644 index 000000000000..173caba1a515 --- /dev/null +++ b/src/android/thread_rpc.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * thread_call.h - Inter-thread procedure call + */ +#ifndef __ANDROID_THREAD_CALL_H__ +#define __ANDROID_THREAD_CALL_H__ + +#include +#include + +#include +#include + +#include "message.h" +#include "thread.h" + +class ThreadRpc +{ +public: + enum RpcTag { + ProcessCaptureRequest, + Close, + }; + + ThreadRpc() + : delivered_(false) {} + + void notifyReception(); + void waitDelivery(); + + RpcTag tag; + + camera3_capture_request_t *request; + +private: + bool delivered_; + std::mutex mutex_; + std::condition_variable cv_; +}; + +class ThreadRpcMessage : public libcamera::Message +{ +public: + ThreadRpcMessage(); + ThreadRpc *rpc; + + static Message::Type type(); + +private: + static libcamera::Message::Type rpcType_; +}; + +#endif /* __ANDROID_THREAD_CALL_H__ */ + diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index a09b23d60022..9b6e4b769760 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -103,11 +103,23 @@ libcamera_deps = [ dependency('threads'), ] -libcamera = shared_library('camera', - libcamera_sources, - install : true, - include_directories : includes, - dependencies : libcamera_deps) +if get_option('android') + libcamera_sources += android_hal_sources + includes += android_includes + + libcamera = shared_library('camera', + libcamera_sources, + install : true, + link_with : android_camera_metadata, + include_directories : includes, + dependencies : libcamera_deps) +else + libcamera = shared_library('camera', + libcamera_sources, + install : true, + include_directories : includes, + dependencies : libcamera_deps) +endif libcamera_dep = declare_dependency(sources : [libcamera_api, libcamera_h], include_directories : libcamera_includes, diff --git a/src/meson.build b/src/meson.build index 628e7a7f23f2..67ad20aab86b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,3 +1,7 @@ +if get_option('android') + subdir('android') +endif + subdir('libcamera') subdir('ipa') subdir('cam')