Patch Detail
Show a patch.
GET /api/patches/19583/?format=api
{ "id": 19583, "url": "https://patchwork.libcamera.org/api/patches/19583/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19583/", "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": "<20240229183654.7206-13-hdegoede@redhat.com>", "date": "2024-02-29T18:36:23", "name": "[v4,12/18] libcamera: pipeline: simple: enable use of Soft ISP and Soft IPA", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "0d1b5b070bf035a1a46e95f7266af8ac72d39d22", "submitter": { "id": 102, "url": "https://patchwork.libcamera.org/api/people/102/?format=api", "name": "Hans de Goede", "email": "hdegoede@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19583/mbox/", "series": [ { "id": 4195, "url": "https://patchwork.libcamera.org/api/series/4195/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4195", "date": "2024-02-29T18:36:11", "name": "libcamera: introduce Software ISP and Software IPA", "version": 4, "mbox": "https://patchwork.libcamera.org/series/4195/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19583/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19583/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 B1FA7BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 29 Feb 2024 18:37:22 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5AB0D628AC;\n\tThu, 29 Feb 2024 19:37:22 +0100 (CET)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 20E096295C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 29 Feb 2024 19:37:20 +0100 (CET)", "from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com\n\t[66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-538-Q14wReTEMhGqkuaeZvsu4Q-1; Thu, 29 Feb 2024 13:37:15 -0500", "from smtp.corp.redhat.com\n\t(int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC318848524;\n\tThu, 29 Feb 2024 18:37:14 +0000 (UTC)", "from shalem.redhat.com (unknown [10.39.192.10])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id D9A981C060AF;\n\tThu, 29 Feb 2024 18:37:13 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"DuLpTJZE\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1709231839;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=ZCGGG09266/HfVuCKCr/1r+yeE30VuyotvYb7b55Cwg=;\n\tb=DuLpTJZEMebwOh7uZBuoAQ1QvCxvu7M2bDWpkaW8h/+1sGNfFb6mFQV0t5fwEu+hSFU+NR\n\tgIdw6JCTsKOpTcsJeAwtiGQNFRLDAH+ilXsmWjejMdBh8qiqKpZsTSR5LdHeEVoHN906Ll\n\tyHaKIqhTjo0F2HPmxvJbJ41r5x0wT6U=", "X-MC-Unique": "Q14wReTEMhGqkuaeZvsu4Q-1", "From": "Hans de Goede <hdegoede@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH v4 12/18] libcamera: pipeline: simple: enable use of Soft ISP\n\tand Soft IPA", "Date": "Thu, 29 Feb 2024 19:36:23 +0100", "Message-ID": "<20240229183654.7206-13-hdegoede@redhat.com>", "In-Reply-To": "<20240229183654.7206-1-hdegoede@redhat.com>", "References": "<20240229183654.7206-1-hdegoede@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.11.54.7", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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>", "Cc": "Maxime Ripard <mripard@redhat.com>, Pavel Machek <pavel@ucw.cz>,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Andrey Konovalov <andrey.konovalov@linaro.org>\n\nTo enable the Simple Soft ISP and Soft IPA for simple pipeline handler\nconfigure the build with:\n -Dpipelines=simple -Dipas=simple\n\nAlso using the Soft ISP for the particular hardware platform must\nbe enabled in the supportedDevices[] table.\n\nIf the pipeline uses Converter, Soft ISP and Soft IPA aren't\navailable.\n\nTested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp Lenovo x13s\nTested-by: Pavel Machek <pavel@ucw.cz>\nReviewed-by: Pavel Machek <pavel@ucw.cz>\nSigned-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 138 ++++++++++++++++++-----\n 1 file changed, 109 insertions(+), 29 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex f4e56e3c..e491ab62 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -34,6 +34,7 @@\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n+#include \"libcamera/internal/software_isp/software_isp.h\"\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n \n@@ -185,18 +186,23 @@ struct SimplePipelineInfo {\n \t * and the number of streams it supports.\n \t */\n \tstd::vector<std::pair<const char *, unsigned int>> converters;\n+\t/*\n+\t * Using Software ISP is to be enabled per driver.\n+\t * The Software ISP can't be used together with the converters.\n+\t */\n+\tbool swIspEnabled;\n };\n \n namespace {\n \n static const SimplePipelineInfo supportedDevices[] = {\n-\t{ \"dcmipp\", {} },\n-\t{ \"imx7-csi\", { { \"pxp\", 1 } } },\n-\t{ \"j721e-csi2rx\", {} },\n-\t{ \"mtk-seninf\", { { \"mtk-mdp\", 3 } } },\n-\t{ \"mxc-isi\", {} },\n-\t{ \"qcom-camss\", {} },\n-\t{ \"sun6i-csi\", {} },\n+\t{ \"dcmipp\", {}, false },\n+\t{ \"imx7-csi\", { { \"pxp\", 1 } }, false },\n+\t{ \"j721e-csi2rx\", {}, false },\n+\t{ \"mtk-seninf\", { { \"mtk-mdp\", 3 } }, false },\n+\t{ \"mxc-isi\", {}, false },\n+\t{ \"qcom-camss\", {}, true },\n+\t{ \"sun6i-csi\", {}, false },\n };\n \n } /* namespace */\n@@ -275,6 +281,7 @@ public:\n \tbool useConversion_;\n \n \tstd::unique_ptr<Converter> converter_;\n+\tstd::unique_ptr<SoftwareIsp> swIsp_;\n \n private:\n \tvoid tryPipeline(unsigned int code, const Size &size);\n@@ -282,6 +289,9 @@ private:\n \n \tvoid conversionInputDone(FrameBuffer *buffer);\n \tvoid conversionOutputDone(FrameBuffer *buffer);\n+\n+\tvoid ispStatsReady(int dummy);\n+\tvoid setSensorControls(const ControlList &sensorControls);\n };\n \n class SimpleCameraConfiguration : public CameraConfiguration\n@@ -333,6 +343,7 @@ public:\n \tV4L2VideoDevice *video(const MediaEntity *entity);\n \tV4L2Subdevice *subdev(const MediaEntity *entity);\n \tMediaDevice *converter() { return converter_; }\n+\tbool swIspEnabled() { return swIspEnabled_; }\n \n protected:\n \tint queueRequestDevice(Camera *camera, Request *request) override;\n@@ -361,6 +372,7 @@ private:\n \tstd::map<const MediaEntity *, EntityData> entities_;\n \n \tMediaDevice *converter_;\n+\tbool swIspEnabled_;\n };\n \n /* -----------------------------------------------------------------------------\n@@ -510,6 +522,29 @@ int SimpleCameraData::init()\n \t\t}\n \t}\n \n+\t/*\n+\t * Instantiate Soft ISP if this is enabled for the given driver and no converter is used.\n+\t */\n+\tif (!converter_ && pipe->swIspEnabled()) {\n+\t\tswIsp_ = std::make_unique<SoftwareIsp>(pipe, sensor_->controls());\n+\t\tif (!swIsp_->isValid()) {\n+\t\t\tLOG(SimplePipeline, Warning)\n+\t\t\t\t<< \"Failed to create software ISP, disabling software debayering\";\n+\t\t\tswIsp_.reset();\n+\t\t} else {\n+\t\t\t/*\n+\t\t\t * \\todo explain why SimpleCameraData::conversionInputDone() can't be directly\n+\t\t\t * connected to inputBufferReady signal.\n+\t\t\t */\n+\t\t\tswIsp_->inputBufferReady.connect(pipe, [this](FrameBuffer *buffer) {\n+\t\t\t\tthis->conversionInputDone(buffer);\n+\t\t\t});\n+\t\t\tswIsp_->outputBufferReady.connect(this, &SimpleCameraData::conversionOutputDone);\n+\t\t\tswIsp_->ispStatsReady.connect(this, &SimpleCameraData::ispStatsReady);\n+\t\t\tswIsp_->setSensorControls.connect(this, &SimpleCameraData::setSensorControls);\n+\t\t}\n+\t}\n+\n \tvideo_ = pipe->video(entities_.back().entity);\n \tASSERT(video_);\n \n@@ -600,12 +635,20 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)\n \t\tconfig.captureFormat = pixelFormat;\n \t\tconfig.captureSize = format.size;\n \n-\t\tif (!converter_) {\n-\t\t\tconfig.outputFormats = { pixelFormat };\n-\t\t\tconfig.outputSizes = config.captureSize;\n-\t\t} else {\n+\t\tif (converter_) {\n \t\t\tconfig.outputFormats = converter_->formats(pixelFormat);\n \t\t\tconfig.outputSizes = converter_->sizes(format.size);\n+\t\t} else if (swIsp_) {\n+\t\t\tconfig.outputFormats = swIsp_->formats(pixelFormat);\n+\t\t\tconfig.outputSizes = swIsp_->sizes(pixelFormat, format.size);\n+\t\t\tif (config.outputFormats.empty()) {\n+\t\t\t\t/* Do not use swIsp for unsupported pixelFormat's: */\n+\t\t\t\tconfig.outputFormats = { pixelFormat };\n+\t\t\t\tconfig.outputSizes = config.captureSize;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tconfig.outputFormats = { pixelFormat };\n+\t\t\tconfig.outputSizes = config.captureSize;\n \t\t}\n \n \t\tconfigs_.push_back(config);\n@@ -751,9 +794,9 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\t}\n \n \t\t/*\n-\t\t * The converter is in use. Requeue the internal buffer for\n-\t\t * capture (unless the stream is being stopped), and complete\n-\t\t * the request with all the user-facing buffers.\n+\t\t * The converter or Software ISP is in use. Requeue the internal\n+\t\t * buffer for capture (unless the stream is being stopped), and\n+\t\t * complete the request with all the user-facing buffers.\n \t\t */\n \t\tif (buffer->metadata().status != FrameMetadata::FrameCancelled)\n \t\t\tvideo_->queueBuffer(buffer);\n@@ -799,9 +842,9 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\t\t\t\tbuffer->metadata().timestamp);\n \n \t/*\n-\t * Queue the captured and the request buffer to the converter if format\n-\t * conversion is needed. If there's no queued request, just requeue the\n-\t * captured buffer for capture.\n+\t * Queue the captured and the request buffer to the converter or Software\n+\t * ISP if format conversion is needed. If there's no queued request, just\n+\t * requeue the captured buffer for capture.\n \t */\n \tif (useConversion_) {\n \t\tif (conversionQueue_.empty()) {\n@@ -809,7 +852,11 @@ void SimpleCameraData::bufferReady(FrameBuffer *buffer)\n \t\t\treturn;\n \t\t}\n \n-\t\tconverter_->queueBuffers(buffer, conversionQueue_.front());\n+\t\tif (converter_)\n+\t\t\tconverter_->queueBuffers(buffer, conversionQueue_.front());\n+\t\telse\n+\t\t\tswIsp_->queueBuffers(buffer, conversionQueue_.front());\n+\n \t\tconversionQueue_.pop();\n \t\treturn;\n \t}\n@@ -835,6 +882,18 @@ void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)\n \t\tpipe->completeRequest(request);\n }\n \n+void SimpleCameraData::ispStatsReady([[maybe_unused]] int dummy)\n+{\n+\tswIsp_->processStats(sensor_->getControls({ V4L2_CID_ANALOGUE_GAIN,\n+\t\t\t\t\t\t V4L2_CID_EXPOSURE }));\n+}\n+\n+void SimpleCameraData::setSensorControls(const ControlList &sensorControls)\n+{\n+\tControlList ctrls(sensorControls);\n+\tsensor_->setControls(&ctrls);\n+}\n+\n /* Retrieve all source pads connected to a sink pad through active routes. */\n std::vector<const MediaPad *> SimpleCameraData::routedSourcePads(MediaPad *sink)\n {\n@@ -1047,8 +1106,10 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n \t\t/* Set the stride, frameSize and bufferCount. */\n \t\tif (needConversion_) {\n \t\t\tstd::tie(cfg.stride, cfg.frameSize) =\n-\t\t\t\tdata_->converter_->strideAndFrameSize(cfg.pixelFormat,\n-\t\t\t\t\t\t\t\t cfg.size);\n+\t\t\t\t(data_->converter_) ? data_->converter_->strideAndFrameSize(cfg.pixelFormat,\n+\t\t\t\t\t\t\t\t\t\t\t cfg.size)\n+\t\t\t\t\t\t : data_->swIsp_->strideAndFrameSize(cfg.pixelFormat,\n+\t\t\t\t\t\t\t\t\t\t\tcfg.size);\n \t\t\tif (cfg.stride == 0)\n \t\t\t\treturn Invalid;\n \t\t} else {\n@@ -1211,7 +1272,9 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \tinputCfg.stride = captureFormat.planes[0].bpl;\n \tinputCfg.bufferCount = kNumInternalBuffers;\n \n-\treturn data->converter_->configure(inputCfg, outputCfgs);\n+\treturn (data->converter_) ? data->converter_->configure(inputCfg, outputCfgs)\n+\t\t\t\t : data->swIsp_->configure(inputCfg, outputCfgs,\n+\t\t\t\t\t\t\t data->sensor_->controls());\n }\n \n int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n@@ -1225,8 +1288,10 @@ int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n \t * whether the converter is used or not.\n \t */\n \tif (data->useConversion_)\n-\t\treturn data->converter_->exportBuffers(data->streamIndex(stream),\n-\t\t\t\t\t\t count, buffers);\n+\t\treturn (data->converter_) ? data->converter_->exportBuffers(data->streamIndex(stream),\n+\t\t\t\t\t\t\t\t\t count, buffers)\n+\t\t\t\t\t : data->swIsp_->exportBuffers(data->streamIndex(stream),\n+\t\t\t\t\t\t\t\t\tcount, buffers);\n \telse\n \t\treturn data->video_->exportBuffers(count, buffers);\n }\n@@ -1271,10 +1336,18 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n \t}\n \n \tif (data->useConversion_) {\n-\t\tret = data->converter_->start();\n-\t\tif (ret < 0) {\n-\t\t\tstop(camera);\n-\t\t\treturn ret;\n+\t\tif (data->converter_) {\n+\t\t\tret = data->converter_->start();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tstop(camera);\n+\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t} else if (data->swIsp_) {\n+\t\t\tret = data->swIsp_->start();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tstop(camera);\n+\t\t\t\treturn ret;\n+\t\t\t}\n \t\t}\n \n \t\t/* Queue all internal buffers for capture. */\n@@ -1290,8 +1363,13 @@ void SimplePipelineHandler::stopDevice(Camera *camera)\n \tSimpleCameraData *data = cameraData(camera);\n \tV4L2VideoDevice *video = data->video_;\n \n-\tif (data->useConversion_)\n-\t\tdata->converter_->stop();\n+\tif (data->useConversion_) {\n+\t\tif (data->converter_)\n+\t\t\tdata->converter_->stop();\n+\t\telse if (data->swIsp_) {\n+\t\t\tdata->swIsp_->stop();\n+\t\t}\n+\t}\n \n \tvideo->streamOff();\n \tvideo->releaseBuffers();\n@@ -1453,6 +1531,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t\t}\n \t}\n \n+\tswIspEnabled_ = info->swIspEnabled;\n+\n \t/* Locate the sensors. */\n \tstd::vector<MediaEntity *> sensors = locateSensors();\n \tif (sensors.empty()) {\n", "prefixes": [ "v4", "12/18" ] }