1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.hardware.camera.device@3.2; 18 19import android.hardware.camera.common@1.0::types; 20import ICameraDeviceSession; 21import ICameraDeviceCallback; 22 23/** 24 * Camera device HAL, first modern version 25 * 26 * Supports the android.hardware.Camera API, and the android.hardware.camera2 27 * API at LIMITED or better hardware level. 28 * 29 */ 30interface ICameraDevice { 31 32 /** 33 * Get camera device resource cost information. 34 * 35 * @return status Status code for the operation, one of: 36 * OK: 37 * On success 38 * INTERNAL_ERROR: 39 * An unexpected internal camera HAL error occurred, and the 40 * resource cost is not available. 41 * CAMERA_DISCONNECTED: 42 * An external camera device has been disconnected, and is no longer 43 * available. This camera device interface is now stale, and a new 44 * instance must be acquired if the device is reconnected. All 45 * subsequent calls on this interface must return 46 * CAMERA_DISCONNECTED. 47 * @return resourceCost 48 * The resources required to open this camera device, or unspecified 49 * values if status is not OK. 50 */ 51 getResourceCost() generates (Status status, CameraResourceCost resourceCost); 52 53 /** 54 * getCameraCharacteristics: 55 * 56 * Return the static camera information for this camera device. This 57 * information may not change between consecutive calls. 58 * 59 * When an external camera is disconnected, its camera id becomes 60 * invalid. Calling this method with this invalid camera id must result in 61 * ILLEGAL_ARGUMENT; this may happen even before the device status callback 62 * is invoked by the HAL. 63 * 64 * @return status Status code for the operation, one of: 65 * OK: 66 * On a successful open of the camera device. 67 * INTERNAL_ERROR: 68 * The camera device cannot be opened due to an internal 69 * error. 70 * CAMERA_DISCONNECTED: 71 * An external camera device has been disconnected, and is no longer 72 * available. This camera device interface is now stale, and a new 73 * instance must be acquired if the device is reconnected. All 74 * subsequent calls on this interface must return 75 * CAMERA_DISCONNECTED. 76 * 77 * @return cameraCharacteristics 78 * The static metadata for this camera device, or an empty metadata 79 * structure if status is not OK. 80 * 81 */ 82 getCameraCharacteristics() generates 83 (Status status, CameraMetadata cameraCharacteristics); 84 85 /** 86 * setTorchMode: 87 * 88 * Turn on or off the torch mode of the flash unit associated with this 89 * camera device. If the operation is successful, HAL must notify the 90 * framework torch state by invoking 91 * ICameraProviderCallback::torchModeStatusChange() with the new state. 92 * 93 * An active camera session has a higher priority accessing the flash 94 * unit. When there are any resource conflicts, such as when open() is 95 * called to fully activate a camera device, the provider must notify the 96 * framework through ICameraProviderCallback::torchModeStatusChange() that 97 * the torch mode has been turned off and the torch mode state has become 98 * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode 99 * become available again, the provider must notify the framework through 100 * ICameraProviderCallback::torchModeStatusChange() that the torch mode 101 * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to 102 * be called. 103 * 104 * When the client calls setTorchMode() to turn on the torch mode of a flash 105 * unit, if the HAL cannot keep multiple torch modes on simultaneously, the 106 * HAL must turn off the torch mode(s) that were turned on by previous 107 * setTorchMode() calls and notify the framework that the torch mode state 108 * of those flash unit(s) has become TORCH_MODE_STATUS_AVAILABLE_OFF. 109 * 110 * @param torchMode The new mode to set the device flash unit to. 111 * 112 * @return status Status code for the operation, one of: 113 * OK: 114 * On a successful change to the torch state 115 * INTERNAL_ERROR: 116 * The flash unit cannot be operated due to an unexpected internal 117 * error. 118 * ILLEGAL_ARGUMENT: 119 * The camera ID is unknown. 120 * CAMERA_IN_USE: 121 * This camera device has been opened, so the torch cannot be 122 * controlled until it is closed. 123 * MAX_CAMERAS_IN_USE: 124 * Due to other camera devices being open, or due to other 125 * resource constraints, the torch cannot be controlled currently. 126 * METHOD_NOT_SUPPORTED: 127 * This provider does not support direct operation of flashlight 128 * torch mode. The framework must open the camera device and turn 129 * the torch on through the device interface. 130 * OPERATION_NOT_SUPPORTED: 131 * This camera device does not have a flash unit. This can 132 * be returned if and only if android.flash.info.available is 133 * false. 134 * CAMERA_DISCONNECTED: 135 * An external camera device has been disconnected, and is no longer 136 * available. This camera device interface is now stale, and a new 137 * instance must be acquired if the device is reconnected. All 138 * subsequent calls on this interface must return 139 * CAMERA_DISCONNECTED. 140 * 141 */ 142 setTorchMode(TorchMode mode) generates (Status status); 143 144 /** 145 * open: 146 * 147 * Power on and initialize this camera device for active use, returning a 148 * session handle for active operations. 149 * 150 * @param callback Interface to invoke by the HAL for device asynchronous 151 * events. For HALs newer than version 3.2, HAL must use castFrom 152 * method to check the exact version of callback sent by camera service. 153 * 154 * @return status Status code for the operation, one of: 155 * OK: 156 * On a successful open of the camera device. 157 * INTERNAL_ERROR: 158 * The camera device cannot be opened due to an internal 159 * error. 160 * ILLEGAL_ARGUMENT: 161 * The callbacks handle is invalid (for example, it is null). 162 * CAMERA_IN_USE: 163 * This camera device is already open. 164 * MAX_CAMERAS_IN_USE: 165 * The maximal number of camera devices that can be 166 * opened concurrently were opened already. 167 * CAMERA_DISCONNECTED: 168 * This external camera device has been disconnected, and is no 169 * longer available. This interface is now stale, and a new instance 170 * must be acquired if the device is reconnected. All subsequent 171 * calls on this interface must return CAMERA_DISCONNECTED. 172 * @return session The interface to the newly-opened camera session, 173 * or null if status is not OK. 174 */ 175 open(ICameraDeviceCallback callback) generates 176 (Status status, ICameraDeviceSession session); 177 178 /** 179 * dumpState: 180 * 181 * Print out debugging state for the camera device. This may be called by 182 * the framework when the camera service is asked for a debug dump, which 183 * happens when using the dumpsys tool, or when capturing a bugreport. 184 * 185 * The passed-in file descriptor can be used to write debugging text using 186 * dprintf() or write(). The text must be in ASCII encoding only. 187 * 188 * In case this camera device has been disconnected, the dump must not fail, 189 * but may simply print out 'Device disconnected' or equivalent. 190 * 191 * Performance requirements: 192 * 193 * This must be a non-blocking call. The HAL should return from this call 194 * in 1ms, must return from this call in 10ms. This call must avoid 195 * deadlocks, as it may be called at any point during camera operation. 196 * Any synchronization primitives used (such as mutex locks or semaphores) 197 * must be acquired with a timeout. 198 */ 199 dumpState(handle fd); 200 201}; 202