From patchwork Fri Dec 9 09:00:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17965 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 9DB55BDE6B for ; Fri, 9 Dec 2022 09:01:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E201363356; Fri, 9 Dec 2022 10:01:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576490; bh=6TPR2QHCOzSmsRgML58GJeHoEheaiRbUfY1Sp25II2M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NEirU1zKsPhFz0yWxm5uXOgIkpfRn/7P9Aq+9Hrv3kgdMH3bxIOcCemumBiNarp4q DSb7643GsdT40QlEFM5ssy9qRfRij9X3nKeVCPkyzlErhqbfcXjuX/ArjQQqbIoIIE 7oHRxo2280rwNRkSzt/jZ1vr+hJ2k74TqO6mITqUp643Beo2jvYv9eDoXp2QKsqcuv kBOpyXu8MaeSrs5e3k+JJOQeMkX1aQvsPZ3+IwTqgnwGJhTY62Y+PYxZQGUjEBvLcA Un+ZPrS6H/UeRPBxzhNuJ/fM168DIs2kzQo4ZykSZ4zahrVNq0qMZxMPzZCMLbd/vb /k53zXufh9hfA== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5D9B561F1E for ; Fri, 9 Dec 2022 10:01:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="aKdXRz0i"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id h8-20020a1c2108000000b003d1efd60b65so5289981wmh.0 for ; Fri, 09 Dec 2022 01:01:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=+2T3ZLVGJwVrydTkz6iNKwj5oO6lQf9kYT88gPluNzs=; b=aKdXRz0iNekVqSnj1JMh6iqn53I32dcR+aAowJgBq30JZuVizyrEw/KPZttRjajyaG d3vjVG3JkgU6M9qfce2Skr4Dn2UP0y2EouQZvu/J4zzXpgvUPAi8ddsZCPbWkxGHymL2 JnKE/BOIKSzi6yLJ1Iw9ZbHEbTr2BL3QlEQu76w94cDpainVxutsrVKVt0N5iWn0YK+5 WnKoln2VNrphXp14j+VLNhkp2cvgzwo+IchNKSdfwhn/MA244+Zz31qlRDiQR8VGT1O3 OfQXiw3AaREG4Tlq7vGC2Qdv/4KXThP327nV3gHptsnvveGEI06iC7rD8wG1tI7FMczU GPAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+2T3ZLVGJwVrydTkz6iNKwj5oO6lQf9kYT88gPluNzs=; b=1XWt3xruI7dDFb1n37G+QykWidA6B4yJcb14vJFzvBUZTI4WZJOdfCNA1utJDv5tyo GPczzfc5q8UT3spbuFrJN/9VUJWGZ5CErxDhG5bkxSI6vWIkvsjFOzPCyemUxEGUOtoW w/in4reH9sMyC6K3+tP6P1Cdu4Of/zfbvOYg9KbhBbYK5uvlfcXPkXeSZwXsWd1a+TZ6 bn6O9uz1YfBj0O5uqpKRjaKStYstPCiTqNWWwO39NOVZBSvW67+q8rV/Chok7ifUDHUF lsZhJbyLbdvtLfJSKV/rjQ5l7waXLnaChqx1DVguYbw+uQYgkX/Tju7DQdysWZ4pSgIg hqDQ== X-Gm-Message-State: ANoB5pmaxgeKBVRSa6KQ1vvWsMkpz9eVpDLYoGJDqt4jkzOhVKvFzlF3 V7mmyCsGT4jHtdOZ1OYQnG2aVt5fEmWbhZbD X-Google-Smtp-Source: AA0mqf7APrhALFxz3tBarLWzO9se3SjrXXYUOBsaxe6mPhOUTsA4rFAsHeFAsOo7lBKctrLPyUaZoQ== X-Received: by 2002:a05:600c:5546:b0:3d1:f6b3:2ce3 with SMTP id iz6-20020a05600c554600b003d1f6b32ce3mr4821034wmb.35.1670576488710; Fri, 09 Dec 2022 01:01:28 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:28 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:39 +0000 Message-Id: <20221209090050.19441-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 01/12] libcamera: stream: Add stream hints to StreamConfiguration 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new hints flags field in the StreamConfiguration structure to allow the application to specify certain intended behavior when driving libcamera. Pipeline handlers are expected to look at these hint flags and may optimise internal operations based on them. Currently, only one flag is listed, MandatoryRequestBuffer, which the application sets to guarantee that a buffer will be provided in the Request for each configured stream. Signed-off-by: Naushir Patuck --- include/libcamera/stream.h | 8 ++++++++ src/libcamera/stream.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 29235ddf0d8a..1c5273004297 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -51,6 +53,12 @@ struct StreamConfiguration { std::optional colorSpace; + enum class Hint { + None = 0, + MandatoryRequestBuffer = (1 << 0), + }; + Flags hints; + Stream *stream() const { return stream_; } void setStream(Stream *stream) { stream_ = stream; } const StreamFormats &formats() const { return formats_; } diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 67f308157fbf..504c6d86cd04 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -349,6 +349,30 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) * color spaces can be supported and in what combinations. */ +/** + * \enum StreamConfiguration::Hint + * \brief List of available hint flags provided by the application for a stream + * + * \var StreamConfiguration::Hint::None + * No hints for this stream. + * \var StreamConfiguration::Hint::MandatoryRequestBuffer + * Informs the pipeline handler that the application guarantee to provide a + * buffer for the configured stream in the Request. This may allow the pipeline + * handler to allocate fewer (or no) buffers for internal use. + */ + +/** + * \var StreamConfiguration::hints + * \brief Application provided StreamConfiguration::Hint flags for specific + * stream behavior + * + * Provides hints from the application to the pipeline handlers on how it + * intends on handling a given configured stream. These hints may alter the + * behavior of the pipeline handlers, for example, by allocating fewer buffers + * for internal use if an application guarantees to always provide a buffer in + * the Request for a stream. + */ + /** * \fn StreamConfiguration::stream() * \brief Retrieve the stream associated with the configuration From patchwork Fri Dec 9 09:00:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17966 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 E6E4CBDE6B for ; Fri, 9 Dec 2022 09:01:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 76DB46335A; Fri, 9 Dec 2022 10:01:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576493; bh=aPx61EyK5426KHTbbJ5ftutp6M7sRBs01qIVaRATqP8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Q1mQ+0s84kxml93hA37Ye5kDN3Vbbb3n16TgH0ugW1Rb8P8OYDM5jfgPw8M5AOtjC n1gqLbyI2gWNhFCY595BEvIt6zwBbdTT1VDkA44o85tg/oicfuTSyuxHYkpLYjUyoX IPS5TGzwSNBR8L6iGamtKk/5VAe6+8AJyVIWETzPGLDyRMKDG0wcggJmzGF7WqABI5 LaixJKH79CJ8j3NFXbbkcW7Wmsmo6T2CIidvwTnJq+DAt+oA5LFwQk9aktbDXjQ3Sq SyO2g+GhUWp9SIHRPq8KUp+8x0j3EvoqtBtvw4VhXejsA0b8mrfIKWxArsnkiGTzGe mZSIE3LL7/rHg== Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D3BB61F1E for ; Fri, 9 Dec 2022 10:01:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fSS9WgmG"; dkim-atps=neutral Received: by mail-wm1-x32d.google.com with SMTP id v124-20020a1cac82000000b003cf7a4ea2caso5258199wme.5 for ; Fri, 09 Dec 2022 01:01:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=gYE4rAs6mWLRRzePAtTOx6PsgAWDmX1Qry7rwDpq1OM=; b=fSS9WgmGx/w2uBE7dksCGM9VWJOUEO0d/LYazmZ2RZH5E/TOoM70o9YRwG2xQCunUR PQtxtXiPFTFvUdsxNbi13uMMN0lQozeO0QArjdLn/G4+wtdtZuVQdsrsg1OkRtSYVvTS fvM3L6g2WVEth9bsC9iuA7/DsJe7v/2lnZvRWzY+H2jlM0qebKS2bEA8utEufa/iCkv7 PD6aU8ajL1prJxIcP0+93XVUpIb4AAmOjnzbbDoeWikRRzkI7Y3GCWNflx/V8cHGWAcQ G2j1oQOQ4rjmVmHf3M/vtlRu4Ue2nwpPTwlDuKeWL4faYksS0yBZE+7kEYie/kIKTVl2 OOYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gYE4rAs6mWLRRzePAtTOx6PsgAWDmX1Qry7rwDpq1OM=; b=ZvAe7CmE2LaRLoH9qKM391sXh1V/zMWFSyrHHbVIZphFZhZyQaCVmamx08H7LViV9u XbbrppTleQPNkq5e38X8PMBQ2LCt1CXmAx2O9NccHdWNsP9qDm0lR3V3rTslXmf9fiAc FbsAc8GX+1ITz4v3hV6oKDzFMlaIv2EnzmdJBPyQ6SI7QbukabhG+rZxrTe8iv6E2xk+ rVhF8X+CDUBpanvLuOkkJgGAWysRQnVpYLgkGKfQ7+dM0IdsrFTzdkCczR8gO3PqzP53 HP8r80aQ28s2x3O46Id7ZuBskkEQ0+PjKf9Y+XdQ4dKdin7B8Z3dsc19NkOdp/aWnTQe 518A== X-Gm-Message-State: ANoB5plyrff5OYbGA/m+MUsiDAe5NND+P+2ys41xcJ8RXCRDhEhSITcK KTaTz7ubbL6DygAU3yravtRb2NdPdUU/sDCa X-Google-Smtp-Source: AA0mqf5c9063c+cCV0nhviTdCoLr9+rXzu9TdP6/8gK0CXvBNAEx6/w28V66vKd+7tMdokN/jl4MAw== X-Received: by 2002:a1c:7316:0:b0:3c6:e60f:3f66 with SMTP id d22-20020a1c7316000000b003c6e60f3f66mr4282831wmb.29.1670576489598; Fri, 09 Dec 2022 01:01:29 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:28 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:40 +0000 Message-Id: <20221209090050.19441-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 02/12] libcamera: pipeline: Add a platform configuration file helper 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new helper function PipelineHandler::configurationFile() that returns the full path of a named configuration file. This configuration file may be read by pipeline handlers for platform specific configuration parameters on initialisation. The mechanism for searching for the configuration file is similar to the IPA configuration file: - In the source tree if libcamera is not installed - Otherwise in standard system locations (etc and share directories). When stored in the source tree, configuration files shall be located in a 'data' subdirectory of their respective pipeline handler directory. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- include/libcamera/internal/pipeline_handler.h | 3 + src/libcamera/pipeline_handler.cpp | 60 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index ec4f662d7399..4c4dfe62a680 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -65,6 +65,9 @@ public: bool completeBuffer(Request *request, FrameBuffer *buffer); void completeRequest(Request *request); + std::string configurationFile(const std::string &subdir, + const std::string &name) const; + const char *name() const { return name_; } protected: diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index cfade4908118..a515ad5ecffb 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -8,6 +8,7 @@ #include "libcamera/internal/pipeline_handler.h" #include +#include #include #include @@ -534,6 +535,65 @@ void PipelineHandler::completeRequest(Request *request) } } +/** + * \brief Retrieve the absolute path to a platform configuration file + * \param[in] subdir The pipeline handler specific subdirectory name + * \param[in] name The configuration file name + * + * This function locates a named platform configuration file and returns + * its absolute path to the pipeline handler. It searches the following + * directories, in order: + * + * - If libcamera is not installed, the src/libcamera/pipeline//data/ + * directory within the source tree ; otherwise + * - The system data (share/libcamera/pipeline/) directory. + * + * The system directories are not searched if libcamera is not installed. + * + * \return The full path to the pipeline handler configuration file, or an empty + * string if no configuration file can be found + */ +std::string PipelineHandler::configurationFile(const std::string &subdir, + const std::string &name) const +{ + std::string confPath; + struct stat statbuf; + int ret; + + std::string root = utils::libcameraSourcePath(); + if (!root.empty()) { + /* + * When libcamera is used before it is installed, load + * configuration files from the source directory. The + * configuration files are then located in the 'data' + * subdirectory of the corresponding pipeline handler. + */ + std::string confDir = root + "src/libcamera/pipeline/"; + confPath = confDir + subdir + "/data/" + name; + + LOG(Pipeline, Info) + << "libcamera is not installed. Loading platform configuration file from '" + << confPath << "'"; + + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } else { + /* Else look in the system locations. */ + confPath = std::string(LIBCAMERA_DATA_DIR) + + "/pipeline/" + subdir + '/' + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + + LOG(Pipeline, Error) + << "Configuration file '" << confPath + << "' not found for pipeline handler '" << PipelineHandler::name() << "'"; + + return std::string(); +} + /** * \brief Register a camera to the camera manager and pipeline handler * \param[in] camera The camera to be added From patchwork Fri Dec 9 09:00:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17967 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 CA265C3284 for ; Fri, 9 Dec 2022 09:01:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 42EAB63359; Fri, 9 Dec 2022 10:01:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576494; bh=bvVkHJiRMJT6sy5clbtelAObI9I7JqaXleneN4SN/4M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ddnXIX5t/MfnzWjcwbSs0rrE6YTW0+Cy5UBDzzRP0LaSREKFmX81toK2b8Lor/Wey fMUUeN7k4yARUMF4bXIalhOx4He3zE5f3UnV6a1kI0SeX5em7C9o3wUMWNEvnMNg6G K8zO8a2BTwoJSlThTzms8M0/7Wo8U0j7tx6H8/qLuEXEWPvksQt8NBxQO92LixdZ8X nkDQGeAD5eSmJum011g39Ezz3qSEr1X8lbM8ABeiuldMRLLOsSrMRwJd4LCaASFdV0 RhFrs1Fx1u970LzXD65t8jvB3NhGihJDwoPVW1BomTwkEbbKU47oGUlmTI7Ov7L/rD OhdSTZPnuWc7w== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CB1063354 for ; Fri, 9 Dec 2022 10:01:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="r39S8mml"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so5275995wma.1 for ; Fri, 09 Dec 2022 01:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=zdIqKZFO5XnrvS7lzwMoLcIDnFJDKdJhRwo2YCjQSZo=; b=r39S8mmlRUgKRTOIJVAPHd/sDSbc/whV+N0tC6dj+hcUelaz2bvMAjGCaKFOBM8L2x JIwOkzYutnoofudStvpm8OHrrt+m4d7gRc8lQcvcGR8AahwQ5Vj0m9f1Uj6WvpC8dltf B5sPeCA5+fr7K6oZZ6HaYBG9KbIAmoDvGw/QVQsNqqn9gUrMQfpotTubY3wglofTBiO5 PQnSBxRA8ujykFDCy4YS/s2XT/nCpktrBnuFk5g4L0+y7pahC2wAdy/bBzUgtFNJwF8J X1rkIOa8rwE3dQjpMBDdIwa8KTjyMVfbHqHSPcSmXV6IaU1cq0Ropb84/1KZ/KL9I5G7 2Wyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdIqKZFO5XnrvS7lzwMoLcIDnFJDKdJhRwo2YCjQSZo=; b=6UhKxnnr/yUVoXP6vwbdjKMxQiLsA+CXk6QN/LoZS7zsRo+xqscx4MZpsvt9ywdJp6 AslrY12590DSAlBN1E0sN5o75A9gUdVsDKIP+P0LaPA2GTDuJmuPcT9/XVfsJwgCJpxX gzhAM2zjaTsgmSVj2+yW71TYhbxo3iG9SZWbBpmREO9lbpWDr3nVoGQUD35C8zoelifq gz64wsvLV0jFSqXYNyjG1p+5PFEOLfFFrW3g790yPIYVRf/HZgfKCUGKuL9aglRwdJqx D5Y2gAedYmVkMlfhgByaj/7Io5RJWtEWOE/jlf5SK2/GDSBl32J2Pg043vb6iOXZdeG1 onXw== X-Gm-Message-State: ANoB5plmu7yCZhS2dnhDJDSOB11PbZPECQQs8jrjr55X1X94ZYOgKKTr qeZCW8zfZtkie+WZvicTFcMBoZk3POyDCOq3 X-Google-Smtp-Source: AA0mqf6F3x8ewWvCo7ZkelgAXgz0+3sDagsQT5cf/tZb61aySkvcuwpbBGfeGim3COYONWime86bQQ== X-Received: by 2002:a7b:c30e:0:b0:3c6:e63d:fcf6 with SMTP id k14-20020a7bc30e000000b003c6e63dfcf6mr4345931wmj.29.1670576490551; Fri, 09 Dec 2022 01:01:30 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:29 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:41 +0000 Message-Id: <20221209090050.19441-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 03/12] pipeline: raspberrypi: Add a pipeline config structure 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a configuration structure to store platform specific parameters used by the pipeline handler. Currently, these only store Unicam buffer counts, replacing the hardcoded static values in the source code. In subsequent commits, more parameters will be added to the configuration structure, and parameters will be read in through a config file. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0e0b71945640..f6388d63416b 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -199,6 +199,7 @@ public: int loadIPA(ipa::RPi::IPAInitResult *result); int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result); + int configurePipeline(); void enumerateVideoDevices(MediaLink *link); @@ -294,6 +295,21 @@ public: /* Have internal buffers been allocated? */ bool buffersAllocated_; + struct Config { + /* + * The minimum number of internal buffers to be allocated for + * the Unicam Image stream. + */ + unsigned int minUnicamBuffers; + /* + * The minimum total (internal + external) buffer count used for + * the Unicam Image stream. + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -1377,6 +1393,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me streams.insert(&data->isp_[Isp::Output0]); streams.insert(&data->isp_[Isp::Output1]); + int ret = data->configurePipeline(); + if (ret) { + LOG(RPI, Error) << "Unable to load pipeline handler configuration"; + return ret; + } + /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = @@ -1439,25 +1461,28 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) for (auto const stream : data->streams_) { unsigned int numBuffers; /* - * For Unicam, allocate a minimum of 4 buffers as we want - * to avoid any frame drops. + * For Unicam, allocate a minimum number of buffers for internal + * use as we want to avoid any frame drops. */ - constexpr unsigned int minBuffers = 4; + const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate * additional buffers to make up the minimum, but ensure - * we have at least 2 sets of internal buffers to use to - * minimise frame drops. + * we have at least minUnicamBuffers of internal buffers + * to use to minimise frame drops. */ - numBuffers = std::max(2, minBuffers - numRawBuffers); + numBuffers = std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow * similar logic as above to count all the RAW buffers * available. */ - numBuffers = numRawBuffers + std::max(2, minBuffers - numRawBuffers); + numBuffers = numRawBuffers + + std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* @@ -1630,6 +1655,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA return 0; } +int RPiCameraData::configurePipeline() +{ + config_ = { + .minUnicamBuffers = 2, + .minTotalUnicamBuffers = 4, + }; + + return 0; +} + /* * enumerateVideoDevices() iterates over the Media Controller topology, starting * at the sensor and finishing at Unicam. For each sensor, RPiCameraData stores From patchwork Fri Dec 9 09:00:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17968 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 30574BDE6B for ; Fri, 9 Dec 2022 09:01:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE4F463361; Fri, 9 Dec 2022 10:01:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576495; bh=8HTIPDT/NLnYs2wOJmUDMwsBHq8KUzzKjYDz7CKniHo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bv2/98MrTdBVCh4xAvWBXqVUapPgBkqAb3FFJ0rOFsFykC3kC14W7n8Y6LGdSe4XA zf+hS/jXFn6SP+Ntd/UtVdQKDpaMxxCSlq9E5EflnLIAYasQYlTESyCYwkz6AwoSe8 KjU4XRTYPwSzp4nYJTA26rVdNt/ggo51CSwsW6tgJLnsTKJbLz1dr8XFx+b65pb+gB 2v5f6+R87iU+3HQ9LumJTd2BvQZ+RSzhsQa0oTRdZMVbICfGY4cZoRN3a8+N+7lRCn pVyNe/K4wYRtWF1bG5/7uT7tH4W49tXSWu+FoAUUTNT3xq0WFHDdwDNm7lyaJWmgs4 2U72H8Zs1whaA== 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 EFFA561F1E for ; Fri, 9 Dec 2022 10:01:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gDXNQZK6"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id o15so2728476wmr.4 for ; Fri, 09 Dec 2022 01:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=5Z11VugKNVYk4NrBATUQ29zE9EItJoR8a0aD1H32Zho=; b=gDXNQZK65MuyLFyDHzPTRa01p6gQbkpp+zAlHRxSTqoUYn7VQhOkZjTtJiFhW4VEy6 zumbqzirh68dV0Np5HjrEcPdysI7/OC2PxYoWCDYq2wfE4jPf9UfDmFlEtZc0Lo3nuPU CZXfbdwQrJrvFS2j6QyIdSnjHV4WIPTO8ngTlK6Glh3EnMInXw1K7dF/LeGZQVVPntGH qYVnKNb065IIr/f2K3WAHMdGUn5pezDNgK5HFWBOO+MeedGT/NgkMLkIH8yjDYqAGs6+ +VlAtGBNF8WABAXokSLTI7RtCt+VIVjluzs/uFyTZohplSMJF81OoyUCwQ8VxrTtuaDy A6rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Z11VugKNVYk4NrBATUQ29zE9EItJoR8a0aD1H32Zho=; b=zgxKX2wtc3l/Lj4OjaZD0x1M7NjaUSU/aKWezvxdgzQMXwI4aDTvhplNz23gA8GrEt WWeKnJA16f1kynOEJWhMmlEqn6e/cEc6sLrPww/uERnbEWhDCOO17uc/0dHdaELbHmv7 UKWMR5xfbLVJtllxdHZUFfwi1PzKXfHt9KClM1fEyXIraNEt/O1Mc5hDeHCktZpMHyB3 iA17tWrmd35HEFcW4FwKd/lNFTEWBUFU03Mu19zkfHcoIKv1N30cPuF3X7jmEa5oKA0E BxfqKsyoKk5jXUioIoSOc8+JtkSYyBpK7Aa8if1WVFsJyNwJ6XWbeNCUfwqbk9AhB9B3 6NRA== X-Gm-Message-State: ANoB5pn7PkuZIKtk/bI1EvgOWYuyXXe2QpDhDN+MWw22CxRD7EhipD/u bjF9jE2In82pFtb1M073VzIBJQL/nQo0P0GT X-Google-Smtp-Source: AA0mqf4QQh03oLLkQihaofdDovzXEUycOMPRDae3mIavTJr3oAHe8HZFolwEkyGrQeoEPFfzlZkCSg== X-Received: by 2002:a05:600c:1da3:b0:3d1:ebdf:d58b with SMTP id p35-20020a05600c1da300b003d1ebdfd58bmr4280386wms.5.1670576491408; Fri, 09 Dec 2022 01:01:31 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:30 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:42 +0000 Message-Id: <20221209090050.19441-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 04/12] pipeline: raspberrypi: Reorder startup drop frame initialisation 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Reorder the code such that the IPA requested startup drop frames count is available before the pipeline handler allocates any stream buffers. This will be used in a subsequent change to stop Unicam buffer allocations if there are no startup drop frames required and the application has configured a raw stream and always provides buffers for it. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f6388d63416b..c5a489fc7581 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1036,21 +1036,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) RPiCameraData *data = cameraData(camera); int ret; - for (auto const stream : data->streams_) - stream->resetBuffers(); - - if (!data->buffersAllocated_) { - /* Allocate buffers for internal pipeline usage. */ - ret = prepareBuffers(camera); - if (ret) { - LOG(RPI, Error) << "Failed to allocate buffers"; - data->freeBuffers(); - stop(camera); - return ret; - } - data->buffersAllocated_ = true; - } - /* Check if a ScalerCrop control was specified. */ if (controls) data->applyScalerCrop(*controls); @@ -1067,6 +1052,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) /* Configure the number of dropped frames required on startup. */ data->dropFrameCount_ = startConfig.dropFrameCount; + for (auto const stream : data->streams_) + stream->resetBuffers(); + + if (!data->buffersAllocated_) { + /* Allocate buffers for internal pipeline usage. */ + ret = prepareBuffers(camera); + if (ret) { + LOG(RPI, Error) << "Failed to allocate buffers"; + data->freeBuffers(); + stop(camera); + return ret; + } + data->buffersAllocated_ = true; + } + /* We need to set the dropFrameCount_ before queueing buffers. */ ret = queueAllBuffers(camera); if (ret) { From patchwork Fri Dec 9 09:00:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17969 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 38ADEBDE6B for ; Fri, 9 Dec 2022 09:01:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C4BB463365; Fri, 9 Dec 2022 10:01:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576497; bh=TT8f77VfTo8ZsU6VKEbwskQdfs0h8NsHNAVP1IObN3A=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Gtu68EU+I8O+RCi5ZJVeTH4vhzxIfFM5dfB12/BNndHJxkWQHfp67iRFBQjUoS67j wDIKDEDhG0//ws8N9d4BbcFAwKBX/W/oQPJ5svbOoC/4uMDLVhboa8vwmDMzujBvYV iI6ke1xx9CpHofx8QIQ2ZWGszbJXmg5hmuPHJxDCckjrVHGH6ivAZgubQUxVpsH/hf 8p4+14Mbac9uKDXPIyCFxOA78I4Hek8OslPgnWSoYIhzueuEdsqrAfxhS7dNKKKwv8 uxthOwiUVPfeteaG9asujN7nxt7/zCUtPmLJmoYVfbljwLbC+RLxB3LejnAi35cHYS YBsidFVGYPz4Q== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC7D063351 for ; Fri, 9 Dec 2022 10:01:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jnN0rIhH"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id m4-20020a05600c3b0400b003d1cb516ce0so5261441wms.4 for ; Fri, 09 Dec 2022 01:01:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=piRa1vTJhlTRtSSbS36pBvVbQZnm13Bd6mtMgWMjARU=; b=jnN0rIhH2Z8heL/iBwOqcHiaondBsziGzzjN1wJI4KgC8DHiGxOlGpfwaP9QDd2701 Mb6ubibkKdCmj261Y8/iOhQHGHXOzpC/+9U/yaXkEtBaTsQUo83MYWBHB2s0NU2Xgw4V wxOIttbgCd5c1g4JoQLMIuEHGE4FwxTdmWVQnfclYpIecpB7+fT1ivmh7b1erGnYOMq5 8RzqnEGMEfpIaB/f+npdvMu9KjD+IqLc1RLlAigl22j5wHuko+7rYXxN2aqcz+5kcpTs gpjp5boR6O6B9FutqIc85vEDlCfEFSZVxtKoMVvlY5l6X+Ue9w6y0ItnLGpzArJdaL3b HMpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=piRa1vTJhlTRtSSbS36pBvVbQZnm13Bd6mtMgWMjARU=; b=t+uBqBHlQiex2kljRGYoQpFiNwFJGM3ocV58fx+hxv9SKWFAOcIiUAhHUQbpHghPfS 3zq4cxe/QwLsvjJII13GIHCDcysmX2COY1Y0oyERgYpOkQuqCZ1YCXRrADdLbo/zov6+ jQ26cRvnmQBwGlylMkBcoM0TO6G9GE5Nabh6S76+qpVjzU8B86FYCa5TQFvMSfzPd/Ny I41EE5jWe/TB4mq6Pf3x11ZEvmnCCglN/lHqnGAJk5IevjnK2CYe+bKG5TDej+SOD5vQ uWfzGj3iL7ygIanwHCBYOsdvi1EpZVKzn9auRr9O52doF8JWcrLqUNcRm7F7MU1vIg5t fCDw== X-Gm-Message-State: ANoB5pljSp6VhWNuCF4kCLEf8Gq0GU0f2Akv8XF8Adkxo+lkSeh7c29Y sz5U0S+jvvVl5CTAXNKQ3Yt2g0k+hCsxrPcT X-Google-Smtp-Source: AA0mqf6sVZLMIbxle3FItyBdI6o/1WnZcfUze/UowsAko0aTuFLLhiu/ZhAmh8lAgCCwUsXO//M0Xg== X-Received: by 2002:a05:600c:3b9c:b0:3d1:e710:98ec with SMTP id n28-20020a05600c3b9c00b003d1e71098ecmr5003710wms.21.1670576492195; Fri, 09 Dec 2022 01:01:32 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:31 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:43 +0000 Message-Id: <20221209090050.19441-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 05/12] pipeline: raspberrypi: Handle MandatoryRequestBuffer hints for Unicam Image 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Look for MandatoryRequestBuffer flag in the hints field of the Unicam Image StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for Unicam Image, so override the minUnicamBuffers and minTotalUnicamBuffers config parameters in the following way: - If startup drop frames are required, allocate at least 1 internal buffer. - If no startup drop frames are required, do not allocate any internal buffers. All other buffer allocations remain unchanged. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index c5a489fc7581..8be46962e825 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1447,12 +1447,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) int PipelineHandlerRPi::prepareBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); - unsigned int numRawBuffers = 0; + unsigned int minUnicamBuffers = data->config_.minUnicamBuffers, + minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers, + numRawBuffers = 0; int ret; for (Stream *s : camera->streams()) { - if (isRaw(s->configuration().pixelFormat)) { + if (s == &data->unicam_[Unicam::Image]) { numRawBuffers = s->configuration().bufferCount; + /* + * If the application provides a guarantees that Unicam + * image buffers will always be provided for the RAW stream + * in a Request, we need: + * - at least 1 internal Unicam buffer to handle startup frame drops, + * - no internal Unicam buffers if there are no startup frame drops. + */ + if (s->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1464,7 +1485,6 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * For Unicam, allocate a minimum number of buffers for internal * use as we want to avoid any frame drops. */ - const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate @@ -1472,8 +1492,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * we have at least minUnicamBuffers of internal buffers * to use to minimise frame drops. */ - numBuffers = std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + numBuffers = std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow @@ -1481,15 +1501,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * available. */ numBuffers = numRawBuffers + - std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* * Embedded data buffers are (currently) for internal use, * so allocate the minimum required to avoid frame drops. */ - numBuffers = minBuffers; + numBuffers = data->config_.minTotalUnicamBuffers; } else { /* * Since the ISP runs synchronous with the IPA and requests, From patchwork Fri Dec 9 09:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17970 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 D7349BDE6B for ; Fri, 9 Dec 2022 09:01:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 868B263358; Fri, 9 Dec 2022 10:01:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576499; bh=Xj0bGDCTa+sLhiEEMJUoLKoRyztC8WQjfciY93nch7s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RFgbbr+IPBXadoqR3RgNYCRAm4nNYX3EKLJ+gJM4c5q7g3WhSRgiQWCb4+GhQGuoG f6N6I9PqLbCjbVGD57ICVRBxzu08n56tDhbdNNBxq1ScgE3iN1FOa+zUh8WOMoFxg8 pt+W69Q9SxZqjJpSB5wsAaVtG7E6gcpdwKDF0Klgyh6hYK2axdpjGdJMqR+s90iKyK Qwzxm4a2Ezaj5ZGOS23ePyrWdvdfihsu05e2FS3GQL+6v8mdbnT97n7RNn0KCy4VNs bcynEsUoCvttDPIX3CjTe3duTfS96gqcqog7UpinUs9GQMhsH1XRxYZidtmgUbiLdR TkYkzOZmKgm9w== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CA6A06335C for ; Fri, 9 Dec 2022 10:01:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="sgdmZqAz"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id m14so4506158wrh.7 for ; Fri, 09 Dec 2022 01:01:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=9OcVoP2hdkkL69hfmYoyijjSQmy4nAYNEAi45K1BQd4=; b=sgdmZqAzYItF9XAfUqxQzkWIoy8UaXt3PWC15HszSFBOI+noG3VhBEnClOdpqEW4mO uZ7LFFiUHsJoE4LpHLxHUQ5erRLhtLSBC/ZJlWJNEf0I32m8kL/JtrGtEs9wZlGcPnR+ MF6m2JvGFGwxOjOEFrAv53jyOTl66TT1p5Jdn2gJcZ8Aqmks0bJatf5r7RHtXvW+855j sHFBgeAeG8LvEljVKEYjsJHJh5Gc0sUa64qE1eZybowGlTASvgHofAjcGZR+d/H+rXe1 EwRBcd0GkdhNebkyUV4i86K9ArNsi2yEVr1Nd4290JZ3RFAyAy5WoQkFc6F2VhI14aTX EH1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9OcVoP2hdkkL69hfmYoyijjSQmy4nAYNEAi45K1BQd4=; b=4IV771ur7FrHCJuVcEvM6X5AQM7+89TDsTDv9R2ijL8mRAduIZ0RkrpOZM7Jz653rg uHCaVc4DrPjjeP9TF2yolGcgLFSLreDWoiMFmkmCtwuV7Jlr1aTWoqbQSV4pchgNny7u nTt9VBo8IN7PdpaaP2ehZBpWJcw9Er/e7ahhSWHDOyBr19fy5MIMH//+xN37tlLDgKBy AEIUFmgUsbM3OD4RptBbxdlLttWjob7f17UFNLw20Pf6BNddVPaaO587K9iEgo4hbZBb MuDuhnOjiL7GphTwc2KyyUloFSkySdjFM9HYqDa8VfxiuR3K8FJyNL5zwo2Jl8YgxaXw tHNA== X-Gm-Message-State: ANoB5ploGUE9CctIRvRalH6gsUV+bxVTGrC6gZtoNz6ioI5uFviJngpW Qp0HFg1IQhyFDF452sO8Jwgmvz9FX9vrWoLA X-Google-Smtp-Source: AA0mqf4HlLM0PauewVHtZeT/uONkD6o+U+bGjIWz6nYDboS8n1hTthQRkaX4ApM+G7w0NfXJ3CZiYg== X-Received: by 2002:a5d:678b:0:b0:242:5d76:f571 with SMTP id v11-20020a5d678b000000b002425d76f571mr3419907wru.2.1670576492936; Fri, 09 Dec 2022 01:01:32 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:32 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:44 +0000 Message-Id: <20221209090050.19441-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 06/12] libcamera: pipeline: build: Add pipeline_data_dir variable 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a pipeline_data_dir variable to the meson build files. This variable points to the location of pipeline handler specific configuration files on the filesystem. Signed-off-by: Naushir Patuck --- src/libcamera/pipeline/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcamera/pipeline/meson.build b/src/libcamera/pipeline/meson.build index 30dc5b97f1dc..f14869f3a3c0 100644 --- a/src/libcamera/pipeline/meson.build +++ b/src/libcamera/pipeline/meson.build @@ -1,5 +1,8 @@ # SPDX-License-Identifier: CC0-1.0 +# Location of pipeline specific configuration files +pipeline_data_dir = libcamera_datadir / 'pipeline' + foreach pipeline : pipelines subdir(pipeline) endforeach From patchwork Fri Dec 9 09:00:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17971 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 BDB11BDE6B for ; Fri, 9 Dec 2022 09:01:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6324D63360; Fri, 9 Dec 2022 10:01:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576500; bh=T2AFAJs4vn9DNlKuZuL/tmptwUv4dxoMe2SbNdHpca4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=e99bKO3mPvLhpfiZTBaiMQOsyTdC1zNTo18XQzOLoQP+XDHWuWMXrBYk1nIw93iEg 9qzS4g7Cn8wPDDkdACh9AXODZP/ZD3p/khojkWVmyO8xtlQZu5E59p1kckNePyvEsl CKUakp4wt1NXb3lKJ8X4ykyAVVy+8dn41IWVCxAXuF+i7XHcD9QApllmjVGWLEIPij xXIhQAK2basJl0KKRox2KS8sFsIrK85+6zcZXLQgW43sNUTXyVRI70ZUs7a0if6oEP XpFXR4QIHSin3kZjLsOswYBtP6Gp+je2dK94ykX96jxFoqL1uspCHcdy23JaWvauKL rMqh7DW0HsLDg== Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 981CC6335F for ; Fri, 9 Dec 2022 10:01:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="DQQSbHoe"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id n7so3061423wms.3 for ; Fri, 09 Dec 2022 01:01:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=AXCdNqevCR4XHkTMpqcZ3r5O13khl/GMC4Xe7cZRkzE=; b=DQQSbHoe51UA3tDonwfFql9HVVgQ8wPaFO+/DBT9CVHzWVDPbvzQx0E5cypwBJ2AV+ DP5NKpGet/AgGfJYGfGZ+muRogqgl614x6e6v9tSBNlQ/8pyTGhUJssW84m1L+58fxkl m9uyfeEl1SAFC/iDzDA81Rcxk6dLwlGYp5aerbbfSGSgOUtuz+w4oxY55gLXFdTS6Jaz ebmwcm3QzBCSY0FmymQhd2JdeIYTSqBvoZIMfUUQGr9FA12Uek4nf175FG7kQ1epdS/a iimslcFwPwP86ku6WL5DyVF6NGMX+pHTH00qxyir4scg5KneSD2xACnYjwJ6YLIu9Bit 0apg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AXCdNqevCR4XHkTMpqcZ3r5O13khl/GMC4Xe7cZRkzE=; b=sX2mC4FtfT8ymE3VlyWfY9h9o8QD2CNX88nucIA4Ma0gCu6ZOaehfyc2kA+O95Ne/V rC2OBY5I+MnDxbgVtx0k75pvzQczvNSmzUV4K+At744VyCwSJtKr1gHCAWwufCvGfYjf f4vdi7U3gLcROBawHhw4pGklCAKoZYLaR8yxp7igsUtmXBHSNBLuhV7NT4xAh+om9O8Y ACn9VKnInol45lM0uMTsMksGmkkYRjcalr41gYzRQmMCeoukI2eYCwbwLav3CcMxrG4F SLU2n5rvbCf6vd7tZDX9+pc5/IXbT0CsJdMSrGE5H3YOLZh4F1RIorBxdHm4rue+9vW3 mZyg== X-Gm-Message-State: ANoB5pl1ouAro4d7Lnm80z0pp+7x/+iMtRWamUlT+byKyEC52ugjD0I9 mADVg1kTWaba1ToufEycVq0o4QStgshoDUlb X-Google-Smtp-Source: AA0mqf6aBOuTLf6hR7xhtKA6QAWg6nE7K/OixmWTh4P6iZZrmdvfVeCyfe3PirlsCJxDzBeejj0fqw== X-Received: by 2002:a05:600c:4e50:b0:3c6:e63e:23f6 with SMTP id e16-20020a05600c4e5000b003c6e63e23f6mr4397490wmq.37.1670576493820; Fri, 09 Dec 2022 01:01:33 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:33 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:45 +0000 Message-Id: <20221209090050.19441-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 07/12] pipeline: raspberrypi: Read config parameters from a file 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the ability to read the platform configuration parameters from a config file provided by the user through the LIBCAMERA_RPI_CONFIG_FILE environment variable. Use the PipelineHandler::configurationFile() helper to determine the full path of the file. Provide an example configuration file named example.yaml. Currently two parameters are available through the json file: "min_unicam_buffers" The minimum number of internal Unicam buffers to allocate. "min_total_unicam_buffers" The minimum number of internal + external Unicam buffers that must be allocated. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/example.yaml | 20 +++++++++ .../pipeline/raspberrypi/data/meson.build | 8 ++++ .../pipeline/raspberrypi/meson.build | 2 + .../pipeline/raspberrypi/raspberrypi.cpp | 45 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/example.yaml create mode 100644 src/libcamera/pipeline/raspberrypi/data/meson.build diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml new file mode 100644 index 000000000000..001a906af528 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -0,0 +1,20 @@ +{ + "version": 1.0, + "target": "bcm2835", + + "pipeline_handler": + { + # The minimum number of internal buffers to be allocated for + # Unicam. This value must be greater than 0, but less than or + # equal to min_total_unicam_buffers. + "min_unicam_buffers": 2, + + # The minimum total (internal + external) buffer count used for + # Unicam. The number of internal buffers allocated for Unicam is + # given by: + # + # internal buffer count = max(min_unicam_buffers, + # min_total_unicam_buffers - external buffer count) + "min_total_unicam_buffers": 4 + } +} diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build new file mode 100644 index 000000000000..1c70433bbcbc --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 + +conf_files = files([ + 'example.yaml', +]) + +install_data(conf_files, + install_dir : pipeline_data_dir / 'raspberrypi') diff --git a/src/libcamera/pipeline/raspberrypi/meson.build b/src/libcamera/pipeline/raspberrypi/meson.build index f1a2f5ee72c2..48235f887501 100644 --- a/src/libcamera/pipeline/raspberrypi/meson.build +++ b/src/libcamera/pipeline/raspberrypi/meson.build @@ -5,3 +5,5 @@ libcamera_sources += files([ 'raspberrypi.cpp', 'rpi_stream.cpp', ]) + +subdir('data') diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8be46962e825..9a316eda6fea 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -40,6 +41,7 @@ #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/v4l2_videodevice.h" +#include "libcamera/internal/yaml_parser.h" #include "dma_heaps.h" #include "rpi_stream.h" @@ -1149,6 +1151,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) */ stream->setExternalBuffer(buffer); } + /* * If no buffer is provided by the request for this stream, we * queue a nullptr to the stream to signify that it must use an @@ -1682,6 +1685,48 @@ int RPiCameraData::configurePipeline() .minTotalUnicamBuffers = 4, }; + char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); + if (!configFromEnv || *configFromEnv == '\0') + return 0; + + std::string filename = std::string(configFromEnv); + File file(filename); + + if (!file.open(File::OpenModeFlag::ReadOnly)) { + LOG(RPI, Error) << "Failed to open configuration file '" << filename << "'"; + return -EIO; + } + + LOG(RPI, Info) << "Using configuration file '" << filename << "'"; + + std::unique_ptr root = YamlParser::parse(file); + if (!root) { + LOG(RPI, Error) << "Failed to parse configuration file, using defaults"; + return -EINVAL; + } + + std::optional ver = (*root)["version"].get(); + if (!ver || *ver != 1.0) { + LOG(RPI, Error) << "Unexpected configuration file version reported"; + return -EINVAL; + } + + const YamlObject &phConfig = (*root)["pipeline_handler"]; + config_.minUnicamBuffers = + phConfig["min_unicam_buffers"].get(config_.minUnicamBuffers); + config_.minTotalUnicamBuffers = + phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); + + if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { + LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; + return -EINVAL; + } + + if (config_.minTotalUnicamBuffers < 1) { + LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= 1"; + return -EINVAL; + } + return 0; } From patchwork Fri Dec 9 09:00:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17972 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 77CA0C3284 for ; Fri, 9 Dec 2022 09:01:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1DB9A63366; Fri, 9 Dec 2022 10:01:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576501; bh=BiHLTGRIZrIxROdmyYa5tRAbZuIiIL1LaiHBSzWJ660=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=IATLDTL3+vv0TcWQ5MrODlRsP+3o/kFqD6e7e8NJQ2vbRY5qqi6h4+XcC9knTnHDA eV6rQw7pbr507L37qEdNZkKl6HBqbTL13uUpyNcDEcszJ7jko7xghob3dLwTODZSsj u5uj72Y44aLIj7d8aw75S9iIuNOyCJw3wmo9Wn8vHdCPkGKk+fH+RmhUZuKEIJpSQ3 JPVcbSuwTB7Tx8XiMnx4Ymtzq0PRTTnvNPb1XDDSmGPddCAk0B9cgMzkSX6LvVg2rW 8xsVeAvIdXpAn18Eg3lyXHeMxDFjbiLMWoHDoViN6fH4BbQUqJ8hccWrZ1F/E3EM+N ERon4pQhAOI7w== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6094D61F1E for ; Fri, 9 Dec 2022 10:01:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JKQQaj+F"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id ay40so3070343wmb.2 for ; Fri, 09 Dec 2022 01:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=aoZyfBtUFeCD/JFLmCZNa14e1yWfA5Pwc8ENXkV9xSs=; b=JKQQaj+Fi+YP5LTOH3yvFlDTYbY5Cqa10SoQIsV+TPvNJZ7TsDE6saTue13agX6LtM tTf31fRIOMRCxkisLwzf7ydMDMqSFsPYiUJ8H4glXyde6NjNQYuPYhbuCpv4+hNSeopQ Nc6V03kPp8KxMs9IL0+lvHx4g5FKl0vFu5GFssHVG8vfg5VvT7vs6Tm5ENArgHn6GQGC t5d4CmaUJ+2V6l2r6PKnEbyWoIG/6BKHUzbMiRngE3GRE1vkWHsdoZZ7mWWuH+IddvXU kuLhrbuZQcIqnCQjok/1kLEZgm+hIHWq3K9Zm5v+PrNGapikcTqoSRn/+ullX8vjPKeY vTWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aoZyfBtUFeCD/JFLmCZNa14e1yWfA5Pwc8ENXkV9xSs=; b=WKW82AorOLw4osZluLhFCiznoUdzYcaJiDzlUb4imO8EyUsFPkY0B0F00mvl0DHJgH K7w9Uo95ZQL1m/V//cwnVnDWRk1O/De0+DKUeZfTSYUc7TLRZs3bobaVbjt71mQR+n/L Ipa4kF3Jp/eWZ0Nc40AdMURfB7HNnucZAxEI8PvkZIf0KBf30i+7bmDDuPOYlc3OulzX tlxhsoNBJlIqnP50VcCZ2bWw7BvhKXZOU7KihZ6xQvqvE687kezmTpNZ/Zu2CsbgAHwf dhAErH6HWhMs//b9KsfL1JR5ec2IGPsXx4KWWquK2sXG/E1IPk7ro8Mdyhe0PVNAEH5M qzUw== X-Gm-Message-State: ANoB5pkhB98GQsHr4FjRGgVyN4Id5WvmUKl38GY3/4dG28jzIhaUNkRE by63Hvq2euGuXrzUOuHOou8P6FW3C35Kb/PF X-Google-Smtp-Source: AA0mqf7eZKYJgrIT1KGg+M8cvb66z3AshP1P0FukkOkBulyK32sWzJ+dytS3+P/Y5EEbNuUHMIGjHQ== X-Received: by 2002:a05:600c:1f09:b0:3d0:7d89:2256 with SMTP id bd9-20020a05600c1f0900b003d07d892256mr4387226wmb.13.1670576494621; Fri, 09 Dec 2022 01:01:34 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:34 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:46 +0000 Message-Id: <20221209090050.19441-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 08/12] pipeline: raspberrypi: Handle MandatoryRequestBuffer hints for ISP Output0 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Look for MandatoryRequestBuffer flag in the hints field of the ISP Output0 StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for the ISP, do not allocate any internal buffers for the device. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9a316eda6fea..45e66839efb9 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1452,7 +1452,7 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) RPiCameraData *data = cameraData(camera); unsigned int minUnicamBuffers = data->config_.minUnicamBuffers, minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers, - numRawBuffers = 0; + numRawBuffers = 0, minIspBuffers = 1; int ret; for (Stream *s : camera->streams()) { @@ -1476,8 +1476,21 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) minTotalUnicamBuffers = 0; } } - - break; + } else if (s == &data->isp_[Isp::Output0]) { + /* + * Since the ISP runs synchronous with the IPA and requests, + * we only ever need a maximum of one internal buffer. Any + * buffers the application wants to hold onto will already + * be exported through PipelineHandlerRPi::exportFrameBuffers(). + * + * However, as above, if the application provides a guarantee + * that the buffer will always be provided for the ISP Output0 + * stream in a Request, we don't need any internal buffers + * allocated. + */ + if (!data->dropFrameCount_ && s->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer) + minIspBuffers = 0; } } @@ -1513,12 +1526,14 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * so allocate the minimum required to avoid frame drops. */ numBuffers = data->config_.minTotalUnicamBuffers; + } else if (stream == &data->isp_[Isp::Output0]) { + /* Buffer count for this is handled in the earlier loop above. */ + numBuffers = minIspBuffers; } else { /* - * Since the ISP runs synchronous with the IPA and requests, - * we only ever need one set of internal buffers. Any buffers - * the application wants to hold onto will already be exported - * through PipelineHandlerRPi::exportFrameBuffers(). + * Same reasoning as for ISP Output 0, we only ever need + * a maximum of one internal buffer for Output1 (required + * for colour denoise) and ISP statistics. */ numBuffers = 1; } From patchwork Fri Dec 9 09:00:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17973 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 0C936BDE6B for ; Fri, 9 Dec 2022 09:01:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AFEFB63364; Fri, 9 Dec 2022 10:01:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576501; bh=d7Qi8omVLjX6Hj2aZtGXJjcZEqUCQWLP8qUpHRkfNM4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=p53K+Hqlgf1fdN1CSm7INzZumBHkcZiVhk8OIoLwFPRKSk3FvczI8JPAwRBTc0Cgw Z8gvIucbeWxCiv+ca7LwD5eEnxr6NqwvBfOFq9iJDcoPrdGiNsurn2ff6xNMxibgjo uGO3E9TcXDFqYw5qPtW0o0woUfwPERIGZvf2wFUuWA4S58HUZAnJeukYnuy4M2wKZm 7/++NYGW99m/mODMhfaa9h7YF6Ocn6fDHrcXDW2oonPEuZvkU3M8MKfbesqfjWecBc prIjY0m3bxcCnfSAOuCm6NCSzTTM+9blPLKxMI5BrHb0/zcBoMozbHQ0JHdGnWhg96 HQS545F1RrGPA== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CD1BB63360 for ; Fri, 9 Dec 2022 10:01:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="WF1L/nOS"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id f13-20020a1cc90d000000b003d08c4cf679so2904970wmb.5 for ; Fri, 09 Dec 2022 01:01:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=rCI8A1BvcyB6cCko9jaDzabqfodtnUyq6LuLmTxg2ik=; b=WF1L/nOSSIYSL0W2C+M8Tgc8zrdLhmHEP51n25hTbPn/KlhLfrJcJFUYNC8Jn3hks3 f8Be6WJC63e7pD8o0JOcnBEduJ59aJrlLzRImfXmXw1+yK8cEwMx9zUZ9XosoOK/S1TR tqjenMSDT3yAX2r1eQ3xOMaMzbu6F9q9ViYAJ2S0E59Y52q7FYPS6w1hfNERhDcLPisO hv6b2ScpfzhrFbZUZYHUD8dnAn949nNrcr1N78dcAkuNvBXnx9F7wdEQHJFzcpeYQTX5 bdmBJ9f2znCceatcTrKjbZpX5HOHQA6V98OtSsuoPFNqiPZ2X6QUShCml1ZTGCr6UmNk qqsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rCI8A1BvcyB6cCko9jaDzabqfodtnUyq6LuLmTxg2ik=; b=fRXczBZ5fIEoC+Ui/qCn2i4vLbE0rDKMktNJwCHL+aLZYWmjCW4JqR3eIxFC/ylmy7 NN//iU8EvyzImTFNrTnwZ/q94yWPTA2GnQ8FrC4+NdUt26cig2uviXY962o76RoNclao 9lVjuVaCXul1dwsZhQWSxxA4/IosE19eXGy2TXR+E57OZRtL1YysEVLEGmusLrXfqPCj Z733YlSohSqSlLKBWBDNYqa4LiA4PhiFUF7LBbAgXbwlnaxoRjvfs4cf22J6NW97R/Up 9XkjwDSSuvkvMBQ8dNolVnmmXlX4If8JILi7n9N/sVs0UF0zpjwo6l+eASQZo73IVmwS 4Cdg== X-Gm-Message-State: ANoB5pkv7aH5RE7t8zmyCeuzGBX1XhYQT2DLAI39FiyybqZ73dL6DPAW eUKjta2AslYZuGm63kokdRkCIuTv6x/37OS1 X-Google-Smtp-Source: AA0mqf6ApOc7NMiGg2UsNq6zJCf6mbUhmFi/7vgxJX6NrCVyYay3L6TOqybpTH5OtLM3K2Bvpb6ggw== X-Received: by 2002:a1c:cc1a:0:b0:3cf:5583:8b3f with SMTP id h26-20020a1ccc1a000000b003cf55838b3fmr4421669wmb.20.1670576495241; Fri, 09 Dec 2022 01:01:35 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:34 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:47 +0000 Message-Id: <20221209090050.19441-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 09/12] pipeline: raspberrypi: Validate MandatoryRequestBuffer in queueRequestDevice() 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add some validation in queueRequestDevice() to ensure that a frame buffer is provided in a Request if the MandatoryRequestBuffer flag has been set in the StreamConfiguration for every configured stream. Signed-off-by: Naushir Patuck --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 45e66839efb9..2c2b79fa021d 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1152,6 +1152,14 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) stream->setExternalBuffer(buffer); } + if (!buffer && (stream->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer)) { + LOG(RPI, Error) << "MandatoryRequestBuffer hint set for stream " + << stream->name() + << ", but no request buffer provided"; + return -EINVAL; + } + /* * If no buffer is provided by the request for this stream, we * queue a nullptr to the stream to signify that it must use an From patchwork Fri Dec 9 09:00:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17974 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 C7344C3284 for ; Fri, 9 Dec 2022 09:01:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 786496335B; Fri, 9 Dec 2022 10:01:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576502; bh=/MmfHyjyuV7+lDsjeOMyhSB65nzOMYCWZ7uEZUFpjpM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=uGi5e99Bz2vXmUNmwEhQXzDZzMtNarwois8Ca+QgmGEQaMLAEU94gRZF9T17wSH0L PbVM4OhYVlFPX0favqXzZbiL9kTVUTG9YPM99w9R0/saUZi6Wr/6mAHEPqfcpaM4oY Vil8dCoiuWUw7F2ssnXcm8ynDgpVMUg2X+H65LMl1wyDDZZb26rR+y1NA0hcJR6gnd xZYuQS68V81yHC1OHHJiXKrV+nyId+xhqesq5VeRNf7XjMoQTluU6TNPXopCwJ30pG 1eIPO2yu6jB7SLlY4MX2e65doT21zrJo9pMulQ+KiD+UJzPW1yB9ML03wN0X0+EELB rUxmpC4C3WNtw== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BA0BE63354 for ; Fri, 9 Dec 2022 10:01:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="LOwYZ4lx"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso2912470wmo.1 for ; Fri, 09 Dec 2022 01:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=3cWiVakbi2NOXkp8NicrmYDVzorY8ikQ/a+5gxscsSs=; b=LOwYZ4lx+PDSjfBWAsL867EVMaaz0VkXcbTFCToLo5+6X1qOx7MINJrv/mG/KsLooz bQr3Da+oGkSHsNQO0oKnm8SvHqHmauG5AxLCSqSB2jUYcbps7VIR4LwJroyYy1mUmc1u 6aWj0ywyu0halEkjIIHI3qSePO0JvLDMy7s6zkbSiH8AdTF2r5+tYEPjecmhbPc09Q4s zQvqYEmhqlpMupLTSrb/6tNTXc4j3k/EsDO1pdBiFp6EKzkbtA5F2wV0IXCePuiBEAuq bjZaELSrGZlNG2Q1csm46I4wBJUCZ/jit2R9hKJ7Mq+GYEA4V5gFOy4nkFyQaliWDUOS 1MSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3cWiVakbi2NOXkp8NicrmYDVzorY8ikQ/a+5gxscsSs=; b=RsVmSm1268q2wgBAOG1eC7PqW8ynhuu+IEdJEpsG3BC9OTggklXOW+f6m4UamfJkWV hUfW0hUO6GeCJMvkfkKOo0BB540wixNl2C0oIzh5H141mUCfmhmmO13p516UTgJN/0zP urnj9x8Li56iEPPnbA1m3plc4O/h40QG2qkbyd4QW3WSXsjxId2gTOk4Ro19diFOy6d8 QoEdR5mAdYVVKZSRa0n6N+MRU6FbIWQ6rhUwztHSyJNs/XPwLMbrgurSTyAzE3Y5jYSb JjpfBdYd0TmNc60AL88w7+9nssphBcEiSipV6NARJIquV+ejO6Wd2EisK47aMbajEZgL HzjA== X-Gm-Message-State: ANoB5pnar3eXfvPT4C+qwMOLEHGlDXOjlru+ZJC8/Z020EDkhv0sIAev Pni8M6slNf/L4TUrJJUfcuYDXVNXs2zrgrrm X-Google-Smtp-Source: AA0mqf7aONo+g+YNMlAJuOhDwl8Fx+8IZQPlXRrILtvWWp4ZTuK52hXHogcjYytuEotD72so4pGHkQ== X-Received: by 2002:a05:600c:a0f:b0:3d0:8a0e:3910 with SMTP id z15-20020a05600c0a0f00b003d08a0e3910mr4251184wmp.34.1670576496096; Fri, 09 Dec 2022 01:01:36 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:35 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:48 +0000 Message-Id: <20221209090050.19441-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 10/12] pipeline: raspberrypi: Add a parameter to disable startup drop frames 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new pipeline config parameter "disable_startup_frame_drops" to disable any startup drop frames, overriding the IPA request. When this parameter is set, it allows the pipeline handler to run with no internally allocated Unicam buffers ("min_unicam_buffers"). Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/libcamera/pipeline/raspberrypi/data/example.yaml | 6 +++++- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml index 001a906af528..421f30e62aa3 100644 --- a/src/libcamera/pipeline/raspberrypi/data/example.yaml +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -15,6 +15,10 @@ # # internal buffer count = max(min_unicam_buffers, # min_total_unicam_buffers - external buffer count) - "min_total_unicam_buffers": 4 + "min_total_unicam_buffers": 4, + + # Override any request from the IPA to drop a number of startup + # frames. + "disable_startup_frame_drops": false } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 2c2b79fa021d..4f15bcf0052a 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -308,6 +308,11 @@ public: * the Unicam Image stream. */ unsigned int minTotalUnicamBuffers; + /* + * Override any request from the IPA to drop a number of startup + * frames. + */ + bool disableStartupFrameDrops; }; Config config_; @@ -1052,7 +1057,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->setSensorControls(startConfig.controls); /* Configure the number of dropped frames required on startup. */ - data->dropFrameCount_ = startConfig.dropFrameCount; + data->dropFrameCount_ = data->config_.disableStartupFrameDrops ? 0 : startConfig.dropFrameCount; for (auto const stream : data->streams_) stream->resetBuffers(); @@ -1706,6 +1711,7 @@ int RPiCameraData::configurePipeline() config_ = { .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, + .disableStartupFrameDrops = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1739,6 +1745,8 @@ int RPiCameraData::configurePipeline() phConfig["min_unicam_buffers"].get(config_.minUnicamBuffers); config_.minTotalUnicamBuffers = phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); + config_.disableStartupFrameDrops = + phConfig["disable_startup_frame_drops"].get(config_.disableStartupFrameDrops); if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; From patchwork Fri Dec 9 09:00:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17975 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 622F9BDE6B for ; Fri, 9 Dec 2022 09:01:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 08C4363369; Fri, 9 Dec 2022 10:01:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576503; bh=rEqIEbuaGZgs29+h7K/U15YmT6g+aKk1ijX90G+xZnU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=lsoK3PoktQxiszPeRnBi0CZ9DOYpexXzusUZub7xCJbL4VGi9/UWrvc62JHZ/WwdU sqvyhEMkf9GRsJMrzN/8+7UMraa2HAsLsbGlkh5sS8pccXA4eCDVN/RCVD0fg/gHlv /GCO/9IeMhmnjSRpH41MXEFToTcnPzD19DU8GWJvSTHlyrFfdveCKB6zpA54uuVL5U 69pxwdilv9vxw7O4oFBOzhF4+ehxS3QYkXHP/pm99BGopYsLfUSqxVm9/DZOSw7Sze ZDwP5ZD+kSLWpLougu8AKhSRkmxk2obMbRijQzEZ/hxBUEMezMttxYo5hCu0mExyTv 1uGJz3wMo4GgA== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6F06561F1E for ; Fri, 9 Dec 2022 10:01:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="BIlIPRuF"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso2912508wmo.1 for ; Fri, 09 Dec 2022 01:01:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=b9p3hmsDwsTnR3TtFnBMbkk9Es9Dkr0IvE7b5jVv5W0=; b=BIlIPRuFhpuucDzOu14c2AIMEuoQfemOKBQ1Tj0ssU7J/P0FS4yF5ScV0iHQ9bJbvg S0B5tb/d2EiPkgh4mpqGZ1xhkd3If7Jc56Rdzi41fdsDiuyzPF2X/VRzhQ5QV0NF7Bho U6dDRSkNrjre9u8qw69Tdi2BS3hqGCGuki6AhgmlACRWPL85c6hdok73eQwAegzzv4mI h3XFPwxO1FggukdWEDbhvImX91tO5fDbVqWRxDEascZ4ABLVbrGVLJXqKiCXaVCChs/e cDOfBhz7DWunyBSM2nPCcR+N/+upeMMX1vrhAKKCEy4Mr7bOdP9XZiuEr8U/GQW7mczI sasg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b9p3hmsDwsTnR3TtFnBMbkk9Es9Dkr0IvE7b5jVv5W0=; b=sogVWB40qGb4Ez3q9mvgMInYLnr0/CVrMvycsey+V5bvLmjF9MJnN27K6aszvGi6ik WA7i3WxOzbpamezfDXrVwYlVU1/Sr56/3Tt8hJCeqovW9WMKvjq41IT0l77rDzVH78T6 uFmQB9BQ7aF73Y8/CasL+yYEn/1MFVz5cPwghb5jSkgtULZm7AOrC2QQevYHlOolqkum 4Z9YGxNTMueqVq/6abbEp4qGJL6UQY4vgL1p54y5YcnZLIvemO/ZP70S+YubzBuRTSgg PeyFd4yroY16WOCD0jU01zltuchpDN8mLwadAOlREl+6uiv129B3oSkxNYfp3JcWOOrj RZhw== X-Gm-Message-State: ANoB5pkRaz0k0XMzDzmg5etJ61DkVM0dnd5dr6d8NganwdRpT7m2Zcjh b/a6HMrgHiDgXZ8+3eccAr86dsOkmhywTVfk X-Google-Smtp-Source: AA0mqf77tEQUaQD7JJWuDK4aLGsIosHzB7YADVsd0Wno2MP18EhyKLlenEiaTw7OXkH+3GD/ta0cCw== X-Received: by 2002:a05:600c:35c4:b0:3cf:85f7:bbc4 with SMTP id r4-20020a05600c35c400b003cf85f7bbc4mr4272428wmq.2.1670576496889; Fri, 09 Dec 2022 01:01:36 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:36 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:49 +0000 Message-Id: <20221209090050.19441-12-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 11/12] pipeline: raspberrypi: Allow pipeline handler to always use the newest frame 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a pipeline config parameter "return_newest_frames" to always use the most recently captured Unicam frame when processing a request. This effectively stops the pipeline handler from queuing Unicam buffers and processing requests using the buffer at the front of the queue. Note that setting this parameter might incur unnecessary frame drops during times of high transient CPU loads where the application might not be able to provide requests quick enough. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/example.yaml | 7 +++++- .../pipeline/raspberrypi/raspberrypi.cpp | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml index 421f30e62aa3..04a117f38ada 100644 --- a/src/libcamera/pipeline/raspberrypi/data/example.yaml +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -19,6 +19,11 @@ # Override any request from the IPA to drop a number of startup # frames. - "disable_startup_frame_drops": false + "disable_startup_frame_drops": false, + + # Always process a pending request with the last captured sensor + # frame. Note that this might lead to avoidable frame drops + # during periods of transient heavy CPU loading. + "return_newest_frames": false } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 4f15bcf0052a..68c70cc19995 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -313,6 +313,11 @@ public: * frames. */ bool disableStartupFrameDrops; + /* + * Always process a pending request with the last captured sensor + * frame. + */ + bool returnNewestFrames; }; Config config_; @@ -1712,6 +1717,7 @@ int RPiCameraData::configurePipeline() .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, .disableStartupFrameDrops = false, + .returnNewestFrames = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1747,6 +1753,8 @@ int RPiCameraData::configurePipeline() phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); config_.disableStartupFrameDrops = phConfig["disable_startup_frame_drops"].get(config_.disableStartupFrameDrops); + config_.returnNewestFrames = + phConfig["return_newest_frames"].get(config_.returnNewestFrames); if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; @@ -2326,6 +2334,21 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em if (bayerQueue_.empty()) return false; + /* + * If the pipeline is configured to only ever return the most recently + * captured frame, empty the buffer queue until a single element is + * left, corresponding to the most recent buffer. Note that this will + * likely result in possibly avoidable dropped frames. + */ + if (config_.returnNewestFrames && !unicam_[Unicam::Image].isExternal()) { + while (bayerQueue_.size() > 1) { + FrameBuffer *bayer = bayerQueue_.front().buffer; + + unicam_[Unicam::Image].returnBuffer(bayer); + bayerQueue_.pop(); + } + } + /* * Find the embedded data buffer with a matching timestamp to pass to * the IPA. Any embedded buffers with a timestamp lower than the From patchwork Fri Dec 9 09:00:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17976 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 E9775C3284 for ; Fri, 9 Dec 2022 09:01:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A33926336A; Fri, 9 Dec 2022 10:01:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576503; bh=a3YaJE7CSXCIWHjsIpjMGKKlrxVHNtGXnCOROHKsYI0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FshxAEFQFGgdp70fSI6nOzWLPM3isX1i2yr7Soet7uSVGmO8TIxbAzqMhmKEtsaxH XbSF4bxISqB8O0bYoJLjJMqofEPJangJReTKFFh6CZiEI1St14Ob9fmEZuuPyUj0J2 hISJGzZPCwMN3j70CTLToOHw/8+vcu7HsVJKQQDqf9z8QV5gnRr/zu3oh5+Dg9UTRk KWQSpp9cnD7YELiNudaSx0A57B7FSsoXTIcIH3KLo5pdHqdlRNaqKd1hHgos9UNDGz +O3T7PnTooNBH+j4ptGLNZc7LFCVWDoj7+CxGN8ht5cegkcT3aa/mqAMds6ni28BDY w3CWS4jd7KZ2A== 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 7431E63366 for ; Fri, 9 Dec 2022 10:01:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qAQDogJA"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so2917187wms.2 for ; Fri, 09 Dec 2022 01:01:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=sWILBBIXlzAhPGU6fvcIkhjxcYBCw5crq4jorvb3iUU=; b=qAQDogJAAhl3vIw4e37ZJkqAggB3BAejH8nSHA1LUjnuGafKFQRHkoRkvagO515tpE cV1wovRKE3IEtwKj6sqbtqhQhhbKJUGh1mjtEMShcHZorgim69Iehiw14LLVmcnefSVW AqAV0p/ReahVASk1QjvRxQe/QMLZ2v9Hl9HtOfXiQ/DM7sQwYFOOT5VbrUJxDK259sgl qdsxU37M0MhIkwxFtS5rBdKcUzpsEO+fNyTLzpRVGfZMu7ywJtk4NyGDIGHwLxudVzds wegQccLt42RCiu3Jx6mA+E95SbLfIfCh/gPjje6mMNCcCp7xwKHqYh9TdCIbbtq9J2um 5rxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sWILBBIXlzAhPGU6fvcIkhjxcYBCw5crq4jorvb3iUU=; b=CgNAtCa+/MWoq3/OTkBBEaoJfgEpX4eawcv7Ozol4U5PNlmh5n6Qr5vKtKycf3KJJ5 xdO7dfwmElSFG20oA4/Y9lsoxPERqP+TS0NQF8BjNEEX+FO8Ae+rPcNbDvVps8JAlYqJ xNR1iMiv9EUvK39/03m4zLIN3i74jmEr77aFu4i0Yx3mn85o+J4pI3FoL9s7fwyOlUjU 6kGQHVKgnfHbHJbIBqbH2KOKe/YNEpvfoHJu8f3LFJK4RK17SVtt6LCsPH9Tr80FMfEh oejRMtdceYQW0hYNpdfmBje75DcOKZWHlhGOsmdAU+ZlJ4f7i9ZVffcZAz8wLx2fAJ1H qhRQ== X-Gm-Message-State: ANoB5pmpS1nOQbHerHJFn+UvKa0WS6qx7rle2VgcF3Riwo+2mBVP2IZy o1odbqtEfgQHwHq1nXhmwAHoFF81MiNuLOV1 X-Google-Smtp-Source: AA0mqf6AbaC6Z7lazVj2UL61RonDO31PFFR6bm/Dzuzg71gw2/00K9dgm2i+W5k1opaDFzEluUOvDw== X-Received: by 2002:a05:600c:1685:b0:3d1:f687:1fd0 with SMTP id k5-20020a05600c168500b003d1f6871fd0mr3788132wmn.12.1670576497697; Fri, 09 Dec 2022 01:01:37 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:37 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:50 +0000 Message-Id: <20221209090050.19441-13-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 12/12] pipeline: raspberrypi: Add minimal memory usage config file 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a platform configuration file that allocates the least amount of frame buffer memory possible. This configuration does come with the following compromises: - Startup frame drops are disabled, so the first few frames will not have fully converged AE/AWB/ALSC applied. - Applications must provide ISP Output0 and Unicam Image (if a RAW stream is configured) buffers in requests. - Only 1 Unicam Image buffer will be allocated if a RAW stream is not configured, causing the framerate to be effectively halved. To use the configuration on the Raspberry Pi platform, invoke the application with the following prepended to the command line: LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/raspberrypi/minimal_mem.yaml Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/meson.build | 1 + .../raspberrypi/data/minimal_mem.yaml | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build index 1c70433bbcbc..6aecd8ae68c8 100644 --- a/src/libcamera/pipeline/raspberrypi/data/meson.build +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -2,6 +2,7 @@ conf_files = files([ 'example.yaml', + 'minimal_mem.yaml', ]) install_data(conf_files, diff --git a/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml new file mode 100644 index 000000000000..5cd593025140 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml @@ -0,0 +1,29 @@ +{ + "version": 1.0, + "target": "bcm2835", + + "pipeline_handler": + { + # The minimum number of internal buffers to be allocated for + # Unicam. This value must be greater than 0, but less than or + # equal to min_total_unicam_buffers. + "min_unicam_buffers": 0, + + # The minimum total (internal + external) buffer count used for + # Unicam. The number of internal buffers allocated for Unicam is + # given by: + # + # internal buffer count = max(min_unicam_buffers, + # min_total_unicam_buffers - external buffer count) + "min_total_unicam_buffers": 1, + + # Override any request from the IPA to drop a number of startup + # frames. + "disable_startup_frame_drops": true, + + # Always process a pending request with the last captured sensor + # frame. Note that this might lead to avoidable frame drops + # during periods of transient heavy CPU loading. + "return_newest_frames": false + } +}