From patchwork Wed Apr 13 09:53:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15666 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 CA5EFC3260 for ; Wed, 13 Apr 2022 09:53:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4FBFC6563F; Wed, 13 Apr 2022 11:53:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649843607; bh=e07PUHPKxK3iB0J5Sy48tMn2fLcWIU2b9tRdks87DzM=; 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=xPOdFW3B4SSv05br8JTOQze1EY+QnO592ApXVSY9td5uza08o8AMCakMgjRffkKUk AMCnZ5Z6FaHaZmVWCIyGiyvC1M8AlNX32Hl+Oq6S1fxtk+2+nE/Cj4HaXe2/Ldk9O6 oJrPbvNqbh+ZuMheCSnhlMOvzo9u7aoqEp81u3kndJVCEWUhpGBnJ/a1fd9/7dwD4M krKol4TPCxnPVM2Gl8L0+YLSX7/MwLCK1uxh1Sdc6WZXjlD4e9XXbAxrp5kWMsOinO mV6K5drd2mraD3ka8pHgnHMOaKcrdwFo2Mazu1eHdsIS0oLlg2pH/dECu/g6RK0I3c viDDXzcoM8Krg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BB59C6563E for ; Wed, 13 Apr 2022 11:53:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NHe/i/8x"; dkim-atps=neutral Received: from Q.ksquared.org.uk.beta.tailscale.net (unknown [178.237.134.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 362D4482; Wed, 13 Apr 2022 11:53:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1649843604; bh=e07PUHPKxK3iB0J5Sy48tMn2fLcWIU2b9tRdks87DzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NHe/i/8xsxvSVtWXSRmjJlw73yb3UkQzGPyCcIBG+VLKBQulDtWSFxZhnY2hkcNmv wBiqXPUC6g0vwH3eRVDIU44kFyGB0byTqJVC5qx1am96xPVZdAFh61d3hcY/cdkA0x doBev+uwBnzcYFp5jApdBRXT73RjJF6MQ/tm8h7o= To: libcamera devel , Naushir Patuck , David Plowman Date: Wed, 13 Apr 2022 11:53:41 +0200 Message-Id: <20220413095342.389460-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413095342.389460-1-kieran.bingham@ideasonboard.com> References: <20220413095342.389460-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman 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 Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck Signed-off-by: Kieran Bingham --- v3: [Kieran] : Spelling correction 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 5bb065847e04..826181cabc92 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -67,6 +67,8 @@ public: Transform transform; + float modeSensitivity; + protected: CameraConfiguration(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 713543fd1bdf..c2e64a0ba5e4 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -160,7 +160,7 @@ LOG_DECLARE_CATEGORY(Camera) * \brief Create an empty camera configuration */ CameraConfiguration::CameraConfiguration() - : transform(Transform::Identity), config_({}) + : transform(Transform::Identity), modeSensitivity(1.0), config_({}) { } @@ -412,6 +412,20 @@ CameraConfiguration::Status CameraConfiguration::validateColorSpaces(ColorSpaceF * 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 returned successfully. + */ + /** * \var CameraConfiguration::config_ * \brief The vector of stream configurations From patchwork Wed Apr 13 09:53:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15667 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 7A401C326C for ; Wed, 13 Apr 2022 09:53:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D6DE26564C; Wed, 13 Apr 2022 11:53:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649843608; bh=miftrjCOdbQgKoEARezQKky9Qx5ev/RXSNaMu/NBVz0=; 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=dZvMRfIBZLPPpmgWsL0wxljVUcTKE7cbwuyWLtgks7x4nLSQeZcNwi1ALHT1yMLCo ueSXZOiTG4UGhknVhO1IKj+4uj6MHaz/50VYgYxUe+SQlDqYoW9OaIUHf/zYm+XW6s t5CHjdgcfZsdODlJN455V/5FTf9lSj9prQmiKCbAc83mppR7jfX6qxKLAr1IcPEASY 7z4Xi7CF6dmmX9BMMf8LyfTphaXZdhpCov6yAudIJtAJQruzjhi8eBDqejlKXfWj7U enbpyKt2ZfcaAlynkV01wVPV029rlkIBr96XtYsqAFNO2W6Gv+XMjIpkK9zeijA5Lc z6vS/EkEvU32A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A41E2604B3 for ; Wed, 13 Apr 2022 11:53:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hWDX41uj"; dkim-atps=neutral Received: from Q.ksquared.org.uk.beta.tailscale.net (unknown [178.237.134.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D242C59D; Wed, 13 Apr 2022 11:53:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1649843605; bh=miftrjCOdbQgKoEARezQKky9Qx5ev/RXSNaMu/NBVz0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hWDX41ujW5pQkjJ9fv/4AOZ5OEg+ohu4uHzb/fsLMNqskO2BXIu/w2lGaMk91QeRx HCYIoMXDPXsUHIpjeHfnvwHVIXlmqoO/ji8uRauOH1FlsOPkhicrhwxGapz/UlfWeQ VzeVHAWAala7mHU6D01bRaSBDaW0cQlkm4F79NF4= To: libcamera devel , Naushir Patuck , David Plowman Date: Wed, 13 Apr 2022 11:53:42 +0200 Message-Id: <20220413095342.389460-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413095342.389460-1-kieran.bingham@ideasonboard.com> References: <20220413095342.389460-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: David Plowman 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 Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck Signed-off-by: Kieran Bingham --- v3 - [Kieran] - Manually applied patch to account for rebase Open questions: - Should the controls list that gets returned be moved into the IPAConfigResult ? - Should this modeSensitivity actually be returned during validate? (This seems more critical to the design of the patch) include/libcamera/ipa/raspberrypi.mojom | 7 ++++++- src/ipa/raspberrypi/raspberrypi.cpp | 7 +++++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 5a228b75cd2f..a60c3bb43d3c 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -38,6 +38,10 @@ struct IPAConfig { libcamera.SharedFD lsTableHandle; }; +struct IPAConfigResult { + float modeSensitivity; +}; + struct StartConfig { libcamera.ControlList controls; int32 dropFrameCount; @@ -58,6 +62,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 function shall be called when the camera is configured to inform * the IPA of the camera's streams and the sensor settings. @@ -72,7 +77,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 89767a9db471..32a9d5166071 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -97,7 +97,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; @@ -342,7 +342,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."; @@ -402,6 +402,9 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, */ ControlList ctrls(sensorCtrls_); + /* 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 d6148724bdd5..3cba7ba993ad 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -200,7 +200,7 @@ public: void frameStarted(uint32_t sequence); int loadIPA(ipa::RPi::SensorConfig *sensorConfig); - int configureIPA(const CameraConfiguration *config); + int configureIPA(CameraConfiguration *config); void enumerateVideoDevices(MediaLink *link); @@ -1528,7 +1528,7 @@ int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) return ipa_->init(settings, sensorConfig); } -int RPiCameraData::configureIPA(const CameraConfiguration *config) +int RPiCameraData::configureIPA(CameraConfiguration *config) { std::map streamConfig; std::map entityControls; @@ -1573,13 +1573,17 @@ 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; } + /* Store the mode sensitivity for the application. */ + config->modeSensitivity = result.modeSensitivity; + if (!controls.empty()) setSensorControls(controls);