Patch Detail
Show a patch.
GET /api/patches/8615/?format=api
{ "id": 8615, "url": "https://patchwork.libcamera.org/api/patches/8615/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8615/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200704005227.21782-12-laurent.pinchart@ideasonboard.com>", "date": "2020-07-04T00:52:26", "name": "[libcamera-devel,v2,11/12] ipa: raspberrypi: Pass sensor config back from configure()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "76ee0c59caf7a85fb4e54244ec47960fa25ed42f", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8615/mbox/", "series": [ { "id": 1081, "url": "https://patchwork.libcamera.org/api/series/1081/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1081", "date": "2020-07-04T00:52:15", "name": "Support passing custom data to IPA configure()", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1081/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8615/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8615/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 66127C2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 4 Jul 2020 00:52:45 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F7DF60DF2;\n\tSat, 4 Jul 2020 02:52:45 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E502760DC9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 4 Jul 2020 02:52:41 +0200 (CEST)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EA70D29E;\n\tSat, 4 Jul 2020 02:52:40 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"OMQvYHoD\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593823961;\n\tbh=b1MAJ6i5kiwK5ibfTdH4Sb02HljK5Xih1Dq2N9FPuZg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OMQvYHoDSzZPOpdFQY3Qk4XngWvpJhEgl5/Vs3hD/HI+xYRDu+AGtDOCAihYhL3vL\n\tpGAdi0gJy2sLczwrws6+2BOHT3+aqL4I7Am8TGu6poH77Kgy/ejvHDgbsmCq8dj0vN\n\tuzJKIBfT8d6flPf2Db3nexxSyPeNkR7RXvp7D2Jk=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 4 Jul 2020 03:52:26 +0300", "Message-Id": "<20200704005227.21782-12-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200704005227.21782-1-laurent.pinchart@ideasonboard.com>", "References": "<20200704005227.21782-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 11/12] ipa: raspberrypi: Pass sensor\n\tconfig back from configure()", "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": "The Raspberry Pi IPA uses the custom RPI_IPA_ACTION_SET_SENSOR_CONFIG\nframe action to send the sensor staggered write configuration to the\npipeline handler when the IPA is configured. Replace this ad-hoc\nmechanism by passing the corresponding data back from the IPA to the\npipeline handler through the configure() response. This allows\nsynchronous handling of the response on the pipeline handler side.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Restore RPI_IPA_ACTION_V4L2_SET_ISP handling in stop state\n- Drop sensor orientation handling based on IPA result\n---\n include/libcamera/ipa/raspberrypi.h | 3 +-\n src/ipa/raspberrypi/raspberrypi.cpp | 42 ++++++++-------\n .../pipeline/raspberrypi/raspberrypi.cpp | 53 +++++++++++--------\n 3 files changed, 56 insertions(+), 42 deletions(-)", "diff": "diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex 46ce7c286b20..a49377695f22 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -12,6 +12,8 @@\n \n enum RPiConfigParameters {\n \tRPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n+\tRPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n+\tRPI_IPA_CONFIG_SENSOR = (1 << 2),\n };\n \n enum RPiOperations {\n@@ -20,7 +22,6 @@ enum RPiOperations {\n \tRPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n \tRPI_IPA_ACTION_RUN_ISP,\n \tRPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n-\tRPI_IPA_ACTION_SET_SENSOR_CONFIG,\n \tRPI_IPA_ACTION_EMBEDDED_COMPLETE,\n \tRPI_IPA_EVENT_SIGNAL_STAT_READY,\n \tRPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 0e39a1137cd0..378ea309fa81 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -93,7 +93,7 @@ private:\n \tvoid reportMetadata();\n \tbool parseEmbeddedData(unsigned int bufferId, struct DeviceStatus &deviceStatus);\n \tvoid processStats(unsigned int bufferId);\n-\tvoid applyAGC(const struct AgcStatus *agcStatus);\n+\tvoid applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls);\n \tvoid applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls);\n \tvoid applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls);\n \tvoid applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls);\n@@ -195,6 +195,8 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tif (entityControls.empty())\n \t\treturn;\n \n+\tresult->operation = 0;\n+\n \tunicam_ctrls_ = entityControls.at(0);\n \tisp_ctrls_ = entityControls.at(1);\n \t/* Setup a metadata ControlList to output metadata. */\n@@ -216,13 +218,11 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\thelper_->GetDelays(exposureDelay, gainDelay);\n \t\tsensorMetadata = helper_->SensorEmbeddedDataPresent();\n \n-\t\tIPAOperationData op;\n-\t\top.operation = RPI_IPA_ACTION_SET_SENSOR_CONFIG;\n-\t\top.data.push_back(gainDelay);\n-\t\top.data.push_back(exposureDelay);\n-\t\top.data.push_back(sensorMetadata);\n+\t\tresult->data.push_back(gainDelay);\n+\t\tresult->data.push_back(exposureDelay);\n+\t\tresult->data.push_back(sensorMetadata);\n \n-\t\tqueueFrameAction.emit(0, op);\n+\t\tresult->operation |= RPI_IPA_CONFIG_STAGGERED_WRITE;\n \t}\n \n \t/* Re-assemble camera mode using the sensor info. */\n@@ -267,8 +267,13 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \n \t/* SwitchMode may supply updated exposure/gain values to use. */\n \tmetadata.Get(\"agc.status\", agcStatus);\n-\tif (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0)\n-\t\tapplyAGC(&agcStatus);\n+\tif (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) {\n+\t\tControlList ctrls(unicam_ctrls_);\n+\t\tapplyAGC(&agcStatus, ctrls);\n+\t\tresult->controls.push_back(ctrls);\n+\n+\t\tresult->operation |= RPI_IPA_CONFIG_SENSOR;\n+\t}\n \n \tlastMode_ = mode_;\n \n@@ -775,8 +780,15 @@ void IPARPi::processStats(unsigned int bufferId)\n \tcontroller_.Process(statistics, &rpiMetadata_);\n \n \tstruct AgcStatus agcStatus;\n-\tif (rpiMetadata_.Get(\"agc.status\", agcStatus) == 0)\n-\t\tapplyAGC(&agcStatus);\n+\tif (rpiMetadata_.Get(\"agc.status\", agcStatus) == 0) {\n+\t\tControlList ctrls(unicam_ctrls_);\n+\t\tapplyAGC(&agcStatus, ctrls);\n+\n+\t\tIPAOperationData op;\n+\t\top.operation = RPI_IPA_ACTION_V4L2_SET_STAGGERED;\n+\t\top.controls.push_back(ctrls);\n+\t\tqueueFrameAction.emit(0, op);\n+\t}\n }\n \n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n@@ -802,11 +814,8 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n \t\t static_cast<int32_t>(awbStatus->gain_b * 1000));\n }\n \n-void IPARPi::applyAGC(const struct AgcStatus *agcStatus)\n+void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n {\n-\tIPAOperationData op;\n-\top.operation = RPI_IPA_ACTION_V4L2_SET_STAGGERED;\n-\n \tint32_t gain_code = helper_->GainCode(agcStatus->analogue_gain);\n \tint32_t exposure_lines = helper_->ExposureLines(agcStatus->shutter_time);\n \n@@ -825,11 +834,8 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus)\n \t\t\t << agcStatus->analogue_gain << \" (Gain Code: \"\n \t\t\t << gain_code << \")\";\n \n-\tControlList ctrls(unicam_ctrls_);\n \tctrls.set(V4L2_CID_ANALOGUE_GAIN, gain_code);\n \tctrls.set(V4L2_CID_EXPOSURE, exposure_lines);\n-\top.controls.push_back(ctrls);\n-\tqueueFrameAction.emit(0, op);\n }\n \n void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls)\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 57602349cab2..9babf9f4a19c 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -819,7 +819,7 @@ int PipelineHandlerRPi::start(Camera *camera)\n \t/*\n \t * Write the last set of gain and exposure values to the camera before\n \t * starting. First check that the staggered ctrl has been initialised\n-\t * by the IPA action.\n+\t * by configure().\n \t */\n \tASSERT(data->staggeredCtrl_);\n \tdata->staggeredCtrl_.reset();\n@@ -1170,15 +1170,36 @@ int RPiCameraData::configureIPA()\n \t}\n \n \t/* Ready the IPA - it must know about the sensor resolution. */\n+\tIPAOperationData result;\n+\n \tipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig,\n-\t\t\tnullptr);\n+\t\t\t&result);\n \n-\t/* Configure the H/V flip controls based on the sensor rotation. */\n-\tControlList ctrls(unicam_[Unicam::Image].dev()->controls());\n-\tint32_t rotation = sensor_->properties().get(properties::Rotation);\n-\tctrls.set(V4L2_CID_HFLIP, static_cast<int32_t>(!!rotation));\n-\tctrls.set(V4L2_CID_VFLIP, static_cast<int32_t>(!!rotation));\n-\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n+\tif (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) {\n+\t\t/*\n+\t\t * Setup our staggered control writer with the sensor default\n+\t\t * gain and exposure delays.\n+\t\t */\n+\t\tif (!staggeredCtrl_) {\n+\t\t\tstaggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n+\t\t\t\t\t { { V4L2_CID_ANALOGUE_GAIN, result.data[0] },\n+\t\t\t\t\t { V4L2_CID_EXPOSURE, result.data[1] } });\n+\t\t\tsensorMetadata_ = result.data[2];\n+\t\t}\n+\n+\t\t/* Configure the H/V flip controls based on the sensor rotation. */\n+\t\tControlList ctrls(unicam_[Unicam::Image].dev()->controls());\n+\t\tint32_t rotation = sensor_->properties().get(properties::Rotation);\n+\t\tctrls.set(V4L2_CID_HFLIP, static_cast<int32_t>(!!rotation));\n+\t\tctrls.set(V4L2_CID_VFLIP, static_cast<int32_t>(!!rotation));\n+\t\tunicam_[Unicam::Image].dev()->setControls(&ctrls);\n+\t}\n+\n+\tif (result.operation & RPI_IPA_CONFIG_SENSOR) {\n+\t\tconst ControlList &ctrls = result.controls[0];\n+\t\tif (!staggeredCtrl_.set(ctrls))\n+\t\t\tLOG(RPI, Error) << \"V4L2 staggered set failed\";\n+\t}\n \n \treturn 0;\n }\n@@ -1191,26 +1212,12 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n \t */\n \tswitch (action.operation) {\n \tcase RPI_IPA_ACTION_V4L2_SET_STAGGERED: {\n-\t\tControlList controls = action.controls[0];\n+\t\tconst ControlList &controls = action.controls[0];\n \t\tif (!staggeredCtrl_.set(controls))\n \t\t\tLOG(RPI, Error) << \"V4L2 staggered set failed\";\n \t\treturn;\n \t}\n \n-\tcase RPI_IPA_ACTION_SET_SENSOR_CONFIG: {\n-\t\t/*\n-\t\t * Setup our staggered control writer with the sensor default\n-\t\t * gain and exposure delays.\n-\t\t */\n-\t\tif (!staggeredCtrl_) {\n-\t\t\tstaggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n-\t\t\t\t\t { { V4L2_CID_ANALOGUE_GAIN, action.data[0] },\n-\t\t\t\t\t { V4L2_CID_EXPOSURE, action.data[1] } });\n-\t\t\tsensorMetadata_ = action.data[2];\n-\t\t}\n-\t\treturn;\n-\t}\n-\n \tcase RPI_IPA_ACTION_V4L2_SET_ISP: {\n \t\tControlList controls = action.controls[0];\n \t\tisp_[Isp::Input].dev()->setControls(&controls);\n", "prefixes": [ "libcamera-devel", "v2", "11/12" ] }