From patchwork Mon Apr 25 09:27:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunke Cao X-Patchwork-Id: 15703 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 904F4C0F1B for ; Mon, 25 Apr 2022 09:27:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F00BA65643; Mon, 25 Apr 2022 11:27:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1650878840; bh=kMflx7Gr6wUz4iSWW6bqn2Rm8Ei4j3qXeXLz+xLKlyM=; 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=Vz+GMHryu+s1TMaxk+VYOBVsPwYXqLNDTW3c1GzK5QaQLHUKoS/AgM7o3SnrjbRdS GnO0XjKuGoicDMRAk7Nn8aQlr5SSQxCoHWY2GylW1BnGY0cxHyDEmu4zhakjbFdrDB fhw+nIyxsLFFcB+9UeJC2KAiEhSW3mv+/rDCzaGcJx9ed69XLSl+5J43M0iSHFNOBl 4b8SpTilK+pwQYtmy8mqbWhDoq0gYSs3Ggk+fXcTisDHH4ZBDfbu9uuOkGRbx9tBOt HdMbhwxZlllMvOapQ8HlxRbcMEeFY/V7hBrwQHnv89I8kNzyxR9N6Ch+1bTs8GziS9 TjVmmCuHbxnsA== Date: Mon, 25 Apr 2022 18:27:10 +0900 In-Reply-To: <368ddf73-1e8e-2009-2cd2-a85aae4a6a6e@ideasonboard.com> References: <368ddf73-1e8e-2009-2cd2-a85aae4a6a6e@ideasonboard.com> To: Kieran Bingham , Laurent Pinchart 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 v4] 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 the recent kernel patch for vimc lens: https://lore.kernel.org/linux-media/20220415023855.2568366-1-yunkec@google.com/ Signed-off-by: Yunke Cao --- Changelog since v3: - Remove unnecessary brace. Sorry! Kept forgetting this. Changelog since v2: - Flip the order of initProperties and discoverAncillaryDevices. - Fix log string. 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 | 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 eaa2da6b..c56b8a60 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 372ee4af..dc99ab33 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; } @@ -104,6 +109,11 @@ protected: return TestFail; } + if (lens_ && lens_->setFocusPosition(10)) { + cerr << "Failed to set lens focus position" << endl; + return TestFail; + } + return TestPass; } @@ -116,6 +126,7 @@ private: std::unique_ptr enumerator_; std::shared_ptr media_; CameraSensor *sensor_; + CameraLens *lens_; }; TEST_REGISTER(CameraSensorTest)