From patchwork Tue Mar 23 14:36:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11667 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 C68ACC32E5 for ; Tue, 23 Mar 2021 14:36:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E05F68D74; Tue, 23 Mar 2021 15:36:19 +0100 (CET) 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="CvpXxGbf"; dkim-atps=neutral Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C06A68D65 for ; Tue, 23 Mar 2021 15:36:17 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id e7so23646129edu.10 for ; Tue, 23 Mar 2021 07:36:17 -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=Pzvorr6SD2Xy1ydO1rmjBLXE5yybuLLY0wcln6JsWjg=; b=CvpXxGbfc80quu7weBjisOo8rX20sfWdC7pZsrvfoKubmgNhjf2RwVll/IRwRmxZRQ p9+9pcGhs4GeO92nXEqwjdoGgBg1sAmWIBjMsvLpLPtudl1tV+2CjiM69Q9ToNe1Izw8 9FxeSOPQnskR2MLccs+YIUvvJTxzrM+h+YrqFycdsnk0KXFGVmVNMdLngMz0Mh5/acwW QfHbHEs1Rtedx9voJpw215Dbm8LsFjmwknnRh6VUaucNrP5jHBckTGiUSmjTujAxRM9Y 7tbKuFKPqFby1cghAz1t2J/jlOB+Z1VUGBTxikM6r5tval4G8BGiLNFZMDmjgi+0I+is cNbw== 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=Pzvorr6SD2Xy1ydO1rmjBLXE5yybuLLY0wcln6JsWjg=; b=kkiEdgJtumWZsBk5AZ49Wo/7dn9h+MMfh+0iWHu5bYs8DKTXsdihfU9IJYMllJXbgt xeov2dku6Nn6W/rxkg3Ibe/HIJWhxYQzaQER0LqHNCJGQdyDIZN4go4rd6TtrOn03pUB b853RaSkJRAf4H5ZznylaxFeYvPTRneLMVqCbzIjv+z+0d2N3k789e9Sus+AnUGNdaXL y7apw1i6e2+1YylzRaPLftMNZmlx45s8UOuvg2CDOkKHb0pyCNXOm+kEoP/J+gI0cUKL 6yleT6G5imCdiGvJtogwVXx6K7ETpmnuz6VaC+AIVVqiRItcYgTroJ1vQW32p7leqgCT MBag== X-Gm-Message-State: AOAM533TzyThZwq5jyDhFdYo+JlDBp+Z8W3QD72q/Y22Cn4LWOTt/ofi QA3d+Bc3njiCnGUCGhcv5O4xj8MwE7Fk+A== X-Google-Smtp-Source: ABdhPJwQPsNfkhSlfnnW8RdCXsyHfrsAAGrq5Msoc/5SucarQ6/1G/9MJxJl3nFVJQUrvvDZqdSiRA== X-Received: by 2002:aa7:da04:: with SMTP id r4mr4887289eds.343.1616510176643; Tue, 23 Mar 2021 07:36:16 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:16 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:04 +0000 Message-Id: <20210323143610.787760-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/7] ipa: Add sensor model string to IPASettings 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" Pass the sensor model string to the IPA init() method through the IPASettings structure. Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/core.mojom | 8 ++++++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 3 ++- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- test/ipa/ipa_interface_test.cpp | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index 5236a672461c..5363f1c5b48b 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -145,8 +145,16 @@ struct IPABuffer { * This field may be an empty string if the IPA doesn't require a configuration * file. */ + + /** + * \var IPASettings::sensorModel + * \brief The sensor model name + * + * Provides the sensor model name to the IPA. + */ struct IPASettings { string configurationFile; + string sensorModel; }; /** diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 2ea13ec9e1b9..c27120710323 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1144,7 +1144,8 @@ int IPU3CameraData::loadIPA() ipa_->queueFrameAction.connect(this, &IPU3CameraData::queueFrameAction); - ipa_->init(IPASettings{}); + CameraSensor *sensor = cio2_.sensor(); + ipa_->init(IPASettings{ "", sensor->model() }); return 0; } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 00fa62c972ed..2c8ae31a28ad 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1227,7 +1227,8 @@ int RPiCameraData::loadIPA() ipa_->setIspControls.connect(this, &RPiCameraData::setIspControls); ipa_->setDelayedControls.connect(this, &RPiCameraData::setDelayedControls); - IPASettings settings(ipa_->configurationFile(sensor_->model() + ".json")); + IPASettings settings(ipa_->configurationFile(sensor_->model() + ".json"), + sensor_->model()); return ipa_->init(settings); } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 57c65b021c46..2dfb63ecf2ef 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -425,7 +425,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) data->ipa_ = IPAManager::createIPA(this, 0, 0); if (data->ipa_ != nullptr) { std::string conf = data->ipa_->configurationFile("vimc.conf"); - data->ipa_->init(IPASettings{ conf }); + data->ipa_->init(IPASettings{ conf, data->sensor_->model() }); } else { LOG(VIMC, Warning) << "no matching IPA found"; } diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 4b88806f8f67..d6ca6f5137b0 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -104,7 +104,7 @@ protected: /* Test initialization of IPA module. */ std::string conf = ipa_->configurationFile("vimc.conf"); - int ret = ipa_->init(IPASettings{ conf }); + int ret = ipa_->init(IPASettings{ conf, "vimc" }); if (ret < 0) { cerr << "IPA interface init() failed" << endl; return TestFail; From patchwork Tue Mar 23 14:36:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11668 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 D8B65C32E5 for ; Tue, 23 Mar 2021 14:36:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C13D68D72; Tue, 23 Mar 2021 15:36:20 +0100 (CET) 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="TYNjB+Sk"; dkim-atps=neutral Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7048168D65 for ; Tue, 23 Mar 2021 15:36:18 +0100 (CET) Received: by mail-ed1-x530.google.com with SMTP id bf3so23739578edb.6 for ; Tue, 23 Mar 2021 07:36:18 -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=Dg1kohCDnlbbmNrW1evKNAxuUx8rW+M7gQwLQR9oWac=; b=TYNjB+Sk2x/HPRgH8Dfe96SzzNw2L2RKvxccNZyJG5xFBF34mTWyFhz7I0sveKsodB 0/ZLxYiMuG0pz/KeEEfZDzL00UjL0rAFM0SDXNsS1IBawVpy57cy8WT5yh86rg2A3I+3 gFXL1b/ypAML+Fj+m3CiCrbhXqt77YkelMtMWRw76gwFWDqVgRJvjeQSLTY1t0fggz/B VbAIWQloJusQqWHikt2Vm7jLYP+jDZkPQGncjgQn9ZtsCw359rKDliLK4vfznswuZz1Z wUKLFnt50RV9E+UyDOd2Oz3aepoLdEzrZh9QDkaK0xmeIukOfvH/q/oi/OmBGIlvixqK D+YQ== 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=Dg1kohCDnlbbmNrW1evKNAxuUx8rW+M7gQwLQR9oWac=; b=uijubrxyIulntcSvrr5/ppnNI3CrKOyWjusr+av3GAEysACq3zBu/Ac9z7QQZSzbBi GVTC5pyRGOCtibNrdiFZTVz5Pt41lc915cgkZ+FNnSEUTXcyUpSjUMdS3V7cJIgJ8oHn mwtDnqIU5cWO2+mvt5pC8tuK3cqUKmaB9UUcYYrd5L1aoPQXxoyEfdqjlJKgdM35rTFe SF83dG9xPCI3YbwFDiBGiYU3MjzYqKIJvZgTFEJggp3gAANH1lMHmFgrCIurx7nFMptw mqsS7yNlFGWzP6WkxLfnAb+Y2Ye7/G77pKgCjCNc+1O5IQ7tyPp+7lzyDs0REHyGy5Qi 9fPw== X-Gm-Message-State: AOAM533G1LZFwVca39tXDYYZcZxmLBpuPs1HM1oA3S4eIcw/PhQKbt1p TB7solBFfMyaCf7hS74R9ITm4nNzFBi5lw== X-Google-Smtp-Source: ABdhPJyydutqoPZJsEe26s2A+zqGLhGFOOeJb8SPAU6vjxtKmP07oC5dQc87tFq3bE0NY+bbSkCKYA== X-Received: by 2002:a05:6402:181a:: with SMTP id g26mr4865446edy.225.1616510177725; Tue, 23 Mar 2021 07:36:17 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:17 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:05 +0000 Message-Id: <20210323143610.787760-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/7] pipeline: ipa: raspberrypi: Open the CamHelper on ipa::init() 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" Move the opening of the CamHelper from ipa::configure() to ipa::init(). This allows the pipeline handler to get the sensor specific parameters in pipeline_handler::match() where the ipa is initialised. Having the sensor parameters available earlier will allow selective use of the embedded data node in a future change. Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.mojom | 8 +-- src/ipa/raspberrypi/raspberrypi.cpp | 62 +++++++++---------- .../pipeline/raspberrypi/raspberrypi.cpp | 36 +++++------ 3 files changed, 46 insertions(+), 60 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index eb427697d349..fafbd6c0cff3 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -15,10 +15,6 @@ enum BufferMask { /* Size of the LS grid allocation. */ const uint32 MaxLsGridSize = 0x8000; -enum ConfigOutputParameters { - ConfigSensorParams = 0x01, -}; - struct SensorConfig { uint32 gainDelay; uint32 exposureDelay; @@ -40,8 +36,6 @@ struct ConfigInput { }; struct ConfigOutput { - uint32 params; - SensorConfig sensorConfig; ControlList controls; }; @@ -51,7 +45,7 @@ struct StartControls { }; interface IPARPiInterface { - init(IPASettings settings) => (int32 ret); + init(IPASettings settings) => (int32 ret, SensorConfig sensorConfig); start(StartControls controls) => (StartControls result); stop(); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 7904225a29fa..a5b4b3110abf 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -79,7 +79,7 @@ public: munmap(lsTable_, ipa::RPi::MaxLsGridSize); } - int init(const IPASettings &settings) override; + int init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig) override; void start(const ipa::RPi::StartControls &data, ipa::RPi::StartControls *result) override; void stop() override {} @@ -164,9 +164,35 @@ private: double maxFrameDuration_; }; -int IPARPi::init(const IPASettings &settings) +int IPARPi::init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig) { tuningFile_ = settings.configurationFile; + + /* + * Load the "helper" for this sensor. This tells us all the device specific stuff + * that the kernel driver doesn't. We only do this the first time; we don't need + * to re-parse the metadata after a simple mode-switch for no reason. + */ + helper_ = std::unique_ptr(RPiController::CamHelper::Create(settings.sensorModel)); + if (!helper_) { + LOG(IPARPI, Error) << "Could not create camera helper for " + << settings.sensorModel; + return -EINVAL; + } + + /* + * Pass out the sensor config to the pipeline handler in order + * to setup the staggered writer class. + */ + int gainDelay, exposureDelay, vblankDelay, sensorMetadata; + helper_->GetDelays(exposureDelay, gainDelay, vblankDelay); + sensorMetadata = helper_->SensorEmbeddedDataPresent(); + + sensorConfig->gainDelay = gainDelay; + sensorConfig->exposureDelay = exposureDelay; + sensorConfig->vblankDelay = vblankDelay; + sensorConfig->sensorMetadata = sensorMetadata; + return 0; } @@ -301,8 +327,6 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo, return -1; } - result->params = 0; - sensorCtrls_ = entityControls.at(0); ispCtrls_ = entityControls.at(1); @@ -319,36 +343,6 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo, /* Setup a metadata ControlList to output metadata. */ libcameraMetadata_ = ControlList(controls::controls); - /* - * Load the "helper" for this sensor. This tells us all the device specific stuff - * that the kernel driver doesn't. We only do this the first time; we don't need - * to re-parse the metadata after a simple mode-switch for no reason. - */ - std::string cameraName(sensorInfo.model); - if (!helper_) { - helper_ = std::unique_ptr(RPiController::CamHelper::Create(cameraName)); - - if (!helper_) { - LOG(IPARPI, Error) << "Could not create camera helper for " - << cameraName; - return -1; - } - - /* - * Pass out the sensor config to the pipeline handler in order - * to setup the staggered writer class. - */ - int gainDelay, exposureDelay, vblankDelay, sensorMetadata; - helper_->GetDelays(exposureDelay, gainDelay, vblankDelay); - sensorMetadata = helper_->SensorEmbeddedDataPresent(); - - result->params |= ipa::RPi::ConfigSensorParams; - result->sensorConfig.gainDelay = gainDelay; - result->sensorConfig.exposureDelay = exposureDelay; - result->sensorConfig.vblankDelay = vblankDelay; - result->sensorConfig.sensorMetadata = sensorMetadata; - } - /* Re-assemble camera mode using the sensor info. */ setMode(sensorInfo); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2c8ae31a28ad..ce1994186d66 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(); + int loadIPA(ipa::RPi::SensorConfig *sensorConfig); int configureIPA(const CameraConfiguration *config); void statsMetadataComplete(uint32_t bufferId, const ControlList &controls); @@ -1030,11 +1030,24 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) if (data->sensor_->init()) return false; - if (data->loadIPA()) { + ipa::RPi::SensorConfig sensorConfig; + if (data->loadIPA(&sensorConfig)) { LOG(RPI, Error) << "Failed to load a suitable IPA library"; return false; } + /* + * Setup our delayed control writer with the sensor default + * gain and exposure delays. Mark VBLANK for priority write. + */ + std::unordered_map params = { + { V4L2_CID_ANALOGUE_GAIN, { sensorConfig.gainDelay, false } }, + { V4L2_CID_EXPOSURE, { sensorConfig.exposureDelay, false } }, + { V4L2_CID_VBLANK, { sensorConfig.vblankDelay, true } } + }; + data->delayedCtrls_ = std::make_unique(data->unicam_[Unicam::Image].dev(), params); + data->sensorMetadata_ = sensorConfig.sensorMetadata; + /* Register the controls that the Raspberry Pi IPA can handle. */ data->controlInfo_ = RPi::Controls; /* Initialize the camera properties. */ @@ -1214,7 +1227,7 @@ void RPiCameraData::frameStarted(uint32_t sequence) delayedCtrls_->applyControls(sequence); } -int RPiCameraData::loadIPA() +int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig) { ipa_ = IPAManager::createIPA(pipe_, 1, 1); @@ -1230,7 +1243,7 @@ int RPiCameraData::loadIPA() IPASettings settings(ipa_->configurationFile(sensor_->model() + ".json"), sensor_->model()); - return ipa_->init(settings); + return ipa_->init(settings, sensorConfig); } int RPiCameraData::configureIPA(const CameraConfiguration *config) @@ -1293,21 +1306,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) return -EPIPE; } - if (result.params & ipa::RPi::ConfigSensorParams) { - /* - * Setup our delayed control writer with the sensor default - * gain and exposure delays. Mark VBLANK for priority write. - */ - std::unordered_map params = { - { V4L2_CID_ANALOGUE_GAIN, { result.sensorConfig.gainDelay, false } }, - { V4L2_CID_EXPOSURE, { result.sensorConfig.exposureDelay, false } }, - { V4L2_CID_VBLANK, { result.sensorConfig.vblankDelay, true } } - }; - - delayedCtrls_ = std::make_unique(unicam_[Unicam::Image].dev(), params); - sensorMetadata_ = result.sensorConfig.sensorMetadata; - } - if (!result.controls.empty()) { ControlList &ctrls = result.controls; unicam_[Unicam::Image].dev()->setControls(&ctrls); From patchwork Tue Mar 23 14:36:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11669 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 9E2A8C32E5 for ; Tue, 23 Mar 2021 14:36:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 50DBD68D71; Tue, 23 Mar 2021 15:36:22 +0100 (CET) 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="V0M4kLaS"; dkim-atps=neutral Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4081768D58 for ; Tue, 23 Mar 2021 15:36:19 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id bx7so23698146edb.12 for ; Tue, 23 Mar 2021 07:36:19 -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=TqSX6AeFx6Ofk9lAqOuURZEnd2MT/7YTuqLSvTiTddg=; b=V0M4kLaSi8lLelB4h9+J7RkbOtT8elaVVa7AASHrE2shQeb+uLEcqfPDTag/KtOX8O IyfwJMvaE+jUKUX9+6T8gluv9mZG4XPK8ItL0HRa52rB2bg6xbKZ/oRW6Zpzke3mrnFz /Ur1bL47e8ERAhfq1JTZ4VyKm96qgCr+KWqxhvppAm7xCYe4rGckeTm5R4ZuBWhvYjEG Po2FeIvpEHBDH60zlL5Y38Aa6AN3SLkLkfLLOLX62+peThzAxfcEtNlwPYnlWhBDWvkF zpube2IKtgJOOERrjt7YpWeiZLCuDcuRRMwxr2yjDIjW0iGmQV6+c+m4aD+2bjiij5KC Musg== 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=TqSX6AeFx6Ofk9lAqOuURZEnd2MT/7YTuqLSvTiTddg=; b=SkZr7XSTt6yloqWNGFhcKDBLa8dWgkD1hT4CgT4sle0QFe+CYlWn+YXpUaEUVpnVCg giqlicOf+saWN9AroMS8NEAPmTg4OTA6oxhK9nTDVPpBGp7cz9REEmSMz76tU/YeBkC2 wxXAhIK+uwMOyAsUU+09USjiaLvcE+HeHUD8JJVtnQ/UxUw9iPCPcPKE19h3LMWnlAxA PQwCHAN0JhpBwMjt9DefMJFnVi4tbZNwwZ8+CoY7jd4qc3JiUB0zpZIZpl4lE0KwkHn7 0wgFqsLXz3kpGlsP5utQOyipA0K3B0GQ2Gv1dYxnNtoDFO2y/9kE++YKvuoiLEhjzT88 rEUA== X-Gm-Message-State: AOAM533tZzqRCnqWBcGzekX+wTIIDcw7PG0OZbl8woiC1MuxiRYX/kdF SIVOb35R6FHdI0ja1IKe83Tk0Bkimz3Udg== X-Google-Smtp-Source: ABdhPJzUg1yz/oU+9NldiTmmVQwAOYbpUjrhekEZhROtkn+hgkdyjo6BlX0LU0DdAPJYyyxiwpbcEQ== X-Received: by 2002:a05:6402:1d33:: with SMTP id dh19mr4867192edb.362.1616510178628; Tue, 23 Mar 2021 07:36:18 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:18 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:06 +0000 Message-Id: <20210323143610.787760-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/7] pipeline: raspberrypi: Conditionally open the embedded data node 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" Conditionally open the embedded data node in pipeline_handler::match() based on whether the ipa::init() result reports if the sensor supports embedded data or not. Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 59 ++++++++----------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ce1994186d66..ed8cc4ead771 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -138,7 +138,7 @@ class RPiCameraData : public CameraData { public: RPiCameraData(PipelineHandler *pipe) - : CameraData(pipe), embeddedNodeOpened_(false), state_(State::Stopped), + : CameraData(pipe), state_(State::Stopped), supportsFlips_(false), flipsAlterBayerOrder_(false), updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0) { @@ -183,7 +183,6 @@ public: std::unique_ptr delayedCtrls_; bool sensorMetadata_; - bool embeddedNodeOpened_; /* * All the functions in this class are called from a single calling @@ -749,19 +748,13 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) LOG(RPI, Error) << "Failed to configure the IPA: " << ret; /* - * The IPA will set data->sensorMetadata_ to true if embedded data is - * supported on this sensor. If so, open the Unicam embedded data - * node and configure the output format. + * Configure the Unicam embedded data output format only if the sensor + * supports it. */ if (data->sensorMetadata_) { format = {}; format.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA); - if (!data->embeddedNodeOpened_) { - data->unicam_[Unicam::Embedded].dev()->open(); - data->embeddedNodeOpened_ = true; - } - LOG(RPI, Debug) << "Setting embedded data format."; ret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format); if (ret) { @@ -778,14 +771,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) */ if (rawStream) data->unicam_[Unicam::Embedded].setExternal(true); - } else { - /* - * No embedded data present, so we do not want to iterate over - * the embedded data stream when starting and stopping. - */ - data->streams_.erase(std::remove(data->streams_.begin(), data->streams_.end(), - &data->unicam_[Unicam::Embedded]), - data->streams_.end()); } /* @@ -989,24 +974,6 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) data->isp_[Isp::Output1] = RPi::Stream("ISP Output1", isp_->getEntityByName("bcm2835-isp0-capture2")); data->isp_[Isp::Stats] = RPi::Stream("ISP Stats", isp_->getEntityByName("bcm2835-isp0-capture3")); - /* This is just for convenience so that we can easily iterate over all streams. */ - for (auto &stream : data->unicam_) - data->streams_.push_back(&stream); - for (auto &stream : data->isp_) - data->streams_.push_back(&stream); - - /* - * Open all Unicam and ISP streams. The exception is the embedded data - * stream, which only gets opened if the IPA reports that the sensor - * supports embedded data. This happens in RPiCameraData::configureIPA(). - */ - for (auto const stream : data->streams_) { - if (stream != &data->unicam_[Unicam::Embedded]) { - if (stream->dev()->open()) - return false; - } - } - /* Wire up all the buffer connections. */ data->unicam_[Unicam::Image].dev()->frameStart.connect(data.get(), &RPiCameraData::frameStarted); data->unicam_[Unicam::Image].dev()->bufferReady.connect(data.get(), &RPiCameraData::unicamBufferDequeue); @@ -1036,6 +1003,26 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) return false; } + /* + * Open all Unicam and ISP streams. The exception is the embedded data + * stream, which only gets opened below if the IPA reports that the sensor + * supports embedded data. + * + * The below grouping is just for convenience so that we can easily + * iterate over all streams in one go. + */ + data->streams_.push_back(&data->unicam_[Unicam::Image]); + if (sensorConfig.sensorMetadata) + data->streams_.push_back(&data->unicam_[Unicam::Embedded]); + + for (auto &stream : data->isp_) + data->streams_.push_back(&stream); + + for (auto stream : data->streams_) { + if (stream->dev()->open()) + return false; + } + /* * Setup our delayed control writer with the sensor default * gain and exposure delays. Mark VBLANK for priority write. From patchwork Tue Mar 23 14:36:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11670 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 29EB1C32E5 for ; Tue, 23 Mar 2021 14:36:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D5FAD68D80; Tue, 23 Mar 2021 15:36:24 +0100 (CET) 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="n+E7eQtY"; dkim-atps=neutral Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8349768D65 for ; Tue, 23 Mar 2021 15:36:20 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id x21so23712149eds.4 for ; Tue, 23 Mar 2021 07:36:20 -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=/lMzWKO1kPu2+n0bhmCmtBZy0p0aK+9qkfid0q6hd3E=; b=n+E7eQtYUmboT8Z61aR9leUd7Ky0h+5jiZpOaTlOj0/yDq/SQ6UezkTtV6WkzGMFTv FvaXOMT+p7MWxyar/vWZPCPe9Zv7JbDNbaGtLNMs4gHt8U9+DtJOtSqwpbBZHsao0w5x OXJ6LToeK1GbhDB2O2j6QSkgjUIEXeC5zYkyGN9c9od++22ON7X3H8hvRnI39X24MlYI 9843moZ0hYeebKjzel+D0a42RbxfPqfVuws8a0Jsgx1RUWHNCzNS9p4IZHlCWzeycwMm 2/Dk4wbeRpXrPgkU/gamOPcG1nHiXUdc77uhjiozUPLdxWL4piX9fJhTOmIr6ZeQAuj+ gBXw== 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=/lMzWKO1kPu2+n0bhmCmtBZy0p0aK+9qkfid0q6hd3E=; b=RV8g38QOZBGQX2hy+rh3e8PlRG//tmN01GKlj7/MWkhiiIqwdGq1GsRmjaIoHAjznR 21Bq4zV1RNDP/qu4gUfYImjg6tdB0RpIFokCBKc1KristUH+LCsqGJXBfIosS77EjZcz NDb7tbRDynhCbigdQ0VHiCPa3sFnept8qSL+C4Uej33StXJ5IH383Z0ETv+LW2T41Ynn BKjLm/9Z2gfzjGxfMM1jcNl1QxYtzrrbJ51AnTR0V6T/T01HbnAK63VF8jONW7BV9Ata AhY/IZAsXgB7kYGLhFAdJ7/42+AfvBTkxxbuqGPugDSXPg3B4CcXEhXckfu5gZinEJPH bqTA== X-Gm-Message-State: AOAM532N5WFLmw88rZAevmnIS2d+jN9IGXK/l25scorlezR+CguYXArc 0hqVTnQ6ls5AEOTImfZkePmiIF/cUJnS3g== X-Google-Smtp-Source: ABdhPJxX6vy1i7F26zqLWIR5WHW7w1EH7+LblljPxe4iDiuGqQZfng0R2D7QVhaEOE9vPCYM6CAbGA== X-Received: by 2002:a05:6402:c88:: with SMTP id cm8mr4952338edb.62.1616510179836; Tue, 23 Mar 2021 07:36:19 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:19 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:07 +0000 Message-Id: <20210323143610.787760-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/7] ipa: raspberrypi: Move the controller initialise to ipa::init() 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 controller initialise is a one-off operation, so move it from ipa::configure() to ipa::init(). Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/raspberrypi.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index a5b4b3110abf..bd20b144f520 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -67,9 +67,8 @@ class IPARPi : public ipa::RPi::IPARPiInterface { public: IPARPi() - : lastMode_({}), controller_(), controllerInit_(false), - frameCount_(0), checkCount_(0), mistrustCount_(0), - lsTable_(nullptr), firstStart_(true) + : lastMode_({}), controller_(), frameCount_(0), checkCount_(0), + mistrustCount_(0), lsTable_(nullptr), firstStart_(true) { } @@ -127,9 +126,6 @@ private: ControlInfoMap ispCtrls_; ControlList libcameraMetadata_; - /* IPA configuration. */ - std::string tuningFile_; - /* Camera sensor params. */ CameraMode mode_; CameraMode lastMode_; @@ -137,7 +133,6 @@ private: /* Raspberry Pi controller specific defines. */ std::unique_ptr helper_; RPiController::Controller controller_; - bool controllerInit_; RPiController::Metadata rpiMetadata_; /* @@ -166,8 +161,6 @@ private: int IPARPi::init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig) { - tuningFile_ = settings.configurationFile; - /* * Load the "helper" for this sensor. This tells us all the device specific stuff * that the kernel driver doesn't. We only do this the first time; we don't need @@ -193,6 +186,10 @@ int IPARPi::init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConf sensorConfig->vblankDelay = vblankDelay; sensorConfig->sensorMetadata = sensorMetadata; + /* Load the tuning file for this sensor. */ + controller_.Read(settings.configurationFile.c_str()); + controller_.Initialise(); + return 0; } @@ -372,12 +369,7 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo, /* Pass the camera mode to the CamHelper to setup algorithms. */ helper_->SetCameraMode(mode_); - if (!controllerInit_) { - /* Load the tuning file for this sensor. */ - controller_.Read(tuningFile_.c_str()); - controller_.Initialise(); - controllerInit_ = true; - + if (firstStart_) { /* Supply initial values for frame durations. */ applyFrameDurations(defaultMinFrameDuration, defaultMaxFrameDuration); From patchwork Tue Mar 23 14:36:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11671 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 92BCEC32E7 for ; Tue, 23 Mar 2021 14:36:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 400A368D83; Tue, 23 Mar 2021 15:36:25 +0100 (CET) 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="gujPtEfX"; dkim-atps=neutral Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 850DC68D63 for ; Tue, 23 Mar 2021 15:36:21 +0100 (CET) Received: by mail-ed1-x533.google.com with SMTP id dm8so23737751edb.2 for ; Tue, 23 Mar 2021 07:36:21 -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=IBYOmNhWc9VLgjJTDXl+uYxRIPrJR5MK3Zb55BkFyfk=; b=gujPtEfXy7EvG/l0MAVbigoYUPDz+JBzH90x7LmvGXKtKSLzBeR/OuQ1DWIPgc7YBa dAIOJK+Ml6NB/ynICLLaRh+tRU+eBrQai8O26bX10OVL4YrHnmij8vvDsl1S855gyQ/j xzLlhOMWcvO3K/nr/Gqk2hCA/SEUxS7KJTR4teFaZD9m9NRYuPlqSqy1Re/b2AVKdeDf QZMKrq0C/kV4XoKaeBJwlqUVyU76HaMx24W1SgpCneI8+9WDOilVg8YKZBG0jFblwN90 8IaoY6NUTuW9nocpuJS+qy7CTNX5RQrP+l2W/QCxk/GG8pgtfy8LqmKub7sKZYx0e1bF vNjA== 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=IBYOmNhWc9VLgjJTDXl+uYxRIPrJR5MK3Zb55BkFyfk=; b=SoX36g2Ix/oDnFxk0tQv8ykAxVm5UHzqvcQAiCyvlMq6LLbGm7HgBC4yN8sT2hzP83 94viizE4fyptqIYk5a3zCoFemSq3EoWpS7c8AbQC6tVuZ9ZROYhA4jB/HtHEDL68vard NvCFzM0Zhs2uQwaUHzwgvrtAJKy06fbfxSLP+oVSMQk7LbvRVM/UcvJuizXQkJCmWGXn HcsKGgbpaDBRyOWU5VabHBn4v4L3XKbmtQT6LYEaoQmPEaiYSDgIAMiKoTK7LQ5APPkW gBWqsGxeXneXptJfNNLCE2vCjTePsx7ZIfVxdqrfUEFulDCjXWajYoCuOumZOnoYmJ+f zkyQ== X-Gm-Message-State: AOAM532dGYYnV7Kg4gcJ4l9preIY4f+G7j56Pkm+CLUXl/67obnpFl23 9R5MsDAf+RQ7Vr3cdlPeCxseX5mcozZr/Q== X-Google-Smtp-Source: ABdhPJxsmnq2byDec0OfGiWG4Z9+oudIlYCz/+G/o3aYNi3eNIGp144KnLqTO5oY+sJBsBgducjifA== X-Received: by 2002:aa7:c9d1:: with SMTP id i17mr4807220edt.46.1616510180924; Tue, 23 Mar 2021 07:36:20 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:20 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:08 +0000 Message-Id: <20210323143610.787760-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/7] ipa: raspberrypi: Remove unused member variable 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 lastMode_ member variable is now unused, so remove it. Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/raspberrypi.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bd20b144f520..93e43f0626fb 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -67,8 +67,8 @@ class IPARPi : public ipa::RPi::IPARPiInterface { public: IPARPi() - : lastMode_({}), controller_(), frameCount_(0), checkCount_(0), - mistrustCount_(0), lsTable_(nullptr), firstStart_(true) + : controller_(), frameCount_(0), checkCount_(0), mistrustCount_(0), + lsTable_(nullptr), firstStart_(true) { } @@ -128,7 +128,6 @@ private: /* Camera sensor params. */ CameraMode mode_; - CameraMode lastMode_; /* Raspberry Pi controller specific defines. */ std::unique_ptr helper_; @@ -383,8 +382,6 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo, result->controls = std::move(ctrls); } - lastMode_ = mode_; - return 0; } From patchwork Tue Mar 23 14:36:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11672 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 0FF72C32E5 for ; Tue, 23 Mar 2021 14:36:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B6EF68D85; Tue, 23 Mar 2021 15:36:25 +0100 (CET) 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="A3D5AS8z"; dkim-atps=neutral Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A7CCA68D7D for ; Tue, 23 Mar 2021 15:36:22 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id jy13so27456033ejc.2 for ; Tue, 23 Mar 2021 07:36:22 -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=wLRxumWPRLBVEvwTd/U5tZ0D639aXVHsrXNw8yQchI4=; b=A3D5AS8zkIYYMyMq9UP1MGhqG492pS4EQXDpDNBr9SBuRb6zjBy/2eBQ0P7UZjen6X cicRhfbhCLc/7oTlGGDYQ4x2l8qCMjwyCN7uRFlZSh6cpHJlypg3wZEdyWrtFQ7OdjLv cXVzC4N6KCX84FsiP5Iy4vLj443iAgtH9d6X+8tpB8Kw4VbKoP4VncueMxTTQv3HOrWD POgBsnosOpLwCQ/rMV7SmBSdUQs2LAXfPwTBKDrG9w+qppkv8ZlSgCq9qkxOLuoCbsXJ ied6bSVozfTMCwJE3gyZtccjdCiBw6qRjF5UIaO0ogeHu1V1s12sozyDuElfz5U+Yovn wE+w== 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=wLRxumWPRLBVEvwTd/U5tZ0D639aXVHsrXNw8yQchI4=; b=QXfuunBwmvSc3n755kVNsVafQuqke9KSMl8AvfzvM9QmvBF7+j4fewVpMFzW+9InIP bj58p6wqS7EpF7sfNUUDuDJUbA55eAQCdW+Aovs2lULx3n7mRvuzYY+jBfsj8nmIy2cg JQSahLl8xQf0a52n9mkZm4a4rNUMdOBjkw3fqzNtdmAwfk0NiI/25yhJoIL0A7pL5ot3 Ax12UmFAKeaTE/wwoitSBjCb8ChGOckpyGp2qub8NRfwfN0iUt5pVKWpTnvJv5+AFa/Z CjHWCLG+JddT+E7R2/5K6VCl3w1e431if8BU4FyfmvW2dQK753P1ROojAWfwW570FN3D HRAw== X-Gm-Message-State: AOAM533yhgMG1+sW2ZnzzAzghtl5B/ucVZfqKngm/tzA9r6VARyDGSkT 4/szD83FnhOKob2rkEuXVgbc16L5zQ9+AA== X-Google-Smtp-Source: ABdhPJyz6VLYGraO3htHiR7xGlhocD75K1Omrc0wOyTfG+Gma8eaD5GF6DykWIQfOMnMSuKaMioKLg== X-Received: by 2002:a17:907:720a:: with SMTP id dr10mr5162634ejc.375.1616510182034; Tue, 23 Mar 2021 07:36:22 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:21 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:09 +0000 Message-Id: <20210323143610.787760-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/7] ipa: raspberrypi: Rationalise parameters to ipa::start() 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" Separate out the in and out parameters in ipa::start() as they are not the same. This function now takes in a ControlList and returns out a struct StartConfig which holds a ControlList and drop frame count for the pipeline handler to action. Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.mojom | 4 ++-- src/ipa/raspberrypi/raspberrypi.cpp | 16 +++++++--------- .../pipeline/raspberrypi/raspberrypi.cpp | 15 +++++---------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index fafbd6c0cff3..55824eebb700 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -39,14 +39,14 @@ struct ConfigOutput { ControlList controls; }; -struct StartControls { +struct StartConfig { ControlList controls; int32 dropFrameCount; }; interface IPARPiInterface { init(IPASettings settings) => (int32 ret, SensorConfig sensorConfig); - start(StartControls controls) => (StartControls result); + start(ControlList controls) => (StartConfig startConfig); stop(); /** diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 93e43f0626fb..b717a83e14b5 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -79,8 +79,7 @@ public: } int init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig) override; - void start(const ipa::RPi::StartControls &data, - ipa::RPi::StartControls *result) override; + void start(const ControlList &controls, ipa::RPi::StartConfig *startConfig) override; void stop() override {} int configure(const CameraSensorInfo &sensorInfo, @@ -192,15 +191,14 @@ int IPARPi::init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConf return 0; } -void IPARPi::start(const ipa::RPi::StartControls &data, - ipa::RPi::StartControls *result) +void IPARPi::start(const ControlList &controls, ipa::RPi::StartConfig *startConfig) { RPiController::Metadata metadata; - ASSERT(result); - if (!data.controls.empty()) { + ASSERT(startConfig); + if (!controls.empty()) { /* We have been given some controls to action before start. */ - queueRequest(data.controls); + queueRequest(controls); } controller_.SwitchMode(mode_, &metadata); @@ -215,7 +213,7 @@ void IPARPi::start(const ipa::RPi::StartControls &data, if (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) { ControlList ctrls(sensorCtrls_); applyAGC(&agcStatus, ctrls); - result->controls = std::move(ctrls); + startConfig->controls = std::move(ctrls); } /* @@ -262,7 +260,7 @@ void IPARPi::start(const ipa::RPi::StartControls &data, mistrustCount_ = helper_->MistrustFramesModeSwitch(); } - result->dropFrameCount = dropFrame; + startConfig->dropFrameCount = dropFrame; firstStart_ = false; } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ed8cc4ead771..a65d53898362 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -815,20 +815,15 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->applyScalerCrop(*controls); /* Start the IPA. */ - ipa::RPi::StartControls ipaData; - ipa::RPi::StartControls result; - if (controls) - ipaData.controls = *controls; - data->ipa_->start(ipaData, &result); + ipa::RPi::StartConfig startConfig; + data->ipa_->start(controls ? *controls : ControlList{}, &startConfig); /* Apply any gain/exposure settings that the IPA may have passed back. */ - if (!result.controls.empty()) { - ControlList &ctrls = result.controls; - data->unicam_[Unicam::Image].dev()->setControls(&ctrls); - } + if (!startConfig.controls.empty()) + data->unicam_[Unicam::Image].dev()->setControls(&startConfig.controls); /* Configure the number of dropped frames required on startup. */ - data->dropFrameCount_ = result.dropFrameCount; + data->dropFrameCount_ = startConfig.dropFrameCount; /* We need to set the dropFrameCount_ before queueing buffers. */ ret = queueAllBuffers(camera); From patchwork Tue Mar 23 14:36:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11673 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 3ECCAC32E5 for ; Tue, 23 Mar 2021 14:36:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EFFA468D79; Tue, 23 Mar 2021 15:36:29 +0100 (CET) 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="d38wnSNI"; dkim-atps=neutral Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A607B68D70 for ; Tue, 23 Mar 2021 15:36:23 +0100 (CET) Received: by mail-ed1-x52d.google.com with SMTP id j3so23673193edp.11 for ; Tue, 23 Mar 2021 07:36:23 -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=MjuUN3XXLe4QH8PuBMguhkBjRZOS/nt2VbKQfSafdxw=; b=d38wnSNIZItkiM8HZv2YsHDoKqHzGrKxUJFJ0VZAAYgLiaMA0lX+dFUhWh7ersvIDI E1UqFFBroKDnL1JSXA/e9f8qV/Aw8tQxiIjhkOU2VlVN/3IIeTBj5Ljy+vMoK5KtTOm/ hU1tnhPPqiIT9h0GbvUtqRx2Awd/0YxSRi+GyMOstYeKPnFanH3ISxkJ42C0F85UfCXq 6P9cx8iQVtfIixtmbsCAEWoMfa29Irnwuq2qF74CIaIw7ZEMKMP+kyhC+zNyutMkVXLM Uxm0uB+n3wT600XQDVn85iuGrzYU1505jdQK98fVmhb+V+tNqALXT4x1x55nJ8cCW/Kh io4Q== 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=MjuUN3XXLe4QH8PuBMguhkBjRZOS/nt2VbKQfSafdxw=; b=MlcQgblgNxqA/9faD3uBbmchLsh8lUODFEJxdDg4vNxxSu4ZH8xhF6r/ZYCpSBUiEO 90pBjmMHYc6vYK/yx2GHdv4+ue01MGUSJsWvC9JfxrltkeleW6Y23gH9ed7eH3lJd50g 1GmRt7vQkDdGUGYznVtOsEo+1uDSr+zKf+Y1x6WZu+f1yRIhMwxwL7daYQJoTKYpw/5N +rXgI8XuIve5Zp+se//kVFUejpQDjjeXSr5kfZPrnXi/B18fQsKb/dVeUWjFJ1lo9pae 4swXMtG3b4MpMd0b2EBhCPF6cdtavX0I3BtiigsM8sre/1CgengLtpzFpIq+qwFtQ9mO gbuQ== X-Gm-Message-State: AOAM5333qLC+SxQyzQDtiSLp10g6I0tqfBMpQ61tIVljyVstVOEdyf92 zh0H6do+pvf99OysZeTy27Wqeo026ZsLiw== X-Google-Smtp-Source: ABdhPJz97f1EnFFz5pzLkR8Gps0U6YMGwlb6LZOmbPhy8Nqfz4ohwrZ2cmY4MXY4Qzc5Csgfv79aqw== X-Received: by 2002:aa7:c398:: with SMTP id k24mr4911468edq.61.1616510183064; Tue, 23 Mar 2021 07:36:23 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:22 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:10 +0000 Message-Id: <20210323143610.787760-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/7] ipa: raspberrypi: Rationalise parameters to ipa::configure() 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" Rename ConfigInput to IPAConfig to be more consistent with the naming, and remove ConfigInput::op, as it is never used. Replace ConfigOutput with a ControlList type, as that is the only return type from ipa::configure(). Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.mojom | 15 +++++---------- src/ipa/raspberrypi/raspberrypi.cpp | 11 ++++++----- .../pipeline/raspberrypi/raspberrypi.cpp | 13 +++++-------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 55824eebb700..f38c22611cc4 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -29,16 +29,11 @@ struct ISPConfig { ControlList controls; }; -struct ConfigInput { - uint32 op; +struct IPAConfig { uint32 transform; FileDescriptor lsTableHandle; }; -struct ConfigOutput { - ControlList controls; -}; - struct StartConfig { ControlList controls; int32 dropFrameCount; @@ -56,7 +51,7 @@ interface IPARPiInterface { * \param[in] streamConfig Configuration of all active streams * \param[in] entityControls Controls provided by the pipeline entities * \param[in] ipaConfig Pipeline-handler-specific configuration data - * \param[out] results Pipeline-handler-specific configuration result + * \param[out] controls Controls to apply by the pipeline entity * * This method shall be called when the camera is configured to inform * the IPA of the camera's streams and the sensor settings. @@ -64,14 +59,14 @@ interface IPARPiInterface { * The \a sensorInfo conveys information about the camera sensor settings that * the pipeline handler has selected for the configuration. * - * The \a ipaConfig and \a results parameters carry data passed by the + * The \a ipaConfig and \a controls parameters carry data passed by the * pipeline handler to the IPA and back. */ configure(CameraSensorInfo sensorInfo, map streamConfig, map entityControls, - ConfigInput ipaConfig) - => (int32 ret, ConfigOutput results); + IPAConfig ipaConfig) + => (int32 ret, ControlList controls); /** * \fn mapBuffers() diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index b717a83e14b5..1c928b72fbd0 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -85,8 +85,8 @@ public: int configure(const CameraSensorInfo &sensorInfo, const std::map &streamConfig, const std::map &entityControls, - const ipa::RPi::ConfigInput &data, - ipa::RPi::ConfigOutput *response) override; + const ipa::RPi::IPAConfig &data, + ControlList *controls) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; void signalStatReady(const uint32_t bufferId) override; @@ -313,8 +313,8 @@ void IPARPi::setMode(const CameraSensorInfo &sensorInfo) int IPARPi::configure(const CameraSensorInfo &sensorInfo, [[maybe_unused]] const std::map &streamConfig, const std::map &entityControls, - const ipa::RPi::ConfigInput &ipaConfig, - ipa::RPi::ConfigOutput *result) + const ipa::RPi::IPAConfig &ipaConfig, + ControlList *controls) { if (entityControls.size() != 2) { LOG(IPARPI, Error) << "No ISP or sensor controls found."; @@ -377,7 +377,8 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo, agcStatus.analogue_gain = DefaultAnalogueGain; applyAGC(&agcStatus, ctrls); - result->controls = std::move(ctrls); + ASSERT(controls); + *controls = std::move(ctrls); } return 0; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index a65d53898362..2cac802c72e5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1236,7 +1236,7 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) std::map streamConfig; std::map entityControls; - ipa::RPi::ConfigInput ipaConfig; + ipa::RPi::IPAConfig ipaConfig; /* Get the device format to pass to the IPA. */ V4L2DeviceFormat sensorFormat; @@ -1279,19 +1279,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config) } /* Ready the IPA - it must know about the sensor resolution. */ - ipa::RPi::ConfigOutput result; - + ControlList controls; ret = ipa_->configure(sensorInfo_, streamConfig, entityControls, ipaConfig, - &result); + &controls); if (ret < 0) { LOG(RPI, Error) << "IPA configuration failed!"; return -EPIPE; } - if (!result.controls.empty()) { - ControlList &ctrls = result.controls; - unicam_[Unicam::Image].dev()->setControls(&ctrls); - } + if (!controls.empty()) + unicam_[Unicam::Image].dev()->setControls(&controls); /* * Configure the H/V flip controls based on the combination of