From patchwork Thu Oct 6 13:17:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17543 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 E906FBD16B for ; Thu, 6 Oct 2022 13:17:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9121562D05; Thu, 6 Oct 2022 15:17:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665062278; bh=DfzHQ0bZZY8QgmiGOX9cjtXd5ci7YtVJOuyas16zy9A=; 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=OfGA84Tqm1hRjLoKxzmNv87R4UK2BULjEhOwKqx8VyPv2RrqqlJYvBAs6V6aRUjNI gy3twsvvFFfQSBYysrpT4qKp0nGpaf2azRMd8sDtIejrwwPnR/wRqgOhy/IHVFZwXr bmxcVGkOrxZAc5rSaV740As17vbZq/+SzZhj6hv+ZqEbXocPamqeYFb0opTqLmSw7E MddrH5hIAt9zPIKkgpQ6FBbVJLsX5NPo21rXmt5PHmtVPH4TL+Dcvn1yUbxpIrzeWa 70K+0ZwXATHYT3fKH5tYdJ8E191pXM1GoVsYLG08/o7JCnUMz6LhHPBINp1wxuCpmZ 3NtXGWqeyhFPA== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F123062CF1 for ; Thu, 6 Oct 2022 15:17:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Lc93DDfi"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id bq9so2690640wrb.4 for ; Thu, 06 Oct 2022 06:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=tM2HZQgNPT7c6W3h2GI86+7wXtUs/IeSla0L7MdHmWA=; b=Lc93DDfiM925gVVxX9JXBk+WI2vnXLKZfPMMl6633tfvypS87nxrP9yMeEmBJnQEPr aU0gXmBIFoKlMQ0YF0IoXiImN2Eb0dlwy4DLUJQtLlVtmiodoQ/WRflmVCu8Fwktlf2f sotMJFElMkS2v0KHWbS/SiMduFQWRFDEnW/AWFkU6QC8x0SEgZflibXXyw5KwvT6yEBY rMqM/RT5Ef7C4e0UCJBsqcHrgMDCo9+O1Vg7o5P56jWsFkAKlhbB7wX2l8pANsJfIs5g tQ7NoHdJEiffWEdwVcI0DJrWoj83qUHp7sWrzGA+rxSerO9yEb1JJzPAEePIeuVQCiB0 qLGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=tM2HZQgNPT7c6W3h2GI86+7wXtUs/IeSla0L7MdHmWA=; b=IJhkT7akgX04Bs0RqZXuUzk9jKmG2yyz8iwk9oKoGdWIAr6T6FmHKV9kzbybHXIDLY zX39MncNzTIgL9HEx6KfTij0HZH1jC2cwrii5MxnXPNm4GirgkH4NuzSHbhMz71QVHIC 1JpQRgclQstte0NhQVF2CrilXCZhFA641Fnw0upEzII/pPXSGkhS1DOg9BfXVvn66s0S yYSt+f4fQYJaCGx8P+YOFu/PxxVeV8cvShCoN4Qf05viQ4V/lb3rsarNNl9peyganYkz Hd1j6I8I0WsADqYwSqs5YgEkmeKWJMSYnAX4e0xUjvbvSh2TJvLLFWP8R/HG6HtpWs+U JehQ== X-Gm-Message-State: ACrzQf0ZTpbfUHcC9xXDRlt4mrgU3XSp63xwqSdnkfSusrKOQqIyQz3K zv+lSUKznkKbuxrn0Xfx8lBj21kE/EP0LA== X-Google-Smtp-Source: AMsMyM4qRDSm+NqxlMztrl3P2/eP0dej/8Qve8A0wT30Ee8x615ALYdm4X5xzmRe34kSBN3Bpr+mqQ== X-Received: by 2002:a05:6000:154e:b0:22a:3177:1985 with SMTP id 14-20020a056000154e00b0022a31771985mr3212296wry.117.1665062274479; Thu, 06 Oct 2022 06:17:54 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q18-20020a056000137200b0022cc7c32309sm17986049wrz.115.2022.10.06.06.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 06:17:53 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Oct 2022 14:17:36 +0100 Message-Id: <20221006131744.5179-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221006131744.5179-1-naush@raspberrypi.com> References: <20221006131744.5179-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/10] ipa: raspberrypi: Add minimum and maximum line length fields to CameraMode 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add fields for minimum and maximum line length duration to the CameraMode structure. This replaces the existing lineLength field. Any use of the existing lineLength field is replaced by the new minLineLength field, as logically we always want to use the fastest sensor readout by default. As a drive-by cosmetic change, split all fields in the CameraMode structure into separate lines. Signed-off-by: Naushir Patuck Tested-by: Dave Stevenson Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 8 +++---- src/ipa/raspberrypi/controller/camera_mode.h | 23 +++++++++++++------- src/ipa/raspberrypi/raspberrypi.cpp | 13 ++++++----- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index cac8f39ee763..42251ba29682 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -64,13 +64,13 @@ void CamHelper::process([[maybe_unused]] StatisticsPtr &stats, uint32_t CamHelper::exposureLines(const Duration exposure) const { assert(initialized_); - return exposure / mode_.lineLength; + return exposure / mode_.minLineLength; } Duration CamHelper::exposure(uint32_t exposureLines) const { assert(initialized_); - return exposureLines * mode_.lineLength; + return exposureLines * mode_.minLineLength; } uint32_t CamHelper::getVBlanking(Duration &exposure, @@ -86,8 +86,8 @@ uint32_t CamHelper::getVBlanking(Duration &exposure, * minFrameDuration and maxFrameDuration are clamped by the caller * based on the limits for the active sensor mode. */ - frameLengthMin = minFrameDuration / mode_.lineLength; - frameLengthMax = maxFrameDuration / mode_.lineLength; + frameLengthMin = minFrameDuration / mode_.minLineLength; + frameLengthMax = maxFrameDuration / mode_.minLineLength; /* * Limit the exposure to the maximum frame duration requested, and diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index a6ccf8c1c600..6bc35b771946 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -20,23 +20,30 @@ struct CameraMode { /* bit depth of the raw camera output */ uint32_t bitdepth; /* size in pixels of frames in this mode */ - uint16_t width, height; + uint16_t width; + uint16_t height; /* size of full resolution uncropped frame ("sensor frame") */ - uint16_t sensorWidth, sensorHeight; + uint16_t sensorWidth; + uint16_t sensorHeight; /* binning factor (1 = no binning, 2 = 2-pixel binning etc.) */ - uint8_t binX, binY; + uint8_t binX; + uint8_t binY; /* location of top left pixel in the sensor frame */ - uint16_t cropX, cropY; + uint16_t cropX; + uint16_t cropY; /* scaling factor (so if uncropped, width*scaleX is sensorWidth) */ - double scaleX, scaleY; + double scaleX; + double scaleY; /* scaling of the noise compared to the native sensor mode */ double noiseFactor; - /* line time */ - libcamera::utils::Duration lineLength; + /* minimum and maximum line time */ + libcamera::utils::Duration minLineLength; + libcamera::utils::Duration maxLineLength; /* any camera transform *not* reflected already in the camera tuning */ libcamera::Transform transform; /* minimum and maximum fame lengths in units of lines */ - uint32_t minFrameLength, maxFrameLength; + uint32_t minFrameLength; + uint32_t maxFrameLength; /* sensitivity of this mode */ double sensitivity; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 358a119da222..67326bcf4a14 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -314,7 +314,7 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) } startConfig->dropFrameCount = dropFrameCount_; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); firstStart_ = false; @@ -356,7 +356,8 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) * Calculate the line length as the ratio between the line length in * pixels and the pixel rate. */ - mode_.lineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate); + mode_.minLineLength = sensorInfo.minLineLength * (1.0s / sensorInfo.pixelRate); + mode_.maxLineLength = sensorInfo.maxLineLength * (1.0s / sensorInfo.pixelRate); /* * Set the frame length limits for the mode to ensure exposure and @@ -458,8 +459,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, * based on the current sensor mode. */ ControlInfoMap::Map ctrlMap = ipaControls; - const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; ctrlMap[&controls::FrameDurationLimits] = ControlInfo(static_cast(minSensorFrameDuration.get()), static_cast(maxSensorFrameDuration.get())); @@ -1150,8 +1151,8 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration) { - const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; - const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.minLineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.minLineLength; /* * This will only be applied once AGC recalculations occur.