diff options
-rw-r--r-- | camera/common/1.0/default/Android.bp | 1 | ||||
-rw-r--r-- | camera/common/1.0/default/HandleImporter.cpp | 56 | ||||
-rw-r--r-- | camera/common/1.0/default/include/HandleImporter.h | 4 | ||||
-rw-r--r-- | camera/device/1.0/default/Android.bp | 1 | ||||
-rw-r--r-- | camera/device/3.2/default/Android.bp | 1 | ||||
-rw-r--r-- | camera/device/3.3/default/Android.bp | 1 | ||||
-rw-r--r-- | camera/device/3.4/default/Android.bp | 2 | ||||
-rw-r--r-- | camera/device/3.5/default/Android.bp | 4 | ||||
-rw-r--r-- | camera/provider/2.4/default/Android.bp | 6 | ||||
-rw-r--r-- | camera/provider/2.4/vts/functional/Android.bp | 2 | ||||
-rw-r--r-- | camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp | 35 |
11 files changed, 101 insertions, 12 deletions
diff --git a/camera/common/1.0/default/Android.bp b/camera/common/1.0/default/Android.bp index 3e5c6d7812..f4390b2e30 100644 --- a/camera/common/1.0/default/Android.bp +++ b/camera/common/1.0/default/Android.bp @@ -21,6 +21,7 @@ cc_library_static { "libcamera_metadata", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "libexif", ], include_dirs: ["system/media/private/camera/include"], diff --git a/camera/common/1.0/default/HandleImporter.cpp b/camera/common/1.0/default/HandleImporter.cpp index b8c40e95b8..76f97789c0 100644 --- a/camera/common/1.0/default/HandleImporter.cpp +++ b/camera/common/1.0/default/HandleImporter.cpp @@ -27,7 +27,9 @@ namespace helper { using MapperErrorV2 = android::hardware::graphics::mapper::V2_0::Error; using MapperErrorV3 = android::hardware::graphics::mapper::V3_0::Error; +using MapperErrorV4 = android::hardware::graphics::mapper::V4_0::Error; using IMapperV3 = android::hardware::graphics::mapper::V3_0::IMapper; +using IMapperV4 = android::hardware::graphics::mapper::V4_0::IMapper; HandleImporter::HandleImporter() : mInitialized(false) {} @@ -36,6 +38,12 @@ void HandleImporter::initializeLocked() { return; } + mMapperV4 = IMapperV4::getService(); + if (mMapperV4 != nullptr) { + mInitialized = true; + return; + } + mMapperV3 = IMapperV3::getService(); if (mMapperV3 != nullptr) { mInitialized = true; @@ -53,6 +61,7 @@ void HandleImporter::initializeLocked() { } void HandleImporter::cleanup() { + mMapperV4.clear(); mMapperV3.clear(); mMapperV2.clear(); mInitialized = false; @@ -151,6 +160,10 @@ bool HandleImporter::importBuffer(buffer_handle_t& handle) { initializeLocked(); } + if (mMapperV4 != nullptr) { + return importBufferInternal<IMapperV4, MapperErrorV4>(mMapperV4, handle); + } + if (mMapperV3 != nullptr) { return importBufferInternal<IMapperV3, MapperErrorV3>(mMapperV3, handle); } @@ -159,7 +172,7 @@ bool HandleImporter::importBuffer(buffer_handle_t& handle) { return importBufferInternal<IMapper, MapperErrorV2>(mMapperV2, handle); } - ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__); + ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__); return false; } @@ -169,12 +182,17 @@ void HandleImporter::freeBuffer(buffer_handle_t handle) { } Mutex::Autolock lock(mLock); - if (mMapperV3 == nullptr && mMapperV2 == nullptr) { - ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__); + if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) { + ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__); return; } - if (mMapperV3 != nullptr) { + if (mMapperV4 != nullptr) { + auto ret = mMapperV4->freeBuffer(const_cast<native_handle_t*>(handle)); + if (!ret.isOk()) { + ALOGE("%s: mapper freeBuffer failed: %s", __FUNCTION__, ret.description().c_str()); + } + } else if (mMapperV3 != nullptr) { auto ret = mMapperV3->freeBuffer(const_cast<native_handle_t*>(handle)); if (!ret.isOk()) { ALOGE("%s: mapper freeBuffer failed: %s", @@ -222,14 +240,27 @@ void* HandleImporter::lock( initializeLocked(); } - if (mMapperV3 == nullptr && mMapperV2 == nullptr) { - ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__); + if (mMapperV4 == nullptr && mMapperV3 == nullptr && mMapperV2 == nullptr) { + ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__); return ret; } hidl_handle acquireFenceHandle; auto buffer = const_cast<native_handle_t*>(buf); - if (mMapperV3 != nullptr) { + if (mMapperV4 != nullptr) { + IMapperV4::Rect accessRegion{0, 0, static_cast<int>(size), 1}; + // No need to use bytesPerPixel and bytesPerStride because we are using + // an 1-D buffer and accressRegion. + mMapperV4->lock(buffer, cpuUsage, accessRegion, acquireFenceHandle, + [&](const auto& tmpError, const auto& tmpPtr, const auto& /*bytesPerPixel*/, + const auto& /*bytesPerStride*/) { + if (tmpError == MapperErrorV4::NONE) { + ret = tmpPtr; + } else { + ALOGE("%s: failed to lock error %d!", __FUNCTION__, tmpError); + } + }); + } else if (mMapperV3 != nullptr) { IMapperV3::Rect accessRegion { 0, 0, static_cast<int>(size), 1 }; // No need to use bytesPerPixel and bytesPerStride because we are using // an 1-D buffer and accressRegion. @@ -269,6 +300,10 @@ YCbCrLayout HandleImporter::lockYCbCr( initializeLocked(); } + if (mMapperV4 != nullptr) { + return lockYCbCrInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf, cpuUsage, accessRegion); + } + if (mMapperV3 != nullptr) { return lockYCbCrInternal<IMapperV3, MapperErrorV3>( mMapperV3, buf, cpuUsage, accessRegion); @@ -279,11 +314,14 @@ YCbCrLayout HandleImporter::lockYCbCr( mMapperV2, buf, cpuUsage, accessRegion); } - ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__); + ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__); return {}; } int HandleImporter::unlock(buffer_handle_t& buf) { + if (mMapperV4 != nullptr) { + return unlockInternal<IMapperV4, MapperErrorV4>(mMapperV4, buf); + } if (mMapperV3 != nullptr) { return unlockInternal<IMapperV3, MapperErrorV3>(mMapperV3, buf); } @@ -291,7 +329,7 @@ int HandleImporter::unlock(buffer_handle_t& buf) { return unlockInternal<IMapper, MapperErrorV2>(mMapperV2, buf); } - ALOGE("%s: mMapperV3 and mMapperV2 are both null!", __FUNCTION__); + ALOGE("%s: mMapperV4, mMapperV3 and mMapperV2 are all null!", __FUNCTION__); return -1; } diff --git a/camera/common/1.0/default/include/HandleImporter.h b/camera/common/1.0/default/include/HandleImporter.h index a93d4554ad..fc2bbd1197 100644 --- a/camera/common/1.0/default/include/HandleImporter.h +++ b/camera/common/1.0/default/include/HandleImporter.h @@ -17,10 +17,11 @@ #ifndef CAMERA_COMMON_1_0_HANDLEIMPORTED_H #define CAMERA_COMMON_1_0_HANDLEIMPORTED_H -#include <utils/Mutex.h> #include <android/hardware/graphics/mapper/2.0/IMapper.h> #include <android/hardware/graphics/mapper/3.0/IMapper.h> +#include <android/hardware/graphics/mapper/4.0/IMapper.h> #include <cutils/native_handle.h> +#include <utils/Mutex.h> using android::hardware::graphics::mapper::V2_0::IMapper; using android::hardware::graphics::mapper::V2_0::YCbCrLayout; @@ -70,6 +71,7 @@ private: bool mInitialized; sp<IMapper> mMapperV2; sp<graphics::mapper::V3_0::IMapper> mMapperV3; + sp<graphics::mapper::V4_0::IMapper> mMapperV4; }; } // namespace helper diff --git a/camera/device/1.0/default/Android.bp b/camera/device/1.0/default/Android.bp index aa3b941c2e..c3518d3325 100644 --- a/camera/device/1.0/default/Android.bp +++ b/camera/device/1.0/default/Android.bp @@ -16,6 +16,7 @@ cc_library_shared { "android.hardware.graphics.allocator@2.0", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "android.hardware.graphics.common@1.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", diff --git a/camera/device/3.2/default/Android.bp b/camera/device/3.2/default/Android.bp index edb008ed62..edc2988fc6 100644 --- a/camera/device/3.2/default/Android.bp +++ b/camera/device/3.2/default/Android.bp @@ -14,6 +14,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "liblog", "libhardware", "libcamera_metadata", diff --git a/camera/device/3.3/default/Android.bp b/camera/device/3.3/default/Android.bp index 39d379d049..f3c2e0e414 100644 --- a/camera/device/3.3/default/Android.bp +++ b/camera/device/3.3/default/Android.bp @@ -16,6 +16,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "liblog", "libhardware", "libcamera_metadata", diff --git a/camera/device/3.4/default/Android.bp b/camera/device/3.4/default/Android.bp index c22b13c2c4..8e699d83d0 100644 --- a/camera/device/3.4/default/Android.bp +++ b/camera/device/3.4/default/Android.bp @@ -49,6 +49,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "liblog", "libhardware", "libcamera_metadata", @@ -86,6 +87,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "liblog", "libhardware", "libcamera_metadata", diff --git a/camera/device/3.5/default/Android.bp b/camera/device/3.5/default/Android.bp index 26b3b6734b..dde585eb6a 100644 --- a/camera/device/3.5/default/Android.bp +++ b/camera/device/3.5/default/Android.bp @@ -50,6 +50,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "liblog", "libhardware", "libcamera_metadata", @@ -83,7 +84,8 @@ cc_library_shared { "android.hardware.camera.device@3.5", "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", - "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "liblog", "libhardware", "libcamera_metadata", diff --git a/camera/provider/2.4/default/Android.bp b/camera/provider/2.4/default/Android.bp index cb78fcb859..313b29bf8d 100644 --- a/camera/provider/2.4/default/Android.bp +++ b/camera/provider/2.4/default/Android.bp @@ -13,6 +13,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", "camera.device@1.0-impl", @@ -52,6 +53,7 @@ cc_library_shared { "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", "camera.device@3.3-impl", @@ -95,6 +97,8 @@ cc_library_shared { "android.hardware.camera.provider@2.4-external", "android.hardware.camera.provider@2.4-legacy", "android.hardware.graphics.mapper@2.0", + "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", "camera.device@1.0-impl", @@ -140,6 +144,8 @@ cc_defaults { "android.hardware.camera.device@3.5", "android.hardware.camera.provider@2.4", "android.hardware.graphics.mapper@2.0", + "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", "libbinder", diff --git a/camera/provider/2.4/vts/functional/Android.bp b/camera/provider/2.4/vts/functional/Android.bp index 2c3ed37a6a..5fe7b197d0 100644 --- a/camera/provider/2.4/vts/functional/Android.bp +++ b/camera/provider/2.4/vts/functional/Android.bp @@ -43,9 +43,11 @@ cc_test { "android.hardware.camera.provider@2.5", "android.hardware.graphics.allocator@2.0", "android.hardware.graphics.allocator@3.0", + "android.hardware.graphics.allocator@4.0", "android.hardware.graphics.common@1.0", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@3.0", + "android.hardware.graphics.mapper@4.0", "android.hidl.allocator@1.0", "libgrallocusage", "libhidlmemory", diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index a5369e7b8d..6f6479d18d 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -55,9 +55,11 @@ #include <android/hardware/graphics/allocator/2.0/IAllocator.h> #include <android/hardware/graphics/allocator/3.0/IAllocator.h> +#include <android/hardware/graphics/allocator/4.0/IAllocator.h> #include <android/hardware/graphics/mapper/2.0/IMapper.h> #include <android/hardware/graphics/mapper/2.0/types.h> #include <android/hardware/graphics/mapper/3.0/IMapper.h> +#include <android/hardware/graphics/mapper/4.0/IMapper.h> #include <android/hidl/allocator/1.0/IAllocator.h> #include <android/hidl/memory/1.0/IMapper.h> #include <android/hidl/memory/1.0/IMemory.h> @@ -6148,13 +6150,44 @@ void CameraHidlTest::allocateGraphicBuffer(uint32_t width, uint32_t height, uint android::hardware::graphics::allocator::V2_0::IAllocator::getService(); sp<android::hardware::graphics::allocator::V3_0::IAllocator> allocatorV3 = android::hardware::graphics::allocator::V3_0::IAllocator::getService(); + sp<android::hardware::graphics::allocator::V4_0::IAllocator> allocatorV4 = + android::hardware::graphics::allocator::V4_0::IAllocator::getService(); + sp<android::hardware::graphics::mapper::V4_0::IMapper> mapperV4 = + android::hardware::graphics::mapper::V4_0::IMapper::getService(); sp<android::hardware::graphics::mapper::V3_0::IMapper> mapperV3 = android::hardware::graphics::mapper::V3_0::IMapper::getService(); sp<android::hardware::graphics::mapper::V2_0::IMapper> mapper = android::hardware::graphics::mapper::V2_0::IMapper::getService(); ::android::hardware::hidl_vec<uint32_t> descriptor; - if (mapperV3 != nullptr && allocatorV3 != nullptr) { + if (mapperV4 != nullptr && allocatorV4 != nullptr) { + android::hardware::graphics::mapper::V4_0::IMapper::BufferDescriptorInfo descriptorInfo{}; + descriptorInfo.width = width; + descriptorInfo.height = height; + descriptorInfo.layerCount = 1; + descriptorInfo.format = + static_cast<android::hardware::graphics::common::V1_2::PixelFormat>(format); + descriptorInfo.usage = usage; + + auto ret = mapperV4->createDescriptor( + descriptorInfo, [&descriptor](android::hardware::graphics::mapper::V4_0::Error err, + ::android::hardware::hidl_vec<uint32_t> desc) { + ASSERT_EQ(err, android::hardware::graphics::mapper::V4_0::Error::NONE); + descriptor = desc; + }); + ASSERT_TRUE(ret.isOk()); + + ret = allocatorV4->allocate( + descriptor, 1u, + [&](android::hardware::graphics::mapper::V4_0::Error err, uint32_t /*stride*/, + const ::android::hardware::hidl_vec<::android::hardware::hidl_handle>& + buffers) { + ASSERT_EQ(android::hardware::graphics::mapper::V4_0::Error::NONE, err); + ASSERT_EQ(buffers.size(), 1u); + *buffer_handle = buffers[0]; + }); + ASSERT_TRUE(ret.isOk()); + } else if (mapperV3 != nullptr && allocatorV3 != nullptr) { android::hardware::graphics::mapper::V3_0::IMapper::BufferDescriptorInfo descriptorInfo {}; descriptorInfo.width = width; descriptorInfo.height = height; |