{"id":24718,"url":"https://patchwork.libcamera.org/api/patches/24718/?format=json","web_url":"https://patchwork.libcamera.org/patch/24718/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20251021182716.29274-9-mzamazal@redhat.com>","date":"2025-10-21T18:27:15","name":"[v13,8/8] libcamera: simple: Make raw streams working","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a81d99c185920267e15b2bd7e027c38f16656e5b","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/?format=json","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24718/mbox/","series":[{"id":5515,"url":"https://patchwork.libcamera.org/api/series/5515/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5515","date":"2025-10-21T18:27:07","name":"Enable raw streams with software ISP","version":13,"mbox":"https://patchwork.libcamera.org/series/5515/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24718/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24718/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 9FD61BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Oct 2025 18:28:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C376607A2;\n\tTue, 21 Oct 2025 20:28:00 +0200 (CEST)","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 CEB8A6079A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Oct 2025 20:27:58 +0200 (CEST)","from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-376-WKGfLBoyOciDcx0sGI782Q-1;\n\tTue, 21 Oct 2025 14:27:54 -0400","from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.111])\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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id DA7E5195609D; Tue, 21 Oct 2025 18:27:52 +0000 (UTC)","from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.124])\n\tby mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 4B41D180044F; Tue, 21 Oct 2025 18:27:50 +0000 (UTC)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"S42t9qsa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1761071277;\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=VEUEZdBKL/6NLUKhupZnV/6J3OF8+JCKYinZTw+Wb1U=;\n\tb=S42t9qsanma5pqhEIu3Cqx33rmZYupF8HIBJz4riVodtWI/H5QSBlNyVPktx4oyWSIufBV\n\tfX6/9Hxu7Mejg/OAoAdObP4a8r4EmeKK2TdR0Obqk68MaPRrNu71QQC8dOZUJeZjsuyxui\n\t7w6h79j7YWHtRhGivXY0h/wTZdW2fYE=","X-MC-Unique":"WKGfLBoyOciDcx0sGI782Q-1","X-Mimecast-MFC-AGG-ID":"WKGfLBoyOciDcx0sGI782Q_1761071273","From":"Milan Zamazal <mzamazal@redhat.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>, Laurent Pinchart\n\t<laurent.pinchart@ideasonboard.com>, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>, =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?=\n\t<barnabas.pocze@ideasonboard.com>, Paul Elder\n\t<paul.elder@ideasonboard.com>, Umang Jain <uajain@igalia.com>","Subject":"[PATCH v13 8/8] libcamera: simple: Make raw streams working","Date":"Tue, 21 Oct 2025 20:27:15 +0200","Message-ID":"<20251021182716.29274-9-mzamazal@redhat.com>","In-Reply-To":"<20251021182716.29274-1-mzamazal@redhat.com>","References":"<20251021182716.29274-1-mzamazal@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.111","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"mgY67ckiDVU_NPgF05_C1hNMwNrXn5-mFTyvsYDaRbA_1761071273","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"When a raw stream is requested, whether alone or together with a\nprocessed stream, its buffers must be handled outside the software ISP\nmachinery.  They serve as output buffers, even when a processed stream\nis produced.\n\nAt most one raw stream and at most one processed stream are supported\nand can be combined.  An example of producing both raw and processed\nfiles using `cam' application:\n\n  cam -c1 -C100 -Ffile# \\\n    -s role=viewfinder,width=1920,height=1080,pixelformat=RGB888 \\\n    -s role=raw,width=3280,height=2464,pixelformat=SRGGB8 \\\n\nNote the difference in viewfinder and raw stream sizes due to the fact\nthat debayering requires enlarging the image width, which enforces\nselecting a larger sensor resolution in this case.\n\nIn order to track whether a raw stream is requested and which one it is,\nSimpleCameraData::rawStream_ member variable is introduced.\n\nThis is the final step to make raw streams working.\n\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 50 +++++++++++++++++-------\n 1 file changed, 36 insertions(+), 14 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 0c3284feb..607b07949 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -333,6 +333,7 @@ public:\n \t};\n \n \tstd::vector<Stream> streams_;\n+\tStream *rawStream_;\n \n \t/*\n \t * All entities in the pipeline, from the camera sensor to the video\n@@ -371,6 +372,11 @@ private:\n \tvoid ispStatsReady(uint32_t frame, uint32_t bufferId);\n \tvoid metadataReady(uint32_t frame, const ControlList &metadata);\n \tvoid setSensorControls(const ControlList &sensorControls);\n+\n+\tbool processedRequested() const\n+\t{\n+\t\treturn streams_.size() - (rawStream_ ? 1 : 0) > 0;\n+\t}\n };\n \n class SimpleCameraConfiguration : public CameraConfiguration\n@@ -467,7 +473,7 @@ private:\n SimpleCameraData::SimpleCameraData(SimplePipelineHandler *pipe,\n \t\t\t\t   unsigned int numStreams,\n \t\t\t\t   MediaEntity *sensor)\n-\t: Camera::Private(pipe), streams_(numStreams)\n+\t: Camera::Private(pipe), streams_(numStreams), rawStream_(nullptr)\n {\n \t/*\n \t * Find the shortest path from the camera sensor to a video capture\n@@ -878,10 +884,13 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \t * point converting an erroneous buffer.\n \t */\n \tif (buffer->metadata().status != FrameMetadata::FrameSuccess) {\n-\t\tif (!useConversion_) {\n+\t\tif (rawStream_) {\n \t\t\t/* No conversion, just complete the request. */\n \t\t\tRequest *request = buffer->request();\n \t\t\tpipe->completeBuffer(request, buffer);\n+\t\t\tSimpleFrameInfo *info = frameInfo_.find(request->sequence());\n+\t\t\tif (info)\n+\t\t\t\tinfo->metadataRequired = false;\n \t\t\ttryCompleteRequest(request);\n \t\t\treturn;\n \t\t}\n@@ -891,7 +900,8 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\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\tif (buffer->metadata().status != FrameMetadata::FrameCancelled &&\n+\t\t    !rawStream_)\n \t\t\tvideo_->queueBuffer(buffer);\n \n \t\tif (conversionQueue_.empty())\n@@ -940,13 +950,14 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \t */\n \tif (useConversion_) {\n \t\tif (conversionQueue_.empty()) {\n-\t\t\tvideo_->queueBuffer(buffer);\n+\t\t\tif (!rawStream_)\n+\t\t\t\tvideo_->queueBuffer(buffer);\n \t\t\treturn;\n \t\t}\n \n \t\tif (converter_)\n \t\t\tconverter_->queueBuffers(buffer, conversionQueue_.front().outputs);\n-\t\telse\n+\t\telse if (processedRequested())\n \t\t\t/*\n \t\t\t * request->sequence() cannot be retrieved from `buffer' inside\n \t\t\t * queueBuffers because unique_ptr's make buffer->request() invalid\n@@ -956,6 +967,8 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer)\n \t\t\t\t\t     conversionQueue_.front().outputs);\n \n \t\tconversionQueue_.pop();\n+\t\tif (rawStream_)\n+\t\t\tpipe->completeBuffer(request, buffer);\n \t\treturn;\n \t}\n \n@@ -993,7 +1006,8 @@ void SimpleCameraData::tryCompleteRequest(Request *request)\n void SimpleCameraData::conversionInputDone(FrameBuffer *buffer)\n {\n \t/* Queue the input buffer back for capture. */\n-\tvideo_->queueBuffer(buffer);\n+\tif (!rawStream_)\n+\t\tvideo_->queueBuffer(buffer);\n }\n \n void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer)\n@@ -1518,11 +1532,15 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \n \tfor (unsigned int i = 0; i < config->size(); ++i) {\n \t\tStreamConfiguration &cfg = config->at(i);\n+\t\tbool rawStream = isRaw(cfg);\n \n \t\tcfg.setStream(&data->streams_[i]);\n \n-\t\tif (data->useConversion_ && !isRaw(cfg))\n+\t\tif (data->useConversion_ && !rawStream)\n \t\t\toutputCfgs.push_back(cfg);\n+\n+\t\tif (rawStream)\n+\t\t\tdata->rawStream_ = &data->streams_[i];\n \t}\n \n \tif (outputCfgs.empty())\n@@ -1553,7 +1571,7 @@ int SimplePipelineHandler::exportFrameBuffers(Camera *camera, Stream *stream,\n \t * Export buffers on the converter or capture video node, depending on\n \t * whether the converter is used or not.\n \t */\n-\tif (data->useConversion_)\n+\tif (data->useConversion_ && stream != data->rawStream_)\n \t\treturn data->converter_\n \t\t\t       ? data->converter_->exportBuffers(stream, count, buffers)\n \t\t\t       : data->swIsp_->exportBuffers(stream, count, buffers);\n@@ -1576,7 +1594,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n \t\treturn -EBUSY;\n \t}\n \n-\tif (data->useConversion_) {\n+\tif (data->useConversion_ && !data->rawStream_) {\n \t\t/*\n \t\t * When using the converter allocate a fixed number of internal\n \t\t * buffers.\n@@ -1584,8 +1602,11 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n \t\tret = video->allocateBuffers(kNumInternalBuffers,\n \t\t\t\t\t     &data->conversionBuffers_);\n \t} else {\n-\t\t/* Otherwise, prepare for using buffers from the only stream. */\n-\t\tStream *stream = &data->streams_[0];\n+\t\t/*\n+\t\t * Otherwise, prepare for using buffers from either the raw stream, if\n+\t\t * requested, or the only stream configured.\n+\t\t */\n+\t\tStream *stream = (data->rawStream_ ? data->rawStream_ : &data->streams_[0]);\n \t\tret = video->importBuffers(stream->configuration().bufferCount);\n \t}\n \tif (ret < 0) {\n@@ -1626,8 +1647,9 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n \t\t}\n \n \t\t/* Queue all internal buffers for capture. */\n-\t\tfor (std::unique_ptr<FrameBuffer> &buffer : data->conversionBuffers_)\n-\t\t\tvideo->queueBuffer(buffer.get());\n+\t\tif (!data->rawStream_)\n+\t\t\tfor (std::unique_ptr<FrameBuffer> &buffer : data->conversionBuffers_)\n+\t\t\t\tvideo->queueBuffer(buffer.get());\n \t}\n \n \treturn 0;\n@@ -1678,7 +1700,7 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request)\n \t\t * queue, it will be handed to the converter in the capture\n \t\t * completion handler.\n \t\t */\n-\t\tif (data->useConversion_) {\n+\t\tif (data->useConversion_ && stream != data->rawStream_) {\n \t\t\tbuffers.emplace(stream, buffer);\n \t\t\tmetadataRequired = !!data->swIsp_;\n \t\t} else {\n","prefixes":["v13","8/8"]}