diff options
-rw-r--r-- | camera/common/1.0/default/HandleImporter.cpp | 32 | ||||
-rw-r--r-- | camera/common/1.0/default/include/HandleImporter.h | 3 |
2 files changed, 35 insertions, 0 deletions
diff --git a/camera/common/1.0/default/HandleImporter.cpp b/camera/common/1.0/default/HandleImporter.cpp index e9741efa9a..21706a84a3 100644 --- a/camera/common/1.0/default/HandleImporter.cpp +++ b/camera/common/1.0/default/HandleImporter.cpp @@ -134,6 +134,38 @@ void HandleImporter::closeFence(int fd) const { } } +void* HandleImporter::lock( + buffer_handle_t& buf, uint64_t cpuUsage, size_t size) { + Mutex::Autolock lock(mLock); + void *ret = 0; + IMapper::Rect accessRegion { 0, 0, static_cast<int>(size), 1 }; + + if (!mInitialized) { + initializeLocked(); + } + + if (mMapper == nullptr) { + ALOGE("%s: mMapper is null!", __FUNCTION__); + return ret; + } + + hidl_handle acquireFenceHandle; + auto buffer = const_cast<native_handle_t*>(buf); + mMapper->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle, + [&](const auto& tmpError, const auto& tmpPtr) { + if (tmpError == MapperError::NONE) { + ret = tmpPtr; + } else { + ALOGE("%s: failed to lock error %d!", + __FUNCTION__, tmpError); + } + }); + + ALOGV("%s: ptr %p size: %zu", __FUNCTION__, ret, size); + return ret; +} + + YCbCrLayout HandleImporter::lockYCbCr( buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion) { diff --git a/camera/common/1.0/default/include/HandleImporter.h b/camera/common/1.0/default/include/HandleImporter.h index 443362d3c2..f9cd9fb604 100644 --- a/camera/common/1.0/default/include/HandleImporter.h +++ b/camera/common/1.0/default/include/HandleImporter.h @@ -45,6 +45,9 @@ public: void closeFence(int fd) const; // Assume caller has done waiting for acquire fences + void* lock(buffer_handle_t& buf, uint64_t cpuUsage, size_t size); + + // Assume caller has done waiting for acquire fences YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion); |