Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bdc4eebc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update EVS VTS test case" into sc-dev

parents cee75918 97d1039d
Loading
Loading
Loading
Loading
+70 −45
Original line number Diff line number Diff line
@@ -2269,12 +2269,41 @@ TEST_P(EvsHidlTest, CameraStreamExternalBuffering) {

    // Acquire the graphics buffer allocator
    android::GraphicBufferAllocator& alloc(android::GraphicBufferAllocator::get());
    const auto usage = GRALLOC_USAGE_HW_TEXTURE |
                       GRALLOC_USAGE_SW_READ_RARELY |
                       GRALLOC_USAGE_SW_WRITE_OFTEN;
    const auto usage =
            GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_SW_READ_RARELY | GRALLOC_USAGE_SW_WRITE_OFTEN;
    const auto format = HAL_PIXEL_FORMAT_RGBA_8888;
    const auto width = 640;
    const auto height = 360;
    uint32_t width = 640;
    uint32_t height = 360;
    camera_metadata_entry_t streamCfgs;

    // Test each reported camera
    for (auto&& cam : cameraInfo) {
        bool foundCfg = false;
        if (!find_camera_metadata_entry(reinterpret_cast<camera_metadata_t*>(cam.metadata.data()),
                                        ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
                                        &streamCfgs)) {
            // Stream configurations are found in metadata
            RawStreamConfig* ptr = reinterpret_cast<RawStreamConfig*>(streamCfgs.data.i32);

            LOG(DEBUG) << __LINE__ << " start searching " << streamCfgs.count;
            for (unsigned idx = 0; idx < streamCfgs.count; idx++) {
                LOG(DEBUG) << "ptr->direction= " << ptr->direction
                           << " ptr->format= " << ptr->format;
                if (ptr->direction == ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT &&
                    ptr->format == HAL_PIXEL_FORMAT_RGBA_8888) {
                    width = ptr->width;
                    height = ptr->height;
                    foundCfg = true;
                    // Always use the 1st available configuration
                    break;
                }
                ++ptr;
            }
        }

        if (!foundCfg) {
            LOG(INFO) << "No configuration found. Use default stream configurations.";
        }

        // Allocate buffers to use
        hidl_vec<BufferDesc> buffers;
@@ -2282,17 +2311,16 @@ TEST_P(EvsHidlTest, CameraStreamExternalBuffering) {
        for (auto i = 0; i < kBuffersToHold; ++i) {
            unsigned pixelsPerLine;
            buffer_handle_t memHandle = nullptr;
        android::status_t result = alloc.allocate(width,
                                                  height,
                                                  format,
                                                  1,
                                                  usage,
                                                  &memHandle,
                                                  &pixelsPerLine,
                                                  0,
                                                  "EvsApp");
            android::status_t result =
                    alloc.allocate(width, height, format, 1, usage, &memHandle, &pixelsPerLine, 0,
                                   "CameraStreamExternalBufferingTest");
            if (result != android::NO_ERROR) {
                LOG(ERROR) << __FUNCTION__ << " failed to allocate memory.";
                // Release previous allocated buffers
                for (auto j = 0; j < i; j++) {
                    alloc.free(buffers[i].buffer.nativeHandle);
                }
                return;
            } else {
                BufferDesc buf;
                AHardwareBuffer_Desc* pDesc =
@@ -2309,8 +2337,6 @@ TEST_P(EvsHidlTest, CameraStreamExternalBuffering) {
            }
        }

    // Test each reported camera
    for (auto&& cam: cameraInfo) {
        bool isLogicalCam = false;
        getPhysicalCameraIds(cam.v1.cameraId, isLogicalCam);

@@ -2374,14 +2400,13 @@ TEST_P(EvsHidlTest, CameraStreamExternalBuffering) {
        // Explicitly release the camera
        pEnumerator->closeCamera(pCam);
        activeCameras.clear();
    }

        // Release buffers
        for (auto& b : buffers) {
            alloc.free(b.buffer.nativeHandle);
        }
        buffers.resize(0);
    }
}


/*