From patchwork Tue Mar 23 12:27:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11658 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 37FC8C32E5 for ; Tue, 23 Mar 2021 12:27:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E70368D6C; Tue, 23 Mar 2021 13:27:47 +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="CqptGzeZ"; dkim-atps=neutral Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5251D602D7 for ; Tue, 23 Mar 2021 13:27:45 +0100 (CET) Received: by mail-ej1-x635.google.com with SMTP id b7so26791279ejv.1 for ; Tue, 23 Mar 2021 05:27:45 -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=J030fngYYhH7A6mLzY/lY5VD3s2pUrc6fPTU9ImqEVU=; b=CqptGzeZQeZ+0cqwNgxPytPAtcET0pkuVHiICjqlPJB8wh9ZMt5BlguWBeBz/o6/pD 17kO48U7Aiq9+JXVWYuzHmJzRm5yw/V/V+yqUrRvvoDQbe36h4BAWzKGlVKOiANU6Lr5 CHW5Vs97j/+Q+kMRxXEJCuxI8+uepYIrPByMceb/2rRwhdnA8RZowyaruHAzi+E1BZPq 0hG5Gk+jJg5mtbJetImE6A2xrr619fZ7AyfPchj4FVDNIcAW4hvPJLBelMASoJowDMA4 jxZHdUJcGY4EvJI5cXYv53X7H1CAjdSjrUAu7xY5w5/SY8JjgrTm+uAjvyEnRYmJVaEN Pqcw== 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=J030fngYYhH7A6mLzY/lY5VD3s2pUrc6fPTU9ImqEVU=; b=PwYauSLTJy+JhvXYJNiKLL9gOezKk4NOfghoZ4kplO710Esqc3d9ucCP1k6B7YTb5Q k92vx3hWF3mMfqBwznFPj9jpbdU8jgTVv7nWzY9FAtYZG7TEEpfSnxFhK63QSV6cAq6x HkxSC1G4B9u7dDjHX4PxsIvvlNxyuanlFqerdbtBfwelhm4X2tHu0ybc6FgglNiIdYQc HrCAC0Kf2aFs4b7SHxk64kTSTx151J0MDekYq2zU/hc+hTrcWp9varoNYNZTEokM67fy mlNfaJ2eyo/PZD4y3MDJPgvcQjjJ82rroygDe3m6aKBUjf5G8a9/ijrs5T4WLEG+q8j9 KJEA== X-Gm-Message-State: AOAM5305I3tQSzOofWARwnek/avfGKe0YzVVvtFdZF2i1FvH0LhkvIlf 0gh1AxOtSEjuZwL3A6BS+zDOUqVCpYKNqQ== X-Google-Smtp-Source: ABdhPJyWHddAKwd912/tv/zg1zVyIcmkuNr9uMNq7ruUGNliGa6u9PEeSDobHWwqDtAOVc9iQt3AdQ== X-Received: by 2002:a17:906:3409:: with SMTP id c9mr4671918ejb.314.1616502464739; Tue, 23 Mar 2021 05:27:44 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:44 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:33 +0000 Message-Id: <20210323122739.680560-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 12:27:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11659 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 9960DC32E5 for ; Tue, 23 Mar 2021 12:27:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C6E368D71; Tue, 23 Mar 2021 13:27:52 +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="jX4nLqGw"; dkim-atps=neutral Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E92768D5E for ; Tue, 23 Mar 2021 13:27:46 +0100 (CET) Received: by mail-ej1-x629.google.com with SMTP id e14so8560224ejz.11 for ; Tue, 23 Mar 2021 05:27:46 -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=jX4nLqGwd4mUpk+PcdBIqMDXjru+M5O1oTpsUijfzKtjzZ+9S7jW769XkXCtgxUEvK EHw+Uofxa2P2bg190+4D6luMAu+JYPuTZMbZ5YX+TU1v+fGw69t71j+IQ/XOB0895nYV TY6UT5yKVj2CTHLSgWHHE2GcJNll/3JWHUHAgPMxP20/HF8B01+yllJiL9L7AohhQPQc hz+RYbOhS/25dnpL5k+UIVZcnlec39ywQvlHL7tvpdkKGJYVM5kenj2vi0ak8nxGtAOK irRolQccglVzNAMF4HNcdMkgLIhNCLbtyqmkYTQzbTCMKcaxyOLU8irOVBfsSQB09oAL K8Tg== 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=efr2i73Oco5oBwL0zlbwpN7cZ3pyq81nL4TPJBxUHUozxpzgq9NFs8pYRVKeGTZlE5 QyIH716Jsnq1SbK3vNIah2ONkEx42Fahv2op4HYkAbGOw9K1JkRyONPigaMkkClxEy3d +2VBeqlooPiqkh/0Q+u2JAH8cjOAMMHlZPcUF+1euKXaI4fSGzpgu1F/51t6xdHWNbUv 1yEBoZymri6HFAEmnZZxR/Ep0PTOYewhSB564/VHjcDF1ayxZF74NPJPwT5WEQywIe5a ONw4kPWD8uspuF/zfxX+CyPafYsFyqM34xx1OKnPKtrD/71WDzzZIQnIMjPm9KDE05s3 RWiw== X-Gm-Message-State: AOAM531hvk46XFVyfFBXMPTliUQ2QiEp68d+pP/Ny/LVolbEpFOXg//F Xy+dtjpPCpUqB6W5JLFFf89yLifYjUUFiQ== X-Google-Smtp-Source: ABdhPJyP5eLBGYjzq1UmshZWpdWDyHCBG6oRUpuuIJ/T2ZOrau2yP1jwE3a2fy0Ew33BVhFXuoM3Dg== X-Received: by 2002:a17:906:5295:: with SMTP id c21mr4679247ejm.67.1616502465679; Tue, 23 Mar 2021 05:27:45 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:45 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:34 +0000 Message-Id: <20210323122739.680560-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 12:27:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11660 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 1A2F7C32E7 for ; Tue, 23 Mar 2021 12:27:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CAFE168D72; Tue, 23 Mar 2021 13:27:52 +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="gWKEbrmi"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 453E668D6F for ; Tue, 23 Mar 2021 13:27:47 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id u21so8806771ejo.13 for ; Tue, 23 Mar 2021 05:27:47 -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=QtqZr5rtt4mlK1CaM05cbcrCVPywpqagw6arr7vbGwA=; b=gWKEbrmi1zVCyhGrHBuYnfS75abSM3637iIXwbpI7UtCDERbIXsxC+XGLL3inDCbnI 8paRerxtlbVL2IaUbF1Ql6QwAGMTzOrMNpEXkg1FYppxHmaaRpdnA1dm1xUxPyojLr4h 36bPjSHPdirhnS3AC1O0qFfvn+uQNFmGQfJd9TbFd/VkGBcgpyPrKQBAToB9wmX3De+z 7k8h38MgJXJc1k1wqjs07AmWMEavAMiz6j3dlDP2CSLTmJ3NxUi844oGThjxg7lhlR8W SX7LAebMk0yJD4zEpfBQbw7NiKuP/B/R+w2VY7Sp3NaOyJc31k6as83FCWgtGWdILGh3 2qnA== 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=QtqZr5rtt4mlK1CaM05cbcrCVPywpqagw6arr7vbGwA=; b=QvXPLdaY7Z7tWWpAs+PYksqtFasit6QAPHJ9f/jkJ4vkFH6FSlqWAXSDPkvh6xbAHp pPhdVwUiQ7rnUgvgCA1sCG6YzpiV9JBajqH5l/NS3X3CwPr7y9HmaK/Xjtv87bXT+3++ G4IqsSMp8dK33dfgqlVYoBVfL4arA3Mdtc5FkTZ5hPtAEecGmQQ/jYOCY5UYKq0PcXCF ntCCq0VEJMimgPLmkrUivHN8FFNxRF/LE8vSWuB9TwJicsz+W6W/A+gsJtXs57AAtPIN BPC7lUjxBZRoU9HsNJXgCZMJymISOZPay7cJY9k9477C4kRuDQpNu+t4aqJK3q7g7bRS L9Bg== X-Gm-Message-State: AOAM532963C2kRkfciYbcgfnXyHA5+mTK/ptKOO0gJOVmERUH/o63Qg0 zWE5uSGI/5zbkx9B+ve6lVvrN2sgD5m2MQ== X-Google-Smtp-Source: ABdhPJwsO2anyBbMaw2gHN/BeV8omLm/ag8nAhhdIDpYo9uUstPEbgmeZnGzcNDrI0Lww/FsK84INw== X-Received: by 2002:a17:906:11d1:: with SMTP id o17mr4626135eja.517.1616502466574; Tue, 23 Mar 2021 05:27:46 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:46 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:35 +0000 Message-Id: <20210323122739.680560-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 57 +++++++------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ce1994186d66..4a3f7cbe3065 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,24 @@ 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); + 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 12:27:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11661 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 CFF56C32E5 for ; Tue, 23 Mar 2021 12:27:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6F61168D73; Tue, 23 Mar 2021 13:27:53 +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="ntxIWY3i"; dkim-atps=neutral Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D3A368D63 for ; Tue, 23 Mar 2021 13:27:48 +0100 (CET) Received: by mail-ej1-x635.google.com with SMTP id e14so8560356ejz.11 for ; Tue, 23 Mar 2021 05:27:48 -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=ntxIWY3iu1T0tWci61AcB08K0wl8bYzuJLuC5KHCwOdyMZSdwJdF4WSeFuoJsvo5Dn JrxVzkcwjtMBWZ02cr93EzDQEzNY0Bf6T2KQPWnOnRxD7PI/fvTOSFGZiubWxsEEdjfm BsJqKxmugSqLxNhhQBSLVvYhZe4L9kVQVN7IqTgTvx8wLTRixNgor1xPdtJAwyvyinxs wF8X0iOjRhSc55voX6eNKmyNOIGJZOnzJzutAWFF55KeF4GzD7uNvMxfylNDoMBsJBdE 2YmsAWsc1VfsbyA4MSQ07vBZBngeWJ4yMkJc1ipLRCBxP5ty1Xi418OkoX6zmXIaGG1r 0Qnw== 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=CiPIsHPh/oO5lmpy5Re6SIy1ru6KPfzTVbJhTQyb8J7TtsZYG7zk7ig1UVbX39WD3P ae8zvQItwt6/HFhIpyk/Kobd8Vjke/SrUnurP/Dibbu1z8/jM+akZaySUImK22RRVUxX 0LcU7G30+V5ZdAxQLTnYwC5OhdqfBuY2pHcYE85ClWfn4hIrhISV6jPQTXCRPAQ/ZID+ M5wCx26Teqks5TfjrTaPmQ3ehOm9krwEDkk6fbMcP2qVsWAQ3QNT1HB2bUoC/TlRoEPt aEhX4BQdDVx2jXpSQcWDPQci7/VPyPcLnJGMicSGe++mW+FzArfDhg9ICkJnYBOw64/4 x5eA== X-Gm-Message-State: AOAM533gXh80zC18e+jyZK8mp7JJVGxTT8rEyaNB20OKkoNAfXY4uayW 1WMb4Rbgwm63UN4twJ9iVvatHZwnERL16g== X-Google-Smtp-Source: ABdhPJyyjk17+UfqkHVkicBXIfmSAiAewY+FPJC6lKxbJyxddI/F3yI1hd4khs032ELUBeNtF9eLUw== X-Received: by 2002:a17:906:6882:: with SMTP id n2mr4676131ejr.50.1616502467615; Tue, 23 Mar 2021 05:27:47 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:47 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:36 +0000 Message-Id: <20210323122739.680560-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 12:27:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11662 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 678FBC32E5 for ; Tue, 23 Mar 2021 12:27:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14E2168D74; Tue, 23 Mar 2021 13:27:54 +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="Ms78kzWY"; dkim-atps=neutral Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 12C7968D63 for ; Tue, 23 Mar 2021 13:27:49 +0100 (CET) Received: by mail-ed1-x535.google.com with SMTP id h10so23181787edt.13 for ; Tue, 23 Mar 2021 05:27:49 -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=Ms78kzWYh92HCLb/q5jAbav20/7Nfjdb/mimJi4ezoCQthDWsq25gKXeLlXlQsLAHm XxcK9JG6OD2bb0MQDO17XXYKZylEPBXBh99wlY3Kog0UpP1gpFKqoTehtFa5dTAzr0pg 3QJm+Rn4VY/jWA3DU1o8w0fq2T2Mh5QwX/as639t9ShQkJ9K8L6J46Ur2JcpSqOFUoFZ GrEhyDv3Lmnj7bj5d+fBY93qG1mxmWtqQDSmLZbfrYv0csImOSc3XDx16KfCk9iG3B2E /vev+cM1c48Emyt1wytpaQ4soImcyHjT1gi9L8dBxT3xyd/VWF5chKFRxtLECrCzAxfQ 3bWQ== 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=UPcP4nwrDGXoLdsbuccSBI0u6YvC2ppzqzEbeF1IpWaGTeR6tSjnflQ6IKOK3UFJBb I14fU+UiMhhSLVnQTntrpP0+9bCYawYO6mZC8EP6oc4E2yqo9hhbnWh1zfB6LsbGGVVV pnIM8nfWwi+QXGZZWPcGXhTg6UAX4ksjuPi34h2NoMWxOK78DW1WBxwoPuDaIBh9pw6c j9tioSYzHz5gJ5A8Vfwe8fcO6B9aYLWAaurNmtLGPjz/X2bNJZ4PwWI3NI4Dqa54Z46N arD1nMbTKzPfTrBp+C7QaSzqsyNaeOwQ21h5KqirxHGXAU67+v2Tz3scEvhOVBH1fugI 82nQ== X-Gm-Message-State: AOAM531BRa1sGs2poQuf6aWKonLCCZsIey+LG1fwj1xNjgoGO2kvTyUI Yxp2dfpkcU/ceo/kp6KVs3QwaK3JT5z3RQ== X-Google-Smtp-Source: ABdhPJx7lhFmtOCOCAnup7LXGpUpVlNQLLPPooB9U6mUIwdC88i7Ivk4vYv8vPaspUJk3eu5gu+wSA== X-Received: by 2002:a05:6402:1d1a:: with SMTP id dg26mr4291130edb.266.1616502468449; Tue, 23 Mar 2021 05:27:48 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:48 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:37 +0000 Message-Id: <20210323122739.680560-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 12:27:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11663 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 325E4C32E5 for ; Tue, 23 Mar 2021 12:27:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B90B468D75; Tue, 23 Mar 2021 13:27:54 +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="L7HSBC7B"; dkim-atps=neutral Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D6D668D63 for ; Tue, 23 Mar 2021 13:27:50 +0100 (CET) Received: by mail-ed1-x534.google.com with SMTP id e7so23158316edu.10 for ; Tue, 23 Mar 2021 05:27:50 -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=6qT0xpw199Qo1K/XH0auRp8A0Asf+uacqMTPUf1Eap0=; b=L7HSBC7BmRs8vwKBz3ULs0qkUhZKds4NPSAFXITh0NPDLva3j1DphwdMV5AYQbBVT0 D5/6loT/tIGm/PMf0OJOKGxXPHm9+wbK4OvO1sTrOD5gUCoz7Gh9hv4BXuG08JOkDWQx GIbAr9BgUYaBpD5hVQXcf8pAOIybgS+sbc3wkQlsHiJqz64BfTHJI1wp5nLf6Dw70YIk 67z8MAhJd5ywTmI1QeQGwWIjAvoAu2VcsHqu3LgFhpF4U+OZr6xzTKEAAzQNggeBBqt6 YfsjTXzgSEdw5DG/UtW9aEevxHj2p5CcaikiMDS/+Sq+lMRzOYqvaWXB7H4s1oNKw3CW Xz3Q== 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=6qT0xpw199Qo1K/XH0auRp8A0Asf+uacqMTPUf1Eap0=; b=lrELRiWmPv1hLRz9Oo4A+mcOcbWNHEWOTIPQP58Dp2hPW0JV+gOhh0nnEc8om13CUk UaaMwo+sMkWtHMEv0lxt9qkjybaBdSYQAui+bYgpC6RlyRs+1o9yk9IKvb+aa3Nkt7w/ z6+1kQVuWhA43fKtBW0hsarJ1HnLfZb50AGICn/NdZ1gvmt/0eBgnuGiMdfweOtpW0cX y3X8R+nxJSEt+URDSlHV/9GO0x5mCh+o4k23UncA0WorQuV/mEVkJ1a4TvboEYUCoQkv 0ZnSTkUnwJsvSK9xmriRNxiDUgbEsCozOUA7FLOpjrwbzKdxFjOd+RHdfKId54M3qGVN a+VA== X-Gm-Message-State: AOAM533znKr+um80G/1uJfxgO45QdAKilAoATqDwqCzQdbOiw+wLr2hg 7LPKYTM4lOTaOReIMq7ArWJGspO2K0KNRA== X-Google-Smtp-Source: ABdhPJwVstSz+Gt8arui1MX5HiQ4dLMeEueJMsMfqSM8xmQiQJGx44KUSu5cTfCIvVHRk1QguiaUew== X-Received: by 2002:aa7:c14a:: with SMTP id r10mr4218914edp.132.1616502469398; Tue, 23 Mar 2021 05:27:49 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:38 +0000 Message-Id: <20210323122739.680560-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 4a3f7cbe3065..1e4861a0c121 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 12:27:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11664 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 B45A3C32E5 for ; Tue, 23 Mar 2021 12:27:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C36468D78; Tue, 23 Mar 2021 13:27:55 +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="U2PEbvlP"; dkim-atps=neutral Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EF23F602D7 for ; Tue, 23 Mar 2021 13:27:50 +0100 (CET) Received: by mail-ed1-x529.google.com with SMTP id w18so23267819edc.0 for ; Tue, 23 Mar 2021 05:27:50 -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=nahPY3IJ+xf5GQDDXyRbYtCcstVTIIhsejrgcUkr/0U=; b=U2PEbvlPHdo4TCl44P57S04fWFJ+BbQoHfpQ+BzKTut8p+Y4fBTBokCZxxRIDDeRdO Wl/8QTpPonVZFDDujtIJYh25qUqBfpmobOj2OQ1ORg9ritjnUcX4bOngwoGdUv6U5HDv Qc33GcPJh/1kRFSkhwOCxdnAebrOkBsFvFcf6hahUUSyqxHFJbQKpk3mDmOMWYHleLtR 6UhKM3BXF0vO7jWShYIWbwxST9psp5N8Mtre1piVCSxgoBySxcpOY2Nk11FgqiG0hWi0 701auzfIHTXfZRA7qtgzqeYQoLmySKI9TSplrBs10QaQmx3hOuWuhZ+LzLK7Ko3/e6FY Nw3A== 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=nahPY3IJ+xf5GQDDXyRbYtCcstVTIIhsejrgcUkr/0U=; b=gzU+q2Ewgf71qFzO2VSJ3hxsLQFXyfprTTsIQFjoq3pVPXUIzUsXjmRMRSfKplNGy+ G6/StN1Uvb1xcgFxBEN6C/bpEv5Ps7N4v9rKyOMFT6WUY6RxCTNRoDdu7il0Xtt3djcB t/7SdVw4XOgValrMfgDTE1ygJYdZ0oveb35C7gWREn9GyGpTRSerQSQ5FtrlXPt9vPfT 0suCKo8zIHZV+/+dgDsXaYytdDN1+u0xd5wym9Kek613Hss1vdaE3SUz/fgbBVRx1VLQ 4Ne2S8WfoV3ZhtDp0N0s1MermbxNxDLGDE3JnL6Tbb6nEPzHDb5RIpr/vN8tz4JuRV61 bqYw== X-Gm-Message-State: AOAM5314EL9HrIvIkzTS8VwexIz8JxOgjNne5KEvR5ILLWXo6TJVginx QOk31TXSt2Gbm6eLD29glrqVp4aomD7fiw== X-Google-Smtp-Source: ABdhPJxaV34Z45CTS1Wu3Rt2K48AlUQfqRgx9uLzDG2ykhkwAmnDC8eD3z37IN6x8jNMbYiUgPX/aQ== X-Received: by 2002:a05:6402:31b7:: with SMTP id dj23mr4409060edb.245.1616502470319; Tue, 23 Mar 2021 05:27:50 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id u13sm11082295ejy.31.2021.03.23.05.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 05:27:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 12:27:39 +0000 Message-Id: <20210323122739.680560-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323122739.680560-1-naush@raspberrypi.com> References: <20210323122739.680560-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 1e4861a0c121..aa9c709d6adb 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1234,7 +1234,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; @@ -1277,19 +1277,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