From patchwork Wed Mar 23 13:36:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 15517 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 D155EC0F1B for ; Wed, 23 Mar 2022 13:36:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 529AF6118A; Wed, 23 Mar 2022 14:36:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648042590; bh=mt2NjO5beNELiNjOzkMNAs3+1O7pEEsXNbhbqF3dxCU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=x4fREEsmghelKCgGbdiFuQxWQLHIxTpMuA2Sja2mukLFFVS2eT6DTC5PJht6SKQ5d E44kTftuG8VQwHZ7OxvulhW/84jsuqPesTWP2/jswofzE4fKK89NGaHxBwaI1nBZ/4 4a3P71k7b2f+9EQXqiOGHgYD24CY/DTTmY8LPSZ9Z7y/oxttHnjCZr6eTymnTbxPpQ ybyCImepBvbk5WSERzI7LeMRBXiGmcJojJZ/ZCT1gD8oEiXt87cyTmErlE+vCSxCBm P5uB9XJGRaAh70wB1F95ghub0aWazZUcDLbH+WS5UWM/jei3TfTsh/KOYOzB3SVqsn TNyvY4GjPW/rQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C80604DA for ; Wed, 23 Mar 2022 14:36:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NlSWJz7u"; dkim-atps=neutral Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:2e05:b10:1542:d51b]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D4A791856; Wed, 23 Mar 2022 14:36:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648042586; bh=mt2NjO5beNELiNjOzkMNAs3+1O7pEEsXNbhbqF3dxCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NlSWJz7uhF9xGE806CgNu66B2R1I0yHPdosPBN57tWuC4b0P2fG3YtjwHm9QvWhkH 8a8sFpe0kLZQ0YAFIkq+sYRRZFTAl1+nQOLd9ZxATVqNzWb3xaz3sNd7Zh9YIgqUmF u6ZwoGUJ8bN41CigbS4cs0Pjhb0zgIJgDKrDuUyQ= To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Mar 2022 14:36:22 +0100 Message-Id: <20220323133622.61593-4-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220323133622.61593-1-jeanmichel.hautbois@ideasonboard.com> References: <20220323133622.61593-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/3] ipa: raspberrypi: Control the lens position X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jean-Michel Hautbois via libcamera-devel From: Jean-Michel Hautbois Reply-To: Jean-Michel Hautbois Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Now that the ancillary links are configured, we can use the CameraLens class and control the VCM through the IPA. For now, force a default value for the lens position, until the AF algorithm is introduced. Signed-off-by: Jean-Michel Hautbois --- src/ipa/raspberrypi/raspberrypi.cpp | 36 +++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 1bf4e270..2e862f37 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -108,6 +108,7 @@ private: void setMode(const IPACameraSensorInfo &sensorInfo); bool validateSensorControls(); bool validateIspControls(); + bool validateLensControls(); void queueRequest(const ControlList &controls); void returnEmbeddedBuffer(unsigned int bufferId); void prepareISP(const ipa::RPi::ISPConfig &data); @@ -132,6 +133,7 @@ private: ControlInfoMap sensorCtrls_; ControlInfoMap ispCtrls_; + ControlInfoMap lensCtrls_; ControlList libcameraMetadata_; /* Camera sensor params. */ @@ -342,13 +344,14 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const ipa::RPi::IPAConfig &ipaConfig, ControlList *controls) { - if (entityControls.size() != 2) { - LOG(IPARPI, Error) << "No ISP or sensor controls found."; + if (entityControls.size() != 3) { + LOG(IPARPI, Error) << "No ISP, lens or sensor controls found."; return -1; } sensorCtrls_ = entityControls.at(0); ispCtrls_ = entityControls.at(1); + lensCtrls_ = entityControls.at(2); if (!validateSensorControls()) { LOG(IPARPI, Error) << "Sensor control validation failed."; @@ -360,6 +363,10 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, return -1; } + if (!validateLensControls()) { + LOG(IPARPI, Error) << "Lens control validation failed."; + } + maxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get(); /* Setup a metadata ControlList to output metadata. */ @@ -578,6 +585,23 @@ bool IPARPi::validateIspControls() return true; } +bool IPARPi::validateLensControls() +{ + static const uint32_t ctrls[] = { + V4L2_CID_FOCUS_ABSOLUTE, + }; + + for (auto c : ctrls) { + if (lensCtrls_.find(c) == lensCtrls_.end()) { + LOG(IPARPI, Error) << "Unable to find lens control " + << utils::hex(c); + return false; + } + } + + return true; +} + /* * Converting between enums (used in the libcamera API) and the names that * we use to identify different modes. Unfortunately, the conversion tables @@ -1066,6 +1090,14 @@ void IPARPi::processStats(unsigned int bufferId) setDelayedControls.emit(ctrls); } + + struct FocusStatus focusStatus; + if (rpiMetadata_.Get("af.status", focusStatus) == 0) { + ControlList lensCtrls(lensCtrls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + static_cast(focusStatus.focus)); + setLensControls.emit(lensCtrls); + } } void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)