From patchwork Thu Dec 1 14:51:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 17932 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 2E549BE08B for ; Thu, 1 Dec 2022 14:52:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 001366333F; Thu, 1 Dec 2022 15:52:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669906368; bh=/fb3lBrt+3qWxFcKDt5/FgOcDcBWLu/Xq10njz/52Bw=; 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=jFzlvI/6Ln8/yufVYuG7v1qRT9bwngJwcUAT+XCcOzUx9lAWbSjgzEAESpY0nP1F8 B4k009BDPG72mNSS78ozuVfy/+aLKRsPhrtEY3/7/lHMkFPVqCLtUoba9IlyfqMZgA CPUY6b9e3UETEu7bdyeHS7xz3WenXUUdbnT1EUPPrqrBEGKpoFPOLpMLKE3Gnzuyow +/XOmLa/i0KuhyTqxa0CToYRPhBw7ZMwq15W07LH2jc6LyGKzd7TC7puCKHnSfUs9z xz4WZAfuifTsQyxmZsMc5sU4YXfwxp/+hByxw3SnFAANhfSREzeCr3aQ4/Sxnmgz2i +5RF4d+S1f+kA== 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 BB0A663345 for ; Thu, 1 Dec 2022 15:52:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sBHAgOHA"; dkim-atps=neutral Received: from umang.jainideasonboard.com (unknown [210.186.188.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B09FC6D0; Thu, 1 Dec 2022 15:52:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1669906365; bh=/fb3lBrt+3qWxFcKDt5/FgOcDcBWLu/Xq10njz/52Bw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sBHAgOHALLz4XhNo/aHX/dWbhswV9AyuSYKPkZBs2IfX/FmpUYVHcovzYNK1yhHmY FFQm/LZTVrw+hbfIZqhzn0qFq11sRVJRNX4Q4jqDQ7XnPfCRcsRiw2Ja7lCw0XkfNe Mq+YV1JosMsB+/HrbUQiYCX9ZofepO8bYys9PJiY= To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Dec 2022 22:51:31 +0800 Message-Id: <20221201145133.479794-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201145133.479794-1-umang.jain@ideasonboard.com> References: <20221201145133.479794-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Jean-Michel Hautbois Now that the ancillary links are configured, we can use the CameraLens class and control the VCM through the IPA. Signed-off-by: Jean-Michel Hautbois --- src/ipa/raspberrypi/raspberrypi.cpp | 30 ++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 4e10c57d..3d1ac8fc 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -30,6 +30,7 @@ #include "libcamera/internal/mapped_framebuffer.h" +#include "af_status.h" #include "agc_algorithm.h" #include "agc_status.h" #include "alsc_status.h" @@ -131,6 +132,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 ISPConfig &data); @@ -155,6 +157,7 @@ private: ControlInfoMap sensorCtrls_; ControlInfoMap ispCtrls_; + ControlInfoMap lensCtrls_; ControlList libcameraMetadata_; /* Camera sensor params. */ @@ -381,7 +384,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ipaConfig, ControlList *controls, IPAConfigResult *result) { - if (entityControls.size() != 2) { + if (entityControls.size() < 2) { LOG(IPARPI, Error) << "No ISP or sensor controls found."; return -1; } @@ -389,6 +392,14 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, sensorCtrls_ = entityControls.at(0); ispCtrls_ = entityControls.at(1); + /* Lens may not be present, don't make it an hard assumption. */ + auto lensControl = entityControls.find(2); + if (lensControl != entityControls.end()) { + lensCtrls_ = lensControl->second; + if (!validateLensControls()) + LOG(IPARPI, Error) << "Lens control validation failed."; + } + if (!validateSensorControls()) { LOG(IPARPI, Error) << "Sensor control validation failed."; return -1; @@ -650,6 +661,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