From patchwork Tue Nov 29 13:45:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17908 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 3F5A9BE08B for ; Tue, 29 Nov 2022 13:45:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 37F296333E; Tue, 29 Nov 2022 14:45:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729540; bh=sEBfzHnphfZAo4fHYpOPsUdpXVpRV0xOAvTaMkFcF/E=; 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=TJejGBUBKtzWH14+2e/spCCnJxG/7F853a4Gwb3KRF+Y1X16GL/SsMn0tkv0FdVSZ 2rCiRvwaGnWPLCt+dTr06iL3/a0tqDQ9cpaOh1TcLlLo2KhKTzTEYN1J6goMwhmu1x EfCER+z8iHq1Nrbuv0QPNnaCW7gqmDLgmJJXqpsKiI/o2mHcYJXaTwn3KjPh60PBoJ MjZ8X/5xVsFKg2MEQ+JiKr24F9qH89AoBK2KkDlc2/R+A2R7++q4azPlF+znBhzEOW LUpVLWCYJDjl7fNz5TIwcRXgftQndvO6N5pyz5CYIxb8Dc1NDqqun2hQCsKefZ4Wmw keoGde0jnHItw== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F35A863331 for ; Tue, 29 Nov 2022 14:45:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="CeGxy6sk"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id 5so10931800wmo.1 for ; Tue, 29 Nov 2022 05:45:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=juEPIBZJVl2IlKL+jRo+h/Z5jZ0Qb5/58kfmj36PGFs=; b=CeGxy6sk4CS14gmqzUlAov5/Yc0UvR1U9rmdExWhs/FyD615T++r9LlIL4Faeb74bh 5GweChlosWGmcUXJPUwbo/znfkHBgoM1QA6USwVYGnG0SDqRYYPHRIhr9uXKIDHcIG30 JzaNd8dsc6RcFttdeNq7sIGtgIz4XvTZI1LojSRvfZrq3PSlDRVjBpI4/emcz5mt0zuc ElxUu2iEVZAJudVbWIpbNnYavn0VUgB1ft3tAr8P5ZMV1OpzI2Ma+wrmkYl+Lo+F5Lff qt9S6RZFaCoiMYFSvKrGAXdN6p8BKTGkme9dKt9Gge5aPPDGSdQseO1mMMQEkSAVUKzE sJXw== 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=juEPIBZJVl2IlKL+jRo+h/Z5jZ0Qb5/58kfmj36PGFs=; b=EatBzoUVLVQfDZMREs38efZ47TqHW4gSZM1bitF1s320J/CDD2kVIsVTOx8KFRzoK6 J1QOkhC12UWGfsPrRA4+fwwB6YNofo7QngPZruDzLrhhRVUYZyx7OjSHczv0dfoyvTIb wDpsYpb0XqUbJcVLRnTehb4PZo68DxJMyhEH7rvzUJKE0jGfPP7Iikp9nScfm/vP7kbm b3z7qC/3Y56/NNj9NPSYWO2pN2FJ2dDzyU1LnDwRSMBoEW7HTNkau8Z0S5So5pKT8v0r rWptTczRx/8ABO/OJxW66BudB5qviOzVOU77sI1E1waB44gAHx4eCiI+L6+y2iMWcIaQ /R1Q== X-Gm-Message-State: ANoB5pme1iNZ/bCzxEi9DgUwDqG1XyqSQ/pZ8oUloEixqcVJJzIZh7H5 tcNycEWdVx7xJcuDXkLKGugs/rF8LyV3pw== X-Google-Smtp-Source: AA0mqf7jC0eBG+7BoD4kp8j8AsmJDY/mC367rFMYTl2NnunG4ktbUPcaCUMbPmEnQfs2RyZvfigtwg== X-Received: by 2002:a05:600c:4e06:b0:3cf:703e:1d88 with SMTP id b6-20020a05600c4e0600b003cf703e1d88mr29731194wmq.155.1669729538330; Tue, 29 Nov 2022 05:45:38 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:37 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:25 +0000 Message-Id: <20221129134534.2933-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 01/10] 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..cd27bcf944d6 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -76,6 +76,9 @@ protected: virtual void releaseDevice(Camera *camera); + std::string configurationFile(const std::string &subdir, + const std::string &name) const; + CameraManager *manager_; private: diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index cfade4908118..b4579671ba5a 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 @@ -638,6 +639,65 @@ void PipelineHandler::disconnect() } } +/** + * \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(); +} + /** * \var PipelineHandler::manager_ * \brief The Camera manager associated with the pipeline handler From patchwork Tue Nov 29 13:45:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17909 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 94C55C3286 for ; Tue, 29 Nov 2022 13:45:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 564B163348; Tue, 29 Nov 2022 14:45:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729543; bh=OpGSWEhXix31IAek7o7Hhe3Prmyd2LN6h4IiThhE2Vo=; 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=SU4UpU/vmshwsHLhMzAzjZOU1zgb/VRSnHuSmfTxl8vnVEKYA5hAF1R0s3PhyTvts gosVjbaE8Fxr2VvV4X7pH5nXztirO1r90De4wuBvD+e6orLZ4UPU92Uz72YUNgrX8y 3b+1b0fFP/HE8YrAFtLRcjh6ECGs8Kqd8syeo3uQEGYB2kIL5dqm/6TCsbZOgVElR3 exgnoIx65JqAW2QpUZp+qYBp0ED2x3loAVzpNzi+4ikfoeTP015L3giJ2BDoKU67uu kq6Ffvg78JtPPRcF0I0bcSc5qwXhbvkrjxvJX9SSBoRqgGxamERhm49Ha63JW6yeUJ ZiIIDj90oHxUg== 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 E1D3263343 for ; Tue, 29 Nov 2022 14:45:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EEFCo+e+"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id 83-20020a1c0256000000b003d0683389e1so873842wmc.4 for ; Tue, 29 Nov 2022 05:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ciBbWTK2dRMSlcTDs0GHUazmwee/kR44mG6SsNS5Crc=; b=EEFCo+e+vVBysbgYdj7qNWmSACjXIQmHzDVubVTJXpOS+jj8cagdntetcxzwDZ9Q0f gLoS8xT0OPicBi8jq1BSHyhFA4kswYg0Ug6OZzjaMN5yxF442ePXFT5rkxo10x9/IW4E IEVvRu42Oa6x2J5ii9iUm4lGXn9SL6I5MXFEW3Jbu6IOI4h0Q9aS46O+3KWOHFsf4WkA VOfiR7qYB3sTjcUDuI5gyTNm8eOPWvcIOkzMEKqbFlipe6MiOkE3fcXW1s5amju44NTR yi2mA/PBgc7GvNqv/aT75tIFllCtxZyOhmadvi3vX4rikpP3TgPF8RAzPEkSNxuQSnq3 Djjw== 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=ciBbWTK2dRMSlcTDs0GHUazmwee/kR44mG6SsNS5Crc=; b=v6cKmdtgyXb5d2NhzSiXkMO/nD3SKiyCw95gVV8M6vJEzRTVbXduiea8HffTuL4eVp iTalxNXXwVd+vX2pCwX8ZI/R7OegzUtBF0GzzpOv090/251Fzq8keZ+gIIEpnA0azt/n sZ9emrXsWGDE5voi2j0p6ZLVOwGafoqgmzFbRrMSK6cMuPWmiqIN2QvfHhUcvPFDlv4D XHOa24eyqRsTk5hBB9vcdzLziA2nDlYTb17Br5HNcCwZWF4id13TELAfyfFcLRRC6s9L C0jZ6wj5eYXXmPleD1ZPuyMbx2rFW8z7rMmPbPRd/isc3y6FJRD58jjTuj6+RLBoxFg4 fuoQ== X-Gm-Message-State: ANoB5plamJfn9w2Qfnn1RZ5/Tv/+WIKDlTnKoimPKAjMAVjvbrj5KCP3 RBhfyPY/eYj1bwAyv8pk8yXrLm28AWFAZg== X-Google-Smtp-Source: AA0mqf6xtwuC1tt4i6GiM8fxLsP5hzltNsO/jcSYOLQI/ekL6dFzAAl0QPw3lXVsn7UUhWyV+r05AA== X-Received: by 2002:a05:600c:6023:b0:3cf:6c05:b4d5 with SMTP id az35-20020a05600c602300b003cf6c05b4d5mr27475877wmb.120.1669729539136; Tue, 29 Nov 2022 05:45:39 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:38 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:26 +0000 Message-Id: <20221129134534.2933-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/10] 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 | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0e0b71945640..4486d31ea78d 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -294,6 +294,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 steram. + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -346,6 +361,7 @@ private: } int registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity); + int configurePipelineHandler(RPiCameraData *data); int queueAllBuffers(Camera *camera); int prepareBuffers(Camera *camera); void mapBuffers(Camera *camera, const RPi::BufferMap &buffers, unsigned int mask); @@ -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 = configurePipelineHandler(data.get()); + if (ret) { + LOG(RPI, Error) << "Unable to configure the pipeline handler!"; + return ret; + } + /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = @@ -1389,6 +1411,18 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me return 0; } +int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) +{ + RPiCameraData::Config &config = data->config_; + + config = { + .minUnicamBuffers = 2, + .minTotalUnicamBuffers = 4, + }; + + return 0; +} + int PipelineHandlerRPi::queueAllBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); @@ -1439,25 +1473,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 sets 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]) { /* From patchwork Tue Nov 29 13:45:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17910 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 6D498BE08B for ; Tue, 29 Nov 2022 13:45:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D52E563343; Tue, 29 Nov 2022 14:45:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729543; bh=OdbIBqn4LJOScBMWLFGppyDRgrAnWiPNTbPBcrFRT7o=; 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=uZ6ped+lzcUybuvwe2NAYm4ileLDcIZ4rIPlzmKNq9ypjiKuEwXHMRUdjXGae7dIY wXpfVnIAKS/K7hSjK4pCXjQle2Jd1qTqeMmBEGrTPzI25yFgctGI/LSV5rfjoZlv9A FdM72IEM//uJMH5/xb0IQ2L6E75HmjUMuxEwIOZ48ircFGF6c7wLNuSKXCIt2q+dRQ rAlQS00I0Zh/oAvLW98nfMUdCEUut5MRJg4DUsT4nbPuWPzKZYVjD/U3MNlK2PI4BF Z94GGpmfxxnpK7t3+E+EJuVuyj+GrOZ8CeLpXSgjQqw2wrJhf6S74Vtg217tg0IjIH 1w4V4ww19BmJw== Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A3A2F63331 for ; Tue, 29 Nov 2022 14:45:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mQWvgYWX"; dkim-atps=neutral Received: by mail-wm1-x332.google.com with SMTP id v7so10952786wmn.0 for ; Tue, 29 Nov 2022 05:45:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vDUjikHxPpLQasRYd91iRpJMp4hp3BcRxTpdbCI0X+o=; b=mQWvgYWXwTzk6spK27NFa/IIdzY5oqFf1ukaVQqCQmpsNJ4RL32Vfi/zvEAvvQYSpY 97T/tIMM3cijJg8CnwLUGLyTMavULxZN9yhQ1leA/DLbPkIGrhoWuUnnNDcQ/LQIlotW f/vUmQ8sfuOaw6GqQhEalR2PDIF6j6WPiNdHKNe7emawX6Xmje0cnR+O/U8dhTFaSd+/ YeU9gq6hKSxxRYLQAoJXU8BWXegieK2VOjSfKu9tqNXKaes4zKMiY9q5UmVjqA4atXID Knb0EQyaAADHGX6UbNGd9ehoBGBsgrhTRQK30pYCFAnfbQac68LyEksDnDuur3wLdVwQ GqpA== 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=vDUjikHxPpLQasRYd91iRpJMp4hp3BcRxTpdbCI0X+o=; b=gslMsdQRfw6oEwbXNQOCJMjxbMh0puGXcr2QlTFigUvYo+imk2VqxLeYTJlFTffX9i oQOTSe9tZBIj09G6M9Tk63wIpyc59RQ+V9ZcjkU97yF6oSz849qjqpnxE8n7n+h1y2FA JwKBOQV4qcbhhxbi3DBTtKdsEekd45CSWcfMTCgyg7pcZINfjvKe7+Gquq4+VOcOUmLM 7+Ak+Ov+7ZgV+vP+I27KkTRE7BD6LyXZss2rynv99wex7ctS5D08V3AnwGyi7dgzuJE9 5hLftz8eCxadple6jbKe35xeobbf6Ft9G94K1zYPjACuIiY7D+2Ri+kJ05wuLtQkTolc C2dQ== X-Gm-Message-State: ANoB5plknzzA+lsdTpcSVR8moFR6NAYzOdSegZNMEse0le4EujIcjFho 5f6DqvHTC9ejSSiqqC1rwFzPFnzXbecm2Q== X-Google-Smtp-Source: AA0mqf5jA6fyGJmROQtVj0wFrYgvE7UqEdvPVVgrpBKir0T2p/4938Jw0BNFic2VQt7YayQ+tBC0mg== X-Received: by 2002:a05:600c:2e0c:b0:3d0:6d87:7b44 with SMTP id o12-20020a05600c2e0c00b003d06d877b44mr909713wmf.106.1669729539950; Tue, 29 Nov 2022 05:45:39 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:39 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:27 +0000 Message-Id: <20221129134534.2933-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 03/10] pipeline: raspberrypi: Split out ISP Output0 buffer allocation 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 config parameter numOutput0Buffers specifying the number of internally allocated ISP Output0 buffers. This parameter defaults to 1. Split out the buffer allocation logic so that the buffer count for ISP Output0 can be different from the ISP Output1 and Statistics streams. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 4486d31ea78d..f2b695af2399 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -305,6 +305,11 @@ public: * the Unicam Image steram. */ unsigned int minTotalUnicamBuffers; + /* + * The number of internal buffers allocated for the ISP Output0 + * stream. + */ + unsigned int numOutput0Buffers; }; Config config_; @@ -1418,6 +1423,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) config = { .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, + .numOutput0Buffers = 1, }; return 0; @@ -1502,12 +1508,19 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * so allocate the minimum required to avoid frame drops. */ numBuffers = minBuffers; - } else { + } else if (stream == &data->isp_[Isp::Output0]) { /* * 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(). + * 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(). + */ + numBuffers = std::min(1u, data->config_.numOutput0Buffers); + } else { + /* + * Same reasoning as above, we only ever need a maximum + * of one internal buffer for Output1 (required for colour + * denoise) and ISP statistics. */ numBuffers = 1; } From patchwork Tue Nov 29 13:45:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17911 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 3D63FC3286 for ; Tue, 29 Nov 2022 13:45:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6736F6333F; Tue, 29 Nov 2022 14:45:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729544; bh=1EA1gvNx34pZxdnIB7ZSD4Wdr6IySmZ/YynJ3Jr6Q6U=; 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=enynkB3gZNsUiif6sHzz42DmU6ZyUfKS/fvydLw6TIsRN9ehURiOd/BWEL4WG7Uvd 7gAL3PIGWwJ+UDjMf7dlARHsV900oO8IqwkCNxGBDo4VIMpLx09x8itrvcAQGiCP7I WiuK181jbaMKssLbMvX+skDhCNQuPIv/VF+hEAy1luHNXpbxp4+1tpYzj3sTsKfSfS AnBb9cyUcnr9g2xbWOAsJAQ10RQ+bPjuX4Vns0MExHJQHXz0t5gX3y+OvXrNU57Vn9 W9GfYvWVeUXKYRiENFs2vhR7xzZGyhymWE7WMs6ijpDboRzGRhu/kXd5QyhwPuYRLK /N2rPK3KVTXUg== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 418F96333F for ; Tue, 29 Nov 2022 14:45:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="XIF19mHa"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id o5so13157447wrm.1 for ; Tue, 29 Nov 2022 05:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dkxuoYbUAgoPHTxggyZSVJLmHd9EHdyyBvKcOavddOY=; b=XIF19mHaGq1E4KuSfYVKpvTX/ZzQBKRoB27mn6q6uEaI+TEBiJ7Esxf81fmBYAe3eu PtsWGQtlhYW/H659R0fa4XZj+wzIjMhWrTcjWU4zLVMRmh6koA/gEuM4bogxTSYzfeu0 q/LmGAOsI4mtDbckCq4+to01TRraqXTtdTHugveVyT3/5nkNoNKE0GOJjoHHpxIHKBXb gMyTwGgmvnMpKPk0FM0mQ8z+7usAhNKjlZJCTfL0duImHj64Zkxow7nhjSgcNSZ9lBRU Da+ySwMURnkOiBfQAa/xhcoNJ399iaI+Ni781yOGCM4fUQdrxLgSO7GOMC4l6AbSpmy5 7QjQ== 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=dkxuoYbUAgoPHTxggyZSVJLmHd9EHdyyBvKcOavddOY=; b=3W1Y/deR3IPX5itefDqIogNF0lfgZjBTSKFnWcSbS+nSGYUcyAymybm/e2eJDI579i ohWiXrIbIUhycyzI0Uc8PO52ayIdiwttx3OfBX1guaQfy+CTNy5pDWSljMQYoT1+IS2r 6KEqfXIBuCJ7pkdQIMXRsy3pcJ5Ta7klBCQy26oPvA1T9s6wPPMUReDKqAufUHrQYlWU mwryLdpuh4dzSz+QuXkWed/lqd/BK/857Xuk1+okDZe0fur1meJszwHWp1BRYtMWrUJs gQsLQN6U4ly2b5ZeYEMBMtGhSdW+U6LCqKwfzMbgdn34D1QVYtDIGwzVSZfgrXWO/8ax /I9A== X-Gm-Message-State: ANoB5pnVuRlb6zGnhKk3JAuk74A6DvS7/d+5XbRr9UgONX6hvoBMyo0c pB/++2iiuBcrwJPfEtnkSDRQ2QEg/GvQyA== X-Google-Smtp-Source: AA0mqf46rZJoMI4+hsthmbEvHxcGpVhNE628tZlPO7OvKyByX0dI3AyChVgxduhloXsTx696OuLo0A== X-Received: by 2002:adf:eb88:0:b0:22e:3e3b:24fe with SMTP id t8-20020adfeb88000000b0022e3e3b24femr32906375wrn.668.1669729540598; Tue, 29 Nov 2022 05:45:40 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:40 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:28 +0000 Message-Id: <20221129134534.2933-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 04/10] 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" Read the platform configuration parameters from default.json config file. Use the PipelineHandler::configurationFile() helper to determine the full path of the file. The default.json filename can be overridden by the user setting the LIBCAMERA_RPI_CONFIG_FILE environment variable giving the full path of the custom file. Add config parameter validation to ensure bad parameters cannot cause the pipeline handler to stop working. Currently three 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. "num_output0_buffers" Number of internal ISP Output0 buffers to allocate. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/default.json | 20 ++++++ .../pipeline/raspberrypi/data/meson.build | 8 +++ .../pipeline/raspberrypi/meson.build | 2 + .../pipeline/raspberrypi/raspberrypi.cpp | 61 +++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/default.json create mode 100644 src/libcamera/pipeline/raspberrypi/data/meson.build diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json new file mode 100644 index 000000000000..d709e31850af --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/default.json @@ -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, + + # The number of internal buffers used for ISP Output0. This must be set to 1. + "num_output0_buffers": 1 + } +} diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build new file mode 100644 index 000000000000..232f8b43c5fd --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 + +conf_files = files([ + 'default.json', +]) + +install_data(conf_files, + install_dir : libcamera_datadir / 'pipeline/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 f2b695af2399..ce411453db0a 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" @@ -313,6 +315,7 @@ public: }; Config config_; + unsigned int numUnicamBuffers; private: void checkRequestCompleted(); @@ -1154,6 +1157,19 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) */ stream->setExternalBuffer(buffer); } + + if (!buffer) { + if (stream == &data->isp_[Isp::Output0] && !data->config_.numOutput0Buffers) { + LOG(RPI, Error) << "Output0 buffer must be provided in the request."; + return -EINVAL; + } + + if (stream == &data->unicam_[Unicam::Image] && !data->numUnicamBuffers) { + LOG(RPI, Error) << "Unicam Image buffer must be provided in the request."; + 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 @@ -1419,6 +1435,7 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) { RPiCameraData::Config &config = data->config_; + std::string filename; config = { .minUnicamBuffers = 2, @@ -1426,6 +1443,49 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) .numOutput0Buffers = 1, }; + char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); + if (!configFromEnv || *configFromEnv == '\0') + filename = configurationFile("raspberrypi", "default.json"); + else + filename = std::string(configFromEnv); + + if (filename.empty()) + return -EINVAL; + + 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; + } + + ASSERT((*root)["version"].get() == 1.0); + + 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); + config.numOutput0Buffers = + phConfig["num_output0_buffers"].get(config.numOutput0Buffers); + + 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; } @@ -1492,6 +1552,7 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) */ numBuffers = std::max(data->config_.minUnicamBuffers, minBuffers - numRawBuffers); + data->numUnicamBuffers = numBuffers; } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow From patchwork Tue Nov 29 13:45:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17912 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 BB51FBE08B for ; Tue, 29 Nov 2022 13:45:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FFE663348; Tue, 29 Nov 2022 14:45:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729546; bh=VmJ10ySTnoK2DomNYykhigrgND5ZRn760On8UiajsLA=; 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=HA6TEcnf+GG+aE4x6w8OahF4lD3R1NCOudZtj2HVTkXRB9fJO2YXALgkgc79nKcI5 SUmhU3HyS4LeF+mHt1urZCQvyctKmaXnOw49Ztf43vmNJS5I67IslEx9Mjo2ULg8RL 9XovygDveGo4cJENrMoE1hkFZ8xeRNfe+4g2+qxHEMoXQ5JOlc8JHhTTYNOu740IvH 7NtmtcKxuNJmyWMpnMk3FrPSUYpghcoeBVZRaWzpoFOm4RGYCYNaj8R67b+xIbL23p 2HMIFJCBUS1SF81HxaihkAhsnIBad2g3QaI96k5BzET4m1G1DFChD9wm7etQhA8Fmi trrjOTc8essDw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE3F063334 for ; Tue, 29 Nov 2022 14:45:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="S7laaz2r"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id o5so13157503wrm.1 for ; Tue, 29 Nov 2022 05:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=s6JWaOD5ahc87t7hdCafQKuhJnaZNJKSyQwGAo5ftKI=; b=S7laaz2rPkTC20d47V0XF+vz1wSwI1B38r3HNqqHBzJPHG/W+PU51olc73DjaVBZs7 /9FQb0yys4Os0tpe9CakwMnttxHtwJLwIbMVE95sM0dhiotNayMNXRU1D9TvsYDR1dHT R8HWaaMXj2+8tLWdXkQ3sTfzppoNPcQ35HIPbyiTBhkshw8jpdX+0p9uMHdXXd8gn0eb PHj3PuqoAnrBN7ob2vCWaRSrBDz+xTFOBmyJ6v9bcCZ/Dybgh5bWtd2ACYog80eJ/avR dlYuviKhRNBY+k4HGrokT0UlTNIKfc9INdiINcrcTHj9Ewt76URDOse4vCQQ8BAKBN2h 83Cw== 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=s6JWaOD5ahc87t7hdCafQKuhJnaZNJKSyQwGAo5ftKI=; b=zyf8iSIZJt5dePqPYpSoQbKbJAh1QPudDBGc5Ce7lomTo1DpKF4AmMCENE165aSK4j C47ixtWn22rxZoKHXh4vd5+Siqo0ufth0IALruRleDwnET1wgYI9R34Du7r+BmavyvJD /YiWEa520YYDTavjoPSgty8N+qREhC9QU9ZKFskxs454BDZNyyShWpYs08zv/QEnlawc g9QBT3UnyXg42p+PoDxvXogCRKWM/HVnOv4RK2OIF53qst8qMr4k0lLWikfisZiNxI+N oCcjMc87ImFyFLpTn426F3PBaw9veYnDhCu7uITfMKTOan6ASP6Nu6MBQI648YTdajRg rfbQ== X-Gm-Message-State: ANoB5pllyEMX3V7HXY0QL8abJ3zPcB1FjMpuAQ1CpYmf9vCXOaXuSXPd joRVWNld2jD3MMSoswpJkSq5Uj0F6c95Ew== X-Google-Smtp-Source: AA0mqf66cN5QDHIZclC7A5vDNOfcaB9d31PTwv7OvBzbSyGJCzY7JWbIR/e3eul7lL2QMMkYFPTYOg== X-Received: by 2002:adf:ab1d:0:b0:242:e73:f642 with SMTP id q29-20020adfab1d000000b002420e73f642mr9098390wrc.184.1669729541340; Tue, 29 Nov 2022 05:45:41 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:40 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:29 +0000 Message-Id: <20221129134534.2933-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 05/10] 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 improving 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/data/default.json | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 34 ++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json index d709e31850af..a7ea735c87f4 100644 --- a/src/libcamera/pipeline/raspberrypi/data/default.json +++ b/src/libcamera/pipeline/raspberrypi/data/default.json @@ -14,7 +14,7 @@ # min_total_unicam_buffers - external buffer count) "min_total_unicam_buffers": 4, - # The number of internal buffers used for ISP Output0. This must be set to 1. + # The number of internal buffers used for ISP Output0. "num_output0_buffers": 1 } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ce411453db0a..86eb43a3a3c5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1094,8 +1094,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); @@ -1500,6 +1510,13 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) if (ret < 0) return ret; } else { + /* + * We don't enable streaming 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 @@ -2169,16 +2186,25 @@ 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 Nov 29 13:45:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17913 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 D5F69BE08B for ; Tue, 29 Nov 2022 13:45:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9A2196333E; Tue, 29 Nov 2022 14:45:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729549; bh=HF0ifAuMwXahZfN9Y84qtX+8Io2LtllLKhr1Mmmd9Xc=; 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=yWFcuxXqWj3s2He457uVt023VyYPh5qngE4uWb9pxaTIAEQhWMsX+sloiU3QqD2zy zQY1LvSKtBy0tw8nMTvmLe5VVEnCdq16AstKEWaa6Tg/aMs4FMYAVoq5R6FlH8tu5z 4QO8RFzNaHbkK9DMUdEe1PF9BlejMVnzYsKiBr3xVbkLOEa5YL39SPIyWiBTKAuMCT 6r/3MUaCFn+1Kvu2sn+VEb/HGv6CWN4NHdHWN4m+4UIo8N3VAhc5s7CrCeEE0IyCtK 8jZL3H2df0mURPh/0mEdAIINclnD15qsceJoGMGr3z3nutFMJDYQ/fazwKEFSHVBA1 5inIDCjwJQ9gA== Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D456363340 for ; Tue, 29 Nov 2022 14:45:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="k9Xsz4t+"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id h11so14868660wrw.13 for ; Tue, 29 Nov 2022 05:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cUsJZiqpEEbEwFHCx4GPjdPrMvQweo8Nuue7++bQ370=; b=k9Xsz4t+/crxHlT1Im3kfShT4N22MNm71vGIdmzJjMM1GBA6z6iEHNkJae2J3e3nli QvzfC21ehhe644GU6GR5X00flNVuCU7h7UhNLLmsE8E4C/tCRTxxAL/Drj50IaUK3Ums kla035ckUKN5isd5KtPm0DV5oCsQBm9gJ2z0qOVNmjmqZrYBEABQ9XqdWz5Q4dq7vTAO EfEXNZffFBwHrCfOERASjPcB7RkePoyY39uzXdF8MmEFoBFe4NnED+AuffDncBQ5aK1J jZL/CvgBEPs1BuQ6qi5SI+XcsdlpYpiCIO3O4RpaXJQshCjbzXDmFu/q6v+2+RacM9AP 2h7g== 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=cUsJZiqpEEbEwFHCx4GPjdPrMvQweo8Nuue7++bQ370=; b=EF5PBgQdJa50VD6O7S8cuqM2cfCOpi1Oog9LoCLHchdlrKp79Nut3dCuphJp4PY8s0 vJIslCj7ioMxOGkU1Ai6d6SspvspMExlEUP/t4UUg+Gn5h8Uyouzq3JkXgFKOQKHg8Bu vpAtaWI0XGM2asez5zStyXWVoloBnXrhmrN9oQscvvvWEhZ5Eir/Hk+v9ElV3eAfkBrh VYSYZ5tOlGlI2fxU6eH3nOCqTi8VBCyXM1FTZYnMaBhlxwHN6ER/4nVSnAaDxBmIs5Vo q8onHpJGwlWF3HsBWgyCEsbfA5JtJln7qkThUQY6tJ4Svx9en/XS1fN8evtecGzy/V0b uLXA== X-Gm-Message-State: ANoB5pmqxqaxArP913JlZo+u1hBOqKipeRsTWWIWgLI5/pukvEPVT6jp p6csGzyRjAkB4Sb41VGTvate6GwZaPMldw== X-Google-Smtp-Source: AA0mqf4UzllLXArxLPcJoL+DA7SZkFSJIGENoBTggaNo8qkW+jKQspuT+/tELccZVKmIr91lqCsLow== X-Received: by 2002:adf:ed8e:0:b0:241:d7ce:4395 with SMTP id c14-20020adfed8e000000b00241d7ce4395mr26300110wro.553.1669729542072; Tue, 29 Nov 2022 05:45:42 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:41 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:30 +0000 Message-Id: <20221129134534.2933-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 06/10] 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. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman 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 86eb43a3a3c5..742521927780 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1044,21 +1044,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); @@ -1075,6 +1060,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 Nov 29 13:45:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17914 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 7EC4DC3286 for ; Tue, 29 Nov 2022 13:45:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F5E763348; Tue, 29 Nov 2022 14:45:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729550; bh=xiZKOmMKgh4C0BiQ8C7Rx95IlKX9+MUIw2e5+Hw+o4I=; 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=SMdqRRTfFQhfYbELezwVbRSTU28gNpdy5iYn3UlzcM0Ut0j/nQeUtor0erkepH+jb W5R82LoCVH8XzU40Kg/obhfGINzO6QdSHTfvX3g6wMzNfy+fZzfzCATdwrJxFzy/cU uPhC7jjT9SeteTiF4eA1SLqrSJkGUHSL7W1v/OFGkAVcQitEMY/Xpt8TfQEbDNct3h lZ50nloKe8jSX0W4l+ABB7GZ91ejYU/mU9MvPf9M6ar108IzucMNROisRuBhoKcyop UcAnx6s4HI9o/q7AU51RXBTvw6M68nrEbEZdmYBGt3xaQ++/7+jtJ47Y7Gpo+tnjGs 81cViQ2sY1jRw== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 650CA63349 for ; Tue, 29 Nov 2022 14:45:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="DKkjlUnq"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id x17so22144311wrn.6 for ; Tue, 29 Nov 2022 05:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0JEGK22eBqrjF4esosBG7CRFyk4lPiCqUBabBHzNiq0=; b=DKkjlUnq2Tr3oePdX2JuR74hGcSR9SKcrUHduqKsithxqWE3K/FtpeyPe42vTveX4f r38YtPUC1IYUWAtNlS5lKsBSTzliF1XcYY42XjyPtk0KHJOkx3hETlr2cQojIDhZBLeK U2vcrl1e5PwcuXAm9CuVbFVUticwQH+gnh6WBolNtcP8Oqga8bDThOOnKg3l6dCi9Q26 eg0/6CBoKkaJUjbCEKkniASdwWPLjitS+7QO/xRRvUfFT/rXHCq6oZyXz8ZFQmMIffJP Uq7c3to8M58Y5RogtFKyGF2agO394Nk2WzuuwCdEY0hkuo9cNhsyFD3SkizwksPwRBxS xtqg== 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=0JEGK22eBqrjF4esosBG7CRFyk4lPiCqUBabBHzNiq0=; b=wQ794QyI0lVuxOmmGjyhJmaYoMa4T+7nvU9rNi5VNXCJA/i2a7lgn5lstztUcaX2ZW KkFoCEtNgbgQfbHu0C5PtBa1jFjdTnZIQ8cYyk8qqNs44APV1sWgJkFgmhH0iqK7QdKG 4GlB6W1fDLuo1gxEpz08S+0JdzOr73K7nvUOz6p5RTC7Iji7qB85UeodEthMRWIvu92r 4T5GwZFWf3tfe9A2u/HFK8L+Mr2UX+QuztFB4CLTS2RmaGCrJdo69l6G3Jv4VzorfmUA 3l4K+kQnRY+Xr7iOVs57plIRtDpXUPVnRzO+k8EXuKgETlQ77bhzaFW1BaLLsjpkuWQJ rUgQ== X-Gm-Message-State: ANoB5pkJxsxAQwviDLVkpbRNEUifTkq3xkWoVkQfIXQy+rQ4w5EOQ47p TVFVKYHzqm9ASLenb8hJtT051VQ7c+Eg9Q== X-Google-Smtp-Source: AA0mqf6RRYAoCmdunkfZsiEZOJHCdIUh1jPG2vb/9P8823Kza5DrJ85LSTdhsLHOrViZvLVj7cCQkQ== X-Received: by 2002:adf:f8c4:0:b0:242:82f:88c8 with SMTP id f4-20020adff8c4000000b00242082f88c8mr12400365wrq.151.1669729542767; Tue, 29 Nov 2022 05:45:42 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:42 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:31 +0000 Message-Id: <20221129134534.2933-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/10] 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"). Add a validation to ensure if "disable_startup_frame_drops" is false, at least one internal Unicam buffer is allocated, possibly overriding the "min_unicam_buffers" parameter. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/default.json | 7 +++++-- .../pipeline/raspberrypi/raspberrypi.cpp | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json index a7ea735c87f4..707414bcc5c5 100644 --- a/src/libcamera/pipeline/raspberrypi/data/default.json +++ b/src/libcamera/pipeline/raspberrypi/data/default.json @@ -5,7 +5,7 @@ "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. + # This value must less than or equal to min_total_unicam_buffers. "min_unicam_buffers": 2, # The minimum total (internal + external) buffer count used for Unicam. @@ -15,6 +15,9 @@ "min_total_unicam_buffers": 4, # The number of internal buffers used for ISP Output0. - "num_output0_buffers": 1 + "num_output0_buffers": 1, + + # 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 742521927780..ef49d32037af 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -312,6 +312,11 @@ public: * stream. */ unsigned int numOutput0Buffers; + /* + * Override any request from the IPA to drop a number of startup + * frames. + */ + bool disableStartupFrameDrops; }; Config config_; @@ -1058,7 +1063,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(); @@ -1451,6 +1456,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, .numOutput0Buffers = 1, + .disableStartupFrameDrops = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1485,6 +1491,8 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) phConfig["min_total_unicam_buffers"].get(config.minTotalUnicamBuffers); config.numOutput0Buffers = phConfig["num_output0_buffers"].get(config.numOutput0Buffers); + 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!"; @@ -1569,6 +1577,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) */ numBuffers = std::max(data->config_.minUnicamBuffers, minBuffers - numRawBuffers); + + if (numBuffers == 0 && data->dropFrameCount_) { + LOG(RPI, Warning) + << "Configured with no Unicam buffers," + " but the IPA requested startup frame drops." + " Increasing to one buffer."; + numBuffers = 1; + } + data->numUnicamBuffers = numBuffers; } else if (stream == &data->isp_[Isp::Input]) { /* From patchwork Tue Nov 29 13:45:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17915 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 4EAECBE08B for ; Tue, 29 Nov 2022 13:45:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0254D6334B; Tue, 29 Nov 2022 14:45:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729551; bh=jUW5kSgJZ0cyJT+RYMdONK0L9oZuYffToSENJa65fwQ=; 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=H1abapNmIKK+9HptkcU6xThJO9A2CE2c260aBx+K8D/hpCj0xBDO6D+s5Xx/aMqT8 Wkv3ZGI9WOQIb3XZSrQJFv0xepcyNh2wTJAZhWWB8Laiz8lWvr37hznY3BnPOlTMUl TMpv4ZrKPNFifOQZVG+TUwMGOvCcujTLzMhcipsuEVH8uv189eGeGfTyO6B0Hp6Kli 7lM89ctiSLVmAeGdQG1AdqIuVH/YCmoIXGlvGmQhFucItLq+Q37xlTxFuxZeIQZmrV onW9/XkmO7K7o0BMMUp14GlAE3oED1xZSKP+bwVYTEozCXHpAyRndQ5oa1bE82WVia KvFnSvJ8yLdeQ== Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3441F6334E for ; Tue, 29 Nov 2022 14:45:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Fy2PfYFG"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id l39-20020a05600c1d2700b003cf93c8156dso10846359wms.4 for ; Tue, 29 Nov 2022 05:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AAjQKP/RW4k0UC1sBsQ3vu92QPpJTB9qQfTD6RkbYDM=; b=Fy2PfYFGjB3yHmADodINJ1gewL/r/tPHAJQ4YW/rBCKq3dEwVW7DyxtzjyVhrl9fFA Dmc/ZGK62O/7u4EkTxNi20XQ8E1IBZaWo9IQB0Pfh0mNp4OuSbbV8Ceml+sK2WUykMlv iR45fvIQIRrQxzVeUGbql/BN8OLHxJhBZvu9fy8CVxV5VlIRWvmCz14LAYCozI0TloiY WkP6n5u6XSyOLQtyTbGC1lb3cODTByiMtuc6Cci9S1VVQT1k8lNmX3pixQbtBmMWjMax Upno2fIqjMM8ts0eRQXvq3SKdtr3w3gybu9VHeKHnv6GctEXVlRKO+pgoBFNM0IuRkis 7xyA== 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=AAjQKP/RW4k0UC1sBsQ3vu92QPpJTB9qQfTD6RkbYDM=; b=l4ewdep10YHLqsXHJXUgNXSfvnEpQSHOH4S1oSfRaLFq5NCVc0MC0AOnlGF24Sa9Rn Z7+K7JAy0qgnWehiVLgRA7/zDl38Zq6qJOsuXp14F7/eEQm2NkVAler2dzbPDhl631Q9 Us3awPaNNcGwT7WPzeH4mUQNhsZsueFbKh5WBiyjPN7mCWhoc7SrECfiga5PoEpVihDO vo00BZ2ebzlkvZc4mNp6p/JMrGmPsRiwB1UqlTLkrO/y24t+pE69lUi1WYkC82fWWt2q QH4svducB25C5VqSqqL9o1+Qa8cS2k4JqcMLT3XG9q4/ZKt0dJ+qu0geZdRuQbOWPPuA ckEg== X-Gm-Message-State: ANoB5plyyLySSBmjzt9DtCh8Q9z1g4ECdSkvyXopEKi5DXr5oQwxrGor O/rE5thcl4cjTOKadjZz0MyA936+/p/pNQ== X-Google-Smtp-Source: AA0mqf7GqneGSIyczTX+sDNDxNvYEpAtdKukflatXthkZ7e+VuUNo5u0QdBNwTptKqR/1pYk3G/OhA== X-Received: by 2002:a05:600c:4f12:b0:3cf:e7bd:303a with SMTP id l18-20020a05600c4f1200b003cfe7bd303amr29421179wmq.151.1669729543514; Tue, 29 Nov 2022 05:45:43 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:32 +0000 Message-Id: <20221129134534.2933-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 08/10] 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/default.json | 7 +++++- .../pipeline/raspberrypi/raspberrypi.cpp | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json index 707414bcc5c5..eda053258c67 100644 --- a/src/libcamera/pipeline/raspberrypi/data/default.json +++ b/src/libcamera/pipeline/raspberrypi/data/default.json @@ -18,6 +18,11 @@ "num_output0_buffers": 1, # 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 ef49d32037af..a369fbd2a528 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -317,6 +317,11 @@ public: * frames. */ bool disableStartupFrameDrops; + /* + * Always process a pending request with the last captured sensor + * frame. + */ + bool returnNewestFrames; }; Config config_; @@ -1457,6 +1462,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) .minTotalUnicamBuffers = 4, .numOutput0Buffers = 1, .disableStartupFrameDrops = false, + .returnNewestFrames = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1493,6 +1499,8 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) phConfig["num_output0_buffers"].get(config.numOutput0Buffers); 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!"; @@ -2349,6 +2357,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 Nov 29 13:45:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17916 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 E37B8C3287 for ; Tue, 29 Nov 2022 13:45:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9630263347; Tue, 29 Nov 2022 14:45:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729551; bh=nhMjr/8XCo8fFgW+XAgMjAcAbVxyemxB03eGT+6+vxs=; 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=l9RD19RU3s1W4RvjEhpL+nofyNXNxgIOEXDHMudUoTeRvsL9vY+1MhDpuuVneYL19 FdL460FTgQjiHlsyXDYiCVpsz81bJnu0Ty1qfFFqMIylTGHm8lk6hv3cpPYUIFb5BJ dY3kfUeDAbdXzMSck4hYlGOHQW5kRqNxY3tzSwDihx6Z7evRZZYpVYTiZdCSVI+s1l FM62/A1I3GjTlZsO6cqF8Kd2KC9M/HdBzWoBA6gY+fV015R81VRXej3w7/6Jrwj395 9PQTt1cUBao6Cld/euiSKApFOZl97VkcR4lACOLzDcxkSF+B8KMr3Cp/0+KFPRkNUf XsC1x/4+mJjSQ== 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 20FC66333E for ; Tue, 29 Nov 2022 14:45:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ZORRXxnC"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id r66-20020a1c4445000000b003d05a3775d4so4906618wma.3 for ; Tue, 29 Nov 2022 05:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uJOuSzayRsCSnI+YDcJu56Ukq9KBYQOZTGGIta+kJ1s=; b=ZORRXxnCiRc8flmuTH/kQr6CEz52pIShKitteOTnQSh8UIJoU9Szmkh0uRD4QKofxq tY+lZ1PhqBf2FuUkRue7YTXXD/E/JD0HQEMjmHi9xkTlfr25R/y5X3TP3GECk/Nu48Rl MMB0oMktmuGjH+BdVQIsKaL/GvW6sLtbs1xkH80SqiD32O0zPQfu/YErfBfnTivp4ou4 OIqLqFpgUf19ufIozffay9Y+YEdJvB0pHXCgr1Kl5BCUHBJ9YZC7rKf1LuKipdml0C7Z qrK5EK3/slnDjZn/qcTS66Bbv7kPWI0JWw/zzcM0ilCprUyePtQ3TOAViXEsZmfoVM20 gPtA== 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=uJOuSzayRsCSnI+YDcJu56Ukq9KBYQOZTGGIta+kJ1s=; b=iJZxdmFMmTAZzjfy2idEkdFIB2pXWf7q9RLbIExLqm0uSm0J7hiVnMAjA2NUKL4hb9 vwRLVMT4DJNxMdnsf+9MTzO8ftUjuMAofCGsklLLH/wRAaCNUwCl1zwVu20eOCDTB/JC DL9v4yOQTPeCb3k47S2u0exRhC5YA36VU7Qw/PsHfA5pKaciy9Bk+Q6twxSWPpnVpKgj tCP85mQIx+plTwvMhxDev3F5uhcSDNU0Cgkju+8vlHv9M96epJLhw0eR6tij/R9Z3YAB lnqOQqE4HHEBq57s0sglr+3bGVOTZBT2ske4AUpA0e6AzdaVcfkT4VmR49P4GpU4WeVL 3YrA== X-Gm-Message-State: ANoB5pnL/7DEMr0AUe8FWYYXcTOvZuctVxwFtY/VBIdNReR9s4jmBitm wD/yy1q/MkLK30yFV1r71r+JFCxdUIVWHg== X-Google-Smtp-Source: AA0mqf41NKF86WS+iBFQkQFbURtlNbQUYRedri5HAOm2V0Zk3CxQ7RKigAO61pxuSV+d13aFks0Qvg== X-Received: by 2002:a1c:4b0f:0:b0:3cf:735c:9d5a with SMTP id y15-20020a1c4b0f000000b003cf735c9d5amr34915263wma.113.1669729544261; Tue, 29 Nov 2022 05:45:44 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:43 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:33 +0000 Message-Id: <20221129134534.2933-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 09/10] 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_memory.json Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/meson.build | 1 + .../raspberrypi/data/minimal_mem.json | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/minimal_mem.json diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build index 232f8b43c5fd..0592fc53877d 100644 --- a/src/libcamera/pipeline/raspberrypi/data/meson.build +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -2,6 +2,7 @@ conf_files = files([ 'default.json', + 'minimal_mem.json', ]) install_data(conf_files, diff --git a/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json new file mode 100644 index 000000000000..87ede70ee854 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/minimal_mem.json @@ -0,0 +1,28 @@ +{ + "version": 1.0, + "target": "bcm2835", + + "pipeline_handler": + { + # The minimum number of internal buffers to be allocated for Unicam. + # This value must 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, + + # The number of internal buffers used for ISP Output0. + "num_output0_buffers": 0, + + # 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 + } +} From patchwork Tue Nov 29 13:45:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17917 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 94D68C3288 for ; Tue, 29 Nov 2022 13:45:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4542363349; Tue, 29 Nov 2022 14:45:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729552; bh=JACO+VqVW5R1p34Q/L3lAMjy/FFZ5dEY4VZvDx+rD3o=; 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=KmFNAhxt39GYnciueVYK+9nNfGJS2ihO3vYr8/kyv9Fmvaq60HXD4MRKuOvTnRCRf sCAfyMrrVASja9voL3OIT+8ziiRLM45Zf4hw6OUeplb5AfB7Hs7PKCXR8GYrYSC4Yl 9XI5zns7vTFZPq9ACpl0oqtBH+9VVeXy4Y1G/Vn4l/romwPJjq4NcgVlEBaI7tslSj oo0VfXsaClWtSeu/Th7MMrq+gmCahFhubTgh+sOnKmOqOxrINcr8oFDJcCYNO70Mdw qVi5aiOMypmELd5j+zGgSdBWOL3uWBwqeKYMerCMVcusd0TRbw7cC3gb2naTQFHpbr hQUTeqX6hQnyQ== Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 73F6363348 for ; Tue, 29 Nov 2022 14:45:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="sVWx2OOJ"; dkim-atps=neutral Received: by mail-wm1-x332.google.com with SMTP id o7-20020a05600c510700b003cffc0b3374so10874057wms.0 for ; Tue, 29 Nov 2022 05:45:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/HHy1+rB6cbeRgieQWT6F2/fu92XrxwPeIORdSkWXT4=; b=sVWx2OOJwtXWTcn/f7AOF80uelt1nvWJRDFStlUCiq0J0YqzdIKSBLdiZ/dT9zjJ4T I7SOQ55NpD1JhyHO0kEZ3khSOdAGUEkdF3yea6aH10Phga32gfje3Q9GJlxcYgICySNq 44H9v3URutNIZzBwFdgJSTog47MoVmtomfhfXvpfPEEKMXdHnJlRQrxyR+kwLlFzHH67 dPpyJuq29i3rwGlJE0mz9YTWgw9dS7GEzs7XvMi3M0Dq2v/ljKr9q9hvpXOWBrlzV7a8 +NL1KWKpavj3MrgCxQfzC6+g82UJosAAVbPiPbrYdiLM/Qqi/0bNWktCmFvaHuEez++3 bK4g== 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=/HHy1+rB6cbeRgieQWT6F2/fu92XrxwPeIORdSkWXT4=; b=meUwpchpMpsP2eQHltx5GtkrPyLA7YNhue7IqXNxL3dogNT6FJjXoDp5EHjOJK1rwd NLsgYCTeOykKMwhJfSpwCfe15jKlfOb1AQj2bb1E0sIwYMt3uTRRNc0UVRLm3tSdwc+K J+zwfg0a0jJwZa1KbTF7gWP/6ciIG5Wg/iTjmesURjoxfRGj92qrhQ66aTvRbF8t7fZ+ cVEEZORVHFvWrEQzH5NR06WZ3OblysaWhwTWmBmepstZw3vgpnC+Tf+qbhPwTiFjLUf2 Waszd9zilQjzDkaywsAKejYsygkRaU8722YDfzeKhkNQTWKm7dc0Zg01hZwRf3giX2Jk kFXw== X-Gm-Message-State: ANoB5pkcKY6P5rnfyqf+LOGg19IxMGlyJf3RP68YCfBMHVB2lxg8gObP DD/rd1KKef9huZ66j9OxCK3nZDUu4okkmg== X-Google-Smtp-Source: AA0mqf587ERPJny49ftglo3xnPnvYz4XbyjTPEQUNALDLKqKwdJ3LHiZgw5SpqjmppKdrYwMLZ2hOw== X-Received: by 2002:a7b:c456:0:b0:3a5:f600:502e with SMTP id l22-20020a7bc456000000b003a5f600502emr32725081wmi.39.1669729544939; Tue, 29 Nov 2022 05:45:44 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:44 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:34 +0000 Message-Id: <20221129134534.2933-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/10] pipeline: raspberrypi: Add libcamera-apps and picamera2 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 optimised for use with the Raspberry Pi suite of libcamera-apps and the picamera2 framework. This configuration minimises the number of internal buffers allocated, with the expectation that applications will always provide buffers in request for any configured stream. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/meson.build | 1 + .../pipeline/raspberrypi/data/rpi_apps.json | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/libcamera/pipeline/raspberrypi/data/rpi_apps.json diff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build index 0592fc53877d..aabde57f25c6 100644 --- a/src/libcamera/pipeline/raspberrypi/data/meson.build +++ b/src/libcamera/pipeline/raspberrypi/data/meson.build @@ -3,6 +3,7 @@ conf_files = files([ 'default.json', 'minimal_mem.json', + 'rpi_apps.json', ]) install_data(conf_files, diff --git a/src/libcamera/pipeline/raspberrypi/data/rpi_apps.json b/src/libcamera/pipeline/raspberrypi/data/rpi_apps.json new file mode 100644 index 000000000000..e25301744499 --- /dev/null +++ b/src/libcamera/pipeline/raspberrypi/data/rpi_apps.json @@ -0,0 +1,28 @@ +{ + "version": 1.0, + "target": "bcm2835", + + "pipeline_handler": + { + # The minimum number of internal buffers to be allocated for Unicam. + # This value must 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": 4, + + # The number of internal buffers used for ISP Output0. + "num_output0_buffers": 0, + + # Override any request from the IPA to drop a number of startup frames. + "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 + } +} \ No newline at end of file