From patchwork Tue Dec 6 13:54:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17944 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 5EE13BE08B for ; Tue, 6 Dec 2022 13:55:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 84E4C63344; Tue, 6 Dec 2022 14:55:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334908; bh=6TPR2QHCOzSmsRgML58GJeHoEheaiRbUfY1Sp25II2M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KL16v4OTKQbdsyFFG1C7h7javm1MuXbg8MmSN7/ntAQtvWF1GEa86JxxpN03JBMqR S3NdO8aD+TztRkTE+y7Z+PXXo1182B1y2WETl+CZPtm+44Bsb9SJ96fb/eQNlTcwrA 021HBXI+klyT/GpNAHM67TtZH/wsrd/NPhQxRZ8JkLGp/YtlDuJX5WP6kOZQr8m9U/ yApQHRnN6rJGbv3pPWc65xK98TtB8zM+bmKqPV6AyY8s0s4Zd4ww/eHGaZnPoXZgcV DLhOUoiTxd6vrPNR8pE2fUVBC4WK0PzYc0OVQcdEApXuHM6FGAFObkSeDru2Ax+PX1 L/0vHOvU4J36w== 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 8B14063331 for ; Tue, 6 Dec 2022 14:55:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="reTMIBef"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id l26so5001163wms.4 for ; Tue, 06 Dec 2022 05:55:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+2T3ZLVGJwVrydTkz6iNKwj5oO6lQf9kYT88gPluNzs=; b=reTMIBefKEXPWQjKL012biBubEyT6uYfbOAGwaHBAujBYnzFsT4dDFahoobWXuN/Y5 DBsZTZ+ANzOrH0Rp5qzl5qtE2BK/MGyhr9dtVie1/B23MgmtA0mu3iIc3+oPNjiEZV1Z zkJzxd6EHDbpJL18Elo2B0N9ba/n9nnKCqQseTYF35BjZRzDAlqe5VM0EdFrJ42vbYTN 4rgURch2lb7GFJox1klOoACNLdIw2Ix1MuomMqZVgo9I3cpr2JlNgjt6Qf2pwMXhMH/9 WFIHhiBiJIOsaNL5hzJjfCgW/zl7Zp/D8os7Wyj9I5hC4JTmu1xDqI8zUXxO/8M/uiih PV4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+2T3ZLVGJwVrydTkz6iNKwj5oO6lQf9kYT88gPluNzs=; b=3v7Uq0ZY74B1ogyX1ld5tVHVaAC3ntp5kSE0w0Gqf8aJUweWshNDDdZ6cRzVytnE25 AZYhV+ZJWqJo/Qnp/NSh4Z/NVwnrpTZrRszylHnT1dr4XvJFRBfYFd0oSxDqLnwhKjGK EOZr5P8613DTFHbx0Co3zH4AaPuQasZq6/5pgVxSPXxjP5jRuDM+qxQsHvAv74HurwI7 w1gUFwA1YivzgEvaKIPBkUjC/aj50WdxH7w2S7334/z5lGRSDCx76uZUkfE2oTcxObLN EcyTsN4yLE1FmXsCCLICGa5LKtgYSIRlVDOTLeVzVJaHoRHdTTarcGvNp8s1O+G7dRbb 3+2Q== X-Gm-Message-State: ANoB5pnPwji3iTvDeATdR/t8ckgXzWKLC6urxSOSVH3IxSrwH97cLXPW 4apS4j5NbWZGyVUHa2lTlAj/OeUxr+oD6L7U X-Google-Smtp-Source: AA0mqf59LzXAMKHHcA3affymZr/l18lG6hS0wjJS7Q4FMgKlwHAuAu8C015eJvTVTi+DgEaPci9fnw== X-Received: by 2002:a05:600c:3ba1:b0:3d0:47c:9ff5 with SMTP id n33-20020a05600c3ba100b003d0047c9ff5mr56847197wms.121.1670334905894; Tue, 06 Dec 2022 05:55:05 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:05 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:47 +0000 Message-Id: <20221206135459.25521-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 01/13] libcamera: stream: Add stream hints to StreamConfiguration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new hints flags field in the StreamConfiguration structure to allow the application to specify certain intended behavior when driving libcamera. Pipeline handlers are expected to look at these hint flags and may optimise internal operations based on them. Currently, only one flag is listed, MandatoryRequestBuffer, which the application sets to guarantee that a buffer will be provided in the Request for each configured stream. Signed-off-by: Naushir Patuck --- include/libcamera/stream.h | 8 ++++++++ src/libcamera/stream.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 29235ddf0d8a..1c5273004297 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -51,6 +53,12 @@ struct StreamConfiguration { std::optional colorSpace; + enum class Hint { + None = 0, + MandatoryRequestBuffer = (1 << 0), + }; + Flags hints; + Stream *stream() const { return stream_; } void setStream(Stream *stream) { stream_ = stream; } const StreamFormats &formats() const { return formats_; } diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 67f308157fbf..504c6d86cd04 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -349,6 +349,30 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) * color spaces can be supported and in what combinations. */ +/** + * \enum StreamConfiguration::Hint + * \brief List of available hint flags provided by the application for a stream + * + * \var StreamConfiguration::Hint::None + * No hints for this stream. + * \var StreamConfiguration::Hint::MandatoryRequestBuffer + * Informs the pipeline handler that the application guarantee to provide a + * buffer for the configured stream in the Request. This may allow the pipeline + * handler to allocate fewer (or no) buffers for internal use. + */ + +/** + * \var StreamConfiguration::hints + * \brief Application provided StreamConfiguration::Hint flags for specific + * stream behavior + * + * Provides hints from the application to the pipeline handlers on how it + * intends on handling a given configured stream. These hints may alter the + * behavior of the pipeline handlers, for example, by allocating fewer buffers + * for internal use if an application guarantees to always provide a buffer in + * the Request for a stream. + */ + /** * \fn StreamConfiguration::stream() * \brief Retrieve the stream associated with the configuration From patchwork Tue Dec 6 13:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17945 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 8CF2CBE08B for ; Tue, 6 Dec 2022 13:55:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E29CF63348; Tue, 6 Dec 2022 14:55:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334908; bh=aPx61EyK5426KHTbbJ5ftutp6M7sRBs01qIVaRATqP8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=e56UvPGTKOcRiyYmvuQfd/emd3Y/LI966nYU2BLjHFqWofgs4vUy4As9E3cs8IIm+ /gCwt0xqGbqI1BeNbXAiAKsHgYtjmRgldYRPl1YaIPlT2Q9pyuvdttWLnigqeu5fwt 7OnlcN6U8GJdjDFBqeay3A2zPQ3+IC7TtrQ7aWXmh6rPO4el7hD4jcuwhprbQuG3zb PYmIUfas+w77ASHfvXSAydIpIf+cRNP4FM3Gp6hYgv51esJVCi+kVWs2qK+Zc6CeDr IuSS+NGBiZn9jhL4he2MU7SibtymRTZMNMRoz/+hEI8rbits0p2K/ntqfq63c4dwna djnt2rzSrellQ== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4CB4263339 for ; Tue, 6 Dec 2022 14:55:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Wy20ClN5"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id h8-20020a1c2108000000b003d1efd60b65so854302wmh.0 for ; Tue, 06 Dec 2022 05:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gYE4rAs6mWLRRzePAtTOx6PsgAWDmX1Qry7rwDpq1OM=; b=Wy20ClN5o6fkskoBBcqhHpoLE2PjRegwAaGM80tounQw+yN0xEFBWL9U4J/lNuxWl/ xypL1rf7kL3Q5JOInYIMu0HS3rWXTw24sem/PVQcY64OBucgPRpe3rWuleyjZG5WOBaA VzA9gxzHC+gWaiCyTk62kM1avUU/kUcfwu9kmfVoc8OZPxUKSo0HB03o+q4W88ns6itd tbPeEVDo1Od3ZNWf3nalcr4+aoZmoy4Sq/S2pIE/Ioedd0ok/Z9lAcPvvq39lo2TSgGU BhlrHCYyAg4Ro2X752aRXEnR6NpvAPKo29lSMQbLerYqfWAvtK5lWW6EuCmA9AJu6zg2 +1Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gYE4rAs6mWLRRzePAtTOx6PsgAWDmX1Qry7rwDpq1OM=; b=NOLgE6TmUUmSPidplqjr8Nj6TrBWUlNU3Lhje9geBdkFn2WXi/ebYfGcp7KYvi8Qdm HrrskVEjQJcyLnNEw+Hcyie16LGzX5ygBbqxb5Nxulvs6AoqM3yIjN1Ljag2duK67u/O ughJDbUfaB763CnLlb6i1N1+739IYGBLIXpuO6KfsEunue8z5xyJHxSEHYfXciQfznkJ i6VGWsTEjf86rqGR8UsRlfCYpYuqae1S93oIdZebRARzwEe10XhescIjF1gVCIVxaF3V qJOz/lNRhRf46yvI7uYyidYlLOzKDHiw+i3etCAZMqQR6SLIm9EaGYsRfO9WrcBWfGyJ znCg== X-Gm-Message-State: ANoB5pnQ/eDGogHiqhf7ia51yeTprp3N5nHmhWy2OjxWZ+GK+jsJkTZi aVddspFXWYiOxrmcJxxEhHnM4XRWLsTu8Rjk X-Google-Smtp-Source: AA0mqf7VoXjA7ELQ+kjHxzSPtvYVh3yhxVHxKirY5adYql/nUgqh4hSe8hgWvJ8og+yudin9YRQ0mQ== X-Received: by 2002:a05:600c:2284:b0:3d0:837c:8561 with SMTP id 4-20020a05600c228400b003d0837c8561mr14397919wmf.168.1670334906673; Tue, 06 Dec 2022 05:55:06 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:06 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:48 +0000 Message-Id: <20221206135459.25521-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 02/13] libcamera: pipeline: Add a platform configuration file helper X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new helper function PipelineHandler::configurationFile() that returns the full path of a named configuration file. This configuration file may be read by pipeline handlers for platform specific configuration parameters on initialisation. The mechanism for searching for the configuration file is similar to the IPA configuration file: - In the source tree if libcamera is not installed - Otherwise in standard system locations (etc and share directories). When stored in the source tree, configuration files shall be located in a 'data' subdirectory of their respective pipeline handler directory. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- include/libcamera/internal/pipeline_handler.h | 3 + src/libcamera/pipeline_handler.cpp | 60 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index ec4f662d7399..4c4dfe62a680 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -65,6 +65,9 @@ public: bool completeBuffer(Request *request, FrameBuffer *buffer); void completeRequest(Request *request); + std::string configurationFile(const std::string &subdir, + const std::string &name) const; + const char *name() const { return name_; } protected: diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index cfade4908118..a515ad5ecffb 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -8,6 +8,7 @@ #include "libcamera/internal/pipeline_handler.h" #include +#include #include #include @@ -534,6 +535,65 @@ void PipelineHandler::completeRequest(Request *request) } } +/** + * \brief Retrieve the absolute path to a platform configuration file + * \param[in] subdir The pipeline handler specific subdirectory name + * \param[in] name The configuration file name + * + * This function locates a named platform configuration file and returns + * its absolute path to the pipeline handler. It searches the following + * directories, in order: + * + * - If libcamera is not installed, the src/libcamera/pipeline//data/ + * directory within the source tree ; otherwise + * - The system data (share/libcamera/pipeline/) directory. + * + * The system directories are not searched if libcamera is not installed. + * + * \return The full path to the pipeline handler configuration file, or an empty + * string if no configuration file can be found + */ +std::string PipelineHandler::configurationFile(const std::string &subdir, + const std::string &name) const +{ + std::string confPath; + struct stat statbuf; + int ret; + + std::string root = utils::libcameraSourcePath(); + if (!root.empty()) { + /* + * When libcamera is used before it is installed, load + * configuration files from the source directory. The + * configuration files are then located in the 'data' + * subdirectory of the corresponding pipeline handler. + */ + std::string confDir = root + "src/libcamera/pipeline/"; + confPath = confDir + subdir + "/data/" + name; + + LOG(Pipeline, Info) + << "libcamera is not installed. Loading platform configuration file from '" + << confPath << "'"; + + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } else { + /* Else look in the system locations. */ + confPath = std::string(LIBCAMERA_DATA_DIR) + + "/pipeline/" + subdir + '/' + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + + LOG(Pipeline, Error) + << "Configuration file '" << confPath + << "' not found for pipeline handler '" << PipelineHandler::name() << "'"; + + return std::string(); +} + /** * \brief Register a camera to the camera manager and pipeline handler * \param[in] camera The camera to be added From patchwork Tue Dec 6 13:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17946 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 1FD84C3284 for ; Tue, 6 Dec 2022 13:55:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B95A76334D; Tue, 6 Dec 2022 14:55:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334911; bh=bvVkHJiRMJT6sy5clbtelAObI9I7JqaXleneN4SN/4M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=CGXcjuwirnwjwOMBfkmkv5znO1zWtb9zHoTMLwgwAH44BDykc/rgLnLue2BLmvkn8 NW6jYPL+83aTRw+mlBHE8E9rNZ/rVmEYK1WMxNQQFrSoMJyscDAr8oOAD0oqOl6GEu lvnsZXHqEiy2/lWeRb+AOXEGByDwFMSjxhbI+Ucj8kRPf38n2wtmNCZ9gbSQvmH/Mt KJAFgVyIchHo0qneUExh93h8yLZFQ4ww2KwCjHVra88b/tdKiQZwepNmt9wTOBiPpJ XnrK2BCb5ApH2A95qRtdz9qfudzS6iW2kT69E92EHWva9Vj/FSUvc5wltygs50Uj14 KN68+Pj/IBxJw== 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 6173563331 for ; Tue, 6 Dec 2022 14:55:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gSRksd6B"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id f13-20020a1cc90d000000b003d08c4cf679so8874745wmb.5 for ; Tue, 06 Dec 2022 05:55:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zdIqKZFO5XnrvS7lzwMoLcIDnFJDKdJhRwo2YCjQSZo=; b=gSRksd6BkX1wJd325ElWc8YAFNdbgmjgUx/SfiCgLu0ztz5w1uwG77daCZ0qGxPzDT 2FO4Qr2sLMmz3v3syNX34Ue6O09bVV3kMAcrSoAZtmsQ2zOBPQRm6DN4vvIvj4PRZyfU gGLR7IX0CF06UsWl9+dcd+A5OTgSMfxmWx+TRhocOK+221IPNXxOR//CG8B7W+YYH0/b aQ3aPtGCXq6x0zNCzUjRQVkrpQCid9klrpAHQIRR/NCkz3vchY8HOdQyqmwdA1RkK8WG Lw1Gq9IvXyuWKK+dNedBUE8KLg0+xRV4ka05WAr3NWAZPX+HhzbSmHEz2U9bcBXvwn7M lrkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdIqKZFO5XnrvS7lzwMoLcIDnFJDKdJhRwo2YCjQSZo=; b=Y78pPrZleJz6SRuYaoKA43XovZTJ5D5WygEK+lHxl0wajAnNArJtAI5DSqfZjRLX9U CvbFtth18aL7if7nd1hoKVh3C5HVlArgYQZWILC5ODVcBJcwEE5WlMwNRaIGBQQYo3zM 2/UVqr53eosaFE0l4NIQ0Yku/WFMCGxeeL9WtcSlGcZfgQk4DvBXNJQ32jqlhjjjHnJq ddBZEk+0wQ/AO5PTt5MmTlti2hau9ax6NVmeW6mwXAEG7UdrQD0ZvAn3vQ90iuow9kxD hAsQu/+bNOq0T8/QTE98OXoKAVRdl27+lhDkaspAWtGOMjNcjdsmwSZwwRGApioBAwVa aEYw== X-Gm-Message-State: ANoB5pkeFAqylPQ8/25Y075joQINkQm5YaSqURf/Dtx+YJgV063vT7I5 qo/A7KtTXDnqkQVwqWF+RXfzft1bi72h35nm X-Google-Smtp-Source: AA0mqf7mswJg4oTAjcomSEwenScxiSaXN45hXidJUXakU348HfsMuyu2n6vxgBm6uOeUY0WxyTe8eQ== X-Received: by 2002:a05:600c:1ca1:b0:3d0:a68b:f7b9 with SMTP id k33-20020a05600c1ca100b003d0a68bf7b9mr9309789wms.87.1670334907425; Tue, 06 Dec 2022 05:55:07 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:06 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:49 +0000 Message-Id: <20221206135459.25521-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 03/13] pipeline: raspberrypi: Add a pipeline config structure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a configuration structure to store platform specific parameters used by the pipeline handler. Currently, these only store Unicam buffer counts, replacing the hardcoded static values in the source code. In subsequent commits, more parameters will be added to the configuration structure, and parameters will be read in through a config file. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0e0b71945640..f6388d63416b 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -199,6 +199,7 @@ public: int loadIPA(ipa::RPi::IPAInitResult *result); int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result); + int configurePipeline(); void enumerateVideoDevices(MediaLink *link); @@ -294,6 +295,21 @@ public: /* Have internal buffers been allocated? */ bool buffersAllocated_; + struct Config { + /* + * The minimum number of internal buffers to be allocated for + * the Unicam Image stream. + */ + unsigned int minUnicamBuffers; + /* + * The minimum total (internal + external) buffer count used for + * the Unicam Image stream. + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -1377,6 +1393,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me streams.insert(&data->isp_[Isp::Output0]); streams.insert(&data->isp_[Isp::Output1]); + int ret = data->configurePipeline(); + if (ret) { + LOG(RPI, Error) << "Unable to load pipeline handler configuration"; + return ret; + } + /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = @@ -1439,25 +1461,28 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) for (auto const stream : data->streams_) { unsigned int numBuffers; /* - * For Unicam, allocate a minimum of 4 buffers as we want - * to avoid any frame drops. + * For Unicam, allocate a minimum number of buffers for internal + * use as we want to avoid any frame drops. */ - constexpr unsigned int minBuffers = 4; + const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate * additional buffers to make up the minimum, but ensure - * we have at least 2 sets of internal buffers to use to - * minimise frame drops. + * we have at least minUnicamBuffers of internal buffers + * to use to minimise frame drops. */ - numBuffers = std::max(2, minBuffers - numRawBuffers); + numBuffers = std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow * similar logic as above to count all the RAW buffers * available. */ - numBuffers = numRawBuffers + std::max(2, minBuffers - numRawBuffers); + numBuffers = numRawBuffers + + std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* @@ -1630,6 +1655,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA return 0; } +int RPiCameraData::configurePipeline() +{ + config_ = { + .minUnicamBuffers = 2, + .minTotalUnicamBuffers = 4, + }; + + return 0; +} + /* * enumerateVideoDevices() iterates over the Media Controller topology, starting * at the sensor and finishing at Unicam. For each sensor, RPiCameraData stores From patchwork Tue Dec 6 13:54:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17947 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 DE0C7BE08B for ; Tue, 6 Dec 2022 13:55:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5F4B063350; Tue, 6 Dec 2022 14:55:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334912; bh=8HTIPDT/NLnYs2wOJmUDMwsBHq8KUzzKjYDz7CKniHo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=bnQKx1lrsLKJsxzq0KLRShk0BaDTM27TEhTxVZSAArccxOtpU5CKzjwq9WNOMt1OE SLA17QtOYZX8Fz4F6WKDqJj3gIwkJKDQYtzOfHFw+XgMeVG4H3ejoth9Nw6PvtJCXI j8pFq8uTg1EZuzegfiG9B0T8U3kR1uxYFhqcddf6VDxRJm++Zx6Swx6KafAfn/K9M9 zvywpM/QuwrO3scqIE5BgNEYNUuDWQjt07mKhrAjuEuiE3tpVJA5wDibLO7bF1z8cI oce+xMMtCrE9nWRg3dM9ZtiJL9z2rlDsCEtQD8GOy9ZQp2lvNJLBKjdflmMj1HfkdA tmbX4G2V825wA== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC78163346 for ; Tue, 6 Dec 2022 14:55:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="YPhG6K2U"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id h8-20020a1c2108000000b003d1efd60b65so854359wmh.0 for ; Tue, 06 Dec 2022 05:55:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Z11VugKNVYk4NrBATUQ29zE9EItJoR8a0aD1H32Zho=; b=YPhG6K2UBHSzUFotlPFnMMcVD6rAYFfJUXj2perq1d//oBfT0kFOieli71dnLgfgRS EwAxCqMbLJgz4KvKR3heksKZcodOzv1GnG2AzsjbdheEpRgWvkf+YH/C900P6GMZ0Y15 u2FanKtwYDOSRUVkymjopvUATkLWxlhVlN/2V8OM3PA00H5c3vnOs906UwJL2RcVjyow fo2nllGl4ZdueV8hhJX1w1IUSO4vy/zai+9dR6dkFcJpq31xhZ+cTKq1xGv1V/wwyhAs X/oDwuA5KBq5j5OpRwVtwqBe94JJtDoAiqaoRqQeHMgIY3KhVaxxULpwTkPOhME+e+7D bpfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Z11VugKNVYk4NrBATUQ29zE9EItJoR8a0aD1H32Zho=; b=Ft21C8D2+j5/ATaHy1shhtzYtABk2kcNPAmFEQ/u1Nq2wnhHKZvvdXUvVhkwj/3r1a mKg/gfk+zfGN+C/WehecsVYmjYYj0HxFevEnYxaZW5KJ0dpGIKxIsUEcVytA3zZRaMso p8c764Ig4TXbK6Ako3+lZkRZcOC7P6E8sQo0/JodM6NG4SsV4xygC/95Pvh7vR65ugWX H/1W+nwITQO8NCd8SmxPvevJ5RyBTTLg/J6RATcXh5VnnKv9w1Asw6btjENz9J46xckL +Lnk/Oouy2ICH85bGSINGaxpeePRXdgcF0c9srkT8FEKnKCtaR0HAwgy5R6CT87lWvaU eA8A== X-Gm-Message-State: ANoB5plLkQvfdnsLaq036jtuP7Tlop/RozKHn1jK8Q8YoQRqL2uSQUdu aoLkfujHXcTb+Lf062L5GEqYFt4i+ftKGAG6 X-Google-Smtp-Source: AA0mqf58ysPl71DJ2YVmQxSRTaGYBxSvLzgXla9RqVVvHX0+Ww7F8JsGz0Wl80CHhJfWFRkdhFOzqQ== X-Received: by 2002:a7b:c3d3:0:b0:3d1:cec6:75a8 with SMTP id t19-20020a7bc3d3000000b003d1cec675a8mr5970784wmj.206.1670334908261; Tue, 06 Dec 2022 05:55:08 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:07 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:50 +0000 Message-Id: <20221206135459.25521-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 04/13] 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 --- .../pipeline/raspberrypi/raspberrypi.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f6388d63416b..c5a489fc7581 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1036,21 +1036,6 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) RPiCameraData *data = cameraData(camera); int ret; - for (auto const stream : data->streams_) - stream->resetBuffers(); - - if (!data->buffersAllocated_) { - /* Allocate buffers for internal pipeline usage. */ - ret = prepareBuffers(camera); - if (ret) { - LOG(RPI, Error) << "Failed to allocate buffers"; - data->freeBuffers(); - stop(camera); - return ret; - } - data->buffersAllocated_ = true; - } - /* Check if a ScalerCrop control was specified. */ if (controls) data->applyScalerCrop(*controls); @@ -1067,6 +1052,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) /* Configure the number of dropped frames required on startup. */ data->dropFrameCount_ = startConfig.dropFrameCount; + for (auto const stream : data->streams_) + stream->resetBuffers(); + + if (!data->buffersAllocated_) { + /* Allocate buffers for internal pipeline usage. */ + ret = prepareBuffers(camera); + if (ret) { + LOG(RPI, Error) << "Failed to allocate buffers"; + data->freeBuffers(); + stop(camera); + return ret; + } + data->buffersAllocated_ = true; + } + /* We need to set the dropFrameCount_ before queueing buffers. */ ret = queueAllBuffers(camera); if (ret) { From patchwork Tue Dec 6 13:54:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17948 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 DC333BE08B for ; Tue, 6 Dec 2022 13:55:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6529F63355; Tue, 6 Dec 2022 14:55:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334914; bh=TT8f77VfTo8ZsU6VKEbwskQdfs0h8NsHNAVP1IObN3A=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sLSYMpbghkoDOQbYvLqMNnXqrjE+CZQhjxHms1NuvjASAfAS70UrLC9vm8aXT/+CO LJoBC1yhXO3QETMUVU5imSlqzz+Uf9SWw/zMlNHY2y7sqvxEsVx2r5tBQ2u2f/koa8 I2702NpZ3gy58Uuyb8Ax+x2HMzK4CLZzuZbIM5/KTzU6XeqliLA9X9F0qYj2AColog khFPoTX6Q6f6Kzwj/QvoxTJoeuJuVcO0szo9wNowabbiHendwZr0pOnahretlyjR7i DU4qmYi+Qi46uz/OKq65vY9tIKrpJJ+23xytC6LKhgbTYbm0YfgKiAvQE82M1DAx8R sg+YWLo2PbrDg== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7908463340 for ; Tue, 6 Dec 2022 14:55:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TwdQq6sO"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id j5-20020a05600c410500b003cfa9c0ea76so12704468wmi.3 for ; Tue, 06 Dec 2022 05:55:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=piRa1vTJhlTRtSSbS36pBvVbQZnm13Bd6mtMgWMjARU=; b=TwdQq6sOPdWFHPp3QNwdjsMceu4HFp/ks/BI2u0/ua623bFbZjAcRxytt71CT+SeOA mCSNd93NZVvyEp+Em4lGZStW2SjrfzYWmaHDuWU2BQ/a+IKuDZSjHzuW0CL8weqmrApd ceBvAFvkonR9XHUVFfanxFrW8SXT0AWv0jBFo+whYMB96zllP6SjWYRu23+2ZOEmUZ96 ajeMByXGGFjC8uv4G+FvGH+DlclKwZ4wcZ1pDkwUjm366AvYTiaU3A6R772cLL1tkcNr 2XyrPT/XgvegKItvnSYXr5+iUH58o+Jpc8kvArQWC4yitFExepB9imE0y/iLwUsSjhEs mt7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=piRa1vTJhlTRtSSbS36pBvVbQZnm13Bd6mtMgWMjARU=; b=UoLfdoIMG11Wp1yaPDoMF5nUrsZjUDzsxnQrtUnbRB+ZqsONniuOA36iDwQFurMuEd 8pYQMQFXrbpkSvOiEX4v2xRM+fZXKti5YCaTDcjqBAnWi1SNDdTDC1ahkl5KHUWDVVvi QjGTOGedfDOGdp/0Z6en7qkd8hgzOShZmngaqkC7SlLqyhWAO4AN9bAM4AsGF3hYqtc+ /a0nyuxCcw/QYTAuP5SKXa5G0XWjRCIwa1N+5GL1fVehkKrj2eOB+gEKY2YXNWkWnF81 8SW9VDO7HKg0CEu3WZ8L3L4FGkF6/5A9QWNZPkbYNwUvlTPOrASRk7qOjVtRrgJuNxeH PRnA== X-Gm-Message-State: ANoB5pn+KhqzpFQCWq1YYFN0LALwRHAiWTvxM+EQzvMoAJ9Y90xc5MZS 3MtN8TO14adtzaKcSt68t6cOfshIHjDCSrvq X-Google-Smtp-Source: AA0mqf442stBLjas1vQV4VmPGSCW5FNbFzU8O1zLS8Dr5qzJlWGCnFFNS+Ia6tpmS+3CEYMCivL5Yg== X-Received: by 2002:a05:600c:792:b0:3cf:6a83:bd19 with SMTP id z18-20020a05600c079200b003cf6a83bd19mr56099201wmo.29.1670334908902; Tue, 06 Dec 2022 05:55:08 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:08 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:51 +0000 Message-Id: <20221206135459.25521-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 05/13] pipeline: raspberrypi: Handle MandatoryRequestBuffer hints for Unicam Image X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Look for MandatoryRequestBuffer flag in the hints field of the Unicam Image StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for Unicam Image, so override the minUnicamBuffers and minTotalUnicamBuffers config parameters in the following way: - If startup drop frames are required, allocate at least 1 internal buffer. - If no startup drop frames are required, do not allocate any internal buffers. All other buffer allocations remain unchanged. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index c5a489fc7581..8be46962e825 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1447,12 +1447,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) int PipelineHandlerRPi::prepareBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); - unsigned int numRawBuffers = 0; + unsigned int minUnicamBuffers = data->config_.minUnicamBuffers, + minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers, + numRawBuffers = 0; int ret; for (Stream *s : camera->streams()) { - if (isRaw(s->configuration().pixelFormat)) { + if (s == &data->unicam_[Unicam::Image]) { numRawBuffers = s->configuration().bufferCount; + /* + * If the application provides a guarantees that Unicam + * image buffers will always be provided for the RAW stream + * in a Request, we need: + * - at least 1 internal Unicam buffer to handle startup frame drops, + * - no internal Unicam buffers if there are no startup frame drops. + */ + if (s->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1464,7 +1485,6 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * For Unicam, allocate a minimum number of buffers for internal * use as we want to avoid any frame drops. */ - const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate @@ -1472,8 +1492,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * we have at least minUnicamBuffers of internal buffers * to use to minimise frame drops. */ - numBuffers = std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + numBuffers = std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow @@ -1481,15 +1501,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * available. */ numBuffers = numRawBuffers + - std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* * Embedded data buffers are (currently) for internal use, * so allocate the minimum required to avoid frame drops. */ - numBuffers = minBuffers; + numBuffers = data->config_.minTotalUnicamBuffers; } else { /* * Since the ISP runs synchronous with the IPA and requests, From patchwork Tue Dec 6 13:54:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17949 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 83E16BE08B for ; Tue, 6 Dec 2022 13:55:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 404F86335A; Tue, 6 Dec 2022 14:55:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334915; bh=Xj0bGDCTa+sLhiEEMJUoLKoRyztC8WQjfciY93nch7s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JTI+tf2ntoITtptoBoWQO+QKnJMuJW+PAL4FqvI+RpeIfmFw0ywzzW6spz5Yv8g6+ U2e63gKJYES3AfD3+21p+rM9CrxZ4l/NilxJKms7B7pgVNvjkuTgUCpuL65Uvxkae9 Lpw2gr5JXIGZtg1zL+mjhzOT2flUlBxgtiiUZu08ILvRLJ+IYm1M+6Yxg666664RgM ArP1K2Dn0QtMaRhLb9vFv6y2SH92Ah3FwkTCeP+uER98SakwJqxuZRoy06bMmumrld KFBP9d7GZvRl1dbPzCLykATKOH36mHIDsWIjLxdM1zha13SjF/TnJY00WeLcx/V9T1 2cHC0tX/EBIcQ== 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 206E6603CD for ; Tue, 6 Dec 2022 14:55:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="WuAtZ/PZ"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id ay14-20020a05600c1e0e00b003cf6ab34b61so14325182wmb.2 for ; Tue, 06 Dec 2022 05:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9OcVoP2hdkkL69hfmYoyijjSQmy4nAYNEAi45K1BQd4=; b=WuAtZ/PZFsDHDS+XS5y2mt9t5njHaQKxLg5v7clHVOJWJ8FlhuGBFDVp9Q6YEn1yMX nESoTTAgcd2GKjZbMRYzetxcW+vkHfJvAUGw1qvU1p+ZmzB7N7qLgUPAyqYUj5Eo5paU m0ltJkQgEk6zD5ri99O75GZa9Af8lPF9Vpbil8zGna8ynyUgrkFZyeyBWCssd+1aUcQq x3ax00tA4om2hmPp1x+VhzBBTkWictGp6jz5eO0zD40G+bZLvxKqIEpFfAH+C0agr2qM EcWiIf4RZ4Edl4kQ+qvAvQ1IMkS/8LR2BTBd5g47nv+Y+boxt9pmA+IZGh24Hnd2f/oN GREA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9OcVoP2hdkkL69hfmYoyijjSQmy4nAYNEAi45K1BQd4=; b=k8mrcx2L7ofttr5bKg9beSyjHH8zVAgY/GIfreWO68U4SX1lU5qzs44GALYHkAQz1z XFz9YYaL8J8Ke8+JpjIwe/UnIo/AC5tf/RGfLK0C6prjn9iJuH4f2XiqSjtgAYKw1UmE Yfk2uMbLvGoZtzEKjXFcPW7v07cSqm8hFNVw+B4HmnkleJtXrlGygH7Oy/PHjgMBUu0p cLx+dwErqsRgTA9WF7mYmfexRuBIa7g+Y1tud/7YNDaJlCzMPCXBEWLJr3n6knGOb+04 Gik+zPJbmibSrp6x3bg9XgN/Fo0aKyl/ElL4MbwdlUNlg9w3XH1Yzu6b2IdpVOXqI/vs XraA== X-Gm-Message-State: ANoB5pmDj3Qu4GChN2P3IGvYjxrt/7zwo1hIpQneQ1mAvDbT6pQedn/1 Tc9n4FXjhFVjgw0QiipHsSFBEWSjtVQXOSdp X-Google-Smtp-Source: AA0mqf7EbD9XGcyDY4ToQQlr0eyILbUJHlcq2zROqYdReyfBBCmVhTAS/knEbQpQ7OSXRLVk/w7oLw== X-Received: by 2002:a7b:cb97:0:b0:3cf:ac0d:3f80 with SMTP id m23-20020a7bcb97000000b003cfac0d3f80mr49091306wmi.185.1670334909638; Tue, 06 Dec 2022 05:55:09 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:09 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:52 +0000 Message-Id: <20221206135459.25521-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 06/13] libcamera: pipeline: build: Add pipeline_data_dir variable X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a pipeline_data_dir variable to the meson build files. This variable points to the location of pipeline handler specific configuration files on the filesystem. Signed-off-by: Naushir Patuck --- src/libcamera/pipeline/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcamera/pipeline/meson.build b/src/libcamera/pipeline/meson.build index 30dc5b97f1dc..f14869f3a3c0 100644 --- a/src/libcamera/pipeline/meson.build +++ b/src/libcamera/pipeline/meson.build @@ -1,5 +1,8 @@ # SPDX-License-Identifier: CC0-1.0 +# Location of pipeline specific configuration files +pipeline_data_dir = libcamera_datadir / 'pipeline' + foreach pipeline : pipelines subdir(pipeline) endforeach From patchwork Tue Dec 6 13:54:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17950 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 B587BBE08B for ; Tue, 6 Dec 2022 13:55:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5584C63353; Tue, 6 Dec 2022 14:55:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334916; bh=T2AFAJs4vn9DNlKuZuL/tmptwUv4dxoMe2SbNdHpca4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OkcEbUM+fWIlzaaP7bhs3+GOBL31OnXN9EgLz5u0gmpTsSfQ4EUEcyidUcpW0KXri QIGchV3o6TfLevrvG90QyGgGwVceknJnjO9RUOie3Th8MrSIM3US1oZYQ06m2Xj4eq 4RJ19BIZd3SDtiI70fC7cGFdCpOMz3UZn+O9KmHiUW10d79JDNaZS/8gXiKO1euu7P D+dsaholFzk3Nlzleg5DJof4La+BmJoGJsh37zCQEhyZoWplNgHdcoscvwcDY3LgRq t1gO3P80/OcCr8+vVo+KpGUqEYngMuh2Qj9jeX0/eC9eAe3M05dws633HQZg8Hkseq TZUEcZ8XRHvEQ== 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 F407663346 for ; Tue, 6 Dec 2022 14:55:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pBIedDe8"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id ay40so4512171wmb.2 for ; Tue, 06 Dec 2022 05:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AXCdNqevCR4XHkTMpqcZ3r5O13khl/GMC4Xe7cZRkzE=; b=pBIedDe8+VW2lmM+8OjM0sOXemknz061tzewvoZ0Whgc9ouLSwTpcP85OWmVJWkACh Ssu1sZ94pDJVQ6TDdbmPWqsX7PbZzCS6n4jre+sY1mcigxl8KlUOLdkIq5bBGl9yjxUG Vg0g6DKT5PIg15pPG0PcqAp61sfAOjcK4Hby8cpsmmOnC2q7++eMApUSEOmrJfe6cLDN /BJq+LL9Fl7MwpVpcRQeQidaet5Seh0cooDnJyPLtbV5cw/FHgnjrI9xSGwSDucnXvP8 BZgLdiUG1RN1pW8yIWOkRdtWWirAeYNpCVKAh0weox7aqF88HiBK+L82tmRzwRPtv2I/ 0MBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AXCdNqevCR4XHkTMpqcZ3r5O13khl/GMC4Xe7cZRkzE=; b=T65KYhH+3LhjdfbKc83yglvv/U7EVQfj3SxwRUKD99k/P8PkW2QjF5AV25lmy4RTCF drMTIJbQ1B+5s/U1tojSnyk6QsmJkN7cYk8FTxaWvAWhRs+nZFLmCjnoEMmDtvd7r9fh pwr6nuDxjwGLD6IdBrtcecUUmMdMhaURXjN9Yx0NwYmtakx64pa9hAlK9N3t5dDeItJ8 6voqIiNYmqElXB6j+8x2N7ZKFUSzOtZ+je1+X3Rr6d/RHQohEjevLFzoK59a5wRntL0Y 9k2eXuMX9nfUml7iI4DPluDlEFgXf/uECWczbSVnHM+NCbyu/xiWrg5uReWYRDG1goCq zmNA== X-Gm-Message-State: ANoB5pkCrPoYC2NLvR7IoOUuYyithOWNJsTW8Itsz9uQYzaakag8jx7Z 4HRbar25EW6nxRmetg3aEGhGlpEx9VbDxWtN X-Google-Smtp-Source: AA0mqf4oluQT2Gn0YuXxIBecPuY5aqoGwi/MWcQTkzvhl+pcoOVAMAcHQJUkXQ+5aghaoufUxTXm1A== X-Received: by 2002:a05:600c:1d1e:b0:3d0:4720:5293 with SMTP id l30-20020a05600c1d1e00b003d047205293mr36946703wms.176.1670334910367; Tue, 06 Dec 2022 05:55:10 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:09 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:53 +0000 Message-Id: <20221206135459.25521-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 07/13] pipeline: raspberrypi: Read config parameters from a file X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the ability to read the platform configuration parameters from a config file provided by the user through the LIBCAMERA_RPI_CONFIG_FILE environment variable. Use the PipelineHandler::configurationFile() helper to determine the full path of the file. Provide an example configuration file named example.yaml. Currently two parameters are available through the json file: "min_unicam_buffers" The minimum number of internal Unicam buffers to allocate. "min_total_unicam_buffers" The minimum number of internal + external Unicam buffers that must be allocated. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/example.yaml | 20 +++++++++ .../pipeline/raspberrypi/data/meson.build | 8 ++++ .../pipeline/raspberrypi/meson.build | 2 + .../pipeline/raspberrypi/raspberrypi.cpp | 45 +++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/example.yaml create mode 100644 src/libcamera/pipeline/raspberrypi/data/meson.build diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml new file mode 100644 index 000000000000..001a906af528 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -0,0 +1,20 @@ +{ + "version": 1.0, + "target": "bcm2835", + + "pipeline_handler": + { + # The minimum number of internal buffers to be allocated for + # Unicam. This value must be greater than 0, but less than or + # equal to min_total_unicam_buffers. + "min_unicam_buffers": 2, + + # The minimum total (internal + external) buffer count used for + # Unicam. The number of internal buffers allocated for Unicam is + # given by: + # + # internal buffer count = max(min_unicam_buffers, + # min_total_unicam_buffers - external buffer count) + "min_total_unicam_buffers": 4 + } +} diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build new file mode 100644 index 000000000000..1c70433bbcbc --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 + +conf_files = files([ + 'example.yaml', +]) + +install_data(conf_files, + install_dir : pipeline_data_dir / 'raspberrypi') diff --git a/src/libcamera/pipeline/raspberrypi/meson.build b/src/libcamera/pipeline/raspberrypi/meson.build index f1a2f5ee72c2..48235f887501 100644 --- a/src/libcamera/pipeline/raspberrypi/meson.build +++ b/src/libcamera/pipeline/raspberrypi/meson.build @@ -5,3 +5,5 @@ libcamera_sources += files([ 'raspberrypi.cpp', 'rpi_stream.cpp', ]) + +subdir('data') diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8be46962e825..9a316eda6fea 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -40,6 +41,7 @@ #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/v4l2_videodevice.h" +#include "libcamera/internal/yaml_parser.h" #include "dma_heaps.h" #include "rpi_stream.h" @@ -1149,6 +1151,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) */ stream->setExternalBuffer(buffer); } + /* * If no buffer is provided by the request for this stream, we * queue a nullptr to the stream to signify that it must use an @@ -1682,6 +1685,48 @@ int RPiCameraData::configurePipeline() .minTotalUnicamBuffers = 4, }; + char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); + if (!configFromEnv || *configFromEnv == '\0') + return 0; + + std::string filename = std::string(configFromEnv); + File file(filename); + + if (!file.open(File::OpenModeFlag::ReadOnly)) { + LOG(RPI, Error) << "Failed to open configuration file '" << filename << "'"; + return -EIO; + } + + LOG(RPI, Info) << "Using configuration file '" << filename << "'"; + + std::unique_ptr root = YamlParser::parse(file); + if (!root) { + LOG(RPI, Error) << "Failed to parse configuration file, using defaults"; + return -EINVAL; + } + + std::optional ver = (*root)["version"].get(); + if (!ver || *ver != 1.0) { + LOG(RPI, Error) << "Unexpected configuration file version reported"; + return -EINVAL; + } + + const YamlObject &phConfig = (*root)["pipeline_handler"]; + config_.minUnicamBuffers = + phConfig["min_unicam_buffers"].get(config_.minUnicamBuffers); + config_.minTotalUnicamBuffers = + phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); + + if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { + LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; + return -EINVAL; + } + + if (config_.minTotalUnicamBuffers < 1) { + LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= 1"; + return -EINVAL; + } + return 0; } From patchwork Tue Dec 6 13:54:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17951 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 5844FC3284 for ; Tue, 6 Dec 2022 13:55:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E80B63354; Tue, 6 Dec 2022 14:55:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334917; bh=B4HsZNfcearAUniari2Gs/ZcNXK742dBDnX4nBxg74U=; 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=E+icSZKp/3smkuQA4XoPTZG2h57/KhF7RPf3LLYXB2AtgX1+rYP7+bzN2/rHj7mjW b3jkWDpz/QgPFH2FdCLfBlGNPRZQ3eQmYodtWgT+JGi6jfYr0qjQzIPGJs8PSe+C09 fn1Q68Ze81qlv0ZuJKttjf7BE1qDphvHQK5ZIEacBps4l4r6xk+utypRMkbUOpPLni DIuDnGRnaXT8bEXkNHeT1BdCILF8WzegEI58ytuzycIIfUaZSYAjFhsN7Nt5HAchal u/Af90GBM4iBHzsZOixbp4xboLiStnT4GY5u20KfMWyvkKDWxXe5iNiovYXa3+09y2 RI9hSDwW3YuIg== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 216056334F for ; Tue, 6 Dec 2022 14:55:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cX9Y0EIl"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id m14so23547681wrh.7 for ; Tue, 06 Dec 2022 05:55:12 -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=r/eQrTC4AgrAqf/8TBfn9thxGdHfbJS4YvWmqv3/Dbc=; b=cX9Y0EIlEHaZHk6BFqOcH+xBzIHFFudsJZ4JbsiCntRRQRcygphFnHUX0t4hw2QPHo IH08LY3amjQYXBlzzLZKTQdqxRlvI9nuzapQor3atVnbYhYDInF8Of+o7wVwpZSHsSLb RVOykMQPxQz5Gkcz2ePm5tywoy4j3jRYPrsmxfJZkqH9u6o5zC1a5eTNR3sjGMtishcM tWphvwW2BAd5hZEHuoBcyhaEIu0QEdPd11Mfb/8T4vzQgpXcSnzqUL/kcTEHRqpEtitP 97ipCP6tbJh85flfXseuHinRPRBXjvSNv6QiLKa8IFcEMhudFQHCrrS2AtHVMxjUpkfu 4BxA== 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=r/eQrTC4AgrAqf/8TBfn9thxGdHfbJS4YvWmqv3/Dbc=; b=3G8BA+TdW6wX/qRAgz/hxXXv0Yyc0Hf98hgXqo2hwc7+gHvH6jaxP5cG7UGTSm65/B /3WIvnQi+9SYRTc4KwFXukLFB17+zSLv+CxEtXuJS+a0MKG81vCeK1CJxn64iyC4Nn7W LjpirgN59+yflos03KfvZGeuAFddelQtHemtvlSVS8piNQRz3pkA/pPwmR0BmXdMOYpN G2HttIYFJEgsaOX6tM37Wg7Wa3x6+lkU3pVMv32n/1z+bKbIfOBf3Ow0i/8UV0jHpO2a hRobtzFrKoe74gsMxKrJmKNanc75EXgLyDM6rX9RAcVLVBUbW6IroQ+EN7be5JPDpu6Y rhpg== X-Gm-Message-State: ANoB5pkZawqks7AnK+1dr89pV5+4ygI8lyuxWuMf5YJGgEe+gkzGqNFP IXMlTVjT6xucJIsEW8YVmwQuF8crANSs+1Dt X-Google-Smtp-Source: AA0mqf6muklV1AX676jjRQ+XCs4UarhsY31IeRtlW63+k76yHELBXcWjRmNBg/oStDguCxgvign1TA== X-Received: by 2002:adf:ee0f:0:b0:242:17c7:d98d with SMTP id y15-20020adfee0f000000b0024217c7d98dmr23532459wrn.87.1670334911128; Tue, 06 Dec 2022 05:55:11 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:10 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:54 +0000 Message-Id: <20221206135459.25521-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 08/13] pipeline: raspberrypi: Disable StreamOn for ISP Output0/1 when dropping 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" If the pipeline handler is required to drop startup frames by the IPA, do not call StreamOn on the ISP Output0 and Output1 device nodes from PipelineHandlerRPi::start(). This stops the ISP from generating output on those channels giving improved latency, and more crucially does not require internal buffers to be allocated to deal with this condition. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9a316eda6fea..302279ac5e01 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1088,8 +1088,18 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->state_ = RPiCameraData::State::Idle; - /* Start all streams. */ + /* + * Start all streams with the exception of ISP Output0 and Output1 if + * we are dropping some start-up frames. This saves a tiny bit of latency + * and avoids the need for allocating an Output0 buffer only to handle + * startup drop frame conditions. + */ for (auto const stream : data->streams_) { + if (data->dropFrameCount_ && + (stream == &data->isp_[Isp::Output0] || + stream == &data->isp_[Isp::Output1])) + continue; + ret = stream->dev()->streamOn(); if (ret) { stop(camera); @@ -1425,6 +1435,14 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) if (ret < 0) return ret; } else { + /* + * We haven't enabled streaming yet for Output0 and Output1 + * for startup frame drops, so don't queue any buffers. + */ + if (stream == &data->isp_[Isp::Output0] || + stream == &data->isp_[Isp::Output1]) + continue; + /* * For external streams, we must queue up a set of internal * buffers to handle the number of drop frames requested by @@ -2158,16 +2176,26 @@ void RPiCameraData::checkRequestCompleted() } /* - * Make sure we have three outputs completed in the case of a dropped - * frame. + * Only the ISP statistics output is generated when we are dropping + * frames on startup. */ if (state_ == State::IpaComplete && - ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) { + ((ispOutputCount_ == 1 && dropFrameCount_) || requestCompleted)) { state_ = State::Idle; if (dropFrameCount_) { dropFrameCount_--; LOG(RPI, Debug) << "Dropping frame at the request of the IPA (" << dropFrameCount_ << " left)"; + + /* + * If we have finished dropping startup frames, start + * streaming on the ISP Output0 and Output1 nodes for + * normal operation. + */ + if (!dropFrameCount_) { + isp_[Isp::Output0].dev()->streamOn(); + isp_[Isp::Output1].dev()->streamOn(); + } } } } From patchwork Tue Dec 6 13:54:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17952 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 12FC9BE08B for ; Tue, 6 Dec 2022 13:55:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A7CD063356; Tue, 6 Dec 2022 14:55:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334917; bh=SLhgGrpHJFQMhrTxEFNQhmxANozPE8v+5FMHPLX9wts=; 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=ASb+rqYFFEU4FmsFo4s4FlVRTJKTNSzaZnzyApFDZp7MMd0M6PvCb+Wa8wrhCRqX5 I18RN082gmoA1lHUFfrTGU6PLf/2DKifTS+sWqsGPDM8Pg7Sk3Iugk5iGUzEPyVEzB ewlwVdneL2D0k/c9rU1v3450NygOt9eJgyzpjm/vsXPab1QkPKXr8bePyGGCdVp5tB zUc5l0EZ9CvT4QJvoLUYRL7EGIT3s7qPQDedG3x/acxsR/iJpad82jP2MsKvR0rhpV +HXEafTNs+UbKFcIQglr376g0saU9tu43TXi9tgvTfg3AIzcK/rqSWyOppcwyvAJiS g2e8ed+OYJ0vw== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BDAD86334A for ; Tue, 6 Dec 2022 14:55:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="bl/gTEI7"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id y16so23574303wrm.2 for ; Tue, 06 Dec 2022 05:55:12 -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=Ccy7ljO79JZF7M7m8/PMAoKlgfWygspiQx69DEnlU1k=; b=bl/gTEI79dt0mrJ2vKtEJbzF0mdMJW6amKQMd2Nrjn2eazx9xMFdOEMItiXIs8MO21 T/5Ra05QDRct8pXVn2K1aNCDn9AjORaHnEjMMsYvdZEQoI0yf+VNwIie2Z5bd/Nh3UUH 1/tSNAKI/1+SM0rjg9UXTGtFhBwGNLmllJ//2rbembKZt1Nxz28qIqfI0h+KuR1Dj/zG oTB1zpf8zXhQ+2crhqX0CJB1We4VP0zROcK1IKhf+3f7GZHiDhBx2DshlyA5A/mhbHyM eCWK4iqPClJMSaaVdVjbR50H+944OfRPJmaN39iw3NNVtWlQFDaCn6gqshEhbd/dELQx OCng== 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=Ccy7ljO79JZF7M7m8/PMAoKlgfWygspiQx69DEnlU1k=; b=stfWAlzjkVpxMHFQI9rrKLIjkFrLxZzU8yO6VrOjBIriioz8NmkIQ/zX/lPf740xGZ OHHfSEekXHPyBOcpaHODirKdCyyQ4q72wQh4r+O4JtduxKm7Sv+yq6j2y5wMKvdeRFp2 753a0Q0m+pRI0DHg7FeUqF9PcTpXPZ8TVn0jD2l+0GoQS7NyCkYrzDDx4n97ucrQZU5E oWqeR8FecUsgEpKoPguRDS7ccskBn9x6rdbsJr3bNiGXQEsuNiiPwEvFLrkeUq7jPTbK gV4CH46no1/wZVpgHwcor2nN6AGO9kbrudBXjFlVbAkeQz1BtgRd25WQE7rXc/0LKoLF kzFA== X-Gm-Message-State: ANoB5pnrLM10fWmPsiSu12azCydhEObN/qcAR9VcB8pcUV0vwBndQNRC 3IN7veNJTHevXcYx7bYRqX0RC6wLjciU88GM X-Google-Smtp-Source: AA0mqf5pLE9HtTKcbCLKW/tSkOszWRG5HZR+FNJo1toM6LaCif6gA1Xdbq1bLPe3w9dqdhkm5UEC5A== X-Received: by 2002:a5d:5545:0:b0:242:3207:c516 with SMTP id g5-20020a5d5545000000b002423207c516mr14668167wrw.243.1670334912025; Tue, 06 Dec 2022 05:55:12 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:11 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:55 +0000 Message-Id: <20221206135459.25521-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 09/13] pipeline: raspberrypi: Handle MandatoryRequestBuffer hints for ISP Output0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Look for MandatoryRequestBuffer flag in the hints field of the ISP Output0 StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for the ISP, do not allocate any internal buffers for the device. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 302279ac5e01..371610be649a 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1470,7 +1470,7 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) RPiCameraData *data = cameraData(camera); unsigned int minUnicamBuffers = data->config_.minUnicamBuffers, minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers, - numRawBuffers = 0; + numRawBuffers = 0, minIspBuffers = 1; int ret; for (Stream *s : camera->streams()) { @@ -1494,8 +1494,21 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) minTotalUnicamBuffers = 0; } } - - break; + } else if (s == &data->isp_[Isp::Output0]) { + /* + * Since the ISP runs synchronous with the IPA and requests, + * we only ever need a maximum of one internal buffer. Any + * buffers the application wants to hold onto will already + * be exported through PipelineHandlerRPi::exportFrameBuffers(). + * + * However, as above, if the application provides a guarantee + * that the buffer will always be provided for the ISP Output0 + * stream in a Request, we don't need any internal buffers + * allocated. + */ + if (s->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer) + minIspBuffers = 0; } } @@ -1531,12 +1544,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 Tue Dec 6 13:54:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17953 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 BAB83BE08B for ; Tue, 6 Dec 2022 13:55:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7883F63352; Tue, 6 Dec 2022 14:55:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334918; bh=hPrH8CNehfseOHrZ0daJ77FFnMfBEWPFyMOoWal5a88=; 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=RQj/VU7gJ3IbZbJfylZsS8szrvbv826OVcuH0bGUEzU2L4e1J5q1rm14ISdiNZFua aroJ+ogZQxKlYAiBtWbCXMHsnBQzEnEuMjSWCDlNjiGuqo7h5d1FxuScMG7fl1jBRd F1uOkgVaxt7gcRr8NLLzG8Xjo+jb4LWYsdSZ3DiKaXlYdVibPbLmLUgj2V/nHDtTZT 9EnDDzFKgOP6b8oNQkZWkys1aozLabPrvaqaK2/rNH/ZXXKRq+ZIRvTe5Q7A9fZYi8 ahWi10ibgwYwEgWFe/p15EPvWmti56EN/zanwvXhX2ky2g2SRdrWVWQBsF9Vt1Ljts e2XiTLpnstnTg== 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 5A9726334C for ; Tue, 6 Dec 2022 14:55:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qgGzTBmO"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id bg10so11245671wmb.1 for ; Tue, 06 Dec 2022 05:55:13 -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=jEQWUxMvjV8vykabVTIkhCGKopOoqCK5oGxbLTvPt0k=; b=qgGzTBmOc8TeS4wbSSL5loqEfsatIqPuK+OcQTYhhwpDQDJJM6RPk5Ak16z9uCOPrL KR/TDwZs364V0YhgdipEamxNEyj9uKvvW54HcyPXUbB/zE8HoKN0VKmRb1BCNsFRRUK+ f39hPIcXRXvXQqvUJA3z+1mVJDfyow8wmh0xdU4BAoeGUy/mijWHqSBxgVDEPlCUdpgp vg/uBFIo4fXkGc6CLBOE1u4Oviw4tul3Glj4X2znfsHRmF4U6untWhTmTfH+4gzRDGyL Cfyy8wkRhfN/b4rgca76q4+5bAYjaivSu/qGCDf30xWDOn/lORrP/Vpd1wLuZiAhsOXU srMg== 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=jEQWUxMvjV8vykabVTIkhCGKopOoqCK5oGxbLTvPt0k=; b=wzQFIOD54S8Hna5O6GbSJ08FY7zQdTQHvdZSD80mh6OUr8GgKOUA5tHzfSMnULL+b/ /efr5lB0BEcAzVB1na2+PnCnZ6/ohIrAxpKBTOH+5nBKnRfBofLMTdk4p2TlTGJh4/Oj 10rV0+ffSKPOYEIZHDJNffZVLAJEjRYJaMZokmtlEESpofRvs/C6WHCr8cYBjV4TpyKz 36UjKXAksIjeFF+2VkigHZvhh/42yZAO35bq9hWAzCqWZkloNgxgyXJd48+fh96Dgy3l IhQWfkh+5+xYsfOXTLJdT1PCAW23vNLpzg6CoU31d/gBb6Rgvz37MsVcfNr8/aTlP/VF DAcg== X-Gm-Message-State: ANoB5pn7RA3QMES5yMtidlkaEYTV8rQFuvuNQPgbJo5zZe7uLcZDFNtp 5ufl7gWzDQLCXFMhMSpkACi8AAzcNuKairkN X-Google-Smtp-Source: AA0mqf4XmntPBf2M12w4EEAACuMKTyftKXQ1914ayPhZ8KXaf7/wgfVa7PQTFj7YzV2H0YNosYMFKQ== X-Received: by 2002:a05:600c:3ba8:b0:3cf:59c9:4a4e with SMTP id n40-20020a05600c3ba800b003cf59c94a4emr52161844wms.17.1670334912832; Tue, 06 Dec 2022 05:55:12 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:12 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:56 +0000 Message-Id: <20221206135459.25521-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 10/13] pipeline: raspberrypi: Validate MandatoryRequestBuffer in queueRequestDevice() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add some validation in queueRequestDevice() to ensure that a frame buffer is provided in a Request if the MandatoryRequestBuffer flag has been set in the StreamConfiguration for every configured stream. Signed-off-by: Naushir Patuck --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 371610be649a..b18e11bb438f 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1162,6 +1162,14 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) stream->setExternalBuffer(buffer); } + if (!buffer && (stream->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer)) { + LOG(RPI, Error) << "MandatoryRequestBuffer hint set for stream " + << stream->name() + << ", but no request buffer provided"; + return -EINVAL; + } + /* * If no buffer is provided by the request for this stream, we * queue a nullptr to the stream to signify that it must use an From patchwork Tue Dec 6 13:54:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17954 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 349C8C3284 for ; Tue, 6 Dec 2022 13:55:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E3D2063358; Tue, 6 Dec 2022 14:55:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334918; bh=7X4Zmc5yC5hboaXK50ZihMMc/kCH6ICSf0zi+pptttg=; 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=mSKx6/uzPPtwvcwkmM25odKKejCuqRaftB135JgwumF22R7yfrVt4Ih/tprb0SaET hOu6gMJyMPL+QbWqBYBkOlsyBvYaDF4rnJwZ7IeIIslq3TGza8T8ULClw1GS5fnNWQ sNV1zPWRrQaXzYNg3TGEfbxgGI4aM+M+MaYCu6jX4O3Yha0n+T0AP5OtbPUWLXKySX hS2iH2JEL66/YGNQxcXsY1Dv0Eot0ytCPjjU8Un9QTr+qhh45gFcQ1YT007xfR5eFP mfHMN/Ys43EspkhUN1mJXCYkS47IS2t3CaThKZxC/cYutTwjYlef6ipH8QEsuz5A4H pH0EU5O/XObMA== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 06EAB63354 for ; Tue, 6 Dec 2022 14:55:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="eeVF0qKB"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id m14so23547834wrh.7 for ; Tue, 06 Dec 2022 05:55:14 -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=BXVGvoqGupVb8f9IJNRqPyPFxShg6Bm934ZLTGAVIzc=; b=eeVF0qKBmt78q/Jy5q7jdN8cW4Ypbu4nsHswRdUbz0rLXsB0PooLM2S4r0JLSicweM FN7KM+W1Gt26qxb0hjraQcFLiQR0xvZeNWtMY//UWj444f1UJ61grcvLVhK/s33z/uf5 /08ldA2I3iHMq7Ris2TdsjO4cB78Ia4qkbmNAln5r6E1D8xv69gywR+I9XvUvy1w1BAb kqs+9Hg+D33Bw4Jk1Ui9zPXEKNvwllN959U3mWI/yHXi5/L2TVCxuf0WHCe7sHSas749 adOlUko4Hy1iPqMyheMdJM9RSxI73OXlNTgoT8DK5Q5t0eeyHBDiqdfN/mZHbdsfPsvm xdFA== 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=BXVGvoqGupVb8f9IJNRqPyPFxShg6Bm934ZLTGAVIzc=; b=wc1JcyLo6twfcARJ1nSBA47pVBj6T8sxk9O4Zewtdrv8Fap+OVlk4GBELrk8FQ+pSh Ait8o42KYkbHBf6FxO6PK5FXJnYOD9tVIXXh7VTUogv+wmwu0w3fS7hF7BQRW7bUtTTW uoEX1blp29QEUcMjT7V6gtfIb8WtadIH9cAfXUlP6gf+/toYcV8iJP3sLvfIRZY+iz79 2sjowfq6Fg/ubx0LtKqhfZ54pPiawmHs1tc8fl7Jq0yioEmY15BwZEJ+duynyPC2qsL2 HLJdudlfyhi3FLdLsJGA6Bx15BopxQ5Hx03W2KANBk/Q48LVmJEuB1t90TYUhoLiDpKr AczA== X-Gm-Message-State: ANoB5pmNtitR9S/trejT/BzNpLug9yVXzfub87C+VYsjgfvXC/4izOYi mSXeEMa/LAJ8mnaLzHiGgUafrfJfcWuEVsm+ X-Google-Smtp-Source: AA0mqf5KiMcYmTGoT5z2POpsCD1fRFyX3AdU4QS+6l9CopX5+0QGnj8CWfNaHk01Zw0m5cI8g7UVlw== X-Received: by 2002:adf:e849:0:b0:242:65e:95d3 with SMTP id d9-20020adfe849000000b00242065e95d3mr29669433wrn.49.1670334913517; Tue, 06 Dec 2022 05:55:13 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:13 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:57 +0000 Message-Id: <20221206135459.25521-12-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 11/13] pipeline: raspberrypi: Add a parameter to disable startup drop frames X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new pipeline config parameter "disable_startup_frame_drops" to disable any startup drop frames, overriding the IPA request. When this parameter is set, it allows the pipeline handler to run with no internally allocated Unicam buffers ("min_unicam_buffers"). Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/libcamera/pipeline/raspberrypi/data/example.yaml | 6 +++++- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml index 001a906af528..421f30e62aa3 100644 --- a/src/libcamera/pipeline/raspberrypi/data/example.yaml +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -15,6 +15,10 @@ # # internal buffer count = max(min_unicam_buffers, # min_total_unicam_buffers - external buffer count) - "min_total_unicam_buffers": 4 + "min_total_unicam_buffers": 4, + + # Override any request from the IPA to drop a number of startup + # frames. + "disable_startup_frame_drops": false } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b18e11bb438f..ffd2ba85182f 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -308,6 +308,11 @@ public: * the Unicam Image stream. */ unsigned int minTotalUnicamBuffers; + /* + * Override any request from the IPA to drop a number of startup + * frames. + */ + bool disableStartupFrameDrops; }; Config config_; @@ -1052,7 +1057,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->setSensorControls(startConfig.controls); /* Configure the number of dropped frames required on startup. */ - data->dropFrameCount_ = startConfig.dropFrameCount; + data->dropFrameCount_ = data->config_.disableStartupFrameDrops ? 0 : startConfig.dropFrameCount; for (auto const stream : data->streams_) stream->resetBuffers(); @@ -1724,6 +1729,7 @@ int RPiCameraData::configurePipeline() config_ = { .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, + .disableStartupFrameDrops = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1757,6 +1763,8 @@ int RPiCameraData::configurePipeline() phConfig["min_unicam_buffers"].get(config_.minUnicamBuffers); config_.minTotalUnicamBuffers = phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); + config_.disableStartupFrameDrops = + phConfig["disable_startup_frame_drops"].get(config_.disableStartupFrameDrops); if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; From patchwork Tue Dec 6 13:54:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17955 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 9C844BE08B for ; Tue, 6 Dec 2022 13:55:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5727B63359; Tue, 6 Dec 2022 14:55:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334920; bh=tDBmBwb4sA+f2nCv8hrEGm2SYDvJRfswWxPT3X7S88U=; 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=H5owGACbSo2pRJxgGRQNTfNjDSn/hC61t3cz7MlpM92eRUzoS6CJSXYXwntHNhdVx 7Npv+9JtYeDARbCDgrT8NsGjtsnOgfx7Ht/WxTl/3lV+ySg1uIsdjaQ6uccmrG29lu vE2ITI16WvEyAouzH01oImikA6kje8DqzQmc8LeYddZiRmn//XOge3eIo7wE3z6GXl HoMHCcoPvPr3ofi64Nci22U28FvBb7kiw7sU9xIvzQONmjzGSxRq+sH2XBX/gK+Ioa nByKZGLFsvq5XcXPMAaw6GfydoIvfJFhHSzkGMYtecA8NcnyGs6rhMWlEcnwWWKldp 2/oSTOQ+cptZg== 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 0390663359 for ; Tue, 6 Dec 2022 14:55:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cpzQ9C7G"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id m4-20020a05600c3b0400b003d1cb516ce0so663330wms.4 for ; Tue, 06 Dec 2022 05:55:15 -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=oe40j38Jy/tRf8WT1pUPWYm8Sw3EeiCXbQh8FbPbkeA=; b=cpzQ9C7G7Y3ATpVmPMLYYE3o6fajc4/gW/yErGM3JtSZt244RgQNVjJJp+1SMPof1a bby+Em+F+00fI4bzeY6TI7iJYkxta9Nhoxo+FFMdWORZ/se+LjUFgqdJBU25uo67Jf9R YWBR/xFtSGInpWoQVfE/fUyBOD7vlJNUX7oc0UFgOPhVcKfyv41UYhQMWMRNg0YR+z+G Q2/xNV5DZemGsUrNNMoG0o+FqjADkoVyaYZfl9/KjDqAYADKMVtPRAk0fEf0tTaZbwQT s7BCCZpQRVtyD5m4zd0W1ersinmyiVl71rvppiZYSf98RjVV3qX0/fAtoNgZGiPZ5/of SVOA== 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=oe40j38Jy/tRf8WT1pUPWYm8Sw3EeiCXbQh8FbPbkeA=; b=RUWL5B6JOpJJUsTJpQ3oeHDfc5BHy9ugSCQU/qCL03PwZESRsmXukS/7iv9ahzvouc 5c66+BNMNIbsAdZ3MbmuCD1DZESwLivmZkjHttcSJM+ur5kH+ZUSMUEvzzFZOLsDQ/Ei z6kKELxc/Pm4zXcg/Vbo5010WFgxwZ7PlTGgIaTR2O4FCGtLOL+5OvXP0oU52U9t65Sn 7bRqx3vw3SDCeCWir2mK3zYqLFHPPpT5D5uk5yg10apXTgUg/uHlcxMcmQ1cjBG2+lIm A6pNQDluyiU3gs59Y9gbonDeF4pusoFur2uQxRmwRkVkHzEkFcBhaosxWABTthkdd+MD BbOA== X-Gm-Message-State: ANoB5plHZywzpr2Ty6pbyzubRlyLQ1xx4OYK4gvj7XcKpSJa/Utx1U6V 59od6wmPv3p/VgXluiTgbCWPPP6e5+V0QGaf X-Google-Smtp-Source: AA0mqf4LN+qx1JDCwRAbWj2BVTPjfycUF0CMcd0QQkNEv8KDHZTyrXXb+mym3LVpU+TMao1dv3jOEw== X-Received: by 2002:a05:600c:1d09:b0:3cf:6ab3:4a0b with SMTP id l9-20020a05600c1d0900b003cf6ab34a0bmr65556823wms.91.1670334914204; Tue, 06 Dec 2022 05:55:14 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:13 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:58 +0000 Message-Id: <20221206135459.25521-13-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 12/13] pipeline: raspberrypi: Allow pipeline handler to always use the newest frame X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a pipeline config parameter "return_newest_frames" to always use the most recently captured Unicam frame when processing a request. This effectively stops the pipeline handler from queuing Unicam buffers and processing requests using the buffer at the front of the queue. Note that setting this parameter might incur unnecessary frame drops during times of high transient CPU loads where the application might not be able to provide requests quick enough. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/example.yaml | 7 +++++- .../pipeline/raspberrypi/raspberrypi.cpp | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml index 421f30e62aa3..04a117f38ada 100644 --- a/src/libcamera/pipeline/raspberrypi/data/example.yaml +++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml @@ -19,6 +19,11 @@ # Override any request from the IPA to drop a number of startup # frames. - "disable_startup_frame_drops": false + "disable_startup_frame_drops": false, + + # Always process a pending request with the last captured sensor + # frame. Note that this might lead to avoidable frame drops + # during periods of transient heavy CPU loading. + "return_newest_frames": false } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ffd2ba85182f..acf81a5beb83 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -313,6 +313,11 @@ public: * frames. */ bool disableStartupFrameDrops; + /* + * Always process a pending request with the last captured sensor + * frame. + */ + bool returnNewestFrames; }; Config config_; @@ -1730,6 +1735,7 @@ int RPiCameraData::configurePipeline() .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, .disableStartupFrameDrops = false, + .returnNewestFrames = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1765,6 +1771,8 @@ int RPiCameraData::configurePipeline() phConfig["min_total_unicam_buffers"].get(config_.minTotalUnicamBuffers); config_.disableStartupFrameDrops = phConfig["disable_startup_frame_drops"].get(config_.disableStartupFrameDrops); + config_.returnNewestFrames = + phConfig["return_newest_frames"].get(config_.returnNewestFrames); if (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) { LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers"; @@ -2354,6 +2362,21 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em if (bayerQueue_.empty()) return false; + /* + * If the pipeline is configured to only ever return the most recently + * captured frame, empty the buffer queue until a single element is + * left, corresponding to the most recent buffer. Note that this will + * likely result in possibly avoidable dropped frames. + */ + if (config_.returnNewestFrames && !unicam_[Unicam::Image].isExternal()) { + while (bayerQueue_.size() > 1) { + FrameBuffer *bayer = bayerQueue_.front().buffer; + + unicam_[Unicam::Image].returnBuffer(bayer); + bayerQueue_.pop(); + } + } + /* * Find the embedded data buffer with a matching timestamp to pass to * the IPA. Any embedded buffers with a timestamp lower than the From patchwork Tue Dec 6 13:54:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17956 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 F1364C3284 for ; Tue, 6 Dec 2022 13:55:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B94C86335E; Tue, 6 Dec 2022 14:55:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334920; bh=a3YaJE7CSXCIWHjsIpjMGKKlrxVHNtGXnCOROHKsYI0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HeVcyz3g3w06wmHUncGl3+EffYPydP+Go64Fh5nO+Ily8da/ejBtLlfFyNdrXuZP7 NYeDTcvbYII3R3twe/PGrt+QF2H6HWznPjrBaPr/H9+l3zZHYRVguzVrYC0mOIOM1V tgn+sC2p4wpzVPJUCX1/wuL+3oSoGAWkGfw4R5xUPQU/TD6bACYC1tlP1MslC3fmmE 7wS3Mbxd6jYyxc6QPPFkrWLk4pCwJh4eTfU9oHFrthdMYNd0XmwVd8+AQdjy+ba3B0 wT79donXyLU6JIqGa8gDrEXWMxzlKa30dVpkk8lVZGbNxdvBbAIzP1kL5e+5iPmy2m HKZ9JMuTREFzA== 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 75F546335C for ; Tue, 6 Dec 2022 14:55:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="dzqYglzO"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id m4-20020a05600c3b0400b003d1cb516ce0so663359wms.4 for ; Tue, 06 Dec 2022 05:55:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sWILBBIXlzAhPGU6fvcIkhjxcYBCw5crq4jorvb3iUU=; b=dzqYglzOfQxskrsTrzJZpzVyd1meLJkz2spte3XD2cZKK9yPZv9G+jcjv/e2eA/ajc ozK64aMZ0dzenqE9R6yJpi5WJaWN56rVXJKPJpRnSRT/yhgWysgB9mFx7lgAQQGY4H7O qzF2LaUSPBs4ScIwxfBIhf6xEo7XtqLhke5FqAXT8RAfY6UtIPa8Joxf2taOeQAd2ZE9 +0RnBtLfNUgsc8X9723LbzbCimihYdV6X2IaGECulJFmH+Zqh/1mo+e/9wF3GCQ/cD7Q pSOeTOgXhyNjgXAb2PVUZnOhXYLWduHTSR7lksVbv+j9ypeN6nKcUm/YMyHo031pQkbB imSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sWILBBIXlzAhPGU6fvcIkhjxcYBCw5crq4jorvb3iUU=; b=1MzmYQp5SJc0kx0SvSSXniIeY4pwQ+dAPyoYLwnxKw4UXazmkqOAydDlOyw4W76Clp CSAKSQC9dOsbnaTvlpo2eVMXfYSGCJpGXZ+v8YW4o2Y6Jz7WzfTKaZqO94D2GUgxJxeb UH8zpFoRjD0sHKwELYAX7VnYySmQjPvcVsJ0mAE8SOehiQutiW87PHw0qacV1H09yUPJ t2MZahvT8WLQlMC7LpFG1FZD8UQ75rI0seIkiZVHDQRPT6F3pOng0vM2RpXpQgP51bBh JfxjNP0TEiFCqnEuIteAmat/GeSZHGT2fB0cPdi7sP4kZ5AJbLF7jYgX/jZPaiAGivvI lXww== X-Gm-Message-State: ANoB5pkI95NAFWTcoYS9Oa7oFjg6gMJRIP2WG90l5JT3wYOnkQqmWd+L jkHCvFuC5jNmFJXIkWfqNdscc39eM9Ao0brs X-Google-Smtp-Source: AA0mqf7VJe1TMveit0puu9y5W1h3TbWConnZSgMMD0RnnqqSct4imaP4Yx5jsE1FDSpmoT66rHxpiA== X-Received: by 2002:a05:600c:4f45:b0:3cf:9be3:8d26 with SMTP id m5-20020a05600c4f4500b003cf9be38d26mr56184608wmq.185.1670334914941; Tue, 06 Dec 2022 05:55:14 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:14 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:59 +0000 Message-Id: <20221206135459.25521-14-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 13/13] pipeline: raspberrypi: Add minimal memory usage config file X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a platform configuration file that allocates the least amount of frame buffer memory possible. This configuration does come with the following compromises: - Startup frame drops are disabled, so the first few frames will not have fully converged AE/AWB/ALSC applied. - Applications must provide ISP Output0 and Unicam Image (if a RAW stream is configured) buffers in requests. - Only 1 Unicam Image buffer will be allocated if a RAW stream is not configured, causing the framerate to be effectively halved. To use the configuration on the Raspberry Pi platform, invoke the application with the following prepended to the command line: LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/raspberrypi/minimal_mem.yaml Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/meson.build | 1 + .../raspberrypi/data/minimal_mem.yaml | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build index 1c70433bbcbc..6aecd8ae68c8 100644 --- a/src/libcamera/pipeline/raspberrypi/data/meson.build +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -2,6 +2,7 @@ conf_files = files([ 'example.yaml', + 'minimal_mem.yaml', ]) install_data(conf_files, diff --git a/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml new file mode 100644 index 000000000000..5cd593025140 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.yaml @@ -0,0 +1,29 @@ +{ + "version": 1.0, + "target": "bcm2835", + + "pipeline_handler": + { + # The minimum number of internal buffers to be allocated for + # Unicam. This value must be greater than 0, but less than or + # equal to min_total_unicam_buffers. + "min_unicam_buffers": 0, + + # The minimum total (internal + external) buffer count used for + # Unicam. The number of internal buffers allocated for Unicam is + # given by: + # + # internal buffer count = max(min_unicam_buffers, + # min_total_unicam_buffers - external buffer count) + "min_total_unicam_buffers": 1, + + # Override any request from the IPA to drop a number of startup + # frames. + "disable_startup_frame_drops": true, + + # Always process a pending request with the last captured sensor + # frame. Note that this might lead to avoidable frame drops + # during periods of transient heavy CPU loading. + "return_newest_frames": false + } +}