Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* |
| 3 | * Copyright (C) 2019, Google Inc. |
| 4 | * |
| 5 | * camera_device.cpp - libcamera Android Camera Device |
| 6 | */ |
| 7 | |
| 8 | #include "camera_device.h" |
| 9 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 10 | #include "log.h" |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 11 | #include "utils.h" |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 12 | |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 13 | #include "camera_metadata.h" |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 14 | |
| 15 | using namespace libcamera; |
| 16 | |
| 17 | LOG_DECLARE_CATEGORY(HAL); |
| 18 | |
| 19 | /* |
| 20 | * \struct Camera3RequestDescriptor |
| 21 | * |
| 22 | * A utility structure that groups information about a capture request to be |
| 23 | * later re-used at request complete time to notify the framework. |
| 24 | */ |
| 25 | |
| 26 | CameraDevice::Camera3RequestDescriptor::Camera3RequestDescriptor( |
| 27 | unsigned int frameNumber, unsigned int numBuffers) |
| 28 | : frameNumber(frameNumber), numBuffers(numBuffers) |
| 29 | { |
| 30 | buffers = new camera3_stream_buffer_t[numBuffers]; |
| 31 | } |
| 32 | |
| 33 | CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor() |
| 34 | { |
| 35 | delete[] buffers; |
| 36 | } |
| 37 | |
| 38 | /* |
| 39 | * \class CameraDevice |
| 40 | * |
| 41 | * The CameraDevice class wraps a libcamera::Camera instance, and implements |
| 42 | * the camera_device_t interface by handling RPC requests received from its |
| 43 | * associated CameraProxy. |
| 44 | * |
| 45 | * It translate parameters and operations from Camera HALv3 API to the libcamera |
| 46 | * ones to provide static information for a Camera, create request templates |
| 47 | * for it, process capture requests and then deliver capture results back |
| 48 | * to the framework using the designated callbacks. |
| 49 | */ |
| 50 | |
Laurent Pinchart | 0ed40d2 | 2019-08-18 01:45:01 +0300 | [diff] [blame] | 51 | CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera) |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 52 | : running_(false), camera_(camera), staticMetadata_(nullptr) |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 53 | { |
| 54 | camera_->requestCompleted.connect(this, &CameraDevice::requestComplete); |
| 55 | } |
| 56 | |
| 57 | CameraDevice::~CameraDevice() |
| 58 | { |
| 59 | if (staticMetadata_) |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 60 | delete staticMetadata_; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 61 | |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 62 | for (auto &it : requestTemplates_) |
| 63 | delete it.second; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 64 | } |
| 65 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 66 | int CameraDevice::open() |
| 67 | { |
| 68 | int ret = camera_->acquire(); |
| 69 | if (ret) { |
| 70 | LOG(HAL, Error) << "Failed to acquire the camera"; |
| 71 | return ret; |
| 72 | } |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | void CameraDevice::close() |
| 78 | { |
| 79 | camera_->stop(); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 80 | camera_->release(); |
| 81 | |
| 82 | running_ = false; |
| 83 | } |
| 84 | |
| 85 | void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks) |
| 86 | { |
| 87 | callbacks_ = callbacks; |
| 88 | } |
| 89 | |
| 90 | /* |
| 91 | * Return static information for the camera. |
| 92 | */ |
| 93 | camera_metadata_t *CameraDevice::getStaticMetadata() |
| 94 | { |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 95 | if (staticMetadata_) |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 96 | return staticMetadata_->get(); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 97 | |
| 98 | /* |
| 99 | * The here reported metadata are enough to implement a basic capture |
| 100 | * example application, but a real camera implementation will require |
| 101 | * more. |
| 102 | */ |
| 103 | |
Jacopo Mondi | 48504ba | 2019-09-04 16:18:19 +0200 | [diff] [blame] | 104 | /* |
| 105 | * \todo Keep this in sync with the actual number of entries. |
Jacopo Mondi | 19f85f4 | 2019-09-04 16:18:25 +0200 | [diff] [blame] | 106 | * Currently: 50 entries, 666 bytes |
Jacopo Mondi | 48504ba | 2019-09-04 16:18:19 +0200 | [diff] [blame] | 107 | */ |
Jacopo Mondi | 19f85f4 | 2019-09-04 16:18:25 +0200 | [diff] [blame] | 108 | staticMetadata_ = new CameraMetadata(50, 700); |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 109 | if (!staticMetadata_->isValid()) { |
| 110 | LOG(HAL, Error) << "Failed to allocate static metadata"; |
| 111 | delete staticMetadata_; |
| 112 | staticMetadata_ = nullptr; |
| 113 | return nullptr; |
| 114 | } |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 115 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 116 | /* Color correction static metadata. */ |
| 117 | std::vector<uint8_t> aberrationModes = { |
| 118 | ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF, |
| 119 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 120 | staticMetadata_->addEntry(ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, |
| 121 | aberrationModes.data(), |
| 122 | aberrationModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 123 | |
| 124 | /* Control static metadata. */ |
| 125 | std::vector<uint8_t> aeAvailableAntiBandingModes = { |
| 126 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF, |
| 127 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ, |
| 128 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ, |
| 129 | ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO, |
| 130 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 131 | staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, |
| 132 | aeAvailableAntiBandingModes.data(), |
| 133 | aeAvailableAntiBandingModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 134 | |
| 135 | std::vector<uint8_t> aeAvailableModes = { |
| 136 | ANDROID_CONTROL_AE_MODE_ON, |
| 137 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 138 | staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_MODES, |
| 139 | aeAvailableModes.data(), |
| 140 | aeAvailableModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 141 | |
| 142 | std::vector<int32_t> availableAeFpsTarget = { |
| 143 | 15, 30, |
| 144 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 145 | staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, |
| 146 | availableAeFpsTarget.data(), |
| 147 | availableAeFpsTarget.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 148 | |
| 149 | std::vector<int32_t> aeCompensationRange = { |
| 150 | 0, 0, |
| 151 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 152 | staticMetadata_->addEntry(ANDROID_CONTROL_AE_COMPENSATION_RANGE, |
| 153 | aeCompensationRange.data(), |
| 154 | aeCompensationRange.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 155 | |
| 156 | const camera_metadata_rational_t aeCompensationStep[] = { |
| 157 | { 0, 1 } |
| 158 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 159 | staticMetadata_->addEntry(ANDROID_CONTROL_AE_COMPENSATION_STEP, |
| 160 | aeCompensationStep, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 161 | |
| 162 | std::vector<uint8_t> availableAfModes = { |
| 163 | ANDROID_CONTROL_AF_MODE_OFF, |
| 164 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 165 | staticMetadata_->addEntry(ANDROID_CONTROL_AF_AVAILABLE_MODES, |
| 166 | availableAfModes.data(), |
| 167 | availableAfModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 168 | |
| 169 | std::vector<uint8_t> availableEffects = { |
| 170 | ANDROID_CONTROL_EFFECT_MODE_OFF, |
| 171 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 172 | staticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_EFFECTS, |
| 173 | availableEffects.data(), |
| 174 | availableEffects.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 175 | |
| 176 | std::vector<uint8_t> availableSceneModes = { |
| 177 | ANDROID_CONTROL_SCENE_MODE_DISABLED, |
| 178 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 179 | staticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_SCENE_MODES, |
| 180 | availableSceneModes.data(), |
| 181 | availableSceneModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 182 | |
| 183 | std::vector<uint8_t> availableStabilizationModes = { |
| 184 | ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF, |
| 185 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 186 | staticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, |
| 187 | availableStabilizationModes.data(), |
| 188 | availableStabilizationModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 189 | |
| 190 | std::vector<uint8_t> availableAwbModes = { |
| 191 | ANDROID_CONTROL_AWB_MODE_OFF, |
| 192 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 193 | staticMetadata_->addEntry(ANDROID_CONTROL_AWB_AVAILABLE_MODES, |
| 194 | availableAwbModes.data(), |
| 195 | availableAwbModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 196 | |
| 197 | std::vector<int32_t> availableMaxRegions = { |
| 198 | 0, 0, 0, |
| 199 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 200 | staticMetadata_->addEntry(ANDROID_CONTROL_MAX_REGIONS, |
| 201 | availableMaxRegions.data(), |
| 202 | availableMaxRegions.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 203 | |
| 204 | std::vector<uint8_t> sceneModesOverride = { |
| 205 | ANDROID_CONTROL_AE_MODE_ON, |
| 206 | ANDROID_CONTROL_AWB_MODE_AUTO, |
| 207 | ANDROID_CONTROL_AF_MODE_AUTO, |
| 208 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 209 | staticMetadata_->addEntry(ANDROID_CONTROL_SCENE_MODE_OVERRIDES, |
| 210 | sceneModesOverride.data(), |
| 211 | sceneModesOverride.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 212 | |
| 213 | uint8_t aeLockAvailable = ANDROID_CONTROL_AE_LOCK_AVAILABLE_FALSE; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 214 | staticMetadata_->addEntry(ANDROID_CONTROL_AE_LOCK_AVAILABLE, |
| 215 | &aeLockAvailable, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 216 | |
| 217 | uint8_t awbLockAvailable = ANDROID_CONTROL_AWB_LOCK_AVAILABLE_FALSE; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 218 | staticMetadata_->addEntry(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, |
| 219 | &awbLockAvailable, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 220 | |
| 221 | char availableControlModes = ANDROID_CONTROL_MODE_AUTO; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 222 | staticMetadata_->addEntry(ANDROID_CONTROL_AVAILABLE_MODES, |
| 223 | &availableControlModes, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 224 | |
| 225 | /* JPEG static metadata. */ |
| 226 | std::vector<int32_t> availableThumbnailSizes = { |
| 227 | 0, 0, |
| 228 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 229 | staticMetadata_->addEntry(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
| 230 | availableThumbnailSizes.data(), |
| 231 | availableThumbnailSizes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 232 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 233 | /* Sensor static metadata. */ |
| 234 | int32_t pixelArraySize[] = { |
| 235 | 2592, 1944, |
| 236 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 237 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, |
| 238 | &pixelArraySize, 2); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 239 | |
| 240 | int32_t sensorSizes[] = { |
| 241 | 0, 0, 2560, 1920, |
| 242 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 243 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, |
| 244 | &sensorSizes, 4); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 245 | |
| 246 | int32_t sensitivityRange[] = { |
| 247 | 32, 2400, |
| 248 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 249 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, |
| 250 | &sensitivityRange, 2); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 251 | |
| 252 | uint16_t filterArr = ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT_GRBG; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 253 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, |
| 254 | &filterArr, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 255 | |
| 256 | int64_t exposureTimeRange[] = { |
| 257 | 100000, 200000000, |
| 258 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 259 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, |
| 260 | &exposureTimeRange, 2); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 261 | |
| 262 | int32_t orientation = 0; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 263 | staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, |
| 264 | &orientation, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 265 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 266 | std::vector<int32_t> testPatterModes = { |
| 267 | ANDROID_SENSOR_TEST_PATTERN_MODE_OFF, |
| 268 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 269 | staticMetadata_->addEntry(ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, |
| 270 | testPatterModes.data(), |
| 271 | testPatterModes.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 272 | |
| 273 | std::vector<float> physicalSize = { |
| 274 | 2592, 1944, |
| 275 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 276 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, |
| 277 | physicalSize.data(), |
| 278 | physicalSize.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 279 | |
| 280 | uint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 281 | staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, |
| 282 | ×tampSource, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 283 | |
| 284 | /* Statistics static metadata. */ |
| 285 | uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 286 | staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, |
| 287 | &faceDetectMode, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 288 | |
| 289 | int32_t maxFaceCount = 0; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 290 | staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, |
| 291 | &maxFaceCount, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 292 | |
| 293 | /* Sync static metadata. */ |
| 294 | int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 295 | staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, &maxLatency, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 296 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 297 | /* Flash static metadata. */ |
| 298 | char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 299 | staticMetadata_->addEntry(ANDROID_FLASH_INFO_AVAILABLE, |
| 300 | &flashAvailable, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 301 | |
| 302 | /* Lens static metadata. */ |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 303 | std::vector<float> lensApertures = { |
| 304 | 2.53 / 100, |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 305 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 306 | staticMetadata_->addEntry(ANDROID_LENS_INFO_AVAILABLE_APERTURES, |
| 307 | lensApertures.data(), |
| 308 | lensApertures.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 309 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 310 | uint8_t lensFacing = ANDROID_LENS_FACING_FRONT; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 311 | staticMetadata_->addEntry(ANDROID_LENS_FACING, &lensFacing, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 312 | |
| 313 | std::vector<float> lensFocalLenghts = { |
| 314 | 1, |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 315 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 316 | staticMetadata_->addEntry(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, |
| 317 | lensFocalLenghts.data(), |
| 318 | lensFocalLenghts.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 319 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 320 | std::vector<uint8_t> opticalStabilizations = { |
| 321 | ANDROID_LENS_OPTICAL_STABILIZATION_MODE_OFF, |
| 322 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 323 | staticMetadata_->addEntry(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, |
| 324 | opticalStabilizations.data(), |
| 325 | opticalStabilizations.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 326 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 327 | float hypeFocalDistance = 0; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 328 | staticMetadata_->addEntry(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, |
| 329 | &hypeFocalDistance, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 330 | |
| 331 | float minFocusDistance = 0; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 332 | staticMetadata_->addEntry(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, |
| 333 | &minFocusDistance, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 334 | |
| 335 | /* Noise reduction modes. */ |
| 336 | uint8_t noiseReductionModes = ANDROID_NOISE_REDUCTION_MODE_OFF; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 337 | staticMetadata_->addEntry(ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, |
| 338 | &noiseReductionModes, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 339 | |
| 340 | /* Scaler static metadata. */ |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 341 | float maxDigitalZoom = 1; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 342 | staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, |
| 343 | &maxDigitalZoom, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 344 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 345 | std::vector<uint32_t> availableStreamFormats = { |
| 346 | ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, |
| 347 | ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, |
| 348 | ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, |
| 349 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 350 | staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_FORMATS, |
| 351 | availableStreamFormats.data(), |
| 352 | availableStreamFormats.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 353 | |
| 354 | std::vector<uint32_t> availableStreamConfigurations = { |
| 355 | ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, |
| 356 | ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, |
| 357 | ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, 2560, 1920, |
| 358 | ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, |
| 359 | ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, 2560, 1920, |
| 360 | ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT, |
| 361 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 362 | staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, |
| 363 | availableStreamConfigurations.data(), |
| 364 | availableStreamConfigurations.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 365 | |
| 366 | std::vector<int64_t> availableStallDurations = { |
| 367 | ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333, |
| 368 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 369 | staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, |
| 370 | availableStallDurations.data(), |
| 371 | availableStallDurations.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 372 | |
| 373 | std::vector<int64_t> minFrameDurations = { |
| 374 | ANDROID_SCALER_AVAILABLE_FORMATS_BLOB, 2560, 1920, 33333333, |
| 375 | ANDROID_SCALER_AVAILABLE_FORMATS_IMPLEMENTATION_DEFINED, 2560, 1920, 33333333, |
| 376 | ANDROID_SCALER_AVAILABLE_FORMATS_YCbCr_420_888, 2560, 1920, 33333333, |
| 377 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 378 | staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, |
| 379 | minFrameDurations.data(), |
| 380 | minFrameDurations.size()); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 381 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 382 | uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 383 | staticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, &croppingType, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 384 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 385 | /* Info static metadata. */ |
| 386 | uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 387 | staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, |
| 388 | &supportedHWLevel, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 389 | |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 390 | /* Request static metadata. */ |
| 391 | int32_t partialResultCount = 1; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 392 | staticMetadata_->addEntry(ANDROID_REQUEST_PARTIAL_RESULT_COUNT, |
| 393 | &partialResultCount, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 394 | |
| 395 | uint8_t maxPipelineDepth = 2; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 396 | staticMetadata_->addEntry(ANDROID_REQUEST_PIPELINE_MAX_DEPTH, |
| 397 | &maxPipelineDepth, 1); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 398 | |
| 399 | std::vector<uint8_t> availableCapabilities = { |
| 400 | ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, |
| 401 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 402 | staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, |
| 403 | availableCapabilities.data(), |
| 404 | availableCapabilities.size()); |
Jacopo Mondi | b4893fc | 2019-09-04 16:18:18 +0200 | [diff] [blame] | 405 | |
Jacopo Mondi | 19f85f4 | 2019-09-04 16:18:25 +0200 | [diff] [blame] | 406 | std::vector<int32_t> availableCharacteristicsKeys = { |
| 407 | ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, |
| 408 | ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, |
| 409 | ANDROID_CONTROL_AE_AVAILABLE_MODES, |
| 410 | ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, |
| 411 | ANDROID_CONTROL_AE_COMPENSATION_RANGE, |
| 412 | ANDROID_CONTROL_AE_COMPENSATION_STEP, |
| 413 | ANDROID_CONTROL_AF_AVAILABLE_MODES, |
| 414 | ANDROID_CONTROL_AVAILABLE_EFFECTS, |
| 415 | ANDROID_CONTROL_AVAILABLE_SCENE_MODES, |
| 416 | ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, |
| 417 | ANDROID_CONTROL_AWB_AVAILABLE_MODES, |
| 418 | ANDROID_CONTROL_MAX_REGIONS, |
| 419 | ANDROID_CONTROL_SCENE_MODE_OVERRIDES, |
| 420 | ANDROID_CONTROL_AE_LOCK_AVAILABLE, |
| 421 | ANDROID_CONTROL_AWB_LOCK_AVAILABLE, |
| 422 | ANDROID_CONTROL_AVAILABLE_MODES, |
| 423 | ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, |
| 424 | ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, |
| 425 | ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, |
| 426 | ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, |
| 427 | ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, |
| 428 | ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, |
| 429 | ANDROID_SENSOR_ORIENTATION, |
| 430 | ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, |
| 431 | ANDROID_SENSOR_INFO_PHYSICAL_SIZE, |
| 432 | ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, |
| 433 | ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, |
| 434 | ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, |
| 435 | ANDROID_SYNC_MAX_LATENCY, |
| 436 | ANDROID_FLASH_INFO_AVAILABLE, |
| 437 | ANDROID_LENS_INFO_AVAILABLE_APERTURES, |
| 438 | ANDROID_LENS_FACING, |
| 439 | ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, |
| 440 | ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, |
| 441 | ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, |
| 442 | ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, |
| 443 | ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, |
| 444 | ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, |
| 445 | ANDROID_SCALER_AVAILABLE_FORMATS, |
| 446 | ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, |
| 447 | ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, |
| 448 | ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, |
| 449 | ANDROID_SCALER_CROPPING_TYPE, |
| 450 | ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, |
| 451 | ANDROID_REQUEST_PARTIAL_RESULT_COUNT, |
| 452 | ANDROID_REQUEST_PIPELINE_MAX_DEPTH, |
| 453 | ANDROID_REQUEST_AVAILABLE_CAPABILITIES, |
| 454 | }; |
| 455 | staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, |
| 456 | availableCharacteristicsKeys.data(), |
| 457 | availableCharacteristicsKeys.size()); |
| 458 | |
| 459 | std::vector<int32_t> availableRequestKeys = { |
| 460 | ANDROID_CONTROL_AE_MODE, |
| 461 | ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, |
| 462 | ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, |
| 463 | ANDROID_CONTROL_AE_LOCK, |
| 464 | ANDROID_CONTROL_AF_TRIGGER, |
| 465 | ANDROID_CONTROL_AWB_MODE, |
| 466 | ANDROID_CONTROL_AWB_LOCK, |
| 467 | ANDROID_FLASH_MODE, |
| 468 | ANDROID_STATISTICS_FACE_DETECT_MODE, |
| 469 | ANDROID_NOISE_REDUCTION_MODE, |
| 470 | ANDROID_COLOR_CORRECTION_ABERRATION_MODE, |
| 471 | ANDROID_CONTROL_CAPTURE_INTENT, |
| 472 | }; |
| 473 | staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, |
| 474 | availableRequestKeys.data(), |
| 475 | availableRequestKeys.size()); |
| 476 | |
| 477 | std::vector<int32_t> availableResultKeys = { |
| 478 | ANDROID_CONTROL_AE_STATE, |
| 479 | ANDROID_CONTROL_AE_LOCK, |
| 480 | ANDROID_CONTROL_AF_STATE, |
| 481 | ANDROID_CONTROL_AWB_STATE, |
| 482 | ANDROID_CONTROL_AWB_LOCK, |
| 483 | ANDROID_LENS_STATE, |
| 484 | ANDROID_SCALER_CROP_REGION, |
| 485 | ANDROID_SENSOR_TIMESTAMP, |
| 486 | ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, |
| 487 | ANDROID_SENSOR_EXPOSURE_TIME, |
| 488 | ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, |
| 489 | ANDROID_STATISTICS_SCENE_FLICKER, |
| 490 | }; |
| 491 | staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, |
| 492 | availableResultKeys.data(), |
| 493 | availableResultKeys.size()); |
| 494 | |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 495 | if (!staticMetadata_->isValid()) { |
| 496 | LOG(HAL, Error) << "Failed to construct static metadata"; |
| 497 | delete staticMetadata_; |
| 498 | staticMetadata_ = nullptr; |
| 499 | return nullptr; |
| 500 | } |
| 501 | |
| 502 | return staticMetadata_->get(); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | /* |
| 506 | * Produce a metadata pack to be used as template for a capture request. |
| 507 | */ |
| 508 | const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) |
| 509 | { |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 510 | auto it = requestTemplates_.find(type); |
| 511 | if (it != requestTemplates_.end()) |
| 512 | return it->second->get(); |
| 513 | |
| 514 | /* Use the capture intent matching the requested template type. */ |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 515 | uint8_t captureIntent; |
| 516 | switch (type) { |
| 517 | case CAMERA3_TEMPLATE_PREVIEW: |
| 518 | captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW; |
| 519 | break; |
| 520 | case CAMERA3_TEMPLATE_STILL_CAPTURE: |
| 521 | captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE; |
| 522 | break; |
| 523 | case CAMERA3_TEMPLATE_VIDEO_RECORD: |
| 524 | captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; |
| 525 | break; |
| 526 | case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: |
| 527 | captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; |
| 528 | break; |
| 529 | case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: |
| 530 | captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG; |
| 531 | break; |
| 532 | case CAMERA3_TEMPLATE_MANUAL: |
| 533 | captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL; |
| 534 | break; |
| 535 | default: |
| 536 | LOG(HAL, Error) << "Invalid template request type: " << type; |
| 537 | return nullptr; |
| 538 | } |
| 539 | |
Jacopo Mondi | 6370347 | 2019-09-04 16:18:22 +0200 | [diff] [blame] | 540 | /* |
| 541 | * \todo Keep this in sync with the actual number of entries. |
| 542 | * Currently: 12 entries, 15 bytes |
| 543 | */ |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 544 | CameraMetadata *requestTemplate = new CameraMetadata(15, 20); |
| 545 | if (!requestTemplate->isValid()) { |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 546 | LOG(HAL, Error) << "Failed to allocate template metadata"; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 547 | delete requestTemplate; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 548 | return nullptr; |
| 549 | } |
| 550 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 551 | uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 552 | requestTemplate->addEntry(ANDROID_CONTROL_AE_MODE, |
| 553 | &aeMode, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 554 | |
| 555 | int32_t aeExposureCompensation = 0; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 556 | requestTemplate->addEntry(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, |
| 557 | &aeExposureCompensation, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 558 | |
| 559 | uint8_t aePrecaptureTrigger = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 560 | requestTemplate->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, |
| 561 | &aePrecaptureTrigger, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 562 | |
| 563 | uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_OFF; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 564 | requestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK, |
| 565 | &aeLock, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 566 | |
| 567 | uint8_t afTrigger = ANDROID_CONTROL_AF_TRIGGER_IDLE; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 568 | requestTemplate->addEntry(ANDROID_CONTROL_AF_TRIGGER, |
| 569 | &afTrigger, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 570 | |
| 571 | uint8_t awbMode = ANDROID_CONTROL_AWB_MODE_AUTO; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 572 | requestTemplate->addEntry(ANDROID_CONTROL_AWB_MODE, |
| 573 | &awbMode, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 574 | |
| 575 | uint8_t awbLock = ANDROID_CONTROL_AWB_LOCK_OFF; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 576 | requestTemplate->addEntry(ANDROID_CONTROL_AWB_LOCK, |
| 577 | &awbLock, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 578 | |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 579 | uint8_t flashMode = ANDROID_FLASH_MODE_OFF; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 580 | requestTemplate->addEntry(ANDROID_FLASH_MODE, |
| 581 | &flashMode, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 582 | |
| 583 | uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 584 | requestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE, |
| 585 | &faceDetectMode, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 586 | |
Jacopo Mondi | 9b361dc | 2019-09-04 16:18:21 +0200 | [diff] [blame] | 587 | uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 588 | requestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE, |
| 589 | &noiseReduction, 1); |
Jacopo Mondi | 9b361dc | 2019-09-04 16:18:21 +0200 | [diff] [blame] | 590 | |
| 591 | uint8_t aberrationMode = ANDROID_COLOR_CORRECTION_ABERRATION_MODE_OFF; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 592 | requestTemplate->addEntry(ANDROID_COLOR_CORRECTION_ABERRATION_MODE, |
| 593 | &aberrationMode, 1); |
Jacopo Mondi | 9b361dc | 2019-09-04 16:18:21 +0200 | [diff] [blame] | 594 | |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 595 | requestTemplate->addEntry(ANDROID_CONTROL_CAPTURE_INTENT, |
| 596 | &captureIntent, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 597 | |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 598 | if (!requestTemplate->isValid()) { |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 599 | LOG(HAL, Error) << "Failed to construct request template"; |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 600 | delete requestTemplate; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 601 | return nullptr; |
| 602 | } |
| 603 | |
Jacopo Mondi | fcd5a4f | 2019-09-04 16:18:23 +0200 | [diff] [blame] | 604 | requestTemplates_[type] = requestTemplate; |
| 605 | return requestTemplate->get(); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | /* |
| 609 | * Inspect the stream_list to produce a list of StreamConfiguration to |
| 610 | * be use to configure the Camera. |
| 611 | */ |
| 612 | int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) |
| 613 | { |
| 614 | for (unsigned int i = 0; i < stream_list->num_streams; ++i) { |
| 615 | camera3_stream_t *stream = stream_list->streams[i]; |
| 616 | |
| 617 | LOG(HAL, Info) << "Stream #" << i |
| 618 | << ", direction: " << stream->stream_type |
| 619 | << ", width: " << stream->width |
| 620 | << ", height: " << stream->height |
Laurent Pinchart | f391048 | 2019-10-13 22:22:04 +0300 | [diff] [blame] | 621 | << ", format: " << utils::hex(stream->format); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | /* Hardcode viewfinder role, collecting sizes from the stream config. */ |
| 625 | if (stream_list->num_streams != 1) { |
| 626 | LOG(HAL, Error) << "Only one stream supported"; |
| 627 | return -EINVAL; |
| 628 | } |
| 629 | |
| 630 | StreamRoles roles = { StreamRole::Viewfinder }; |
| 631 | config_ = camera_->generateConfiguration(roles); |
| 632 | if (!config_ || config_->empty()) { |
| 633 | LOG(HAL, Error) << "Failed to generate camera configuration"; |
| 634 | return -EINVAL; |
| 635 | } |
| 636 | |
| 637 | /* Only one stream is supported. */ |
| 638 | camera3_stream_t *camera3Stream = stream_list->streams[0]; |
| 639 | StreamConfiguration *streamConfiguration = &config_->at(0); |
| 640 | streamConfiguration->size.width = camera3Stream->width; |
| 641 | streamConfiguration->size.height = camera3Stream->height; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 642 | |
| 643 | /* |
| 644 | * \todo We'll need to translate from Android defined pixel format codes |
| 645 | * to the libcamera image format codes. For now, do not change the |
| 646 | * format returned from Camera::generateConfiguration(). |
| 647 | */ |
| 648 | |
| 649 | switch (config_->validate()) { |
| 650 | case CameraConfiguration::Valid: |
| 651 | break; |
| 652 | case CameraConfiguration::Adjusted: |
| 653 | LOG(HAL, Info) << "Camera configuration adjusted"; |
| 654 | config_.reset(); |
| 655 | return -EINVAL; |
| 656 | case CameraConfiguration::Invalid: |
| 657 | LOG(HAL, Info) << "Camera configuration invalid"; |
| 658 | config_.reset(); |
| 659 | return -EINVAL; |
| 660 | } |
| 661 | |
| 662 | camera3Stream->max_buffers = streamConfiguration->bufferCount; |
| 663 | |
| 664 | /* |
| 665 | * Once the CameraConfiguration has been adjusted/validated |
| 666 | * it can be applied to the camera. |
| 667 | */ |
| 668 | int ret = camera_->configure(config_.get()); |
| 669 | if (ret) { |
| 670 | LOG(HAL, Error) << "Failed to configure camera '" |
| 671 | << camera_->name() << "'"; |
| 672 | return ret; |
| 673 | } |
| 674 | |
| 675 | return 0; |
| 676 | } |
| 677 | |
Jacopo Mondi | 53eab99 | 2019-10-27 02:01:08 +0100 | [diff] [blame] | 678 | void CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request) |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 679 | { |
| 680 | StreamConfiguration *streamConfiguration = &config_->at(0); |
| 681 | Stream *stream = streamConfiguration->stream(); |
| 682 | |
| 683 | if (camera3Request->num_output_buffers != 1) { |
| 684 | LOG(HAL, Error) << "Invalid number of output buffers: " |
| 685 | << camera3Request->num_output_buffers; |
Jacopo Mondi | 53eab99 | 2019-10-27 02:01:08 +0100 | [diff] [blame] | 686 | return; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | /* Start the camera if that's the first request we handle. */ |
| 690 | if (!running_) { |
Niklas Söderlund | a1c5450 | 2019-11-25 17:51:06 +0100 | [diff] [blame^] | 691 | int ret = camera_->start(); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 692 | if (ret) { |
| 693 | LOG(HAL, Error) << "Failed to start camera"; |
Jacopo Mondi | 53eab99 | 2019-10-27 02:01:08 +0100 | [diff] [blame] | 694 | return; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | running_ = true; |
| 698 | } |
| 699 | |
| 700 | /* |
| 701 | * Queue a request for the Camera with the provided dmabuf file |
| 702 | * descriptors. |
| 703 | */ |
| 704 | const camera3_stream_buffer_t *camera3Buffers = |
| 705 | camera3Request->output_buffers; |
| 706 | |
| 707 | /* |
| 708 | * Save the request descriptors for use at completion time. |
| 709 | * The descriptor and the associated memory reserved here are freed |
| 710 | * at request complete time. |
| 711 | */ |
| 712 | Camera3RequestDescriptor *descriptor = |
| 713 | new Camera3RequestDescriptor(camera3Request->frame_number, |
| 714 | camera3Request->num_output_buffers); |
| 715 | for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { |
| 716 | /* |
| 717 | * Keep track of which stream the request belongs to and store |
| 718 | * the native buffer handles. |
| 719 | * |
| 720 | * \todo Currently we only support one capture buffer. Copy |
| 721 | * all of them to be ready once we'll support more. |
| 722 | */ |
| 723 | descriptor->buffers[i].stream = camera3Buffers[i].stream; |
| 724 | descriptor->buffers[i].buffer = camera3Buffers[i].buffer; |
| 725 | } |
| 726 | |
| 727 | /* |
| 728 | * Create a libcamera buffer using the dmabuf descriptors of the first |
| 729 | * and (currently) only supported request buffer. |
| 730 | */ |
| 731 | const buffer_handle_t camera3Handle = *camera3Buffers[0].buffer; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 732 | |
Niklas Söderlund | 9217f27 | 2019-11-22 16:22:56 +0100 | [diff] [blame] | 733 | std::vector<FrameBuffer::Plane> planes; |
| 734 | for (int i = 0; i < 3; i++) { |
| 735 | FrameBuffer::Plane plane; |
| 736 | plane.fd = FileDescriptor(camera3Handle->data[i]); |
| 737 | /* |
| 738 | * Setting length to zero here is OK as the length is only used |
| 739 | * to map the memory of the plane. Libcamera do not need to poke |
| 740 | * at the memory content queued by the HAL. |
| 741 | */ |
| 742 | plane.length = 0; |
| 743 | planes.push_back(std::move(plane)); |
| 744 | } |
| 745 | |
| 746 | FrameBuffer *buffer = new FrameBuffer(std::move(planes)); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 747 | if (!buffer) { |
| 748 | LOG(HAL, Error) << "Failed to create buffer"; |
| 749 | delete descriptor; |
Jacopo Mondi | 53eab99 | 2019-10-27 02:01:08 +0100 | [diff] [blame] | 750 | return; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | Request *request = |
| 754 | camera_->createRequest(reinterpret_cast<uint64_t>(descriptor)); |
Niklas Söderlund | 9217f27 | 2019-11-22 16:22:56 +0100 | [diff] [blame] | 755 | request->addBuffer(stream, buffer); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 756 | |
| 757 | int ret = camera_->queueRequest(request); |
| 758 | if (ret) { |
| 759 | LOG(HAL, Error) << "Failed to queue request"; |
| 760 | goto error; |
| 761 | } |
| 762 | |
Jacopo Mondi | 53eab99 | 2019-10-27 02:01:08 +0100 | [diff] [blame] | 763 | return; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 764 | |
| 765 | error: |
| 766 | delete request; |
| 767 | delete descriptor; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 768 | } |
| 769 | |
Niklas Söderlund | f7ddfd4 | 2019-10-21 20:01:19 +0200 | [diff] [blame] | 770 | void CameraDevice::requestComplete(Request *request) |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 771 | { |
Niklas Söderlund | 9217f27 | 2019-11-22 16:22:56 +0100 | [diff] [blame] | 772 | const std::map<Stream *, FrameBuffer *> &buffers = request->buffers(); |
| 773 | FrameBuffer *buffer = buffers.begin()->second; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 774 | camera3_buffer_status status = CAMERA3_BUFFER_STATUS_OK; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 775 | std::unique_ptr<CameraMetadata> resultMetadata; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 776 | |
| 777 | if (request->status() != Request::RequestComplete) { |
| 778 | LOG(HAL, Error) << "Request not succesfully completed: " |
| 779 | << request->status(); |
| 780 | status = CAMERA3_BUFFER_STATUS_ERROR; |
| 781 | } |
| 782 | |
| 783 | /* Prepare to call back the Android camera stack. */ |
| 784 | Camera3RequestDescriptor *descriptor = |
| 785 | reinterpret_cast<Camera3RequestDescriptor *>(request->cookie()); |
| 786 | |
| 787 | camera3_capture_result_t captureResult = {}; |
| 788 | captureResult.frame_number = descriptor->frameNumber; |
| 789 | captureResult.num_output_buffers = descriptor->numBuffers; |
| 790 | for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { |
| 791 | /* |
| 792 | * \todo Currently we only support one capture buffer. Prepare |
| 793 | * all of them to be ready once we'll support more. |
| 794 | */ |
| 795 | descriptor->buffers[i].acquire_fence = -1; |
| 796 | descriptor->buffers[i].release_fence = -1; |
| 797 | descriptor->buffers[i].status = status; |
| 798 | } |
| 799 | captureResult.output_buffers = |
| 800 | const_cast<const camera3_stream_buffer_t *>(descriptor->buffers); |
| 801 | |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 802 | if (status == CAMERA3_BUFFER_STATUS_OK) { |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 803 | notifyShutter(descriptor->frameNumber, |
Niklas Söderlund | 9217f27 | 2019-11-22 16:22:56 +0100 | [diff] [blame] | 804 | buffer->metadata().timestamp); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 805 | |
| 806 | captureResult.partial_result = 1; |
| 807 | resultMetadata = getResultMetadata(descriptor->frameNumber, |
Niklas Söderlund | 9217f27 | 2019-11-22 16:22:56 +0100 | [diff] [blame] | 808 | buffer->metadata().timestamp); |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 809 | captureResult.result = resultMetadata->get(); |
| 810 | } |
| 811 | |
| 812 | if (status == CAMERA3_BUFFER_STATUS_ERROR || !captureResult.result) { |
| 813 | /* \todo Improve error handling. In case we notify an error |
| 814 | * because the metadata generation fails, a shutter event has |
| 815 | * already been notified for this frame number before the error |
| 816 | * is here signalled. Make sure the error path plays well with |
| 817 | * the camera stack state machine. |
| 818 | */ |
| 819 | notifyError(descriptor->frameNumber, |
| 820 | descriptor->buffers[0].stream); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | callbacks_->process_capture_result(callbacks_, &captureResult); |
| 824 | |
| 825 | delete descriptor; |
Niklas Söderlund | 9217f27 | 2019-11-22 16:22:56 +0100 | [diff] [blame] | 826 | delete buffer; |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | void CameraDevice::notifyShutter(uint32_t frameNumber, uint64_t timestamp) |
| 830 | { |
| 831 | camera3_notify_msg_t notify = {}; |
| 832 | |
| 833 | notify.type = CAMERA3_MSG_SHUTTER; |
| 834 | notify.message.shutter.frame_number = frameNumber; |
| 835 | notify.message.shutter.timestamp = timestamp; |
| 836 | |
| 837 | callbacks_->notify(callbacks_, ¬ify); |
| 838 | } |
| 839 | |
| 840 | void CameraDevice::notifyError(uint32_t frameNumber, camera3_stream_t *stream) |
| 841 | { |
| 842 | camera3_notify_msg_t notify = {}; |
| 843 | |
| 844 | notify.type = CAMERA3_MSG_ERROR; |
| 845 | notify.message.error.error_stream = stream; |
| 846 | notify.message.error.frame_number = frameNumber; |
| 847 | notify.message.error.error_code = CAMERA3_MSG_ERROR_REQUEST; |
| 848 | |
| 849 | callbacks_->notify(callbacks_, ¬ify); |
| 850 | } |
| 851 | |
| 852 | /* |
| 853 | * Produce a set of fixed result metadata. |
| 854 | */ |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 855 | std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata(int frame_number, |
| 856 | int64_t timestamp) |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 857 | { |
Jacopo Mondi | 48504ba | 2019-09-04 16:18:19 +0200 | [diff] [blame] | 858 | /* |
| 859 | * \todo Keep this in sync with the actual number of entries. |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 860 | * Currently: 12 entries, 36 bytes |
Jacopo Mondi | 48504ba | 2019-09-04 16:18:19 +0200 | [diff] [blame] | 861 | */ |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 862 | std::unique_ptr<CameraMetadata> resultMetadata = |
| 863 | utils::make_unique<CameraMetadata>(15, 50); |
| 864 | if (!resultMetadata->isValid()) { |
| 865 | LOG(HAL, Error) << "Failed to allocate static metadata"; |
| 866 | return nullptr; |
| 867 | } |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 868 | |
| 869 | const uint8_t ae_state = ANDROID_CONTROL_AE_STATE_CONVERGED; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 870 | resultMetadata->addEntry(ANDROID_CONTROL_AE_STATE, &ae_state, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 871 | |
| 872 | const uint8_t ae_lock = ANDROID_CONTROL_AE_LOCK_OFF; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 873 | resultMetadata->addEntry(ANDROID_CONTROL_AE_LOCK, &ae_lock, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 874 | |
| 875 | uint8_t af_state = ANDROID_CONTROL_AF_STATE_INACTIVE; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 876 | resultMetadata->addEntry(ANDROID_CONTROL_AF_STATE, &af_state, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 877 | |
| 878 | const uint8_t awb_state = ANDROID_CONTROL_AWB_STATE_CONVERGED; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 879 | resultMetadata->addEntry(ANDROID_CONTROL_AWB_STATE, &awb_state, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 880 | |
| 881 | const uint8_t awb_lock = ANDROID_CONTROL_AWB_LOCK_OFF; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 882 | resultMetadata->addEntry(ANDROID_CONTROL_AWB_LOCK, &awb_lock, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 883 | |
| 884 | const uint8_t lens_state = ANDROID_LENS_STATE_STATIONARY; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 885 | resultMetadata->addEntry(ANDROID_LENS_STATE, &lens_state, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 886 | |
| 887 | int32_t sensorSizes[] = { |
| 888 | 0, 0, 2560, 1920, |
| 889 | }; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 890 | resultMetadata->addEntry(ANDROID_SCALER_CROP_REGION, sensorSizes, 4); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 891 | |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 892 | resultMetadata->addEntry(ANDROID_SENSOR_TIMESTAMP, ×tamp, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 893 | |
| 894 | /* 33.3 msec */ |
| 895 | const int64_t rolling_shutter_skew = 33300000; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 896 | resultMetadata->addEntry(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, |
| 897 | &rolling_shutter_skew, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 898 | |
| 899 | /* 16.6 msec */ |
| 900 | const int64_t exposure_time = 16600000; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 901 | resultMetadata->addEntry(ANDROID_SENSOR_EXPOSURE_TIME, |
| 902 | &exposure_time, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 903 | |
| 904 | const uint8_t lens_shading_map_mode = |
| 905 | ANDROID_STATISTICS_LENS_SHADING_MAP_MODE_OFF; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 906 | resultMetadata->addEntry(ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, |
| 907 | &lens_shading_map_mode, 1); |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 908 | |
| 909 | const uint8_t scene_flicker = ANDROID_STATISTICS_SCENE_FLICKER_NONE; |
Laurent Pinchart | 3986009 | 2019-09-05 03:12:34 +0300 | [diff] [blame] | 910 | resultMetadata->addEntry(ANDROID_STATISTICS_SCENE_FLICKER, |
| 911 | &scene_flicker, 1); |
| 912 | |
| 913 | /* |
| 914 | * Return the result metadata pack even is not valid: get() will return |
| 915 | * nullptr. |
| 916 | */ |
| 917 | if (!resultMetadata->isValid()) { |
| 918 | LOG(HAL, Error) << "Failed to construct result metadata"; |
| 919 | } |
Jacopo Mondi | 667d8ea | 2019-05-10 17:40:02 +0200 | [diff] [blame] | 920 | |
| 921 | return resultMetadata; |
| 922 | } |