From patchwork Mon Jun 28 08:56:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12720 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 60228C321F for ; Mon, 28 Jun 2021 08:56:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A6C31684DA; Mon, 28 Jun 2021 10:56:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="N36mUbQH"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EDF6E684D3 for ; Mon, 28 Jun 2021 10:56:32 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id w13so10869232wmc.3 for ; Mon, 28 Jun 2021 01:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sowNw/qaIjLQtmQOw1xULSjivxaJNp/QUhd2EfpMn8E=; b=N36mUbQHe8pAE5SF0BLTZU7KMAInBEnJn8YbEeW+Gld1HV1H48pD/QPaPGHAptxncF RMSbUKP7wi3aqtDSj0MHuNsf9MmxEi2nPl/3S1ImYPUyLpjXCuUp6uGkSF/7iAKizVjW LujCizuzXKDk4rv9Fk7x+mLVmJZDcAxcfQFmppLqzaGDtEOd9DYza/eEdlxR+a8cOBNg OUfq0O5SvHyTSrfZJSW2dWg7cEEbgPgvcBPjT1GyxTI+Lqn1ZvCNsvMkq58NCr5yEds8 CR9KsSquGLIJttBPwUtMo3LM9E2nki/J9pMkG7fCwqUxb5j3j0/O1ypL0RaXME6Af+aK 9hZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sowNw/qaIjLQtmQOw1xULSjivxaJNp/QUhd2EfpMn8E=; b=jHun08BZCqJivYLYPriSe80FcwVRa/rPScddyqLYQeGbPpeG6CETss22k3KLJjqZDV alDmQLf62ntW7gegCYxrXtEGrO8HkClvlJZM5KYtYeN7addC0ztL8sSAqON9DNQF09Em cu1/H9m1HPI9TjXznxam9tUymHrH3kVH9seWaO50I8qfG781FlWpVZdA/1KiDvYU8aXb Iz5mohl3QeapjQAnMgbrTQUme9f2w2RGREwJHNV004W7mC3Bcf2D7QU5hl9vk6KQfRAB iEQkwN6V2LlaSiUSXtB2qnBFgvhytYKKRdnWRPpTB9uhJanDSa12fRaua/evGkNndtVG N6ig== X-Gm-Message-State: AOAM530rA8oE4XRL6gU6CjsAA0RAhbGdt4Z+SId7CRGZdbSnUURXHK2N p/vEbb75DwuQwy2/TH4MV86CCm3JvoEvng== X-Google-Smtp-Source: ABdhPJzlGz/huVVbAM5fQACVw5Xzes6ZdnlFuokcJkR/qgIe318E62Cw4xVNI2uYmZhC8M0rm9Xgxw== X-Received: by 2002:a1c:4cd:: with SMTP id 196mr5282435wme.145.1624870592475; Mon, 28 Jun 2021 01:56:32 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id g7sm10578243wmq.27.2021.06.28.01.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 01:56:32 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Jun 2021 09:56:29 +0100 Message-Id: <20210628085630.2081-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210628085630.2081-1-david.plowman@raspberrypi.com> References: <20210628085630.2081-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: camera: add a mode sensitivity field 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" The modeSensitivity field is a number that describes how sensitive the selected sensor mode is compared to other readout modes of the same sensor. For example, a binned mode might have twice the sensitivity of the full resolution mode, meaning you would get double the signal level for the same exposure and gains. Signed-off-by: David Plowman --- include/libcamera/camera.h | 2 ++ src/libcamera/camera.cpp | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index d7164180..85f7f999 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -65,6 +65,8 @@ public: Transform transform; + float modeSensitivity; + protected: CameraConfiguration(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 1340c266..6b3627b6 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -154,7 +154,7 @@ LOG_DECLARE_CATEGORY(Camera) * \brief Create an empty camera configuration */ CameraConfiguration::CameraConfiguration() - : transform(Transform::Identity), config_({}) + : transform(Transform::Identity), modeSensitivity(1.0), config_({}) { } @@ -325,6 +325,20 @@ std::size_t CameraConfiguration::size() const * may adjust this field at its discretion if the selection is not supported. */ +/** + * \var CameraConfiguration::modeSensitivity + * \brief The relative sensitivity of the chosen sensor mode + * + * Some sensors have readout modes with different sensitivities. For example, + * a binned camera mode might, with the same exposure and gains, produce + * twice the signal level of the full resolution readout. This would be + * signalled by the binned mode, when it is chosen, indicating a value here + * that is twice that of the full resolution mode. + * + * This value should only be read, and not set, by the user. It will be + * valid after the configure method has reteurned successfully. + */ + /** * \var CameraConfiguration::config_ * \brief The vector of stream configurations From patchwork Mon Jun 28 08:56:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12722 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 EA3A8C321F for ; Mon, 28 Jun 2021 08:56:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71C94684D8; Mon, 28 Jun 2021 10:56:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="YIaktZJv"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7B806684D2 for ; Mon, 28 Jun 2021 10:56:33 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso13171039wmh.4 for ; Mon, 28 Jun 2021 01:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OoNdfN627FI5cwtkJre1MidqsYnjhjb1szI/zMamHw0=; b=YIaktZJviBAP39sYuWSDsPV/kJTnXtEcYUWHXZY24AufEHBdAep6SAdjATr08QBZEV HinvKeQehcRONMYC9Syi5BfPUho4qC8TqpsysU5E0++0X71wee3Zdw+n0TxJXpGJ0NIg giZW1x6WaxDXCUxMrnPSk07OrF6LSWDSB7+6qHpTiG8GBXroQIrbL5BVMK2ysfSfqwC7 UCQa21V7Y5yEutZJ92guX5wL3o7K6MhCYeDZXvRsc9EeFrWLBYpik8+3Pq2VzkCKQ9Fe ur6cb/BUlMWYk0MheX8inYJP9gvFDmCiQgnao7nLVM63XNG5KnQ2sdzaS+Nn7Gbqnt7z 8ojQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OoNdfN627FI5cwtkJre1MidqsYnjhjb1szI/zMamHw0=; b=qZqmXgtqTyFH4oizEvp+aNm63P7zevxk1DW2OKLCxKhhLUbqUj2XHVcf2zFSom52T/ 80lORxhorjUArQsSckeApjuAyaZBnqcJMjLCKQVZxBy6AcdkbAgKNP59HMoJQgf1vlz4 Qb2no8r1hcbsq5XId1GJnRsm7Xrl1KNUNH747uo8Ukq46rPbZsF4JCR33Mkm4eSjXrc2 q0nK4MyX6ZWiExM+HGb194m5QH5Gnh0gzMpRedUPxzpFk0ceJDiumBwvpZ9DA5YJ+5Rj 3qRosoWfX0qKlTN/6Ek+QAR+LWb0z3nbERdJyWwlNMpDxxCFNUq7Px4irx9Uvl8UmYT6 WS0w== X-Gm-Message-State: AOAM530nQNojflV7Zl2+44BXnSCln274CvHlNF5+cUvXJghSNELl53ha jqstwhd8SkGP+K28Nrp5b1e2148KyNmjdA== X-Google-Smtp-Source: ABdhPJzvPe3gGJ6CM2up0YrwCCj3uoaFUUiQnhdYBlNH2040yKcIIYCyEG+3dDiQPnsqxq10jRbPMQ== X-Received: by 2002:a1c:f616:: with SMTP id w22mr10669253wmc.73.1624870593063; Mon, 28 Jun 2021 01:56:33 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id g7sm10578243wmq.27.2021.06.28.01.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Jun 2021 01:56:32 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 28 Jun 2021 09:56:30 +0100 Message-Id: <20210628085630.2081-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210628085630.2081-1-david.plowman@raspberrypi.com> References: <20210628085630.2081-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: raspberrypi: fetch correct value for sensor's modeSensitivity 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" These changes retrieve the correct value for sensitivity of the mode selected for the sensor. This value is known to the CamHelper which passes it across to the pipeline handler so that it can be set correctly in the CameraConfiguration. Signed-off-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 7 ++++++- src/ipa/raspberrypi/raspberrypi.cpp | 7 +++++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 9 ++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 606d1de4..3a71c167 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -38,6 +38,10 @@ struct IPAConfig { libcamera.FileDescriptor lsTableHandle; }; +struct IPAConfigResult { + float modeSensitivity; +}; + struct StartConfig { libcamera.ControlList controls; int32 dropFrameCount; @@ -57,6 +61,7 @@ interface IPARPiInterface { * \param[in] entityControls Controls provided by the pipeline entities * \param[in] ipaConfig Pipeline-handler-specific configuration data * \param[out] controls Controls to apply by the pipeline entity + * \param[out] result Other results that the pipeline handler may require * * This method shall be called when the camera is configured to inform * the IPA of the camera's streams and the sensor settings. @@ -71,7 +76,7 @@ interface IPARPiInterface { map streamConfig, map entityControls, IPAConfig ipaConfig) - => (int32 ret, libcamera.ControlList controls); + => (int32 ret, libcamera.ControlList controls, IPAConfigResult result); /** * \fn mapBuffers() diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9ce0db08..76376e06 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -96,7 +96,7 @@ public: const std::map &streamConfig, const std::map &entityControls, const ipa::RPi::IPAConfig &data, - ControlList *controls) override; + ControlList *controls, ipa::RPi::IPAConfigResult *result) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; void signalStatReady(const uint32_t bufferId) override; @@ -336,7 +336,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, [[maybe_unused]] const std::map &streamConfig, const std::map &entityControls, const ipa::RPi::IPAConfig &ipaConfig, - ControlList *controls) + ControlList *controls, ipa::RPi::IPAConfigResult *result) { if (entityControls.size() != 2) { LOG(IPARPI, Error) << "No ISP or sensor controls found."; @@ -388,6 +388,9 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, /* Pass the camera mode to the CamHelper to setup algorithms. */ helper_->SetCameraMode(mode_); + /* The pipeline handler passes out the mode's sensitivity. */ + result->modeSensitivity = mode_.sensitivity; + if (firstStart_) { /* Supply initial values for frame durations. */ applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index a65b4568..7bace5b8 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -146,7 +146,7 @@ public: void frameStarted(uint32_t sequence); int loadIPA(ipa::RPi::SensorConfig *sensorConfig); - int configureIPA(const CameraConfiguration *config); + int configureIPA(CameraConfiguration *config); void statsMetadataComplete(uint32_t bufferId, const ControlList &controls); void runIsp(uint32_t bufferId); @@ -1235,7 +1235,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) return ipa_->init(settings, sensorConfig); } -int RPiCameraData::configureIPA(const CameraConfiguration *config) +int RPiCameraData::configureIPA(CameraConfiguration *config) { /* We know config must be an RPiCameraConfiguration. */ const RPiCameraConfiguration *rpiConfig = @@ -1284,13 +1284,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) /* Ready the IPA - it must know about the sensor resolution. */ ControlList controls; + ipa::RPi::IPAConfigResult result; ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig, - &controls); + &controls, &result); if (ret < 0) { LOG(RPI, Error) << "IPA configuration failed!"; return -EPIPE; } + config->modeSensitivity = result.modeSensitivity; + if (!controls.empty()) unicam_[Unicam::Image].dev()->setControls(&controls);