1 <html devsite> 2 <head> 3 <title>Camera HAL3</title> 4 <meta name="project_path" value="/_project.yaml" /> 5 <meta name="book_path" value="/_book.yaml" /> 6 </head> 7 <body> 8 <!-- 9 Copyright 2017 The Android Open Source Project 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 --> 23 24 25 26 <p> 27 Android's camera Hardware Abstraction Layer (HAL) connects the higher level 28 camera framework APIs in 29 <a href="http://developer.android.com/reference/android/hardware/Camera.html">android.hardware.Camera</a> 30 to your underlying camera driver and hardware. Android 5.0 introduced a new, 31 underlying implementation of the camera stack. If you have previously developed 32 a camera HAL module and driver for older versions of Android, be aware of 33 significant changes in the camera pipeline.</p> 34 35 <p class="note"><strong>Note:</strong> The new camera HAL is in active 36 development and can change at any time. This document describes the high-level 37 design of the camera subsystem; for details, see 38 <a href="/devices/camera/versioning.html">Camera Version Support</a>.</p> 39 40 <h2 id="overview">Camera HAL1 overview</h2> 41 42 <p>Version 1 of the camera subsystem was designed as a black box with high-level 43 controls and the following three operating modes:</p> 44 45 <ul> 46 <li>Preview</li> 47 <li>Video Record</li> 48 <li>Still Capture</li> 49 </ul> 50 51 <p>Each mode has slightly different and overlapping capabilities. This made it 52 hard to implement new types of features, such as burst mode, since it would fall 53 between two of these modes.</p> 54 55 <img src="images/camera_block.png" alt="Camera block diagram" id="figure1" /> 56 <p class="img-caption"><strong>Figure 1.</strong> Camera components</p> 57 58 <p>Android 7.0 continues to support camera HAL1 as many devices still rely on 59 it. In addition, the Android camera service supports implementing both HALs (1 60 and 3), which is useful when you want to support a less-capable front-facing 61 camera with camera HAL1 and a more advanced back-facing camera with camera 62 HAL3.</p> 63 64 <p class="note"><strong>Note:</strong> Camera HAL2 is not supported as it was a 65 temporary step on the way to camera HAL3.</p> 66 67 <p>There is a single camera HAL <em>module</em> (with its own 68 <a href="/devices/camera/versioning.html#module_version">version 69 number</a>), which lists multiple independent camera devices that each have 70 their own version number. Camera module 2 or newer is required to support 71 devices 2 or newer, and such camera modules can have a mix of camera device 72 versions (this is what we mean when we say Android supports implementing both 73 HALs).</p> 74 75 <h2 id="v3-enhance">Camera HAL3 enhancements</h2> 76 77 <p>The aim of the Android Camera API redesign is to substantially increase the 78 ability of applications to control the camera subsystem on Android devices while 79 reorganizing the API to make it more efficient and maintainable. The additional 80 control makes it easier to build high-quality camera applications on Android 81 devices that can operate reliably across multiple products while still using 82 device-specific algorithms whenever possible to maximize quality and 83 performance.</p> 84 85 <p>Version 3 of the camera subsystem structures the operation modes into a 86 single unified view, which can be used to implement any of the previous modes 87 and several others, such as burst mode. This results in better user control for 88 focus and exposure and more post-processing, such as noise reduction, contrast 89 and sharpening. Further, this simplified view makes it easier for application 90 developers to use the camera's various functions.</p> 91 <p>The API models the camera subsystem as a pipeline that converts incoming 92 requests for frame captures into frames, on a 1:1 basis. The requests 93 encapsulate all configuration information about the capture and processing of a 94 frame. This includes resolution and pixel format; manual sensor, lens and flash 95 control; 3A operating modes; RAW->YUV processing control; statistics generation; 96 and so on.</p> 97 98 <p>In simple terms, the application framework requests a frame from the camera 99 subsystem, and the camera subsystem returns results to an output stream. In 100 addition, metadata that contains information such as color spaces and lens 101 shading is generated for each set of results. You can think of camera version 3 102 as a pipeline to camera version 1's one-way stream. It converts each capture 103 request into one image captured by the sensor, which is processed into:</p> 104 105 <ul> 106 <li>A Result object with metadata about the capture.</li> 107 <li>One to N buffers of image data, each into its own destination Surface.</li> 108 </ul> 109 110 <p>The set of possible output Surfaces is preconfigured:</p> 111 112 <ul> 113 <li>Each Surface is a destination for a stream of image buffers of a fixed 114 resolution.</li> 115 <li>Only a small number of Surfaces can be configured as outputs at once (~3). 116 </li> 117 </ul> 118 119 <p>A request contains all desired capture settings and the list of output 120 Surfaces to push image buffers into for this request (out of the total 121 configured set). A request can be one-shot (with <code>capture()</code>), or it 122 may be repeated indefinitely (with <code>setRepeatingRequest()</code>). Captures 123 have priority over repeating requests.</p> 124 125 <img src="images/camera_simple_model.png" alt="Camera data model" id="figure2" /> 126 <p class="img-caption"><strong>Figure 2.</strong> Camera core operation model</p> 127 128 </body> 129 </html> 130