From patchwork Thu Jan 21 17:46:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 10938 X-Patchwork-Delegate: jacopo@jmondi.org 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 C5FADC0F2A for ; Thu, 21 Jan 2021 17:46:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BD2756820A; Thu, 21 Jan 2021 18:46:44 +0100 (CET) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A11C468206 for ; Thu, 21 Jan 2021 18:46:42 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 6E17CFF80E for ; Thu, 21 Jan 2021 17:46:42 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 21 Jan 2021 18:46:30 +0100 Message-Id: <20210121174633.382334-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210121174633.382334-1-jacopo@jmondi.org> References: <20210121174633.382334-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] libcamera: ipu3: Register FrameDurations control 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Register the FrameDurations control in the IPU3 pipeline handler computed using the vertical blanking limits and the current configuration pixel rate as parameters. The FrameDurations control limits should be updated everytime a new configuration is applied to the sensor. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 35 +++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 329b9d51cf1b..50b03008c0fb 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -754,6 +754,7 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) return ret; ControlInfoMap::Map controls = IPU3Controls; + const ControlInfoMap &sensorControls = sensor->controls(); /* * Compute exposure time limits. @@ -766,7 +767,6 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) */ double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6f); - const ControlInfoMap &sensorControls = sensor->controls(); const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; int32_t minExposure = v4l2Exposure.min().get() * lineDuration; int32_t maxExposure = v4l2Exposure.max().get() * lineDuration; @@ -781,6 +781,39 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure, defExposure); + /* + * Compute the frame duration limits. + * + * \todo The frame duration limits depend on the sensor configuration. + * Initialize the control using the frame sizes and pixel rate of the + * current configuration. + * + * The frame length is computed assuming a fixed line length combined + * with the vertical frame sizes. + */ + const ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second; + uint32_t hblank = v4l2HBlank.def().get(); + uint32_t lineLength = sensorInfo.outputSize.width + hblank; + + const ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second; + std::array frameHeights{ + (v4l2VBlank.min().get() + sensorInfo.outputSize.height), + (v4l2VBlank.max().get() + sensorInfo.outputSize.height), + (v4l2VBlank.def().get() + sensorInfo.outputSize.height), + }; + + std::vector frameDurations; + frameDurations.reserve(3); + std::transform(frameHeights.begin(), frameHeights.end(), + std::back_inserter(frameDurations), + [&](int32_t frameHeight) { + int64_t frameSize = lineLength * frameHeight; + return frameSize / (sensorInfo.pixelRate / 1000000U); + }); + controls[&controls::FrameDurations] = ControlInfo(frameDurations[0], + frameDurations[1], + frameDurations[2]); + /* * Compute the scaler crop limits. *