From patchwork Wed Jul 1 13:24:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 27154 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 E0175C3307 for ; Wed, 1 Jul 2026 13:26:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 28E3A65FAD; Wed, 1 Jul 2026 15:26:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JLzzg9tp"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5DA8865F14 for ; Wed, 1 Jul 2026 15:25:58 +0200 (CEST) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-493b68b4643so4101915e9.0 for ; Wed, 01 Jul 2026 06:25:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1782912358; x=1783517158; 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:content-type; bh=l/zZP76L0qGd29J1oaikfH68PPMLBZeClrJm9zoVXS4=; b=JLzzg9tpFkN5gzfD6m3u6XeWO9CVRAMZuR0F1Y9mEW03FFBPv5iJoSyf0kOXE5OuR8 CkkKg9xC65r5WUFvO6Ddj/L2a9S8Dq4Bcd0KPHEA1vT707PHPspWkChmsML4zIG2Lk3a rBF50oKlhCmgzQFmAd+dQRT+2yQpo3k48046B0o0oRwQjrLgR94fK3pG1iBtoHdJ+PWE mdW48PhQ4APrGeTI2/mYNzhUZTwE5cWOiPZ6sbkaZKlH6FRECWF2RBYS8hBPL9vWRX+S wjfDWXyUYojJQCGfhtYaTRKYD+5Rf5Q6+gDNgInUXtv+kSW33TtEN6L314YgCj/ltTUB xF9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782912358; x=1783517158; 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:content-type; bh=l/zZP76L0qGd29J1oaikfH68PPMLBZeClrJm9zoVXS4=; b=fl9iI0GAIG7ys3FK/dfgZUo6z1FNgLLpRtL+W6XM9kgLr4eO7/KMGrOLSZH3xMWkEu SX3VjHJdwErbHFeEog1wcLXSrdS2HHqQFMIT4PFLzY+3OYYPxoQabZAlVh5kBZzJbhrv r51aHbkI1MEACR1Gaqm4Y0Lkh7NxOUInus8cxnxzzfxEuf0eMnW9jdKOFqQbmurr8fpp 8L2f7lLs9jSsJoSsYbSDYXm8hUMXA5q/XdDJRZesCLRISooGGTbkhPb3gwy/V88Cj20l iyybhnH3hge/gjjY3PgdLcwrLX/DXz9aYcgDK54KyIRLOabD0jQHHmZCXYKTW6YIhy7F Swlw== X-Gm-Message-State: AOJu0Yz+xwOen6Lz2bfq/R0ra1ATON0tNnlnlVbSqzhb6+i2Cz0+5sC7 5Ou31VAiUBUVXi6geBBgFN5PvK6j5ynC9oecxRuvf73ofkx3pPreeS8Lbzagd2fClcO2pQ04ydJ YzBSplRo= X-Gm-Gg: AfdE7cnnTESZs6R9KbY6PPmDyAN2SA/LJhb7kW7Ri2OvdHZDbo2BJLW3RQ4xfgBZE3k ZZHaltKkwnWOnpMVZlthSt1xTvTjcpiZMQixuSjTeYMiN3LIcwuuTvJZTN/RKW1utBTz5HAMucF HaA9OJ98tx68n/iwqwGl09sficUz9vUu//jQ4IZNTl/jXr+JV05B8xfDAMdY7W76xGdG/g/Khcs b/X/XiySpYsdtimGpk0An6f6kINEtMT27hQ0bXviZKjnMZm8YjIVFRyjdex4mIGZrxnKUdDhmMR UkAiEuyS+tI+H0PGu6GjI2829TeLtrUPUa770OOWzSv0CulgATl7pqhhX7y5jyHbd+q+N2aUD+i njU2kX/mvmFJ9Q0+oRv22mFdn8QBb5UbdI6qZTWhXBVwBCHliegKSzbBFWg354U0KtzTxmpEpwf Klo523BiavX+EdNgW08mAylJuY9c33erOSxTPBkS83GR95GYJ1dH05sVQpv7Sb3ZNrUhJXo24XY 7YHuV4My95ChOtr8x+BsmfXMMr7Ioqh X-Received: by 2002:a05:600c:a215:b0:493:ba40:ef39 with SMTP id 5b1f17b1804b1-493c3cd7ce3mr6948765e9.15.1782912357720; Wed, 01 Jul 2026 06:25:57 -0700 (PDT) Received: from davidp-pi5.pitowers.org ([2a00:1098:3142:1f:4706:89ee:c47e:1087]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493be4fef11sm70758135e9.15.2026.07.01.06.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 06:25:57 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: David Plowman Subject: [PATCH v2 1/1] pipeline: rpi: Handle buffers with offsets Date: Wed, 1 Jul 2026 14:24:10 +0100 Message-ID: <20260701132555.66035-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260701132555.66035-1-david.plowman@raspberrypi.com> References: <20260701132555.66035-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 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. The libpisp version is moved on to 1.6.0 which is required for this change. Signed-off-by: David Plowman --- .../pipeline/rpi/common/rpi_stream.h | 10 ++++++++-- src/libcamera/pipeline/rpi/pisp/meson.build | 2 +- src/libcamera/pipeline/rpi/pisp/pisp.cpp | 19 +++++++++++++++++++ subprojects/libpisp.wrap | 2 +- 4 files changed, 29 insertions(+), 4 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/meson.build b/src/libcamera/pipeline/rpi/pisp/meson.build index 178df94c..121f93ef 100644 --- a/src/libcamera/pipeline/rpi/pisp/meson.build +++ b/src/libcamera/pipeline/rpi/pisp/meson.build @@ -5,7 +5,7 @@ libcamera_internal_sources += files([ ]) librt = cc.find_library('rt', required : true) -libpisp_dep = dependency('libpisp', fallback : ['libpisp', 'libpisp_dep']) +libpisp_dep = dependency('libpisp', version : '>=1.6.0', fallback : ['libpisp', 'libpisp_dep']) libcamera_deps += [libpisp_dep, librt] diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp index c9d89d58..23f4c14d 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); @@ -2306,6 +2307,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()); diff --git a/subprojects/libpisp.wrap b/subprojects/libpisp.wrap index b92de484..1a3c3b77 100644 --- a/subprojects/libpisp.wrap +++ b/subprojects/libpisp.wrap @@ -2,5 +2,5 @@ [wrap-git] url = https://github.com/raspberrypi/libpisp.git -revision = v1.5.0 +revision = v1.6.0 depth = 1