1 page.title=Camera HAL3 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 27 <p> 28 Android's camera Hardware Abstraction Layer (HAL) connects the higher level 29 camera framework APIs in 30 <a href="http://developer.android.com/reference/android/hardware/Camera.html">android.hardware.Camera</a> 31 to your underlying camera driver and hardware. Android 5.0 introduced a new, 32 underlying implementation of the camera stack. If you have previously developed 33 a camera HAL module and driver for older versions of Android, be aware of 34 significant changes in the camera pipeline.</p> 35 36 <p class="note"><strong>Note:</strong> The new camera HAL is in active 37 development and can change at any time. This document describes the high-level 38 design of the camera subsystem; for details, see 39 <a href="{@docRoot}devices/camera/versioning.html">Camera Version Support</a>.</p> 40 41 <h2 id="overview">Camera HAL1 overview</h2> 42 43 <p>Version 1 of the camera subsystem was designed as a black box with high-level 44 controls and the following three operating modes:</p> 45 46 <ul> 47 <li>Preview</li> 48 <li>Video Record</li> 49 <li>Still Capture</li> 50 </ul> 51 52 <p>Each mode has slightly different and overlapping capabilities. This made it 53 hard to implement new types of features, such as burst mode, since it would fall 54 between two of these modes.</p> 55 56 <img src="images/camera_block.png" alt="Camera block diagram" id="figure1" /> 57 <p class="img-caption"><strong>Figure 1.</strong> Camera components</p> 58 59 <p>Android 7.0 continues to support camera HAL1 as many devices still rely on 60 it. In addition, the Android camera service supports implementing both HALs (1 61 and 3), which is useful when you want to support a less-capable front-facing 62 camera with camera HAL1 and a more advanced back-facing camera with camera 63 HAL3.</p> 64 65 <p class="note"><strong>Note:</strong> Camera HAL2 is not supported as it was a 66 temporary step on the way to camera HAL3.</p> 67 68 <p>There is a single camera HAL <em>module</em> (with its own 69 <a href="{@docRoot}devices/camera/versioning.html#module_version">version 70 number</a>), which lists multiple independent camera devices that each have 71 their own version number. Camera module 2 or newer is required to support 72 devices 2 or newer, and such camera modules can have a mix of camera device 73 versions (this is what we mean when we say Android supports implementing both 74 HALs).</p> 75 76 <h2 id="v3-enhance">Camera HAL3 enhancements</h2> 77 78 <p>The aim of the Android Camera API redesign is to substantially increase the 79 ability of applications to control the camera subsystem on Android devices while 80 reorganizing the API to make it more efficient and maintainable. The additional 81 control makes it easier to build high-quality camera applications on Android 82 devices that can operate reliably across multiple products while still using 83 device-specific algorithms whenever possible to maximize quality and 84 performance.</p> 85 86 <p>Version 3 of the camera subsystem structures the operation modes into a 87 single unified view, which can be used to implement any of the previous modes 88 and several others, such as burst mode. This results in better user control for 89 focus and exposure and more post-processing, such as noise reduction, contrast 90 and sharpening. Further, this simplified view makes it easier for application 91 developers to use the camera's various functions.</p> 92 <p>The API models the camera subsystem as a pipeline that converts incoming 93 requests for frame captures into frames, on a 1:1 basis. The requests 94 encapsulate all configuration information about the capture and processing of a 95 frame. This includes resolution and pixel format; manual sensor, lens and flash 96 control; 3A operating modes; RAW->YUV processing control; statistics generation; 97 and so on.</p> 98 99 <p>In simple terms, the application framework requests a frame from the camera 100 subsystem, and the camera subsystem returns results to an output stream. In 101 addition, metadata that contains information such as color spaces and lens 102 shading is generated for each set of results. You can think of camera version 3 103 as a pipeline to camera version 1's one-way stream. It converts each capture 104 request into one image captured by the sensor, 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). 117 </li> 118 </ul> 119 120 <p>A request contains all desired capture settings and the list of output 121 Surfaces to push image buffers into for this request (out of the total 122 configured set). A request can be one-shot (with <code>capture()</code>), or it 123 may be repeated indefinitely (with <code>setRepeatingRequest()</code>). Captures 124 have priority over repeating requests.</p> 125 126 <img src="images/camera_simple_model.png" alt="Camera data model" id="figure2" /> 127 <p class="img-caption"><strong>Figure 2.</strong> Camera core operation model</p> 128