From patchwork Wed Jan 18 08:59:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18127 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 3A489C3294 for ; Wed, 18 Jan 2023 09:01:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2F8A625E8; Wed, 18 Jan 2023 10:01:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032478; bh=QkvgCjnb1SkCZNUezMj93jhzlLB9aGvfY1B1Coe2aPo=; 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=sl5AWh96R7bBpG3fgvLG2Q27z29758JsMbaHO7XJrOfzD2BJMWFp7Tiuw8o4OaRJ6 K1gcDLe63Pg1NGam5McQ5G0tRToab19ENW9GxEyft2vXbTg1ScesrDvm2cxtGXW7qX ey/TWwL/h9os3ZeqUFnJGWleJ6RWv8IKmf4b4Td5jBPKD7gyR/RPVkHdMYlM2fP++c bllkz/pwQPW43s1wN+FX4zRe/3cxTpGoCzebjhiZQZXP5oNcH+o4ZIsp/z1ldp8ddA TXvBjVkrSL90rWqMFAMjW09dfCtqYqUAhD+/9UAqus7SLiLOm7HnUarmnft7Wdwid4 dciZ0Jm0Tc1sg== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B4AD7625D8 for ; Wed, 18 Jan 2023 10:01:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jpA4+qnE"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id r9so10402228wrw.4 for ; Wed, 18 Jan 2023 01:01:16 -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=xCtV3Pwa506NG4l5A7ynk9d9USDPVq0OwwiiFJsSw4Y=; b=jpA4+qnEnCrCnw/j/vPMqF8C8a4/sAQ1ch3z8/KNPToySSwj39NmQfsCQTyKJMH5nf 0NPurXaybdYwuzlETUrMtbSSU3UHWFNkkcid48zXbkcbY7LRUwTGhyP46mq4rDv6TE1C 9l/vIwoBd8vj1+vC1QThU5BUeQcAdQPR/EMlGq5XeN7qFfXXZSKMQb4gUogMfu4l3/sa 8BUxdb+EJgs/vTqPyXM/lTBYD10l2d1TU7li/bBdWuEQeLj1RSzO0Db6QK0NHQ/VSx0O Hn8/O1Vr+kVtdI94viyr8ZxwfjLsYWm0ReJUn30Eyu+dF4pWasscghI78PaqyVgXICHM ymeA== 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=xCtV3Pwa506NG4l5A7ynk9d9USDPVq0OwwiiFJsSw4Y=; b=kiZH6a+au/wO2SIJ8ZY/ToVRvqXHYyT6Wx3COcjnUP/vtkfMriBUxXLa2AL+PPY3sm buaA6OlXJZP165oo844KdYngNwsNlKK1oq9mS8VTPDISSlwVHyw5XfV9yhsnGj/JZPsh eUpoenA4GPaixr9FXnIvlnhQx3r+vU1khi98UfFo+CcXmVC1wWcVwUltqyqIncv2fYIr xYcwExc0qEGKLqdlemdVKi5Nr4LpU0oPAwc6mhzAl81OPYrPbYzsplcBTVW+mBX2z+px VIpkS3CErGp6+KA6R65jch2fx6Omgl44E5/LPCnlDqfBSFZbcf7Qp3XKC6zZauflE40V c8SA== X-Gm-Message-State: AFqh2kpDGpjbkoffU/2swf0fxk2rxIacEubO6Llh2I3P8DC84wvGxTGV tzbp+skQtoHChVbTBZew3d0Lbdq8o3OdnEy5w+s= X-Google-Smtp-Source: AMrXdXsQ/feAZJstXNbNbqLvgIak+ogYMmTSLLOxKQF1Bzev7r0HZ/0z1xOCgYzoZpFZC7hooNlwVQ== X-Received: by 2002:a05:6000:98d:b0:25f:8ead:96cc with SMTP id by13-20020a056000098d00b0025f8ead96ccmr5527753wrb.70.1674032476013; Wed, 18 Jan 2023 01:01:16 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:15 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:42 +0000 Message-Id: <20230118085953.7027-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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, OptionalStream, which the application can set to inform the pipeline handler that a buffer may not be provided on every Request for a given 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..233ff0450451 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, + OptionalStream = (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..b7de85f8b9c7 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::OptionalStream + * Informs the pipeline handler that the application may not always provide a + * buffer for the configured stream in every Request. This may ensure the + * pipeline handler allocates additional stream 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 additional + * buffers for internal use if an application does not guarantee buffers will be + * provided in every Request for a stream. + */ + /** * \fn StreamConfiguration::stream() * \brief Retrieve the stream associated with the configuration From patchwork Wed Jan 18 08:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18128 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 C128FC3240 for ; Wed, 18 Jan 2023 09:01:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6435F625F1; Wed, 18 Jan 2023 10:01:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032480; 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=vJb0mZ1SNcAYwmrHnfXvimDs+e/aiThWgWXtUgBplaiEAh5kLkFHG3JOh7aaLhjV0 f7a6CHk5vf4Jgk25qciujvq+3xePfw6QWohcOtLr/dU0fAAaa3asvDr/ZBzVWDKgv6 3WgEFx9L6FwZC1fpDy5BS/PtQCDmOSH/ffgcQU5YYYx9TUuC8q4Yazg72O1p+Gt9Wb xm+1OTCrxk4xKNS6qpss9jyRiFSSEhaEACE2df7B/Y+fxSKwGQv7Jp61M8HbQCRqxH qhiRLOK1arEBy/FmIaavTppAjpG7dx6XSQl6p+Zke/indaruY3E32sqirk2yEE5ooi MRXf4/tB6ZzVQ== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91A7B625E8 for ; Wed, 18 Jan 2023 10:01:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="miHWQt7Z"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id h16so33173492wrz.12 for ; Wed, 18 Jan 2023 01:01:17 -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=miHWQt7Zsk8yHx90JiUjQ8voLApwX+n/hWexy8RIanyNhyCswyq4qcKxSL6M5+70+x zJbMYCd8dm2UvvveNonnEqMVFN3qLQg9UfimuLs8GKe5SArXCO64bryv1gkqRuwH40wN LJ8eB/7HfSR8DB84SfA5oCrXU/Gqahe4wS50svQSMPDjhI89WrA+XjvA29or7yuFevJh 1yLo7pWx8mSJNlEHoi1a+MKaNgtILpUUYxCHi6rzcn5XaI9/6veG5mgsoLhQlQHjGpnq 2v0bxD+tP0sSF1L1socmDnajN11LBp/Ng55EFmCiP2alSp12Zd+JoiN9oY3aV7JWBEkR p1Pg== 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=d6EnffcGdsBGEYCTqIeOAe/ypsu1jnY/+y9OuYXVvzoM92DffwqwZaHRS9/yk3Hwgb KJdEAj8GAPtasZ+5Yk9Oif6Z6fSou4ixoP9wt6qpaat5H4ygfHQMydi+pbIp+bBNhw4S Qj9gb8AFUNsoV7ssmTrXd69Chv6sU9Gxz4hNADgnWncrNwPpBZ+4rYbmjtf9InECb3yW wYyG/mROrGhgt7GEqRfsodC1yYfw2QaD9d2c6xYyT4AmnFg3KrovzqdrF/NOaF1D9RQP GWXkHKbtVcMJo52Yp+/N1c4nqPQo9GkWQVLTmJetdxWpdNnyItEltj/dg4fFZ0Cvd6gV gmtA== X-Gm-Message-State: AFqh2krUDwaCinMb8Enr0G/5ikp7h8KDsHlqhjubXlNxpE4TppXk8kFf DcuKOq5SWUED5DKHyqSDhuLhCSX/ITuLywWO29s= X-Google-Smtp-Source: AMrXdXvzvgs25OtnEvrUI/qNxVBnmkLZL3+64D37NALOdgrdL6+1o5WVkr34JD4DjeqwvvdsrSMLEA== X-Received: by 2002:a5d:59c7:0:b0:293:1868:3a14 with SMTP id v7-20020a5d59c7000000b0029318683a14mr1943695wry.0.1674032476825; Wed, 18 Jan 2023 01:01:16 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:16 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:43 +0000 Message-Id: <20230118085953.7027-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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 Wed Jan 18 08:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18129 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 EED25C3294 for ; Wed, 18 Jan 2023 09:01:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5ABC8625F8; Wed, 18 Jan 2023 10:01:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032481; bh=DCEFzNUHEZLbcUeoR1xC2Lch1oiujuK9RPYAtZWf5Ro=; 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=yr73IGC2TtWLyemfitYoN2RLi8s0aHFsDceJOtMEebXjrgzCruRlWn7gcgogdOmO2 IuUZOrq2I1Xr7g7fuEi6F/Ss16667k23lOO03Mw6yTCG8TegzdrvPdwABEuB0+w6bE 2Hq49IqiyEkpUBecr1SzL5JpaSCXJYtL52bhF9Ctu3TynS05HKJBJXKP7w9PtbsnBS Z9TjGj4s5aIo/gaIf+KpzN8jHtteBvOT4mgPTkJaGby5vYKqbdV5G/5/vkdmmcZzBD N4Q6KpPU42U62GsfOfugeRAiJ5dSqr4u8IxLFmJoZvLUY0V1K5Tk9Chto9yeYb8ztE 1lFpwHM7sTx1A== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F90D61EFD for ; Wed, 18 Jan 2023 10:01:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Ib4QRsEx"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id b5so12018859wrn.0 for ; Wed, 18 Jan 2023 01:01:18 -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=fbgMUqKNkGfg+xlrxfdo3R2wbqR2znQt6T4Zz6boTAM=; b=Ib4QRsExtVvYhsMek2Hj2SNzfgy81L2iBLNJrfv0wKtolnQ7B1GLEabc8uD/i7qUxG kFo43GypR1RIU85E7jSzV0KtEKiNtapSkq93ciyO2we8sNb5J8mL3hMskdWw4BXnoFpU MaZXiYin6pZ2viFMtL8VKLsEbvDvNJ/ustXSZ33JoQIZTtEauGqHe7b4k+t2OjgFK/R4 YHnPPVS6zfKbhj7pIlx0TSJE/0t2Spb9Gtiv9Q2VLNWe5oHXln11940VGH6XEDr9BSoW Nvifu7PM4O1t3H4+4xrdrJkeQVwgwsNVCeeWXV1eR/D6UZQ1hiIK+NgN2ivaHKRDMtLf FVmA== 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=fbgMUqKNkGfg+xlrxfdo3R2wbqR2znQt6T4Zz6boTAM=; b=54WzArUGguk+nVfOvV841EPubGON+H0hp7SObnTBBX6KhrD0mVj/7L0NHFZF26gxX8 0vAEU81aEoRLV0ONMM2CFSX2rtGdRT/L2BUnDHNewQX7ZGR6rY/kU+RhLCF1FaU8Crpy hA+6Si+57pjzLVLSt2YuJa1Z8ZJ+UVRxoGJkT7vEMbMc9+fZFFOctFV6gd2X1Uv84nlY 8EEb3S6onprV8aZh3tNALF4cJGMhTWMwkyF0cu8JsEcxqlyc3g3xJExsKykDXoBPg4n8 BZ0qJB4rB3mNr/4Gflu4USQcp2W9TyivTk5HhnSfuA+yJ/StGRZim3YEOKTY23JeX2t+ XTkw== X-Gm-Message-State: AFqh2kon+aFUJR8JZBxVl0ikU4UO/JvWbEZ6ujzYHUgslLFHVFAUSdZ3 puiYkcQoLSZokXSx7GJF7INjFPdZX4WaqB5RUes= X-Google-Smtp-Source: AMrXdXuhGOzbAat5YEhJmVOoVx1KoKsddScs2uy6MsW22LYzv94grAw5R7MInW9w+Usuf/Y0W2sPYw== X-Received: by 2002:a5d:59c3:0:b0:2be:1535:e5b3 with SMTP id v3-20020a5d59c3000000b002be1535e5b3mr6615040wry.41.1674032477468; Wed, 18 Jan 2023 01:01:17 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:17 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:44 +0000 Message-Id: <20230118085953.7027-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Kieran Bingham --- .../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 8569df17976a..6bf9a669c679 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); @@ -295,6 +296,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, @@ -1378,6 +1394,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 = @@ -1440,25 +1462,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]) { /* @@ -1631,6 +1656,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 Wed Jan 18 08:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18130 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 9C03CC3240 for ; Wed, 18 Jan 2023 09:01:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C7F5625EA; Wed, 18 Jan 2023 10:01:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032482; bh=L265xLyiuEuaKv9P5lGhDdWVXIA6ltrNVdeVTVaM2LM=; 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=zkyOaypu3lTYwRZxt1nCwuTZSnCUz8MEifPYPR+FfcboHYubgISNPSo4wgEy8toHA 3TJPcQLuPPt/mtmeddjrUSMGntuuYemiCA3Nmb2e+cJKdeBKWyNgqefADndgPdafxl N2UgEnL0FnycW7+GYzRRFrPlBMpcadTjkdUJiPsXn91k6RP2tQLlDZjDPhhbqpKdW/ qhL8pWF7rqahrAE++2FEdmQB9JE2AJWOBswVuWhuhnTDA5gn/Pj0i/kJi/WkRjvKiG jhFqcNzPryFPIcsmYPMXRP3ksNBZGOYWRxJz8OEEea0yHJRaz+fYNb3PeEKGdlpQ85 PN2G44Thi0Kzw== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C3FAA625EB for ; Wed, 18 Jan 2023 10:01:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pENFsmiP"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id b5so12018907wrn.0 for ; Wed, 18 Jan 2023 01:01:18 -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=8TFxH7E7BdYI52Y2sjOrvKP7oQS4L1/5NWJaxGyGFtw=; b=pENFsmiPp6RixW9LHbNQlpk4YEZy3qKniHm9WiVLYBFuy+mN+OchW9U+w7PB8VuAJk RrTUIpDI/13ioJyd3rOxTg0SYpADEyBIRZfcFiwOL79adu1+a91QH/+UQ+YmaiTwIPQ/ sDSiT/HIGXlfErOvtCuwZGuu12OeFDLwTPUmrKWDKUJpgOsWH40ToxBsa7u8QpyR9aIe 82Z6PnP32eg9bWxKFMPGLcwhNBtHI6tKtrSQHDymZRYitWO7lZPSsZyWbk5JVpt3dywm ji2O2fLabGsZtoMnhYe4w1BzufJ7sshs0TlLS0c6ktQpnK3QdNNAFvCzrUBqr4VYIkpv 2IRw== 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=8TFxH7E7BdYI52Y2sjOrvKP7oQS4L1/5NWJaxGyGFtw=; b=QmGAYMv544tu69HgWyH/elDHTP0vk1JiKa4zxWMM2QznRk820pO8i4NZu0Md4JOKCS GlIKMQybfl4m6Si404XDkXiVvkqj4MgatYO8eqY7rm20ruIz5tnNUC0J434NMYTrv51i o2DkUWuvHxlTN41on6KjZYyfxSbsKu+kDK5G4C17jn5xDEja5bQnSKYE2BKxJz9dCIcQ 2hcKAqeBqQw5M6/il7D4O7W+0Jy18GEM2SbZF1oaEXq/oZ/D8GRtVOK4sEDCdkQffrmP dM8y0h8EbmHXbybD+dSaczXrWnaRF1FaDBhQ/i4a6Y24QIxhnQRgWJNBN5T08BEanjDd PLfg== X-Gm-Message-State: AFqh2koi3Y+fHyLtiMT060dolDGO06Mfhu83N+5Q8kEgVTRpSiHJoqCP ovWeYsswoZ51XqR3mIgNp3vgysCZX5RR2vtOpCI= X-Google-Smtp-Source: AMrXdXsvU8JK+RPyfiUMjzZGgwbi5t9RZ5v2yZyhcZj8U4V/MGydEI5kTR4PRROTf8Czas62nhQ0+Q== X-Received: by 2002:adf:edc2:0:b0:242:4cf5:f385 with SMTP id v2-20020adfedc2000000b002424cf5f385mr5455645wro.34.1674032478160; Wed, 18 Jan 2023 01:01:18 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:17 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:45 +0000 Message-Id: <20230118085953.7027-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 6bf9a669c679..8d325c7a18c5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1037,21 +1037,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); @@ -1068,6 +1053,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 Wed Jan 18 08:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18131 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 4199DC3295 for ; Wed, 18 Jan 2023 09:01:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 98314625FA; Wed, 18 Jan 2023 10:01:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032482; bh=jhW47XycTJeJKViSSbDzQOA0ZeuaoMQvJsIW4Wz891g=; 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=qq+lbWLtaJASzBFws9XupzDV4V2NYSjJVMKqC2aELekNSm5cCMkXoHB/84cO2ywE2 eDEa55EwQ6J/OOgtrK49etTEmURFleGro/riRtEy61QaYO4im6QrsNb8oLnd/ZubiF OtQ4EkeUnHID0/Tg+KVgq+VUTrNDkKCx7RfMeV4isvEiVz2GBcxZX0KwRbvD4OSRFE FFzcP1xUFNoe991sLTVZqqVKYmChaBqJII22BCmDs2DCSmqQwZn/VbbN6/vdVIqxB3 WQIYCvt817/DvJOXPoilcdn+LW+Te7D/CQ6KGOG7tF1gQvbhGxKqruEcP7hGS0M+mB bzj/AlRpe5Cdg== Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F28261EFD for ; Wed, 18 Jan 2023 10:01:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OO7hxI4I"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id n7so7117659wrx.5 for ; Wed, 18 Jan 2023 01:01:19 -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=MF/+iG7HIHFeXPj2IZioMbRFhVvgaszMfkZq5nsWvdw=; b=OO7hxI4Iya5vUbhk+KHdOtX1hJf3OPBlxmJjpEsB3Z5XsZxNSWyCaIeDVoi0bsjaoD NLOtTEjevAg8GAT0dmOs6koUowv5jpgBVLy627N4D2w02pRB5Y2E3HoG8xNisI56q+hi AtrZv9OQqb1FJpMPqjBMqlDT19wGIeq7uGbOCv0Lrop1PLY0xXOR5Bm6znmvz5BlJeJe 9bvCnGXRfYb1S9TSyx6M2nt8HigEnfa0Pk9O2PH0FO46/6pev7r04h8Q0ZKqlPNOqfLk fzdiCme3Rh624YIYJoW/+8FoJ4Gb4i5YkKge4tzgw1YVNXn37mmt82/yLnbx2hPzYtJr 4HgA== 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=MF/+iG7HIHFeXPj2IZioMbRFhVvgaszMfkZq5nsWvdw=; b=tVSs2Jo6MWqyGb+ZHoqd1Y3BDIZJ4ax9JCmyG8feQHVJc8I0l1sOcwV+99hHwTfwB7 pgTi/la6cit/oNZIREv113MH10fsUY0jp1uwL8evqb6kqnjeXr5p3xpDyQMekYg4S44C xmx4kqizgpfHB0gkAdxzu6iiAKFjJqZkcCyILm8kSgietnwVPAWid+gbps2pleU7ITdq OpzpA6ZxIGMWGjy2ab4YK4v1GDsJAaZLFws4ao6FduN/WSPvRoN044D64GYZ+0r5SmBZ sBYQ+Ff09VEPPKrIpm0u0J9E7v+0OE7MxwRfscg6RY4c56rmoB0Nh59ud0Vz0IJoZ2Ex jhfw== X-Gm-Message-State: AFqh2kqVJJEfFWpe+YjtR9uOe4oJbYwNBhW0QdbkBsisn8I3phB00CR7 sKrQWOcSCgKU+JbbyVpDAKc+ui+fqcvForoFUmg= X-Google-Smtp-Source: AMrXdXsNSb5pPN8Ey2hLWPziQkgq56hIFDQICQrKzEGB9VhZIRsF+TCKmPMv83X17hJP3Yr+Fd9D7w== X-Received: by 2002:adf:e991:0:b0:2b9:1a52:4f50 with SMTP id h17-20020adfe991000000b002b91a524f50mr13724505wrm.6.1674032478718; Wed, 18 Jan 2023 01:01:18 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:18 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:46 +0000 Message-Id: <20230118085953.7027-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 05/12] pipeline: raspberrypi: Handle OptionalStream 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 OptionalStream flag in the hints field of the Unicam Image StreamConfiguration structure. If this flag is not 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 8d325c7a18c5..6ed4cc2c7ba7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1448,12 +1448,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::OptionalStream)) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1465,7 +1486,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 @@ -1473,8 +1493,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 @@ -1482,15 +1502,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 Wed Jan 18 08:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18132 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 C3DFCC3294 for ; Wed, 18 Jan 2023 09:01:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3FF3C625EE; Wed, 18 Jan 2023 10:01:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032483; 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=000HdEyHryWG+WZFSAdd93zopcl1RC9/twrKt/pHIBN6M8UbwfWL6sNc562CfwH5t kq46D+MuY7VEXZuNPhALHIHtscUxX7KkcZfJzMl2/9IUP/ToJP790vOc0AAFcss+7E u0GOFsSZ1eDJB7dKPlkeyingQW0vMJa0i6iy6tOjaVm7dmC9uKk+5y49MGloYLf4LG P6EOm82EeqhpLmCtzRCTzmXZ/F2+ERwUwFqg2FgMAnDzSkywJ/3BZEcVP0haVx6SKO eYDb3LEMjFHQ24HOYtvOoO5aK5rEigZGeHxJSP5GJf+kT0LoUIHJsZPboX+Gbr79xm 2xbX+mSBblZ8Q== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB171625DD for ; Wed, 18 Jan 2023 10:01:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="HA9DKqdK"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id d2so13061951wrp.8 for ; Wed, 18 Jan 2023 01:01:19 -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=HA9DKqdK2BcderLmYPvUggyognkQjJDkno7/VkDuYrMt+O2IM8qFYr2D4KzOc7TEKA h7Bcj6mgOVgvWRIGVuvE/8jPpxz8CJr6k0+Xb2MRqp+r2COJ8du5Da5DQNyA3yVxHuIC oCWrKZf8+cx+jZEYivjxjVnnanLLFJTeWJIAHBdNy9sWhDQ27i8ERVstXhP9+FhoOJmq gQS3NjZXpQ3fBEgoVrQ7sBF8gNSucPoOpRdj+859KCiSwLK5tevpUHn9kJ/XMdRUBRrq xXQChbxVwy62ODwCojK/3Kn8rXIZ/zv74zYoNeGRrSrzRR1Iu+nEVs7SmKcFHi6bjto4 +Brg== 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=P8Bwo3suDyaw3H2woY2tZhCAX1ZWnHMhreX8lhXxdEBd2kXFLdYNRChLLmvmYlQ7mw vvEmRJUoED2od2j43TaU7qt5DDa/meocpoy4xQIvOGnk5kPDQYXCbhCyWR+HrxjXdwXt V9eHOyM+E41hC0BCQiejNZIdUqNtA299c5/a7gnk0fSrAJyjdjqBbQ1YjO9GB7pVo3L/ ww0IlDRN7Zk9uC/fOgiAPIV+/bknOE+hgn+bjsSlRmG7F/vNziMX1g8FVFo3xHVVjroL zU9UHvnRBhhEzMpjOxA7LmvR5kNc1a7VB/luAR5Bx8NTzMiffWScAQmxYz9T/W7RM95s Sj5g== X-Gm-Message-State: AFqh2koMlDSVrmJhxxy2K6Pxvf7p4si+qCazTP7M5rj1LHhyRzE+odnQ iT5Gd0W9yCr7cHGc9kWQKJwZJPAPMAK4gQqifug= X-Google-Smtp-Source: AMrXdXtulS9YrSHTXi8GXwhUwLX2BpxYA3GKwKsWOcagsVARXBsO2d9kcZeYRTsd8MeB7Jn73pP8Vw== X-Received: by 2002:adf:dc81:0:b0:2a1:328f:23aa with SMTP id r1-20020adfdc81000000b002a1328f23aamr5277657wrj.6.1674032479254; Wed, 18 Jan 2023 01:01:19 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:18 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:47 +0000 Message-Id: <20230118085953.7027-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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 Wed Jan 18 08:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18134 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 3BEBFC3294 for ; Wed, 18 Jan 2023 09:01:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C72C9625E8; Wed, 18 Jan 2023 10:01:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032486; bh=2BVu3khsD0IidZZis0CYJfsB9vWYAIIJPnK1/awr90k=; 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=f3e7CkYa/wLAY+fXha/699TgzJf2/ZU1Z5NlAkEbMl/nuVRfmYtgYuoOQtTGcsMJx 21biNK4yrvzTV+wI6jdUmijke9c0jjLjtUYKBmjV+W8fAxPbMKchetpwJXJXerlLRs 7TluVtIAwSQG38+qFOyJdQl66TbwWL4ui9aAArdhpWNqPjGGkHXNk5whBds3ZBs+2t dywZhJsVN84epEYx9QrxQ1SgvbfvbXMRanvITZkumD4Pnvw70/OASIyFEDxUNGNsDr OIPAkUN6AE5pB4tCIbwqC7ZfK9qVsHVO3oCgfh82XkYNQbLPiiRzDmtNlufejaIDno Uv2ysDv9Wc4ww== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BA893625F3 for ; Wed, 18 Jan 2023 10:01:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="lo9G4s1l"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id e3so23962098wru.13 for ; Wed, 18 Jan 2023 01:01:20 -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=XEl4otV2Go+V21qaL70bccDWfHDHc7iqcSfag6Wgyg0=; b=lo9G4s1lzAj4ZiD8InZ/89EoDTI4Fo7rm1b3Mcy8BXPmtbGzK3VzGA654m1/reHUND eYzKX17EkTxmOLR0gvNbn09jOIcBSEltX4fBPeOt3dpxXzPMXB/+q01DsKRQ5/mG4JYv 9TnvSfwOW12PUeSMzV8ElO1e3vUFZSgmYcH8N+GFNswsPx7F+O14bbhonekqRTNoOHP8 eUsMEril0UYHrQv0c1QswWthjYyKqOPPaDjF7T6Vv0eDh3Ubbhvaw7T3aObrInJxRCMs I//YAla4y/r/6ZlQLdr6FCHFvfC3irXfXfpN980retqpPq0cQ75h09roCj/7xiU0umJj gUsA== 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=XEl4otV2Go+V21qaL70bccDWfHDHc7iqcSfag6Wgyg0=; b=hAFP/wRzk0pM3H71HQVpAJJpdODUWP3cV4POOwKtjAIkdPXbaJYlYOziWnNGAB/HVA wGCtySN95qOwHpTsRv+/ksWalbliUMXyBA6dY23pXA2XjK3I1RcCveMBYgzva+nZTgUJ sI/Ss7vZpVcrKojEq7GH9Vpx3b8xy5cEcknOmCL5t/rKWJvwwu4k1C25wLW41fToGyLS ODg7YEX+sRZuWICon1b1YHYMseikvZqwG90gQLubL1l8Mv50iHHs2aCaFAK+faOUVepM gxktAMzvvxUG91jJbGqDbSBxqW62aIAm9F3EuCfUitnPfYlY49/pu1As8+uijPs59idl +glA== X-Gm-Message-State: AFqh2krqHtZYyODhxr5pMbc+c+O2bskFugC0NanHU5gt+cYl+CDUrW3q ww+lshXG6K0unJuei9OW7izgy4BwHC4EOc905Xk= X-Google-Smtp-Source: AMrXdXv0RhUSuTIuoAnsK21m0wa9spfyY3GyWK0KavjyJP2DbeRFw9R+6058gQrzrRjbYSaGyQrayA== X-Received: by 2002:a05:6000:608:b0:2bd:db84:d663 with SMTP id bn8-20020a056000060800b002bddb84d663mr1729047wrb.5.1674032479875; Wed, 18 Jan 2023 01:01:19 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:19 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:48 +0000 Message-Id: <20230118085953.7027-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 6064a3f00122..59e8fb18c555 100644 --- a/src/libcamera/pipeline/raspberrypi/meson.build +++ b/src/libcamera/pipeline/raspberrypi/meson.build @@ -6,3 +6,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 6ed4cc2c7ba7..2b396f1db9b6 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -39,6 +40,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 "delayed_controls.h" #include "dma_heaps.h" @@ -1150,6 +1152,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 @@ -1683,6 +1686,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 Wed Jan 18 08:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18133 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 52ACFC3240 for ; Wed, 18 Jan 2023 09:01:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 17AB2625F6; Wed, 18 Jan 2023 10:01:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032486; bh=vuQseQL50Web6ilc98fPnTOnE7PpKyM5XiUabaPa4xo=; 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=ooUHbqq0xII44hCEuEO56EXWLi4Qf33jxeDU4yMivB50tIqZUVVVTSy4SnTEbMemo I5gKl+/2Z21y4GGoZaQAIr1xXOD+VvYgHStlRTekTko3s5FjDCdW7pdyhRc2XuyCGB PHO8Y/BdXP3uje60iFuR5k/ehYi/XhxQgjLmdAVGENOO81m636HGef6VZkXceA86lx JQ7JBTPrM992OHEx/L+26mjj9NJhbRvDBNsFNtYTICu1lnbeiB3kbgWgKmrsoPXcsq S6DFivBk1P/yZuKq/cxNyRjd1aBrPq1Zyg06FaZuP/1U8CvXmRKh1+JlrUArv6Ojs9 8EtMJpjPkWrtQ== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E13B4625EB for ; Wed, 18 Jan 2023 10:01:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Qltgl0TZ"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id d2so13062029wrp.8 for ; Wed, 18 Jan 2023 01:01:20 -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=lnM2OXv07hslcltNdshxDVv/HvxqNMcVEFP3wRy+Ugo=; b=Qltgl0TZBMLdGafULXUJj2Hwwf+1YA9LWbkY4G4kIwnQT1TYu8JqQIMi+J80VnUWdP 5K/q0fs0Ae6pvw83FoNFbABm8pMhj4CdJopzHAZ8dVJp4zHnSpjFzbJjzmN8IeYM1ZUb TsKkcGPb9tZ8ZxRUUX/VCovGx1zgzmeL+ycGoAPsFW4OU6eJCFZK97g1QyAIw8WyhaaA eKkO7V5vm5wCIBfzrPrPTYs2bzqFP8oLt9lKN17TJacDVmSs1gdPUpksgpDREumVyVpa I52BOVWUXjq6lhhHvlQQG8MJ9cLq4+yIvUHM/GL2Bs8WMYZADuWKJsVEcosy3MKDnKDb HS0Q== 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=lnM2OXv07hslcltNdshxDVv/HvxqNMcVEFP3wRy+Ugo=; b=Adw34kM/1LPPxIo0KaxF6EVTHst6wF5jfcDErozzM0GHB+Ec6p0GbChlzSFexGCxOg q/Y+BdNXx9Sz8C9Yp9eewP1ADU5/3getwzCvGGCgox5SjhgkQYWki0FeEI37Hwu9RPnm 8lZHYUSnRIgtvPHzxegxLHcs2lOIMTYE+5Mq2b6WuBz7OcfnPYacEv5YB+xGaqDmPr59 6grWlbmClRwBvUUQPP/0LSnoRlzOv6QXoC6eBrvKGETEBuf5ZlSkz6n4g+zGhe09HlYZ 5/Xg1lo9XN62wD7UhuD3n2j0zdr/5463RnHEdob5hh3TXvpKT54k37Ipu6W7fn7zvC7A 01+A== X-Gm-Message-State: AFqh2kpryh0B5k5zLECPoRjjhvaFmktUtF5XSIedwNxuxVStDe5Y9UOI DTmN88ctnyVxLObaD+AWmbzacDYXih+IyM91R6Q= X-Google-Smtp-Source: AMrXdXt9suwAefXVlT10YNjWMX7lLwygBytFKPsrv5eJbh/NRdHDt8frAZc1xBsDWMG3STqZ2e1axw== X-Received: by 2002:adf:ffc3:0:b0:2bb:ede4:5dd4 with SMTP id x3-20020adfffc3000000b002bbede45dd4mr15286388wrs.34.1674032480448; Wed, 18 Jan 2023 01:01:20 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:20 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:49 +0000 Message-Id: <20230118085953.7027-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 08/12] pipeline: raspberrypi: Handle OptionalStream 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 OptionalStream flag in the hints field of the ISP Output0 StreamConfiguration structure. If this flag is not 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 Reviewed-by: Kieran Bingham --- .../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 2b396f1db9b6..13d0ab4c4968 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1453,7 +1453,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()) { @@ -1477,8 +1477,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 (!(s->configuration().hints & StreamConfiguration::Hint::OptionalStream) && + !data->dropFrameCount_) + minIspBuffers = 0; } } @@ -1514,12 +1527,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 Wed Jan 18 08:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18135 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 22F8EC3295 for ; Wed, 18 Jan 2023 09:01:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CACC0625F5; Wed, 18 Jan 2023 10:01:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032487; bh=wYQ9Gzq0mgdNx+u92NePezXNkFq6y5MyqGIMkKZ4dww=; 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=D1NMJBl6OVEKOaYhSv4Bx0kRVmLl2mkNrBScf/Fjussym4EKAa5lCcCZXklJOFBSl adn6q2O5cnR46EVuMKtDo41IcdjKIPzg6ZngVVdF2ruxpt0OuhKCUxFHdS5fLDpzSC Mrd3yPaL0uuOb6P09nFPjiun0BH/WgP2lO5gcnfm7+5wsuJsbCWeGK4Sbg8+j5RifY 0ZXB0rXEIKaOtmza041kY3E2kqSlHBVFWFcaGOoNyWnyKnT+9Ppd7go5rAP60ong5W fIGaMmZiaS/qJ4DPD7twc4ghY0MIl7N3uNAIr7LYbtOWGD+DHQdKbmZrAn+X4l1CFa /3kTs1sn/heLQ== Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D3891625EF for ; Wed, 18 Jan 2023 10:01:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="IQc4yoHW"; dkim-atps=neutral Received: by mail-wr1-x430.google.com with SMTP id b7so7192328wrt.3 for ; Wed, 18 Jan 2023 01:01:21 -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=6pw3j43ulVU5D59XUCkB3/cOw6PKc1joLaWHRtaeVno=; b=IQc4yoHW58QGQwL601r4DyATNVQpXjJYz1gFg/YrMTw2F7+78NhfjrInVvLzzcLwzO 2sVgPj7hIAC05DoF7RetRQTArF3Xv0WcWDNex0u45W7Lut57m1K5vIxAwSlsGOWwdCGy fbmISNZLpABfQ0dHXax5vsJog5aOH/mLR6WHCx7yRLJ/t4RUfyfpvLjd8pToRosIGOH8 tBeaIoEqZlA71lQUn8j04odmRxGEXYE8CgAMg1enk2jao7zmGhcmL2ng7l8X8lCzrhwJ n6EwZnTiW+DaRzJrX71qv5pqc2BYmXaNkRv8FgYNIC3noJ0uC+6XE6Rv20oWaTvCj4MN UrfA== 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=6pw3j43ulVU5D59XUCkB3/cOw6PKc1joLaWHRtaeVno=; b=RxlgDG68hdlpH/vYClXQY6YDKO+8IYMUfRSY+aEqPv6Nkvlg5Msu1QJxKURJzK+aOs 5sXZr6/+DAyveufk1fFuonkn8l0k4a9PfUJhGmzxCwuRgGuZzafzDx00gDi5YyJUuxJM Gmjl2WyHwYS0fbBO8E95L+Qg9garsCzU+DVyas0Fv82vXf+1warePOpJH4b/JiQ41Hef fZTp/vmOtXkohhZoVKnhTndPM/3aIFGfi/KlKYs6+Qv2wnyUqyZPAfBjMyj6gCgEVPqF izwTAdjeA6/SF8HCIJwV5URKGbSXngmoRXw5ndsU0NM87uM+4V4aZI8jQXczq/0RUrNA /OGw== X-Gm-Message-State: AFqh2krKszHHeGBi6TzmkY70C0kEIWqkKfC3W8T6flmR542UJRZklXp4 ApW7/sC2F9gCsfSKp2UhevIfFOqpXwaBs2SEb+E= X-Google-Smtp-Source: AMrXdXsWXoQMxaNwJV3sBROhppPTSkiKlACiffhbUBCIU/qkc9MaERQlDwhXyOuCZDTF6LPbWcMAUw== X-Received: by 2002:a5d:58db:0:b0:2bd:e150:bf54 with SMTP id o27-20020a5d58db000000b002bde150bf54mr1442418wrf.60.1674032481120; Wed, 18 Jan 2023 01:01:21 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:20 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:50 +0000 Message-Id: <20230118085953.7027-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 09/12] pipeline: raspberrypi: Validate OptionalStream 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 not been set in the StreamConfiguration for every configured stream. Signed-off-by: Naushir Patuck --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 13d0ab4c4968..39f48e0a57fb 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1153,6 +1153,13 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) stream->setExternalBuffer(buffer); } + if (!(stream->configuration().hints & StreamConfiguration::Hint::OptionalStream) && + !buffer) { + LOG(RPI, Error) << "No buffer provided for mandatory stream " + << stream->name(); + 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 Wed Jan 18 08:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18136 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 BAC14C3240 for ; Wed, 18 Jan 2023 09:01:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 63D95625EF; Wed, 18 Jan 2023 10:01:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032488; bh=xWEJkF6fwmg+ej+XN2M6IqJL/P22tjDDj7dvCFuyLAg=; 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=0emIc8dKJp+Fvxt29RXorP8KYQccq/27Y+u71oiSsn401cW/cGK4FSHWa4plLSddE o7WM9I/bG87l0gg9OK6eZWd71n3UK5JAokVXifOyaLlTAxvwFFWXp0lJvaNuHN8f78 0EbzWyAE96qBVvq7KoKDvTA2zjQImQg3LUnUxVJJiWMHfSQ0AHQgrJwG+L8UL29W2D MnMwPZDhFv0d5NPFgN2V1H64woPQ3hj2QNMySi6bMAhNIvWFvn88007BGcYoqxiwnM yic5VpAiMQtH33gSrpLDdNl3hZNRaba+rsYI8ANFcHVF52pE8oKXR/mIHeKH29r2+9 d74dB/c7qwAxg== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 56AC8625F5 for ; Wed, 18 Jan 2023 10:01:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jd+8h6CC"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id d2so13062097wrp.8 for ; Wed, 18 Jan 2023 01:01:22 -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=Xm9A0Dc0ylC7MuHawpOh5lFzItkxnCtpqzdPfEfou7U=; b=jd+8h6CCvQAhG2OxH29I9t6kXMUTdqkzE4jTPalYIrBaxF03Eol6baf2x7n/JAnTzg XZ8F+3CMsKdoj4sWnc9Us9fOPBa/AuoIfD2keVA8zceRZjhiXUvEYF0p3g3g6P4KTILW 8EcPMxspfYWMGHDpaVJPvOXgWjnuhFcKufYuyM+5mIl2dpkbwuPRy2669rK1aNZLS6fc T2aBva7QrPvjrdHESXDLIgdgcy/O2+ZBRcxeUymzkDPKtsmWAUv00PgoW2pewS+308LW dyGutZvop3zkgQ6Z9+JBAdGGz3tUwPXIpLuZjcnFflHJJ71Q+ClWGImLkMCvuLgLufqm WLPQ== 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=Xm9A0Dc0ylC7MuHawpOh5lFzItkxnCtpqzdPfEfou7U=; b=02isU2CBxC3uoVVkJk47YQxWUPiAlf5CwNy6ZGs8dJxIgIGcD2zc1MvhrLHgAgLXao Wf5m31MPlGyqQEoFURHfmjTwMCjIhG7gQ2wBtBxYWzVIpTMgNK2AjTbMp1C5k0RGwVSm dhC670sEhzEfx6jM7HlhDGmhcrmBjn5Afu2qYp8c4rsxHKtEwJcpy2RidVHuUEHWO0jX 6s+AFDMFaIc+qJqrC0bAnfKYPhCY0nEyGu1dw9nJ5pkOWMnQXKFS337zND4WZnO2Vsvm NTb9/omy0JcZabMsD341/8Z29aSXIpsS9bc6UEmDjUNXBOZRiRaC1HZwq6n3wE0EIAxc EFyw== X-Gm-Message-State: AFqh2kohQghd9HR3S1qybyIfeFdFH2ujlSjWvNNoSyKnOkY+CbbxpuEb EiAJqSR5Zcet2TQFHis+sG0cZm1B5UArmAoZzVo= X-Google-Smtp-Source: AMrXdXtiJNJdZBQDplNOt3BDxK/f9XlMjgLEVFBxpY4YlmgkLGgYOggkZ3Z5Rkkf8xigzaeJ8EMgrA== X-Received: by 2002:a5d:5224:0:b0:2bd:bbf7:1f87 with SMTP id i4-20020a5d5224000000b002bdbbf71f87mr6124530wra.60.1674032481781; Wed, 18 Jan 2023 01:01:21 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:21 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:51 +0000 Message-Id: <20230118085953.7027-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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 39f48e0a57fb..3529d331deb6 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -309,6 +309,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_; @@ -1053,7 +1058,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 Wed Jan 18 08:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18137 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 4A8D2C3296 for ; Wed, 18 Jan 2023 09:01:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0967E62608; Wed, 18 Jan 2023 10:01:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032489; bh=sxi3z4CTMGPw3NMx/xRPBi3JYi/YJTSm90v0e0/aqNQ=; 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=dogR+PUbd1tiw4QXZ3o7TuWbMqak4Djs4JrsgtvgLSGlN5rXBD1voDJY0COI7nR6q z7HCoZCL8aVbSM//h3kuWpp2cs7vhDvmVW7Hmz3c2/5jUcc6akroK5L/kqX79Ou4oS XoyhYZE5CNjFVcCIV4EMSdOuUYSR2zWyfS+Vs7tNkbMdf+/l2pB8FjpGY8pi+AcAZU 3UeqATeMA8G3UKYVA27zELEF4BHAvElb7nxY+SZo/8Qrd26Ft9FN0EkMGzImITP9Sz GLSkuuYggO+cIYOl1jTEbgtEzF54SV3You3NKsZA6hrjpzhINVrIme17SjSEpMJnqM RCz/X8GK8okbQ== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E4C1A625F6 for ; Wed, 18 Jan 2023 10:01:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NAA70eWv"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id k8so18695011wrc.9 for ; Wed, 18 Jan 2023 01:01:23 -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=x5JG3wUYq4xcmcSB2omZlxtc+5jDqfCvpE5cZCfhkuI=; b=NAA70eWvMXW3R4n46g7aj5SLm1aMljJfsDyf0el2wCEVwhb22nddPOFtkazHA3yvSh I7HOqGcxzG/WwsJ4z7ClBn7N8r6hvQDuXSfX3f6q50jUKEjWwjbNPYCJRmcgXE2Jp4Ik UAFLJ7qWr5t8DGtqxD9UBmW/gaHyvAA+xEE7EqN80WT7KNsckIAdOfn2xnmtzoXKdkAe fyzL4YLoZL9ROD6ndpSXqaH3wNZgwWK8JZzbuyqOmlXpORNwl+msPkBBbuqEi90ECMs5 6UxK4Wvj1a7r+SXLDFpbP7QbXl0jFIGHyEfGDUEVUWiZCTiajJwAifQPUtGx92XQmeSt mcSA== 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=x5JG3wUYq4xcmcSB2omZlxtc+5jDqfCvpE5cZCfhkuI=; b=FhhoxeBo0O2Kzk7f7uKNAq5eqguIaGPONO33RZNggRdzN0NG/SqQaqlyACVRD/uCW4 WorY5uBKNjeDO5V/Wc09BEjjtqVSF401002X95p1XlXBJbI/ISXFxHlm5YSss3MCOnGj 5V4Ki3GHWC38UdxDvPJTgpRebD2W99nnbIeP5JfLmTG1D+tpx8BvDQ1vC3tpv5YuWHI3 zsBWB/ZdYf6X9KKU+aBzfG6NXEimxCuLBwEvWA/xsIolEsMPEYZU+oUzyZK02nglRvVo 0zIgCEAkvIiOZQu6LGorftZiR7BU3Xk9+pIWzM/3/obk38F+tIo0sQ0Km4q7e/DO3ATr lZYw== X-Gm-Message-State: AFqh2kpYDFSDSsnZEXqceRn81k1FhnDx4YUdASO2/jDAe0e5ltVHZbJF BYgNVfNhVxxPomz/ScACW2U0764hfMI+3U5LJ20= X-Google-Smtp-Source: AMrXdXv1TQRZXy0aliKibyoMNdZA6o1E3QY9HYnqxll0GCY0UGJKQyX5NCNKjKCTl7xChace9MfU1A== X-Received: by 2002:adf:d0c5:0:b0:2be:34fa:7bdb with SMTP id z5-20020adfd0c5000000b002be34fa7bdbmr373198wrh.39.1674032482536; Wed, 18 Jan 2023 01:01:22 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:22 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:52 +0000 Message-Id: <20230118085953.7027-12-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 3529d331deb6..21edc8e05469 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -314,6 +314,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"; @@ -2329,6 +2337,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 Wed Jan 18 08:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18138 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 E2DE6C3294 for ; Wed, 18 Jan 2023 09:01:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A7127625F8; Wed, 18 Jan 2023 10:01:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032489; 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=iSmbQp5s4EG60Zl326abZxD5r3vSYghEDST0jjNP7XFA8tkH6qhU16fUt+yMJumDC 525zcN0kV3uTmYu7sSx1iBjXEwRiXl6ZyOqDiaHR+tm9zm+F80+VZ6+nt68ARLnPvh 5LwWoUw0FDZpDRz9IK5KKHINbDdRfBDCJx7HWsrJ2nMrkYLUv8JHJodu+It0FE2RBt fWH1nHLh3PgF0/1MvVw8Max24QWBrIcsKqm4zNp7gmZ+lYCuKYNEpkj+ktv3P6vOrH 6yrNWDluwg22zsDTSXE7b3Oxo8H90yYhn1g596EWg5d18Eg2oa7nQcQJ/QvRUKzw8L GzHqiXjAZ3jjA== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F8CB625FF for ; Wed, 18 Jan 2023 10:01:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="tvfctysQ"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id d2so13062185wrp.8 for ; Wed, 18 Jan 2023 01:01:24 -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=tvfctysQOa8FpzKUR4vVKGBkyvciMZg2vPcPJY5TmvicTeBvFRzKlRin4ZJSnRZ7J5 DCeH6XT34/Cw4aYtymdLCYo+hzxLY8sL08HnH5jWBNcFFFA/7Ih+z2gWreDX6avhkbFU DBp4SDqryRkzhyfb68svoWyLcYQXvDmIWcK9HiaLKhPKnPtNwM+IiHC4aWvA1307GKzv r+Gu8MTImHWZjuGNFCN6knD/Yy2WAePkbcmIvoX4hfUeHmpMPILg06whYADaFrM+xRXY 8NVpLLXuJKmRkmADNBOvbjSgLluQmn7Q/qUb7WU/bGux2OTnwceZqsCw5hqnymDqxNyR Fc0Q== 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=qw8aYXiOGVZEC6g+4Sk3voLa01vwDXd2grO+tiI9qeSh6z1hzW4NinBH8ah1SvHZOE 0TGHLCyCtVuSZPAf3fZn6EkxtFfZNQg8cc7+r2mqBYWEncu3MBo0mwbkGkZ+d/eOWMxy P6/iB1T7hjJNpzMis0Rdb+lsi+gvqP+riKBP+Fq2ZyeTxK7M7gs1A3rbmqH6fLUNeMWB le/40t44wQEDSpp7rEAxCsmE3mmzLOklADzZAs/dQqCqebhKDSDSsKtE9vs0aa1btG2d LEReUHJE8HT5K3GZMyS+2w/aIrpZ4S840Y1VpjjlDJRKRdJSLwhRCVXGwFGvAkfbwpBr ytlA== X-Gm-Message-State: AFqh2kqLFE8/djXwba+X8VdZfn9gukVct69FaYCZmgRkzTZX6PexA5m9 q/vR6R0NZ85N5Ks379UBzWWRYpMIZ+PAPZgMP+w= X-Google-Smtp-Source: AMrXdXulM0i2nh8gD0yGuMavAinP9tEMBPvFCk/ZnsiiS8n+4eK2wolUu3sPCMIx3goY+7mVRCMgUg== X-Received: by 2002:a5d:4dc9:0:b0:2be:21fc:ae3 with SMTP id f9-20020a5d4dc9000000b002be21fc0ae3mr4194808wru.11.1674032483651; Wed, 18 Jan 2023 01:01:23 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:23 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:53 +0000 Message-Id: <20230118085953.7027-13-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Kieran Bingham --- .../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 + } +}