From 3d612720fb99057f10e21d2069aacdfbbf0f05d1 Mon Sep 17 00:00:00 2001 From: Yunke Cao Date: Mon, 25 Apr 2022 18:27:10 +0900 Subject: libcamera: Test sensor's ability to discover ancillary devices Use vimc lens to test sensor's ability to discover ancillary lens. Tested with the recent kernel patch for vimc lens: https://lore.kernel.org/linux-media/20220415023855.2568366-1-yunkec@google.com/ Signed-off-by: Yunke Cao Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/libcamera/camera_sensor.cpp | 7 ++++++- test/camera-sensor.cpp | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ea373458..ae3127d6 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -152,7 +152,12 @@ int CameraSensor::init() */ if (entity_->device()->driver() == "vimc") { initVimcDefaultProperties(); - return initProperties(); + + ret = initProperties(); + if (ret) + return ret; + + return discoverAncillaryDevices(); } /* Get the color filter array pattern (only for RAW sensors). */ diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index d3dcb510..2a17cc79 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -12,6 +12,7 @@ #include +#include "libcamera/internal/camera_lens.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" @@ -57,6 +58,10 @@ protected: return TestFail; } + lens_ = sensor_->focusLens(); + if (lens_) + cout << "Found lens controller" << endl; + return TestPass; } @@ -103,6 +108,11 @@ protected: return TestFail; } + if (lens_ && lens_->setFocusPosition(10)) { + cerr << "Failed to set lens focus position" << endl; + return TestFail; + } + return TestPass; } @@ -115,6 +125,7 @@ private: std::unique_ptr enumerator_; std::shared_ptr media_; CameraSensor *sensor_; + CameraLens *lens_; }; TEST_REGISTER(CameraSensorTest) -- cgit v1.2.1