{"id":27078,"url":"https://patchwork.libcamera.org/api/patches/27078/?format=json","web_url":"https://patchwork.libcamera.org/patch/27078/","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":"<20260629110240.3656-2-david.plowman@raspberrypi.com>","date":"2026-06-29T10:31:00","name":"[1/1] pipeline: rpi: Handle buffers with offsets","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b59f773c9eec79b673392548e7b1f6020e40485f","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27078/mbox/","series":[{"id":6024,"url":"https://patchwork.libcamera.org/api/series/6024/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6024","date":"2026-06-29T10:30:59","name":"Make Raspberry Pi 5 handle buffer offsets","version":1,"mbox":"https://patchwork.libcamera.org/series/6024/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27078/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27078/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 AFB0AC3303\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2026 11:02:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C393B65F2C;\n\tMon, 29 Jun 2026 13:02:48 +0200 (CEST)","from mail-wm1-x330.google.com (mail-wm1-x330.google.com\n\t[IPv6:2a00:1450:4864:20::330])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D8AF65F19\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 13:02:46 +0200 (CEST)","by mail-wm1-x330.google.com with SMTP id\n\t5b1f17b1804b1-493a7bd27c2so11037985e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2026 04:02:46 -0700 (PDT)","from davidp-pi5.pitowers.org\n\t([2a00:1098:3142:1f:88ea:c658:5b20:5e46])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-473dddcb295sm8346405f8f.35.2026.06.29.04.02.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 29 Jun 2026 04:02:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"YOG4DPCJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1782730965; x=1783335765;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=1l+cnQXO3OrrrNqA3+WaFcO7pj85ELB+GsNC/nJLBHI=;\n\tb=YOG4DPCJ+gNzkhst+4Unx74e0w2HNSMozlQNyZMhzVuMG7QM1o68iTtyFpFjhP6TO+\n\t11JTmQenn++evaHiWuo1R8HeZqRmvh1dRG7JFT9B4J0MyedQ1aX2yCNxpbhzrwAldh/0\n\tqS4q0LJ8CsW8mHvxP8EHAcFCBw2UzxYkdK/9P9IIJsGdK5yxFOLUi8KHRP94jsQSRoTw\n\ts7/SkKNnkzRWnA5xB1abEzbluT1hkG9Xl/AovS5HYuCHv9SrwspQF/KlWahyZEOF/Abi\n\tEi25402NnEWegdfc/6dXz+GxY47yZS7UayrN/JljO2vhveYxZGUuKXnb1Bq9uJb2ANhG\n\tqeFw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782730965; x=1783335765;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=1l+cnQXO3OrrrNqA3+WaFcO7pj85ELB+GsNC/nJLBHI=;\n\tb=fNas+EIiL1oAp3Q7QQrUoOX/BETc0wfYNsMUuvHXxIUJuKSq8Jna/rpREOyMDcOLto\n\tCA0Xog9CwhMiu8d88GYQLpuEqGpSHYvGi2w2xyXXFRHKMcXXvcXkx1/TMF/Pj9tXmXwB\n\t0RFW5qfTMZtS/BONAztrmBP+FnAWe2MDkvr+/azSXf0aTnTFQm4q0pmyDJ8dxaaAfVJF\n\tLU9ScYtGDSHTbjPhcgVWnH+x2g/8OfpHC0iaHS9lRGUmC/HYIdwcGHIN99ZAHFORxPer\n\tKH+oosoWrN7mqjlsooEPM5HehAoRKJ+TopoP9Y2FHzdBlCjnVhfFJjlO9U5m59kiVtDu\n\tI3Gw==","X-Gm-Message-State":"AOJu0YxomCtdhT1gXL3WKhYy6qMalZGhKfcbDmnvmS3tldRKkdXN2Kuy\n\t+SrTtPGEhf+Ck47rkJidHINDax/dsTMEpa6vjJ/Brt/GA6mzSNijgUvkFkM9s8w9y2sMG3gHr8S\n\t95sLeMtU=","X-Gm-Gg":"AfdE7cl64HSsfcE1Yeyp5FZJUNkHR5nKr6dWE3YlOh4kHl+fHHSBFJtYnLxX/Q6TK5R\n\tfuiOdrBTnZoLfnSt+Wh5CbyLrUiaF76vwZHDxjri7rb2UJRrEIckwFAopHbJal1g26+Fk8+hYHt\n\tq7zap3jcoYRf38FNevUPI7uS1muvEMuaFBk911yisYj6Z0tHqEYVSmVjqHPD/qmFS7WAWMUUtjr\n\tiMiwa59eOCKA8zsCpdXwjR8d858qkljGQ70HYsJhUelBWTqjB3iyZLVZJKE0BRtgHJBZmy0xn2o\n\thl/wj+owPGP/9JqyiQmrjS9SjrT0BWw+2pVCdG8vspLhslYBsyJRJGxrCsppj6+QUksLZg+jCDG\n\tRZ5+Pr+FrHSj9Y5yHBXLNzKNsYzdN2SIy/RZdZf95H44v2ppy/X3L62eB9BfXYjZ2GBkpZmAAzu\n\tq8UceFMWKCScPlpb2/DJI4Ob0h2BuZlduzDhCKkacUUXsKkeuxZ+wCuPd95E970/Yi453NNZoVU\n\tUDd+VzLG3Gv3dRUl1KcQm6asG0FaMA=","X-Received":"by 2002:a05:600c:34cc:b0:489:5022:39a4 with SMTP id\n\t5b1f17b1804b1-493b7199050mr4334615e9.9.1782730965395; \n\tMon, 29 Jun 2026 04:02:45 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>","Subject":"[PATCH 1/1] pipeline: rpi: Handle buffers with offsets","Date":"Mon, 29 Jun 2026 11:31:00 +0100","Message-ID":"<20260629110240.3656-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20260629110240.3656-1-david.plowman@raspberrypi.com>","References":"<20260629110240.3656-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"This allows camera images to be written to offset locations within\nbuffers (which must have be allocated with sufficient space\navailable).\n\nFirstly, the RPi::Stream class tracks the associated \"ispOutputIndex\"\nfor output streams, that is, whether it corresponds to ISP output\nbranch 0 or branch 1.\n\nSecondly, we pass buffer offsets on to libpisp for each request.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/rpi/common/rpi_stream.h          | 10 ++++++++--\n src/libcamera/pipeline/rpi/pisp/pisp.cpp      | 19 +++++++++++++++++++\n 2 files changed, 27 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h\nindex 300a352a..51931867 100644\n--- a/src/libcamera/pipeline/rpi/common/rpi_stream.h\n+++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h\n@@ -97,14 +97,14 @@ public:\n \tusing StreamFlags = Flags<StreamFlag>;\n \n \tStream()\n-\t\t: flags_(StreamFlag::None), id_(0), swDownscale_(0)\n+\t\t: flags_(StreamFlag::None), id_(0), swDownscale_(0), ispOutputIndex_(-1)\n \t{\n \t}\n \n \tStream(const char *name, MediaEntity *dev, StreamFlags flags = StreamFlag::None)\n \t\t: flags_(flags), name_(name),\n \t\t  dev_(std::make_unique<V4L2VideoDevice>(dev)), id_(0),\n-\t\t  swDownscale_(0)\n+\t\t  swDownscale_(0), ispOutputIndex_(-1)\n \t{\n \t}\n \n@@ -125,6 +125,9 @@ public:\n \n \tvoid setExportedBuffer(FrameBuffer *buffer);\n \n+\tvoid setIspIndex(int ispIndex) { ispOutputIndex_ = ispIndex; }\n+\tint getIspIndex() const { return ispOutputIndex_; }\n+\n \tint allocateBuffers(unsigned int count);\n \tint queueBuffer(FrameBuffer *buffer);\n \tvoid returnBuffer(FrameBuffer *buffer);\n@@ -181,6 +184,9 @@ private:\n \t * as the stream needs to maintain ownership of these buffers.\n \t */\n \tstd::vector<std::unique_ptr<FrameBuffer>> internalBuffers_;\n+\n+\t/* For output streams, the ISP branch for this stream (otherwise -1). */\n+\tint ispOutputIndex_;\n };\n \n /*\ndiff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\nindex b744c901..1238d0e9 100644\n--- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n+++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n@@ -1524,6 +1524,7 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf\n \t\t\tbeEnables |= PISP_BE_RGB_ENABLE_OUTPUT0;\n \t\t\tispIndex = 0;\n \t\t}\n+\t\tstream->setIspIndex(ispIndex);\n \n \t\tformat = outStreams[i].format;\n \t\tbool needs32BitConversion = adjustDeviceFormat(format);\n@@ -2317,6 +2318,24 @@ void PiSPCameraData::tryRunPipeline()\n \tRequest *request = requestQueue_.front();\n \tASSERT(request->metadata().empty());\n \n+\t/* Pass the plane offsets of any output buffers to the Back End ISP. */\n+\tfor (auto const &[stream, buffer] : request->buffers()) {\n+\t\tint ispIndex = static_cast<const RPi::Stream *>(stream)->getIspIndex();\n+\t\tif (ispIndex >= 0) {\n+\t\t\t/*\n+\t\t\t * PiSP takes only 2 offsets; offset 3 (where required) is assumed\n+\t\t\t * to be the same as offset 2.\n+\t\t\t */\n+\t\t\tunsigned int offset = buffer->planes()[0].offset;\n+\t\t\tunsigned int offset2 = 0;\n+\t\t\tif (buffer->planes().size() > 1)\n+\t\t\t\toffset2 = buffer->planes()[1].offset;\n+\n+\t\t\tpisp_be_output_format_extra extra{ 0, 0, { offset, offset2 } };\n+\t\t\tbe_->SetOutputFormatExtra(ispIndex, extra);\n+\t\t}\n+\t}\n+\n \t/* See if a new ScalerCrop value needs to be applied. */\n \tapplyScalerCrop(request->controls());\n \n","prefixes":["1/1"]}