{"id":15529,"url":"https://patchwork.libcamera.org/api/1.1/patches/15529/?format=json","web_url":"https://patchwork.libcamera.org/patch/15529/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220323160145.90606-5-jeanmichel.hautbois@ideasonboard.com>","date":"2022-03-23T16:01:45","name":"[libcamera-devel,RFC,v2,4/4] ipa: raspberrypi: Control the lens position","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"7b0243b7c15718aa0c50c43719e4ea85c476e40c","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/1.1/people/75/?format=json","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15529/mbox/","series":[{"id":2991,"url":"https://patchwork.libcamera.org/api/1.1/series/2991/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2991","date":"2022-03-23T16:01:41","name":"RPi: Introduce AF algorithm","version":2,"mbox":"https://patchwork.libcamera.org/series/2991/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15529/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15529/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 984B2C3265\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Mar 2022 16:01:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DB4A610F8;\n\tWed, 23 Mar 2022 17:01:55 +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 26AD0604DB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Mar 2022 17:01:50 +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 D43CAFFD;\n\tWed, 23 Mar 2022 17:01:49 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648051315;\n\tbh=veCQMbxbFw2w3L45sYunZOtpe4x5G1w83ycREIJOKzg=;\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=drbje7l2F/oLLKWY+QeJZ55ZYsoyBPp041qH1YvbIkUqRhwDkXv/xGnHEmCO9t0v/\n\tvqlKdQChuIqGVxeqUkZISpWEtelSiZjGlJJquuVOlp7afH5JB+pyUr6asHtMPtvxU8\n\tPRQsUB9p+xy0xsGf06zMuBj3+XA4Qw7KHosj0HXV2irUB5s5Z9Z6TfoFyOavq1ERDA\n\tjqoI9A3wdYVGFAkIjMGsPI/yNbaUj0fXe2L1sQ9YCMTysctdCqHk5HjdbyNegD4FAC\n\tRabIZ37Y/IGnyJqFze/LPhf09I5CgTu3KypKG5PXsX0LF5z1kGT75/Fm7Yd/oJRrpE\n\tye947dAxhR5XA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1648051309;\n\tbh=veCQMbxbFw2w3L45sYunZOtpe4x5G1w83ycREIJOKzg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OFwPHCcPA6dXugMKATkkVp8KdSFKfAuK892CQJe452aAlfxfATNUzm/JmVyh6qSRw\n\tGLJ0BUyC78s283QdLVf+Wek+sKUqzntRF1OwIDj3usa6k/idULpO203ScJU+AsuL/V\n\tW+GIja56lnBOWkmedXdi2aoga5e70JnZfFPkU+H4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OFwPHCcP\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 23 Mar 2022 17:01:45 +0100","Message-Id":"<20220323160145.90606-5-jeanmichel.hautbois@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20220323160145.90606-1-jeanmichel.hautbois@ideasonboard.com>","References":"<20220323160145.90606-1-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH v2 4/4] 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---\nv2: Change the need for lens control to be present\n---\n src/ipa/raspberrypi/raspberrypi.cpp | 42 ++++++++++++++++++++++++++++-\n 1 file changed, 41 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex cf4e6cab..ff302e37 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -30,6 +30,7 @@\n \n #include \"libcamera/internal/mapped_framebuffer.h\"\n \n+#include \"af_status.h\"\n #include \"agc_algorithm.hpp\"\n #include \"agc_status.h\"\n #include \"alsc_status.h\"\n@@ -110,6 +111,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 ISPConfig &data);\n@@ -134,6 +136,7 @@ private:\n \n \tControlInfoMap sensorCtrls_;\n \tControlInfoMap ispCtrls_;\n+\tControlInfoMap lensCtrls_;\n \tControlList libcameraMetadata_;\n \n \t/* Camera sensor params. */\n@@ -344,7 +347,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n \t\t      const IPAConfig &ipaConfig,\n \t\t      ControlList *controls)\n {\n-\tif (entityControls.size() != 2) {\n+\tif (entityControls.size() < 2) {\n \t\tLOG(IPARPI, Error) << \"No ISP or sensor controls found.\";\n \t\treturn -1;\n \t}\n@@ -352,6 +355,14 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo,\n \tsensorCtrls_ = entityControls.at(0);\n \tispCtrls_ = entityControls.at(1);\n \n+\t/* Lens may not be present, don't make it an hard assumption. */\n+\tauto lensControl = entityControls.find(2);\n+\tif (lensControl != entityControls.end()) {\n+\t\tlensCtrls_ = lensControl->second;\n+\t\tif (!validateLensControls())\n+\t\t\tLOG(IPARPI, Error) << \"Lens control validation failed.\";\n+\t}\n+\n \tif (!validateSensorControls()) {\n \t\tLOG(IPARPI, Error) << \"Sensor control validation failed.\";\n \t\treturn -1;\n@@ -362,6 +373,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@@ -580,6 +595,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@@ -1068,6 +1100,14 @@ void IPARPi::processStats(unsigned int bufferId)\n \n \t\tsetDelayedControls.emit(ctrls);\n \t}\n+\n+\tstruct AfStatus afStatus;\n+\tif (rpiMetadata_.Get(\"af.status\", afStatus) == 0) {\n+\t\tControlList lensCtrls(lensCtrls_);\n+\t\tlensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,\n+\t\t\t      static_cast<int32_t>(afStatus.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","v2","4/4"]}