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