From patchwork Thu Apr 21 09:53:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunke Cao X-Patchwork-Id: 15696 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 54604C0F1B for ; Thu, 21 Apr 2022 09:53:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8A50665646; Thu, 21 Apr 2022 11:53:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1650534821; bh=ouWoPtX3SoW1qnwMdzIIoQAkFwRLeKv59jj9/+2VY3I=; h=Date:In-Reply-To:References:To:List-Id:List-Post:From:Cc: List-Subscribe:List-Unsubscribe:List-Archive:Reply-To:List-Help: Subject:From; b=Z9NQD7Gu8S18EsTizYv/Q2lP7XZqzW8l18uqzAo8sj0KHxPhZIfWbVJclmAeRrhFM VfhazD84sDnnv/tuNcoLXxZoVIMMb93arXZl5ostWjGF+12HTHREbuH5nLLWTMVYeJ DmWn9nowgfZ/lyU/ixdr8/5AXO7FHZ5qHDKZglk/oErirxLAs4LVzHztcT8IvkUZwL 1GQOqWGQf4Z8HEZAmnWSfN+gleStOWuyr0n/d8uP2tltTDm/zUrNhwfv30xMhlHaQG XH64mRd1efzVJTHpavkUSMuWS8i/CCShBpKAqMjAEfXb6zNzI7BoWZ2oyQn2dKt+7W rWm51AX766/YA== Date: Thu, 21 Apr 2022 18:53:20 +0900 In-Reply-To: <165052542462.3002092.9959330002688816513@Monstersaurus> References: <165052542462.3002092.9959330002688816513@Monstersaurus> To: Han-lin Chen , Kieran Bingham MIME-Version: 1.0 Message-ID: List-Id: List-Post: X-Patchwork-Original-From: Yunke Cao via libcamera-devel From: Yunke Cao Precedence: list Cc: Tomasz Figa , libcamera-devel@lists.libcamera.org, Yunke Cao X-Mailman-Version: 2.1.29 X-BeenThere: libcamera-devel@lists.libcamera.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Yunke Cao List-Help: Subject: [libcamera-devel] [PATCH v2] libcamera: Test sensor's ability to discover ancillary devices Content-Disposition: inline Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use vimc lens to test sensor's ability to discover ancillary lens. Tested with/without 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: Kieran Bingham Reviewed-by: Laurent Pinchart --- Changelog since v1: - Dont fail test when lens is not present. - Remove lens from dm. - Tested on both kernels with/without the vimc lens patch. src/libcamera/camera_sensor.cpp | 5 +++++ test/camera-sensor.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index eaa2da6b..fe366267 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -152,6 +152,11 @@ int CameraSensor::init() */ if (entity_->device()->driver() == "vimc") { initVimcDefaultProperties(); + + ret = discoverAncillaryDevices(); + if (ret) + return ret; + return initProperties(); } diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 372ee4af..d1bb639a 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,11 @@ protected: return TestFail; } + lens_ = sensor_->focusLens(); + if (lens_) { + cout << "Found lens" << endl; + } + return TestPass; } @@ -104,6 +110,11 @@ protected: return TestFail; } + if (lens_ && lens_->setFocusPosition(10)) { + cerr << "Failed to set lens focus position" << endl; + return TestFail; + } + return TestPass; } @@ -116,6 +127,7 @@ private: std::unique_ptr enumerator_; std::shared_ptr media_; CameraSensor *sensor_; + CameraLens *lens_; }; TEST_REGISTER(CameraSensorTest)