blob: 402684bc72670db6c9a67b477376c453d341c09a [file] [log] [blame]
Clay Murphy594d0ed2014-10-21 11:04:30 -07001page.title=Camera version support
2@jd:body
3
4<!--
5 Copyright 2014 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
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070027<p>This page details version differences in Camera HALs, APIs, and associated
28Android Compatibility Test Suite (CTS) tests. It also covers several
29architectural changes made to harden and secure the camera framework in Android
307.0 and the updates vendors must make to support these changes in their camera
31implementations.</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -070032
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070033<h2 id=glossary>Terminology</h2>
Clay Murphy594d0ed2014-10-21 11:04:30 -070034
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070035<p>The following terms are used on this page:</p>
36
37<dl>
38
39<dt>Camera API1</dt>
40<dd>The app-level camera framework on Android 4.4 and earlier devices, exposed
41through the <code>android.hardware.Camera</code> class.</dd>
42
43<dt>Camera API2</dt>
44<dd>The app-level camera framework on Android 5.0 and later devices, exposed
45through the<code> android.hardware.camera2</code> package.</dd>
46
47<dt>Camera HAL</dt>
48<dd>The camera module layer implemented by SoC vendors. The app-level public
49frameworks are built on top of the camera HAL.</dd>
50
51<dt>Camera HAL3.1</dt>
52<dd>Version of the camera device HAL released with Android 4.4.</dd>
53
54<dt>Camera HAL3.2</dt>
55<dd>Version of the camera device HAL released with Android 5.0.</dd>
56
57<dt>Camera API1 CTS</dt>
58<dd>Set of camera Compatibility Test Suite (CTS) tests that run on top of Camera
59API1.</dd>
60
61<dt>Camera API2 CTS</dt>
62<dd>Additional set of camera CTS tests that run on top of Camera API2.</dd>
63
64</dl>
65
66
67<h2 id=camera_apis>Camera APIs</h2>
68
69
70<h3 id=camera_api1>Camera API1</h3>
71
72<p>Android 5.0 deprecated Camera API1, which continues to be phased out as new
73platform development focuses on Camera API2. However, the phase-out period will
74be lengthy, and Android releases will continue to support Camera API1 apps for
75some time. Specifically, support continues for:</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -070076
77<ul>
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070078<li><em>Camera API1 interfaces for apps</em>. Camera apps built on top of Camera API1
79should work as they do on devices running earlier Android release versions.</li>
80<li><em>Camera HAL versions</em>. Includes support for Camera HAL1.0.</li>
Clay Murphy594d0ed2014-10-21 11:04:30 -070081</ul>
82
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070083<h3 id=camera_api2>Camera API2</h3>
Clay Murphy594d0ed2014-10-21 11:04:30 -070084
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070085<p>The Camera API2 framework exposes lower-level camera control to the app,
Clay Murphy594d0ed2014-10-21 11:04:30 -070086including efficient zero-copy burst/streaming flows and per-frame controls of
87exposure, gain, white balance gains, color conversion, denoising, sharpening,
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070088and more. For details, watch the
89<a href="https://www.youtube.com/watch?v=92fgcUNCHic&feature=youtu.be&t=29m50s">Google
90I/O video overview</a>.</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -070091
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070092<p>Android 5.0 and later includes Camera API2; however, devices running Android
935.0 and later may not support all Camera API2 features. The
Clay Murphy594d0ed2014-10-21 11:04:30 -070094<code>android.info.supportedHardwareLevel</code> property that apps can query
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070095through the Camera API2 interfaces reports one of the following support
96levels:</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -070097
Heidi von Markhamafd1cd72016-07-11 14:05:19 -070098<ul>
99<li><code>LEGACY</code>. These devices expose capabilities to apps through the
100Camera API2 interfaces that are approximately the same capabilities as those
101exposed to apps through the Camera API1 interfaces. The legacy frameworks code
102conceptually translates Camera API2 calls into Camera API1 calls; legacy devices
103do not support Camera API2 features such as per-frame controls.</li>
104<li><code>FULL</code>. These devices support all of major capabilities of Camera
105API2 and must use Camera HAL 3.2 or later and Android 5.0 or later.</li>
106<li><code>LIMITED</code>. These devices support some Camera API2 capabilities
107(but not all) and must use Camera HAL 3.2 or later.</li>
108</ul>
Clay Murphy594d0ed2014-10-21 11:04:30 -0700109
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700110<p>Individual capabilities are exposed via the
111<code>android.request.availableCapabilities</code> property in the Camera API2
112interfaces. <code>FULL</code> devices require the <code>MANUAL_SENSOR</code> and
113<code>MANUAL_POST_PROCESSING</code> capabilities, among others. The
114<code>RAW</code> capability is optional even for <code>FULL</code> devices.
115<code>LIMITED</code> devices can advertise any subset of these capabilities,
116including none of them. However, the <code>BACKWARD_COMPATIBLE</code> capability
117must always be defined.</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -0700118
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700119<p>The supported hardware level of the device, as well as the specific Camera
120API2 capabilities it supports, are available as the following feature flags to
121allow Google Play filtering of Camera API2 camera apps.</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -0700122
123<ul>
124 <li><code>android.hardware.camera.hardware_level.full</code>
125 <li><code>android.hardware.camera.capability.raw</code>
126 <li><code>android.hardware.camera.capability.manual_sensor</code>
127 <li><code>android.hardware.camera.capability.manual_post_processing</code>
128</ul>
129
130<h2 id=cts_requirements>CTS requirements</h2>
131
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700132<p>Android 5.0 and later devices must pass the Camera API1 CTS, Camera API2 CTS,
133and CTS Verifier camera tests.</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -0700134
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700135<p>Devices that do not feature a Camera HAL3.2 implementation and are not
136capable of supporting the full Camera API2 interfaces must still pass the Camera
137API2 CTS tests. However, the device will be running in Camera API2
138<code>LEGACY</code> mode (in which the Camera API2 calls are conceptually mapped
139to Camera API1 calls) so any Camera API2 CTS tests related to features or
140capabilities beyond Camera API1 will be automatically skipped.</p>
Clay Murphy594d0ed2014-10-21 11:04:30 -0700141
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700142<p>On legacy devices, Camera API2 CTS tests that are not skipped use the
143existing public Camera API1 interfaces and capabilities with no new
144requirements. Bugs that are exposed (and which cause a Camera API2 CTS failure)
145are bugs already present in the device’s existing Camera HAL, and thus would
146be found by existing Camera API1 apps. We do not expect many bugs of this nature
147(however, any such bugs must be fixed to pass the Camera API2 CTS tests).</p>
Clay Murphy0d4125a2015-02-24 16:52:40 -0800148
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700149<h2 id=hardening>Camera framework hardening</h2>
150
151<p>To harden media and camera framework security, Android 7.0 moves camera
152service out of mediaserver. Vendors may need to make changes in the camera HAL
153depending on the API and HAL versions in use. The following sections detail
154architectural changes in AP1 and AP2 for HAL1 and HAL3, as well as general
155requirements.</p>
156
157<h3 id=hardening_api1>Architectural changes for API1</h3>
158<p>API1 video recording may assume camera and video encoder live in the same
159process. When using API1 on:</p>
160
161<ul>
162<li>HAL3, where camera service uses BufferQueue to pass buffers between
163processes, <strong>no vendor update</strong> is necessary.
164<p><img src="images/ape_camera_n_api1_hal3.png" alt="Android 7.0 camera and media
165stack in API1 on HAL3" id="figure1" /></p>
166<p class="img-caption"><strong>Figure 1.</strong>Android 7.0 camera and media
167stack in API1 on HAL3.</p>
168</li>
169<li>HAL1, which supports passing metadata in video buffers, <strong>vendors must
170update the HAL to allow camera and video encoder in different processes</strong>
171(e.g., the HAL cannot store virtual addresses in the metadata).
172<p><img src="images/ape_camera_n_api1_hal1.png" alt="Android 7.0 camera and media
173stack in API1 on HAL1" id="figure1" /></p>
174<p class="img-caption"><strong>Figure 2.</strong>Android 7.0 camera and media
175stack in API1 on HAL1.</p>
176</li>
177</ul>
178
179<h3 id=hardening_api2>Architectural changes for API2</h3>
180<p>For API2 on HAL1 or HAL3, BufferQueue passes buffers so those paths continue
181to work. The Android 7.0 architecture for API2 on:</p>
182
183<ul>
184<li>HAL1 is not affected by the cameraservice move, and <strong>no vendor
185update</strong> is necessary.</li>
186<li>HAL3 <em>is</em> affected, but <strong>no vendor update</strong> is
187necessary:
188<p><img src="images/ape_camera_n_api2_hal3.png" alt="Android 7.0 camera and
189media stack in API2 on HAL2" id="figure1" /></p>
190<p class="img-caption"><strong>Figure 3.</strong>Android 7.0 camera and media
191stack in API2 on HAL3.</p>
192</li>
193</ul>
194
195<h3 id=hardening_general>Additional requirements</h3>
196<p>The architectural changes made for hardening media and camera framework
197security include the following additional device requirements.</p>
198
199<ul>
200<li><strong>General</strong>. Devices require additional bandwidth due to IPC,
201which may affect time-sensitive camera use cases such as high-speed video
202recording. Vendors can measure actual impact by running
203<code>android.hardware.camera2.cts.PerformanceTest</code> and the Google Camera
204App for 120/240 FPS high speed video recording. Devices also require a small
205amount of additional RAM to create the new process.</li>
206<li><strong>Pass metadata in video buffers</strong>(<em>HAL1 only</em>). If HAL1
207stores metadata instead of real YUV frame data in video buffers, the HAL must
208not store anything that is invalid across process boundaries, including native
209handles. If HAL passes native handles in the metadata in video buffers, you must
210update it to use <code>kMetadataBufferTypeNativeHandleSource</code> as the
211metadata buffer type and pass <code>VideoNativeHandleMetadata</code> in video
212buffers.
213<p>With <code>VideoNativeHandleMetadata</code>, camera and media frameworks are
214able to pass the video buffers between processes by serializing and
215deserializing the native handles properly. If HAL chooses to continue using
216<code>kMetadataBufferTypeCameraSource</code> as the metadata buffer type, the
217metadata must be able to be passed between processes as plain values.</p>
218</li>
219<li><strong>Buffer handle address does not always store same buffer</strong>
220(<em>HAL3 only</em>). For each capture request, HAL3 gets addresses of buffer
221handles. HAL cannot use the addresses to identify buffers because the addresses
222may store another buffer handle after HAL returns the buffer. You must update
223the HAL to use buffer handles to identify the buffers. For example: HAL receives
224a buffer handle address A, which stores buffer handle A. After HAL returns
225buffer handle A, buffer handle address A may store buffer handle B next time the
226HAL receives it.</li>
227<li><strong>Update SELinux policies for cameraserver</strong>. If
228device-specific SELinux policies give mediaserver permissions to run the camera,
229you must update the SELinux policies to give cameraserver proper permissions. We
230do not encourage replicating the mediaserver's SELinux policies for cameraserver
231(as mediaserver and cameraserver generally require different resources in the
232system). Cameraserver should have only the permissions needed to perform camera
233functionalities and any unnecessary camera-related permissions in mediaserver
234should be removed.</p>
235
236<h3 id=hardening_validation>Validation</h3>
237<p>For all devices that include a camera and run Android 7.0, verify the
238implementation by running Android 7.0 CTS. Although Android 7.0 does not include
239new CTS tests that verify camera service changes, existing CTS tests will fail
240if you have not made the updates indicated above.</p>
241
242<h2 id="version-history">Camera HAL version history</h2>
243<p>For a list of tests available for evaluating the Android Camera HAL, see the
244<a href="{@docRoot}compatibility/cts/camera-hal.html">Camera HAL Testing
245Checklist</a>.</p>
Clay Murphy0d4125a2015-02-24 16:52:40 -0800246
247<h3 id="32">3.2</h3>
248
249<p>Second revision of expanded-capability HAL:</p>
250
251<ul>
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700252<li>Deprecates get_metadata_vendor_tag_ops. Use get_vendor_tag_ops in
Clay Murphy0d4125a2015-02-24 16:52:40 -0800253camera_common.h instead.</li>
254<li>register_stream_buffers deprecated. All gralloc buffers provided by
255framework to HAL in process_capture_request may be new at any time.</li>
256<li>Add partial result support. process_capture_result may be called multiple
257times with a subset of the available result before the full result is available.</li>
258<li>Add manual template to camera3_request_template. The applications may use
259this template to control the capture settings directly.</li>
260<li>Rework the bidirectional and input stream specifications.</li>
261<li>Change the input buffer return path. The buffer is returned in
262process_capture_result instead of process_capture_request.</li>
263</ul>
264
265<h3 id="31">3.1</h3>
266
267<p>Minor revision of expanded-capability HAL:</p>
268
269<ul>
270<li>configure_streams passes consumer usage flags to the HAL.</li>
271<li>flush call to drop all in-flight requests/buffers as fast as possible.</li>
272</ul>
273
274<h3 id="30">3.0</h3>
275
276<p>First revision of expanded-capability HAL:</p>
277
278<ul>
279<li>Major version change since the ABI is completely different. No change to the
280required hardware capabilities or operational model from 2.0.</li>
281<li>Reworked input request and stream queue interfaces: Framework calls into HAL
282with next request and stream buffers already dequeued. Sync framework support
283is included, necessary for efficient implementations.</li>
284<li>Moved triggers into requests, most notifications into results.</li>
285<li>Consolidated all callbacks into framework into one structure, and all setup
286methods into a single initialize() call.</li>
287<li>Made stream configuration into a single call to simplify stream management.
288Bidirectional streams replace STREAM_FROM_STREAM construct.</li>
289<li>Limited mode semantics for older/limited hardware devices.</li>
290</ul>
291
292<h3 id="20">2.0</h3>
293
294<p>Initial release of expanded-capability HAL (Android 4.2) [camera2.h]:</p>
295
296<ul>
297<li>Sufficient for implementing existing android.hardware.Camera API.</li>
298<li>Allows for ZSL queue in camera service layer</li>
299<li>Not tested for any new features such manual capture control, Bayer RAW
300capture, reprocessing of RAW data.</li>
301</ul>
302
303<h3 id="10">1.0</strong></h3>
304
305<p>Initial Android camera HAL (Android 4.0) [camera.h]:</p>
306
307<ul>
308<li>Converted from C++ CameraHardwareInterface abstraction layer.</li>
309<li>Supports android.hardware.Camera API.</li>
310</ul>