{"id":15517,"url":"https://patchwork.libcamera.org/api/patches/15517/?format=json","web_url":"https://patchwork.libcamera.org/patch/15517/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220323133622.61593-4-jeanmichel.hautbois@ideasonboard.com>","date":"2022-03-23T13:36:22","name":"[libcamera-devel,RFC,3/3] ipa: raspberrypi: Control the lens position","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c52881398e8684b702dbcf66beff287202a01bb1","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15517/mbox/","series":[{"id":2988,"url":"https://patchwork.libcamera.org/api/series/2988/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2988","date":"2022-03-23T13:36:19","name":"RPi: Introduce AF algorithm","version":1,"mbox":"https://patchwork.libcamera.org/series/2988/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15517/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15517/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D155EC0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 13:36:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 529AF6118A;\n\tWed, 23 Mar 2022 14:36:30 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 27C80604DA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 14:36:27 +0100 (CET)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:2e05:b10:1542:d51b])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D4A791856;\n\tWed, 23 Mar 2022 14:36:26 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648042590;\n\tbh=mt2NjO5beNELiNjOzkMNAs3+1O7pEEsXNbhbqF3dxCU=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=x4fREEsmghelKCgGbdiFuQxWQLHIxTpMuA2Sja2mukLFFVS2eT6DTC5PJht6SKQ5d\n\tE44kTftuG8VQwHZ7OxvulhW/84jsuqPesTWP2/jswofzE4fKK89NGaHxBwaI1nBZ/4\n\t4a3P71k7b2f+9EQXqiOGHgYD24CY/DTTmY8LPSZ9Z7y/oxttHnjCZr6eTymnTbxPpQ\n\tybyCImepBvbk5WSERzI7LeMRBXiGmcJojJZ/ZCT1gD8oEiXt87cyTmErlE+vCSxCBm\n\tP5uB9XJGRaAh70wB1F95ghub0aWazZUcDLbH+WS5UWM/jei3TfTsh/KOYOzB3SVqsn\n\tTNyvY4GjPW/rQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648042586;\n\tbh=mt2NjO5beNELiNjOzkMNAs3+1O7pEEsXNbhbqF3dxCU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=NlSWJz7uhF9xGE806CgNu66B2R1I0yHPdosPBN57tWuC4b0P2fG3YtjwHm9QvWhkH\n\t8a8sFpe0kLZQ0YAFIkq+sYRRZFTAl1+nQOLd9ZxATVqNzWb3xaz3sNd7Zh9YIgqUmF\n\tu6ZwoGUJ8bN41CigbS4cs0Pjhb0zgIJgDKrDuUyQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"NlSWJz7u\"; dkim-atps=neutral","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 3/3] ipa: raspberrypi: Control the\n\tlens position","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Now that the ancillary links are configured, we can use the CameraLens\nclass and control the VCM through the IPA.\nFor now, force a default value for the lens position, until the AF\nalgorithm is introduced.\n\nSigned-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 36 +++++++++++++++++++++++++++--\n 1 file changed, 34 insertions(+), 2 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 1bf4e270..2e862f37 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -108,6 +108,7 @@ private:\n \tvoid setMode(const IPACameraSensorInfo &sensorInfo);\n \tbool validateSensorControls();\n \tbool validateIspControls();\n+\tbool validateLensControls();\n \tvoid queueRequest(const ControlList &controls);\n \tvoid returnEmbeddedBuffer(unsigned int bufferId);\n \tvoid prepareISP(const ipa::RPi::ISPConfig &data);\n@@ -132,6 +133,7 @@ private:\n \n \tControlInfoMap sensorCtrls_;\n \tControlInfoMap ispCtrls_;\n+\tControlInfoMap lensCtrls_;\n \tControlList libcameraMetadata_;\n \n \t/* Camera sensor params. */\n@@ -342,13 +344,14 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n \t\t      const ipa::RPi::IPAConfig &ipaConfig,\n \t\t      ControlList *controls)\n {\n-\tif (entityControls.size() != 2) {\n-\t\tLOG(IPARPI, Error) << \"No ISP or sensor controls found.\";\n+\tif (entityControls.size() != 3) {\n+\t\tLOG(IPARPI, Error) << \"No ISP, lens or sensor controls found.\";\n \t\treturn -1;\n \t}\n \n \tsensorCtrls_ = entityControls.at(0);\n \tispCtrls_ = entityControls.at(1);\n+\tlensCtrls_ = entityControls.at(2);\n \n \tif (!validateSensorControls()) {\n \t\tLOG(IPARPI, Error) << \"Sensor control validation failed.\";\n@@ -360,6 +363,10 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n \t\treturn -1;\n \t}\n \n+\tif (!validateLensControls()) {\n+\t\tLOG(IPARPI, Error) << \"Lens control validation failed.\";\n+\t}\n+\n \tmaxSensorGainCode_ = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN).max().get<int32_t>();\n \n \t/* Setup a metadata ControlList to output metadata. */\n@@ -578,6 +585,23 @@ bool IPARPi::validateIspControls()\n \treturn true;\n }\n \n+bool IPARPi::validateLensControls()\n+{\n+\tstatic const uint32_t ctrls[] = {\n+\t\tV4L2_CID_FOCUS_ABSOLUTE,\n+\t};\n+\n+\tfor (auto c : ctrls) {\n+\t\tif (lensCtrls_.find(c) == lensCtrls_.end()) {\n+\t\t\tLOG(IPARPI, Error) << \"Unable to find lens control \"\n+\t\t\t\t\t   << utils::hex(c);\n+\t\t\treturn false;\n+\t\t}\n+\t}\n+\n+\treturn true;\n+}\n+\n /*\n  * Converting between enums (used in the libcamera API) and the names that\n  * we use to identify different modes. Unfortunately, the conversion tables\n@@ -1066,6 +1090,14 @@ void IPARPi::processStats(unsigned int bufferId)\n \n \t\tsetDelayedControls.emit(ctrls);\n \t}\n+\n+\tstruct FocusStatus focusStatus;\n+\tif (rpiMetadata_.Get(\"af.status\", focusStatus) == 0) {\n+\t\tControlList lensCtrls(lensCtrls_);\n+\t\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,\n+\t\t\t      static_cast<int32_t>(focusStatus.focus));\n+\t\tsetLensControls.emit(lensCtrls);\n+\t}\n }\n \n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n","prefixes":["libcamera-devel","RFC","3/3"]}