blob: 89830991171e7a903e3ab4097fd09533824d2df7 [file] [log] [blame]
Clay Murphy594d0ed2014-10-21 11:04:30 -07001page.title=Camera version support
2@jd:body
3
4<!--
Clay Murphy4c746142016-07-11 14:11:37 -07005 Copyright 2016 The Android Open Source Project
Clay Murphy594d0ed2014-10-21 11:04:30 -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
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
Clay Murphy4c746142016-07-11 14:11:37 -0700247<h3 id="34">3.4</h3>
248
249<p>Minor additions to supported metadata and changes to data_space support:</p>
250
251<ul>
252 <li>Add ANDROID_SENSOR_OPAQUE_RAW_SIZE static metadata as mandatory if
253 RAW_OPAQUE format is supported.</li>
254 <li>Add ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE static metadata as
255 mandatory if any RAW format is supported.</li>
256 <li>Switch camera3_stream_t data_space field to a more flexible definition,
257 using the version 0 definition of dataspace encoding.</li>
258 <li>General metadata additions which are available to use for HALv3.2 or
259 newer:
260 <ul>
261 <li><a href="https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#INFO_SUPPORTED_HARDWARE_LEVEL_3">ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3</a></li>
262 <li>ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST</li>
263 <li>ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE</li>
264 <li>ANDROID_SENSOR_DYNAMIC_BLACK_LEVEL</li>
265 <li>ANDROID_SENSOR_DYNAMIC_WHITE_LEVEL</li>
266 <li>ANDROID_SENSOR_OPAQUE_RAW_SIZE</li>
267 <li>ANDROID_SENSOR_OPTICAL_BLACK_REGIONS</li>
268 </ul>
269 <li>
270</ul>
271
272<h3 id="33">3.3</h3>
273
274<p>Minor revision of expanded-capability HAL:</p>
275
276<ul>
277 <li>OPAQUE and YUV reprocessing API updates.</li>
278 <li>Basic support for depth output buffers.</li>
279 <li>Addition of data_space field to camera3_stream_t.</li>
280 <li>Addition of rotation field to camera3_stream_t.</li>
281 <li>Addition of camera3 stream configuration operation mode to
282 camera3_stream_configuration_t.</li>
283</ul>
284
Clay Murphy0d4125a2015-02-24 16:52:40 -0800285<h3 id="32">3.2</h3>
286
Clay Murphy4c746142016-07-11 14:11:37 -0700287<p>Minor revision of expanded-capability HAL:</p>
Clay Murphy0d4125a2015-02-24 16:52:40 -0800288
289<ul>
Heidi von Markhamafd1cd72016-07-11 14:05:19 -0700290<li>Deprecates get_metadata_vendor_tag_ops. Use get_vendor_tag_ops in
Clay Murphy0d4125a2015-02-24 16:52:40 -0800291camera_common.h instead.</li>
292<li>register_stream_buffers deprecated. All gralloc buffers provided by
293framework to HAL in process_capture_request may be new at any time.</li>
294<li>Add partial result support. process_capture_result may be called multiple
295times with a subset of the available result before the full result is available.</li>
296<li>Add manual template to camera3_request_template. The applications may use
297this template to control the capture settings directly.</li>
298<li>Rework the bidirectional and input stream specifications.</li>
299<li>Change the input buffer return path. The buffer is returned in
300process_capture_result instead of process_capture_request.</li>
301</ul>
302
303<h3 id="31">3.1</h3>
304
305<p>Minor revision of expanded-capability HAL:</p>
306
307<ul>
308<li>configure_streams passes consumer usage flags to the HAL.</li>
309<li>flush call to drop all in-flight requests/buffers as fast as possible.</li>
310</ul>
311
312<h3 id="30">3.0</h3>
313
314<p>First revision of expanded-capability HAL:</p>
315
316<ul>
317<li>Major version change since the ABI is completely different. No change to the
318required hardware capabilities or operational model from 2.0.</li>
319<li>Reworked input request and stream queue interfaces: Framework calls into HAL
320with next request and stream buffers already dequeued. Sync framework support
321is included, necessary for efficient implementations.</li>
322<li>Moved triggers into requests, most notifications into results.</li>
323<li>Consolidated all callbacks into framework into one structure, and all setup
324methods into a single initialize() call.</li>
325<li>Made stream configuration into a single call to simplify stream management.
326Bidirectional streams replace STREAM_FROM_STREAM construct.</li>
327<li>Limited mode semantics for older/limited hardware devices.</li>
328</ul>
329
330<h3 id="20">2.0</h3>
331
332<p>Initial release of expanded-capability HAL (Android 4.2) [camera2.h]:</p>
333
334<ul>
335<li>Sufficient for implementing existing android.hardware.Camera API.</li>
336<li>Allows for ZSL queue in camera service layer</li>
337<li>Not tested for any new features such manual capture control, Bayer RAW
338capture, reprocessing of RAW data.</li>
339</ul>
340
341<h3 id="10">1.0</strong></h3>
342
343<p>Initial Android camera HAL (Android 4.0) [camera.h]:</p>
344
345<ul>
346<li>Converted from C++ CameraHardwareInterface abstraction layer.</li>
347<li>Supports android.hardware.Camera API.</li>
348</ul>
Clay Murphy4c746142016-07-11 14:11:37 -0700349
350<h2 id="version-history">Camera module version history</h2>
351
352<p>
353This section contains module versioning information for the Camera hardware module, based on
354camera_module_t.common.module_api_version. The two most significant hex
355digits represent the major version, and the two least significant represent
356the minor version.
357</p>
358
359<h3 id="24">2_4</h3>
360
361<p>This camera module version adds below API changes:</p>
362
363<ol>
364 <li>Torch mode support. The framework can use it to turn on torch mode for
365 any camera device that has a flash unit, without opening a camera device. The
366 camera device has a higher priority accessing the flash unit than the camera
367 module; opening a camera device will turn off the torch if it had been enabled
368 through the module interface. When there are any resource conflicts, such as
369 open() is called to open a camera device, the camera HAL module must notify the
370 framework through the torch mode status callback that the torch mode has been
371 turned off.</li>
372
373 <li>External camera (e.g. USB hot-plug camera) support. The API updates specify that
374 the camera static info is only available when camera is connected and ready to
375 use for external hot-plug cameras. Calls to get static info will be invalid
376 calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks
377 will only count on device status change callbacks to manage the available external
378 camera list.</li>
379
380 <li>Camera arbitration hints. This module version adds support for explicitly
381 indicating the number of camera devices that can be simultaneously opened and used.
382 To specify valid combinations of devices, the resource_cost and conflicting_devices
383 fields should always be set in the camera_info structure returned by the
384 get_camera_info call.</li>
385
386 <li>Module initialization method. This will be called by the camera service
387 right after the HAL module is loaded, to allow for one-time initialization
388 of the HAL. It is called before any other module methods are invoked.</li>
389</ol>
390
391<h3 id="23">2_3</h3>
392
393<p>This camera module version adds open legacy camera HAL device support.
394 Framework can use it to open the camera device as lower device HAL version
395 HAL device if the same device can support multiple device API versions.
396 The standard hardware module open call (common.methods->open) continues
397 to open the camera device with the latest supported version, which is
398 also the version listed in camera_info_t.device_version.</p>
399
400<h3 id="22">2_2</h3>
401
402<p>This camera module version adds vendor tag support from the module, and
403deprecates the old vendor_tag_query_ops that were previously only
404accessible with a device open.</p>
405
406<h3 id="21">2_1</h3>
407
408<p>This camera module version adds support for asynchronous callbacks to the
409framework from the camera HAL module, which is used to notify the framework
410about changes to the camera module state. Modules that provide a valid
411set_callbacks() method must report at least this version number.</p>
412
413<h3 id="20">2_0</h3>
414
415<p>Camera modules that report this version number implement the second version
416of the camera module HAL interface. Camera devices openable through this
417module may support either version 1.0 or version 2.0 of the camera device
418HAL interface. The device_version field of camera_info is always valid; the
419static_camera_characteristics field of camera_info is valid if the
420device_version field is 2.0 or higher.</p>
421
422<h3 id="10">1_0</h3>
423
424<p>Camera modules that report these version numbers implement the initial
425camera module HAL interface. All camera devices openable through this
426module support only version 1 of the camera device HAL. The device_version
427and static_camera_characteristics fields of camera_info are not valid. Only
428the android.hardware.Camera API can be supported by this module and its
429devices.</p>