From patchwork Mon Mar 27 09:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18465 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 EC98AC326C for ; Mon, 27 Mar 2023 09:34:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC51E6273D; Mon, 27 Mar 2023 11:34:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679909685; bh=O145NJ/eDREy69ovZASc8+j6VP/8f0yzLsVuI+LQYX0=; 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=mn1vPY9sVW3l8bD0BuJRF7EENjH58fjWKF3y+ZPwcMAjL1SGZPz1bKEAxQ2Nl2xCy NOlbY9Y2aTrBi0hgInDU6RGV9wYb7O7XearFfyf5zHUaZxC5IFTfqVRe/yZopOT4Ms aRb/JJNkxW3gLux1oDHXBS2QXRi4pCRWnBxqvLfpRqmayYKSWOBj3VNR/1Vqe30FQ/ FTD/OYyyO2RHMdSwtVmR3L1GWhJCpZbDrMF7uIcB7QBMMNRbLM1v3szocKcaHsgfVq 7CubsIeS7Z5swaRUuwBan7ZMVL3ThqZTpsAKvH0vfH4vBTi97PnCKJUFfNZnvwXt+l ogtnFmVdnByYQ== Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 89662626DB for ; Mon, 27 Mar 2023 11:34:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TdSkYR14"; dkim-atps=neutral Received: by mail-io1-xd30.google.com with SMTP id e13so3630220ioc.0 for ; Mon, 27 Mar 2023 02:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1679909682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=57Xo0a5+A05ZYv9p8DpBaQMTnNKtoIQ1uVFpyH98Sv0=; b=TdSkYR14iTLtbvRtPlf1lrBuXkzgWmLRo78+3YQBHDB0CBG3NI5tYYYSnauSK7yEPp l+VDoTbDj8l3SwhskvUe/RhDitd5iFz0ADEgJQUInxUdxlLMJnXygZdV09cUrzI3PM86 IfbD1V/PCz7bYNC3MT+Hx4Fftrpa/VMt8/zgFzJQAsmCEEaxIqySWc2CINUwHnbn0P9N bBkHTRbn8/9fTiJBodrAQfa9Wg6IlaHoKx00lXEXQVa2y1f83WzouNmXG9qJVTZTvS0l zo6geBZzXpwQqG9oO3u+iwkWQ2knfJCc4/gaLhcmg+lLj8HVsUAoRasDDVDjkdL47nI+ T9XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679909682; 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:message-id:reply-to; bh=57Xo0a5+A05ZYv9p8DpBaQMTnNKtoIQ1uVFpyH98Sv0=; b=4/TqsrNVS2xpPHdb2vW7coUL7ckd0cqExHRLcVJccgeg93fvy6WN11WYI8msIZNBgT /oyiRFlYEh6GvMCxcYr/WGuRQahGoA1KSoqSUVShKCSRwQQBPwvOM/cE4mhrSC/nIJRd 6dsOIpG64YlEqtdXTYdp9qI5bulB//zSklWU7C6vGnPZ4f3GOphCO0JY4zuNRxb3W4u0 oL+l/UsUKh36eDK/A07Sci9qC9AnRhHX2Gh7jAgZOKsY4axSzJvGzqEpLWzkIK5DIuZ0 yOh8ePTyUQx6eNM9cO3kOxAMPNDF8YJwnuFYB3N8AxEyxlKY5xzsNPLcq0Oj69bnn1AQ 1sSg== X-Gm-Message-State: AAQBX9f7zuShPhBJocSTl00IMPj+jdmosP5RnRo1ldSk2mMVMDRfgDbV ibE1OfxpJjk+stI5fdgit2Zn8n8XwMqjQBKWzeIBew== X-Google-Smtp-Source: AKy350ZK8QsuRYm3dXschrbqabF5qt9Ee+lg7yc5ghLTx7mR7ZRVpN+NZ0KxoACyiCldQSL1d1xHEw== X-Received: by 2002:a6b:da05:0:b0:759:a25a:c755 with SMTP id x5-20020a6bda05000000b00759a25ac755mr5086148iob.1.1679909682260; Mon, 27 Mar 2023 02:34:42 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id d12-20020a056602328c00b0075464a69c10sm7658345ioz.10.2023.03.27.02.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 02:34:42 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Mar 2023 10:34:36 +0100 Message-Id: <20230327093439.24670-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230327093439.24670-1-naush@raspberrypi.com> References: <20230327093439.24670-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] ipa: raspberrypi: Add sensor mode limits 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 in the CameraMode structure to capture the mode specific limits for analogue gain and shutter speed. For convenience, also add fields for minimum and maximum frame durations. Populate these new fields when setting up the CameraMode structure. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Jacopo Mondi --- src/ipa/raspberrypi/controller/camera_mode.h | 10 +++++++++- src/ipa/raspberrypi/raspberrypi.cpp | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index 94c51ddf1686..63b1177852d0 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -36,9 +36,11 @@ struct CameraMode { double scaleY; /* scaling of the noise compared to the native sensor mode */ double noiseFactor; - /* minimum and maximum line time */ + /* minimum and maximum line time and frame durations */ libcamera::utils::Duration minLineLength; libcamera::utils::Duration maxLineLength; + libcamera::utils::Duration minFrameDuration; + libcamera::utils::Duration maxFrameDuration; /* any camera transform *not* reflected already in the camera tuning */ libcamera::Transform transform; /* minimum and maximum frame lengths in units of lines */ @@ -48,4 +50,10 @@ struct CameraMode { double sensitivity; /* pixel clock rate */ uint64_t pixelRate; + /* Mode specific shutter speed limits */ + libcamera::utils::Duration minShutter; + libcamera::utils::Duration maxShutter; + /* Mode specific analogue gain limits */ + double minAnalogueGain; + double maxAnalogueGain; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 1375795568e2..3f1afb846420 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -407,11 +407,27 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) mode_.minFrameLength = sensorInfo.minFrameLength; mode_.maxFrameLength = sensorInfo.maxFrameLength; + /* Store these for convenience. */ + mode_.minFrameDuration = mode_.minFrameLength * mode_.minLineLength; + mode_.maxFrameDuration = mode_.maxFrameLength * mode_.maxLineLength; + /* * Some sensors may have different sensitivities in different modes; * the CamHelper will know the correct value. */ mode_.sensitivity = helper_->getModeSensitivity(mode_); + + const ControlInfo &gainCtrl = sensorCtrls_.at(V4L2_CID_ANALOGUE_GAIN); + const ControlInfo &shutterCtrl = sensorCtrls_.at(V4L2_CID_EXPOSURE); + + mode_.minAnalogueGain = helper_->gain(gainCtrl.min().get()); + mode_.maxAnalogueGain = helper_->gain(gainCtrl.max().get()); + + /* Shutter speed is calculated based on the limits of the frame durations. */ + mode_.minShutter = helper_->exposure(shutterCtrl.min().get(), mode_.minLineLength); + mode_.maxShutter = Duration::max(); + helper_->getBlanking(mode_.maxShutter, + mode_.minFrameDuration, mode_.maxFrameDuration); } int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, const IPAConfig &ipaConfig,