1 page.title=Camera HAL v3 overview 2 @jd:body 3 4 <!-- 5 Copyright 2013 The Android Open Source Project 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 --> 19 <div id="qv-wrapper"> 20 <div id="qv"> 21 <h2>In this document</h2> 22 <ol id="auto-toc"> 23 </ol> 24 </div> 25 </div> 26 27 <p> 28 Android's camera Hardware Abstraction Layer (HAL) connects the higher level 29 camera framework APIs in 30 <a 31 href="http://developer.android.com/reference/android/hardware/Camera.html">android.hardware.Camera</a> 32 to your underlying camera driver and hardware. The latest version of Android 33 introduces a new, underlying implementation of the camera stack. If you have 34 previously developed a camera HAL module and driver for other versions of 35 Android, be aware that there are significant changes in the camera pipeline.</p> 36 <p>Version 1 of the camera HAL is still supported for future releases of Android 37 because many devices still rely on it. Implementing both HALs is also supported 38 by the Android camera service, which is useful when you want to support a less 39 capable front-facing camera with version 1 of the HAL and a more advanced 40 back-facing camera with version 3 of the HAL. Version 2 was a stepping stone to 41 version 3 and is not supported.</p> 42 <p> 43 There is only one camera HAL module (with its own version number, currently 1, 2, 44 or 2.1), which lists multiple independent camera devices that each have 45 their own version. Camera module v2 or newer is required to support devices v2 or newer, and such 46 camera modules can have a mix of camera device versions. This is what we mean 47 when we say we Android supports implementing both HALs. 48 </p> 49 <p><strong>Note:</strong> The new camera HAL is in active development and can change at any 50 time. This document describes at a high level the design of the camera subsystem 51 and omits many details. Stay tuned for more updates to the PDK repository and 52 look out for updates to the Camera HAL and reference implementation for more 53 information.</p> 54 55 <h2 id="overview">Overview</h2> 56 57 <p> 58 Version 1 of the camera subsystem was designed as a black box with high-level 59 controls. Roughly speaking, the old subsystem has three operating modes:</p> 60 61 <ul> 62 <li>Preview</li> 63 <li>Video Record</li> 64 <li>Still Capture</li> 65 </ul> 66 67 <p>Each mode has slightly different and overlapping capabilities. This made it hard 68 to implement new types of features, such as burst mode, since it would fall 69 between two of these modes.<br/> 70 <img src="images/camera_block.png" alt="Camera block diagram"/><br/> 71 <strong>Figure 1.</strong> Camera components</p> 72 73 <h2 id="v3-enhance">Version 3 enhancements</h2> 74 75 <p>The aim of the Android Camera API redesign is to substantially increase the 76 ability of applications to control the camera subsystem on Android devices while 77 reorganizing the API to make it more efficient and maintainable.</p> 78 79 <p>The additional control makes it easier to build high-quality camera applications 80 on Android devices that can operate reliably across multiple products while 81 still using device-specific algorithms whenever possible to maximize quality and 82 performance.</p> 83 84 <p>Version 3 of the camera subsystem structures the operation modes into a single 85 unified view, which can be used to implement any of the previous modes and 86 several others, such as burst mode. This results in better user control for 87 focus and exposure and more post-processing, such as noise reduction, contrast 88 and sharpening. Further, this simplified view makes it easier for application 89 developers to use the camera's various functions.<br/> 90 The API models the camera subsystem as a pipeline that converts incoming 91 requests for frame captures into frames, on a 1:1 basis. The requests 92 encapsulate all configuration information about the capture and processing of a 93 frame. This includes: resolution and pixel format; manual sensor, lens and flash 94 control; 3A operating modes; RAW->YUV processing control; statistics generation; 95 and so on.</p> 96 97 <p>In simple terms, the application framework requests a frame from the camera 98 subsystem, and the camera subsystem returns results to an output stream. In 99 addition, metadata that contains information such as color spaces and lens 100 shading is generated for each set of results. The following sections and 101 diagrams give you more detail about each component.<br/> 102 You can think of camera version 3 as a pipeline to camera version 1's one-way 103 stream. It converts each capture request into one image captured by the sensor, 104 which is processed into: </p> 105 106 <ul> 107 <li>A Result object with metadata about the capture.</li> 108 <li>One to N buffers of image data, each into its own destination Surface.</li> 109 </ul> 110 111 <p>The set of possible output Surfaces is preconfigured:</p> 112 113 <ul> 114 <li>Each Surface is a destination for a stream of image buffers of a fixed 115 resolution.</li> 116 <li>Only a small number of Surfaces can be configured as outputs at once (~3).</li> 117 </ul> 118 119 <p>A request contains all desired capture settings and the list of output Surfaces 120 to push image buffers into for this request (out of the total configured set). A 121 request can be one-shot ( with capture() ), or it may be repeated indefinitely 122 (with setRepeatingRequest() ). Captures have priority over repeating 123 requests.</p> 124 <img src="images/camera_simple_model.png" alt="Camera data model"/> 125 <p><strong>Figure 2.</strong> Camera core operation model</p> 126 127 <h2 id="supported-version">Supported version</h2> 128 129 <p>Camera devices that support this version of the HAL must return 130 CAMERA_DEVICE_API_VERSION_3_1 in camera_device_t.common.version and in 131 camera_info_t.device_version (from camera_module_t.get_camera_info).<br/> 132 Camera modules that may contain version 3.1 devices must implement at least 133 version 2.0 of the camera module interface (as defined by 134 camera_module_t.common.module_api_version).<br/> 135 See camera_common.h for more versioning details.</p> 136 137 <h2 id="version-history">Version history</h2> 138 139 <h4><strong>1.0</strong></h4> 140 141 <p>Initial Android camera HAL (Android 4.0) [camera.h]:</p> 142 143 <ul> 144 <li>Converted from C++ CameraHardwareInterface abstraction layer.</li> 145 <li>Supports android.hardware.Camera API.</li> 146 </ul> 147 148 <h4><strong>2.0</strong></h4> 149 150 <p>Initial release of expanded-capability HAL (Android 4.2) [camera2.h]:</p> 151 152 <ul> 153 <li>Sufficient for implementing existing android.hardware.Camera API.</li> 154 <li>Allows for ZSL queue in camera service layer</li> 155 <li>Not tested for any new features such manual capture control, Bayer RAW 156 capture, reprocessing of RAW data.</li> 157 </ul> 158 159 <h4><strong>3.0</strong></h4> 160 161 <p>First revision of expanded-capability HAL:</p> 162 163 <ul> 164 <li>Major version change since the ABI is completely different. No change to the 165 required hardware capabilities or operational model from 2.0.</li> 166 <li>Reworked input request and stream queue interfaces: Framework calls into HAL 167 with next request and stream buffers already dequeued. Sync framework support 168 is included, necessary for efficient implementations.</li> 169 <li>Moved triggers into requests, most notifications into results.</li> 170 <li>Consolidated all callbacks into framework into one structure, and all setup 171 methods into a single initialize() call.</li> 172 <li>Made stream configuration into a single call to simplify stream management. 173 Bidirectional streams replace STREAM_FROM_STREAM construct.</li> 174 <li>Limited mode semantics for older/limited hardware devices.</li> 175 </ul> 176 177 <h4><strong>3.1</strong></h4> 178 179 <p>Minor revision of expanded-capability HAL:</p> 180 181 <ul> 182 <li>configure_streams passes consumer usage flags to the HAL.</li> 183 <li>flush call to drop all in-flight requests/buffers as fast as possible.</li> 184 </ul> 185