Loading camera/common/1.0/default/HandleImporter.cpp +59 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,65 @@ void HandleImporter::closeFence(int fd) const { } } YCbCrLayout HandleImporter::lockYCbCr( buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion) { Mutex::Autolock lock(mLock); YCbCrLayout layout = {}; if (!mInitialized) { initializeLocked(); } if (mMapper == nullptr) { ALOGE("%s: mMapper is null!", __FUNCTION__); return layout; } hidl_handle acquireFenceHandle; auto buffer = const_cast<native_handle_t*>(buf); mMapper->lockYCbCr(buffer, cpuUsage, accessRegion, acquireFenceHandle, [&](const auto& tmpError, const auto& tmpLayout) { if (tmpError == MapperError::NONE) { layout = tmpLayout; } else { ALOGE("%s: failed to lockYCbCr error %d!", __FUNCTION__, tmpError); } }); ALOGV("%s: layout y %p cb %p cr %p y_str %d c_str %d c_step %d", __FUNCTION__, layout.y, layout.cb, layout.cr, layout.yStride, layout.cStride, layout.chromaStep); return layout; } int HandleImporter::unlock(buffer_handle_t& buf) { int releaseFence = -1; auto buffer = const_cast<native_handle_t*>(buf); mMapper->unlock( buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) { if (tmpError == MapperError::NONE) { auto fenceHandle = tmpReleaseFence.getNativeHandle(); if (fenceHandle) { if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) { ALOGE("%s: bad release fence numInts %d numFds %d", __FUNCTION__, fenceHandle->numInts, fenceHandle->numFds); return; } releaseFence = dup(fenceHandle->data[0]); if (releaseFence <= 0) { ALOGE("%s: bad release fence FD %d", __FUNCTION__, releaseFence); } } } else { ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError); } }); return releaseFence; } } // namespace helper } // namespace V1_0 } // namespace common Loading camera/common/1.0/default/include/HandleImporter.h +8 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <cutils/native_handle.h> using android::hardware::graphics::mapper::V2_0::IMapper; using android::hardware::graphics::mapper::V2_0::YCbCrLayout; namespace android { namespace hardware { Loading @@ -43,6 +44,12 @@ public: bool importFence(const native_handle_t* handle, int& fd) const; void closeFence(int fd) const; // Assume caller has done waiting for acquire fences YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion); int unlock(buffer_handle_t& buf); // returns release fence private: void initializeLocked(); void cleanup(); Loading camera/device/3.4/default/Android.bp +44 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,13 @@ cc_library_headers { name: "camera.device@3.4-impl_headers", vendor: true, export_include_dirs: ["include/device_v3_4_impl"], export_include_dirs: ["include/device_v3_4_impl"] } cc_library_headers { name: "camera.device@3.4-external-impl_headers", vendor: true, export_include_dirs: ["include/ext_device_v3_4_impl"] } cc_library_shared { Loading Loading @@ -55,3 +61,40 @@ cc_library_shared { "libfmq", ], } cc_library_shared { name: "camera.device@3.4-external-impl", defaults: ["hidl_defaults"], proprietary: true, vendor: true, srcs: [ "ExternalCameraDevice.cpp", "ExternalCameraDeviceSession.cpp" ], shared_libs: [ "libhidlbase", "libhidltransport", "libutils", "libcutils", "camera.device@3.2-impl", "camera.device@3.3-impl", "android.hardware.camera.device@3.2", "android.hardware.camera.device@3.3", "android.hardware.camera.device@3.4", "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "liblog", "libhardware", "libcamera_metadata", "libfmq", "libsync", "libyuv", ], static_libs: [ "android.hardware.camera.common@1.0-helper", ], local_include_dirs: ["include/ext_device_v3_4_impl"], export_shared_lib_headers: [ "libfmq", ], } Loading
camera/common/1.0/default/HandleImporter.cpp +59 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,65 @@ void HandleImporter::closeFence(int fd) const { } } YCbCrLayout HandleImporter::lockYCbCr( buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion) { Mutex::Autolock lock(mLock); YCbCrLayout layout = {}; if (!mInitialized) { initializeLocked(); } if (mMapper == nullptr) { ALOGE("%s: mMapper is null!", __FUNCTION__); return layout; } hidl_handle acquireFenceHandle; auto buffer = const_cast<native_handle_t*>(buf); mMapper->lockYCbCr(buffer, cpuUsage, accessRegion, acquireFenceHandle, [&](const auto& tmpError, const auto& tmpLayout) { if (tmpError == MapperError::NONE) { layout = tmpLayout; } else { ALOGE("%s: failed to lockYCbCr error %d!", __FUNCTION__, tmpError); } }); ALOGV("%s: layout y %p cb %p cr %p y_str %d c_str %d c_step %d", __FUNCTION__, layout.y, layout.cb, layout.cr, layout.yStride, layout.cStride, layout.chromaStep); return layout; } int HandleImporter::unlock(buffer_handle_t& buf) { int releaseFence = -1; auto buffer = const_cast<native_handle_t*>(buf); mMapper->unlock( buffer, [&](const auto& tmpError, const auto& tmpReleaseFence) { if (tmpError == MapperError::NONE) { auto fenceHandle = tmpReleaseFence.getNativeHandle(); if (fenceHandle) { if (fenceHandle->numInts != 0 || fenceHandle->numFds != 1) { ALOGE("%s: bad release fence numInts %d numFds %d", __FUNCTION__, fenceHandle->numInts, fenceHandle->numFds); return; } releaseFence = dup(fenceHandle->data[0]); if (releaseFence <= 0) { ALOGE("%s: bad release fence FD %d", __FUNCTION__, releaseFence); } } } else { ALOGE("%s: failed to unlock error %d!", __FUNCTION__, tmpError); } }); return releaseFence; } } // namespace helper } // namespace V1_0 } // namespace common Loading
camera/common/1.0/default/include/HandleImporter.h +8 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <cutils/native_handle.h> using android::hardware::graphics::mapper::V2_0::IMapper; using android::hardware::graphics::mapper::V2_0::YCbCrLayout; namespace android { namespace hardware { Loading @@ -43,6 +44,12 @@ public: bool importFence(const native_handle_t* handle, int& fd) const; void closeFence(int fd) const; // Assume caller has done waiting for acquire fences YCbCrLayout lockYCbCr(buffer_handle_t& buf, uint64_t cpuUsage, const IMapper::Rect& accessRegion); int unlock(buffer_handle_t& buf); // returns release fence private: void initializeLocked(); void cleanup(); Loading
camera/device/3.4/default/Android.bp +44 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,13 @@ cc_library_headers { name: "camera.device@3.4-impl_headers", vendor: true, export_include_dirs: ["include/device_v3_4_impl"], export_include_dirs: ["include/device_v3_4_impl"] } cc_library_headers { name: "camera.device@3.4-external-impl_headers", vendor: true, export_include_dirs: ["include/ext_device_v3_4_impl"] } cc_library_shared { Loading Loading @@ -55,3 +61,40 @@ cc_library_shared { "libfmq", ], } cc_library_shared { name: "camera.device@3.4-external-impl", defaults: ["hidl_defaults"], proprietary: true, vendor: true, srcs: [ "ExternalCameraDevice.cpp", "ExternalCameraDeviceSession.cpp" ], shared_libs: [ "libhidlbase", "libhidltransport", "libutils", "libcutils", "camera.device@3.2-impl", "camera.device@3.3-impl", "android.hardware.camera.device@3.2", "android.hardware.camera.device@3.3", "android.hardware.camera.device@3.4", "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "liblog", "libhardware", "libcamera_metadata", "libfmq", "libsync", "libyuv", ], static_libs: [ "android.hardware.camera.common@1.0-helper", ], local_include_dirs: ["include/ext_device_v3_4_impl"], export_shared_lib_headers: [ "libfmq", ], }