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 | #ifndef ANDROID_HARDWARE_CAMERA_DEVICE_V3_2_CAMERADEVICE3SESSION_H |
| 18 | #define ANDROID_HARDWARE_CAMERA_DEVICE_V3_2_CAMERADEVICE3SESSION_H |
| 19 | |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 20 | #include <android/hardware/camera/device/3.2/ICameraDevice.h> |
| 21 | #include <android/hardware/camera/device/3.2/ICameraDeviceSession.h> |
| 22 | #include <fmq/MessageQueue.h> |
| 23 | #include <hidl/MQDescriptor.h> |
| 24 | #include <hidl/Status.h> |
| 25 | #include <include/convert.h> |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 26 | #include <deque> |
| 27 | #include <map> |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 28 | #include <unordered_map> |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 29 | #include "CameraMetadata.h" |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 30 | #include "HandleImporter.h" |
| 31 | #include "hardware/camera3.h" |
| 32 | #include "hardware/camera_common.h" |
| 33 | #include "utils/Mutex.h" |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 34 | |
| 35 | namespace android { |
| 36 | namespace hardware { |
| 37 | namespace camera { |
| 38 | namespace device { |
| 39 | namespace V3_2 { |
| 40 | namespace implementation { |
| 41 | |
| 42 | using ::android::hardware::camera::device::V3_2::CaptureRequest; |
| 43 | using ::android::hardware::camera::device::V3_2::HalStreamConfiguration; |
| 44 | using ::android::hardware::camera::device::V3_2::StreamConfiguration; |
| 45 | using ::android::hardware::camera::device::V3_2::ICameraDeviceSession; |
| 46 | using ::android::hardware::camera::common::V1_0::Status; |
Yin-Chia Yeh | 248ed70 | 2017-01-23 17:27:26 -0800 | [diff] [blame] | 47 | using ::android::hardware::camera::common::V1_0::helper::HandleImporter; |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 48 | using ::android::hardware::kSynchronizedReadWrite; |
| 49 | using ::android::hardware::MessageQueue; |
| 50 | using ::android::hardware::MQDescriptorSync; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 51 | using ::android::hardware::Return; |
| 52 | using ::android::hardware::Void; |
| 53 | using ::android::hardware::hidl_vec; |
| 54 | using ::android::hardware::hidl_string; |
| 55 | using ::android::sp; |
| 56 | using ::android::Mutex; |
| 57 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 58 | struct Camera3Stream; |
| 59 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Function pointer types with C calling convention to |
| 62 | * use for HAL callback functions. |
| 63 | */ |
| 64 | extern "C" { |
| 65 | typedef void (callbacks_process_capture_result_t)( |
| 66 | const struct camera3_callback_ops *, |
| 67 | const camera3_capture_result_t *); |
| 68 | |
| 69 | typedef void (callbacks_notify_t)( |
| 70 | const struct camera3_callback_ops *, |
| 71 | const camera3_notify_msg_t *); |
| 72 | } |
| 73 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 74 | struct CameraDeviceSession : public virtual RefBase, protected camera3_callback_ops { |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 75 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 76 | CameraDeviceSession(camera3_device_t*, |
| 77 | const camera_metadata_t* deviceInfo, |
| 78 | const sp<ICameraDeviceCallback>&); |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 79 | virtual ~CameraDeviceSession(); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 80 | // Call by CameraDevice to dump active device states |
| 81 | void dumpState(const native_handle_t* fd); |
| 82 | // Caller must use this method to check if CameraDeviceSession ctor failed |
| 83 | bool isInitFailed() { return mInitFail; } |
| 84 | // Used by CameraDevice to signal external camera disconnected |
| 85 | void disconnect(); |
| 86 | bool isClosed(); |
| 87 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 88 | // Retrieve the HIDL interface, split into its own class to avoid inheritance issues when |
| 89 | // dealing with minor version revs and simultaneous implementation and interface inheritance |
| 90 | virtual sp<ICameraDeviceSession> getInterface() { |
| 91 | return new TrampolineSessionInterface_3_2(this); |
| 92 | } |
| 93 | |
| 94 | protected: |
| 95 | |
| 96 | // Methods from ::android::hardware::camera::device::V3_2::ICameraDeviceSession follow |
| 97 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 98 | Return<void> constructDefaultRequestSettings( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 99 | RequestTemplate type, |
| 100 | ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 101 | Return<void> configureStreams( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 102 | const StreamConfiguration& requestedConfiguration, |
| 103 | ICameraDeviceSession::configureStreams_cb _hidl_cb); |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 104 | Return<void> getCaptureRequestMetadataQueue( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 105 | ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 106 | Return<void> getCaptureResultMetadataQueue( |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 107 | ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 108 | Return<void> processCaptureRequest( |
Yin-Chia Yeh | 28eebbf | 2017-03-30 15:06:20 -0700 | [diff] [blame] | 109 | const hidl_vec<CaptureRequest>& requests, |
| 110 | const hidl_vec<BufferCache>& cachesToRemove, |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 111 | ICameraDeviceSession::processCaptureRequest_cb _hidl_cb); |
| 112 | Return<Status> flush(); |
| 113 | Return<void> close(); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 114 | |
Emilian Peev | e18057b | 2017-11-13 16:03:44 +0000 | [diff] [blame] | 115 | //Helper methods |
| 116 | bool preProcessConfigurationLocked(const StreamConfiguration& requestedConfiguration, |
| 117 | camera3_stream_configuration_t *stream_list /*out*/, |
| 118 | hidl_vec<camera3_stream_t*> *streams /*out*/); |
| 119 | void postProcessConfigurationLocked(const StreamConfiguration& requestedConfiguration); |
| 120 | |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 121 | protected: |
| 122 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 123 | // protecting mClosed/mDisconnected/mInitFail |
| 124 | mutable Mutex mStateLock; |
| 125 | // device is closed either |
| 126 | // - closed by user |
| 127 | // - init failed |
| 128 | // - camera disconnected |
| 129 | bool mClosed = false; |
| 130 | |
| 131 | // Set by CameraDevice (when external camera is disconnected) |
| 132 | bool mDisconnected = false; |
| 133 | |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 134 | struct AETriggerCancelOverride { |
| 135 | bool applyAeLock; |
| 136 | uint8_t aeLock; |
| 137 | bool applyAePrecaptureTrigger; |
| 138 | uint8_t aePrecaptureTrigger; |
| 139 | }; |
| 140 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 141 | camera3_device_t* mDevice; |
Emilian Peev | 7d52a6f | 2017-04-07 09:53:48 +0100 | [diff] [blame] | 142 | uint32_t mDeviceVersion; |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 143 | bool mIsAELockAvailable; |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 144 | bool mDerivePostRawSensKey; |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 145 | uint32_t mNumPartialResults; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 146 | // Stream ID -> Camera3Stream cache |
| 147 | std::map<int, Camera3Stream> mStreamMap; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 148 | |
| 149 | mutable Mutex mInflightLock; // protecting mInflightBuffers and mCirculatingBuffers |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 150 | // (streamID, frameNumber) -> inflight buffer cache |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 151 | std::map<std::pair<int, uint32_t>, camera3_stream_buffer_t> mInflightBuffers; |
| 152 | |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 153 | // (frameNumber, AETriggerOverride) -> inflight request AETriggerOverrides |
| 154 | std::map<uint32_t, AETriggerCancelOverride> mInflightAETriggerOverrides; |
| 155 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata mOverridenResult; |
Emilian Peev | a13ac99 | 2017-04-10 12:02:17 +0100 | [diff] [blame] | 156 | std::map<uint32_t, bool> mInflightRawBoostPresent; |
| 157 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata mOverridenRequest; |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 158 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 159 | // buffers currently ciculating between HAL and camera service |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 160 | // key: bufferId sent via HIDL interface |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 161 | // value: imported buffer_handle_t |
| 162 | // Buffer will be imported during process_capture_request and will be freed |
| 163 | // when the its stream is deleted or camera device session is closed |
Yin-Chia Yeh | d926f93 | 2017-01-09 15:21:11 -0800 | [diff] [blame] | 164 | typedef std::unordered_map<uint64_t, buffer_handle_t> CirculatingBuffers; |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 165 | // Stream ID -> circulating buffers map |
| 166 | std::map<int, CirculatingBuffers> mCirculatingBuffers; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 167 | |
Yin-Chia Yeh | 519c167 | 2017-04-21 14:59:31 -0700 | [diff] [blame] | 168 | static HandleImporter sHandleImporter; |
Yin-Chia Yeh | 248ed70 | 2017-01-23 17:27:26 -0800 | [diff] [blame] | 169 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 170 | bool mInitFail; |
Yin-Chia Yeh | e9ab822 | 2017-07-27 11:36:44 -0700 | [diff] [blame] | 171 | bool mFirstRequest = false; |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 172 | |
| 173 | common::V1_0::helper::CameraMetadata mDeviceInfo; |
| 174 | |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 175 | using RequestMetadataQueue = MessageQueue<uint8_t, kSynchronizedReadWrite>; |
| 176 | std::unique_ptr<RequestMetadataQueue> mRequestMetadataQueue; |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 177 | using ResultMetadataQueue = MessageQueue<uint8_t, kSynchronizedReadWrite>; |
| 178 | std::shared_ptr<ResultMetadataQueue> mResultMetadataQueue; |
Yifan Hong | 1192e1d | 2017-04-11 14:45:00 -0700 | [diff] [blame] | 179 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 180 | class ResultBatcher { |
| 181 | public: |
| 182 | ResultBatcher(const sp<ICameraDeviceCallback>& callback); |
| 183 | void setNumPartialResults(uint32_t n); |
| 184 | void setBatchedStreams(const std::vector<int>& streamsToBatch); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 185 | void setResultMetadataQueue(std::shared_ptr<ResultMetadataQueue> q); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 186 | |
Emilian Peev | b75aa35 | 2018-01-17 11:00:54 +0000 | [diff] [blame] | 187 | void registerBatch(uint32_t frameNumber, uint32_t batchSize); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 188 | void notify(NotifyMsg& msg); |
| 189 | void processCaptureResult(CaptureResult& result); |
| 190 | |
| 191 | private: |
| 192 | struct InflightBatch { |
| 193 | // Protect access to entire struct. Acquire this lock before read/write any data or |
| 194 | // calling any methods. processCaptureResult and notify will compete for this lock |
| 195 | // HIDL IPCs might be issued while the lock is held |
| 196 | Mutex mLock; |
| 197 | |
| 198 | bool allDelivered() const; |
| 199 | |
| 200 | uint32_t mFirstFrame; |
| 201 | uint32_t mLastFrame; |
| 202 | uint32_t mBatchSize; |
| 203 | |
| 204 | bool mShutterDelivered = false; |
| 205 | std::vector<NotifyMsg> mShutterMsgs; |
| 206 | |
| 207 | struct BufferBatch { |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 208 | BufferBatch(uint32_t batchSize) { |
| 209 | mBuffers.reserve(batchSize); |
| 210 | } |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 211 | bool mDelivered = false; |
| 212 | // This currently assumes every batched request will output to the batched stream |
| 213 | // and since HAL must always send buffers in order, no frameNumber tracking is |
| 214 | // needed |
| 215 | std::vector<StreamBuffer> mBuffers; |
| 216 | }; |
| 217 | // Stream ID -> VideoBatch |
| 218 | std::unordered_map<int, BufferBatch> mBatchBufs; |
| 219 | |
| 220 | struct MetadataBatch { |
| 221 | // (frameNumber, metadata) |
| 222 | std::vector<std::pair<uint32_t, CameraMetadata>> mMds; |
| 223 | }; |
| 224 | // Partial result IDs that has been delivered to framework |
| 225 | uint32_t mNumPartialResults; |
| 226 | uint32_t mPartialResultProgress = 0; |
| 227 | // partialResult -> MetadataBatch |
| 228 | std::map<uint32_t, MetadataBatch> mResultMds; |
| 229 | |
| 230 | // Set to true when batch is removed from mInflightBatches |
| 231 | // processCaptureResult and notify must check this flag after acquiring mLock to make |
| 232 | // sure this batch isn't removed while waiting for mLock |
| 233 | bool mRemoved = false; |
| 234 | }; |
| 235 | |
| 236 | static const int NOT_BATCHED = -1; |
| 237 | |
| 238 | // Get the batch index and pointer to InflightBatch (nullptrt if the frame is not batched) |
| 239 | // Caller must acquire the InflightBatch::mLock before accessing the InflightBatch |
| 240 | // It's possible that the InflightBatch is removed from mInflightBatches before the |
| 241 | // InflightBatch::mLock is acquired (most likely caused by an error notification), so |
| 242 | // caller must check InflightBatch::mRemoved flag after the lock is acquried. |
| 243 | // This method will hold ResultBatcher::mLock briefly |
| 244 | std::pair<int, std::shared_ptr<InflightBatch>> getBatch(uint32_t frameNumber); |
| 245 | |
| 246 | // Check if the first batch in mInflightBatches is ready to be removed, and remove it if so |
| 247 | // This method will hold ResultBatcher::mLock briefly |
| 248 | void checkAndRemoveFirstBatch(); |
| 249 | |
| 250 | // The following sendXXXX methods must be called while the InflightBatch::mLock is locked |
| 251 | // HIDL IPC methods will be called during these methods. |
| 252 | void sendBatchShutterCbsLocked(std::shared_ptr<InflightBatch> batch); |
| 253 | // send buffers for all batched streams |
| 254 | void sendBatchBuffersLocked(std::shared_ptr<InflightBatch> batch); |
| 255 | // send buffers for specified streams |
| 256 | void sendBatchBuffersLocked( |
| 257 | std::shared_ptr<InflightBatch> batch, const std::vector<int>& streams); |
| 258 | void sendBatchMetadataLocked( |
| 259 | std::shared_ptr<InflightBatch> batch, uint32_t lastPartialResultIdx); |
| 260 | // End of sendXXXX methods |
| 261 | |
| 262 | // helper methods |
| 263 | void freeReleaseFences(hidl_vec<CaptureResult>&); |
| 264 | void notifySingleMsg(NotifyMsg& msg); |
| 265 | void processOneCaptureResult(CaptureResult& result); |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 266 | void invokeProcessCaptureResultCallback(hidl_vec<CaptureResult> &results, bool tryWriteFmq); |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 267 | |
Yin-Chia Yeh | aa69931 | 2017-05-26 14:01:32 -0700 | [diff] [blame] | 268 | // move/push function avoids "hidl_handle& operator=(hidl_handle&)", which clones native |
| 269 | // handle |
| 270 | void moveStreamBuffer(StreamBuffer&& src, StreamBuffer& dst); |
| 271 | void pushStreamBuffer(StreamBuffer&& src, std::vector<StreamBuffer>& dst); |
| 272 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 273 | // Protect access to mInflightBatches, mNumPartialResults and mStreamsToBatch |
| 274 | // processCaptureRequest, processCaptureResult, notify will compete for this lock |
| 275 | // Do NOT issue HIDL IPCs while holding this lock (except when HAL reports error) |
| 276 | mutable Mutex mLock; |
| 277 | std::deque<std::shared_ptr<InflightBatch>> mInflightBatches; |
| 278 | uint32_t mNumPartialResults; |
| 279 | std::vector<int> mStreamsToBatch; |
| 280 | const sp<ICameraDeviceCallback> mCallback; |
Yifan Hong | 993e3d0 | 2017-04-12 16:31:23 -0700 | [diff] [blame] | 281 | std::shared_ptr<ResultMetadataQueue> mResultMetadataQueue; |
| 282 | |
| 283 | // Protect against invokeProcessCaptureResultCallback() |
| 284 | Mutex mProcessCaptureResultLock; |
| 285 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 286 | } mResultBatcher; |
| 287 | |
| 288 | std::vector<int> mVideoStreamIds; |
| 289 | |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 290 | bool initialize(); |
| 291 | |
| 292 | Status initStatus() const; |
| 293 | |
| 294 | // Validate and import request's input buffer and acquire fence |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 295 | Status importRequest( |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 296 | const CaptureRequest& request, |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 297 | hidl_vec<buffer_handle_t*>& allBufPtrs, |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 298 | hidl_vec<int>& allFences); |
| 299 | |
Yin-Chia Yeh | 9c6dbd5 | 2016-12-22 14:55:02 -0800 | [diff] [blame] | 300 | static void cleanupInflightFences( |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 301 | hidl_vec<int>& allFences, size_t numFences); |
| 302 | |
Emilian Peev | 98014ff | 2017-02-02 16:20:12 +0000 | [diff] [blame] | 303 | void cleanupBuffersLocked(int id); |
| 304 | |
Yin-Chia Yeh | 28eebbf | 2017-03-30 15:06:20 -0700 | [diff] [blame] | 305 | void updateBufferCaches(const hidl_vec<BufferCache>& cachesToRemove); |
| 306 | |
Emilian Peev | 7d52a6f | 2017-04-07 09:53:48 +0100 | [diff] [blame] | 307 | android_dataspace mapToLegacyDataspace( |
| 308 | android_dataspace dataSpace) const; |
| 309 | |
Emilian Peev | cf58137 | 2017-04-07 13:53:10 +0100 | [diff] [blame] | 310 | bool handleAePrecaptureCancelRequestLocked( |
| 311 | const camera3_capture_request_t &halRequest, |
| 312 | android::hardware::camera::common::V1_0::helper::CameraMetadata *settings /*out*/, |
| 313 | AETriggerCancelOverride *override /*out*/); |
| 314 | |
| 315 | void overrideResultForPrecaptureCancelLocked( |
| 316 | const AETriggerCancelOverride &aeTriggerCancelOverride, |
| 317 | ::android::hardware::camera::common::V1_0::helper::CameraMetadata *settings /*out*/); |
| 318 | |
Yin-Chia Yeh | bed3a94 | 2017-03-06 14:14:17 -0800 | [diff] [blame] | 319 | Status processOneCaptureRequest(const CaptureRequest& request); |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 320 | /** |
| 321 | * Static callback forwarding methods from HAL to instance |
| 322 | */ |
| 323 | static callbacks_process_capture_result_t sProcessCaptureResult; |
| 324 | static callbacks_notify_t sNotify; |
Eino-Ville Talvala | 50fe430 | 2017-08-22 16:15:09 -0700 | [diff] [blame] | 325 | |
| 326 | private: |
| 327 | |
| 328 | struct TrampolineSessionInterface_3_2 : public ICameraDeviceSession { |
| 329 | TrampolineSessionInterface_3_2(sp<CameraDeviceSession> parent) : |
| 330 | mParent(parent) {} |
| 331 | |
| 332 | virtual Return<void> constructDefaultRequestSettings( |
| 333 | V3_2::RequestTemplate type, |
| 334 | V3_2::ICameraDeviceSession::constructDefaultRequestSettings_cb _hidl_cb) override { |
| 335 | return mParent->constructDefaultRequestSettings(type, _hidl_cb); |
| 336 | } |
| 337 | |
| 338 | virtual Return<void> configureStreams( |
| 339 | const V3_2::StreamConfiguration& requestedConfiguration, |
| 340 | V3_2::ICameraDeviceSession::configureStreams_cb _hidl_cb) override { |
| 341 | return mParent->configureStreams(requestedConfiguration, _hidl_cb); |
| 342 | } |
| 343 | |
| 344 | virtual Return<void> processCaptureRequest(const hidl_vec<V3_2::CaptureRequest>& requests, |
| 345 | const hidl_vec<V3_2::BufferCache>& cachesToRemove, |
| 346 | V3_2::ICameraDeviceSession::processCaptureRequest_cb _hidl_cb) override { |
| 347 | return mParent->processCaptureRequest(requests, cachesToRemove, _hidl_cb); |
| 348 | } |
| 349 | |
| 350 | virtual Return<void> getCaptureRequestMetadataQueue( |
| 351 | V3_2::ICameraDeviceSession::getCaptureRequestMetadataQueue_cb _hidl_cb) override { |
| 352 | return mParent->getCaptureRequestMetadataQueue(_hidl_cb); |
| 353 | } |
| 354 | |
| 355 | virtual Return<void> getCaptureResultMetadataQueue( |
| 356 | V3_2::ICameraDeviceSession::getCaptureResultMetadataQueue_cb _hidl_cb) override { |
| 357 | return mParent->getCaptureResultMetadataQueue(_hidl_cb); |
| 358 | } |
| 359 | |
| 360 | virtual Return<Status> flush() override { |
| 361 | return mParent->flush(); |
| 362 | } |
| 363 | |
| 364 | virtual Return<void> close() override { |
| 365 | return mParent->close(); |
| 366 | } |
| 367 | |
| 368 | private: |
| 369 | sp<CameraDeviceSession> mParent; |
| 370 | }; |
Yin-Chia Yeh | faef8f9 | 2016-10-31 12:53:56 -0700 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | } // namespace implementation |
| 374 | } // namespace V3_2 |
| 375 | } // namespace device |
| 376 | } // namespace camera |
| 377 | } // namespace hardware |
| 378 | } // namespace android |
| 379 | |
| 380 | #endif // ANDROID_HARDWARE_CAMERA_DEVICE_V3_2_CAMERADEVICE3SESSION_H |