Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 1 | page.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 Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 27 | <p>This page details version differences in Camera HALs, APIs, and associated |
| 28 | Android Compatibility Test Suite (CTS) tests. It also covers several |
| 29 | architectural changes made to harden and secure the camera framework in Android |
| 30 | 7.0 and the updates vendors must make to support these changes in their camera |
| 31 | implementations.</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 32 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 33 | <h2 id=glossary>Terminology</h2> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 34 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 35 | <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 |
| 41 | through 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 |
| 45 | through 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 |
| 49 | frameworks 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 |
| 59 | API1.</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 |
| 73 | platform development focuses on Camera API2. However, the phase-out period will |
| 74 | be lengthy, and Android releases will continue to support Camera API1 apps for |
| 75 | some time. Specifically, support continues for:</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 76 | |
| 77 | <ul> |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 78 | <li><em>Camera API1 interfaces for apps</em>. Camera apps built on top of Camera API1 |
| 79 | should 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 Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 81 | </ul> |
| 82 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 83 | <h3 id=camera_api2>Camera API2</h3> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 84 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 85 | <p>The Camera API2 framework exposes lower-level camera control to the app, |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 86 | including efficient zero-copy burst/streaming flows and per-frame controls of |
| 87 | exposure, gain, white balance gains, color conversion, denoising, sharpening, |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 88 | and more. For details, watch the |
| 89 | <a href="https://www.youtube.com/watch?v=92fgcUNCHic&feature=youtu.be&t=29m50s">Google |
| 90 | I/O video overview</a>.</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 91 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 92 | <p>Android 5.0 and later includes Camera API2; however, devices running Android |
| 93 | 5.0 and later may not support all Camera API2 features. The |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 94 | <code>android.info.supportedHardwareLevel</code> property that apps can query |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 95 | through the Camera API2 interfaces reports one of the following support |
| 96 | levels:</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 97 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 98 | <ul> |
| 99 | <li><code>LEGACY</code>. These devices expose capabilities to apps through the |
| 100 | Camera API2 interfaces that are approximately the same capabilities as those |
| 101 | exposed to apps through the Camera API1 interfaces. The legacy frameworks code |
| 102 | conceptually translates Camera API2 calls into Camera API1 calls; legacy devices |
| 103 | do 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 |
| 105 | API2 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 Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 109 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 110 | <p>Individual capabilities are exposed via the |
| 111 | <code>android.request.availableCapabilities</code> property in the Camera API2 |
| 112 | interfaces. <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, |
| 116 | including none of them. However, the <code>BACKWARD_COMPATIBLE</code> capability |
| 117 | must always be defined.</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 118 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 119 | <p>The supported hardware level of the device, as well as the specific Camera |
| 120 | API2 capabilities it supports, are available as the following feature flags to |
| 121 | allow Google Play filtering of Camera API2 camera apps.</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 122 | |
| 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 Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 132 | <p>Android 5.0 and later devices must pass the Camera API1 CTS, Camera API2 CTS, |
| 133 | and CTS Verifier camera tests.</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 134 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 135 | <p>Devices that do not feature a Camera HAL3.2 implementation and are not |
| 136 | capable of supporting the full Camera API2 interfaces must still pass the Camera |
| 137 | API2 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 |
| 139 | to Camera API1 calls) so any Camera API2 CTS tests related to features or |
| 140 | capabilities beyond Camera API1 will be automatically skipped.</p> |
Clay Murphy | 594d0ed | 2014-10-21 11:04:30 -0700 | [diff] [blame] | 141 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 142 | <p>On legacy devices, Camera API2 CTS tests that are not skipped use the |
| 143 | existing public Camera API1 interfaces and capabilities with no new |
| 144 | requirements. Bugs that are exposed (and which cause a Camera API2 CTS failure) |
| 145 | are bugs already present in the device’s existing Camera HAL, and thus would |
| 146 | be 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 Murphy | 0d4125a | 2015-02-24 16:52:40 -0800 | [diff] [blame] | 148 | |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 149 | <h2 id=hardening>Camera framework hardening</h2> |
| 150 | |
| 151 | <p>To harden media and camera framework security, Android 7.0 moves camera |
| 152 | service out of mediaserver. Vendors may need to make changes in the camera HAL |
| 153 | depending on the API and HAL versions in use. The following sections detail |
| 154 | architectural changes in AP1 and AP2 for HAL1 and HAL3, as well as general |
| 155 | requirements.</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 |
| 159 | process. When using API1 on:</p> |
| 160 | |
| 161 | <ul> |
| 162 | <li>HAL3, where camera service uses BufferQueue to pass buffers between |
| 163 | processes, <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 |
| 165 | stack in API1 on HAL3" id="figure1" /></p> |
| 166 | <p class="img-caption"><strong>Figure 1.</strong>Android 7.0 camera and media |
| 167 | stack in API1 on HAL3.</p> |
| 168 | </li> |
| 169 | <li>HAL1, which supports passing metadata in video buffers, <strong>vendors must |
| 170 | update 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 |
| 173 | stack in API1 on HAL1" id="figure1" /></p> |
| 174 | <p class="img-caption"><strong>Figure 2.</strong>Android 7.0 camera and media |
| 175 | stack 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 |
| 181 | to 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 |
| 185 | update</strong> is necessary.</li> |
| 186 | <li>HAL3 <em>is</em> affected, but <strong>no vendor update</strong> is |
| 187 | necessary: |
| 188 | <p><img src="images/ape_camera_n_api2_hal3.png" alt="Android 7.0 camera and |
| 189 | media stack in API2 on HAL2" id="figure1" /></p> |
| 190 | <p class="img-caption"><strong>Figure 3.</strong>Android 7.0 camera and media |
| 191 | stack 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 |
| 197 | security include the following additional device requirements.</p> |
| 198 | |
| 199 | <ul> |
| 200 | <li><strong>General</strong>. Devices require additional bandwidth due to IPC, |
| 201 | which may affect time-sensitive camera use cases such as high-speed video |
| 202 | recording. Vendors can measure actual impact by running |
| 203 | <code>android.hardware.camera2.cts.PerformanceTest</code> and the Google Camera |
| 204 | App for 120/240 FPS high speed video recording. Devices also require a small |
| 205 | amount of additional RAM to create the new process.</li> |
| 206 | <li><strong>Pass metadata in video buffers</strong>(<em>HAL1 only</em>). If HAL1 |
| 207 | stores metadata instead of real YUV frame data in video buffers, the HAL must |
| 208 | not store anything that is invalid across process boundaries, including native |
| 209 | handles. If HAL passes native handles in the metadata in video buffers, you must |
| 210 | update it to use <code>kMetadataBufferTypeNativeHandleSource</code> as the |
| 211 | metadata buffer type and pass <code>VideoNativeHandleMetadata</code> in video |
| 212 | buffers. |
| 213 | <p>With <code>VideoNativeHandleMetadata</code>, camera and media frameworks are |
| 214 | able to pass the video buffers between processes by serializing and |
| 215 | deserializing the native handles properly. If HAL chooses to continue using |
| 216 | <code>kMetadataBufferTypeCameraSource</code> as the metadata buffer type, the |
| 217 | metadata 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 |
| 221 | handles. HAL cannot use the addresses to identify buffers because the addresses |
| 222 | may store another buffer handle after HAL returns the buffer. You must update |
| 223 | the HAL to use buffer handles to identify the buffers. For example: HAL receives |
| 224 | a buffer handle address A, which stores buffer handle A. After HAL returns |
| 225 | buffer handle A, buffer handle address A may store buffer handle B next time the |
| 226 | HAL receives it.</li> |
| 227 | <li><strong>Update SELinux policies for cameraserver</strong>. If |
| 228 | device-specific SELinux policies give mediaserver permissions to run the camera, |
| 229 | you must update the SELinux policies to give cameraserver proper permissions. We |
| 230 | do not encourage replicating the mediaserver's SELinux policies for cameraserver |
| 231 | (as mediaserver and cameraserver generally require different resources in the |
| 232 | system). Cameraserver should have only the permissions needed to perform camera |
| 233 | functionalities and any unnecessary camera-related permissions in mediaserver |
| 234 | should 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 |
| 238 | implementation by running Android 7.0 CTS. Although Android 7.0 does not include |
| 239 | new CTS tests that verify camera service changes, existing CTS tests will fail |
| 240 | if 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 |
| 245 | Checklist</a>.</p> |
Clay Murphy | 0d4125a | 2015-02-24 16:52:40 -0800 | [diff] [blame] | 246 | |
| 247 | <h3 id="32">3.2</h3> |
| 248 | |
| 249 | <p>Second revision of expanded-capability HAL:</p> |
| 250 | |
| 251 | <ul> |
Heidi von Markham | afd1cd7 | 2016-07-11 14:05:19 -0700 | [diff] [blame^] | 252 | <li>Deprecates get_metadata_vendor_tag_ops. Use get_vendor_tag_ops in |
Clay Murphy | 0d4125a | 2015-02-24 16:52:40 -0800 | [diff] [blame] | 253 | camera_common.h instead.</li> |
| 254 | <li>register_stream_buffers deprecated. All gralloc buffers provided by |
| 255 | framework 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 |
| 257 | times 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 |
| 259 | this 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 |
| 262 | process_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 |
| 280 | required hardware capabilities or operational model from 2.0.</li> |
| 281 | <li>Reworked input request and stream queue interfaces: Framework calls into HAL |
| 282 | with next request and stream buffers already dequeued. Sync framework support |
| 283 | is 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 |
| 286 | methods into a single initialize() call.</li> |
| 287 | <li>Made stream configuration into a single call to simplify stream management. |
| 288 | Bidirectional 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 |
| 300 | capture, 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> |