From patchwork Wed Apr 1 16:25:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26407 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 7C72AC32BB for ; Wed, 1 Apr 2026 16:26:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A83862D65; Wed, 1 Apr 2026 18:26:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CUNNXT+M"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C6E962D58 for ; Wed, 1 Apr 2026 18:26:01 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B6E96F04; Wed, 1 Apr 2026 18:24:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060677; bh=cPNFG01nfL/fFep4yGdJzWBDfo5rH8weIzKgIeOBJvw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CUNNXT+MMz5NXgJLqVOK9QuGllxDn+d8azRg3vfk6zaX+LyHzcM03G9+X9AkDBvgW gmymDndMQTwpEV1xcjBWBkW5/TFTNKmWTRgkqDxKrbhlmbn1B7QFxoJij2wldw9f3N n5y37u+4EID2Fp50VqHBahpuPc/ZdbydIuXWfNZE= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:50 +0200 Subject: [PATCH v8 1/8] libcamera: mali-c55: Add RZG2LCRU class MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-1-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=9802; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=l/27g48AuepEqwXR256i1nph+XEQELQu6hC3lLzVaV8=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcW7ZWVEYc0JN0SANbw6xKAHKUvJcVZY9e1d Aa9oMPi1+qJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFgAKCRByNAaPFqFW PL9BEADDdhSMwSqANi/cBqxP34bMHAZgz+lkargT6PABTjmsM61yQOwrwNxTWZ+i4wB6Y1RjQQl Mq0V5VPdoZj8+55pTOrcgkPv34G55X+nYr1ZwGnqhD1JH3/cBBID9x6rISF7uRNs6Qw/of2MbpZ RwkliTyKfCQp7JFTOm8/+6r6bgYatRYVT92d9LZPkt65lzeJgfD6hLKhuYU4BXbqPwmaz3hTznz VW2MIfQ48dkcwtqdjBP4v5PdygS60RUXj9oNvrt0v5o83ab6FF3P/4W7sT8imslwSUHWvkB98jJ Hu3W/D3Zn9beDKwKL4numa2zdMAUy8V/eS6KsI9v7PHSEHovtyIY/1bqLRvI+SXau+K6eh1jCBl dG7NxdNS53H5FrhlOf6AHVj/m3Ue5YNbfy/2oMzuTDsbvodEHa92IjA2FJa1+T510RLWYctvTH9 CyCsghDUPJGRVQSFZYfDnVdgmDDqwmi4H/Vctk1bDvRj0+5zXg2KeWAHAh8/N+/AylJsnk6mMFg f1hLCGD0MYEygvmYbXFQKb+KAHhnFwc12vniBFQjphtSjuHGtvjaKV+goz4hHu9P/nMu6e2GF4n tvRfp3EejVrhG0rAd7Ds9Q7gKHkoIXZD7y+a15M++UfUaKso6BVyP/oS9q0aU1yq/cuAhXobLUm L6NtPtyYS3pGqog== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" From: Daniel Scally Add a class allowing us to control the RZ/G2L Camera Receiver Unit. The class is named after the media device it handles, which is called "rzg2l_cru" but the CRU is actually found in other SoCs than the RZ/G2L one, such as the RZ/V2H(P). The RZG2LCRU class models the CSI-2 receiver found on those SoCs and allows to add support for memory-to-memory operations on the RZ/V2H(P) SoC which integrates a Mali-C55 ISP and a specialized DMA engine named IVC that feeds images from memory, where the CRU has saved them. Signed-off-by: Daniel Scally Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/mali-c55/meson.build | 3 +- src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp | 253 ++++++++++++++++++++++++++ src/libcamera/pipeline/mali-c55/rzg2l-cru.h | 70 +++++++ 3 files changed, 325 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/mali-c55/meson.build b/src/libcamera/pipeline/mali-c55/meson.build index eba8e5a39054..4e768242602e 100644 --- a/src/libcamera/pipeline/mali-c55/meson.build +++ b/src/libcamera/pipeline/mali-c55/meson.build @@ -1,5 +1,6 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_internal_sources += files([ - 'mali-c55.cpp' + 'mali-c55.cpp', + 'rzg2l-cru.cpp', ]) diff --git a/src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp b/src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp new file mode 100644 index 000000000000..9cb7cc3f10c6 --- /dev/null +++ b/src/libcamera/pipeline/mali-c55/rzg2l-cru.cpp @@ -0,0 +1,253 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Ideas on Board Oy + * + * Pipine handler element for the Renesas RZ/G2L Camera Receiver Unit + */ + +#include "rzg2l-cru.h" + +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/camera_sensor.h" +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/media_device.h" +#include "libcamera/internal/request.h" + +namespace libcamera { + +static const std::map bitDepthToFmt{ + { 10, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU10) }, + { 12, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU12) }, + { 14, V4L2PixelFormat(V4L2_PIX_FMT_RAW_CRU14) }, +}; + +LOG_DEFINE_CATEGORY(RZG2LCRU) + +FrameBuffer *RZG2LCRU::queueBuffer(Request *request) +{ + FrameBuffer *buffer; + + if (availableBuffers_.empty()) { + LOG(RZG2LCRU, Debug) << "CRU buffer underrun"; + return nullptr; + } + + buffer = availableBuffers_.back(); + + int ret = output_->queueBuffer(buffer); + if (ret) { + LOG(RZG2LCRU, Error) << "Failed to queue buffer to CRU"; + return nullptr; + } + + availableBuffers_.pop_back(); + buffer->_d()->setRequest(request); + + return buffer; +} + +void RZG2LCRU::returnBuffer(FrameBuffer *buffer) +{ + auto it = std::find_if(buffers_.begin(), buffers_.end(), + [&](const auto &b) { return b.get() == buffer; }); + ASSERT(it != buffers_.end()); + + availableBuffers_.push_back(buffer); +} + +int RZG2LCRU::start(unsigned int bufferCount) +{ + int ret = output_->exportBuffers(bufferCount, &buffers_); + if (ret < 0) + return ret; + + utils::scope_exit bufferGuard([&] { freeBuffers(); }); + + ret = output_->importBuffers(bufferCount); + if (ret) + return ret; + + for (std::unique_ptr &buffer : buffers_) + availableBuffers_.push_back(buffer.get()); + + ret = output_->streamOn(); + if (ret) + return ret; + + bufferGuard.release(); + + return 0; +} + +int RZG2LCRU::stop() +{ + return output_->streamOff(); +} + +int RZG2LCRU::freeBuffers() +{ + availableBuffers_.clear(); + buffers_.clear(); + + return output_->releaseBuffers(); +} + +int RZG2LCRU::configure(V4L2SubdeviceFormat *subdevFormat, V4L2DeviceFormat *inputFormat) +{ + /* + * Set format on the sensor and propagate it up to the CRU video + * device. + */ + + int ret = sensor_->setFormat(subdevFormat); + if (ret) + return ret; + + ret = csi2_->setFormat(0, subdevFormat); + if (ret) + return ret; + + ret = csi2_->getFormat(1, subdevFormat); + if (ret) + return ret; + + ret = cru_->setFormat(0, subdevFormat); + if (ret) + return ret; + + ret = cru_->getFormat(1, subdevFormat); + if (ret) + return ret; + + /* + * The capture device needs to be set with a format that can be produced + * from the mbus code of the subdevFormat. The CRU and IVC use bayer + * order agnostic pixel formats, so all we need to do is find the right + * bitdepth and select the appropriate format. + */ + BayerFormat bayerFormat = BayerFormat::fromMbusCode(subdevFormat->code); + if (!bayerFormat.isValid()) + return -EINVAL; + + V4L2DeviceFormat captureFormat; + captureFormat.fourcc = bitDepthToFmt.at(bayerFormat.bitDepth); + captureFormat.size = subdevFormat->size; + + ret = output_->setFormat(&captureFormat); + if (ret) + return ret; + + /* + * We return the format that we set against the output device, as the + * same format will also need to be set against the Input Video Control + * Block device. + */ + *inputFormat = captureFormat; + + return 0; +} + +void RZG2LCRU::initCRUSizes() +{ + Size maxCSI2Size; + + /* + * Get the maximum supported size on the CSI-2 receiver. We need to + * query the kernel interface as the size limits differ from RZ/G2L + * (2800x4095) and RZ/V2H (4096x4096). + */ + V4L2Subdevice::Formats csi2Formats = csi2_->formats(0); + if (csi2Formats.empty()) + return; + + for (const auto &format : csi2Formats) { + for (const auto &range : format.second) { + if (range.max > maxCSI2Size) + maxCSI2Size = range.max; + } + } + + /* + * Enumerate the sensor supported resolutions and filter out the ones + * larger than the maximum supported CSI-2 receiver input size. + */ + V4L2Subdevice::Formats formats = sensor_->device()->formats(0); + if (formats.empty()) + return; + + for (const auto &format : formats) { + for (const auto &range : format.second) { + const Size &max = range.max; + + if (max.width > maxCSI2Size.width || + max.height > maxCSI2Size.height) + continue; + + csi2Sizes_.push_back(max); + } + } + + /* Sort in increasing order and remove duplicates. */ + std::sort(csi2Sizes_.begin(), csi2Sizes_.end()); + auto last = std::unique(csi2Sizes_.begin(), csi2Sizes_.end()); + csi2Sizes_.erase(last, csi2Sizes_.end()); + + csi2Resolution_ = csi2Sizes_.back(); +} + +int RZG2LCRU::init(const MediaDevice *media) +{ + static const std::regex cruRegex("cru-ip-[0-9a-f]{8}.cru[0-9]"); + static const std::regex csi2Regex("csi-[0-9a-f]{8}.csi2"); + + csi2_ = V4L2Subdevice::fromEntityName(media, csi2Regex); + if (!csi2_) + return -ENODEV; + + int ret = csi2_->open(); + if (ret) + return ret; + + const std::vector &pads = csi2_->entity()->pads(); + if (pads.empty()) + return -ENODEV; + + /* The receiver has a single sink pad at index 0 */ + MediaPad *sink = pads[0]; + const std::vector &links = sink->links(); + if (links.empty()) + return -ENODEV; + + MediaLink *link = links[0]; + sensor_ = CameraSensorFactoryBase::create(link->source()->entity()); + if (!sensor_) + return -ENODEV; + + cru_ = V4L2Subdevice::fromEntityName(media, cruRegex); + ret = cru_->open(); + if (ret) + return ret; + + output_ = V4L2VideoDevice::fromEntityName(media, "CRU output"); + ret = output_->open(); + if (ret) + return ret; + + initCRUSizes(); + + return 0; +} + +} /* namespace libcamera */ diff --git a/src/libcamera/pipeline/mali-c55/rzg2l-cru.h b/src/libcamera/pipeline/mali-c55/rzg2l-cru.h new file mode 100644 index 000000000000..8bd4c027adda --- /dev/null +++ b/src/libcamera/pipeline/mali-c55/rzg2l-cru.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Ideas on Board Oy + * + * Pipine handler element for the Renesas RZ/G2L Camera Receiver Unit + */ + +#pragma once + +#include +#include + +#include + +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" + +namespace libcamera { + +class CameraSensor; +class FrameBuffer; +class MediaDevice; +class Request; +class Size; + +class RZG2LCRU +{ +public: + RZG2LCRU() = default; + + const std::vector &sizes() const + { + return csi2Sizes_; + } + + int init(const MediaDevice *media); + const Size &resolution() const + { + return csi2Resolution_; + } + + CameraSensor *sensor() const { return sensor_.get(); } + V4L2Subdevice *csi2() const { return csi2_.get(); } + V4L2Subdevice *cru() const { return cru_.get(); } + V4L2VideoDevice *output() { return output_.get(); } + + int configure(V4L2SubdeviceFormat *subdevFormat, V4L2DeviceFormat *inputFormat); + FrameBuffer *queueBuffer(Request *request); + void returnBuffer(FrameBuffer *buffer); + int freeBuffers(); + + int start(unsigned int bufferCount); + int stop(); + +private: + void initCRUSizes(); + + std::unique_ptr sensor_; + std::unique_ptr csi2_; + std::unique_ptr cru_; + std::unique_ptr output_; + + std::vector> buffers_; + std::vector availableBuffers_; + + std::vector csi2Sizes_; + Size csi2Resolution_; +}; + +} /* namespace libcamera */ From patchwork Wed Apr 1 16:25:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26408 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 7CED3BDCBD for ; Wed, 1 Apr 2026 16:26:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51C0D62D5F; Wed, 1 Apr 2026 18:26:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BdFO0S5P"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 62BDE62CCA for ; Wed, 1 Apr 2026 18:26:01 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1576A156F; Wed, 1 Apr 2026 18:24:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060678; bh=FegylNAS/ZE8S1oZUyAdmGxPOxc4ElLR/QAsnKcxhNE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BdFO0S5P1x70M5Htg8RBoVM11nhs5pGR/qrFZxzYSkvD+IeE1ABu0pcfYqpFhr1NX gHGlbyElSL8+ZwAYy1vPSycoDVRzvLmhVHIcuYGyJ60NzaExphKDk5KjIXmfajrpQn ui6uU08ce2XRdO/xcq0As7VXt2K7t5yQhKOLnHyc= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:51 +0200 Subject: [PATCH v8 2/8] libcamera: utils: Add overloaded visitor helpers MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-2-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4147; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=FegylNAS/ZE8S1oZUyAdmGxPOxc4ElLR/QAsnKcxhNE=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcXv/dKg1BUMtXevpqyBlb2FaYhW2CcbeS28 EV5Xane6BSJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW POcYD/9sLKseRdO+/w3DdsCqg71lmjcYYYKwe4HRLSAnyM5jBSW5tgf5Ek2mJDVroF/20HeB4pT tANvnrGQJskPOf/GLRdz0pnaO1WRV449eFc3uTEohAR157FZb9BMzjIw+sS5ZblLoCeIEQ3F7Aa KooJSeh75gl1fiMvw1gr13qP76wrMcMvE4kEuBBWlN6wvqBX5bXGab0ISp2hM2+3RbogZJCi/0v 9wqujjQG5z9CHsqa24ZWjW3U8+nnpyZDkksko/ErC4AB1Fz3loerUWpnq/BuzdlxFcyYnfsrCB1 43C1vF+v4QE8o6CcXVHA6m58EpMZBWuBuuhLKsv0m9Y7i6zuNmJeJSx2hdFSwKR70vElCSIpP8r 5ru0W0HjO1UTv+y79XOHfByTMuNyR6q+KbVWUuhew1cYVmqeWuu8PWKEJAJ/Zl+ZnMyFlfiggqt KtLR/jQJ5XAB5ryvmxO/99FoWslUNPAPqiPcIhzf1NDStNoiaDQCZNs8MH1S+TG7diyA+8h9re4 aT6Pz0YJXf+q7y8wZI5dVqEAU83WldLU9gzhnphOHckl3phGiGH3wmkHr6+SYqcn2Npavbbj2eC 77BnV5tVU+rc85jfaSP2Vw27/pXGmKpPoneD+DNQUw+TiWm4JapzYFh9mqP5KfxjsFCDupdoPkV IRBJfEE+3sRV/LA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" std::visit() allows quite elegant type-matching implementation of the visitor pattern. The 'overloaded' type helpers allow to define a hierarchy of overloaded operator() implementations which can be used by std::visit(). Currently only the Virtual pipeline handler uses this type-matching implementation of std::visit. To prepare to add another user in the Mali C55 pipeline handler move the 'overloaded' helper type to libcamera::utils for easier re-use. Reviewed-by: Barnabás Pőcze Signed-off-by: Jacopo Mondi --- include/libcamera/base/utils.h | 7 ++++++ src/libcamera/base/utils.cpp | 35 ++++++++++++++++++++++++++++++ src/libcamera/pipeline/virtual/virtual.cpp | 10 ++------- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h index 7083b7ce9ce9..62c7f89c25a1 100644 --- a/include/libcamera/base/utils.h +++ b/include/libcamera/base/utils.h @@ -37,6 +37,13 @@ namespace libcamera { namespace utils { +template +struct overloaded : Ts... { + using Ts::operator()...; +}; +template +overloaded(Ts...) -> overloaded; + const char *basename(const char *path); char *secure_getenv(const char *name); diff --git a/src/libcamera/base/utils.cpp b/src/libcamera/base/utils.cpp index 42a516097be2..836aec87c539 100644 --- a/src/libcamera/base/utils.cpp +++ b/src/libcamera/base/utils.cpp @@ -23,6 +23,41 @@ namespace libcamera { namespace utils { +/** + * \struct overloaded + * \brief Helper type for type-matching std::visit implementations + * \tparam Ts... Template arguments pack of visitors + * + * Expand the template argument pack \a Ts... to provide overloaded \a + * operator() to support type-matching implementations of the visitor design + * pattern using std::visit. + * + * An example is provided by the STL documentation in the form of: + * + * \code{.cpp} + * template struct overloaded : Ts... { using Ts::operator()...; }; + * template overloaded(Ts...) -> overloaded; + * + * using var_t = std::variant; + * std::vector vec = {10, 15l, 1.5, "hello"}; + * + * for (auto& v: vec) { + * std::visit(overloaded { + * [](auto arg) { std::cout << arg << ' '; }, + * [](double arg) { std::cout << std::fixed << arg << ' '; }, + * [](const std::string& arg) { std::cout << std::quoted(arg) << ' '; }, + * }, v); + * \endcode + * + * Use this helper to implement type-matching visitors using std::visit(). + */ + +/** + * \var overloaded(Ts...) -> overloaded + * \brief Deduction guide necessary for C++17 compatibility + * \tparam Ts... Template arguments pack of visitor functions + */ + /** * \brief Strip the directory prefix from the path * \param[in] path The path to process diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp index efd800ebe3d6..e8ef7e524ccf 100644 --- a/src/libcamera/pipeline/virtual/virtual.cpp +++ b/src/libcamera/pipeline/virtual/virtual.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -57,13 +58,6 @@ uint64_t currentTimestamp() } /* namespace */ -template -struct overloaded : Ts... { - using Ts::operator()...; -}; -template -overloaded(Ts...) -> overloaded; - class VirtualCameraConfiguration : public CameraConfiguration { public: @@ -428,7 +422,7 @@ bool PipelineHandlerVirtual::initFrameGenerator(Camera *camera) { auto data = cameraData(camera); auto &frame = data->config_.frame; - std::visit(overloaded{ + std::visit(utils::overloaded{ [&](TestPattern &testPattern) { for (auto &streamConfig : data->streamConfigs_) { if (testPattern == TestPattern::DiagonalLines) From patchwork Wed Apr 1 16:25:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26409 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 895CDC32F6 for ; Wed, 1 Apr 2026 16:26:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 323A362D73; Wed, 1 Apr 2026 18:26:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aammw6Zc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CFA162D5A for ; Wed, 1 Apr 2026 18:26:01 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 621B716AC; Wed, 1 Apr 2026 18:24:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060678; bh=jFpT13cBTk2VgxmG46TrkerQDDgq6237mXTx4G/Gn0A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aammw6ZcoIRhvOq/66t0p/HX0u5dWerv3iMPqEjffNvb/jIaRXwBXhOBWy1gZTC61 sH72UgfC3K+c0oo1mipE1Q1gdjPTcvibW9wvxqTOXxGGf5ievR40yZpQHxBLSnpfbd 3F0s7rLpd8JAR/1+DdWJzgd8+bf055BI/MmQPq9o= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:52 +0200 Subject: [PATCH v8 3/8] libcamera: mali-c55: Split TPG and Inline camera handling MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-3-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=16182; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=jFpT13cBTk2VgxmG46TrkerQDDgq6237mXTx4G/Gn0A=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcX6kAzbTnXWNWAjNSTk9ESFs9JuGQXLZpBU ylSdjOpnyKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW PI1KD/4lZC3bl7998gTv2z0hVp0gaWRcqiEzWHsrks9ejbVed2yYmXx47Ot+bjQdaQ7ZeiHgv7a GEV2tSPs/xTVcY56PKmONd3LdjoZ1BQZaRhIdbzpPDFKO0rKvLEYK1IxRIhKRZBMUg1tzkhRIZt dWHcFVXFqQsC0mhpZmnjYlHU7iZo3gEI6/r0v81OsIva47tAwIvJZYR8l3Eb0b1r5bjFHnbIep1 Rztl7oKbqMXJuBCun45B5UM3pWCdjzD6KkzeJHjWXhil13Liny+umjcQ+qWRV2PefDenxrIKJZ1 Wf/hAm74rVmdtQr9/HWZX4xqXuxMzVsmXyiwWJktdXwdmMEaP0dTbkFt7VDNmoNIVnvGhIEzc6S bM2IAg4RZsgYRKN5q2AAJQcq2qTpWLjbVWG+mrGkD0CfbFPek0KYlUdYW+Gh0zUwi/DdJ4IgE5Q WqwR0va6uZrXPhsEnG6r+usNC1oOQVsjfGznrJmxSrvQCglYnTFs/CoaY3W7M85HVx3gmY0mqC1 QoTawdYeSafNxjq04AlqQ/mdtaiV39RpGnNs86tTKP0xEjvewlPsV8XaxSnUuH9OWFn7t8w9Wj0 wVebsxpuPM38NIu4r9i3YCZQKYPepvu9vkEcfrXHak/6xlpKsF6hOungeAx49QL1v4jn/wsVCd4 /CdUY7FhUPr+xBA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" In order to prepare to support memory input cameras, split the handling of the TPG and Inline camera cases. The Mali C55 pipeline handler uses the entity and subdevice stored in the CameraData to support both the handling of the TPG and of the Inline (CSI-2 + sensor) use cases. Adding support for memory cameras by using the CRU unit would add yet-another special case making the code harder to follow and more prone to errors. Split the handling of the TPG and Inline cameras by introducing an std::variant<> variable and to deflect the functions called on the camera data to the correct type by using overloaded std::visit<>(). Signed-off-by: Jacopo Mondi Reviewed-by: Barnabás Pőcze --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 278 ++++++++++++++++----------- 1 file changed, 162 insertions(+), 116 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index c209b0b070b1..26dfd0aef73c 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -92,17 +94,77 @@ struct MaliC55FrameInfo { class MaliC55CameraData : public Camera::Private { public: - MaliC55CameraData(PipelineHandler *pipe, MediaEntity *entity) - : Camera::Private(pipe), entity_(entity) + struct Tpg { + std::vector sizes(unsigned int mbusCode) const; + + Size resolution_; + std::unique_ptr sd_; + }; + + struct Inline { + std::unique_ptr csi2_; + std::unique_ptr sensor_; + }; + using CameraType = std::variant; + + MaliC55CameraData(PipelineHandler *pipe) + : Camera::Private(pipe) { } - int init(); int loadIPA(); - /* Deflect these functionalities to either TPG or CameraSensor. */ - std::vector sizes(unsigned int mbusCode) const; - Size resolution() const; + Tpg *initTpg(MediaEntity *entity); + Inline *initInline(MediaEntity *entity); + + std::vector sizes(unsigned int mbusCode) const + { + return std::visit(utils::overloaded{ + [&](const Tpg &tpg) -> std::vector { + return tpg.sizes(mbusCode); + }, + [&](const Inline &in) -> std::vector { + return in.sensor_->sizes(mbusCode); + } + }, input_); + } + + V4L2Subdevice *subdev() const + { + return std::visit(utils::overloaded{ + [&](const Tpg &tpg) -> V4L2Subdevice * { + return tpg.sd_.get(); + }, + [&](const Inline &in) -> V4L2Subdevice * { + return in.sensor_->device(); + }, + }, input_); + } + + CameraSensor *sensor() const + { + return std::visit(utils::overloaded{ + [&](auto &) -> CameraSensor * { + ASSERT(false); + return nullptr; + }, + [&](const Inline &in) -> CameraSensor * { + return in.sensor_.get(); + }, + }, input_); + } + + Size resolution() const + { + return std::visit(utils::overloaded{ + [&](const Tpg &tpg) -> Size { + return tpg.resolution_; + }, + [&](const Inline &in) -> Size { + return in.sensor_->resolution(); + }, + }, input_); + } int pixfmtToMbusCode(const PixelFormat &pixFmt) const; const PixelFormat &bestRawFormat() const; @@ -112,11 +174,6 @@ public: PixelFormat adjustRawFormat(const PixelFormat &pixFmt) const; Size adjustRawSizes(const PixelFormat &pixFmt, const Size &rawSize) const; - std::unique_ptr sensor_; - - MediaEntity *entity_; - std::unique_ptr csi_; - std::unique_ptr sd_; Stream frStream_; Stream dsStream_; @@ -126,58 +183,28 @@ public: std::unique_ptr delayedCtrls_; + CameraType input_; + private: - void initTPGData(); void setSensorControls(const ControlList &sensorControls); - std::string id_; - Size tpgResolution_; }; -int MaliC55CameraData::init() +MaliC55CameraData::Tpg *MaliC55CameraData::initTpg(MediaEntity *entity) { - int ret; + Tpg tpg; - sd_ = std::make_unique(entity_); - ret = sd_->open(); + tpg.sd_ = std::make_unique(entity); + int ret = tpg.sd_->open(); if (ret) { - LOG(MaliC55, Error) << "Failed to open sensor subdevice"; - return ret; - } - - /* If this camera is created from TPG, we return here. */ - if (entity_->name() == "mali-c55 tpg") { - initTPGData(); - return 0; - } - - /* - * Register a CameraSensor if we connect to a sensor and create - * an entity for the connected CSI-2 receiver. - */ - sensor_ = CameraSensorFactoryBase::create(entity_); - if (!sensor_) - return -ENODEV; - - const MediaPad *sourcePad = entity_->getPadByIndex(0); - MediaEntity *csiEntity = sourcePad->links()[0]->sink()->entity(); - - csi_ = std::make_unique(csiEntity); - ret = csi_->open(); - if (ret) { - LOG(MaliC55, Error) << "Failed to open CSI-2 subdevice"; - return ret; + LOG(MaliC55, Error) << "Failed to open TPG subdevice"; + return nullptr; } - return 0; -} - -void MaliC55CameraData::initTPGData() -{ /* Replicate the CameraSensor implementation for TPG. */ - V4L2Subdevice::Formats formats = sd_->formats(0); + V4L2Subdevice::Formats formats = tpg.sd_->formats(0); if (formats.empty()) - return; + return nullptr; std::vector tpgSizes; @@ -187,19 +214,35 @@ void MaliC55CameraData::initTPGData() [](const SizeRange &range) { return range.max; }); } - tpgResolution_ = tpgSizes.back(); + tpg.resolution_ = tpgSizes.back(); + + return &input_.emplace(std::move(tpg)); } -void MaliC55CameraData::setSensorControls(const ControlList &sensorControls) +MaliC55CameraData::Inline *MaliC55CameraData::initInline(MediaEntity *sensor) { - delayedCtrls_->push(sensorControls); + Inline in; + + /* Register a CameraSensor and create an entity for the CSI-2 receiver. */ + in.sensor_ = CameraSensorFactoryBase::create(sensor); + if (!in.sensor_) + return nullptr; + + const MediaPad *sourcePad = sensor->getPadByIndex(0); + MediaEntity *csiEntity = sourcePad->links()[0]->sink()->entity(); + + in.csi2_ = std::make_unique(csiEntity); + int ret = in.csi2_->open(); + if (ret) { + LOG(MaliC55, Error) << "Failed to open CSI-2 subdevice"; + return nullptr; + } + + return &input_.emplace(std::move(in)); } -std::vector MaliC55CameraData::sizes(unsigned int mbusCode) const +std::vector MaliC55CameraData::Tpg::sizes(unsigned int mbusCode) const { - if (sensor_) - return sensor_->sizes(mbusCode); - V4L2Subdevice::Formats formats = sd_->formats(0); if (formats.empty()) return {}; @@ -218,12 +261,9 @@ std::vector MaliC55CameraData::sizes(unsigned int mbusCode) const return sizes; } -Size MaliC55CameraData::resolution() const +void MaliC55CameraData::setSensorControls(const ControlList &sensorControls) { - if (sensor_) - return sensor_->resolution(); - - return tpgResolution_; + delayedCtrls_->push(sensorControls); } /* @@ -242,7 +282,7 @@ int MaliC55CameraData::pixfmtToMbusCode(const PixelFormat &pixFmt) const if (!bayerFormat.isValid()) return -EINVAL; - V4L2Subdevice::Formats formats = sd_->formats(0); + V4L2Subdevice::Formats formats = subdev()->formats(0); unsigned int sensorMbusCode = 0; unsigned int bitDepth = 0; @@ -280,7 +320,7 @@ const PixelFormat &MaliC55CameraData::bestRawFormat() const { static const PixelFormat invalidPixFmt = {}; - for (const auto &fmt : sd_->formats(0)) { + for (const auto &fmt : subdev()->formats(0)) { BayerFormat sensorBayer = BayerFormat::fromMbusCode(fmt.first); if (!sensorBayer.isValid()) @@ -302,11 +342,11 @@ const PixelFormat &MaliC55CameraData::bestRawFormat() const void MaliC55CameraData::updateControls(const ControlInfoMap &ipaControls) { - if (!sensor_) + if (std::holds_alternative(input_)) return; IPACameraSensorInfo sensorInfo; - int ret = sensor_->sensorInfo(&sensorInfo); + int ret = sensor()->sensorInfo(&sensorInfo); if (ret) { LOG(MaliC55, Error) << "Failed to retrieve sensor info"; return; @@ -379,7 +419,7 @@ int MaliC55CameraData::loadIPA() int ret; /* Do not initialize IPA for TPG. */ - if (!sensor_) + if (std::holds_alternative(input_)) return 0; ipa_ = IPAManager::createIPA(pipe(), 1, 1); @@ -388,20 +428,20 @@ int MaliC55CameraData::loadIPA() ipa_->setSensorControls.connect(this, &MaliC55CameraData::setSensorControls); - std::string ipaTuningFile = ipa_->configurationFile(sensor_->model() + ".yaml", + std::string ipaTuningFile = ipa_->configurationFile(sensor()->model() + ".yaml", "uncalibrated.yaml"); /* We need to inform the IPA of the sensor configuration */ ipa::mali_c55::IPAConfigInfo ipaConfig{}; - ret = sensor_->sensorInfo(&ipaConfig.sensorInfo); + ret = sensor()->sensorInfo(&ipaConfig.sensorInfo); if (ret) return ret; - ipaConfig.sensorControls = sensor_->controls(); + ipaConfig.sensorControls = sensor()->controls(); ControlInfoMap ipaControls; - ret = ipa_->init({ ipaTuningFile, sensor_->model() }, ipaConfig, + ret = ipa_->init({ ipaTuningFile, sensor()->model() }, ipaConfig, &ipaControls); if (ret) { LOG(MaliC55, Error) << "Failed to initialise the Mali-C55 IPA"; @@ -444,13 +484,13 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() * The TPG doesn't support flips, so we only need to calculate a * transform if we have a sensor. */ - if (data_->sensor_) { + if (std::holds_alternative(data_->input_)) { + combinedTransform_ = Transform::Rot0; + } else { Orientation requestedOrientation = orientation; - combinedTransform_ = data_->sensor_->computeTransform(&orientation); + combinedTransform_ = data_->sensor()->computeTransform(&orientation); if (orientation != requestedOrientation) status = Adjusted; - } else { - combinedTransform_ = Transform::Rot0; } /* Only 2 streams available. */ @@ -927,39 +967,44 @@ int PipelineHandlerMaliC55::configure(Camera *camera, /* Link the graph depending if we are operating the TPG or a sensor. */ MaliC55CameraData *data = cameraData(camera); - if (data->csi_) { - const MediaEntity *csiEntity = data->csi_->entity(); - ret = csiEntity->getPadByIndex(1)->links()[0]->setEnabled(true); - } else { - ret = data->entity_->getPadByIndex(0)->links()[0]->setEnabled(true); - } + ret = std::visit(utils::overloaded{ + [](MaliC55CameraData::Tpg &tpg) { + const MediaEntity *tpgEntity = tpg.sd_->entity(); + return tpgEntity->getPadByIndex(0)->links()[0]->setEnabled(true); + }, + [](MaliC55CameraData::Inline &in) { + const MediaEntity *csi2Entity = in.csi2_->entity(); + return csi2Entity->getPadByIndex(1)->links()[0]->setEnabled(true); + }, + }, data->input_); if (ret) return ret; MaliC55CameraConfiguration *maliConfig = static_cast(config); V4L2SubdeviceFormat subdevFormat = maliConfig->sensorFormat_; - ret = data->sd_->getFormat(0, &subdevFormat); + + /* Apply format to the origin of the pipeline and propagate it. */ + ret = std::visit(utils::overloaded{ + [&](MaliC55CameraData::Tpg &tpg) { + return tpg.sd_->setFormat(0, &subdevFormat); + }, + [&](MaliC55CameraData::Inline &in) { + int r = in.sensor_->setFormat(&subdevFormat, + maliConfig->combinedTransform()); + if (r) + return r; + + r = in.csi2_->setFormat(0, &subdevFormat); + if (r) + return r; + + return in.csi2_->getFormat(1, &subdevFormat); + }, + }, data->input_); if (ret) return ret; - if (data->sensor_) { - ret = data->sensor_->setFormat(&subdevFormat, - maliConfig->combinedTransform()); - if (ret) - return ret; - } - - if (data->csi_) { - ret = data->csi_->setFormat(0, &subdevFormat); - if (ret) - return ret; - - ret = data->csi_->getFormat(1, &subdevFormat); - if (ret) - return ret; - } - V4L2DeviceFormat statsFormat; ret = stats_->getFormat(&statsFormat); if (ret) @@ -973,8 +1018,6 @@ int PipelineHandlerMaliC55::configure(Camera *camera, /* * Propagate the format to the ISP sink pad and configure the input * crop rectangle (no crop at the moment). - * - * \todo Configure the CSI-2 receiver. */ ret = isp_->setFormat(0, &subdevFormat); if (ret) @@ -1058,18 +1101,18 @@ int PipelineHandlerMaliC55::configure(Camera *camera, /* We need to inform the IPA of the sensor configuration */ ipa::mali_c55::IPAConfigInfo ipaConfig{}; - ret = data->sensor_->sensorInfo(&ipaConfig.sensorInfo); + ret = data->sensor()->sensorInfo(&ipaConfig.sensorInfo); if (ret) return ret; - ipaConfig.sensorControls = data->sensor_->controls(); + ipaConfig.sensorControls = data->sensor()->controls(); /* * And we also need to tell the IPA the bayerOrder of the data (as * affected by any flips that we've configured) */ const Transform &combinedTransform = maliConfig->combinedTransform(); - BayerFormat::Order bayerOrder = data->sensor_->bayerOrder(combinedTransform); + BayerFormat::Order bayerOrder = data->sensor()->bayerOrder(combinedTransform); ControlInfoMap ipaControls; ret = data->ipa_->configure(ipaConfig, utils::to_underlying(bayerOrder), @@ -1283,7 +1326,7 @@ void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera, if (!scalerCrop) return; - if (!data->sensor_) { + if (std::holds_alternative(data->input_)) { LOG(MaliC55, Error) << "ScalerCrop not supported for TPG"; return; } @@ -1291,7 +1334,7 @@ void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera, Rectangle nativeCrop = *scalerCrop; IPACameraSensorInfo sensorInfo; - int ret = data->sensor_->sensorInfo(&sensorInfo); + int ret = data->sensor()->sensorInfo(&sensorInfo); if (ret) { LOG(MaliC55, Error) << "Failed to retrieve sensor info"; return; @@ -1573,9 +1616,9 @@ bool PipelineHandlerMaliC55::registerTPGCamera(MediaLink *link) } std::unique_ptr data = - std::make_unique(this, link->source()->entity()); + std::make_unique(this); - if (data->init()) + if (!data->initTpg(link->source()->entity())) return false; return registerMaliCamera(std::move(data), name); @@ -1600,21 +1643,24 @@ bool PipelineHandlerMaliC55::registerSensorCamera(MediaLink *ispLink) continue; std::unique_ptr data = - std::make_unique(this, sensor); - if (data->init()) + std::make_unique(this); + + auto *in = data->initInline(sensor); + if (!in) return false; - data->properties_ = data->sensor_->properties(); + data->properties_ = in->sensor_->properties(); - const CameraSensorProperties::SensorDelays &delays = data->sensor_->sensorDelays(); + const CameraSensorProperties::SensorDelays &delays = + in->sensor_->sensorDelays(); std::unordered_map params = { { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } }, { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } }, }; - data->delayedCtrls_ = - std::make_unique(data->sensor_->device(), - params); + V4L2Subdevice *sensorSubdev = in->sensor_->device(); + data->delayedCtrls_ = std::make_unique(sensorSubdev, + params); isp_->frameStart.connect(data->delayedCtrls_.get(), &DelayedControls::applyControls); From patchwork Wed Apr 1 16:25:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26410 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 7B822C32F5 for ; Wed, 1 Apr 2026 16:26:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE31862D6F; Wed, 1 Apr 2026 18:26:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QJuJYTAi"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E76E562D5C for ; Wed, 1 Apr 2026 18:26:01 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BC0511752; Wed, 1 Apr 2026 18:24:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060678; bh=8GJoWmvnnhVfjvW8kFKHhENpJe9siUMg4bcn9jHEZB8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QJuJYTAihH+K0TBWQhsHttBz123BDtQOYx57cAWoSh/hNJys8/m4R5VSlkttkMUmz HXMXf6lST09eZnEkX8FxkROQImBIEzUvPLNMOU4KBWD9+1jvYN9STm9N8q5Nu7HrIh 1Z2i5hIyVQ6FW7/Nti2GYMa89F3C7rBkCZ6+sxwM= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:53 +0200 Subject: [PATCH v8 4/8] libcamera: mali-c55: Register memory input camera MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-4-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=9956; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=8GJoWmvnnhVfjvW8kFKHhENpJe9siUMg4bcn9jHEZB8=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcXEZvNpY1/FDChnfynSpRk9GRsSqJrNzNNK drOKlHeJRiJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW POxEEAC/d5s2IFZhiYjOEyhQ/D63bPgs3XL+TyHJHsqPEJeLrWdPwWw4UpxK64COlzr1MHABmmS jJxHAuQ47Yr0C7HqQvyaS4vrd/vQui5ywNxjfioPrpkmx3IHvfx5ntAt71Vy4AhzTy+45yCrb7r /AhI5WeKODAkwgLwWeBTIVTVbbi1psdtLDX1ztHd5bupFpsmZK+jcEzvVIafqorQe3oLMusQ/Hs slqWA6anXCSupeAjto6p4fsfyiOuqsFX/UKN5LAF2EPMqLmlyEFXuSmNVuKipu8IjnCXczR3tc9 ijazg43K1YKcbBJ7bKAVXuQFlAQqEgIJMA5RnOsniohBHt9nEuB3B4/Eksl1uaYOjpgt88V0B0q ZmhB/EpduEmZc3sCDYVkuVfZR96VZAxJBf+AbmwSnKSFQO+PaLtqw8bZrZV/fhG5oDnNe3FczUJ zK60cfe/Q+9/LtZiGgwDuxLbi7+aqPMOdArSUvm+uBY49s3JQoEZF1G2hAtBqp5yvwSRN7bt/D4 X+nLr7N+LA7MmL/67+gWkpj9LlW8ILHx0LYkP4/qWJ6/yt8magDHXbELKLhHxjRFlwg3R15sm1F nnnnmBLn758MsowymXIg1szXz/n4Geqe+U0nRwErd6hh5D15eUmDpB6jUR5hv5K2mXhInhtskxi XgzRRy3pKqzEvQg== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" Add support to Mali C55 pipeline handler for memory-to-memory camera mode. The Mali-C55, as integrated in the Renesas RZ/V2H(P) SoC, is fed with images saved to memory by the CRU unit and read on behalf of the ISP by the IVC. Update the pipeline handler's match() function to search for the CRU media entity necessary to register a memory input camera. Create and initialize a CameraData instance for the memory camera use case if a valid CRU is found and initialize the IVC components used to feed the ISP with images read from memory. Do not implement camera configuration for the time being to reuce the patch size. It will be provided in the following patches. Signed-off-by: Daniel Scally Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 154 +++++++++++++++++++++++---- 1 file changed, 136 insertions(+), 18 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 26dfd0aef73c..d17b026db119 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -44,6 +44,8 @@ #include "libcamera/internal/v4l2_subdevice.h" #include "libcamera/internal/v4l2_videodevice.h" +#include "rzg2l-cru.h" + namespace { bool isFormatRaw(const libcamera::PixelFormat &pixFmt) @@ -105,7 +107,12 @@ public: std::unique_ptr csi2_; std::unique_ptr sensor_; }; - using CameraType = std::variant; + + struct Memory { + std::unique_ptr cru_; + }; + + using CameraType = std::variant; MaliC55CameraData(PipelineHandler *pipe) : Camera::Private(pipe) @@ -116,6 +123,7 @@ public: Tpg *initTpg(MediaEntity *entity); Inline *initInline(MediaEntity *entity); + Memory *initMemory(MediaDevice *cruMedia); std::vector sizes(unsigned int mbusCode) const { @@ -125,7 +133,10 @@ public: }, [&](const Inline &in) -> std::vector { return in.sensor_->sizes(mbusCode); - } + }, + [&](const Memory &mem) -> std::vector { + return mem.cru_->sizes(); + }, }, input_); } @@ -138,6 +149,9 @@ public: [&](const Inline &in) -> V4L2Subdevice * { return in.sensor_->device(); }, + [&](const Memory &mem) -> V4L2Subdevice * { + return mem.cru_->sensor()->device(); + }, }, input_); } @@ -151,6 +165,9 @@ public: [&](const Inline &in) -> CameraSensor * { return in.sensor_.get(); }, + [&](const Memory &mem) -> CameraSensor * { + return mem.cru_->sensor(); + }, }, input_); } @@ -163,6 +180,9 @@ public: [&](const Inline &in) -> Size { return in.sensor_->resolution(); }, + [&](const Memory &mem) -> Size { + return mem.cru_->resolution(); + }, }, input_); } @@ -241,6 +261,19 @@ MaliC55CameraData::Inline *MaliC55CameraData::initInline(MediaEntity *sensor) return &input_.emplace(std::move(in)); } +MaliC55CameraData::Memory *MaliC55CameraData::initMemory(MediaDevice *cruMedia) +{ + Memory mem; + + mem.cru_ = std::make_unique(); + + int ret = mem.cru_->init(cruMedia); + if (ret) + return nullptr; + + return &input_.emplace(std::move(mem)); +} + std::vector MaliC55CameraData::Tpg::sizes(unsigned int mbusCode) const { V4L2Subdevice::Formats formats = sd_->formats(0); @@ -721,11 +754,15 @@ private: const std::string &name); bool registerTPGCamera(MediaLink *link); bool registerSensorCamera(MediaLink *link); + bool registerMemoryInputCamera(MediaLink *link); std::shared_ptr media_; + std::shared_ptr cruMedia_; std::unique_ptr isp_; std::unique_ptr stats_; std::unique_ptr params_; + std::unique_ptr ivcSd_; + std::unique_ptr ivc_; std::vector> statsBuffers_; std::queue availableStatsBuffers_; @@ -976,6 +1013,9 @@ int PipelineHandlerMaliC55::configure(Camera *camera, const MediaEntity *csi2Entity = in.csi2_->entity(); return csi2Entity->getPadByIndex(1)->links()[0]->setEnabled(true); }, + [](MaliC55CameraData::Memory &) { + return 0; + }, }, data->input_); if (ret) return ret; @@ -1001,6 +1041,9 @@ int PipelineHandlerMaliC55::configure(Camera *camera, return in.csi2_->getFormat(1, &subdevFormat); }, + [](MaliC55CameraData::Memory &) { + return 0; + }, }, data->input_); if (ret) return ret; @@ -1673,6 +1716,66 @@ bool PipelineHandlerMaliC55::registerSensorCamera(MediaLink *ispLink) return true; } +bool PipelineHandlerMaliC55::registerMemoryInputCamera(MediaLink *link) +{ + /* + * Errors are not fatal at this point, return true and just skip + * registering a camera for this media link. + */ + const std::string &name = link->source()->entity()->name(); + if (name != "rzv2h ivc block") { + LOG(MaliC55, Warning) << "Unsupported direct connection to " + << link->source()->entity()->name(); + return true; + } + + if (!cruMedia_) { + LOG(MaliC55, Warning) << "Unable to find CRU for memory input"; + return true; + } + + /* + * From now on, errors should be reported up as we have the components + * we need to support memory-to-memory and if we fail something has + * to be fixed. + */ + + ivcSd_ = V4L2Subdevice::fromEntityName(media_.get(), + "rzv2h ivc block"); + if (!ivcSd_ || ivcSd_->open() < 0) + return false; + + ivc_ = V4L2VideoDevice::fromEntityName(media_.get(), + "rzv2h-ivc"); + if (!ivc_ || ivc_->open() < 0) + return false; + + std::unique_ptr data = + std::make_unique(this); + + auto *mem = data->initMemory(cruMedia_.get()); + if (!mem) + return false; + + CameraSensor *sensor = data->sensor(); + data->properties_ = sensor->properties(); + + const CameraSensorProperties::SensorDelays &delays = sensor->sensorDelays(); + std::unordered_map params = { + { V4L2_CID_ANALOGUE_GAIN, { delays.gainDelay, false } }, + { V4L2_CID_EXPOSURE, { delays.exposureDelay, false } }, + }; + + data->delayedCtrls_ = + std::make_unique(sensor->device(), params); + isp_->frameStart.connect(data->delayedCtrls_.get(), + &DelayedControls::applyControls); + + ivc_->bufferReady.connect(mem->cru_.get(), &RZG2LCRU::returnBuffer); + + return registerMaliCamera(std::move(data), sensor->device()->entity()->name()); +} + bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) { const MediaPad *ispSink; @@ -1682,14 +1785,14 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) * The TPG and the downscale pipe are both optional blocks and may not * be fitted. */ - DeviceMatch dm("mali-c55"); - dm.add("mali-c55 isp"); - dm.add("mali-c55 resizer fr"); - dm.add("mali-c55 fr"); - dm.add("mali-c55 3a stats"); - dm.add("mali-c55 3a params"); - - media_ = acquireMediaDevice(enumerator, dm); + DeviceMatch c55Dm("mali-c55"); + c55Dm.add("mali-c55 isp"); + c55Dm.add("mali-c55 resizer fr"); + c55Dm.add("mali-c55 fr"); + c55Dm.add("mali-c55 3a stats"); + c55Dm.add("mali-c55 3a params"); + + media_ = acquireMediaDevice(enumerator, c55Dm); if (!media_) return false; @@ -1749,6 +1852,25 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) stats_->bufferReady.connect(this, &PipelineHandlerMaliC55::statsBufferReady); params_->bufferReady.connect(this, &PipelineHandlerMaliC55::paramsBufferReady); + /* + * We also need to search for the rzg2l-cru CSI-2 receiver. If we find + * that then we need to work in memory input mode instead of the inline + * mode. The absence of this match is not necessarily a failure at this + * point...it depends on the media links that we investigate momentarily. + * + * This is a bit hacky, because there could be multiple of these media + * devices and we're just taking the first. We need modular pipelines to + * properly solve the issue. + */ + static const std::regex cruCsi2Regex("csi-[0-9a-f]{8}.csi2"); + static const std::regex cruIpRegex("cru-ip-[0-9a-f]{8}.cru[0-9]"); + + DeviceMatch cruDm("rzg2l_cru"); + cruDm.add(cruCsi2Regex); + cruDm.add(cruIpRegex); + cruDm.add("CRU output"); + cruMedia_ = acquireMediaDevice(enumerator, cruDm); + ispSink = isp_->entity()->getPadByIndex(0); if (!ispSink || ispSink->links().empty()) { LOG(MaliC55, Error) << "ISP sink pad error"; @@ -1762,13 +1884,6 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) * MEDIA_ENT_F_CAM_SENSOR - The test pattern generator * MEDIA_ENT_F_VID_IF_BRIDGE - A CSI-2 receiver * MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER - An input device - * - * The last one will be unsupported for now. The TPG is relatively easy, - * we just register a Camera for it. If we have a CSI-2 receiver we need - * to check its sink pad and register Cameras for anything connected to - * it (probably...there are some complex situations in which that might - * not be true but let's pretend they don't exist until we come across - * them) */ bool registered; for (MediaLink *link : ispSink->links()) { @@ -1788,7 +1903,10 @@ bool PipelineHandlerMaliC55::match(DeviceEnumerator *enumerator) break; case MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER: - LOG(MaliC55, Warning) << "Memory input not yet supported"; + registered = registerMemoryInputCamera(link); + if (!registered) + return registered; + break; default: LOG(MaliC55, Error) << "Unsupported entity function"; From patchwork Wed Apr 1 16:25:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26411 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 0BC19C32F7 for ; Wed, 1 Apr 2026 16:26:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B4CB62D66; Wed, 1 Apr 2026 18:26:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ExGprCHj"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 75B4062D68 for ; Wed, 1 Apr 2026 18:26:02 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 17F11CE7; Wed, 1 Apr 2026 18:24:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060679; bh=TM7VmBjE8vfgc8t0dcQuhc3P87EZAMjVVw3CwS12mcg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ExGprCHjn/uQcLiRDE4RdjPGPhR81WechKIaBoVvtUnwtbjPHAzQqprdko7u+diVd jIKlwqHUog7Yx98QXLODnZPAkv48zPEqgwe4sErgvrUrK5oQNcYZ6x6Jes9m8ixqU1 d72lSbXixni5rap/IuM9YmNHOyjJhtIMOeiOp+Pw= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:54 +0200 Subject: [PATCH v8 5/8] libcamera: mali-c55: Configure camera in memory-to-memory MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-5-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1848; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=TM7VmBjE8vfgc8t0dcQuhc3P87EZAMjVVw3CwS12mcg=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcXC70mmk7KEOOIT+tt8EZNccSq4xRuaIrw8 ljBaWDR6eKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW PCmRD/9Ef0R+WeKcoI9l1e3Nfh1wCN0knlgqprsk4o4hU5cnkSHGnxpjV6Wz+2IG+D0XSaYuy/b DGGaJ0RoGYS337O4pmKyLWwYnlL/5qthDfweDGbdPOcof31omL/Ih2pAMsxTWq1g7h6RcZoW/E2 YcxPAQLpMeKKXraDxh2uZTVt0j4Y/lmDP2SnOF312MlxU2m6YXY/x2YAeqc+eMfPgmkC8na1kWM KCI8MGkilKbhPIog5csIMYLDReZGdwVkuI0CBn4nRAhp55VKoqRkpxLy4k6Gt6vpaJSrBcDnhc4 BIAfDiX6L8N0IXhN//R0dXNm9Xd1hcimNsktbtzWOD0vGe5fGdp3V8SqP1jQ/hiOGVKaj/X2GLr KjDqgF2nr2pM2SpVsk1QJbOvCZV65fmMWwIr2A1hBZ2KI3M0j/HeNlD+TkR5RYSacCDNLesnP+2 1MDGSBzb2i1VSXFZnCJuJRbkmqYxNUktFhGdNZ5pAkHMy9KtV9SXszC7e2movKaTJoqpT32lKTb KP3GbpzJB2MrjtbpWmG4XS7BpU5Skndrk7imx4ROHObE3adjCNW0op6IXctHV/BH0s8/7Qurqam AkO6L3ZoHWNJFkgTdV95DfD0ntRJubV1tc/Pu1gTevjXzgh7WPnHH4v6kCGZiVK30CEA0RKXT4e XE6WUTI1h0WoVgA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" Add support for memory-to-memory Camera to the PipelineHandlerMaliC55::configure() function. Start by enabling the IVC links, then configure the CRU and propagate the format to the IVC. Signed-off-by: Jacopo Mondi Reviewed-by: Barnabás Pőcze --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index d17b026db119..566fa0549675 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -1013,8 +1013,9 @@ int PipelineHandlerMaliC55::configure(Camera *camera, const MediaEntity *csi2Entity = in.csi2_->entity(); return csi2Entity->getPadByIndex(1)->links()[0]->setEnabled(true); }, - [](MaliC55CameraData::Memory &) { - return 0; + [&](MaliC55CameraData::Memory &) { + const MediaEntity *ivcEntity = ivcSd_->entity(); + return ivcEntity->getPadByIndex(1)->links()[0]->setEnabled(true); }, }, data->input_); if (ret) @@ -1041,8 +1042,23 @@ int PipelineHandlerMaliC55::configure(Camera *camera, return in.csi2_->getFormat(1, &subdevFormat); }, - [](MaliC55CameraData::Memory &) { - return 0; + [&](MaliC55CameraData::Memory &mem) { + V4L2DeviceFormat inputFormat; + + int r = mem.cru_->configure(&subdevFormat, &inputFormat); + if (r) + return r; + + /* Propagate the CRU format to the IVC input. */ + r = ivcSd_->setFormat(0, &subdevFormat); + if (r) + return r; + + r = ivcSd_->getFormat(1, &subdevFormat); + if (r) + return r; + + return ivc_->setFormat(&inputFormat); }, }, data->input_); if (ret) From patchwork Wed Apr 1 16:25:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26413 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 E05F9C32F8 for ; Wed, 1 Apr 2026 16:26:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 25ECF62D79; Wed, 1 Apr 2026 18:26:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oZzkdZRT"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B1F5C62D58 for ; Wed, 1 Apr 2026 18:26:02 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 673561B0C; Wed, 1 Apr 2026 18:24:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060679; bh=L5j9uJQPSeneKNWyQ0HTWyYejmERbJhTNJMOPIbNeFY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oZzkdZRTQDHM3He3cqUd4O9Mk3WFsy1ECfDSwKVP6Z+35wY5NB8who+k+zFET7dr9 Gm0G4nbwu7srn80DGtzPH1cFBAV0NHKu/P4CryIJ6zwYUpdQURwmApNsWLlAt3v0OW bR8FyTJahJBvpfSg+iwOqTRGxtgXOh6gDjMHR6gU= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:55 +0200 Subject: [PATCH v8 6/8] libcamera: mali-c55: Do not rely on bufferCount MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-6-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2258; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=L5j9uJQPSeneKNWyQ0HTWyYejmERbJhTNJMOPIbNeFY=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcXcOJcK4dCB50aYkv8MGTOASvilB6Jdn3nO zqLtcAcUDCJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW PDzREADEhCfnH5cC1t80/Hs/YDYe2NZ+ngKhO3IrdpNsJzte6tzs1VACcW6MJBQo/qd5V3G1DUI zJJG/mB2/IqycGKh/aa2na8AnDspiQbdCVQKNqTjvGDWb6SsBD4OKzg9SYF0f3R4ZckKbTQVrXQ IyFLO3l4XMIDu8WrXQG2SgnmcQAaKR3Z+POLdfggR1WzQu5XhB+f+8nPRgqYNtDcD2BvIIckxN+ NdAOkZd+PzZH+G/F10E5MOLNu2xRVsOFT9n4Ap3fBZ9nGhSPMuk785gIrT1oa4w8Gk8OoA69dyR 0ObiMxk8xktO1vQAmyAGSYFXbcWH5Wa8YquzhtV/Q12PS59HXAf0qWYBMBfisfT6NHiB9yykCq9 zTOQOeE1cwW0ehCuJXeeQhUU2v2naLDGWY7eUNKuwrTJ3FFFsNwIeQeQn6WCChjZZx1Ip0sewX6 0NnP46X99xN8R7u201VanPKumyH0OIiseKE+m8JEJL9y5SC3oY275QynD6T8pUza8211Yz2sLt0 mQ3FlmxzUNjGelMiu1m9z3NdehcB/v6C/HvTL+zAfKUGeQkI/V/fUDeNXgOl6z1RkUlIAB+xRUe A5wGIpwbpz2+JpuYBwUgVvUk/uubCuiUnMe36yB94FVRJ86g0xlRx8DCYchtnsaLeGazW0cYePn 57F+3d2GGIP8Yig== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" Do not rely on bufferCount for the allocation of parameters and stats buffers but add instead kMaliC55BufferCount which is also used to limit the number of in-flight requests supported by the pipeline handler. Signed-off-by: Jacopo Mondi Reviewed-by: Barnabás Pőcze --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 566fa0549675..9df35585fef0 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -48,6 +48,8 @@ namespace { +static constexpr unsigned int kMaliC55BufferCount = 8; + bool isFormatRaw(const libcamera::PixelFormat &pixFmt) { return libcamera::PixelFormatInfo::info(pixFmt).colourEncoding == @@ -778,7 +780,7 @@ private: }; PipelineHandlerMaliC55::PipelineHandlerMaliC55(CameraManager *manager) - : PipelineHandler(manager), dsFitted_(true) + : PipelineHandler(manager, kMaliC55BufferCount), dsFitted_(true) { } @@ -1227,14 +1229,8 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) { MaliC55CameraData *data = cameraData(camera); unsigned int ipaBufferId = 1; - unsigned int bufferCount; int ret; - bufferCount = std::max({ - data->frStream_.configuration().bufferCount, - data->dsStream_.configuration().bufferCount, - }); - auto pushBuffers = [&](const std::vector> &buffers, std::queue &queue, std::vector &ipaBuffers) { @@ -1249,14 +1245,14 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) } }; - ret = stats_->allocateBuffers(bufferCount, &statsBuffers_); + ret = stats_->allocateBuffers(kMaliC55BufferCount, &statsBuffers_); if (ret < 0) return ret; pushBuffers(statsBuffers_, availableStatsBuffers_, data->ipaStatBuffers_); - ret = params_->allocateBuffers(bufferCount, ¶msBuffers_); + ret = params_->allocateBuffers(kMaliC55BufferCount, ¶msBuffers_); if (ret < 0) return ret; From patchwork Wed Apr 1 16:25:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26412 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 880F4C32BB for ; Wed, 1 Apr 2026 16:26:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A67F62D70; Wed, 1 Apr 2026 18:26:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gvd7tDz+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ED6E562D60 for ; Wed, 1 Apr 2026 18:26:02 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B8A9E1E20; Wed, 1 Apr 2026 18:24:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060679; bh=paK7Ba5u2RsF8GusTt3bboJvKePRQi0B4pGcCMBuXck=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gvd7tDz+e3OuaUZBSsaC6VXNdHiorI2TzNqcoyTwJKcmaKvt5vzmHJb5zkbc41qSK SpQvKVaZvqGC+hhoA7TcF5dzt4u2Bum8r4eJIbYWePJ2N5iQjYWVfdrk/FZHARFFbe qOSgQsa6UoE7C4WpvPhsX9Ev7FNvbPnFXPlcztDE= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:56 +0200 Subject: [PATCH v8 7/8] libcamera: mali-c55: Implement capture for memory-to-memory MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-7-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=12694; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=paK7Ba5u2RsF8GusTt3bboJvKePRQi0B4pGcCMBuXck=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcXuior/sCmVjroQr9n5N8PH/4M2qDmveZfs y2IWUoO8UmJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW PMolD/9pNy4T9ly3oGlSDUBq8PHQzI4ni7sUOEbbZZYmLcKmXmxf2uIB+nCJtcBnF/jGm9lmUr/ zaz+vYIhHR3B3Kh8zY+mVuQQQSf9AJhJVqW1yu+ceOGTrhobVMekJtZwvTIbcP487st3nO+36O5 sqGLcDJUJ29nfq9Ubvswshx5QH2s43H9lUSvoXKBmhZfkiHUiUkjl4L9vgKcPFB7bmhu3/r/tpm CeBDCv3EgA9mrpHjNUZ9x+idpcUsP+AiZdB8HbvLSyP0M5CNwr0XKGMfetRxgUyzpe3lqUzAInW YC8grG6nin12FebcoAwpSHQrZbTSXqHVRJ389Iy4sfDePjQXWn/9CgO0FDYePBywtOY7wCERYD3 phLWAINDIoqlOwUQjjhCMP0gOrSdTTidQv2V5X3JZGTB7tWxTHlqJmD3DZEhmDiANpfWEhe2b8F YcPY6pTApNDShAlzZcjjAYpcHkIbtNudGvUPP+1vN+uYbaYQWnz+vLtLCGsBzEvXvNEmlVEkKYg BFEjdmOM4P3amITd5lhNiz2nU/878TKsGf9rt6bi5KN6gU6rbfROm9iYuYwR00aXQffmtCQAbLH mUDHiroFwr0qJ4CcOce3u5doM05sJImaX1gXHw+LhmswbkN8LPWhnDt8vELfT3L1YcupucTUlsa otTA76XabV+g6yA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" Plumb in the MaliC55 pipeline handler support for capturing frames from memory using the CRU. Introduce a data flow which uses the CRU to feed the ISP through the IVC. In detail: - push incoming request to a pending queue until a buffer from the CRU is available - delay the call to ipa_->fillParams() to the CRU buffer ready event - once the IPA has computed parameters feed the ISP through the IVC with buffers from the CRU, params and statistics - Handle completion of in-flight requests: in m2m mode buffers are queued earlier to the ISP capture devices. If the camera is stopped these buffers are returned earlier in error state: complete the Request bypassing the IPA operations - As cancelled Requests might now be completed earlier then IPA events, modify the IPA event handler to ignore Requests that have been completed already Signed-off-by: Daniel Scally Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 212 ++++++++++++++++++++++----- 1 file changed, 174 insertions(+), 38 deletions(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index 9df35585fef0..a78ffc21c808 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -90,6 +91,7 @@ struct MaliC55FrameInfo { FrameBuffer *paramBuffer; FrameBuffer *statBuffer; + FrameBuffer *rawBuffer; bool paramsDone; bool statsDone; @@ -693,6 +695,7 @@ public: void imageBufferReady(FrameBuffer *buffer); void paramsBufferReady(FrameBuffer *buffer); void statsBufferReady(FrameBuffer *buffer); + void cruBufferReady(FrameBuffer *buffer); void paramsComputed(unsigned int requestId, uint32_t bytesused); void statsProcessed(unsigned int requestId, const ControlList &metadata); @@ -741,7 +744,7 @@ private: MaliC55FrameInfo *findFrameInfo(FrameBuffer *buffer); MaliC55FrameInfo *findFrameInfo(Request *request); - void tryComplete(MaliC55FrameInfo *info); + void tryComplete(MaliC55FrameInfo *info, bool cancelled = false); int configureRawStream(MaliC55CameraData *data, const StreamConfiguration &config, @@ -750,6 +753,9 @@ private: const StreamConfiguration &config, V4L2SubdeviceFormat &subdevFormat); + MaliC55FrameInfo *prepareFrameInfo(Request *request); + void queueRequestToCru(MaliC55CameraData *data, Request *request); + void applyScalerCrop(Camera *camera, const ControlList &controls); bool registerMaliCamera(std::unique_ptr data, @@ -1222,6 +1228,13 @@ void PipelineHandlerMaliC55::freeBuffers(Camera *camera) if (params_->releaseBuffers()) LOG(MaliC55, Error) << "Failed to release params buffers"; + if (auto *mem = std::get_if(&data->input_)) { + if (ivc_->releaseBuffers()) + LOG(MaliC55, Error) << "Failed to release input buffers"; + if (mem->cru_->freeBuffers()) + LOG(MaliC55, Error) << "Failed to release CRU buffers"; + } + return; } @@ -1245,6 +1258,12 @@ int PipelineHandlerMaliC55::allocateBuffers(Camera *camera) } }; + if (std::holds_alternative(data->input_)) { + ret = ivc_->importBuffers(kMaliC55BufferCount); + if (ret < 0) + return ret; + } + ret = stats_->allocateBuffers(kMaliC55BufferCount, &statsBuffers_); if (ret < 0) return ret; @@ -1276,6 +1295,24 @@ int PipelineHandlerMaliC55::start(Camera *camera, [[maybe_unused]] const Control if (ret) return ret; + if (auto *mem = std::get_if(&data->input_)) { + ret = mem->cru_->start(kMaliC55BufferCount); + if (ret) { + LOG(MaliC55, Error) + << "Failed to start CRU " << camera->id(); + freeBuffers(camera); + return ret; + } + + ret = ivc_->streamOn(); + if (ret) { + LOG(MaliC55, Error) + << "Failed to start IVC" << camera->id(); + freeBuffers(camera); + return ret; + } + } + if (data->ipa_) { ret = data->ipa_->start(); if (ret) { @@ -1357,6 +1394,11 @@ void PipelineHandlerMaliC55::stopDevice(Camera *camera) isp_->setFrameStartEnabled(false); + if (auto *mem = std::get_if(&data->input_)) { + ivc_->streamOff(); + mem->cru_->stop(); + } + for (MaliC55Pipe &pipe : pipes_) { if (!pipe.stream) continue; @@ -1468,10 +1510,68 @@ void PipelineHandlerMaliC55::applyScalerCrop(Camera *camera, } } +MaliC55FrameInfo *PipelineHandlerMaliC55::prepareFrameInfo(Request *request) +{ + if (availableStatsBuffers_.empty()) { + LOG(MaliC55, Error) << "Stats buffer underrun"; + return nullptr; + } + + if (availableParamsBuffers_.empty()) { + LOG(MaliC55, Error) << "Params buffer underrun"; + return nullptr; + } + + MaliC55FrameInfo &frameInfo = frameInfoMap_[request->sequence()]; + frameInfo.request = request; + frameInfo.statBuffer = availableStatsBuffers_.front(); + availableStatsBuffers_.pop(); + frameInfo.paramBuffer = availableParamsBuffers_.front(); + availableParamsBuffers_.pop(); + + frameInfo.paramsDone = false; + frameInfo.statsDone = false; + + return &frameInfo; +} + +void PipelineHandlerMaliC55::queueRequestToCru(MaliC55CameraData *data, + Request *request) +{ + auto *mem = std::get_if(&data->input_); + ASSERT(mem); + + FrameBuffer *cruBuffer = mem->cru_->queueBuffer(request); + ASSERT(cruBuffer); + + auto frameInfo = prepareFrameInfo(request); + ASSERT(frameInfo); + + frameInfo->rawBuffer = cruBuffer; + + for (auto &[stream, buffer] : request->buffers()) { + MaliC55Pipe *pipe = pipeFromStream(data, stream); + + pipe->cap->queueBuffer(buffer); + } + + data->ipa_->queueRequest(request->sequence(), request->controls()); +} + int PipelineHandlerMaliC55::queueRequestDevice(Camera *camera, Request *request) { MaliC55CameraData *data = cameraData(camera); + /* + * If we're in memory input mode, we need to queue the Request to the + * CRU, otherwise we can just do everything immediately. + */ + if (std::holds_alternative(data->input_)) { + queueRequestToCru(data, request); + + return 0; + } + /* Do not run the IPA if the TPG is in use. */ if (!data->ipa_) { MaliC55FrameInfo frameInfo; @@ -1492,32 +1592,12 @@ int PipelineHandlerMaliC55::queueRequestDevice(Camera *camera, Request *request) return 0; } - if (availableStatsBuffers_.empty()) { - LOG(MaliC55, Error) << "Stats buffer underrun"; - return -ENOENT; - } - - if (availableParamsBuffers_.empty()) { - LOG(MaliC55, Error) << "Params buffer underrun"; - return -ENOENT; - } - - MaliC55FrameInfo frameInfo; - frameInfo.request = request; - - frameInfo.statBuffer = availableStatsBuffers_.front(); - availableStatsBuffers_.pop(); - frameInfo.paramBuffer = availableParamsBuffers_.front(); - availableParamsBuffers_.pop(); - - frameInfo.paramsDone = false; - frameInfo.statsDone = false; - - frameInfoMap_[request->sequence()] = frameInfo; + auto frameInfo = prepareFrameInfo(request); + ASSERT(frameInfo); data->ipa_->queueRequest(request->sequence(), request->controls()); data->ipa_->fillParams(request->sequence(), - frameInfo.paramBuffer->cookie()); + frameInfo->paramBuffer->cookie()); return 0; } @@ -1536,18 +1616,21 @@ MaliC55FrameInfo *PipelineHandlerMaliC55::findFrameInfo(FrameBuffer *buffer) { for (auto &[sequence, info] : frameInfoMap_) { if (info.paramBuffer == buffer || - info.statBuffer == buffer) + info.statBuffer == buffer || + info.rawBuffer == buffer) return &info; } return nullptr; } -void PipelineHandlerMaliC55::tryComplete(MaliC55FrameInfo *info) +void PipelineHandlerMaliC55::tryComplete(MaliC55FrameInfo *info, bool cancelled) { - if (!info->paramsDone) - return; - if (!info->statsDone) + /* + * If the buffer has been cancelled, we complete the request without + * waiting for the IPA. + */ + if (!cancelled && (!info->paramsDone || !info->statsDone)) return; Request *request = info->request; @@ -1571,13 +1654,15 @@ void PipelineHandlerMaliC55::imageBufferReady(FrameBuffer *buffer) ASSERT(info); if (completeBuffer(request, buffer)) - tryComplete(info); + tryComplete(info, + buffer->metadata().status == FrameMetadata::FrameCancelled); } void PipelineHandlerMaliC55::paramsBufferReady(FrameBuffer *buffer) { MaliC55FrameInfo *info = findFrameInfo(buffer); - ASSERT(info); + if (!info) + return; info->paramsDone = true; @@ -1587,7 +1672,8 @@ void PipelineHandlerMaliC55::paramsBufferReady(FrameBuffer *buffer) void PipelineHandlerMaliC55::statsBufferReady(FrameBuffer *buffer) { MaliC55FrameInfo *info = findFrameInfo(buffer); - ASSERT(info); + if (!info) + return; Request *request = info->request; MaliC55CameraData *data = cameraData(request->_d()->camera()); @@ -1598,32 +1684,79 @@ void PipelineHandlerMaliC55::statsBufferReady(FrameBuffer *buffer) sensorControls); } +void PipelineHandlerMaliC55::cruBufferReady(FrameBuffer *buffer) +{ + /* + * If the buffer has been cancelled, do not ask the IPA to prepare + * parameters. + * + * The Request this cancelled buffer belongs to will be handled by + * imageBufferReady() as we have queued buffers to the ISP capture + * devices at the same time we have queued this buffer to the CRU + * when running in m2m mode. + */ + if (buffer->metadata().status == FrameMetadata::FrameCancelled) + return; + + MaliC55FrameInfo *info = findFrameInfo(buffer); + ASSERT(info); + + Request *request = info->request; + request->_d()->metadata().set(controls::SensorTimestamp, + buffer->metadata().timestamp); + + MaliC55CameraData *data = cameraData(request->_d()->camera()); + data->ipa_->fillParams(request->sequence(), info->paramBuffer->cookie()); +} + void PipelineHandlerMaliC55::paramsComputed(unsigned int requestId, uint32_t bytesused) { - MaliC55FrameInfo &frameInfo = frameInfoMap_[requestId]; + auto it = frameInfoMap_.find(requestId); + if (it == frameInfoMap_.end()) + return; + + MaliC55FrameInfo &frameInfo = it->second; Request *request = frameInfo.request; + if (!request) + return; + MaliC55CameraData *data = cameraData(request->_d()->camera()); /* * Queue buffers for stats and params, then queue buffers to the capture - * video devices. + * video devices if we're running in Inline mode or with the TPG. + * + * If we're running in M2M buffers have been queued to the capture + * devices at queueRequestToCru() time and here we only have to queue + * buffers to the IVC input to start a transfer. */ frameInfo.paramBuffer->_d()->metadata().planes()[0].bytesused = bytesused; params_->queueBuffer(frameInfo.paramBuffer); stats_->queueBuffer(frameInfo.statBuffer); - for (auto &[stream, buffer] : request->buffers()) { - MaliC55Pipe *pipe = pipeFromStream(data, stream); + if (!std::holds_alternative(data->input_)) { + for (auto &[stream, buffer] : request->buffers()) { + MaliC55Pipe *pipe = pipeFromStream(data, stream); - pipe->cap->queueBuffer(buffer); + pipe->cap->queueBuffer(buffer); + } + } else { + ivc_->queueBuffer(frameInfo.rawBuffer); + frameInfo.rawBuffer = nullptr; } } void PipelineHandlerMaliC55::statsProcessed(unsigned int requestId, const ControlList &metadata) { - MaliC55FrameInfo &frameInfo = frameInfoMap_[requestId]; + auto it = frameInfoMap_.find(requestId); + if (it == frameInfoMap_.end()) + return; + + MaliC55FrameInfo &frameInfo = it->second; + if (!frameInfo.request) + return; frameInfo.statsDone = true; frameInfo.request->_d()->metadata().merge(metadata); @@ -1785,6 +1918,9 @@ bool PipelineHandlerMaliC55::registerMemoryInputCamera(MediaLink *link) ivc_->bufferReady.connect(mem->cru_.get(), &RZG2LCRU::returnBuffer); + V4L2VideoDevice *cruOutput = mem->cru_->output(); + cruOutput->bufferReady.connect(this, &PipelineHandlerMaliC55::cruBufferReady); + return registerMaliCamera(std::move(data), sensor->device()->entity()->name()); } From patchwork Wed Apr 1 16:25:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 26414 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 5C776C32F9 for ; Wed, 1 Apr 2026 16:26:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5A0662D76; Wed, 1 Apr 2026 18:26:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nJhH43Qo"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4765E62D66 for ; Wed, 1 Apr 2026 18:26:03 +0200 (CEST) Received: from [100.93.44.16] (net-93-65-100-155.cust.vodafonedsl.it [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 194CFF04; Wed, 1 Apr 2026 18:24:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1775060680; bh=KqKprtini/35wm23jEEMQd4FCaoFI/KUjFpUo2GXVn4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nJhH43Qo3NqTq7N5PDslZk5/YlB2j2YlQT0NAg3uCwXmchhRYo//WdiFtYSC4NBib 84brX33wAxtoQAp3mEzh9z6WZ+KDI8O4aDsNojoxnEwAYF1FFeQQo3JFg5e8BIu3J1 JSq1S02GcLKFpqT1pfS4xgFuY32YKh+xfZGBh3BU= From: Jacopo Mondi Date: Wed, 01 Apr 2026 18:25:57 +0200 Subject: [PATCH v8 8/8] libcamera: mali-c55: Fix sensor size computation MIME-Version: 1.0 Message-Id: <20260401-mali-cru-v8-8-44c48f990e28@ideasonboard.com> References: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> In-Reply-To: <20260401-mali-cru-v8-0-44c48f990e28@ideasonboard.com> To: Daniel Scally , libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1117; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=KqKprtini/35wm23jEEMQd4FCaoFI/KUjFpUo2GXVn4=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBpzUcXPJAJ0NEj9SgacQmm+ZaNpoj4UtECTiG2I if7QUddKHKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCac1HFwAKCRByNAaPFqFW PL9rD/9N+tHRSt96G4godhc8ycAFi5rIpj7VVjs1Hdg1IFpgcyVu/BbchL6RvZ/fXIMjCGW8vAH DswBbgo2/WdTOHyIwgsmLUCW+NkGRSJA8sN6p9OFBwXCa/LHY35kmhIb/Xq9Tw4Jxe/F7ESPS6x DEpUMLKyo1JiIIl428a+I+TuHf/AFZJNILVrDrPlZSMSq/pa0PVJla6jdGpb8hln5g+FhW2BQf6 uk1sUiuiKZyD2SQaqObDemV6cHBGs39srr1K+eC7Tj1D4nz+pP6ZsrsRlM7Wr6pYoYo/LE2fToe Yq+I3jlbnlHpjGq6tgEaSF4taTNXgpiLtJFSQLfPaKIvJJD8QXIEjGRLOg2IfXX79oZp46XiCnJ tDI6iCuw6SlvsuhJ9iFU+9LrXPN7b72Bwij7tlpt3kd+YMcVqZyXvTQxwiX/iVYL2pMbTAQPSQi tBU4M15IA9FVhHg+Ed0Hdzr9HL+gBeQQG0v30ooicf7xYkyIL8ixdZXoz5UldDcmxw1XOrpJ/Rm Gb1/wdX6mn8n5RZ9ffDV/Dh33ANNmuTWeP2wZ+9VfY/pDnndLgYiGAEH8NhWuMSHOpXyMuVkwyy GoYWgIEY8cu96JFzcggXLYK6CfkQDdcqJD9J1Aiu93Icy2TigDKv80WfI18G2b1cCR4GyKff0ki tDWPvjdhdON9dPA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" The last size in the list is always selected unconditionally because the current best distance is not updated properly during the search. Fix the size computation procedure which has an inverted assignment. Signed-off-by: Jacopo Mondi Reviewed-by: Daniel Scally Tested-by: Daniel Scally Reviewed-by: Barnabás Pőcze --- src/libcamera/pipeline/mali-c55/mali-c55.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp index a78ffc21c808..0aa4d5e1780b 100644 --- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp +++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp @@ -662,7 +662,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate() std::abs(static_cast(minSensorSize.height) - static_cast(size.height)); if (dist < distance) { - dist = distance; + distance = dist; bestSize = size; } }