{"id":11668,"url":"https://patchwork.libcamera.org/api/1.1/patches/11668/?format=json","web_url":"https://patchwork.libcamera.org/patch/11668/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210323143610.787760-3-naush@raspberrypi.com>","date":"2021-03-23T14:36:05","name":"[libcamera-devel,v3,2/7] pipeline: ipa: raspberrypi: Open the CamHelper on ipa::init()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"42538c82743a18682fe74320b824a121f3aeb70d","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11668/mbox/","series":[{"id":1823,"url":"https://patchwork.libcamera.org/api/1.1/series/1823/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1823","date":"2021-03-23T14:36:03","name":"Raspberry Pi: ipa::init() restructuring","version":3,"mbox":"https://patchwork.libcamera.org/series/1823/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11668/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11668/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D8B65C32E5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Mar 2021 14:36:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C13D68D72;\n\tTue, 23 Mar 2021 15:36:20 +0100 (CET)","from mail-ed1-x530.google.com (mail-ed1-x530.google.com\n\t[IPv6:2a00:1450:4864:20::530])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7048168D65\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Mar 2021 15:36:18 +0100 (CET)","by mail-ed1-x530.google.com with SMTP id bf3so23739578edb.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Mar 2021 07:36:18 -0700 (PDT)","from naush-laptop.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tn6sm11282430eji.37.2021.03.23.07.36.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 23 Mar 2021 07:36:17 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"TYNjB+Sk\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Dg1kohCDnlbbmNrW1evKNAxuUx8rW+M7gQwLQR9oWac=;\n\tb=TYNjB+Sk2x/HPRgH8Dfe96SzzNw2L2RKvxccNZyJG5xFBF34mTWyFhz7I0sveKsodB\n\t0/ZLxYiMuG0pz/KeEEfZDzL00UjL0rAFM0SDXNsS1IBawVpy57cy8WT5yh86rg2A3I+3\n\tgFXL1b/ypAML+Fj+m3CiCrbhXqt77YkelMtMWRw76gwFWDqVgRJvjeQSLTY1t0fggz/B\n\tVbAIWQloJusQqWHikt2Vm7jLYP+jDZkPQGncjgQn9ZtsCw359rKDliLK4vfznswuZz1Z\n\twUKLFnt50RV9E+UyDOd2Oz3aepoLdEzrZh9QDkaK0xmeIukOfvH/q/oi/OmBGIlvixqK\n\tD+YQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Dg1kohCDnlbbmNrW1evKNAxuUx8rW+M7gQwLQR9oWac=;\n\tb=uijubrxyIulntcSvrr5/ppnNI3CrKOyWjusr+av3GAEysACq3zBu/Ac9z7QQZSzbBi\n\tGVTC5pyRGOCtibNrdiFZTVz5Pt41lc915cgkZ+FNnSEUTXcyUpSjUMdS3V7cJIgJ8oHn\n\tmwtDnqIU5cWO2+mvt5pC8tuK3cqUKmaB9UUcYYrd5L1aoPQXxoyEfdqjlJKgdM35rTFe\n\tSF83dG9xPCI3YbwFDiBGiYU3MjzYqKIJvZgTFEJggp3gAANH1lMHmFgrCIurx7nFMptw\n\tmqsS7yNlFGWzP6WkxLfnAb+Y2Ye7/G77pKgCjCNc+1O5IQ7tyPp+7lzyDs0REHyGy5Qi\n\t9fPw==","X-Gm-Message-State":"AOAM533G1LZFwVca39tXDYYZcZxmLBpuPs1HM1oA3S4eIcw/PhQKbt1p\n\tTB7solBFfMyaCf7hS74R9ITm4nNzFBi5lw==","X-Google-Smtp-Source":"ABdhPJyydutqoPZJsEe26s2A+zqGLhGFOOeJb8SPAU6vjxtKmP07oC5dQc87tFq3bE0NY+bbSkCKYA==","X-Received":"by 2002:a05:6402:181a:: with SMTP id\n\tg26mr4865446edy.225.1616510177725; \n\tTue, 23 Mar 2021 07:36:17 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","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\n\tthe CamHelper on ipa::init()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Move the opening of the CamHelper from ipa::configure() to ipa::init().\nThis allows the pipeline handler to get the sensor specific parameters\nin pipeline_handler::match() where the ipa is initialised.\n\nHaving the sensor parameters available earlier will allow selective\nuse of the embedded data node in a future change.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/ipa/raspberrypi.mojom       |  8 +--\n src/ipa/raspberrypi/raspberrypi.cpp           | 62 +++++++++----------\n .../pipeline/raspberrypi/raspberrypi.cpp      | 36 +++++------\n 3 files changed, 46 insertions(+), 60 deletions(-)","diff":"diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\nindex eb427697d349..fafbd6c0cff3 100644\n--- a/include/libcamera/ipa/raspberrypi.mojom\n+++ b/include/libcamera/ipa/raspberrypi.mojom\n@@ -15,10 +15,6 @@ enum BufferMask {\n /* Size of the LS grid allocation. */\n const uint32 MaxLsGridSize = 0x8000;\n \n-enum ConfigOutputParameters {\n-\tConfigSensorParams = 0x01,\n-};\n-\n struct SensorConfig {\n \tuint32 gainDelay;\n \tuint32 exposureDelay;\n@@ -40,8 +36,6 @@ struct ConfigInput {\n };\n \n struct ConfigOutput {\n-\tuint32 params;\n-\tSensorConfig sensorConfig;\n \tControlList controls;\n };\n \n@@ -51,7 +45,7 @@ struct StartControls {\n };\n \n interface IPARPiInterface {\n-\tinit(IPASettings settings) => (int32 ret);\n+\tinit(IPASettings settings) => (int32 ret, SensorConfig sensorConfig);\n \tstart(StartControls controls) => (StartControls result);\n \tstop();\n \ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 7904225a29fa..a5b4b3110abf 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -79,7 +79,7 @@ public:\n \t\t\tmunmap(lsTable_, ipa::RPi::MaxLsGridSize);\n \t}\n \n-\tint init(const IPASettings &settings) override;\n+\tint init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig) override;\n \tvoid start(const ipa::RPi::StartControls &data,\n \t\t   ipa::RPi::StartControls *result) override;\n \tvoid stop() override {}\n@@ -164,9 +164,35 @@ private:\n \tdouble maxFrameDuration_;\n };\n \n-int IPARPi::init(const IPASettings &settings)\n+int IPARPi::init(const IPASettings &settings, ipa::RPi::SensorConfig *sensorConfig)\n {\n \ttuningFile_ = settings.configurationFile;\n+\n+\t/*\n+\t * Load the \"helper\" for this sensor. This tells us all the device specific stuff\n+\t * that the kernel driver doesn't. We only do this the first time; we don't need\n+\t * to re-parse the metadata after a simple mode-switch for no reason.\n+\t */\n+\thelper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::Create(settings.sensorModel));\n+\tif (!helper_) {\n+\t\tLOG(IPARPI, Error) << \"Could not create camera helper for \"\n+\t\t\t\t   << settings.sensorModel;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/*\n+\t * Pass out the sensor config to the pipeline handler in order\n+\t * to setup the staggered writer class.\n+\t */\n+\tint gainDelay, exposureDelay, vblankDelay, sensorMetadata;\n+\thelper_->GetDelays(exposureDelay, gainDelay, vblankDelay);\n+\tsensorMetadata = helper_->SensorEmbeddedDataPresent();\n+\n+\tsensorConfig->gainDelay = gainDelay;\n+\tsensorConfig->exposureDelay = exposureDelay;\n+\tsensorConfig->vblankDelay = vblankDelay;\n+\tsensorConfig->sensorMetadata = sensorMetadata;\n+\n \treturn 0;\n }\n \n@@ -301,8 +327,6 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\treturn -1;\n \t}\n \n-\tresult->params = 0;\n-\n \tsensorCtrls_ = entityControls.at(0);\n \tispCtrls_ = entityControls.at(1);\n \n@@ -319,36 +343,6 @@ int IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t/* Setup a metadata ControlList to output metadata. */\n \tlibcameraMetadata_ = ControlList(controls::controls);\n \n-\t/*\n-\t * Load the \"helper\" for this sensor. This tells us all the device specific stuff\n-\t * that the kernel driver doesn't. We only do this the first time; we don't need\n-\t * to re-parse the metadata after a simple mode-switch for no reason.\n-\t */\n-\tstd::string cameraName(sensorInfo.model);\n-\tif (!helper_) {\n-\t\thelper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::Create(cameraName));\n-\n-\t\tif (!helper_) {\n-\t\t\tLOG(IPARPI, Error) << \"Could not create camera helper for \"\n-\t\t\t\t\t   << cameraName;\n-\t\t\treturn -1;\n-\t\t}\n-\n-\t\t/*\n-\t\t * Pass out the sensor config to the pipeline handler in order\n-\t\t * to setup the staggered writer class.\n-\t\t */\n-\t\tint gainDelay, exposureDelay, vblankDelay, sensorMetadata;\n-\t\thelper_->GetDelays(exposureDelay, gainDelay, vblankDelay);\n-\t\tsensorMetadata = helper_->SensorEmbeddedDataPresent();\n-\n-\t\tresult->params |= ipa::RPi::ConfigSensorParams;\n-\t\tresult->sensorConfig.gainDelay = gainDelay;\n-\t\tresult->sensorConfig.exposureDelay = exposureDelay;\n-\t\tresult->sensorConfig.vblankDelay = vblankDelay;\n-\t\tresult->sensorConfig.sensorMetadata = sensorMetadata;\n-\t}\n-\n \t/* Re-assemble camera mode using the sensor info. */\n \tsetMode(sensorInfo);\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 2c8ae31a28ad..ce1994186d66 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -146,7 +146,7 @@ public:\n \n \tvoid frameStarted(uint32_t sequence);\n \n-\tint loadIPA();\n+\tint loadIPA(ipa::RPi::SensorConfig *sensorConfig);\n \tint configureIPA(const CameraConfiguration *config);\n \n \tvoid statsMetadataComplete(uint32_t bufferId, const ControlList &controls);\n@@ -1030,11 +1030,24 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \tif (data->sensor_->init())\n \t\treturn false;\n \n-\tif (data->loadIPA()) {\n+\tipa::RPi::SensorConfig sensorConfig;\n+\tif (data->loadIPA(&sensorConfig)) {\n \t\tLOG(RPI, Error) << \"Failed to load a suitable IPA library\";\n \t\treturn false;\n \t}\n \n+\t/*\n+\t * Setup our delayed control writer with the sensor default\n+\t * gain and exposure delays. Mark VBLANK for priority write.\n+\t */\n+\tstd::unordered_map<uint32_t, DelayedControls::ControlParams> params = {\n+\t\t{ V4L2_CID_ANALOGUE_GAIN, { sensorConfig.gainDelay, false } },\n+\t\t{ V4L2_CID_EXPOSURE, { sensorConfig.exposureDelay, false } },\n+\t\t{ V4L2_CID_VBLANK, { sensorConfig.vblankDelay, true } }\n+\t};\n+\tdata->delayedCtrls_ = std::make_unique<DelayedControls>(data->unicam_[Unicam::Image].dev(), params);\n+\tdata->sensorMetadata_ = sensorConfig.sensorMetadata;\n+\n \t/* Register the controls that the Raspberry Pi IPA can handle. */\n \tdata->controlInfo_ = RPi::Controls;\n \t/* Initialize the camera properties. */\n@@ -1214,7 +1227,7 @@ void RPiCameraData::frameStarted(uint32_t sequence)\n \tdelayedCtrls_->applyControls(sequence);\n }\n \n-int RPiCameraData::loadIPA()\n+int RPiCameraData::loadIPA(ipa::RPi::SensorConfig *sensorConfig)\n {\n \tipa_ = IPAManager::createIPA<ipa::RPi::IPAProxyRPi>(pipe_, 1, 1);\n \n@@ -1230,7 +1243,7 @@ int RPiCameraData::loadIPA()\n \tIPASettings settings(ipa_->configurationFile(sensor_->model() + \".json\"),\n \t\t\t     sensor_->model());\n \n-\treturn ipa_->init(settings);\n+\treturn ipa_->init(settings, sensorConfig);\n }\n \n int RPiCameraData::configureIPA(const CameraConfiguration *config)\n@@ -1293,21 +1306,6 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config)\n \t\treturn -EPIPE;\n \t}\n \n-\tif (result.params & ipa::RPi::ConfigSensorParams) {\n-\t\t/*\n-\t\t * Setup our delayed control writer with the sensor default\n-\t\t * gain and exposure delays. Mark VBLANK for priority write.\n-\t\t */\n-\t\tstd::unordered_map<uint32_t, DelayedControls::ControlParams> params = {\n-\t\t\t{ V4L2_CID_ANALOGUE_GAIN, { result.sensorConfig.gainDelay, false } },\n-\t\t\t{ V4L2_CID_EXPOSURE, { result.sensorConfig.exposureDelay, false } },\n-\t\t\t{ V4L2_CID_VBLANK, { result.sensorConfig.vblankDelay, true } }\n-\t\t};\n-\n-\t\tdelayedCtrls_ = std::make_unique<DelayedControls>(unicam_[Unicam::Image].dev(), params);\n-\t\tsensorMetadata_ = result.sensorConfig.sensorMetadata;\n-\t}\n-\n \tif (!result.controls.empty()) {\n \t\tControlList &ctrls = result.controls;\n \t\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n","prefixes":["libcamera-devel","v3","2/7"]}