[{"id":18864,"web_url":"https://patchwork.libcamera.org/comment/18864/","msgid":"<21189f93-10d7-d055-4b48-4c3e4cc01481@ideasonboard.com>","date":"2021-08-17T08:27:53","subject":"Re: [libcamera-devel] [IPU3-IPA PATCH] ipu3: Initialise controls in\n\tthe IPA","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Kieran,\n\nLooks like I missed this email :(\n\nOn 8/13/21 7:52 PM, Kieran Bingham wrote:\n> In commit 11fe4333c54d (\"libcamera: ipu3: Initialize controls in the\n> IPA\") the interface for the IPA was updated and the creation of exposure\n> and frame duration controls are now the responsibility of the IPA.\n>\n> In libcamera, the code that creates these controls was moved to the\n> integrated IPA for the IPU3.\n>\n> Duplicate the implementation here.\n>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nAcked-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   ipu3.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--\n>   1 file changed, 56 insertions(+), 2 deletions(-)\n>\n> diff --git a/ipu3.cpp b/ipu3.cpp\n> index b8015af20454..3e89e6dd4e02 100644\n> --- a/ipu3.cpp\n> +++ b/ipu3.cpp\n> @@ -36,7 +36,10 @@ namespace ipa::ipu3 {\n>   class IPAIPU3 : public IPAIPU3Interface\n>   {\n>   public:\n> -\tint init(const IPASettings &settings) override;\n> +\tint init(const IPASettings &settings,\n> +\t\t const IPACameraSensorInfo &sensorInfo,\n> +\t\t const ControlInfoMap &sensorControls,\n> +\t\t ControlInfoMap *ipaControls) override;\n>   \n>   \tint start() override;\n>   \tvoid stop() override {}\n> @@ -83,7 +86,10 @@ private:\n>   \tBinaryData aiqd_;\n>   };\n>   \n> -int IPAIPU3::init(const IPASettings &settings)\n> +int IPAIPU3::init(const IPASettings &settings,\n> +\t\t  const IPACameraSensorInfo &sensorInfo,\n> +\t\t  const ControlInfoMap &sensorControls,\n> +\t\t  ControlInfoMap *ipaControls)\n>   {\n>   \tint ret;\n>   \n> @@ -135,6 +141,54 @@ int IPAIPU3::init(const IPASettings &settings)\n>   \n>   \taiqInputParams_.init();\n>   \n> +\t/* Initialize Controls. */\n> +\tControlInfoMap::Map controls{};\n> +\n> +\t/*\n> +\t * Compute exposure time limits.\n> +\t *\n> +\t * Initialize the control using the line length and pixel rate of the\n> +\t * current configuration converted to microseconds. Use the\n> +\t * V4L2_CID_EXPOSURE control to get exposure min, max and default and\n> +\t * convert it from lines to microseconds.\n> +\t */\n> +\tdouble lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);\n> +\tconst ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;\n> +\tint32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;\n> +\tint32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;\n> +\tint32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;\n> +\tcontrols[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,\n> +\t\t\t\t\t\t\tdefExposure);\n> +\n> +\t/*\n> +\t * Compute the frame duration limits.\n> +\t *\n> +\t * The frame length is computed assuming a fixed line length combined\n> +\t * with the vertical frame sizes.\n> +\t */\n> +\tconst ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second;\n> +\tuint32_t hblank = v4l2HBlank.def().get<int32_t>();\n> +\tuint32_t lineLength = sensorInfo.outputSize.width + hblank;\n> +\n> +\tconst ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second;\n> +\tstd::array<uint32_t, 3> frameHeights{\n> +\t\tv4l2VBlank.min().get<int32_t>() + sensorInfo.outputSize.height,\n> +\t\tv4l2VBlank.max().get<int32_t>() + sensorInfo.outputSize.height,\n> +\t\tv4l2VBlank.def().get<int32_t>() + sensorInfo.outputSize.height,\n> +\t};\n> +\n> +\tstd::array<int64_t, 3> frameDurations;\n> +\tfor (unsigned int i = 0; i < frameHeights.size(); ++i) {\n> +\t\tuint64_t frameSize = lineLength * frameHeights[i];\n> +\t\tframeDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);\n> +\t}\n> +\n> +\tcontrols[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],\n> +\t\t\t\t\t\t\t       frameDurations[1],\n> +\t\t\t\t\t\t\t       frameDurations[2]);\n> +\n> +\t*ipaControls = ControlInfoMap(std::move(controls), controls::controls);\n> +\n>   \treturn 0;\n>   }\n>","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 C6DFEBD87D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 Aug 2021 08:27:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 13D5D688A5;\n\tTue, 17 Aug 2021 10:27:59 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 06CD468886\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Aug 2021 10:27:57 +0200 (CEST)","from [192.168.1.104] (unknown [103.238.109.15])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A3292C5;\n\tTue, 17 Aug 2021 10:27:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Z+rzrFrP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629188876;\n\tbh=W0DlXTTcO3HYrBmMEJpWrwq0uZpf1oP9EcOYZD6onxA=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=Z+rzrFrPvIb/8IrDMOz0i5rxrPnCjE4DH4dcW/uAfcroU9RFrIQeACt0rykk43511\n\tfCRaKGZbzH7x2wrv1fjaEwR4/FsqLvORqf3GWHwZkCzZFFqXbZP5SXVy6MW3W/48Ws\n\t88tV0A+dYYkxVty7EtDl/4XcXKdn5nxT36wray64=","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tlibcamera devel <libcamera-devel@lists.libcamera.org>","References":"<20210813142218.3521879-1-kieran.bingham@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<21189f93-10d7-d055-4b48-4c3e4cc01481@ideasonboard.com>","Date":"Tue, 17 Aug 2021 13:57:53 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.10.2","MIME-Version":"1.0","In-Reply-To":"<20210813142218.3521879-1-kieran.bingham@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [IPU3-IPA PATCH] ipu3: Initialise controls in\n\tthe IPA","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]