From patchwork Mon Jun 29 10:31:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27078 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AFB0AC3303 for ; Mon, 29 Jun 2026 11:02:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C393B65F2C; Mon, 29 Jun 2026 13:02:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="YOG4DPCJ"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D8AF65F19 for ; Mon, 29 Jun 2026 13:02:46 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-493a7bd27c2so11037985e9.3 for ; Mon, 29 Jun 2026 04:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1782730965; x=1783335765; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1l+cnQXO3OrrrNqA3+WaFcO7pj85ELB+GsNC/nJLBHI=; b=YOG4DPCJ+gNzkhst+4Unx74e0w2HNSMozlQNyZMhzVuMG7QM1o68iTtyFpFjhP6TO+ 11JTmQenn++evaHiWuo1R8HeZqRmvh1dRG7JFT9B4J0MyedQ1aX2yCNxpbhzrwAldh/0 qS4q0LJ8CsW8mHvxP8EHAcFCBw2UzxYkdK/9P9IIJsGdK5yxFOLUi8KHRP94jsQSRoTw s7/SkKNnkzRWnA5xB1abEzbluT1hkG9Xl/AovS5HYuCHv9SrwspQF/KlWahyZEOF/Abi Ei25402NnEWegdfc/6dXz+GxY47yZS7UayrN/JljO2vhveYxZGUuKXnb1Bq9uJb2ANhG qeFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782730965; x=1783335765; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1l+cnQXO3OrrrNqA3+WaFcO7pj85ELB+GsNC/nJLBHI=; b=fNas+EIiL1oAp3Q7QQrUoOX/BETc0wfYNsMUuvHXxIUJuKSq8Jna/rpREOyMDcOLto CA0Xog9CwhMiu8d88GYQLpuEqGpSHYvGi2w2xyXXFRHKMcXXvcXkx1/TMF/Pj9tXmXwB 0RFW5qfTMZtS/BONAztrmBP+FnAWe2MDkvr+/azSXf0aTnTFQm4q0pmyDJ8dxaaAfVJF LU9ScYtGDSHTbjPhcgVWnH+x2g/8OfpHC0iaHS9lRGUmC/HYIdwcGHIN99ZAHFORxPer KH+oosoWrN7mqjlsooEPM5HehAoRKJ+TopoP9Y2FHzdBlCjnVhfFJjlO9U5m59kiVtDu I3Gw== X-Gm-Message-State: AOJu0YxomCtdhT1gXL3WKhYy6qMalZGhKfcbDmnvmS3tldRKkdXN2Kuy +SrTtPGEhf+Ck47rkJidHINDax/dsTMEpa6vjJ/Brt/GA6mzSNijgUvkFkM9s8w9y2sMG3gHr8S 95sLeMtU= X-Gm-Gg: AfdE7cl64HSsfcE1Yeyp5FZJUNkHR5nKr6dWE3YlOh4kHl+fHHSBFJtYnLxX/Q6TK5R fuiOdrBTnZoLfnSt+Wh5CbyLrUiaF76vwZHDxjri7rb2UJRrEIckwFAopHbJal1g26+Fk8+hYHt q7zap3jcoYRf38FNevUPI7uS1muvEMuaFBk911yisYj6Z0tHqEYVSmVjqHPD/qmFS7WAWMUUtjr iMiwa59eOCKA8zsCpdXwjR8d858qkljGQ70HYsJhUelBWTqjB3iyZLVZJKE0BRtgHJBZmy0xn2o hl/wj+owPGP/9JqyiQmrjS9SjrT0BWw+2pVCdG8vspLhslYBsyJRJGxrCsppj6+QUksLZg+jCDG RZ5+Pr+FrHSj9Y5yHBXLNzKNsYzdN2SIy/RZdZf95H44v2ppy/X3L62eB9BfXYjZ2GBkpZmAAzu q8UceFMWKCScPlpb2/DJI4Ob0h2BuZlduzDhCKkacUUXsKkeuxZ+wCuPd95E970/Yi453NNZoVU UDd+VzLG3Gv3dRUl1KcQm6asG0FaMA= X-Received: by 2002:a05:600c:34cc:b0:489:5022:39a4 with SMTP id 5b1f17b1804b1-493b7199050mr4334615e9.9.1782730965395; Mon, 29 Jun 2026 04:02:45 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:88ea:c658:5b20:5e46]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-473dddcb295sm8346405f8f.35.2026.06.29.04.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 04:02:45 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This allows camera images to be written to offset locations within buffers (which must have be allocated with sufficient space available). Firstly, the RPi::Stream class tracks the associated "ispOutputIndex" for output streams, that is, whether it corresponds to ISP output branch 0 or branch 1. Secondly, we pass buffer offsets on to libpisp for each request. Signed-off-by: David Plowman --- .../pipeline/rpi/common/rpi_stream.h | 10 ++++++++-- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h index 300a352a..51931867 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h @@ -97,14 +97,14 @@ public: using StreamFlags = Flags; Stream() - : flags_(StreamFlag::None), id_(0), swDownscale_(0) + : flags_(StreamFlag::None), id_(0), swDownscale_(0), ispOutputIndex_(-1) { } Stream(const char *name, MediaEntity *dev, StreamFlags flags = StreamFlag::None) : flags_(flags), name_(name), dev_(std::make_unique(dev)), id_(0), - swDownscale_(0) + swDownscale_(0), ispOutputIndex_(-1) { } @@ -125,6 +125,9 @@ public: void setExportedBuffer(FrameBuffer *buffer); + void setIspIndex(int ispIndex) { ispOutputIndex_ = ispIndex; } + int getIspIndex() const { return ispOutputIndex_; } + int allocateBuffers(unsigned int count); int queueBuffer(FrameBuffer *buffer); void returnBuffer(FrameBuffer *buffer); @@ -181,6 +184,9 @@ private: * as the stream needs to maintain ownership of these buffers. */ std::vector> internalBuffers_; + + /* For output streams, the ISP branch for this stream (otherwise -1). */ + int ispOutputIndex_; }; /* diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index b744c901..1238d0e9 100644 --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp @@ -1524,6 +1524,7 @@ int PiSPCameraData::platformConfigure(const RPi::RPiCameraConfiguration *rpiConf beEnables |= PISP_BE_RGB_ENABLE_OUTPUT0; ispIndex = 0; } + stream->setIspIndex(ispIndex); format = outStreams[i].format; bool needs32BitConversion = adjustDeviceFormat(format); @@ -2317,6 +2318,24 @@ void PiSPCameraData::tryRunPipeline() Request *request = requestQueue_.front(); ASSERT(request->metadata().empty()); + /* Pass the plane offsets of any output buffers to the Back End ISP. */ + for (auto const &[stream, buffer] : request->buffers()) { + int ispIndex = static_cast(stream)->getIspIndex(); + if (ispIndex >= 0) { + /* + * PiSP takes only 2 offsets; offset 3 (where required) is assumed + * to be the same as offset 2. + */ + unsigned int offset = buffer->planes()[0].offset; + unsigned int offset2 = 0; + if (buffer->planes().size() > 1) + offset2 = buffer->planes()[1].offset; + + pisp_be_output_format_extra extra{ 0, 0, { offset, offset2 } }; + be_->SetOutputFormatExtra(ispIndex, extra); + } + } + /* See if a new ScalerCrop value needs to be applied. */ applyScalerCrop(request->controls());