From patchwork Fri Jan 27 15:43:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18201 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 2E66BBDC71 for ; Fri, 27 Jan 2023 15:43:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B6AA5625EF; Fri, 27 Jan 2023 16:43:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834218; bh=1NQfkm46gkmlgegsWn0lnrEGMhw+21+M3ZnxqhkEqek=; 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=E6D3sinvRJQkc6Je7MfllTa14o8AnSYRY1tbSu5mmpvwGEK1JjUVFR3TizOFgZi5L VnXYGFG1lW7YS5xSKba7RpyPeRDo++aQHSdgDp4yBpSyL6WOekgwprXqnwcVbQn3XS jOZfXR/0tDe7Jkbw4ODJ3EjJ3oReX4v5x/pJ8TKhFeDv0MnBmHJxZMybVhVKMaAQTE CBR4lZYu8lxoi/EVSdf/DihTjisJMyDQLNUgLHiwz7AWiGX98+j4pHuRZTpEHNwQwv P91CSGT4T6x5zEkMQSBn418pBN60ADpTyQOLGikeSRgjxJ4aMh0eGjCIyXGgUH8sn7 Gnc/0pGde/oSQ== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C9ED761EFA for ; Fri, 27 Jan 2023 16:43:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="P7KpJQoO"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id j17so3774841wms.0 for ; Fri, 27 Jan 2023 07:43: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=/Puf9MTPyfFZF0uns/wRRwCfjTobp9ecB2pODryenMo=; b=P7KpJQoOjJ2vx0fX3W9dIWcNfi+GU7vxE5Lf5FWj39Ervrpt/rVHOLJU2uTsU1447e 14aGQyfghDdnNW9Jvr427W9wkK0XakGzC1LuWm4tT8giyguxp4Kb+vNuW7K99oxsuEeA SXoerMFy3WpndV8sRsFx+4pNSDvMfJJZgtkoEoxFBboO4VY5GFn6W0qORwT8atEglQxd GF1NwzVCknXl//3RLjnnkb5xMJ9eAFarFqnzy0CKnkRW3I5nt1aaBarV1pLRnyYclE4h SfH1fUXbR8aVXtzm2r1i3QBDItUwizsqTy1ltZtQ0+cppe89voUpWbyQRXFsVGNK8e1K L7Dw== 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=/Puf9MTPyfFZF0uns/wRRwCfjTobp9ecB2pODryenMo=; b=gjyLuNvdq7VVx2lrEuT51T9IrP7swSCrFipGQOBpPhN9Kf54zu24PBdvBtnL+l/Ve7 9+Ek6/awdGIOK9b3kW2+g4Bir/MZek9BKYu+zEVsexOja7P1P9Cz1cKxWJV1Li7Tj+bH WYsAI0Tr9pux9Faik0u5HGiwEPz6qPhSm/igL0+KdFoCXk81RC1iXOro4MMV1rDes8UL P8s0AM93RwZ4reroKFQomravHgzpOS9FVHOxnOKPS7QfvQUgYetA+IW9Qn8r5iIbYbjj YPb2fk9ERfH69cVnBWDP8vcX9W4g95X1inhcKPK/cFoLmeRMPhZMjQyDizatC2BIevTi BOFw== X-Gm-Message-State: AFqh2kp37LO8/yTV4WC0C07o9guZWEVl7wZqAw4nFDCzA8Z60xflCmLf sFxJxefITc2yoi1mZdUuc+Eb+sFYk6k3N1r1I0s= X-Google-Smtp-Source: AMrXdXtzvtOaD+rMRwXG0xawSPbEa1lBz05TMDWpkaYIPvnDWr3l3VBND8ATCZvDyzzDGO4n0swV+Q== X-Received: by 2002:a05:600c:5114:b0:3db:254e:59a9 with SMTP id o20-20020a05600c511400b003db254e59a9mr31104326wms.15.1674834216045; Fri, 27 Jan 2023 07:43:36 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:35 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:08 +0000 Message-Id: <20230127154322.29019-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 01/15] 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, MandatoryStream, which the application can set to inform the pipeline handler that a buffer will always be provided on every Request for a given stream. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- include/libcamera/stream.h | 8 ++++++++ src/libcamera/stream.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 29235ddf0d8a..56e5a74b2aab 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, + MandatoryStream = (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..9b0e8dd548cf 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -349,6 +349,31 @@ 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::MandatoryStream + * Informs the pipeline handler that the application will always provide a + * buffer for the configured stream in every Request. This may ensure the + * pipeline handler does not need any additional stream buffer allocations 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 not allocating additional + * buffers for internal use if an application guarantees buffers will be + * provided in every Request for a stream. + */ + /** * \fn StreamConfiguration::stream() * \brief Retrieve the stream associated with the configuration From patchwork Fri Jan 27 15:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18202 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 DFA2DBDC71 for ; Fri, 27 Jan 2023 15:43:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D459F625EE; Fri, 27 Jan 2023 16:43:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834219; bh=MfmJvw88lgHQVnelEqUJ4gx08aFdQMY340f3rWJzFOs=; 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=Yp6HxVVrNrnTVY/pL4o7+Q6kk2QjBR/pvMl/on0S8Jn7QxRVxyMU0uIPhdGCnWwBh ITV89XcvwlR/DvwSgepNWHL/qo4HS1fPbcaH7MR5tHOxPzwPWumF9LeNOTFSip4AJa /heU/bUYt8g6r+N/vBSqwYm4bFELw/UsNfX22OXh0ymgI+o8EecnsLjB7XP5aW1GPq Dvjrk4digzmKAfL1s+4TtGXa+bGdHiHoJdlge7EZRuhrxjs047D0hVOe50DHiHxCK0 qO+RrGJYLx6VS1NC5h4xFgB4ahHcZ1gmn2mnXmN1UWbw5Atsk4bai+ucwl/J4bpNVT jR8qV+QxGWA+A== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FFD961EFA for ; Fri, 27 Jan 2023 16:43:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="S4iRAzH3"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id k16so3747561wms.2 for ; Fri, 27 Jan 2023 07:43: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=qg+Vovpm8IQXQFF1XiND9m99lJ0nfk2ofAAVcmswMfM=; b=S4iRAzH3jrPcocHmUeObkuojnJPeXPAesDgmyAJcfXmzFa2NyI6WqkyhRPrx6DaIT0 aVHCMgqt+apB34+NJpjCdS6kQICSzCfN1STprTMfxnKc2l6rWCWfiPB2jQtjQ0gawpvb x94YKvxS2XxvQ+tM8fGlJnjarChXBsD4zvdVGosa3h2eDxMkrcSgN0+FscGYFSjjMQql b5RbOBDiiUNwhII/NOEi4ktr/teXPm5wcgwZXzPaELyGL8C7yWFEvOlq5ziPQW24KmVO K7OwfReTM+qRU/dfXQtuO0ur3E1yuwtxgb/cqCM44jaA+zsdr/UNN5Mh5UaFfsBazyQh as8A== 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=qg+Vovpm8IQXQFF1XiND9m99lJ0nfk2ofAAVcmswMfM=; b=B8V1VoxVIyYipowBX47czGmi5vXZncui1NAVpTq79lfKl7jHD80qNz9A9otjzsfHN/ +bQpgcmu8eN3bM0rL0+qB8E1To9nL3LSkoXkNI3v3tT5/QBTsLMVME6tJBljy05srvvb 25KMaytm+0w5dTHD8UzJ0DGYQLUB3SgKTuC1mJWRk8kruCToim+SfYHqBROygCQSPT4P IVUiwQsLQEtmn5U0CXusxhwmW1WopoJzLz/avynKh77JeUabNqbC+z+B/tNZq5Pa+qR3 3sbifid+zLMfBH9RFd9nTwHtXOT7GpNqB4W6LA02caVG40JqXLuWTHvqlNvp8ZAnz8G+ hjHg== X-Gm-Message-State: AFqh2kqTKKP0r0OhCGtS2DA0tU9A9tO2hFmtDqWpMBTOmqBBrf/Zd1ir AyQsTvRBtb7slUDHh4P4h1n8jbI0ryYAByP6i3U= X-Google-Smtp-Source: AMrXdXsspt+LX0+VLrE0D9IbxQ04g+PsqmFsUNxwecF8uxY6LH8Py9dXjLvMCU5weFTrGSyNjZ0pDg== X-Received: by 2002:a05:600c:3412:b0:3d6:e790:c9a0 with SMTP id y18-20020a05600c341200b003d6e790c9a0mr41633639wmp.10.1674834216641; Fri, 27 Jan 2023 07:43:36 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:36 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:09 +0000 Message-Id: <20230127154322.29019-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 02/15] 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 | 57 +++++++++++++++++++ 2 files changed, 60 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..f72613b8e515 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,62 @@ 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 << "'"; + } 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 Jan 27 15:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18203 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 A8A57C3242 for ; Fri, 27 Jan 2023 15:43:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C1F90625F5; Fri, 27 Jan 2023 16:43:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834221; bh=fjUZ2Y6M5SIvy8YqXeyirbL4bFJ8DM4NFQmHEKWK8To=; 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=X7E46+VC9ppAYPqYf3jxlELbXC/Os02fJVl8IW5t4s7RQbV8+L09dgWDdOy1Sa0Vw XL5GClOn/Kwwt8F9ufxsIsvXUrVchWU6/ahVZAK0IdLFjVbXp5PH97tG1+12Hj7EYz Z6AS0UotHemf7iqAuuD9DFdIOhztye564DWjDRLv1ZmUTl/vV8eJ3Ague00ghy8pCR K2HdgSY3BaHC3isFr3c+YdL+XFGfoaZVtQC7Sh/hYfouFtH4kd6mkR04/rhfCVmuHG zmuvuzIWlIU3ILyst7zLiZmR1VphRfG1m70FKuuwAuhgNtB1mGzHwP1YGO2liAeqbh 09rwS6ZUt6m+A== 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 0F87E625E4 for ; Fri, 27 Jan 2023 16:43:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EGTO0cRc"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso3769627wmq.5 for ; Fri, 27 Jan 2023 07:43: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=u6mC/hSCt4w6JopK/0knsJmp2imtUWG/I8MNT7rGc+E=; b=EGTO0cRcPUjRMRyx4hgo5vTiZUsf7lhz0HBtXYRvDsYZW63t8WA8UTsANzT+p5K94o R9t5TEVKe8PJ4jyaJ28qh15l2h71roVueMHl/fh7FkF7VrwHOx4UJkw7kpzByruTb49p u0Xh30ltEqp6lN7ZwDS0BB+/gWHu7gTvXDy8gfaWXFF8xo3F0Nk2qzCej1QqOTeki225 YfcTQDJuLzZ//imjmQHuKwM/FNdGsozFVjhbhIYOHLOpW+xzkbng1SQLV4qoMQq0JdOK o88IGvV+wvM2GdO6zpT/IAkiwbE5550MUNkKMheXeMFKwG3CKysCH8pBFOpu9PwMhAw6 UReg== 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=u6mC/hSCt4w6JopK/0knsJmp2imtUWG/I8MNT7rGc+E=; b=xT+lHiTM8LvQKQCKL/MSgGoNkCATw2y2BwTt7ic1ohaoEnOwGLXEZEA9tMFBw8WpkW /+Hxv/CYBj68z61/Tvn3AR6DytnZE+kOaNozndXi4HPfjzVks3WbwCx3sHOIESlZXdJ4 8lR568Zfp59d3kxkSmGoBOaIcdMrw9AxYWrdKRXRiAnA6VDhA98kE+sTo1nSSr3/lwFE JDhYUQbS2MVQVUAYF/jEUyQaPlzHDAhXFEnHZm9y4eG7fRaFNOGwHlIfTd7tI4aNa7nd 1LD8UMp/ucuA3HP/o1gtiZawP4IHYJ003iMwc5tx55mnYq/g2/Kv2Qo9fDLpJc9EUiit JbFg== X-Gm-Message-State: AFqh2kpn3hhkWQJgDe3eV9lJ6mMsuPFNtZGPhx1KTrmXTOyai4zVSohd c/D0gDIKbN21ChP7mtpsUSxY6DKItQT9lP2p7dM= X-Google-Smtp-Source: AMrXdXtBgoJbWPIeUcATjnIW2zj23eZa5z6rSLhmXQ8VguqDxyvGZjbP4pFZRNOyjfV3SdX8r/8+Cg== X-Received: by 2002:a05:600c:1d8e:b0:3d1:fcb4:4074 with SMTP id p14-20020a05600c1d8e00b003d1fcb44074mr41551146wms.22.1674834217306; Fri, 27 Jan 2023 07:43:37 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:36 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:10 +0000 Message-Id: <20230127154322.29019-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 03/15] 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 | 53 ++++++++++++++++--- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8569df17976a..9e959782d310 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 loadPipelineConfiguration(); void enumerateVideoDevices(MediaLink *link); @@ -295,6 +296,25 @@ 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. + * + * Note that: + * minTotalUnicamBuffers must be >= 1, and + * minTotalUnicamBuffers >= minUnicamBuffers + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -1378,6 +1398,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me streams.insert(&data->isp_[Isp::Output0]); streams.insert(&data->isp_[Isp::Output1]); + int ret = data->loadPipelineConfiguration(); + if (ret) { + LOG(RPI, Error) << "Unable to load pipeline configuration"; + return ret; + } + /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = @@ -1440,25 +1466,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 +1660,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA return 0; } +int RPiCameraData::loadPipelineConfiguration() +{ + 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 Jan 27 15:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18204 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 7084CBDC71 for ; Fri, 27 Jan 2023 15:43:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7C41661EF9; Fri, 27 Jan 2023 16:43:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834223; bh=z1bIE/e9vXtfIY1SAoNZ7ufuWwQk4rK8DoHrCYJLUls=; 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=x5i2yCr50G0FMNXzDo6UgnQ0bPDNeF81hZfUA19gJvkENJYfZKn+edcmX/DttH4qk qO+n8iGC5SZl7R00BBvWnDtwOrj96qW5Pp48FK4oMIWQY3cMyepYDc3wFjaPH/nezZ ie1gaH6KzM52KiRog2c3Ht4QxAaAhV3XyxnOQ8eTyVnhUhDkC9ld7Vqgf3YzPB5i03 1djwG5xAiYDjG8ytBD/pr9BBctMARf5ahWuactKm5W85uvhwDb0K514qsCRv7uu+Rv A+8nkT9zQ7ekbMUPT+MElriTGIauvXGRAaRkI4uxczfqGTP7liWSFspkyIDkO04iVF 1cBN5FOpmHYzQ== 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 937C9625E6 for ; Fri, 27 Jan 2023 16:43:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="myAdBZsx"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so5679063wml.3 for ; Fri, 27 Jan 2023 07:43: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=ebjZaGnHe6ttVotKHBzk7oVcPheV/bXS8hsRGk0E6Ww=; b=myAdBZsxMr1VwosKcCONkePJupMB+esasWDsaeNf69disqRmhXzXz0jeBl3CzqUXLb QxKqcJphZUBKpmzq+0b3eQR+YODU/cjt92OPNOtzOyOItQzSBR1UZCVvNDcsyG4JTskP T6kUsHnqZk4Za4/yMurjVvFUugFVdENiJmm/XP+um6MMZgN0lkrTzVox6HvX4AFKeehj A8LGlxj4o0VIj0aH9zzEqd3TzMl9Zlmcln4f5XwCpzN32/9D6henURq2ruaC3ho5LGpw EvazNmyo6Cfg1oIFI58AnPVi/X+Qylq3UoThBrsfR4Zzvh2zvX61+JbzbFrlzu5Jv5WS DOsA== 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=ebjZaGnHe6ttVotKHBzk7oVcPheV/bXS8hsRGk0E6Ww=; b=eRCirA38zujlb8oVkZomxbUSCsNxnQNDpvCsfUmw61pW0HKZXvQSgZFsIfqnIqpp6D tMsQGHod9m44Ww8qMAXY72iYjP+KrcucXMVAw8Hh/1TAb8kwglBwQ7eBUTuZ2wCbad6m FfLE05mjljm13M8goa8P1k1UWRbIw0NlcQtaJoVj0CuFhQJs+Cgm5J/0cfoNeFYf5B2z ECfv4aTb1sW8DTDigZlmcqYQiQAe0USHnM9NPckv7axzJH3yKckRbARf+gYER84Y/Yqt dB8PD5TMyn98H54QBdC9LsuN28jVkg/N/4/KEgQaSUnhwfPn5GQxTin/nzq/jWBOOQR3 qrCA== X-Gm-Message-State: AFqh2kpAq/HzRHBxddD1OLNHfCjLS4hKsgWf2PRl0C/T8cYlNzm7nHkk 2Yyo9gXJzooN9H4m/jz9Swqzi4xRVZXqhZbh7r4= X-Google-Smtp-Source: AMrXdXtyozZAJsU8ucpfaOkaHmxtO5BqLuSh4fksNAnsq5Cnh0J9akFlh92iZj1wkuXjZLUDrxtcdg== X-Received: by 2002:a05:600c:a4d:b0:3db:1d6:16f7 with SMTP id c13-20020a05600c0a4d00b003db01d616f7mr37645196wmq.23.1674834217876; Fri, 27 Jan 2023 07:43:37 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:37 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:11 +0000 Message-Id: <20230127154322.29019-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 04/15] 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 9e959782d310..8aa83aa76ae0 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1041,21 +1041,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); @@ -1072,6 +1057,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 Jan 27 15:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18205 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 920FCC3242 for ; Fri, 27 Jan 2023 15:43:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 08DC9625FE; Fri, 27 Jan 2023 16:43:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834225; bh=LSY3MtkRkonnhlfUVdGTa0WEosqs8kEbZpn/jYt5LZY=; 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=a8D+0brLNSlrtXMPTxP8iNwmOenJD5NwdakEo/B5yKQQxwXcl7qKyK/pNJOkCuZQn GtmO+f7IHrR6KNGzThzkMP0hWm/F/+h+yGcKzHL2eHVXesNdLwwVjNN3dmOYLnkc+G UedVKG1esAn9S3lTm4z++D13Wh0sqahOBPFVE2b9LH06KFd65YCV1HsW3SQg2L5Yc2 Ktia/uS46rC+Pf17G+0PPC3bYRMDQCr/yjnSkjHVG7wMn0mH/U1lVp5NgyooZvdrTu Y8PBE9EBVOC4XlA1FtFfeLxroePhTc5iJ5sfkBkPwjg6e+yazXmYTq/KnVg2PSrUll qtZfEDaFn37lQ== 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 DFC8A625EA for ; Fri, 27 Jan 2023 16:43:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pgE6kJY/"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso3769664wmq.5 for ; Fri, 27 Jan 2023 07:43: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=Gu7pQeRtJKEaZCE/Wr2FRS5oI/UGPEaX00FNTi5YwBM=; b=pgE6kJY/paPxzankVf1PJOunKzUYED3veXEDEpnt0KyoNweXNj6u9jQ/kp//BlIOah 4vNpkgbCvzHmDIeuPBo5wxy6zKNkYe0bVFfkbe/MzrKnDOZr1a80coyNFA/PYotPgf/6 0z57w789a+P7ZQjOWr1/HDMyTmLY7QU/ojW1B4mpUH2jJtiCum1UaAad+cqcbNtaZi+/ UZn4GKjhLTxhTjnLK1NDGYKh8GvsJhe3g8TeczHwtkbJeqx7Rv0NITkZC3ucZ4SCMZdr RTdwlPMf0xvxt4wt5mWpqfmbrjH3U0hW36OyRr6rLphrcJEZsPZzvtaHAScIWqwUuEzt lT3w== 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=Gu7pQeRtJKEaZCE/Wr2FRS5oI/UGPEaX00FNTi5YwBM=; b=wHWNQYcWdaHgNyn6514uDf1L3oMSYZc0Glc6vOXuQUBXxKwe9dAPdWNxhVg8otw/Kk VsH96CikUvhnSOD2POMPE9Rwlo2PCgCymqT9Ub2aqAZ3nx8E2Nmwyfo6jGPib9lWvJtw gkRbFniIxqTzMgbWCPS+cd28kHi/Wml+4mgj5ib1x16+91GTlIqfbw39VVwQ2lTdX18l fe2tEDHWZzU9+t41jQ+7f77deFwuby1bUEwaqFoyN4vRqoMsfuzrRhz8lC7FKbQeccXC YSvScUGywd8cNgVHx2VAC4J7sFsHGAAij2QbFgR1lJqNmtPrTmyNj7L5WgjZHo1n9ZjZ RuIw== X-Gm-Message-State: AFqh2kodKcOb57/UCGfaIR81xNN/KV8PzSb5oVpZcEdMe5CgmkupT87Y l3WMJ5hC94uoc3t7gFVSIL5D6iI7oMft4W+kZgE= X-Google-Smtp-Source: AMrXdXuV7SP6+X9wg7d8aYWTl4OQ/jBQtdAOofrGdwGio5YM0SymVnZsKerqlCMzc8+z5HzQdf4B2g== X-Received: by 2002:a05:600c:500c:b0:3db:2537:5ad3 with SMTP id n12-20020a05600c500c00b003db25375ad3mr33419995wmr.30.1674834218437; Fri, 27 Jan 2023 07:43:38 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:38 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:12 +0000 Message-Id: <20230127154322.29019-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 05/15] pipeline: raspberrypi: Handle MandatoryStream 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 MandatoryStream 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 | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8aa83aa76ae0..44b1727678c7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1452,12 +1452,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) int PipelineHandlerRPi::prepareBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); + unsigned int minUnicamBuffers = data->config_.minUnicamBuffers; + unsigned int minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers; unsigned int 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::MandatoryStream) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1469,7 +1490,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 @@ -1477,8 +1497,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 @@ -1486,15 +1506,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 Jan 27 15:43:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18206 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 2F1A2C3296 for ; Fri, 27 Jan 2023 15:43:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB57562604; Fri, 27 Jan 2023 16:43:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834225; bh=r/gOvMtU4dkipAZof9iQp4JV7jjgH1EBuDbLmpTy7AI=; 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=JE9D4F4AAweQyYmzhNK61efT+9c1hzrDoM+603DYAhnrdh3lVgmxINTAvBDe+/EV0 F00pgvu4CgkjE4NG/VdPL+CVYgLVfz2S8+HvyGqOu6qggHK0bRG6Ww8HhksVDausjn 4W0baV9wE9Q58UCJdDqNdrRFbkbG2HvnA+w/70cpBAhmKp1MPsb14/n7nBAxOOit+O UExLHEJMYOgYv3i9JD4P+LyBsEECxCXl6uNifH2sIxe2g+3w2LryGGPrlVWhqOO/MG 8rN8xAIz8SlNyTL0cu02y2cOe8amxfeq/Sbhrl3sDLAlaJme3bBGgxa6y00/CTBtiY XCzhiTGNsxs3g== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B58EA625E7 for ; Fri, 27 Jan 2023 16:43:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="GX/p2Ha2"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id l41-20020a05600c1d2900b003daf986faaeso3770072wms.3 for ; Fri, 27 Jan 2023 07:43:39 -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=BJ7gQdEQSZ+kcJWBPibTocZaCRrgd++19jEsBvGlJqg=; b=GX/p2Ha2w1H7qEwWBN8Az6IkRz2GdZvECIheZpDryT+AkyacZA5zTKBh5n9Cdx7q4v kkXKRQL/sxSc24A50BMOAi+Gly11ZRRA95r0FcUdEIBXIcepAzndl7OAxOF5udXIMxP8 XyxP6Mn7mIyB17O/Ktds2UpHWKHdtEuhyFOY5qMB5Lj06keuJ+zreKnNhRsNp2urUaAK fn76QPBKVKmD0EUladIbzNW1mqAiOm1LQsCjGiJV7z+rg69RjBQcE/S6TrKOpSlDHoe4 //2pzOa4JGH5RcLGZkPJQ7cNnrZ90IAoh2ADnQiB5iuCPfsyV1YpdzIoEO4/CGBPvexC qwRQ== 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=BJ7gQdEQSZ+kcJWBPibTocZaCRrgd++19jEsBvGlJqg=; b=4R5hHoIDSD+UJAGfUqABAT972sB6BgSUz9O2JpSgluRTrs5jT95PrfwCHBH66Ww474 2UfkxsHxu4UOULcDQItymXpxyevXSogG5HSmGeEyD4xgQn5sBfDKZ+794xp03D1U6X2d OhbLqtroP4OVigMftht0FzNUeg4SBHD2cIWu8RMeLls1HXQlBL6/ZnbdsL/0DzT5w5ON DlLJC+ZeBthaOjnkAclpSDXnNkp8oVcjvT0aB635ciji4oRZqIL4qIRtWk/kwMocMvt6 /YjmsD+i2vYRl8kJ1+4Sxyqaqv3RKhjv04XZ8wo3YiSezCjUuJDFwmqiLY59g68QnfE9 5jvQ== X-Gm-Message-State: AO0yUKVzWJyhhHJwnKYQJ0hq4c/9LOGFuFQ7luBXxX86wKqlu9EIfutH 47U7HIXZfha6HX+aHr7gA1I7nh7IPwSf3zQHAUQ= X-Google-Smtp-Source: AK7set8zWx+rKL3xr6vEA+jdvhOaDNijJzJnCXAlN/GUxOaDk/HxMaDbl1xLiIWUGtaHGGOTwy2tBw== X-Received: by 2002:a05:600c:3c9d:b0:3dc:3af2:79d6 with SMTP id bg29-20020a05600c3c9d00b003dc3af279d6mr2491900wmb.16.1674834219042; Fri, 27 Jan 2023 07:43:39 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:38 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:13 +0000 Message-Id: <20230127154322.29019-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 06/15] 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 Fri Jan 27 15:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18207 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 DB633C3297 for ; Fri, 27 Jan 2023 15:43:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56DEE62608; Fri, 27 Jan 2023 16:43:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834226; bh=/5OUM1/xRqXPdDagWUAFW17IXHeqW1pka9Exg+IwItU=; 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=avPnl92JgsBajeVKCQQUp/QZyLIZwKmQt1QZIClMNBaXpHBoAR9gvFOKH3sGPQPk6 ts15pwQIG51RoBaAcHfG2v8ZSWFhRpf8/MxsCLcnEKwaZvEZRIw1EVsjIcPRpt/NUG Xhbx8JWOl3bZmsEM+6wFpxRRQU1sblTPYsQsTqL0KRfCauYl9C067uAIvNWAPtxwAk 8Hiel5ErROK5/p7sGZf3vmjQoKcZSYzysPgo6c2KX42FBRdbmNxtKkrcNfRolzizyZ JTDI/N55Wvp8KEsRJYjDQ37fesqba5beCKyfnqfKHIMv6/E0qcHsFeWw4dScUalest KnSOS1p/dRMVw== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A8CC61EF9 for ; Fri, 27 Jan 2023 16:43:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="a9n94iy0"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id j17so3774960wms.0 for ; Fri, 27 Jan 2023 07:43:40 -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=E6dHlkOnJMQJvyJm8IaDqSUyf4r2Yg8uomKDc/nSU+s=; b=a9n94iy0MEoEPY2hhySvXgI8sph+Vl3eCzOW17jxM34oFCOb7nbNgQyZuLqstZo6UD AmAWS2RiaLwXfMxrZP0tB3oaWACsKA2WU2sonDY0cRTQ8qUmhhQHIuY9gO+lQPbtAQXd ANmImXJEv9pDXawPQdizgvZUcexlnO2WvTj5XVypKLsR8smWxgMF8DJqr13IRtWlpGiG /l4YOKSy/b5ZtE65NbkYYhoCqsGQIq/Zet2ROpOtknRt1avUu6ED1HUfI/b0pNR6xr2x rA235VZktlJzJA60l/rGESOUueXfZTkFpm59akUFUI9DEaYaq2XxZGdUFiVulhSjY6na P6gg== 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=E6dHlkOnJMQJvyJm8IaDqSUyf4r2Yg8uomKDc/nSU+s=; b=INMxRm2ROqFjK8pqAEzdmePhJqwyjsCypzSqyyo+3KTQXv0vQetSkgrVMVrdItinnn tpsa9juz24E16Z5QEsBiFQS01OTjCTnhtUnPl/u6G68W200vAOFtZUjB8yVGJUVaKbXU fiDoSBJXT7kDlCkaw71bU+PxsY+sOMobaycSUYMknuZSMj0/Yij1d+jNVCvdT23q4umw 8RfNB2CzLPXoTbdTDqrfuYyDsPI5jIXOFQ9lTS1g+pjtlc7OH9HbqRVDUBFecTdsGhSZ PGtjt+PHzYslM1Co0joAxAqGPy1sPnYLAjH5mX6wFtvd/Oswp07pBGMsLilRupIZM1K9 qVug== X-Gm-Message-State: AFqh2kq0vqykjjBduWOGwDWZGaW2PPDKXU22vJaleV+VUS+nCTIvYK6s 3g+Nrh55H9LPa+DFUaW8xrULqCIcNFaO0C6sVG8= X-Google-Smtp-Source: AMrXdXv5roefk4Zi+s+gIbQRgSK3gZQXqGrDsNDQmirGcsQfvTJL4QV454AW493PegC5aj424HwR6A== X-Received: by 2002:a05:600c:3ac8:b0:3da:270b:ba6b with SMTP id d8-20020a05600c3ac800b003da270bba6bmr41411738wms.41.1674834219684; Fri, 27 Jan 2023 07:43:39 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:39 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:14 +0000 Message-Id: <20230127154322.29019-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 07/15] 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 --- Documentation/environment_variables.rst | 5 +++ .../pipeline/raspberrypi/data/example.yaml | 32 +++++++++++++ .../pipeline/raspberrypi/data/meson.build | 8 ++++ .../pipeline/raspberrypi/meson.build | 2 + .../pipeline/raspberrypi/raspberrypi.cpp | 45 +++++++++++++++++++ 5 files changed, 92 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/example.yaml create mode 100644 src/libcamera/pipeline/raspberrypi/data/meson.build diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst index f092cbbd29c5..ceeb251a2ac0 100644 --- a/Documentation/environment_variables.rst +++ b/Documentation/environment_variables.rst @@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib`` +LIBCAMERA_RPI_CONFIG_FILE + Define a custom configuration file to use in the Raspberry Pi pipeline handler. + + Example value: ``/usr/local/share/libcamera/pipeline/raspberrypi/minimal_mem.yaml`` + Further details --------------- diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml new file mode 100644 index 000000000000..4662136e0be0 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -0,0 +1,32 @@ +{ + "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. + # + # A larger number of internal buffers can reduce the occurrence + # of frame drops during high CPU loads, but might also cause + # additional latency in the system. + # + # Note that the pipeline handler might override this value and + # not allocate any internal buffers if it knows they will never + # be used. For example if the RAW stream is marked as mandatory + # and there are no dropped frames signalled for algorithm + # convergence. + # + # "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 44b1727678c7..83e82bd2880d 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" @@ -1154,6 +1156,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 @@ -1687,6 +1690,48 @@ int RPiCameraData::loadPipelineConfiguration() .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, Warning) << "Failed to parse configuration file, using defaults"; + return 0; + } + + 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 Jan 27 15:43:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18208 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 9A602BDC71 for ; Fri, 27 Jan 2023 15:43:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 645B2625FF; Fri, 27 Jan 2023 16:43:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834227; bh=xK2wcpQnZCDzyHE/dpHSFOEbJ7h/9g8/6FWAzLqHuw8=; 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=rHNM/Eb0BHpFxU5ORTw1wUfZFQdkTSepKKAI6YQTxvVGAZ4g4VgSs/aqQWasxFien 6MqCp5bV+/egYuebnM9FAF5ZEgE3oi359CGU7mnXYapBe6kuS2ET4mOJSCbx6NEmUl STlTZnrQJVFrGNa3RrYS9revwpZhlR/OVg/sIySEprcKEjkVepXPCMC6EmYqgcrIfB 8OHVKPu+E9zzTZBkvmLoV25PHor2fpGqP1TvbOtmEc5SWinPdck1MFFcXxLtLmXBGa W+qDV749zzS457E/ZrH816A9QWx9FDTn45ZYrhZwtP4WpzegAiVeCWa7INLpW6OTQG hSsUFwbnbdXUg== 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 AE795625E4 for ; Fri, 27 Jan 2023 16:43:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="j3pipNP9"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id iv8-20020a05600c548800b003db04a0a46bso5849988wmb.0 for ; Fri, 27 Jan 2023 07:43:40 -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=afcKaE04BexTLMjLTfmnTqFdQC6rwFUactfLih+k2m0=; b=j3pipNP9e8NgOlCfqM1GmAJoGNaqryXd+zfLdAWQIz1iPV+9V5/6EvZZ1XvkNzaWRV Fm6fQEXdCOogNJatj8N5CBpr3ej9/o2pqtOfOVg/9+PGVJ/dnsiJ4J6CPyT0cEkC2SN0 ebnOJFRnccD6lUfYpRH9ARR8rxc7NtIek8v5eX2xSyT+7UYjMWfwd8z/lTmRqfLiEZ5k H8m8SMnCdRCq0T//z5Dx4F2EUzW/4vkE+ybc4fPR4ssl/EnjYfgNNV9x49gADeBk6yKf +H3n+XKPsrJl08lVCy5yEE5yhqhCECadqyToc8E7rpWBXcawHY1BN8V6gIoOC9qT+Fxx ys/w== 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=afcKaE04BexTLMjLTfmnTqFdQC6rwFUactfLih+k2m0=; b=OIUaGpR1trMI1Sq5TQHIgi8KPh1q4YgBoIN6xkljtp2dbJC596WcVPW9+TUeV3KJxi utcLE4rE2QxSL/MxCb/02rADEx+Zfs10uyTQHdFDsbCM+R4EH8tQHlhuEgpuGIc5sgil OLp13Wllc8BpIfd/BmIkxZuND802F3Z2C6kDG+7WAbasYGJmq91xFuL4p5TALc5pFMtO CugnN2lGWUCDIXDV5aBWEofYuCy4isE1PpYabcZD2LzmbHNSiEBhft9pAirF3agT/9K4 2ry8p15jY3um+wvDptLv50XquLsdJoZwDxZobeqDFb5osijt6/fyj+VFQ/dzRbV+sV+w Gprw== X-Gm-Message-State: AFqh2krEP0r3k99yP52v/Ok/v6+7pXvozZxxgJ+m35qmC/AhvRJzMSBZ 7t6ub0kpEI0SUKkcshY2y3Qo4zx/XgQ7TdyJclY= X-Google-Smtp-Source: AMrXdXuq6Rirle1AEUwL9n6Ez1fQEwcOewprFfESaYF/AhFf0c5+dKL7UWY1lZkGYjm62SsB2uJxDQ== X-Received: by 2002:a1c:cc11:0:b0:3da:1d52:26b5 with SMTP id h17-20020a1ccc11000000b003da1d5226b5mr47332010wmb.14.1674834220207; Fri, 27 Jan 2023 07:43:40 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:39 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:15 +0000 Message-Id: <20230127154322.29019-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 08/15] pipeline: raspberrypi: Handle MandatoryStream 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 MandatoryStream 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 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 83e82bd2880d..7c6db070dfc0 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1457,7 +1457,7 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) RPiCameraData *data = cameraData(camera); unsigned int minUnicamBuffers = data->config_.minUnicamBuffers; unsigned int minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers; - unsigned int numRawBuffers = 0; + unsigned int numRawBuffers = 0, minIspBuffers = 1; int ret; for (Stream *s : camera->streams()) { @@ -1481,8 +1481,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::MandatoryStream) + minIspBuffers = 0; } } @@ -1518,12 +1531,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 Jan 27 15:43:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18209 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 2ABA4C3242 for ; Fri, 27 Jan 2023 15:43:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE4FB625EE; Fri, 27 Jan 2023 16:43:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834229; bh=LHFc9oAT7V0oKglt+dmod6zeVMnswHwmpo6gmQVvMlU=; 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=s5O9lYkEWT7MJ9T6MU0lxNg1oHhG9/2P8z+DqesmkLlnf6HnQfZc/e1ACc6woYqVe +sfPzkk6SwiUG/BBglK5x8EqvDGQLWA+r+l8k7eSfpAqOtMQHGZ50xMk8EzPFMwc2C w/e2uMfYFKlG+rcs2Cw6rRMwP2IbAd48/O5+3Up4sOyGAnwZsbiSpBRzFlfCtBl0ss GF/ko7D5+HIyeVPvD+HSh5toi2Z+UUhfZe2Ujbr3sMqRtlvJsjDPfGGMKvCI0gSABX TKBjS+ngQmqgRMIVlQklQEoS2Kncyp0kEJevp+KWiCyvsb+QZeOLNbWdpbDvFOUAlo DoAAXGbbUpzJg== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42B0B625DD for ; Fri, 27 Jan 2023 16:43:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="YOLrR94L"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id j17so3774991wms.0 for ; Fri, 27 Jan 2023 07:43:41 -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=U/rJVWuxNB0Zl6v7nsB+2X3RSr+G8CnS+bjX1/c2Tvo=; b=YOLrR94LzwutjpenSznjrAr3gJNv4SRhq5W4roa6jMv8wSwZODxzuyep0z7dKPGnJV fwBteb4Q4xvGqWQ5Ye71SgzPnItpJ+BDA5YIfG4SrLkU7tJnEl3b2w9T+qo1PlyLc4r6 l2nnXQSjww5fkAMgwP4ItHVLzFWf2j6hrQcGehwoZczfatuM3PHu3sltvKDUoJfQ1dNC u9PI0+LAvhZt8uVqquO7r/HMmciJypkfqwcd8RK2SXQCqvCWcguN/qdSHmnZep1GpI3Y zaS9DnJ+eIYmbBs7qWzhntx6qPAPq6TYtbBfzySKpwhnm2PYSCHyHWZiGRCEtMNFFrR5 P3og== 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=U/rJVWuxNB0Zl6v7nsB+2X3RSr+G8CnS+bjX1/c2Tvo=; b=rFydXtBkc4IEkqzcqjdS8cBDMVBxG/9rX+nsxRVcOBDfS3dbvtAKCp+LEaJ6WfRKiN T4btHUsGemv13OcfD85d+6KQZDW7bgnTQhoRrQ5M2Bl+TRX2EqUDuAegq/95/3EmxOUq Lw+eZbBMI+mhX6fMpGB8HoKbncorPP7DGEhuMZPbHlqNTmVkqZvl7hBQXLGfZYvsDvRr ghKwe1jFLB68BaAPMtTittERsdL9+4aU8b/aa0io0vVilQm2iXgHuiC/jTw7c/LPU47L zV6YGnc6UWjRmus+vSBFpQiI9UtQjFrMf0+8RIg1hj2wvZYlT58MH/RjMwNt8cb8/zP8 jU8g== X-Gm-Message-State: AO0yUKUZD+CDqoQOVMLJ+fglYkIdcQyInMy+/8B51qgDNykQX31Tsujn YFrAl5isiIuHRcl7wa9TPXhcFtHL1Zi7XO3zekY= X-Google-Smtp-Source: AK7set8nLi4fhMrRK0oEdaCqIyF7DOEBWdYbiluWeituViYIF/izskLhL49HqvlAyN0O8zqCgGQs9w== X-Received: by 2002:a05:600c:314d:b0:3dc:2039:1710 with SMTP id h13-20020a05600c314d00b003dc20391710mr9820047wmo.20.1674834220780; Fri, 27 Jan 2023 07:43:40 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:40 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:16 +0000 Message-Id: <20230127154322.29019-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 09/15] libcamera: camera: Validate MandatoryStream in queueRequest() 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 queueRequest() to ensure that a frame buffer is provided in a Request if the MandatoryStream flag has been set in the StreamConfiguration for every active stream. Signed-off-by: Naushir Patuck --- src/libcamera/camera.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 2d947a442bff..b0b0a5cb5bb3 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1144,6 +1144,18 @@ int Camera::queueRequest(Request *request) } } + for (auto const stream : d->activeStreams_) { + const StreamConfiguration &config = stream->configuration(); + FrameBuffer *buffer = request->findBuffer(stream); + + if (!buffer && config.hints & StreamConfiguration::Hint::MandatoryStream) { + LOG(Camera, Error) + << "No buffer provided for mandatory stream"; + request->_d()->reset(); + return -ENOMEM; + } + } + d->pipe_->invokeMethod(&PipelineHandler::queueRequest, ConnectionTypeQueued, request); From patchwork Fri Jan 27 15:43:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18210 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 D4697C3296 for ; Fri, 27 Jan 2023 15:43:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 940FE625EA; Fri, 27 Jan 2023 16:43:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834230; bh=pHI5uWmbWB5cxcaFlY7jt6B/aYTSunV8vLgbsZ0H2AM=; 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=THuXKU+1tKpvYF01IwdXnc9H06Eo27atZ/dBl2zM9E8OsOrW3cZwn3bQtWYRFESss ZcaAfXamRrDnheCCdgMYUBi7XHp1H4GAh0ZnmNuL27G2uEetVk1P8V6hlG/G/pC9iT QI4SO4Hi3kjzScgU+n5pXzpdaEv9t49oKmzRFeAB3/wKr6VZlNuhLR/7pgjLyyWP9a yUNABdcklHbvdgclr/7l2hhdzRcbOAdMsMOcDFbYSHTY8Yvgp/EFGGlX9mAYxDRm7B tcqTiWaFkZq5Tbj+SeElEoTzL4jc+QVLgl8DAr4hRQKw/BijhChNJoCbZY1mJ5z6hU Zd/k4Nc9IkI5g== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 11265625F8 for ; Fri, 27 Jan 2023 16:43:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="YGbkrgfm"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id j17so3775019wms.0 for ; Fri, 27 Jan 2023 07:43:42 -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=lK8gMsRaEMF9LU/BvGhTG6doYfu6+Hb6usSUiLnZCQg=; b=YGbkrgfmvPZ/chDoIDU1bcdYYaRoMsMrZ1iYCE9VhOzEIf8AlPdQTZg73/Ek6qAaN7 EJKQUZGu2h5Sh8EjUm3YzEmjREdIUI0qVBhHRCENw2+xoglAbz+jqmRb3Sp5XjKu8A0r US0IgIe3Cf61GfQ5OTglfDGyn29v2HyDiUSgDXSWWgJ4KUhS/XL7kSNEvauD5AdhIohG OAE4KVITrc35ZjyTuDNgoAOQl9PmQtd4qMx/qKM7JTW4zHnK9t68IkHrxeUbHZAGPT7w awAj2cBdus/pL7SNGu5L7ViJMXK6El13TRPa74qSl6lK56o4T+7ni89YbWoUP5NhcZXX g1Ug== 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=lK8gMsRaEMF9LU/BvGhTG6doYfu6+Hb6usSUiLnZCQg=; b=y2Un/iMLMh21AotemBkEJTkcgMLlsyCb9wQsVwmlUMmjZR7fsYg7zGHGGNms80Alal JZmXTYdwt+/aMi2YgNoJyJPAtz4TKni5s077X6FweY4Z4IbeZWNATNr7cwvyvZ/+wx7o 23tAMClWvK5wNcDXE5MR6kDE9tO41A0hVeHD2aSquWIVhQft+RfFjcQxQYzCJNnDxMpA P51DYWd+/DHcEVvV31TAokZ62/79AZ329k93oG9/2mIm940uiaBIFG6SvDYQpJr2v+Ni sLKPGwYCawUKpIK+ME3DjbQAlOvrZWmmbW3YA1Td1FJyir9ZK+GsmtUgroF+KdBL/eD8 g+RA== X-Gm-Message-State: AFqh2ko12GFPPGQwL7BKJFKmdy1ShlyLelCoH4oP2VYXOgJy+ed0fRLQ gU1yBZonQ/flcSSsQXMR0MoOWrUHYeyPo8N/RnI= X-Google-Smtp-Source: AMrXdXsZwfRgpvk/rNuMejv2tWhXnU/xGidDoA29Gd0KAgDVXux+Yj0xgyFJZCbgZx+SkvgUa4CkJA== X-Received: by 2002:a05:600c:16c9:b0:3db:222:3e0c with SMTP id l9-20020a05600c16c900b003db02223e0cmr39877232wmn.33.1674834221433; Fri, 27 Jan 2023 07:43:41 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:41 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:17 +0000 Message-Id: <20230127154322.29019-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 10/15] 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 | 7 ++++++- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml index 4662136e0be0..ad5f2344384f 100644 --- a/src/libcamera/pipeline/raspberrypi/data/example.yaml +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -27,6 +27,11 @@ # 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 7c6db070dfc0..9920f6bb01a7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -313,6 +313,11 @@ public: * minTotalUnicamBuffers >= minUnicamBuffers */ unsigned int minTotalUnicamBuffers; + /* + * Override any request from the IPA to drop a number of startup + * frames. + */ + bool disableStartupFrameDrops; }; Config config_; @@ -1057,7 +1062,8 @@ 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(); @@ -1703,6 +1709,7 @@ int RPiCameraData::loadPipelineConfiguration() config_ = { .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, + .disableStartupFrameDrops = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1736,6 +1743,8 @@ int RPiCameraData::loadPipelineConfiguration() 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 Jan 27 15:43:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18211 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 CF671C3297 for ; Fri, 27 Jan 2023 15:43:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 705FC625FD; Fri, 27 Jan 2023 16:43:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834231; bh=1Ig8lWSCDlGf6VtqXhWEwfeoCFsqN7yB5rm1PzEHhOw=; 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=lAUoYm9S6+zcg0OYGnn5d1O6qZOhLn8Bfl+RbKToQSXJm9FsoACcScRV730VGeCdX RwDYj+38gq5FCLtMxENqUjZA/gY1IrFYltukXAAat1Mmo2n2q1zItvXPjaJbW7syKB WpJFoGyjhGqSLQUoC6lzBhtfgf2/V5c9VdWJzA3ELPZuXHPmn3wOL8qe/cKU9NVulk avm2WR4xLn3GfKQDC9uYNwssrxHgMDWgk/ukG3ib4SWttDr7NENtbnddq1i15/Ujrn XjSseMReS6KE8OCd5RoysLEE4BmM8z5mbDDn6HySbptfD89XrXbP0ZXavJUndvWAd5 Qt8Z3njEXoA/A== 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 C70D6625EA for ; Fri, 27 Jan 2023 16:43:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NeVffUHK"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id bk16so5314255wrb.11 for ; Fri, 27 Jan 2023 07:43:42 -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=6Pu/E3yZHUFL7jfDGhxcod1G6B+EAehMGf3zdxn2Go0=; b=NeVffUHK+yS0olihAs1licR6w6GZ76ed9VkI5OKmIycR4hKvr2EkBR16OnlMiKU4CQ G1Qd/lWaNwhu/2docvGE3UsytTY8fbrJ8S1X0WI+K3/Fgcj5VuWiobIZnyq+AlTA/W39 s+YT4eMzEWHjscQt5Z6zEFxAwDy/UC/Kx1xMdNAph4tif6XxszBzyO3rwNZfIM8Ks2Yl kBZuxOERA7kT2OmA6INP0z60hKPl8IDl8ODfzjuMXzLs9MrtO8dUcqFeODmYe+v5+Hpd Rb9aeJrV1pHyp+AH5L2IXIguB8qSA/NoIuWzvEXe4KFIYzxr6JM7x0BfvP7LH6+sZ+7M UPCw== 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=6Pu/E3yZHUFL7jfDGhxcod1G6B+EAehMGf3zdxn2Go0=; b=0c9CFcuHBu2R3pNuqz+UY5aXVS5kGCdYyan1Bd7lw52oFXU+v0Az3faf8emJZpaRVH SbVmP9Ay/x3bARsjjFkalXlrjW5QEtckaluLQheszOzpZbxPhJ66RRqAovFxm3B0lS0H ZseSTM9JNSqYxApUDsXcS9cRLi12FEXVUoTL3ohhb+vT0u6Hhq53r1+gOiG2sWa/a9qg qSXGBl91Ak7xucT2QOJep/llmwUoSAA36kDupZFAJbo6l6bj5s9HFCVCpQakQQ0YZYuF 1TgX2JeVlBcHP/wgMNTwT14x4fkqPLZsl2nsbSqhN3Tu2mCYtarErHgBSZNGQFfGSRdZ Xgag== X-Gm-Message-State: AFqh2kqjTCBYQcq6floQXpWDsCydnJTVdRcSA3tWqTXcnqa4Rv/RIpcc KVHKTaQG7ZTwSdLc9HAB82EKxqBwWwCPG9AuBow= X-Google-Smtp-Source: AMrXdXsPgjEqJghSce77KbkUg22vSnB5teKvgtZRLLM+rYG0YULPFKyjMcSGsd+gzR9Ay3Nnkdu6qw== X-Received: by 2002:a5d:5190:0:b0:2bd:fde4:885c with SMTP id k16-20020a5d5190000000b002bdfde4885cmr33059578wrv.63.1674834222197; Fri, 27 Jan 2023 07:43:42 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:41 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:18 +0000 Message-Id: <20230127154322.29019-12-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 11/15] 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 | 37 +++++++++++++++++++ 2 files changed, 38 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..5e4906af7cfd --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml @@ -0,0 +1,37 @@ +{ + "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. + # + # A larger number of internal buffers can reduce the occurrence + # of frame drops during high CPU loads, but might also cause + # additional latency in the system. + # + # Note that the pipeline handler might override this value and + # not allocate any internal buffers if it knows they will never + # be used. For example if the RAW stream is marked as mandatory + # and there are no dropped frames signalled for algorithm + # convergence. + # + "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 + } +} From patchwork Fri Jan 27 15:43:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18212 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 3DAF0BDC71 for ; Fri, 27 Jan 2023 15:43:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ED1FD62600; Fri, 27 Jan 2023 16:43:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834231; bh=oJDUAEahPnQTy8VjBnFaA8X0iM7MlZ41x4e3hveQ0hw=; 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=nKXUNXP+7i0dY5rv5uaaAiZvE28y3O3SE5za9/yk+BH6w4KLxppB18/iOdJ75JvtS GMDGzseaafLjf8Q3LrhaiI2Nj/bMLT5RxWufMsNHh5XteI79dtApXyEZQpQxs4CFRB Qj0OzhZjqTv+b0bo20Fd6w97jvKQbf9RqOwV6Wtn6QtRMMtJbrwfKTUWXhX5/4gLMQ DBHFdA4RnTMzMQujmHx24NRR/fymnVWlkjarlMKKBRsufLx2z9VA++YX9UUhSXkaCr pCDRj3kJuhYcJdr/eevmK8qrxgRVheujXNnfaV1Jy/aPJidO7yJMV234/34GQVPUIE ugK4ZN5x4Lktg== 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 6291A625E7 for ; Fri, 27 Jan 2023 16:43:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Zr55Ty1p"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so5679250wml.3 for ; Fri, 27 Jan 2023 07:43:43 -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=jWVV/JyEAPl4kBWc5ldf5h6NOU1c89AUGkoy8ucYGBU=; b=Zr55Ty1pf4w84UlyLtNCTSMPly7DgaWDUFRyIaExdiLEebHabYa2OircgAdylFNLV7 RmNp8P8M49gIihIIkhbfyL/Ec7PWfmgD2u5cfIb9N6XhIKRcD9eTYIrQzfIg28v5ZGKg e52mce0+hphN4s40yCRU/vwhGX0Uj6KijUjTI1hxUD2mjsvRWB0Ae/UHdQEjUhfiEQW4 ENAogVgPpNP35gorUO5h7MkjOE0n9yvk4JIdTqqz9fT7YQqyoEqj2mIIy++H+W3TU7TW +nWcV2R0Sh1TTAutxQhHh1iklfn+ZOJ9qiN6DtGnvFckAa6m22Qty4WEVBkfvx+E+/jX oqew== 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=jWVV/JyEAPl4kBWc5ldf5h6NOU1c89AUGkoy8ucYGBU=; b=I2Y3JA1jMwelLqfN+lC3TT+rj4XJ8r9++dPeeeQJL3WPZabmjIGOkNi+9WbxyG4oYi KWpdYOsJ01oe2YEBaCPFV88ETa4gUfQB6EpGhaRkE47CIXsgO+tfbbMSDOEOUUFddTBT M2CD+BYYaf8czO8NJmZjd5IHDC3IMJGZ3jWdUV5dk3jLvcti33n8UtGipHyEqMWz5/9A abnmUV1AdN1R0Njqic426P7WPeO5vaV6CGWQnGVsZLYtFh9K6nHb/14ocRp1n9PVSLrx tc2LEc5gH3OKVTEHKIgzGhzfOo+RIO999UZh+39WLAquqBUrowPiMluDhuL8kshcn1GS J8tw== X-Gm-Message-State: AFqh2kpYzTqilRKq4yH0opPMY5fiJ58W1MRFX1JVLijC8V7/FJEgSNRQ sFTfI4KjjGTu1jIwETVRnFT4l/mxa+sDnzf7Wq8= X-Google-Smtp-Source: AMrXdXvfJKPzs/kdTMKSJAp+wHU+YRw56jt9Qpx2D3hR+3iJVdrEWSq2+r+Aqn97f4rT8mFxjyD0KA== X-Received: by 2002:a05:600c:1c9c:b0:3d3:49db:9b25 with SMTP id k28-20020a05600c1c9c00b003d349db9b25mr37690517wms.26.1674834222918; Fri, 27 Jan 2023 07:43:42 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:42 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:19 +0000 Message-Id: <20230127154322.29019-13-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 12/15] libcamera: apps: lcc: Make rolesMap global 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" Move rolesMap out of the nameParameters() function to allow use with other functions in the file. Additionally enclose all global variables in an unnamed namespace. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/apps/lc-compliance/capture_test.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 1dcfcf92fc8c..37138dfb3d2e 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -15,6 +15,15 @@ using namespace libcamera; +namespace { + +std::map rolesMap = { + { StreamRole::Raw, "Raw" }, + { StreamRole::StillCapture, "StillCapture" }, + { StreamRole::VideoRecording, "VideoRecording" }, + { StreamRole::Viewfinder, "Viewfinder" } +}; + const std::vector NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; const std::vector ROLES = { StreamRole::Raw, @@ -23,6 +32,8 @@ const std::vector ROLES = { StreamRole::Viewfinder }; +} /* namespace */ + class SingleStream : public testing::TestWithParam> { public: @@ -59,13 +70,6 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo &info) { - std::map rolesMap = { - { StreamRole::Raw, "Raw" }, - { StreamRole::StillCapture, "StillCapture" }, - { StreamRole::VideoRecording, "VideoRecording" }, - { StreamRole::Viewfinder, "Viewfinder" } - }; - std::string roleName = rolesMap[std::get<0>(info.param)]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); From patchwork Fri Jan 27 15:43:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18213 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 C3A7BC3298 for ; Fri, 27 Jan 2023 15:43:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 818BF625EF; Fri, 27 Jan 2023 16:43:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834232; bh=NxhZeUKE1nvXap0YMG8vugqatVNdph4Ii/SKNyji8+Q=; 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=Eyd2/tcRRF1BrfTIbr6EP5aL8r2FQYumwuRuvKdxg9uAxoW5dGA9hbT/rir/uPPoW vRVunDoQ8cRdY6n03rqeA1a8wenQQJZBITjfIAcdSZWl8UaQ2A2fCQCDzkRn8gIi+w 933b+leEplToYNw7FlzYcw2koWRO7lzzKppln8+rDk3qvN00OEIqENjGA+KfDekovi yElIbbUUm9IA+dbgiziSWC7LFs30bMFJlxuFcwIfdg1F/Bdia5x0J5bFkPyxXTiRli sMOx55kQEszmIBTY7ZjXnzs9rh9YYXPBSQl0w7/VXhm8toZR9mx9/JBp02akhnO6hw soZNQ64AWteHw== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 70049625FD for ; Fri, 27 Jan 2023 16:43:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Lxlzb4kP"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so5693712wma.1 for ; Fri, 27 Jan 2023 07:43:44 -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=nytONP2YDrHV/JpeWzsmettXZPjzIzkspdiWeo6WEy0=; b=Lxlzb4kP4hg392zv0MbsrOvfF73Do60pvWhQ0ZtDmgYiiUfdqSlgUp8v8p3NPGO4er QVgiYL+HzVr1USnbe2XN59jubjp1tO6vht12hdzSSrqQhwR5aAOJBkgwOvYnDTsAYe++ VNaqMBxiYr89T+eJKQ+mN8/AbwzqnfMF3QHh6w4wSsdiKhvJEx07KJ9eJSKL3Zis7Vtd DdQgbDcETSDQbGBumvEc2lZICYNgb/QT3ltUENq8Z20Pas+jWwBxI7noLqNoN0ceZ2ZQ VmlYrEh9NHMYu/zR3UbB5XLeRL+TytfgkA4IHmoSYx0wm+Fa13sSwIGp3r8dqZAJh736 o7rA== 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=nytONP2YDrHV/JpeWzsmettXZPjzIzkspdiWeo6WEy0=; b=eITmeCF7H2KsoAURQWac7ct9DjZzmx3H26KLMTEDK/J35Z6k7TTagsakAeTGaaX1Zo mjgJvQym07yxjxNNBY348BhiNadXCkA1N9uAEfAutOq2P9JgpUYk5eUFvNtHFYIR43Re ijQo9rlMvR0VGvCRbIjziBdkqF7L09kOaKw2wnvl9SEFq2VaygM9mEkra60Ws+v4pbid tFamZNIJh+SnF3GV4+OJ5pxcjRg84snx1kCRnHpv9udF4NaJ/JR3wEzvqPyA4ZYuA8xQ vlFJ2el6pPvnfHluKGfJ1lZ2jO/vCte2sOE1ENde6Tx3b4+LNA6JActs6fYsGOYf9NIG KCDw== X-Gm-Message-State: AFqh2kq3+G7GImDPxHzjvaMCou7XfWwo05l//LeVgo2tZs7t2ZASK46J QVxZPx9qu7BxKCA0EnsHFSORYtjju1NGWqYI5z0= X-Google-Smtp-Source: AMrXdXvK1BXqHUIAd/qAFNd4DZSnnS+U/tJqlt2Wm38buk5GohF4oqLui8SyNuj+f/amExjov/AnmQ== X-Received: by 2002:a05:600c:3ba5:b0:3da:ff66:e3cc with SMTP id n37-20020a05600c3ba500b003daff66e3ccmr38723861wms.21.1674834223589; Fri, 27 Jan 2023 07:43:43 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:20 +0000 Message-Id: <20230127154322.29019-14-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 13/15] libcamera: apps: lcc: Add multi-stream capture test framework 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 framework for testing multi-stream captures with lcc. To start with, a single test class, MultiStream, has been implemented. This class is based off the SimpleCaptureBalanced behavior, and tests that the pipeline handler completes the exact number of requests queued to it. Add a test to capture_test.cpp using the MultiStream class to test the pipeline handler running with two simultaneous streams. The test framework permutate across a list of named stream pairs. Signed-off-by: Naushir Patuck --- src/apps/lc-compliance/capture_test.cpp | 77 ++++++++++ src/apps/lc-compliance/meson.build | 1 + src/apps/lc-compliance/multi_capture.cpp | 187 +++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 61 ++++++++ 4 files changed, 326 insertions(+) create mode 100644 src/apps/lc-compliance/multi_capture.cpp create mode 100644 src/apps/lc-compliance/multi_capture.h diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 37138dfb3d2e..8d534161e985 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -11,6 +11,7 @@ #include #include "environment.h" +#include "multi_capture.h" #include "simple_capture.h" using namespace libcamera; @@ -32,6 +33,13 @@ const std::vector ROLES = { StreamRole::Viewfinder }; +const std::vector> MULTIROLES = { + { StreamRole::Raw, StreamRole::StillCapture }, + { StreamRole::Raw, StreamRole::VideoRecording }, + { StreamRole::StillCapture, StreamRole::VideoRecording }, + { StreamRole::VideoRecording, StreamRole::VideoRecording }, +}; + } /* namespace */ class SingleStream : public testing::TestWithParam> @@ -137,3 +145,72 @@ INSTANTIATE_TEST_SUITE_P(CaptureTests, testing::Combine(testing::ValuesIn(ROLES), testing::ValuesIn(NUMREQUESTS)), SingleStream::nameParameters); + +class MultiStream : public testing::TestWithParam, int>> +{ +public: + static std::string nameParameters(const testing::TestParamInfo &info); + +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr camera_; +}; + +/* + * We use gtest's SetUp() and TearDown() instead of constructor and destructor + * in order to be able to assert on them. + */ +void MultiStream::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void MultiStream::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +std::string MultiStream::nameParameters(const testing::TestParamInfo &info) +{ + std::string roleName = rolesMap[std::get<0>(info.param).first] + "_" + + rolesMap[std::get<0>(info.param).second]; + std::string numRequestsName = std::to_string(std::get<1>(info.param)); + + return roleName + "_" + numRequestsName; +} + +/* + * Test multi-stream capture cycles + * + * Makes sure the camera completes the exact number of requests queued. Example + * failure is a camera that completes less requests than the number of requests + * queued. + */ +TEST_P(MultiStream, Capture) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCapture capture(camera_); + + capture.configure({ roles.first, roles.second }); + + capture.capture(numRequests, NumStreams); +} + +INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, + MultiStream, + testing::Combine(testing::ValuesIn(MULTIROLES), + testing::ValuesIn(NUMREQUESTS)), + MultiStream::nameParameters); diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index 51d9075ac30b..0357cda2f301 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -13,6 +13,7 @@ lc_compliance_enabled = true lc_compliance_sources = files([ 'environment.cpp', 'main.cpp', + 'multi_capture.cpp', 'simple_capture.cpp', 'capture_test.cpp', ]) diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp new file mode 100644 index 000000000000..23becf964fd7 --- /dev/null +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Raspberry Pi Ltd + * + * multi_capture.cpp - Multi-stream capture helper + */ +#include "multi_capture.h" + +#include + +#include + +using namespace libcamera; + +MultiCaptureBase::MultiCaptureBase(std::shared_ptr camera) + : loop_(nullptr), camera_(camera), + allocator_(std::make_unique(camera)) +{ +} + +MultiCaptureBase::~MultiCaptureBase() +{ + stop(); +} + +void MultiCaptureBase::configure(const libcamera::StreamRoles &roles) +{ + config_ = camera_->generateConfiguration(roles); + + if (!config_) { + std::cout << "Roles not supported by camera" << std::endl; + GTEST_SKIP(); + } + + /* Set the buffer counts to the largest value across all streams */ + auto largest = + std::max_element(config_->begin(), config_->end(), + [](libcamera::StreamConfiguration &l, libcamera::StreamConfiguration &r) + { return l.bufferCount < r.bufferCount; }); + + for (auto &stream : *config_) + stream.bufferCount = largest->bufferCount; + + updateConfig(); + + if (config_->validate() != CameraConfiguration::Valid) { + config_.reset(); + FAIL() << "Configuration not valid"; + } + + if (camera_->configure(config_.get())) { + config_.reset(); + FAIL() << "Failed to configure camera"; + } +} + +void MultiCaptureBase::start() +{ + unsigned int i = 0; + + for (auto const &config : *config_) { + Stream *stream = config.stream(); + int count = allocator_->allocate(stream); + + ASSERT_GE(count, 0) << "Failed to allocate buffers for stream " + << i; + EXPECT_EQ(count, config.bufferCount) + << "Alocated less buffers than expected for stream " + << i; + i++; + } + + camera_->requestCompleted.connect(this, &MultiCaptureBase::requestComplete); + + ASSERT_EQ(camera_->start(), 0) << "Failed to start camera"; +} + +void MultiCaptureBase::stop() +{ + if (!config_ || !allocator_->allocated()) + return; + + camera_->stop(); + + camera_->requestCompleted.disconnect(this); + + requests_.clear(); + + for (auto const &config : *config_) { + Stream *stream = config.stream(); + allocator_->free(stream); + } +} + +std::vector +MultiCaptureBase::prepareBuffers(unsigned int numRequests, unsigned int numStreams) +{ + std::vector buffers; + + for (unsigned int i = 0; i < numStreams; i++) { + Stream *stream = config_->at(i).stream(); + + buffers.emplace_back(&allocator_->buffers(stream)); + + /* No point in testing less requests then the camera depth. */ + if (buffers.back()->size() > numRequests) { + std::cout << "Stream " << i + << " needs " << std::to_string(buffers.back()->size()) + << " requests, can't test only " + << std::to_string(numRequests) << std::endl; + return {}; + } + } + + return buffers; +} + +/* MultiCapture */ + +MultiCapture::MultiCapture(std::shared_ptr camera) + : MultiCaptureBase(camera) +{ +} + +void MultiCapture::capture(unsigned int numRequests, unsigned int numStreams) +{ + start(); + + queueCount_ = 0; + captureCount_ = 0; + captureLimit_ = numRequests; + + std::vector + buffers = prepareBuffers(numRequests, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue the recommended number of requests. */ + const unsigned int inFlightRequests = config_->at(0).bufferCount; + for (unsigned int i = 0; i < inFlightRequests; i++) { + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[i].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(queueRequest(request.get()), 0) + << "Failed to queue request"; + requests_.push_back(std::move(request)); + } + + /* Run capture session. */ + loop_ = new EventLoop(); + loop_->exec(); + stop(); + delete loop_; + + ASSERT_EQ(captureCount_, captureLimit_); +} + +int MultiCapture::queueRequest(Request *request) +{ + queueCount_++; + if (queueCount_ > captureLimit_) + return 0; + + return camera_->queueRequest(request); +} + +void MultiCapture::requestComplete(Request *request) +{ + captureCount_++; + if (captureCount_ >= captureLimit_) { + loop_->exit(0); + return; + } + + request->reuse(Request::ReuseBuffers); + if (queueRequest(request)) + loop_->exit(-EINVAL); +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h new file mode 100644 index 000000000000..9037099988e5 --- /dev/null +++ b/src/apps/lc-compliance/multi_capture.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Raspberry Pi Ltd + * + * multi_capture.h - Multi-stream capture helper + */ + +#pragma once + +#include +#include + +#include + +#include "../common/event_loop.h" + +using FrameBufferList = std::vector>; + +class MultiCaptureBase +{ +public: + void configure(const libcamera::StreamRoles &roles); + +protected: + MultiCaptureBase(std::shared_ptr camera); + virtual ~MultiCaptureBase(); + + void start(); + void stop(); + + std::vector + prepareBuffers(unsigned int numRequests, unsigned int numStreams); + + virtual void requestComplete(libcamera::Request *request) = 0; + virtual void updateConfig() = 0; + + EventLoop *loop_; + + std::shared_ptr camera_; + std::unique_ptr allocator_; + std::unique_ptr config_; + std::vector> requests_; +}; + +class MultiCapture : public MultiCaptureBase +{ +public: + MultiCapture(std::shared_ptr camera); + + void capture(unsigned int numRequests, unsigned int numStreams); + +protected: + int queueRequest(libcamera::Request *request); + void requestComplete(libcamera::Request *request) override; + + void updateConfig() override {} + + unsigned int queueCount_; + unsigned int captureCount_; + unsigned int captureLimit_; +}; From patchwork Fri Jan 27 15:43:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18214 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 62B07C3299 for ; Fri, 27 Jan 2023 15:43:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E0BB6260E; Fri, 27 Jan 2023 16:43:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834233; bh=CR3beotvVv+IR6MJ9i1aC77DfZeOx13xFujkR6NZtX0=; 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=qNvptr7aMm7njT9sis0aTqnwq4xLcwn1XOseMehFq7n34LWffiF45EOsYHjGM4SYp 7RpFg0f7mznj4V469cgcAG+hHos83NPp27RQEHi1G8DUM0GZcI72yclAKCkAPl9F2T y1VeAKfyyPTXMW/lWC1WdJqMXJ8wy+W6gHXW+r7OhnszBG141oN0g2HCRdcMq7XYhL MBTVDCeY/8TyfCSw5yZvU8G7+vgqVGfU0OKAQc3IhZmGZ60PM6IbXSgooQ7lrr0/s7 wlRtC2GtnBV5VTQOYoSFaYZUxy7+S5CsnE6Cm4JqY3kGNDK24D7GTMWyju6+3GuR7A 764Ext8fxj/1A== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6071062605 for ; Fri, 27 Jan 2023 16:43:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="p2zS6brG"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id m15so3740760wms.4 for ; Fri, 27 Jan 2023 07:43:45 -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=/hgBGNe9687TY2y9ydcpdr81a5GOgRL+7LnWjqWMLcw=; b=p2zS6brGgO0J/UmSHc2dR+MNF+GeU9QdHCaTDmS5Mn9kaBiXnwch2+Vck13Rv6c8zq tCrPD5585wXllHLOPfDU47DefGwRGKJr6fJMTXuEOGkV6WFXxUsyiJSqWACZ28ZEEneM 4TDDx0Y+UbXhD/8ODkTCNja+oyw/+5KtF3vWEFeakQqbdR0yC/lAu8fPgTqe0A3L9qmW Hl0o90FSe7ZW/Dg5DR0PIk0I/+z3zgSQ8zv1Qd3bCQ3/OsYk+bWzxUbok5ShsuqEIzIF 0SLxcuIdHhPRRqTObzBO8nyaiRah1bHFgMX7OElHfLFy/uPOWf7pAp1g/OaAXHYOrvKn tfDQ== 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=/hgBGNe9687TY2y9ydcpdr81a5GOgRL+7LnWjqWMLcw=; b=QSXz9uVirnveus/vO0y7AXI6FkRU1/VDbvyRpfU9MIi+l6a/rgMsykzLfNdnv6rPu/ kAWIbgq99GTt9uzi0boEf70Tht2t/9RaUdn7pBCw//nh0gAzwcVYjegZm5is4Vf6fUyY WjGLffER3M/n6eczLP3NcvwD0ug5YPhPBzv59M0masGIx2GD7/T2ahAEceWuxCZxrzxf gFGgC/bfRHjnvucQSwb5P/C9KswZSidxTv14W/AFSEK7iYFn9sIYqFgLvLXykmzo2k7Z Q6rO1djoe/UgCIK8idV9yv6G1N3v+cprncSke+Rc4m8OyvofIAPGCaWJ44WpMrsBMjji pVZA== X-Gm-Message-State: AFqh2kqxDTZX/Ne0S3AzOy+2CM0pbK/2Ex10RIY9+q/k2OMvVUIgND6O OIPgaW3sQLIf7xUb3olBzWdqL5pd8FLxVyG6ECY= X-Google-Smtp-Source: AMrXdXugLXhZa8lRtuRFIQsMOfkqyI1NSAsFoemJrSXhUzwQd6L8VH4a4iece2Ym0ajxguUIC9llfg== X-Received: by 2002:a05:600c:1e08:b0:3da:f443:9f0f with SMTP id ay8-20020a05600c1e0800b003daf4439f0fmr41127887wmb.18.1674834224149; Fri, 27 Jan 2023 07:43:44 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:21 +0000 Message-Id: <20230127154322.29019-15-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 14/15] libcamera: apps: lcc: Add optional stream tests 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 test class, MultiCaptureOptional. This tests operating with multiple streams, where one of the two streams is not provided buffers in certain requests. Signed-off-by: Naushir Patuck --- src/apps/lc-compliance/capture_test.cpp | 20 +++++++++ src/apps/lc-compliance/multi_capture.cpp | 53 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 9 ++++ 3 files changed, 82 insertions(+) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 8d534161e985..c6a09a63248a 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -209,6 +209,26 @@ TEST_P(MultiStream, Capture) capture.capture(numRequests, NumStreams); } +/* + * Test optional stream capture cycles + * + * Do not provide buffers for all streams in all Requests, testing that stream + * output can be optional. + */ +TEST_P(MultiStream, CaptureOptional) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCaptureOptional capture(camera_); + + capture.configure({ roles.first, roles.second }); + + capture.capture(numRequests, NumStreams, 0); + capture.capture(numRequests, NumStreams, 1); +} + INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, MultiStream, testing::Combine(testing::ValuesIn(MULTIROLES), diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp index 23becf964fd7..a011dfb285c8 100644 --- a/src/apps/lc-compliance/multi_capture.cpp +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -185,3 +185,56 @@ void MultiCapture::requestComplete(Request *request) if (queueRequest(request)) loop_->exit(-EINVAL); } + +/* MultiCaptureOptional */ + +MultiCaptureOptional::MultiCaptureOptional(std::shared_ptr camera) + : MultiCapture(camera) +{ +} + +void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStreams, + unsigned int optionalStream) +{ + start(); + + queueCount_ = 0; + captureCount_ = 0; + captureLimit_ = numRequests; + + std::vector + buffers = prepareBuffers(numRequests, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue the recommended number of requests. */ + const unsigned int inFlightRequests = config_->at(0).bufferCount; + for (unsigned int i = 0; i < inFlightRequests; i++) { + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + if (j == optionalStream && !i) + continue; + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[i].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(queueRequest(request.get()), 0) + << "Failed to queue request"; + requests_.push_back(std::move(request)); + } + + /* Run capture session. */ + loop_ = new EventLoop(); + loop_->exec(); + stop(); + delete loop_; + + ASSERT_EQ(captureCount_, captureLimit_); +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h index 9037099988e5..3d92ba3d4c10 100644 --- a/src/apps/lc-compliance/multi_capture.h +++ b/src/apps/lc-compliance/multi_capture.h @@ -59,3 +59,12 @@ protected: unsigned int captureCount_; unsigned int captureLimit_; }; + +class MultiCaptureOptional : public MultiCapture +{ +public: + MultiCaptureOptional(std::shared_ptr camera); + + void capture(unsigned int numRequests, unsigned int numStreams, + unsigned int optionalStream); +}; From patchwork Fri Jan 27 15:43:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18215 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 E5B80C3242 for ; Fri, 27 Jan 2023 15:43:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AEA862612; Fri, 27 Jan 2023 16:43:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834233; bh=LUAtUnrEzmwGTWKwtNC+GNZf02WnRv8bO7rk/b6Yt0Y=; 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=XGiHL5GRqbZFGr5agKmCrObAtXmIuXeR0JSlZX6vsEKaGT0m2vLwT43zocNQynEwM oKWiGNTDfFh3LZW6nWGbHrs2UrzEDP4NNjNdsyr1eYTemSsyvH9ID769QIjFIzea82 gSyJbXocz91V/XxzT0lNYCxhXMqPwpWvW8ZBxCnD/HYVpjdwwIPBwQhiF3Uy0Ph6rE zgRmMVYIV2zL/s4xY5eZOSEkTAwvnl8UPzzOKtSETKfUT9PZbHEyzXchT0mqVsVTkG SKVzqiGxEtH8rJabH1bSTOsE9t6b904PdE2w0QAvzs6cP2l45v+wlBkSblifGwiRI5 TbNMhfxYW5I5A== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 80E36625E8 for ; Fri, 27 Jan 2023 16:43:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UrRL6Iyr"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id f19-20020a1c6a13000000b003db0ef4dedcso5681788wmc.4 for ; Fri, 27 Jan 2023 07:43:45 -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=2scObb81b/oIwD4q0wu6Jc8r9Izoe6TDhaQrbOzkfu8=; b=UrRL6IyrVsoQzDnEIjQMdcflk5yemW4cHLz0L1ccej3jbBW3kOfzsVDAZ5J8wAm2tz YppcFEbwg9+MFptqJVLeEjbfIP7/lX2SHyljeIoHN3oyTr9hfX/FRJmEj51elw0/EtMW Tdc44lB2TITgGDxhFhY/YVAw+CMySeMhk9eZQpvFhMA/ksVWQ+ijY6qH5fGydZ8i97b3 uhR2Lsy5eZ7x/e9n4H2lY3/DcmIkIHpo99mZ18CHdcusN7CzHv9Ln1JZYOkWLdac1pna VbsGv14YbK469YzYjHTiz2MNXpmjDMKveoDdC/5RfxnxqsLW1pUFayX9x+hhSZw/RtDr fStw== 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=2scObb81b/oIwD4q0wu6Jc8r9Izoe6TDhaQrbOzkfu8=; b=xTg9LkEc5LZrkJCVKmoMe93I+lMZCegq6DEz2Nfb7WOQMry6U53mpRcIrdRSX5pjYc C+Mhn6Wqhy80Brt2BnuZhWs7LW5OAPmjDR7QywDuOQ0f82vp+vqbzLOIH9rFDnFNfVCv N0BUJi9xt/k4CJSMCCaLkBtVCeCXzruqwB2a+Q9gvVMpKADH96Py/oGmdHNb5/yBfySr gAHTeB0EDWTlA3JjJvSVpKw52UC1+Tz2Fjqn5deAfU6GfdqYAdJaaRywVcocn5UxKXxG NxBOm/3l059B8Uoz4Lqq2I1CbfaWgoQ/uAti8GUZY83b+VQYyCqdWSsSuN95YUDQhG00 HMmQ== X-Gm-Message-State: AFqh2kpWslU9h+6hqg9CfMsguohXZ07ltCmrkBo+HkGRiltD4XFT+hlz /S0lNCpJWpeA6na4L0FUI3HV6qds8QZCPMHCN50= X-Google-Smtp-Source: AMrXdXvLOxvsiDqojxAw1iu/Xza5r6/KS3fJc9KEHwfHgcz3mpI90OMwL1s0iUUIROimDI/08XjXvw== X-Received: by 2002:a05:600c:540d:b0:3d9:fb59:c16b with SMTP id he13-20020a05600c540d00b003d9fb59c16bmr37122954wmb.36.1674834224748; Fri, 27 Jan 2023 07:43:44 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:44 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:22 +0000 Message-Id: <20230127154322.29019-16-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 15/15] libcamera: apps: lcc: Add stream hints test 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 test class, MultiCaptureHints. This tests the MandatoryStream hint flag and ensures that requests are cancelled correctly if the flag is set and no buffer is provided. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/apps/lc-compliance/capture_test.cpp | 21 +++++++++++ src/apps/lc-compliance/multi_capture.cpp | 48 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 17 +++++++++ 3 files changed, 86 insertions(+) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index c6a09a63248a..9239e8b5fc8a 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -229,6 +229,27 @@ TEST_P(MultiStream, CaptureOptional) capture.capture(numRequests, NumStreams, 1); } +/* + * Test mandatory stream hints + * + * Mark a single stream as mandatory, and don't provide a buffer for it in the + * request. This should case the queueRequest call to fail. + */ +TEST_P(MultiStream, CaptureHints) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCaptureHints capture0(camera_, 0); + capture0.configure({ roles.first, roles.second }); + capture0.capture(NumStreams); + + MultiCaptureHints capture1(camera_, 1); + capture1.configure({ roles.first, roles.second }); + capture1.capture(NumStreams); +} + INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, MultiStream, testing::Combine(testing::ValuesIn(MULTIROLES), diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp index a011dfb285c8..6aa39b7e281f 100644 --- a/src/apps/lc-compliance/multi_capture.cpp +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -238,3 +238,51 @@ void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStr ASSERT_EQ(captureCount_, captureLimit_); } + +/* MultiCaptureHints */ + +MultiCaptureHints::MultiCaptureHints(std::shared_ptr camera, + unsigned int mandatoryStream) + : MultiCaptureBase(camera), mandatoryStream_(mandatoryStream) +{ +} + +void MultiCaptureHints::capture(unsigned int numStreams) +{ + start(); + + std::vector + buffers = prepareBuffers(config_->at(0).bufferCount, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue a single request */ + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + /* + * Do not add a buffer for the mandatory stream to cause a + * deliberate failure. + */ + if (j == mandatoryStream_) + continue; + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[0].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(camera_->queueRequest(request.get()), -ENOMEM) + << "queueRequest did not fail!"; + + stop(); +} + +void MultiCaptureHints::updateConfig() +{ + config_.get()->at(mandatoryStream_).hints = StreamConfiguration::Hint::MandatoryStream; +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h index 3d92ba3d4c10..c48c16e7565d 100644 --- a/src/apps/lc-compliance/multi_capture.h +++ b/src/apps/lc-compliance/multi_capture.h @@ -68,3 +68,20 @@ public: void capture(unsigned int numRequests, unsigned int numStreams, unsigned int optionalStream); }; + +class MultiCaptureHints : public MultiCaptureBase +{ +public: + MultiCaptureHints(std::shared_ptr camera, + unsigned int mandatoryStream); + + void capture(unsigned int numStreams); + +private: + void updateConfig() override; + void requestComplete([[maybe_unused]] libcamera::Request *request) override + { + } + + unsigned int mandatoryStream_; +};