From patchwork Fri Dec 12 10:23:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 25546 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 8A7F3C326B for ; Fri, 12 Dec 2025 10:34:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C832A61664; Fri, 12 Dec 2025 11:34:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iq8uptHD"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B49AD61645 for ; Fri, 12 Dec 2025 11:34:14 +0100 (CET) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4779aa4f928so12448525e9.1 for ; Fri, 12 Dec 2025 02:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1765535654; x=1766140454; 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=rHmpk8rHk/IlsYU76ryoqPKQ/4NYcVsL5LSqEDs/vLU=; b=iq8uptHD9jKAP+c3IARobMnxAD9f/gS3puGA34R4e29ZVB+7Kj14u2JMHQuD9riakz ociSFfb/3AS1IdE6/p6CDObhaBM+nfBDtwwKbnSpknN3hh9QdK92a+V2p7bo3LD1L+im uSA7ZiLfhUgIUBr1j8NUEQ1PYYXpWzTs2ur80MdCIFxqBBByRMaDVoPdcqV8HEHGgLVC ZDUGyxCCnB5/0N+wf3LzAnc2jVakZMfimVwerJIm5OSlyBAj5RxNgEupvCYoLJ1tsWqX ZsiZJtRPCXv6U+FZhkU2vDFn9ynO3fkV/aRchIaTujyWyCHaExqSCBX24AMfJ0KeG7pp uCAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765535654; x=1766140454; 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=rHmpk8rHk/IlsYU76ryoqPKQ/4NYcVsL5LSqEDs/vLU=; b=QdrkKZIw5oXD7VTZpY7hQF6RJNXgcgpFPSAT+5OKHJ6dq4T5wQ6D+IJIpKQa0nRhw1 MNwfL/P4Z2Ie5RbLQ/ZbWH9sU9ujy7ReiwPRmPsKetSBZVGdcTawXAVKFYyCOM/yt3wS QhnNRmnXIOv4pMgq4Ung5ySjxe0yIkokC7itxflOgMvhxEWpX5uI6oSTz+HtTQirWP1F vIGIstHyzcD1nCy6udgE49Wg2qyHdyGQ8E/0F0YweLp5GeKUqhD21KYODrh1H+w+5zyT m1RjuznPPiZ9lvPjYiiM/dRv4wai7MxU5Q3YV0AoE1Fg/RtNJXse9UIF1TOEejHB9761 y9Vw== X-Gm-Message-State: AOJu0Yw4wUHbEeyNmEZvWTK23saHVmcd+XLH8ZkMkVyVT8v2iNovPgvg nQUtyJvZixO+xzczXYOn9sVJHZtQ5khnqOQmREUxWlC+aQBja0pycsJkVfVBRPNxZqgsOoom1IQ Fgmxd X-Gm-Gg: AY/fxX4YjyRW40ilnYFO1h+A9PrXN8mW/e8OAlynV/qY93yrAFow9KePBRVOzx7QnQY vVR7GtUJveYAL8hIp5mKBnWgb7wujle9zMHs6LoMJbQfjHjBJATQwefiD+hvr8Haz4UqXafwlNB zNpBtijbeAtm7mUhhf0VTOSiCAkZ3HmK3QXt4aBTDNWRGBbzZ5ofWihXIGBuBj0MkWgGCLlREkL GiJo6r3pWmWy8ZNz+Pj7/p1MTccw6fSYG/Q4QgNiufVjg57oDYOOfPY0JSXWwwqma3BYhhOR9cy qmVOuheL2nS8tOFLzWlGdq4/H2RoHhOBnXjLJsolzGPl5sYJVlWsNxIPsKaYUby8CSaKY3+nbnq rfdDtMwU2I7qvVuTHp6QHtcRoiKFQA+Edxqew8WYgg12DMdwVFJRgMYEbrpGqDCdpH6uvdX+3p+ ed/xXcdQC8LVLOqeEB65Ng7Rwk38CzPwkwLWfgNNmEXdpaqZcysm8b7DLDooZrHKVVeWBsuIfO+ aO55ZU6kE/Kh9Va+g5/L7t1Jg== X-Google-Smtp-Source: AGHT+IGUmx+gGkMacnKbNrvEjBGk+ngEmge+pTwrEJByYsjGXIBzrj83XTtjPmD1k/1gentPdm1/Xw== X-Received: by 2002:a05:600c:828d:b0:45b:7d77:b592 with SMTP id 5b1f17b1804b1-47a8f8c05e7mr17785315e9.12.1765535653913; Fri, 12 Dec 2025 02:34:13 -0800 (PST) Received: from localhost.localdomain ([2a06:61c0:f337:0:9c1f:b517:931a:3b19]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8a7044csm12232495f8f.15.2025.12.12.02.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 02:34:11 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Cc: Peter Bailey , David Plowman , Naushir Patuck Subject: [PATCH v3 3/4] ipa: rpi: controller: Ignore algorithms that are not enabled Date: Fri, 12 Dec 2025 10:23:52 +0000 Message-ID: <20251212103401.3776-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251212103401.3776-1-david.plowman@raspberrypi.com> References: <20251212103401.3776-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" From: Peter Bailey Algorithms may now contain an "enabled" field which can be set to false to disable it and prevent it from being loaded. If not present, algorithms are treated as enabled by default for backwards compatability. We additionally prevent duplicate versions of the same algorithm type (such as AWB) from loading, and flag an error. This will prevent undefined behaviour if (for example) two distinct AWB algorithms are trying to run simultaneously. Signed-off-by: Peter Bailey Reviewed-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/rpi/controller/controller.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ipa/rpi/controller/controller.cpp b/src/ipa/rpi/controller/controller.cpp index df45dcd3..88de6f36 100644 --- a/src/ipa/rpi/controller/controller.cpp +++ b/src/ipa/rpi/controller/controller.cpp @@ -145,6 +145,14 @@ int Controller::read(char const *filename) int Controller::createAlgorithm(const std::string &name, const YamlObject ¶ms) { + /* Any algorithm may be disabled by setting "enabled" to false. */ + bool enabled = params["enabled"].get(true); + LOG(RPiController, Debug) + << "Algorithm " << name << ": " + << (enabled ? "enabled" : "disabled"); + if (!enabled) + return 0; + auto it = getAlgorithms().find(name); if (it == getAlgorithms().end()) { LOG(RPiController, Warning) @@ -152,6 +160,16 @@ int Controller::createAlgorithm(const std::string &name, const YamlObject ¶m return 0; } + /* Do not allow duplicate versions of algorithms (e.g. AWB) to run. */ + size_t pos = name.find_last_of('.'); + std::string const &algoType = + pos == std::string::npos ? name : name.substr(pos + 1); + if (getAlgorithm(algoType)) { + LOG(RPiController, Error) + << "Algorithm type '" << algoType << "' already exists"; + return -1; + } + Algorithm *algo = (*it->second)(this); int ret = algo->read(params); if (ret)