From patchwork Mon Oct 3 08:39:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17489 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 185E6C327C for ; Mon, 3 Oct 2022 08:40:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1155762CE4; Mon, 3 Oct 2022 10:40:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1664786402; bh=pKEJ82w+q8AzYxYD5MzI7GOYv4UyMiRvHsZgi0chqa8=; 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=Myw+jqbYpecbULYz4tCCmDocaAOx23fvAsR0U3QDjI3Fodv7MjWiuqyQ9IlpikuEZ v+T07aFVxfPyr2erCMltj0wYz+EMF90AnaWbq9IMb2ScJYRoMm2cPAiqkcEdIjIIcC lB72Bo9Ga+3UQ4Semug+u9ZE73jk3Fw9/qribhzuT1BOMtwEzrnxtt4NKUQBYSX5Up 9nS77gbp9XiX+O4A3a4QfCkzomGWkCTF6iSFaT0BynmSH5+Z5nvBUjA/VDhk4QDzj1 PdlJxkn4gjDT/hlJTZozsZBrQK86A9gtKSVNw0FawYHLt8/CLpgrFGLb0++aBpaNiY 71O/2KDFradXg== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1504D61F74 for ; Mon, 3 Oct 2022 10:39:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PAODfqMP"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id iv17so6535905wmb.4 for ; Mon, 03 Oct 2022 01:39:59 -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=1QCNpi5jJlmRb7DM3+pXDRv9ADcRQP27dKFxrOHea6E=; b=PAODfqMPZfM/7lme+IkrjJ2KPJP0TohcXzh6UPMqHCYsKcju5wLP+sKGIgmDxatDSg GlU6gqDWf2+B1un2bqdq89VNvcQ+Y+ENM+6LpVAtOhVfRcDCRH84jBR3Yn29eSD64HFb U5AtlqwX0C3/Fn74yTtH5DMvhYAF0XSPfzC7O4pX0BaT+s919dSJsLMX4hMTAI6DC6ha UKAtzbQ2OpIG/PXrhdVM3GXoYDmYWFb9wY4Ofp7gGgh5zcd7POdlOUqm77IvnRw6Ll01 DHRtcoOy9DfE5PE8a9cv2ac7BMG8D83g3l0mO9qFaV6fImO0+JOEdwLUuV2+z1eWC1ch INsQ== 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=1QCNpi5jJlmRb7DM3+pXDRv9ADcRQP27dKFxrOHea6E=; b=CQr0PALMdyiYH7yf/qevv54WH9baOv08/FRVBTJD/axtUGast2mTPUsFz5Fa5VH4v2 vk8DRaF4WwHalJ9AQNC6eLOGqnyTz5OTHc4elZ5HTD2a5M0ZXNwc0qZydFtAstUVXs62 D9/IFoadYH4YFMg43T3jAvj2NJqkDV11aQFTKebwhaWuN3gvhvrkpALraHDI67JydoQ9 eTQC2HbI+ibCWWu+lguNiR6PshsyYScZLxxI+OOw9M/vZxbFXhIwwnXkSrMLGUDSz48U Uy02Kekuf9Ie5X2HrpkydhEzeK1OdMWOZPqEixNxEF6I7j/yuAoGFNwvMnQatZIvfh5o Qm+w== X-Gm-Message-State: ACrzQf2hIM6LO8sfBQ0PR+k3dPbd0aeIAe+Fmh81HdgHMEZxTGgBcEev XvzdCEsBti/2UABbKsXdo1AW3ejonqrmTg== X-Google-Smtp-Source: AMsMyM69cSLJj/iXo+PVpnpLc4qMTRQ9o4winclxmkpQfPdxpP/UuwVna2QBW1pfxldl+gSmmph51A== X-Received: by 2002:a05:600c:35cc:b0:3b4:c403:7888 with SMTP id r12-20020a05600c35cc00b003b4c4037888mr6118578wmq.206.1664786398568; Mon, 03 Oct 2022 01:39:58 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0022ae59d472esm8922787wrw.112.2022.10.03.01.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 01:39:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Oct 2022 09:39:28 +0100 Message-Id: <20221003083934.31629-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221003083934.31629-1-naush@raspberrypi.com> References: <20221003083934.31629-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/9] 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 (in units of pixels) 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. Signed-off-by: Naushir Patuck --- src/ipa/raspberrypi/cam_helper.cpp | 8 ++++---- src/ipa/raspberrypi/controller/camera_mode.h | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 13 +++++++------ 3 files changed, 12 insertions(+), 11 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..b7e73aae4698 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -32,7 +32,7 @@ struct CameraMode { /* scaling of the noise compared to the native sensor mode */ double noiseFactor; /* line time */ - libcamera::utils::Duration lineLength; + libcamera::utils::Duration minLineLength, maxLineLength; /* any camera transform *not* reflected already in the camera tuning */ libcamera::Transform transform; /* minimum and maximum fame lengths in units of lines */ 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.