Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 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 | |
| 17 | #define LOG_TAG "[email protected]" |
| 18 | #include <android/log.h> |
| 19 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 20 | #include <set> |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 21 | #include <cutils/properties.h> |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 22 | #include <utils/Trace.h> |
| 23 | #include <hardware/gralloc.h> |
| 24 | #include <hardware/gralloc1.h> |
| 25 | #include "CameraDeviceSession.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace camera { |
| 30 | namespace device { |
| 31 | namespace V3_2 { |
| 32 | namespace implementation { |
| 33 | |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 34 | // Size of request metadata fast message queue. Change to 0 to always use hwbinder buffer. |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 35 | static constexpr int32_t CAMERA_REQUEST_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */; |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 36 | // Size of result metadata fast message queue. Change to 0 to always use hwbinder buffer. |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 37 | static constexpr int32_t CAMERA_RESULT_METADATA_QUEUE_SIZE = 1 << 20 /* 1MB */; |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 38 | |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 39 | // Metadata sent by HAL will be replaced by a compact copy |
| 40 | // if their (total size >= compact size + METADATA_SHRINK_ABS_THRESHOLD && |
| 41 | // total_size >= compact size * METADATA_SHRINK_REL_THRESHOLD) |
| 42 | // Heuristically picked by size of one page |
| 43 | static constexpr int METADATA_SHRINK_ABS_THRESHOLD = 4096; |
| 44 | static constexpr int METADATA_SHRINK_REL_THRESHOLD = 2; |
| 45 | |
Yin-Chia Yeh | 519c167 | 2017-04-21 14:59:31 -0700 | [diff] [blame] | 46 | HandleImporter CameraDeviceSession::sHandleImporter; |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 47 | buffer_handle_t CameraDeviceSession::sEmptyBuffer = nullptr; |
| 48 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 49 | const int CameraDeviceSession::ResultBatcher::NOT_BATCHED; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 50 | |
| 51 | CameraDeviceSession::CameraDeviceSession( |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 52 | camera3_device_t* device, |
| 53 | const camera_metadata_t* deviceInfo, |
| 54 | const sp<ICameraDeviceCallback>& callback) : |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 55 | camera3_callback_ops({&sProcessCaptureResult, &sNotify, nullptr, nullptr}), |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 56 | mDevice(device), |
Emilian Peev | 7d52a6f | 2017-04-07 09:53:48 +0100 | [diff] [blame] | 57 | mDeviceVersion(device->common.version), |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 58 | mFreeBufEarly(shouldFreeBufEarly()), |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 59 | mIsAELockAvailable(false), |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 60 | mDerivePostRawSensKey(false), |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 61 | mNumPartialResults(1), |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 62 | mResultBatcher(callback) { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 63 | mDeviceInfo = deviceInfo; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 64 | camera_metadata_entry partialResultsCount = |
| 65 | mDeviceInfo.find(ANDROID_REQUEST_PARTIAL_RESULT_COUNT); |
| 66 | if (partialResultsCount.count > 0) { |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 67 | mNumPartialResults = partialResultsCount.data.i32[0]; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 68 | } |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 69 | mResultBatcher.setNumPartialResults(mNumPartialResults); |
| 70 | |
| 71 | camera_metadata_entry aeLockAvailableEntry = mDeviceInfo.find( |
| 72 | ANDROID_CONTROL_AE_LOCK_AVAILABLE); |
| 73 | if (aeLockAvailableEntry.count > 0) { |
| 74 | mIsAELockAvailable = (aeLockAvailableEntry.data.u8[0] == |
| 75 | ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE); |
| 76 | } |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 77 | |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 78 | // Determine whether we need to derive sensitivity boost values for older devices. |
| 79 | // If post-RAW sensitivity boost range is listed, so should post-raw sensitivity control |
| 80 | // be listed (as the default value 100) |
| 81 | if (mDeviceInfo.exists(ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST_RANGE)) { |
| 82 | mDerivePostRawSensKey = true; |
| 83 | } |
| 84 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 85 | mInitFail = initialize(); |
| 86 | } |
| 87 | |
| 88 | bool CameraDeviceSession::initialize() { |
| 89 | /** Initialize device with callback functions */ |
| 90 | ATRACE_BEGIN("camera3->initialize"); |
| 91 | status_t res = mDevice->ops->initialize(mDevice, this); |
| 92 | ATRACE_END(); |
| 93 | |
| 94 | if (res != OK) { |
| 95 | ALOGE("%s: Unable to initialize HAL device: %s (%d)", |
| 96 | __FUNCTION__, strerror(-res), res); |
| 97 | mDevice->common.close(&mDevice->common); |
| 98 | mClosed = true; |
| 99 | return true; |
| 100 | } |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 101 | |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 102 | // "ro.camera" properties are no longer supported on vendor side. |
| 103 | // Support a fall back for the fmq size override that uses "ro.vendor.camera" |
| 104 | // properties. |
| 105 | int32_t reqFMQSize = property_get_int32("ro.vendor.camera.req.fmq.size", /*default*/-1); |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 106 | if (reqFMQSize < 0) { |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 107 | reqFMQSize = property_get_int32("ro.camera.req.fmq.size", /*default*/-1); |
| 108 | if (reqFMQSize < 0) { |
| 109 | reqFMQSize = CAMERA_REQUEST_METADATA_QUEUE_SIZE; |
| 110 | } else { |
| 111 | ALOGV("%s: request FMQ size overridden to %d", __FUNCTION__, reqFMQSize); |
| 112 | } |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 113 | } else { |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 114 | ALOGV("%s: request FMQ size overridden to %d via fallback property", __FUNCTION__, |
| 115 | reqFMQSize); |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 118 | mRequestMetadataQueue = std::make_unique<RequestMetadataQueue>( |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 119 | static_cast<size_t>(reqFMQSize), |
| 120 | false /* non blocking */); |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 121 | if (!mRequestMetadataQueue->isValid()) { |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 122 | ALOGE("%s: invalid request fmq", __FUNCTION__); |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 123 | return true; |
| 124 | } |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 125 | |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 126 | // "ro.camera" properties are no longer supported on vendor side. |
| 127 | // Support a fall back for the fmq size override that uses "ro.vendor.camera" |
| 128 | // properties. |
| 129 | int32_t resFMQSize = property_get_int32("ro.vendor.camera.res.fmq.size", /*default*/-1); |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 130 | if (resFMQSize < 0) { |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 131 | resFMQSize = property_get_int32("ro.camera.res.fmq.size", /*default*/-1); |
| 132 | if (resFMQSize < 0) { |
| 133 | resFMQSize = CAMERA_RESULT_METADATA_QUEUE_SIZE; |
| 134 | } else { |
| 135 | ALOGV("%s: result FMQ size overridden to %d", __FUNCTION__, resFMQSize); |
| 136 | } |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 137 | } else { |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 138 | ALOGV("%s: result FMQ size overridden to %d via fallback property", __FUNCTION__, |
| 139 | resFMQSize); |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 140 | } |
Emilian Peev | 5ec377b | 2019-05-01 10:51:23 -0700 | [diff] [blame] | 141 | |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 142 | mResultMetadataQueue = std::make_shared<RequestMetadataQueue>( |
Yin-Chia Yeh | 9d32c13 | 2018-05-24 10:31:56 -0700 | [diff] [blame] | 143 | static_cast<size_t>(resFMQSize), |
| 144 | false /* non blocking */); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 145 | if (!mResultMetadataQueue->isValid()) { |
| 146 | ALOGE("%s: invalid result fmq", __FUNCTION__); |
| 147 | return true; |
| 148 | } |
| 149 | mResultBatcher.setResultMetadataQueue(mResultMetadataQueue); |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 150 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 151 | return false; |
| 152 | } |
| 153 | |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 154 | bool CameraDeviceSession::shouldFreeBufEarly() { |
| 155 | return property_get_bool("ro.vendor.camera.free_buf_early", 0) == 1; |
| 156 | } |
| 157 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 158 | CameraDeviceSession::~CameraDeviceSession() { |
| 159 | if (!isClosed()) { |
| 160 | ALOGE("CameraDeviceSession deleted before close!"); |
| 161 | close(); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | bool CameraDeviceSession::isClosed() { |
| 166 | Mutex::Autolock _l(mStateLock); |
| 167 | return mClosed; |
| 168 | } |
| 169 | |
| 170 | Status CameraDeviceSession::initStatus() const { |
| 171 | Mutex::Autolock _l(mStateLock); |
| 172 | Status status = Status::OK; |
| 173 | if (mInitFail) { |
| 174 | status = Status::INTERNAL_ERROR; |
| 175 | } else if (mDisconnected) { |
| 176 | status = Status::CAMERA_DISCONNECTED; |
| 177 | } else if (mClosed) { |
| 178 | status = Status::INTERNAL_ERROR; |
| 179 | } |
| 180 | return status; |
| 181 | } |
| 182 | |
| 183 | void CameraDeviceSession::disconnect() { |
| 184 | Mutex::Autolock _l(mStateLock); |
| 185 | mDisconnected = true; |
| 186 | ALOGW("%s: Camera device is disconnected. Closing.", __FUNCTION__); |
| 187 | if (!mClosed) { |
| 188 | mDevice->common.close(&mDevice->common); |
| 189 | mClosed = true; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | void CameraDeviceSession::dumpState(const native_handle_t* fd) { |
| 194 | if (!isClosed()) { |
| 195 | mDevice->ops->dump(mDevice, fd->data[0]); |
| 196 | } |
| 197 | } |
| 198 | |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 199 | /** |
| 200 | * For devices <= CAMERA_DEVICE_API_VERSION_3_2, AE_PRECAPTURE_TRIGGER_CANCEL is not supported so |
| 201 | * we need to override AE_PRECAPTURE_TRIGGER_CANCEL to AE_PRECAPTURE_TRIGGER_IDLE and AE_LOCK_OFF |
| 202 | * to AE_LOCK_ON to start cancelling AE precapture. If AE lock is not available, it still overrides |
| 203 | * AE_PRECAPTURE_TRIGGER_CANCEL to AE_PRECAPTURE_TRIGGER_IDLE but doesn't add AE_LOCK_ON to the |
| 204 | * request. |
| 205 | */ |
| 206 | bool CameraDeviceSession::handleAePrecaptureCancelRequestLocked( |
| 207 | const camera3_capture_request_t &halRequest, |
| 208 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata *settings /*out*/, |
| 209 | AETriggerCancelOverride *override /*out*/) { |
| 210 | if ((mDeviceVersion > CAMERA_DEVICE_API_VERSION_3_2) || |
| 211 | (nullptr == halRequest.settings) || (nullptr == settings) || |
| 212 | (0 == get_camera_metadata_entry_count(halRequest.settings))) { |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | settings->clear(); |
| 217 | settings->append(halRequest.settings); |
| 218 | camera_metadata_entry_t aePrecaptureTrigger = |
| 219 | settings->find(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER); |
| 220 | if (aePrecaptureTrigger.count > 0 && |
| 221 | aePrecaptureTrigger.data.u8[0] == |
| 222 | ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL) { |
| 223 | // Always override CANCEL to IDLE |
| 224 | uint8_t aePrecaptureTrigger = |
| 225 | ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE; |
| 226 | settings->update(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, |
| 227 | &aePrecaptureTrigger, 1); |
| 228 | *override = { false, ANDROID_CONTROL_AE_LOCK_OFF, |
| 229 | true, ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL }; |
| 230 | |
| 231 | if (mIsAELockAvailable == true) { |
| 232 | camera_metadata_entry_t aeLock = settings->find( |
| 233 | ANDROID_CONTROL_AE_LOCK); |
| 234 | if (aeLock.count == 0 || aeLock.data.u8[0] == |
| 235 | ANDROID_CONTROL_AE_LOCK_OFF) { |
| 236 | uint8_t aeLock = ANDROID_CONTROL_AE_LOCK_ON; |
| 237 | settings->update(ANDROID_CONTROL_AE_LOCK, &aeLock, 1); |
| 238 | override->applyAeLock = true; |
| 239 | override->aeLock = ANDROID_CONTROL_AE_LOCK_OFF; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | return false; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Override result metadata for cancelling AE precapture trigger applied in |
| 251 | * handleAePrecaptureCancelRequestLocked(). |
| 252 | */ |
| 253 | void CameraDeviceSession::overrideResultForPrecaptureCancelLocked( |
| 254 | const AETriggerCancelOverride &aeTriggerCancelOverride, |
| 255 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata *settings /*out*/) { |
| 256 | if (aeTriggerCancelOverride.applyAeLock) { |
| 257 | // Only devices <= v3.2 should have this override |
| 258 | assert(mDeviceVersion <= CAMERA_DEVICE_API_VERSION_3_2); |
| 259 | settings->update(ANDROID_CONTROL_AE_LOCK, &aeTriggerCancelOverride.aeLock, 1); |
| 260 | } |
| 261 | |
| 262 | if (aeTriggerCancelOverride.applyAePrecaptureTrigger) { |
| 263 | // Only devices <= v3.2 should have this override |
| 264 | assert(mDeviceVersion <= CAMERA_DEVICE_API_VERSION_3_2); |
| 265 | settings->update(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, |
| 266 | &aeTriggerCancelOverride.aePrecaptureTrigger, 1); |
| 267 | } |
| 268 | } |
| 269 | |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 270 | Status CameraDeviceSession::importBuffer(int32_t streamId, |
| 271 | uint64_t bufId, buffer_handle_t buf, |
| 272 | /*out*/buffer_handle_t** outBufPtr, |
| 273 | bool allowEmptyBuf) { |
| 274 | |
| 275 | if (buf == nullptr && bufId == BUFFER_ID_NO_BUFFER) { |
| 276 | if (allowEmptyBuf) { |
| 277 | *outBufPtr = &sEmptyBuffer; |
| 278 | return Status::OK; |
| 279 | } else { |
| 280 | ALOGE("%s: bufferId %" PRIu64 " has null buffer handle!", __FUNCTION__, bufId); |
| 281 | return Status::ILLEGAL_ARGUMENT; |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | Mutex::Autolock _l(mInflightLock); |
| 286 | CirculatingBuffers& cbs = mCirculatingBuffers[streamId]; |
| 287 | if (cbs.count(bufId) == 0) { |
| 288 | // Register a newly seen buffer |
| 289 | buffer_handle_t importedBuf = buf; |
| 290 | sHandleImporter.importBuffer(importedBuf); |
| 291 | if (importedBuf == nullptr) { |
| 292 | ALOGE("%s: output buffer for stream %d is invalid!", __FUNCTION__, streamId); |
| 293 | return Status::INTERNAL_ERROR; |
| 294 | } else { |
| 295 | cbs[bufId] = importedBuf; |
| 296 | } |
| 297 | } |
| 298 | *outBufPtr = &cbs[bufId]; |
| 299 | return Status::OK; |
| 300 | } |
| 301 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 302 | Status CameraDeviceSession::importRequest( |
| 303 | const CaptureRequest& request, |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 304 | hidl_vec<buffer_handle_t*>& allBufPtrs, |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 305 | hidl_vec<int>& allFences) { |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 306 | return importRequestImpl(request, allBufPtrs, allFences); |
| 307 | } |
| 308 | |
| 309 | Status CameraDeviceSession::importRequestImpl( |
| 310 | const CaptureRequest& request, |
| 311 | hidl_vec<buffer_handle_t*>& allBufPtrs, |
| 312 | hidl_vec<int>& allFences, |
| 313 | bool allowEmptyBuf) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 314 | bool hasInputBuf = (request.inputBuffer.streamId != -1 && |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 315 | request.inputBuffer.bufferId != 0); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 316 | size_t numOutputBufs = request.outputBuffers.size(); |
| 317 | size_t numBufs = numOutputBufs + (hasInputBuf ? 1 : 0); |
| 318 | // Validate all I/O buffers |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 319 | hidl_vec<buffer_handle_t> allBufs; |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 320 | hidl_vec<uint64_t> allBufIds; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 321 | allBufs.resize(numBufs); |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 322 | allBufIds.resize(numBufs); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 323 | allBufPtrs.resize(numBufs); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 324 | allFences.resize(numBufs); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 325 | std::vector<int32_t> streamIds(numBufs); |
| 326 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 327 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 328 | allBufs[i] = request.outputBuffers[i].buffer.getNativeHandle(); |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 329 | allBufIds[i] = request.outputBuffers[i].bufferId; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 330 | allBufPtrs[i] = &allBufs[i]; |
| 331 | streamIds[i] = request.outputBuffers[i].streamId; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 332 | } |
| 333 | if (hasInputBuf) { |
| 334 | allBufs[numOutputBufs] = request.inputBuffer.buffer.getNativeHandle(); |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 335 | allBufIds[numOutputBufs] = request.inputBuffer.bufferId; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 336 | allBufPtrs[numOutputBufs] = &allBufs[numOutputBufs]; |
| 337 | streamIds[numOutputBufs] = request.inputBuffer.streamId; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 338 | } |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 339 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 340 | for (size_t i = 0; i < numBufs; i++) { |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 341 | Status st = importBuffer( |
| 342 | streamIds[i], allBufIds[i], allBufs[i], &allBufPtrs[i], |
| 343 | // Disallow empty buf for input stream, otherwise follow |
| 344 | // the allowEmptyBuf argument. |
| 345 | (hasInputBuf && i == numOutputBufs) ? false : allowEmptyBuf); |
| 346 | if (st != Status::OK) { |
| 347 | // Detailed error logs printed in importBuffer |
| 348 | return st; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | |
| 352 | // All buffers are imported. Now validate output buffer acquire fences |
| 353 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 354 | if (!sHandleImporter.importFence( |
| 355 | request.outputBuffers[i].acquireFence, allFences[i])) { |
| 356 | ALOGE("%s: output buffer %zu acquire fence is invalid", __FUNCTION__, i); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 357 | cleanupInflightFences(allFences, i); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 358 | return Status::INTERNAL_ERROR; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | // Validate input buffer acquire fences |
| 363 | if (hasInputBuf) { |
| 364 | if (!sHandleImporter.importFence( |
| 365 | request.inputBuffer.acquireFence, allFences[numOutputBufs])) { |
| 366 | ALOGE("%s: input buffer acquire fence is invalid", __FUNCTION__); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 367 | cleanupInflightFences(allFences, numOutputBufs); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 368 | return Status::INTERNAL_ERROR; |
| 369 | } |
| 370 | } |
| 371 | return Status::OK; |
| 372 | } |
| 373 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 374 | void CameraDeviceSession::cleanupInflightFences( |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 375 | hidl_vec<int>& allFences, size_t numFences) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 376 | for (size_t j = 0; j < numFences; j++) { |
| 377 | sHandleImporter.closeFence(allFences[j]); |
| 378 | } |
| 379 | } |
| 380 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 381 | CameraDeviceSession::ResultBatcher::ResultBatcher( |
| 382 | const sp<ICameraDeviceCallback>& callback) : mCallback(callback) {}; |
| 383 | |
| 384 | bool CameraDeviceSession::ResultBatcher::InflightBatch::allDelivered() const { |
| 385 | if (!mShutterDelivered) return false; |
| 386 | |
| 387 | if (mPartialResultProgress < mNumPartialResults) { |
| 388 | return false; |
| 389 | } |
| 390 | |
| 391 | for (const auto& pair : mBatchBufs) { |
| 392 | if (!pair.second.mDelivered) { |
| 393 | return false; |
| 394 | } |
| 395 | } |
| 396 | return true; |
| 397 | } |
| 398 | |
| 399 | void CameraDeviceSession::ResultBatcher::setNumPartialResults(uint32_t n) { |
| 400 | Mutex::Autolock _l(mLock); |
| 401 | mNumPartialResults = n; |
| 402 | } |
| 403 | |
| 404 | void CameraDeviceSession::ResultBatcher::setBatchedStreams( |
| 405 | const std::vector<int>& streamsToBatch) { |
| 406 | Mutex::Autolock _l(mLock); |
| 407 | mStreamsToBatch = streamsToBatch; |
| 408 | } |
| 409 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 410 | void CameraDeviceSession::ResultBatcher::setResultMetadataQueue( |
| 411 | std::shared_ptr<ResultMetadataQueue> q) { |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 412 | Mutex::Autolock _l(mLock); |
| 413 | mResultMetadataQueue = q; |
| 414 | } |
| 415 | |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 416 | void CameraDeviceSession::ResultBatcher::registerBatch(uint32_t frameNumber, uint32_t batchSize) { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 417 | auto batch = std::make_shared<InflightBatch>(); |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 418 | batch->mFirstFrame = frameNumber; |
| 419 | batch->mBatchSize = batchSize; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 420 | batch->mLastFrame = batch->mFirstFrame + batch->mBatchSize - 1; |
| 421 | batch->mNumPartialResults = mNumPartialResults; |
| 422 | for (int id : mStreamsToBatch) { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 423 | batch->mBatchBufs.emplace(id, batch->mBatchSize); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 424 | } |
| 425 | Mutex::Autolock _l(mLock); |
| 426 | mInflightBatches.push_back(batch); |
| 427 | } |
| 428 | |
| 429 | std::pair<int, std::shared_ptr<CameraDeviceSession::ResultBatcher::InflightBatch>> |
| 430 | CameraDeviceSession::ResultBatcher::getBatch( |
| 431 | uint32_t frameNumber) { |
| 432 | Mutex::Autolock _l(mLock); |
| 433 | int numBatches = mInflightBatches.size(); |
| 434 | if (numBatches == 0) { |
| 435 | return std::make_pair(NOT_BATCHED, nullptr); |
| 436 | } |
| 437 | uint32_t frameMin = mInflightBatches[0]->mFirstFrame; |
| 438 | uint32_t frameMax = mInflightBatches[numBatches - 1]->mLastFrame; |
| 439 | if (frameNumber < frameMin || frameNumber > frameMax) { |
| 440 | return std::make_pair(NOT_BATCHED, nullptr); |
| 441 | } |
| 442 | for (int i = 0; i < numBatches; i++) { |
| 443 | if (frameNumber >= mInflightBatches[i]->mFirstFrame && |
| 444 | frameNumber <= mInflightBatches[i]->mLastFrame) { |
| 445 | return std::make_pair(i, mInflightBatches[i]); |
| 446 | } |
| 447 | } |
| 448 | return std::make_pair(NOT_BATCHED, nullptr); |
| 449 | } |
| 450 | |
| 451 | void CameraDeviceSession::ResultBatcher::checkAndRemoveFirstBatch() { |
| 452 | Mutex::Autolock _l(mLock); |
| 453 | if (mInflightBatches.size() > 0) { |
| 454 | std::shared_ptr<InflightBatch> batch = mInflightBatches[0]; |
| 455 | bool shouldRemove = false; |
| 456 | { |
| 457 | Mutex::Autolock _l(batch->mLock); |
| 458 | if (batch->allDelivered()) { |
| 459 | batch->mRemoved = true; |
| 460 | shouldRemove = true; |
| 461 | } |
| 462 | } |
| 463 | if (shouldRemove) { |
| 464 | mInflightBatches.pop_front(); |
| 465 | } |
| 466 | } |
| 467 | } |
| 468 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 469 | void CameraDeviceSession::ResultBatcher::sendBatchShutterCbsLocked( |
| 470 | std::shared_ptr<InflightBatch> batch) { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 471 | if (batch->mShutterDelivered) { |
| 472 | ALOGW("%s: batch shutter callback already sent!", __FUNCTION__); |
| 473 | return; |
| 474 | } |
| 475 | |
Yin-Chia Yeh | b014079 | 2018-04-27 09:32:39 -0700 | [diff] [blame] | 476 | auto ret = mCallback->notify(batch->mShutterMsgs); |
| 477 | if (!ret.isOk()) { |
| 478 | ALOGE("%s: notify shutter transaction failed: %s", |
| 479 | __FUNCTION__, ret.description().c_str()); |
| 480 | } |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 481 | batch->mShutterDelivered = true; |
| 482 | batch->mShutterMsgs.clear(); |
| 483 | } |
| 484 | |
| 485 | void CameraDeviceSession::ResultBatcher::freeReleaseFences(hidl_vec<CaptureResult>& results) { |
| 486 | for (auto& result : results) { |
| 487 | if (result.inputBuffer.releaseFence.getNativeHandle() != nullptr) { |
| 488 | native_handle_t* handle = const_cast<native_handle_t*>( |
| 489 | result.inputBuffer.releaseFence.getNativeHandle()); |
Eino-Ville Talvala | 4ebf53f | 2017-05-24 15:05:56 -0700 | [diff] [blame] | 490 | native_handle_close(handle); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 491 | native_handle_delete(handle); |
| 492 | } |
| 493 | for (auto& buf : result.outputBuffers) { |
| 494 | if (buf.releaseFence.getNativeHandle() != nullptr) { |
| 495 | native_handle_t* handle = const_cast<native_handle_t*>( |
| 496 | buf.releaseFence.getNativeHandle()); |
Eino-Ville Talvala | 4ebf53f | 2017-05-24 15:05:56 -0700 | [diff] [blame] | 497 | native_handle_close(handle); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 498 | native_handle_delete(handle); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | return; |
| 503 | } |
| 504 | |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 505 | void CameraDeviceSession::ResultBatcher::moveStreamBuffer(StreamBuffer&& src, StreamBuffer& dst) { |
| 506 | // Only dealing with releaseFence here. Assume buffer/acquireFence are null |
| 507 | const native_handle_t* handle = src.releaseFence.getNativeHandle(); |
| 508 | src.releaseFence = nullptr; |
| 509 | dst = src; |
| 510 | dst.releaseFence = handle; |
| 511 | if (handle != dst.releaseFence.getNativeHandle()) { |
| 512 | ALOGE("%s: native handle cloned!", __FUNCTION__); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | void CameraDeviceSession::ResultBatcher::pushStreamBuffer( |
| 517 | StreamBuffer&& src, std::vector<StreamBuffer>& dst) { |
| 518 | // Only dealing with releaseFence here. Assume buffer/acquireFence are null |
| 519 | const native_handle_t* handle = src.releaseFence.getNativeHandle(); |
| 520 | src.releaseFence = nullptr; |
| 521 | dst.push_back(src); |
| 522 | dst.back().releaseFence = handle; |
| 523 | if (handle != dst.back().releaseFence.getNativeHandle()) { |
| 524 | ALOGE("%s: native handle cloned!", __FUNCTION__); |
| 525 | } |
| 526 | } |
| 527 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 528 | void CameraDeviceSession::ResultBatcher::sendBatchBuffersLocked( |
| 529 | std::shared_ptr<InflightBatch> batch) { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 530 | sendBatchBuffersLocked(batch, mStreamsToBatch); |
| 531 | } |
| 532 | |
| 533 | void CameraDeviceSession::ResultBatcher::sendBatchBuffersLocked( |
| 534 | std::shared_ptr<InflightBatch> batch, const std::vector<int>& streams) { |
| 535 | size_t batchSize = 0; |
| 536 | for (int streamId : streams) { |
| 537 | auto it = batch->mBatchBufs.find(streamId); |
| 538 | if (it != batch->mBatchBufs.end()) { |
| 539 | InflightBatch::BufferBatch& bb = it->second; |
| 540 | if (bb.mDelivered) { |
| 541 | continue; |
| 542 | } |
| 543 | if (bb.mBuffers.size() > batchSize) { |
| 544 | batchSize = bb.mBuffers.size(); |
| 545 | } |
| 546 | } else { |
| 547 | ALOGE("%s: stream ID %d is not batched!", __FUNCTION__, streamId); |
| 548 | return; |
| 549 | } |
| 550 | } |
| 551 | |
| 552 | if (batchSize == 0) { |
| 553 | ALOGW("%s: there is no buffer to be delivered for this batch.", __FUNCTION__); |
| 554 | for (int streamId : streams) { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 555 | auto it = batch->mBatchBufs.find(streamId); |
| 556 | if (it == batch->mBatchBufs.end()) { |
| 557 | ALOGE("%s: cannot find stream %d in batched buffers!", __FUNCTION__, streamId); |
| 558 | return; |
| 559 | } |
| 560 | InflightBatch::BufferBatch& bb = it->second; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 561 | bb.mDelivered = true; |
| 562 | } |
| 563 | return; |
| 564 | } |
| 565 | |
| 566 | hidl_vec<CaptureResult> results; |
| 567 | results.resize(batchSize); |
| 568 | for (size_t i = 0; i < batchSize; i++) { |
| 569 | results[i].frameNumber = batch->mFirstFrame + i; |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 570 | results[i].fmqResultSize = 0; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 571 | results[i].partialResult = 0; // 0 for buffer only results |
| 572 | results[i].inputBuffer.streamId = -1; |
| 573 | results[i].inputBuffer.bufferId = 0; |
| 574 | results[i].inputBuffer.buffer = nullptr; |
| 575 | std::vector<StreamBuffer> outBufs; |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 576 | outBufs.reserve(streams.size()); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 577 | for (int streamId : streams) { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 578 | auto it = batch->mBatchBufs.find(streamId); |
| 579 | if (it == batch->mBatchBufs.end()) { |
| 580 | ALOGE("%s: cannot find stream %d in batched buffers!", __FUNCTION__, streamId); |
| 581 | return; |
| 582 | } |
| 583 | InflightBatch::BufferBatch& bb = it->second; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 584 | if (bb.mDelivered) { |
| 585 | continue; |
| 586 | } |
| 587 | if (i < bb.mBuffers.size()) { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 588 | pushStreamBuffer(std::move(bb.mBuffers[i]), outBufs); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 589 | } |
| 590 | } |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 591 | results[i].outputBuffers.resize(outBufs.size()); |
| 592 | for (size_t j = 0; j < outBufs.size(); j++) { |
| 593 | moveStreamBuffer(std::move(outBufs[j]), results[i].outputBuffers[j]); |
| 594 | } |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 595 | } |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 596 | invokeProcessCaptureResultCallback(results, /* tryWriteFmq */false); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 597 | freeReleaseFences(results); |
| 598 | for (int streamId : streams) { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 599 | auto it = batch->mBatchBufs.find(streamId); |
| 600 | if (it == batch->mBatchBufs.end()) { |
| 601 | ALOGE("%s: cannot find stream %d in batched buffers!", __FUNCTION__, streamId); |
| 602 | return; |
| 603 | } |
| 604 | InflightBatch::BufferBatch& bb = it->second; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 605 | bb.mDelivered = true; |
| 606 | bb.mBuffers.clear(); |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | void CameraDeviceSession::ResultBatcher::sendBatchMetadataLocked( |
| 611 | std::shared_ptr<InflightBatch> batch, uint32_t lastPartialResultIdx) { |
| 612 | if (lastPartialResultIdx <= batch->mPartialResultProgress) { |
| 613 | // Result has been delivered. Return |
| 614 | ALOGW("%s: partial result %u has been delivered", __FUNCTION__, lastPartialResultIdx); |
| 615 | return; |
| 616 | } |
| 617 | |
| 618 | std::vector<CaptureResult> results; |
| 619 | std::vector<uint32_t> toBeRemovedIdxes; |
| 620 | for (auto& pair : batch->mResultMds) { |
| 621 | uint32_t partialIdx = pair.first; |
| 622 | if (partialIdx > lastPartialResultIdx) { |
| 623 | continue; |
| 624 | } |
| 625 | toBeRemovedIdxes.push_back(partialIdx); |
| 626 | InflightBatch::MetadataBatch& mb = pair.second; |
| 627 | for (const auto& p : mb.mMds) { |
| 628 | CaptureResult result; |
| 629 | result.frameNumber = p.first; |
| 630 | result.result = std::move(p.second); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 631 | result.fmqResultSize = 0; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 632 | result.inputBuffer.streamId = -1; |
| 633 | result.inputBuffer.bufferId = 0; |
| 634 | result.inputBuffer.buffer = nullptr; |
| 635 | result.partialResult = partialIdx; |
| 636 | results.push_back(std::move(result)); |
| 637 | } |
| 638 | mb.mMds.clear(); |
| 639 | } |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 640 | hidl_vec<CaptureResult> hResults; |
| 641 | hResults.setToExternal(results.data(), results.size()); |
| 642 | invokeProcessCaptureResultCallback(hResults, /* tryWriteFmq */true); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 643 | batch->mPartialResultProgress = lastPartialResultIdx; |
| 644 | for (uint32_t partialIdx : toBeRemovedIdxes) { |
| 645 | batch->mResultMds.erase(partialIdx); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | void CameraDeviceSession::ResultBatcher::notifySingleMsg(NotifyMsg& msg) { |
Yin-Chia Yeh | b014079 | 2018-04-27 09:32:39 -0700 | [diff] [blame] | 650 | auto ret = mCallback->notify({msg}); |
| 651 | if (!ret.isOk()) { |
| 652 | ALOGE("%s: notify transaction failed: %s", |
| 653 | __FUNCTION__, ret.description().c_str()); |
| 654 | } |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 655 | return; |
| 656 | } |
| 657 | |
| 658 | void CameraDeviceSession::ResultBatcher::notify(NotifyMsg& msg) { |
| 659 | uint32_t frameNumber; |
| 660 | if (CC_LIKELY(msg.type == MsgType::SHUTTER)) { |
| 661 | frameNumber = msg.msg.shutter.frameNumber; |
| 662 | } else { |
| 663 | frameNumber = msg.msg.error.frameNumber; |
| 664 | } |
| 665 | |
| 666 | auto pair = getBatch(frameNumber); |
| 667 | int batchIdx = pair.first; |
| 668 | if (batchIdx == NOT_BATCHED) { |
| 669 | notifySingleMsg(msg); |
| 670 | return; |
| 671 | } |
| 672 | |
| 673 | // When error happened, stop batching for all batches earlier |
| 674 | if (CC_UNLIKELY(msg.type == MsgType::ERROR)) { |
| 675 | Mutex::Autolock _l(mLock); |
| 676 | for (int i = 0; i <= batchIdx; i++) { |
| 677 | // Send batched data up |
| 678 | std::shared_ptr<InflightBatch> batch = mInflightBatches[0]; |
| 679 | { |
| 680 | Mutex::Autolock _l(batch->mLock); |
| 681 | sendBatchShutterCbsLocked(batch); |
| 682 | sendBatchBuffersLocked(batch); |
| 683 | sendBatchMetadataLocked(batch, mNumPartialResults); |
| 684 | if (!batch->allDelivered()) { |
| 685 | ALOGE("%s: error: some batch data not sent back to framework!", |
| 686 | __FUNCTION__); |
| 687 | } |
| 688 | batch->mRemoved = true; |
| 689 | } |
| 690 | mInflightBatches.pop_front(); |
| 691 | } |
| 692 | // Send the error up |
| 693 | notifySingleMsg(msg); |
| 694 | return; |
| 695 | } |
| 696 | // Queue shutter callbacks for future delivery |
| 697 | std::shared_ptr<InflightBatch> batch = pair.second; |
| 698 | { |
| 699 | Mutex::Autolock _l(batch->mLock); |
| 700 | // Check if the batch is removed (mostly by notify error) before lock was acquired |
| 701 | if (batch->mRemoved) { |
| 702 | // Fall back to non-batch path |
| 703 | notifySingleMsg(msg); |
| 704 | return; |
| 705 | } |
| 706 | |
| 707 | batch->mShutterMsgs.push_back(msg); |
| 708 | if (frameNumber == batch->mLastFrame) { |
| 709 | sendBatchShutterCbsLocked(batch); |
| 710 | } |
| 711 | } // end of batch lock scope |
| 712 | |
| 713 | // see if the batch is complete |
| 714 | if (frameNumber == batch->mLastFrame) { |
| 715 | checkAndRemoveFirstBatch(); |
| 716 | } |
| 717 | } |
| 718 | |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 719 | void CameraDeviceSession::ResultBatcher::invokeProcessCaptureResultCallback( |
| 720 | hidl_vec<CaptureResult> &results, bool tryWriteFmq) { |
| 721 | if (mProcessCaptureResultLock.tryLock() != OK) { |
Shuzhen Wang | 2078677 | 2017-05-25 10:34:13 -0700 | [diff] [blame] | 722 | ALOGV("%s: previous call is not finished! waiting 1s...", __FUNCTION__); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 723 | if (mProcessCaptureResultLock.timedLock(1000000000 /* 1s */) != OK) { |
| 724 | ALOGE("%s: cannot acquire lock in 1s, cannot proceed", |
| 725 | __FUNCTION__); |
| 726 | return; |
| 727 | } |
| 728 | } |
| 729 | if (tryWriteFmq && mResultMetadataQueue->availableToWrite() > 0) { |
| 730 | for (CaptureResult &result : results) { |
| 731 | if (result.result.size() > 0) { |
| 732 | if (mResultMetadataQueue->write(result.result.data(), result.result.size())) { |
| 733 | result.fmqResultSize = result.result.size(); |
| 734 | result.result.resize(0); |
| 735 | } else { |
Zhijun He | 9b61e61 | 2018-04-06 18:44:42 -0700 | [diff] [blame] | 736 | ALOGW("%s: couldn't utilize fmq, fall back to hwbinder, result size: %zu," |
| 737 | "shared message queue available size: %zu", |
| 738 | __FUNCTION__, result.result.size(), |
| 739 | mResultMetadataQueue->availableToWrite()); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 740 | result.fmqResultSize = 0; |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | } |
Yin-Chia Yeh | b014079 | 2018-04-27 09:32:39 -0700 | [diff] [blame] | 745 | auto ret = mCallback->processCaptureResult(results); |
| 746 | if (!ret.isOk()) { |
| 747 | ALOGE("%s: processCaptureResult transaction failed: %s", |
| 748 | __FUNCTION__, ret.description().c_str()); |
| 749 | } |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 750 | mProcessCaptureResultLock.unlock(); |
| 751 | } |
| 752 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 753 | void CameraDeviceSession::ResultBatcher::processOneCaptureResult(CaptureResult& result) { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 754 | hidl_vec<CaptureResult> results; |
| 755 | results.resize(1); |
| 756 | results[0] = std::move(result); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 757 | invokeProcessCaptureResultCallback(results, /* tryWriteFmq */true); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 758 | freeReleaseFences(results); |
| 759 | return; |
| 760 | } |
| 761 | |
| 762 | void CameraDeviceSession::ResultBatcher::processCaptureResult(CaptureResult& result) { |
| 763 | auto pair = getBatch(result.frameNumber); |
| 764 | int batchIdx = pair.first; |
| 765 | if (batchIdx == NOT_BATCHED) { |
| 766 | processOneCaptureResult(result); |
| 767 | return; |
| 768 | } |
| 769 | std::shared_ptr<InflightBatch> batch = pair.second; |
| 770 | { |
| 771 | Mutex::Autolock _l(batch->mLock); |
| 772 | // Check if the batch is removed (mostly by notify error) before lock was acquired |
| 773 | if (batch->mRemoved) { |
| 774 | // Fall back to non-batch path |
| 775 | processOneCaptureResult(result); |
| 776 | return; |
| 777 | } |
| 778 | |
| 779 | // queue metadata |
| 780 | if (result.result.size() != 0) { |
| 781 | // Save a copy of metadata |
| 782 | batch->mResultMds[result.partialResult].mMds.push_back( |
| 783 | std::make_pair(result.frameNumber, result.result)); |
| 784 | } |
| 785 | |
| 786 | // queue buffer |
| 787 | std::vector<int> filledStreams; |
| 788 | std::vector<StreamBuffer> nonBatchedBuffers; |
| 789 | for (auto& buffer : result.outputBuffers) { |
| 790 | auto it = batch->mBatchBufs.find(buffer.streamId); |
| 791 | if (it != batch->mBatchBufs.end()) { |
| 792 | InflightBatch::BufferBatch& bb = it->second; |
Chih-Hung Hsieh | ba3a1cb | 2020-03-05 15:30:00 -0800 | [diff] [blame] | 793 | auto id = buffer.streamId; |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 794 | pushStreamBuffer(std::move(buffer), bb.mBuffers); |
Chih-Hung Hsieh | ba3a1cb | 2020-03-05 15:30:00 -0800 | [diff] [blame] | 795 | filledStreams.push_back(id); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 796 | } else { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 797 | pushStreamBuffer(std::move(buffer), nonBatchedBuffers); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 798 | } |
| 799 | } |
| 800 | |
| 801 | // send non-batched buffers up |
| 802 | if (nonBatchedBuffers.size() > 0 || result.inputBuffer.streamId != -1) { |
| 803 | CaptureResult nonBatchedResult; |
| 804 | nonBatchedResult.frameNumber = result.frameNumber; |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 805 | nonBatchedResult.fmqResultSize = 0; |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 806 | nonBatchedResult.outputBuffers.resize(nonBatchedBuffers.size()); |
| 807 | for (size_t i = 0; i < nonBatchedBuffers.size(); i++) { |
| 808 | moveStreamBuffer( |
| 809 | std::move(nonBatchedBuffers[i]), nonBatchedResult.outputBuffers[i]); |
| 810 | } |
| 811 | moveStreamBuffer(std::move(result.inputBuffer), nonBatchedResult.inputBuffer); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 812 | nonBatchedResult.partialResult = 0; // 0 for buffer only results |
| 813 | processOneCaptureResult(nonBatchedResult); |
| 814 | } |
| 815 | |
| 816 | if (result.frameNumber == batch->mLastFrame) { |
| 817 | // Send data up |
| 818 | if (result.partialResult > 0) { |
| 819 | sendBatchMetadataLocked(batch, result.partialResult); |
| 820 | } |
| 821 | // send buffer up |
| 822 | if (filledStreams.size() > 0) { |
| 823 | sendBatchBuffersLocked(batch, filledStreams); |
| 824 | } |
| 825 | } |
| 826 | } // end of batch lock scope |
| 827 | |
| 828 | // see if the batch is complete |
| 829 | if (result.frameNumber == batch->mLastFrame) { |
| 830 | checkAndRemoveFirstBatch(); |
| 831 | } |
| 832 | } |
| 833 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 834 | // Methods from ::android::hardware::camera::device::V3_2::ICameraDeviceSession follow. |
| 835 | Return<void> CameraDeviceSession::constructDefaultRequestSettings( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 836 | RequestTemplate type, ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 837 | CameraMetadata outMetadata; |
Eino-Ville Talvala | 658d30d | 2018-01-18 12:55:07 -0800 | [diff] [blame] | 838 | Status status = constructDefaultRequestSettingsRaw( (int) type, &outMetadata); |
| 839 | _hidl_cb(status, outMetadata); |
| 840 | return Void(); |
| 841 | } |
| 842 | |
| 843 | Status CameraDeviceSession::constructDefaultRequestSettingsRaw(int type, CameraMetadata *outMetadata) { |
| 844 | Status status = initStatus(); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 845 | const camera_metadata_t *rawRequest; |
| 846 | if (status == Status::OK) { |
| 847 | ATRACE_BEGIN("camera3->construct_default_request_settings"); |
| 848 | rawRequest = mDevice->ops->construct_default_request_settings(mDevice, (int) type); |
| 849 | ATRACE_END(); |
| 850 | if (rawRequest == nullptr) { |
| 851 | ALOGI("%s: template %d is not supported on this camera device", |
| 852 | __FUNCTION__, type); |
| 853 | status = Status::ILLEGAL_ARGUMENT; |
| 854 | } else { |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 855 | mOverridenRequest.clear(); |
| 856 | mOverridenRequest.append(rawRequest); |
| 857 | // Derive some new keys for backward compatibility |
| 858 | if (mDerivePostRawSensKey && !mOverridenRequest.exists( |
| 859 | ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST)) { |
| 860 | int32_t defaultBoost[1] = {100}; |
| 861 | mOverridenRequest.update( |
| 862 | ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST, |
| 863 | defaultBoost, 1); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 864 | } |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 865 | const camera_metadata_t *metaBuffer = |
| 866 | mOverridenRequest.getAndLock(); |
| 867 | convertToHidl(metaBuffer, outMetadata); |
| 868 | mOverridenRequest.unlock(metaBuffer); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 869 | } |
| 870 | } |
Eino-Ville Talvala | 658d30d | 2018-01-18 12:55:07 -0800 | [diff] [blame] | 871 | return status; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 872 | } |
| 873 | |
Emilian Peev | 7d52a6f | 2017-04-07 09:53:48 +0100 | [diff] [blame] | 874 | /** |
| 875 | * Map Android N dataspace definitions back to Android M definitions, for |
| 876 | * use with HALv3.3 or older. |
| 877 | * |
| 878 | * Only map where correspondences exist, and otherwise preserve the value. |
| 879 | */ |
| 880 | android_dataspace CameraDeviceSession::mapToLegacyDataspace( |
| 881 | android_dataspace dataSpace) const { |
| 882 | if (mDeviceVersion <= CAMERA_DEVICE_API_VERSION_3_3) { |
| 883 | switch (dataSpace) { |
| 884 | case HAL_DATASPACE_V0_SRGB_LINEAR: |
| 885 | return HAL_DATASPACE_SRGB_LINEAR; |
| 886 | case HAL_DATASPACE_V0_SRGB: |
| 887 | return HAL_DATASPACE_SRGB; |
| 888 | case HAL_DATASPACE_V0_JFIF: |
| 889 | return HAL_DATASPACE_JFIF; |
| 890 | case HAL_DATASPACE_V0_BT601_625: |
| 891 | return HAL_DATASPACE_BT601_625; |
| 892 | case HAL_DATASPACE_V0_BT601_525: |
| 893 | return HAL_DATASPACE_BT601_525; |
| 894 | case HAL_DATASPACE_V0_BT709: |
| 895 | return HAL_DATASPACE_BT709; |
| 896 | default: |
| 897 | return dataSpace; |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | return dataSpace; |
| 902 | } |
| 903 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 904 | bool CameraDeviceSession::preProcessConfigurationLocked( |
| 905 | const StreamConfiguration& requestedConfiguration, |
| 906 | camera3_stream_configuration_t *stream_list /*out*/, |
| 907 | hidl_vec<camera3_stream_t*> *streams /*out*/) { |
| 908 | |
| 909 | if ((stream_list == nullptr) || (streams == nullptr)) { |
| 910 | return false; |
| 911 | } |
| 912 | |
| 913 | stream_list->operation_mode = (uint32_t) requestedConfiguration.operationMode; |
| 914 | stream_list->num_streams = requestedConfiguration.streams.size(); |
| 915 | streams->resize(stream_list->num_streams); |
| 916 | stream_list->streams = streams->data(); |
| 917 | |
| 918 | for (uint32_t i = 0; i < stream_list->num_streams; i++) { |
| 919 | int id = requestedConfiguration.streams[i].id; |
| 920 | |
| 921 | if (mStreamMap.count(id) == 0) { |
| 922 | Camera3Stream stream; |
| 923 | convertFromHidl(requestedConfiguration.streams[i], &stream); |
| 924 | mStreamMap[id] = stream; |
| 925 | mStreamMap[id].data_space = mapToLegacyDataspace( |
| 926 | mStreamMap[id].data_space); |
| 927 | mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{}); |
| 928 | } else { |
| 929 | // width/height/format must not change, but usage/rotation might need to change |
| 930 | if (mStreamMap[id].stream_type != |
| 931 | (int) requestedConfiguration.streams[i].streamType || |
| 932 | mStreamMap[id].width != requestedConfiguration.streams[i].width || |
| 933 | mStreamMap[id].height != requestedConfiguration.streams[i].height || |
| 934 | mStreamMap[id].format != (int) requestedConfiguration.streams[i].format || |
| 935 | mStreamMap[id].data_space != |
| 936 | mapToLegacyDataspace( static_cast<android_dataspace_t> ( |
| 937 | requestedConfiguration.streams[i].dataSpace))) { |
| 938 | ALOGE("%s: stream %d configuration changed!", __FUNCTION__, id); |
| 939 | return false; |
| 940 | } |
| 941 | mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].rotation; |
| 942 | mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].usage; |
| 943 | } |
| 944 | (*streams)[i] = &mStreamMap[id]; |
| 945 | } |
| 946 | |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 947 | if (mFreeBufEarly) { |
| 948 | // Remove buffers of deleted streams |
| 949 | for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { |
| 950 | int id = it->first; |
| 951 | bool found = false; |
| 952 | for (const auto& stream : requestedConfiguration.streams) { |
| 953 | if (id == stream.id) { |
| 954 | found = true; |
| 955 | break; |
| 956 | } |
| 957 | } |
| 958 | if (!found) { |
| 959 | // Unmap all buffers of deleted stream |
| 960 | cleanupBuffersLocked(id); |
| 961 | } |
| 962 | } |
| 963 | } |
| 964 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 965 | return true; |
| 966 | } |
| 967 | |
| 968 | void CameraDeviceSession::postProcessConfigurationLocked( |
| 969 | const StreamConfiguration& requestedConfiguration) { |
| 970 | // delete unused streams, note we do this after adding new streams to ensure new stream |
| 971 | // will not have the same address as deleted stream, and HAL has a chance to reference |
| 972 | // the to be deleted stream in configure_streams call |
| 973 | for(auto it = mStreamMap.begin(); it != mStreamMap.end();) { |
| 974 | int id = it->first; |
| 975 | bool found = false; |
| 976 | for (const auto& stream : requestedConfiguration.streams) { |
| 977 | if (id == stream.id) { |
| 978 | found = true; |
| 979 | break; |
| 980 | } |
| 981 | } |
| 982 | if (!found) { |
| 983 | // Unmap all buffers of deleted stream |
| 984 | // in case the configuration call succeeds and HAL |
| 985 | // is able to release the corresponding resources too. |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 986 | if (!mFreeBufEarly) { |
| 987 | cleanupBuffersLocked(id); |
| 988 | } |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 989 | it = mStreamMap.erase(it); |
| 990 | } else { |
| 991 | ++it; |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | // Track video streams |
| 996 | mVideoStreamIds.clear(); |
| 997 | for (const auto& stream : requestedConfiguration.streams) { |
| 998 | if (stream.streamType == StreamType::OUTPUT && |
| 999 | stream.usage & |
| 1000 | graphics::common::V1_0::BufferUsage::VIDEO_ENCODER) { |
| 1001 | mVideoStreamIds.push_back(stream.id); |
| 1002 | } |
| 1003 | } |
| 1004 | mResultBatcher.setBatchedStreams(mVideoStreamIds); |
| 1005 | } |
| 1006 | |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 1007 | |
| 1008 | void CameraDeviceSession::postProcessConfigurationFailureLocked( |
| 1009 | const StreamConfiguration& requestedConfiguration) { |
| 1010 | if (mFreeBufEarly) { |
| 1011 | // Re-build the buf cache entry for deleted streams |
| 1012 | for(auto it = mStreamMap.begin(); it != mStreamMap.end(); it++) { |
| 1013 | int id = it->first; |
| 1014 | bool found = false; |
| 1015 | for (const auto& stream : requestedConfiguration.streams) { |
| 1016 | if (id == stream.id) { |
| 1017 | found = true; |
| 1018 | break; |
| 1019 | } |
| 1020 | } |
| 1021 | if (!found) { |
| 1022 | mCirculatingBuffers.emplace(id, CirculatingBuffers{}); |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | } |
| 1027 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1028 | Return<void> CameraDeviceSession::configureStreams( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 1029 | const StreamConfiguration& requestedConfiguration, |
| 1030 | ICameraDeviceSession::configureStreams_cb _hidl_cb) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1031 | Status status = initStatus(); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1032 | HalStreamConfiguration outStreams; |
| 1033 | |
| 1034 | // hold the inflight lock for entire configureStreams scope since there must not be any |
| 1035 | // inflight request/results during stream configuration. |
| 1036 | Mutex::Autolock _l(mInflightLock); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1037 | if (!mInflightBuffers.empty()) { |
| 1038 | ALOGE("%s: trying to configureStreams while there are still %zu inflight buffers!", |
| 1039 | __FUNCTION__, mInflightBuffers.size()); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1040 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
| 1041 | return Void(); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1042 | } |
| 1043 | |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1044 | if (!mInflightAETriggerOverrides.empty()) { |
| 1045 | ALOGE("%s: trying to configureStreams while there are still %zu inflight" |
| 1046 | " trigger overrides!", __FUNCTION__, |
| 1047 | mInflightAETriggerOverrides.size()); |
| 1048 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
| 1049 | return Void(); |
| 1050 | } |
| 1051 | |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1052 | if (!mInflightRawBoostPresent.empty()) { |
| 1053 | ALOGE("%s: trying to configureStreams while there are still %zu inflight" |
| 1054 | " boost overrides!", __FUNCTION__, |
| 1055 | mInflightRawBoostPresent.size()); |
| 1056 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
| 1057 | return Void(); |
| 1058 | } |
| 1059 | |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1060 | if (status != Status::OK) { |
| 1061 | _hidl_cb(status, outStreams); |
| 1062 | return Void(); |
| 1063 | } |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1064 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 1065 | camera3_stream_configuration_t stream_list{}; |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1066 | hidl_vec<camera3_stream_t*> streams; |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 1067 | if (!preProcessConfigurationLocked(requestedConfiguration, &stream_list, &streams)) { |
| 1068 | _hidl_cb(Status::INTERNAL_ERROR, outStreams); |
| 1069 | return Void(); |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1070 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1071 | |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1072 | ATRACE_BEGIN("camera3->configure_streams"); |
| 1073 | status_t ret = mDevice->ops->configure_streams(mDevice, &stream_list); |
| 1074 | ATRACE_END(); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1075 | |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1076 | // In case Hal returns error most likely it was not able to release |
| 1077 | // the corresponding resources of the deleted streams. |
| 1078 | if (ret == OK) { |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 1079 | postProcessConfigurationLocked(requestedConfiguration); |
Yin-Chia Yeh | 7d1fdec | 2018-08-03 11:50:47 -0700 | [diff] [blame] | 1080 | } else { |
| 1081 | postProcessConfigurationFailureLocked(requestedConfiguration); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1082 | } |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1083 | |
| 1084 | if (ret == -EINVAL) { |
| 1085 | status = Status::ILLEGAL_ARGUMENT; |
| 1086 | } else if (ret != OK) { |
| 1087 | status = Status::INTERNAL_ERROR; |
| 1088 | } else { |
| 1089 | convertToHidl(stream_list, &outStreams); |
Yin-Chia Yeh | e9ab822 | 2017-07-27 11:36:44 -0700 | [diff] [blame] | 1090 | mFirstRequest = true; |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1091 | } |
| 1092 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1093 | _hidl_cb(status, outStreams); |
| 1094 | return Void(); |
| 1095 | } |
| 1096 | |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 1097 | // Needs to get called after acquiring 'mInflightLock' |
| 1098 | void CameraDeviceSession::cleanupBuffersLocked(int id) { |
| 1099 | for (auto& pair : mCirculatingBuffers.at(id)) { |
| 1100 | sHandleImporter.freeBuffer(pair.second); |
| 1101 | } |
| 1102 | mCirculatingBuffers[id].clear(); |
| 1103 | mCirculatingBuffers.erase(id); |
| 1104 | } |
| 1105 | |
Yin-Chia Yeh | 28eebbf | 2017-03-30 15:06:20 -0700 | [diff] [blame] | 1106 | void CameraDeviceSession::updateBufferCaches(const hidl_vec<BufferCache>& cachesToRemove) { |
| 1107 | Mutex::Autolock _l(mInflightLock); |
| 1108 | for (auto& cache : cachesToRemove) { |
| 1109 | auto cbsIt = mCirculatingBuffers.find(cache.streamId); |
| 1110 | if (cbsIt == mCirculatingBuffers.end()) { |
| 1111 | // The stream could have been removed |
| 1112 | continue; |
| 1113 | } |
| 1114 | CirculatingBuffers& cbs = cbsIt->second; |
| 1115 | auto it = cbs.find(cache.bufferId); |
| 1116 | if (it != cbs.end()) { |
| 1117 | sHandleImporter.freeBuffer(it->second); |
| 1118 | cbs.erase(it); |
| 1119 | } else { |
| 1120 | ALOGE("%s: stream %d buffer %" PRIu64 " is not cached", |
| 1121 | __FUNCTION__, cache.streamId, cache.bufferId); |
| 1122 | } |
| 1123 | } |
| 1124 | } |
| 1125 | |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 1126 | Return<void> CameraDeviceSession::getCaptureRequestMetadataQueue( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 1127 | ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb) { |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 1128 | _hidl_cb(*mRequestMetadataQueue->getDesc()); |
| 1129 | return Void(); |
| 1130 | } |
| 1131 | |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 1132 | Return<void> CameraDeviceSession::getCaptureResultMetadataQueue( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 1133 | ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb) { |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 1134 | _hidl_cb(*mResultMetadataQueue->getDesc()); |
| 1135 | return Void(); |
| 1136 | } |
| 1137 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1138 | Return<void> CameraDeviceSession::processCaptureRequest( |
Yin-Chia Yeh | 28eebbf | 2017-03-30 15:06:20 -0700 | [diff] [blame] | 1139 | const hidl_vec<CaptureRequest>& requests, |
| 1140 | const hidl_vec<BufferCache>& cachesToRemove, |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 1141 | ICameraDeviceSession::processCaptureRequest_cb _hidl_cb) { |
Yin-Chia Yeh | 28eebbf | 2017-03-30 15:06:20 -0700 | [diff] [blame] | 1142 | updateBufferCaches(cachesToRemove); |
| 1143 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1144 | uint32_t numRequestProcessed = 0; |
| 1145 | Status s = Status::OK; |
| 1146 | for (size_t i = 0; i < requests.size(); i++, numRequestProcessed++) { |
| 1147 | s = processOneCaptureRequest(requests[i]); |
| 1148 | if (s != Status::OK) { |
| 1149 | break; |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | if (s == Status::OK && requests.size() > 1) { |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 1154 | mResultBatcher.registerBatch(requests[0].frameNumber, requests.size()); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | _hidl_cb(s, numRequestProcessed); |
| 1158 | return Void(); |
| 1159 | } |
| 1160 | |
| 1161 | Status CameraDeviceSession::processOneCaptureRequest(const CaptureRequest& request) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1162 | Status status = initStatus(); |
| 1163 | if (status != Status::OK) { |
| 1164 | ALOGE("%s: camera init failed or disconnected", __FUNCTION__); |
| 1165 | return status; |
| 1166 | } |
| 1167 | |
| 1168 | camera3_capture_request_t halRequest; |
| 1169 | halRequest.frame_number = request.frameNumber; |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 1170 | |
| 1171 | bool converted = true; |
| 1172 | CameraMetadata settingsFmq; // settings from FMQ |
| 1173 | if (request.fmqSettingsSize > 0) { |
| 1174 | // non-blocking read; client must write metadata before calling |
| 1175 | // processOneCaptureRequest |
| 1176 | settingsFmq.resize(request.fmqSettingsSize); |
| 1177 | bool read = mRequestMetadataQueue->read(settingsFmq.data(), request.fmqSettingsSize); |
| 1178 | if (read) { |
| 1179 | converted = convertFromHidl(settingsFmq, &halRequest.settings); |
| 1180 | } else { |
| 1181 | ALOGE("%s: capture request settings metadata couldn't be read from fmq!", __FUNCTION__); |
| 1182 | converted = false; |
| 1183 | } |
| 1184 | } else { |
| 1185 | converted = convertFromHidl(request.settings, &halRequest.settings); |
| 1186 | } |
| 1187 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1188 | if (!converted) { |
| 1189 | ALOGE("%s: capture request settings metadata is corrupt!", __FUNCTION__); |
Yin-Chia Yeh | e9ab822 | 2017-07-27 11:36:44 -0700 | [diff] [blame] | 1190 | return Status::ILLEGAL_ARGUMENT; |
| 1191 | } |
| 1192 | |
| 1193 | if (mFirstRequest && halRequest.settings == nullptr) { |
| 1194 | ALOGE("%s: capture request settings must not be null for first request!", |
| 1195 | __FUNCTION__); |
| 1196 | return Status::ILLEGAL_ARGUMENT; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1197 | } |
| 1198 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1199 | hidl_vec<buffer_handle_t*> allBufPtrs; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1200 | hidl_vec<int> allFences; |
| 1201 | bool hasInputBuf = (request.inputBuffer.streamId != -1 && |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 1202 | request.inputBuffer.bufferId != 0); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1203 | size_t numOutputBufs = request.outputBuffers.size(); |
| 1204 | size_t numBufs = numOutputBufs + (hasInputBuf ? 1 : 0); |
Yin-Chia Yeh | e9ab822 | 2017-07-27 11:36:44 -0700 | [diff] [blame] | 1205 | |
| 1206 | if (numOutputBufs == 0) { |
| 1207 | ALOGE("%s: capture request must have at least one output buffer!", __FUNCTION__); |
| 1208 | return Status::ILLEGAL_ARGUMENT; |
| 1209 | } |
| 1210 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1211 | status = importRequest(request, allBufPtrs, allFences); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1212 | if (status != Status::OK) { |
| 1213 | return status; |
| 1214 | } |
| 1215 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1216 | hidl_vec<camera3_stream_buffer_t> outHalBufs; |
| 1217 | outHalBufs.resize(numOutputBufs); |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1218 | bool aeCancelTriggerNeeded = false; |
| 1219 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata settingsOverride; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1220 | { |
| 1221 | Mutex::Autolock _l(mInflightLock); |
| 1222 | if (hasInputBuf) { |
| 1223 | auto key = std::make_pair(request.inputBuffer.streamId, request.frameNumber); |
| 1224 | auto& bufCache = mInflightBuffers[key] = camera3_stream_buffer_t{}; |
| 1225 | convertFromHidl( |
| 1226 | allBufPtrs[numOutputBufs], request.inputBuffer.status, |
| 1227 | &mStreamMap[request.inputBuffer.streamId], allFences[numOutputBufs], |
| 1228 | &bufCache); |
| 1229 | halRequest.input_buffer = &bufCache; |
| 1230 | } else { |
| 1231 | halRequest.input_buffer = nullptr; |
| 1232 | } |
| 1233 | |
| 1234 | halRequest.num_output_buffers = numOutputBufs; |
| 1235 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 1236 | auto key = std::make_pair(request.outputBuffers[i].streamId, request.frameNumber); |
| 1237 | auto& bufCache = mInflightBuffers[key] = camera3_stream_buffer_t{}; |
| 1238 | convertFromHidl( |
| 1239 | allBufPtrs[i], request.outputBuffers[i].status, |
| 1240 | &mStreamMap[request.outputBuffers[i].streamId], allFences[i], |
| 1241 | &bufCache); |
| 1242 | outHalBufs[i] = bufCache; |
| 1243 | } |
| 1244 | halRequest.output_buffers = outHalBufs.data(); |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1245 | |
| 1246 | AETriggerCancelOverride triggerOverride; |
| 1247 | aeCancelTriggerNeeded = handleAePrecaptureCancelRequestLocked( |
| 1248 | halRequest, &settingsOverride /*out*/, &triggerOverride/*out*/); |
| 1249 | if (aeCancelTriggerNeeded) { |
| 1250 | mInflightAETriggerOverrides[halRequest.frame_number] = |
| 1251 | triggerOverride; |
| 1252 | halRequest.settings = settingsOverride.getAndLock(); |
| 1253 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1254 | } |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 1255 | halRequest.num_physcam_settings = 0; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1256 | |
| 1257 | ATRACE_ASYNC_BEGIN("frame capture", request.frameNumber); |
| 1258 | ATRACE_BEGIN("camera3->process_capture_request"); |
| 1259 | status_t ret = mDevice->ops->process_capture_request(mDevice, &halRequest); |
| 1260 | ATRACE_END(); |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1261 | if (aeCancelTriggerNeeded) { |
| 1262 | settingsOverride.unlock(halRequest.settings); |
| 1263 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1264 | if (ret != OK) { |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1265 | Mutex::Autolock _l(mInflightLock); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1266 | ALOGE("%s: HAL process_capture_request call failed!", __FUNCTION__); |
| 1267 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1268 | cleanupInflightFences(allFences, numBufs); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1269 | if (hasInputBuf) { |
| 1270 | auto key = std::make_pair(request.inputBuffer.streamId, request.frameNumber); |
| 1271 | mInflightBuffers.erase(key); |
| 1272 | } |
| 1273 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 1274 | auto key = std::make_pair(request.outputBuffers[i].streamId, request.frameNumber); |
| 1275 | mInflightBuffers.erase(key); |
| 1276 | } |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1277 | if (aeCancelTriggerNeeded) { |
| 1278 | mInflightAETriggerOverrides.erase(request.frameNumber); |
| 1279 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1280 | return Status::INTERNAL_ERROR; |
| 1281 | } |
| 1282 | |
Yin-Chia Yeh | e9ab822 | 2017-07-27 11:36:44 -0700 | [diff] [blame] | 1283 | mFirstRequest = false; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1284 | return Status::OK; |
| 1285 | } |
| 1286 | |
| 1287 | Return<Status> CameraDeviceSession::flush() { |
| 1288 | Status status = initStatus(); |
| 1289 | if (status == Status::OK) { |
| 1290 | // Flush is always supported on device 3.1 or later |
| 1291 | status_t ret = mDevice->ops->flush(mDevice); |
| 1292 | if (ret != OK) { |
| 1293 | status = Status::INTERNAL_ERROR; |
| 1294 | } |
| 1295 | } |
| 1296 | return status; |
| 1297 | } |
| 1298 | |
| 1299 | Return<void> CameraDeviceSession::close() { |
| 1300 | Mutex::Autolock _l(mStateLock); |
| 1301 | if (!mClosed) { |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1302 | { |
| 1303 | Mutex::Autolock _l(mInflightLock); |
| 1304 | if (!mInflightBuffers.empty()) { |
| 1305 | ALOGE("%s: trying to close while there are still %zu inflight buffers!", |
| 1306 | __FUNCTION__, mInflightBuffers.size()); |
| 1307 | } |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1308 | if (!mInflightAETriggerOverrides.empty()) { |
| 1309 | ALOGE("%s: trying to close while there are still %zu inflight " |
| 1310 | "trigger overrides!", __FUNCTION__, |
| 1311 | mInflightAETriggerOverrides.size()); |
| 1312 | } |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1313 | if (!mInflightRawBoostPresent.empty()) { |
| 1314 | ALOGE("%s: trying to close while there are still %zu inflight " |
| 1315 | " RAW boost overrides!", __FUNCTION__, |
| 1316 | mInflightRawBoostPresent.size()); |
| 1317 | } |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1318 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1319 | } |
| 1320 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1321 | ATRACE_BEGIN("camera3->close"); |
| 1322 | mDevice->common.close(&mDevice->common); |
| 1323 | ATRACE_END(); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1324 | |
| 1325 | // free all imported buffers |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 1326 | Mutex::Autolock _l(mInflightLock); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1327 | for(auto& pair : mCirculatingBuffers) { |
| 1328 | CirculatingBuffers& buffers = pair.second; |
| 1329 | for (auto& p2 : buffers) { |
| 1330 | sHandleImporter.freeBuffer(p2.second); |
| 1331 | } |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 1332 | buffers.clear(); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1333 | } |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 1334 | mCirculatingBuffers.clear(); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1335 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1336 | mClosed = true; |
| 1337 | } |
| 1338 | return Void(); |
| 1339 | } |
| 1340 | |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 1341 | uint64_t CameraDeviceSession::getCapResultBufferId(const buffer_handle_t&, int) { |
| 1342 | // No need to fill in bufferId by default |
| 1343 | return BUFFER_ID_NO_BUFFER; |
| 1344 | } |
| 1345 | |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 1346 | status_t CameraDeviceSession::constructCaptureResult(CaptureResult& result, |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1347 | const camera3_capture_result *hal_result) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1348 | uint32_t frameNumber = hal_result->frame_number; |
| 1349 | bool hasInputBuf = (hal_result->input_buffer != nullptr); |
| 1350 | size_t numOutputBufs = hal_result->num_output_buffers; |
| 1351 | size_t numBufs = numOutputBufs + (hasInputBuf ? 1 : 0); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1352 | if (numBufs > 0) { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1353 | Mutex::Autolock _l(mInflightLock); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1354 | if (hasInputBuf) { |
| 1355 | int streamId = static_cast<Camera3Stream*>(hal_result->input_buffer->stream)->mId; |
| 1356 | // validate if buffer is inflight |
| 1357 | auto key = std::make_pair(streamId, frameNumber); |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1358 | if (mInflightBuffers.count(key) != 1) { |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1359 | ALOGE("%s: input buffer for stream %d frame %d is not inflight!", |
| 1360 | __FUNCTION__, streamId, frameNumber); |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 1361 | return -EINVAL; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1362 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1363 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1364 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1365 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 1366 | int streamId = static_cast<Camera3Stream*>(hal_result->output_buffers[i].stream)->mId; |
| 1367 | // validate if buffer is inflight |
| 1368 | auto key = std::make_pair(streamId, frameNumber); |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1369 | if (mInflightBuffers.count(key) != 1) { |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1370 | ALOGE("%s: output buffer for stream %d frame %d is not inflight!", |
| 1371 | __FUNCTION__, streamId, frameNumber); |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 1372 | return -EINVAL; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1373 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1374 | } |
| 1375 | } |
| 1376 | // We don't need to validate/import fences here since we will be passing them to camera service |
| 1377 | // within the scope of this function |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1378 | result.frameNumber = frameNumber; |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 1379 | result.fmqResultSize = 0; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1380 | result.partialResult = hal_result->partial_result; |
| 1381 | convertToHidl(hal_result->result, &result.result); |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1382 | if (nullptr != hal_result->result) { |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1383 | bool resultOverriden = false; |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1384 | Mutex::Autolock _l(mInflightLock); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1385 | |
| 1386 | // Derive some new keys for backward compatibility |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1387 | if (mDerivePostRawSensKey) { |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1388 | camera_metadata_ro_entry entry; |
| 1389 | if (find_camera_metadata_ro_entry(hal_result->result, |
| 1390 | ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST, &entry) == 0) { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1391 | mInflightRawBoostPresent[frameNumber] = true; |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1392 | } else { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1393 | auto entry = mInflightRawBoostPresent.find(frameNumber); |
| 1394 | if (mInflightRawBoostPresent.end() == entry) { |
| 1395 | mInflightRawBoostPresent[frameNumber] = false; |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1396 | } |
| 1397 | } |
| 1398 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1399 | if ((hal_result->partial_result == mNumPartialResults)) { |
| 1400 | if (!mInflightRawBoostPresent[frameNumber]) { |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1401 | if (!resultOverriden) { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1402 | mOverridenResult.clear(); |
| 1403 | mOverridenResult.append(hal_result->result); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1404 | resultOverriden = true; |
| 1405 | } |
| 1406 | int32_t defaultBoost[1] = {100}; |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1407 | mOverridenResult.update( |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1408 | ANDROID_CONTROL_POST_RAW_SENSITIVITY_BOOST, |
| 1409 | defaultBoost, 1); |
| 1410 | } |
| 1411 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1412 | mInflightRawBoostPresent.erase(frameNumber); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1413 | } |
| 1414 | } |
| 1415 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1416 | auto entry = mInflightAETriggerOverrides.find(frameNumber); |
| 1417 | if (mInflightAETriggerOverrides.end() != entry) { |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1418 | if (!resultOverriden) { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1419 | mOverridenResult.clear(); |
| 1420 | mOverridenResult.append(hal_result->result); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1421 | resultOverriden = true; |
| 1422 | } |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1423 | overrideResultForPrecaptureCancelLocked(entry->second, |
| 1424 | &mOverridenResult); |
| 1425 | if (hal_result->partial_result == mNumPartialResults) { |
| 1426 | mInflightAETriggerOverrides.erase(frameNumber); |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1427 | } |
| 1428 | } |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1429 | |
| 1430 | if (resultOverriden) { |
| 1431 | const camera_metadata_t *metaBuffer = |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1432 | mOverridenResult.getAndLock(); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1433 | convertToHidl(metaBuffer, &result.result); |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1434 | mOverridenResult.unlock(metaBuffer); |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1435 | } |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1436 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1437 | if (hasInputBuf) { |
| 1438 | result.inputBuffer.streamId = |
| 1439 | static_cast<Camera3Stream*>(hal_result->input_buffer->stream)->mId; |
| 1440 | result.inputBuffer.buffer = nullptr; |
| 1441 | result.inputBuffer.status = (BufferStatus) hal_result->input_buffer->status; |
| 1442 | // skip acquire fence since it's no use to camera service |
| 1443 | if (hal_result->input_buffer->release_fence != -1) { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1444 | native_handle_t* handle = native_handle_create(/*numFds*/1, /*numInts*/0); |
| 1445 | handle->data[0] = hal_result->input_buffer->release_fence; |
| 1446 | result.inputBuffer.releaseFence = handle; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1447 | } else { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1448 | result.inputBuffer.releaseFence = nullptr; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1449 | } |
| 1450 | } else { |
| 1451 | result.inputBuffer.streamId = -1; |
| 1452 | } |
| 1453 | |
| 1454 | result.outputBuffers.resize(numOutputBufs); |
| 1455 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 1456 | result.outputBuffers[i].streamId = |
| 1457 | static_cast<Camera3Stream*>(hal_result->output_buffers[i].stream)->mId; |
| 1458 | result.outputBuffers[i].buffer = nullptr; |
Yin-Chia Yeh | c2d3d1d | 2018-09-20 15:06:13 -0700 | [diff] [blame] | 1459 | if (hal_result->output_buffers[i].buffer != nullptr) { |
| 1460 | result.outputBuffers[i].bufferId = getCapResultBufferId( |
| 1461 | *(hal_result->output_buffers[i].buffer), |
| 1462 | result.outputBuffers[i].streamId); |
| 1463 | } else { |
| 1464 | result.outputBuffers[i].bufferId = 0; |
| 1465 | } |
| 1466 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1467 | result.outputBuffers[i].status = (BufferStatus) hal_result->output_buffers[i].status; |
| 1468 | // skip acquire fence since it's of no use to camera service |
| 1469 | if (hal_result->output_buffers[i].release_fence != -1) { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1470 | native_handle_t* handle = native_handle_create(/*numFds*/1, /*numInts*/0); |
| 1471 | handle->data[0] = hal_result->output_buffers[i].release_fence; |
| 1472 | result.outputBuffers[i].releaseFence = handle; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1473 | } else { |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1474 | result.outputBuffers[i].releaseFence = nullptr; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | // Free inflight record/fences. |
| 1479 | // Do this before call back to camera service because camera service might jump to |
| 1480 | // configure_streams right after the processCaptureResult call so we need to finish |
| 1481 | // updating inflight queues first |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1482 | if (numBufs > 0) { |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1483 | Mutex::Autolock _l(mInflightLock); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1484 | if (hasInputBuf) { |
| 1485 | int streamId = static_cast<Camera3Stream*>(hal_result->input_buffer->stream)->mId; |
| 1486 | auto key = std::make_pair(streamId, frameNumber); |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1487 | mInflightBuffers.erase(key); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1488 | } |
| 1489 | |
| 1490 | for (size_t i = 0; i < numOutputBufs; i++) { |
| 1491 | int streamId = static_cast<Camera3Stream*>(hal_result->output_buffers[i].stream)->mId; |
| 1492 | auto key = std::make_pair(streamId, frameNumber); |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1493 | mInflightBuffers.erase(key); |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1494 | } |
| 1495 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1496 | if (mInflightBuffers.empty()) { |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1497 | ALOGV("%s: inflight buffer queue is now empty!", __FUNCTION__); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1498 | } |
| 1499 | } |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 1500 | return OK; |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1501 | } |
| 1502 | |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 1503 | // Static helper method to copy/shrink capture result metadata sent by HAL |
| 1504 | void CameraDeviceSession::sShrinkCaptureResult( |
| 1505 | camera3_capture_result* dst, const camera3_capture_result* src, |
| 1506 | std::vector<::android::hardware::camera::common::V1_0::helper::CameraMetadata>* mds, |
| 1507 | std::vector<const camera_metadata_t*>* physCamMdArray, |
| 1508 | bool handlePhysCam) { |
| 1509 | *dst = *src; |
Shuzhen Wang | 9b71bc2 | 2018-06-05 22:23:39 -0700 | [diff] [blame] | 1510 | // Reserve maximum number of entries to avoid metadata re-allocation. |
| 1511 | mds->reserve(1 + (handlePhysCam ? src->num_physcam_metadata : 0)); |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 1512 | if (sShouldShrink(src->result)) { |
| 1513 | mds->emplace_back(sCreateCompactCopy(src->result)); |
| 1514 | dst->result = mds->back().getAndLock(); |
| 1515 | } |
| 1516 | |
| 1517 | if (handlePhysCam) { |
| 1518 | // First determine if we need to create new camera_metadata_t* array |
| 1519 | bool needShrink = false; |
| 1520 | for (uint32_t i = 0; i < src->num_physcam_metadata; i++) { |
| 1521 | if (sShouldShrink(src->physcam_metadata[i])) { |
| 1522 | needShrink = true; |
| 1523 | } |
| 1524 | } |
| 1525 | |
| 1526 | if (!needShrink) return; |
| 1527 | |
| 1528 | physCamMdArray->reserve(src->num_physcam_metadata); |
| 1529 | dst->physcam_metadata = physCamMdArray->data(); |
| 1530 | for (uint32_t i = 0; i < src->num_physcam_metadata; i++) { |
| 1531 | if (sShouldShrink(src->physcam_metadata[i])) { |
| 1532 | mds->emplace_back(sCreateCompactCopy(src->physcam_metadata[i])); |
| 1533 | dst->physcam_metadata[i] = mds->back().getAndLock(); |
| 1534 | } else { |
| 1535 | dst->physcam_metadata[i] = src->physcam_metadata[i]; |
| 1536 | } |
| 1537 | } |
| 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | bool CameraDeviceSession::sShouldShrink(const camera_metadata_t* md) { |
| 1542 | size_t compactSize = get_camera_metadata_compact_size(md); |
| 1543 | size_t totalSize = get_camera_metadata_size(md); |
| 1544 | if (totalSize >= compactSize + METADATA_SHRINK_ABS_THRESHOLD && |
| 1545 | totalSize >= compactSize * METADATA_SHRINK_REL_THRESHOLD) { |
| 1546 | ALOGV("Camera metadata should be shrunk from %zu to %zu", totalSize, compactSize); |
| 1547 | return true; |
| 1548 | } |
| 1549 | return false; |
| 1550 | } |
| 1551 | |
| 1552 | camera_metadata_t* CameraDeviceSession::sCreateCompactCopy(const camera_metadata_t* src) { |
| 1553 | size_t compactSize = get_camera_metadata_compact_size(src); |
| 1554 | void* buffer = calloc(1, compactSize); |
| 1555 | if (buffer == nullptr) { |
| 1556 | ALOGE("%s: Allocating %zu bytes failed", __FUNCTION__, compactSize); |
| 1557 | } |
| 1558 | return copy_camera_metadata(buffer, compactSize, src); |
| 1559 | } |
| 1560 | |
Shuzhen Wang | 39cf8fd | 2017-12-29 16:17:09 -0800 | [diff] [blame] | 1561 | /** |
| 1562 | * Static callback forwarding methods from HAL to instance |
| 1563 | */ |
| 1564 | void CameraDeviceSession::sProcessCaptureResult( |
| 1565 | const camera3_callback_ops *cb, |
| 1566 | const camera3_capture_result *hal_result) { |
| 1567 | CameraDeviceSession *d = |
| 1568 | const_cast<CameraDeviceSession*>(static_cast<const CameraDeviceSession*>(cb)); |
| 1569 | |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 1570 | CaptureResult result = {}; |
Yin-Chia Yeh | 090872a | 2018-05-17 15:53:30 -0700 | [diff] [blame] | 1571 | camera3_capture_result shadowResult; |
| 1572 | bool handlePhysCam = (d->mDeviceVersion >= CAMERA_DEVICE_API_VERSION_3_5); |
| 1573 | std::vector<::android::hardware::camera::common::V1_0::helper::CameraMetadata> compactMds; |
| 1574 | std::vector<const camera_metadata_t*> physCamMdArray; |
| 1575 | sShrinkCaptureResult(&shadowResult, hal_result, &compactMds, &physCamMdArray, handlePhysCam); |
| 1576 | |
| 1577 | status_t ret = d->constructCaptureResult(result, &shadowResult); |
Shuzhen Wang | 17d817a | 2018-03-09 15:58:43 -0800 | [diff] [blame] | 1578 | if (ret == OK) { |
| 1579 | d->mResultBatcher.processCaptureResult(result); |
| 1580 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1581 | } |
| 1582 | |
| 1583 | void CameraDeviceSession::sNotify( |
| 1584 | const camera3_callback_ops *cb, |
| 1585 | const camera3_notify_msg *msg) { |
| 1586 | CameraDeviceSession *d = |
| 1587 | const_cast<CameraDeviceSession*>(static_cast<const CameraDeviceSession*>(cb)); |
| 1588 | NotifyMsg hidlMsg; |
| 1589 | convertToHidl(msg, &hidlMsg); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1590 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 1591 | if (hidlMsg.type == (MsgType) CAMERA3_MSG_ERROR && |
| 1592 | hidlMsg.msg.error.errorStreamId != -1) { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1593 | if (d->mStreamMap.count(hidlMsg.msg.error.errorStreamId) != 1) { |
| 1594 | ALOGE("%s: unknown stream ID %d reports an error!", |
| 1595 | __FUNCTION__, hidlMsg.msg.error.errorStreamId); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1596 | return; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1597 | } |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1598 | } |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1599 | |
| 1600 | if (static_cast<camera3_msg_type_t>(hidlMsg.type) == CAMERA3_MSG_ERROR) { |
| 1601 | switch (hidlMsg.msg.error.errorCode) { |
| 1602 | case ErrorCode::ERROR_DEVICE: |
| 1603 | case ErrorCode::ERROR_REQUEST: |
| 1604 | case ErrorCode::ERROR_RESULT: { |
| 1605 | Mutex::Autolock _l(d->mInflightLock); |
| 1606 | auto entry = d->mInflightAETriggerOverrides.find( |
| 1607 | hidlMsg.msg.error.frameNumber); |
| 1608 | if (d->mInflightAETriggerOverrides.end() != entry) { |
| 1609 | d->mInflightAETriggerOverrides.erase( |
| 1610 | hidlMsg.msg.error.frameNumber); |
| 1611 | } |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 1612 | |
| 1613 | auto boostEntry = d->mInflightRawBoostPresent.find( |
| 1614 | hidlMsg.msg.error.frameNumber); |
| 1615 | if (d->mInflightRawBoostPresent.end() != boostEntry) { |
| 1616 | d->mInflightRawBoostPresent.erase( |
| 1617 | hidlMsg.msg.error.frameNumber); |
| 1618 | } |
| 1619 | |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 1620 | } |
| 1621 | break; |
| 1622 | case ErrorCode::ERROR_BUFFER: |
| 1623 | default: |
| 1624 | break; |
| 1625 | } |
| 1626 | |
| 1627 | } |
| 1628 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 1629 | d->mResultBatcher.notify(hidlMsg); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 1630 | } |
| 1631 | |
| 1632 | } // namespace implementation |
| 1633 | } // namespace V3_2 |
| 1634 | } // namespace device |
| 1635 | } // namespace camera |
| 1636 | } // namespace hardware |
| 1637 | } // namespace android |