From patchwork Mon Apr 25 02:00:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunke Cao X-Patchwork-Id: 15702 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 2EB9BC3256 for ; Mon, 25 Apr 2022 02:00:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8160865644; Mon, 25 Apr 2022 04:00:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1650852020; bh=QTCLp3mbuO0AqiijOHApKHBdsutZ//f9rEpf+4PM3zs=; 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=bJLdHM3YZdFhEG9BDUr7PYDi951pZa39Ui4454+Vtizqenb0YmT4kPiuBRL1YiZOx nWpHSKC/hTo4GdzX39lkNC9p1/dKPsLk+o4swoh5AoewpZ+3qe2phV7XbzkHfvFHQP schKP7coHBxs/HtHUZHoHzQmsUXyQ6ASv2/dHthG228Jaqink/M8JnPm8K3XiFr5eQ M700InoJrnY51EOIcOozIfOXv2zXWkGesl/ZdmOUxz5QJ6sYGEf2K7wJp1cUl/qIIu GS9jwXi2lbjTiHQre+dszBDzjVjvoOYqZtNFG2XadHKohj9Xp0zcSAUro4Tyi0hBZ2 RK7PelCE9m0zg== Date: Mon, 25 Apr 2022 11:00:11 +0900 In-Reply-To: References: To: 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 v3] 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 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 | 12 ++++++++++++ 2 files changed, 18 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..4473ca19 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 controller" << 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)