From patchwork Wed Sep 22 13:29:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 13885 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 38925BF01C for ; Wed, 22 Sep 2021 13:29:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F3D0869191; Wed, 22 Sep 2021 15:29:28 +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="fOX/Lr6/"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 55ADD6917F for ; Wed, 22 Sep 2021 15:29:25 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id t8so6940074wri.1 for ; Wed, 22 Sep 2021 06:29:25 -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=u/KfOE6Hnhi4DCfVpPNhejIB69FbyQsSdO7xOHmF9IY=; b=fOX/Lr6/T0YXnV39PQdmvvGjCpbWKSJVIOAwTu0ElsfACVj3XEMQXnoJTu459mDfoX nKXarWYJXsFIQTJPuYaW6vtlg93TflnWDIJPKJVRjSVEUaYZhzwmxUhynZi5l/E4E9HB ytfAieDXgw4+7UBTI8ihuwcNNwJW9LuttLKMCEZ1PLqICPAa3RS0xjNgTgZhFQeXWZNL WWXe3LZjm5whjqXJnHotpZ75ikikHYks6xns9eT5ITGQ+FsCmtsC/hlIN4qV0gPNmakj abeq3wEhAsQ934musZuMZqxyOi+aqMrrGrHOgkdU6FbHUwn0RrXqMSSA62HOd94x5Gnx 0okg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u/KfOE6Hnhi4DCfVpPNhejIB69FbyQsSdO7xOHmF9IY=; b=PNQJ6SRv/zF5rRFhn8odNIKVUiPCf5AmfAIpX/yIv7Vk8hIENEdQ0FVjrfnrd7qHNf 1in9lz9wsAPxmryO5WmjMjl8GHoKmqxIDX9PMqeXLa2Ggx+tNh7s+KK/5YbM6BocwHiF 4rXQNDWua/bNYSKTQ6LuaIQXnpWuNEGPf63Tj09wVnNMuXtktoXtZzGCn1H+y9fgr6/g vNuwMCPuWOp4dSIr4fD523aPcfGXhI8bV+uLy+Pm98ZpCLHb7B3lziMpX+GGyWs8UGSz N/h3AGsp3jaFUvjgO2qte+0PtvfAr0iRbsgfesTWlgI16ELI5HtDcL84woxrDg4UIoBK g3kg== X-Gm-Message-State: AOAM530vrJxGZ0DM6KzX1H2bdso9IxVy1lnfHQv3yLd3nOoRfsnRXyvL m2D1rD9zVR+pQ7XHXR0BW1sP2EgjcxcaFVEP X-Google-Smtp-Source: ABdhPJx2wGCTVY56A1AvEKt8npegT6HuO2icJ3Qpig7KoSKeVVezc+m30gKFigh9HLLM7YLc1zzLsw== X-Received: by 2002:a05:600c:2259:: with SMTP id a25mr10650208wmm.133.1632317364777; Wed, 22 Sep 2021 06:29:24 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id q126sm5776310wma.10.2021.09.22.06.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 06:29:24 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Sep 2021 14:29:14 +0100 Message-Id: <20210922132915.14881-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210922132915.14881-1-david.plowman@raspberrypi.com> References: <20210922132915.14881-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- 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 601ee46e..3314c06b 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -66,6 +66,8 @@ public: Transform transform; + float modeSensitivity; + protected: CameraConfiguration(); diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 71809bcd..8d795dff 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -156,7 +156,7 @@ LOG_DECLARE_CATEGORY(Camera) * \brief Create an empty camera configuration */ CameraConfiguration::CameraConfiguration() - : transform(Transform::Identity), config_({}) + : transform(Transform::Identity), modeSensitivity(1.0), config_({}) { } @@ -327,6 +327,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 Wed Sep 22 13:29:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 13886 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 62FEBBF01C for ; Wed, 22 Sep 2021 13:29:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9CEBE69196; Wed, 22 Sep 2021 15:29:29 +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="Vkyotmk7"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4000B6917F for ; Wed, 22 Sep 2021 15:29:26 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id t7so6694362wrw.13 for ; Wed, 22 Sep 2021 06:29:26 -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=TB6Bt57clhDipCaxaFUZl8FofXJfzseyc3L+AJBLXmQ=; b=Vkyotmk7nRPy+pHRR3sn/SfAcaK4Bss5INVk0l/FTOsjrB1oNyWwwDwAUifWrtxyMy Nj51mnQfoFtuHd6hLmZLrkBJqDB3ueLziVeNs6GWia1IwAljhawnG8/bi7YHFuZUtxDh MIoAZUhNDpV5UJpSe/hOVDumhGgIQWMTXwePf3Dy1Xgf027C5fWlI0Sb7nv+U/z/UmME eiZ0SoqzR8JxH/6DaXUFGzGohT5QiE02XZv2RT25+XVucDl3oO5WMi6FcWZijZvwwEJT Y1phZrES2jRPtnR7oqI3t9O/BvPk8id6JkGJA7Cfx20wT94DetG4ulD/nhAakLdzaY/n djdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TB6Bt57clhDipCaxaFUZl8FofXJfzseyc3L+AJBLXmQ=; b=gHYfDekQ9Y5JwK1faW/uOYezcVuTHBiPd5pVVAxt+SypE4ZZCHcjpRs36kUWiwgX8Q vcSsRuRWU3BlHP91MA22qNLFzw8Xw25xpo2bkwZ6wvSqVIYoocs/gqfI1VKtysbrCmVE Tgcupdg408qT8r7PWWrWSxeeKXd4nAG5PbQG6elpejwjKONc1rW59ipeVvcuA0BQT7t6 eYMQxH1hIh/mJdJjx2aeCno2MX/BHLl7gV8mjXvIpDROdXrp0jIYM4ZMkjmaDPXKwqy6 3B8SqLkKiFIDt6vJHQyoRRczDrF54Lfq/4k+c4oW7pPXXAkndRTyvCawavKO8J9tlXMI MLuQ== X-Gm-Message-State: AOAM533wC41/6f+fI8G1OoSrW3RRGHX7oCXi1jTDBe4/cMKh69m+F570 3r7sXwOKne/5SrM6/sXNEr+c8AsK7BoMx97z X-Google-Smtp-Source: ABdhPJxtFYY7qG5P7aOvnWwQx9ydDNZ7XNNwsefEYVroOJtmzykEQMyia6u/kQ/106ZpOE0w/iQ9Mw== X-Received: by 2002:a05:600c:3585:: with SMTP id p5mr10658012wmq.88.1632317365705; Wed, 22 Sep 2021 06:29:25 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id q126sm5776310wma.10.2021.09.22.06.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 06:29:24 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Sep 2021 14:29:15 +0100 Message-Id: <20210922132915.14881-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210922132915.14881-1-david.plowman@raspberrypi.com> References: <20210922132915.14881-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck --- 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 e453d46c..a92a76f8 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 function 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 047123ab..796e6d15 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; @@ -337,7 +337,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."; @@ -389,6 +389,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 0bdfa727..caf0030e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -147,7 +147,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); @@ -1250,7 +1250,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 = @@ -1299,13 +1299,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; + /* * Configure the H/V flip controls based on the combination of * the sensor and user transform.