From b8524954e6c0ac4dae2083c8778426a406cdc1fe Mon Sep 17 00:00:00 2001 From: Emil Jahshan Date: Sun, 27 Jan 2019 11:56:25 +0200 Subject: [PATCH] VTS tests to work with depth Y16 modified VTS tests functions to work with the Y16 format with the correct dataspace. Y16 changes are in this patch: 847192 Test: ran and tested on intel depth camera D415 and a regular RGB camera Change-Id: Ie40347d58d4f72ed2fc9676bdaab2d1dca5dc5bc Signed-off-by: Emil Jahshan --- .../VtsHalCameraProviderV2_4TargetTest.cpp | 129 +++++++++++++++--- 1 file changed, 109 insertions(+), 20 deletions(-) diff --git a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp index 22b738256d..2a464d58fb 100644 --- a/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp +++ b/camera/provider/2.4/vts/functional/VtsHalCameraProviderV2_4TargetTest.cpp @@ -671,6 +671,7 @@ public: HalStreamConfiguration *halStreamConfig /*out*/, bool *supportsPartialResults /*out*/, uint32_t *partialResultCount /*out*/); + bool isDepthOnly(camera_metadata_t* staticMeta); static Status getAvailableOutputStreams(camera_metadata_t *staticMeta, std::vector &outputStreams, const AvailableStream *threshold = nullptr); @@ -682,6 +683,10 @@ public: std::unordered_set *physicalIds/*out*/); static Status getSupportedKeys(camera_metadata_t *staticMeta, uint32_t tagId, std::unordered_set *requestIDs/*out*/); + static void fillOutputStreams(camera_metadata_ro_entry_t* entry, + std::vector& outputStreams, + const AvailableStream *threshold = nullptr, + const int32_t availableConfigOutputTag = 0u); static void constructFilteredSettings(const sp& session, const std::unordered_set& availableKeys, RequestTemplate reqTemplate, android::hardware::camera::common::V1_0::helper::CameraMetadata* defaultSettings/*out*/, @@ -2521,14 +2526,24 @@ TEST_F(CameraHidlTest, configureStreamsAvailableOutputs) { int32_t streamId = 0; for (auto& it : outputStreams) { V3_2::Stream stream3_2; - bool isJpeg = static_cast(it.format) == PixelFormat::BLOB; + V3_2::DataspaceFlags dataspaceFlag = 0; + switch (static_cast(it.format)) { + case PixelFormat::BLOB: + dataspaceFlag = static_cast(Dataspace::V0_JFIF); + break; + case PixelFormat::Y16: + dataspaceFlag = static_cast(Dataspace::DEPTH); + break; + default: + dataspaceFlag = static_cast(Dataspace::UNKNOWN); + } stream3_2 = {streamId, StreamType::OUTPUT, static_cast(it.width), static_cast(it.height), static_cast(it.format), GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, - (isJpeg) ? static_cast(Dataspace::V0_JFIF) : 0, + dataspaceFlag, StreamRotation::ROTATION_0}; ::android::hardware::hidl_vec streams3_2 = {stream3_2}; ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4; @@ -2962,6 +2977,14 @@ TEST_F(CameraHidlTest, configureStreamsPreviewStillOutputs) { openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/); castSession(session, deviceVersion, &session3_3, &session3_4); + // Check if camera support depth only + if (isDepthOnly(staticMeta)) { + free_camera_metadata(staticMeta); + ret = session->close(); + ASSERT_TRUE(ret.isOk()); + continue; + } + outputBlobStreams.clear(); ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputBlobStreams, @@ -3230,6 +3253,14 @@ TEST_F(CameraHidlTest, configureStreamsVideoStillOutputs) { openEmptyDeviceSession(name, mProvider, &session /*out*/, &staticMeta /*out*/); castSession(session, deviceVersion, &session3_3, &session3_4); + // Check if camera support depth only + if (isDepthOnly(staticMeta)) { + free_camera_metadata(staticMeta); + ret = session->close(); + ASSERT_TRUE(ret.isOk()); + continue; + } + outputBlobStreams.clear(); ASSERT_EQ(Status::OK, getAvailableOutputStreams(staticMeta, outputBlobStreams, @@ -4135,38 +4166,56 @@ TEST_F(CameraHidlTest, flushEmpty) { Status CameraHidlTest::getAvailableOutputStreams(camera_metadata_t *staticMeta, std::vector &outputStreams, const AvailableStream *threshold) { + AvailableStream depthPreviewThreshold = {kMaxPreviewWidth, kMaxPreviewHeight, + static_cast(PixelFormat::Y16)}; if (nullptr == staticMeta) { return Status::ILLEGAL_ARGUMENT; } - camera_metadata_ro_entry entry; - int rc = find_camera_metadata_ro_entry(staticMeta, - ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, &entry); - if ((0 != rc) || (0 != (entry.count % 4))) { + camera_metadata_ro_entry scalarEntry; + camera_metadata_ro_entry depthEntry; + int foundScalar = find_camera_metadata_ro_entry(staticMeta, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, &scalarEntry); + int foundDepth = find_camera_metadata_ro_entry(staticMeta, + ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, &depthEntry); + if ((0 != foundScalar || (0 != (scalarEntry.count % 4))) && + (0 != foundDepth || (0 != (depthEntry.count % 4)))) { return Status::ILLEGAL_ARGUMENT; } - for (size_t i = 0; i < entry.count; i+=4) { - if (ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT == - entry.data.i32[i + 3]) { + if(foundScalar == 0 && (0 == (scalarEntry.count % 4))) { + fillOutputStreams(&scalarEntry, outputStreams, threshold, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT); + } + + if(foundDepth == 0 && (0 == (depthEntry.count % 4))) { + fillOutputStreams(&depthEntry, outputStreams, &depthPreviewThreshold, + ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS_OUTPUT); + } + + return Status::OK; +} + +void CameraHidlTest::fillOutputStreams(camera_metadata_ro_entry_t* entry, + std::vector& outputStreams, const AvailableStream* threshold, + const int32_t availableConfigOutputTag) { + for (size_t i = 0; i < entry->count; i+=4) { + if (availableConfigOutputTag == entry->data.i32[i + 3]) { if(nullptr == threshold) { - AvailableStream s = {entry.data.i32[i+1], - entry.data.i32[i+2], entry.data.i32[i]}; + AvailableStream s = {entry->data.i32[i+1], + entry->data.i32[i+2], entry->data.i32[i]}; outputStreams.push_back(s); } else { - if ((threshold->format == entry.data.i32[i]) && - (threshold->width >= entry.data.i32[i+1]) && - (threshold->height >= entry.data.i32[i+2])) { - AvailableStream s = {entry.data.i32[i+1], - entry.data.i32[i+2], threshold->format}; + if ((threshold->format == entry->data.i32[i]) && + (threshold->width >= entry->data.i32[i+1]) && + (threshold->height >= entry->data.i32[i+2])) { + AvailableStream s = {entry->data.i32[i+1], + entry->data.i32[i+2], threshold->format}; outputStreams.push_back(s); } } } - } - - return Status::OK; } // Get max jpeg buffer size in android.jpeg.maxSize @@ -4563,6 +4612,37 @@ void CameraHidlTest::configurePreviewStreams3_4(const std::string &name, int32_t ASSERT_TRUE(ret.isOk()); } +bool CameraHidlTest::isDepthOnly(camera_metadata_t* staticMeta) { + camera_metadata_ro_entry scalarEntry; + camera_metadata_ro_entry depthEntry; + + int rc = find_camera_metadata_ro_entry( + staticMeta, ANDROID_REQUEST_AVAILABLE_CAPABILITIES, &scalarEntry); + if (rc == 0) { + for (uint32_t i = 0; i < scalarEntry.count; i++) { + if (scalarEntry.data.u8[i] == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE) { + return false; + } + } + } + + for (uint32_t i = 0; i < scalarEntry.count; i++) { + if (scalarEntry.data.u8[i] == ANDROID_REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT) { + + rc = find_camera_metadata_ro_entry( + staticMeta, ANDROID_DEPTH_AVAILABLE_DEPTH_STREAM_CONFIGURATIONS, &depthEntry); + size_t i = 0; + if (rc == 0 && depthEntry.data.i32[i] == static_cast(PixelFormat::Y16)) { + // only Depth16 format is supported now + return true; + } + break; + } + } + + return false; +} + // Open a device session and configure a preview stream. void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t deviceVersion, sp provider, @@ -4638,11 +4718,20 @@ void CameraHidlTest::configurePreviewStream(const std::string &name, int32_t dev ASSERT_EQ(Status::OK, rc); ASSERT_FALSE(outputPreviewStreams.empty()); + V3_2::DataspaceFlags dataspaceFlag = 0; + switch (static_cast(outputPreviewStreams[0].format)) { + case PixelFormat::Y16: + dataspaceFlag = static_cast(Dataspace::DEPTH); + break; + default: + dataspaceFlag = static_cast(Dataspace::UNKNOWN); + } + V3_2::Stream stream3_2 = {0, StreamType::OUTPUT, static_cast (outputPreviewStreams[0].width), static_cast (outputPreviewStreams[0].height), static_cast (outputPreviewStreams[0].format), - GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, 0, StreamRotation::ROTATION_0}; + GRALLOC1_CONSUMER_USAGE_HWCOMPOSER, dataspaceFlag, StreamRotation::ROTATION_0}; ::android::hardware::hidl_vec streams3_2 = {stream3_2}; ::android::hardware::camera::device::V3_2::StreamConfiguration config3_2; ::android::hardware::camera::device::V3_4::StreamConfiguration config3_4;