From patchwork Fri Oct 14 13:18:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17596 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 29A12C0DA4 for ; Fri, 14 Oct 2022 13:18:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E0D462DC0; Fri, 14 Oct 2022 15:18:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753535; bh=pJFkucVB9rxJO4NW4seeCPGipcgO5BSEG6Mr5Rdtppo=; 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=LGQiXr+FDRKtOYS3TfJQvA8vHqoSOx6WamsV0FSOuBqHQzbCWcuF7d45cKks85rqy Rt4H5tjMf+hg+qdVnnsCeURYvuWr3QNKYlmu6htqX9K9d0AFjgJlO0sc2jols4KYZi eUdPI4KwrAWghCX1auzvbdYrosrl90AzJeFmq5Nm0BqMMn9E+ymtETiaLla2MGKZH8 PRs5OsfbolJDygSeb7ZQSkQM/5Rg/+/yY47tlHH4NJliZI38Ds62gY2uceHiVbVEs+ sTRMBxUskbriF6QdScEJtgTn+juMUzB++gFbd9S3PDvpP3Ymgnm27aRejiNB388YdJ KI/sX+c4b6o9w== 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 7E05E62DB4 for ; Fri, 14 Oct 2022 15:18:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nBjhQO89"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id b4so7572842wrs.1 for ; Fri, 14 Oct 2022 06:18:52 -0700 (PDT) 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=eHxk+LvYm29yyPUnLCf2+9E9jltugsKim5wIoTNNHc4=; b=nBjhQO89Xyop/cq/OpQGBia/gbzcAbjElWyGbsWGQM1snTPp7JrAcPbhBgALqsMnUx F5H94UCozxaa3QpMbH+o9KKrp2znAJHxqKZcsFRRlRda73+MY6AIrDVyq7JZ+5xxzF5j ua1bqYoYg0fkvnWI++teMzdGJeXwogfIFP9Vlg9Y+oU7gjg/axfgUIlc8kTzUb1SV3Vh 1r3wQK8yWwKvL2lgHqmPEdLEKctwhyGsERIUwKd2Cvd9yqYEHy/vTa6GYlYieXenyXNh s1ykTUSFW73jy7cU08dLRyQ5ocB/hUJRWNzrH/1HzclL1iBythb0EbiCO6j+MJswbI43 YGDw== 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=eHxk+LvYm29yyPUnLCf2+9E9jltugsKim5wIoTNNHc4=; b=46hjUWK/+NBGiYAuXVj0vgXj90lCgtQqfwYX9hXG+798CJsYHiZ0Eb2XDkw4i5OxMY /hTxkjSX8S9gZ9lah7mxqh9NNjc6LItIFd8r2sV1d8lrRJ+z+bCu2PnjLkuYX1BtKCU3 5CAdg2ocXw8igDoy3ju6n8kusGITmwCJFwZiMWTsz6Gy4PRA5KmxpT5nUEy8UHLgygPQ ftW0iqyM1l3rC4s4gcYTEcZD6wONDZyx5CL3V7oP0lymHyL511m/s+6LrYEPLkjQFqt2 3wdSWz0ckZ5KMVa5dEHJ3n43FQtxNdLzYylijnGRkbV6fweOZ9+xKiaqDs9MVMTInaPL idLg== X-Gm-Message-State: ACrzQf3XlCXUZV1rBBJMtaLFQN/CFCa5GgropCw3JENeouZ3A1ANNTRX cRZ1UJq05VnDRTlwQyzcRyN8XhwhuDT62Q== X-Google-Smtp-Source: AMsMyM71Fw4vxMWFuyfhDuftMGVdCKG1Pj3x6E8z5Rh0pm3ShRQS55YWl9RJpRyVhHV9Qu1GQSesCQ== X-Received: by 2002:a05:6000:1866:b0:22f:2616:5613 with SMTP id d6-20020a056000186600b0022f26165613mr3294779wri.145.1665753531836; Fri, 14 Oct 2022 06:18:51 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:50 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:37 +0100 Message-Id: <20221014131846.27169-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 2 + src/libcamera/pipeline_handler.cpp | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index b6139a88d421..6648975f15de 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -74,6 +74,8 @@ protected: virtual int queueRequestDevice(Camera *camera, Request *request) = 0; virtual void stopDevice(Camera *camera) = 0; + std::string configurationFile(const std::string &name) const; + CameraManager *manager_; private: diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 588a3db30e82..998dcece05f2 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 @@ -625,6 +626,62 @@ void PipelineHandler::disconnect() } } +/** + * \brief Retrieve the absolute path to a platform configuration file + * \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/ 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 &name) const +{ + 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 IPA module. + */ + std::string confDir = root + "src/libcamera/pipeline/data"; + + LOG(Pipeline, Info) + << "libcamera is not installed. Loading platform configuration file from '" + << confDir << "'"; + + std::string confPath = confDir + "/" + name; + 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. */ + std::string confPath = std::string(LIBCAMERA_DATA_DIR) + "/pipeline/" + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + + LOG(Pipeline, Error) + << "Configuration file '" << name + << "' not found for pipeline handler '" << PipelineHandler::name() << "'"; + + return std::string(); +} + /** * \var PipelineHandler::manager_ * \brief The Camera manager associated with the pipeline handler From patchwork Fri Oct 14 13:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17598 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 D1895C3285 for ; Fri, 14 Oct 2022 13:18:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BAE4162DCA; Fri, 14 Oct 2022 15:18:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753537; bh=goFAaoDI8o03/gfiSute0UE3zr84ty9OOkq2eNc+11E=; 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=s3gYPMxaxU50zqMXZCTjCgEaUX0i1npvQLvXdlhXLV85mToefaN2pflodUaAIaN5T zJ8GU7vYH1eOoe6qEg/t4iuuogz0+oxHMHbH2qgs5x0cWEe3TM25fL2tBZAKrbaRJv GUL5s+zDdNyvFk2j/C4+SLLekWUnfF5TEJqXGHw3jqzvUecMNGLYINxDui7hZ/o6FK zILym0bPzFxXiLgCETiHqERaLL5kn40qXoSvr+AWTJ9xdIKsTkeHBHh6Wmhk4p4uU3 mf3w8ik6tZ52izcPWQ/ruyUXMNH3jjiasPtt60mxH3aPjxu6uETr9VCGPt2hMJYx+O qyfjgRIYarfuQ== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C429F62D8E for ; Fri, 14 Oct 2022 15:18:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="RJVk8DxQ"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so3519279wmb.0 for ; Fri, 14 Oct 2022 06:18:53 -0700 (PDT) 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=e/GW87CqgWqh4eKNVRigDH08aPTFQ6MgXDRPJsXtl+8=; b=RJVk8DxQsYoV1kNYOxQqH+bNtuUoOpPczpEKGqv6HMpXDx1WVLxqdqUKQkxXMrnC7b 3Y9WNZ3CcxvS4wLuUTJLSP3CdCrCV6joAUWwVFRY7xq9R0x3DgBn1qZTsRZp5ZF/tDTi bJI/K4oKQ0ptPTOxQAulQknBF0vLfAs9EKRiyKoqoQiL6dS6nwnjkzoe7wwHpJAXa9cH ui+FcEbUti2mp6goTVtQoEEfA+/8s2SrEj1ZAqR+4WTLEDwYn5adZ2homk9ci+6tz77j lpRk8V3KkkwpeZ3b+6Dln/83UGre4NvsDunRwrZwX63E65XMHOhCAQwOr3XbT+LNeMWm JRvQ== 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=e/GW87CqgWqh4eKNVRigDH08aPTFQ6MgXDRPJsXtl+8=; b=P8HPqToPkkBzVbBM4mNVxVE0CXvsvFcrCMkGZagv85WtuBitR3fEP8yaYJfEWXC/Iq 3BXz1HGPHPUJUs4ndS2BM1i9bUnExrl7USdTF19w4/r0y9+Q4Hl7jGyPajHfdBlDA9sO 0assMwtPLJiO4x7AFFjPGdIp8apBNx5l+xGgjD3INOs2ljnHtmXZ9TgYccUqqfccGiIl kvbrkxg7CRY78oJ9gMNzlVSZa0oo5Eg2zZJNj/1iV/tX8Ler4wfUz5BN0uiWEU6ZJ3c+ Jvcsrx+8R/UhIYFgjqcErujSf3B+M7tFXJeHyfmjyj8vXy2//7HJoqg46RSlpNeSXKBJ DODg== X-Gm-Message-State: ACrzQf0l9SxjDJ11EI6Oh13wb3/+PB1ltXRnVycDDjGYuQCmlbSf1iT+ ZULWtXnNjIiXlJHN/x1Q0FrGKPO/g6NZCw== X-Google-Smtp-Source: AMsMyM7193NQTN8PM0BYQTCUGNy/WyFslE9SFPG2tW+C6CUVzkB6AEfgZ35GicjF9KSQtOJYrHPnug== X-Received: by 2002:a05:600c:4fcf:b0:3c6:cdb9:b68f with SMTP id o15-20020a05600c4fcf00b003c6cdb9b68fmr10621950wmq.73.1665753533147; Fri, 14 Oct 2022 06:18:53 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:38 +0100 Message-Id: <20221014131846.27169-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d366a8bec007..7d1e454cddcd 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -294,6 +294,13 @@ public: /* Have internal buffers been allocated? */ bool buffersAllocated_; + struct Config { + unsigned int minUnicamBuffers; + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -343,6 +350,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); @@ -1368,6 +1376,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 = @@ -1380,6 +1394,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); @@ -1430,25 +1456,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 Fri Oct 14 13:18:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17599 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 8CE22C0DA4 for ; Fri, 14 Oct 2022 13:18:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E61562DCE; Fri, 14 Oct 2022 15:18:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753538; bh=DmRt7iDdF3iU70iACpSbId932K7vjHRoNGMzbP27ZSY=; 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=wZvTznotwubP99cXOEOK5QXH2b9ZxVPrVCR0rXNtwe1OdHO/AIkfcG20Ic636wIdS XhwPppqA1F74hnckIVN7eejWWAbC3BLQ5/BnZNeNZBr7rAUuOsvbYygYH03M30wxHM /EwZFT6YOtk3C/o0vHG27nDOMXC4elD9pJsyLibShpmbwkoO9kzOL8Ac7CW4/smA+x DMcffYZ75QcXg5V4iLVF3iNORLty1iVJYUEqVPLwD64HJzG5YJBKPFqdta0OgoZSIV JAGHyHPjeX0G+q6FyHTJRX/bJ/WmoHEwklK3T4YVuPlV7FKsMykSBVpe5TrQ1ySHgb LSEmmlJxeoe0A== 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 7FEEE62D8E for ; Fri, 14 Oct 2022 15:18:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gF5hn0SG"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id b4so7572980wrs.1 for ; Fri, 14 Oct 2022 06:18:54 -0700 (PDT) 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=jixBM/knBT5ddTo/kQAj1J1RKHqf2+VLhhPdXJMppwE=; b=gF5hn0SGw7VA8OeepQO46ofSnn3+1BuPEMrhwG8gk6dlgIL7gCrSucPYudJeInfpQC kkGz8IluVZn9SNkY6J3OMaO/pUmutYO78v7wPhBubLYHc0GIFPD7nTMU/k0jAIzq5kEz 3SPZZ615W7tF++Heb4EFeRDHXeVv2EwrE9O6Tuo5f/67FS7rkfAF5ZDeY0horMfBof0Y M3/30X5etbUyNI1Nr11AJOSW4kbsxmPGTAQceELWLsVxiXQ9mmnRZhmuO9OqoPIN9+PJ VCKXTjwBEoFafP9cuZuxUUXAhfPK5mtMw9Rscsvfl1I953UdztrvEUD0NyPDiOcPjnsg jXoQ== 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=jixBM/knBT5ddTo/kQAj1J1RKHqf2+VLhhPdXJMppwE=; b=wY1M5PoerfgK8jxTnCphIhEKxLm42cza5i5eQiPHPx28xBZ2pbh3tMojRqB9NOxLMO DPfPs/uQxIK2KKG5sUWU6Ej5Je8KIxPfQhvrdCIEaTCfolgT+ahbJ6uZqzAtrDsOqUbk Emb5lxRJvyutthQvYI4qyHxH8CGf5YEdZ18FNOaSCGypdmlrCfpI+WuOBOitJ4olACmz ERBQw06BRpbUvJZn64HCUnOro9oNYsjBXKzRlvTft1MXRtVDKA86kczHD+xKf756k7Ry CNDREK0B1etYZwbbowEPOKg9Iisstgw9yWfylAHUyIJ1bcPk16Kx+KIjmQphcVtnHhDj EWOw== X-Gm-Message-State: ACrzQf28f3YlYeDv7sS+pKFwzkWREGWf0PjNTnV44c3//9uqFYyrDjDV mDs/8KgTuFmjBk08fxxOfAeCK/L5PUGYXQ== X-Google-Smtp-Source: AMsMyM57oiF0CLza799DZ0gaJf4E3bwKce6VqG9nWwoYAit+QTPuf7HlQltmXEVow4xPmFsVzPDXhQ== X-Received: by 2002:adf:fd4a:0:b0:22d:d3aa:e004 with SMTP id h10-20020adffd4a000000b0022dd3aae004mr3362492wrs.173.1665753534058; Fri, 14 Oct 2022 06:18:54 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:53 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:39 +0100 Message-Id: <20221014131846.27169-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 7d1e454cddcd..450029197b11 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -297,6 +297,7 @@ public: struct Config { unsigned int minUnicamBuffers; unsigned int minTotalUnicamBuffers; + unsigned int numOutput0Buffers; }; Config config_; @@ -1401,6 +1402,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) config = { .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, + .numOutput0Buffers = 1, }; return 0; @@ -1485,12 +1487,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 Fri Oct 14 13:18:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17600 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 C92E5C327C for ; Fri, 14 Oct 2022 13:19:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C9F362DD4; Fri, 14 Oct 2022 15:19:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753540; bh=nz3wJ1qW+PINInuZKlj5y+yw3Z7lfUw7r92acE02Cog=; 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=P6nUguKBTFllMLulI0nHtDTSdP8Vb6rpvppicF6ZHtobB+AQQtzO1NrojRvgJkSng oBa9H5JXTgUMJgTr5vbv8t+w3zyZfmujBnd7csLyORxlWx/PIMhXr5h61tSD8cOTKM +4Bce+yEUgsNewFxfMM9k442xDlxAMDfZ7jAhLOQWa35nEKiyBcRbbdHKyc0BSOAo/ H9QA1QZ+luNcXNQ3w2y+hnsPUWBQFbVMZSF+vy9CpBbTotwzSaUGoWf44RE/ZHAq4y QnE64Pgf0OJdF4K8UfZNL3wZ/TEtzLTFmn068Lv8aWy4DXu9IpZ/k7QHFiFLjxD2EK 7i4fXgI67pj2w== 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 6A2B262DC2 for ; Fri, 14 Oct 2022 15:18:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="E6qtY5AI"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id l16-20020a05600c4f1000b003c6c0d2a445so3490143wmq.4 for ; Fri, 14 Oct 2022 06:18:55 -0700 (PDT) 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=xz66QQBqRMHVmsLde1uoiES/yRhcr0v24H45LmZwNm0=; b=E6qtY5AIUBKqauKjRhUmMFBsLl31Ruiaf/kZCUAExBJYxRHPZd16pLLgphUmEpjkhg xHeK3uLPqwDG5dK+JTu64ci7QAfPGLXhor1MYiDcJiG+DaKPXJFUIjpEQXc9XSEFZ1Mr cc34fDsoZsMIL5/FBbiWeynH0s/6/MuvZ5DsM0uCbIHnJlyrgTeIYK5EBXIi3mRixwJD H2A+hs8sXGWV/ulM4Y3X5aZoc+5AtGULfDVggxN9uHfF7LOeXOCbMX7iDdSDa+SuGBN6 iBt1qGVkzHtpWB0/Nb9ebgYO+VIWNiWlnherXeAnS6qHj/uqrzOcfyXrlrD/fn3rYjuk oJtg== 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=xz66QQBqRMHVmsLde1uoiES/yRhcr0v24H45LmZwNm0=; b=JZ4CFS03G+Q6HDxgxUmPebzq279xiki/MRzUm+TDVGCNyw+CQXdwCsiWGj7WpziSwe 1BxNjB3dZpxMSvsDrZHWNg+wF7h5UVDmeV4Tssl8d2/Bn2tNeWUYxu4q4c8vEh4QrwCW sEupPbC53HqLa6Ybq6kNZ6q0jkECWxLXGEtT+m9Wc0htcycqQtx8R9V12FT2AlA40aic MgKAhOoIyZWefoaCynVch5IyiayV46z7ZNKxzdZjIwWZdnl2brdw16WfReoaAu/m8ICk 9pof3m/7GGfuPXPO/5esisC2vvY889RiDnCburd3CsOXyHzIGpBKaxwYh9k9psJDL2zO Zqpg== X-Gm-Message-State: ACrzQf3lo0V74V9Bxli3BHzpkQYuf7vXPeIgOApxKDDX6xIbObBCslSl zxguwanvUblxdgvm5qKE2pM8D7ch7/cjCw== X-Google-Smtp-Source: AMsMyM6o7YSWlcNXiq4QkSnh5oAYeY8gc9lttQZuCfTPbZgTy1RBNJ3yP1yr37+AjTRCfVs7igwcyw== X-Received: by 2002:a05:600c:4194:b0:3c3:d0ed:2d44 with SMTP id p20-20020a05600c419400b003c3d0ed2d44mr10652925wmh.151.1665753534792; Fri, 14 Oct 2022 06:18:54 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:54 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:40 +0100 Message-Id: <20221014131846.27169-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 56 +++++++++++++++++++ 4 files changed, 86 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 450029197b11..bac7a66ba900 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" @@ -301,6 +303,7 @@ public: }; Config config_; + unsigned int numUnicamBuffers; private: void checkRequestCompleted(); @@ -1140,6 +1143,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 @@ -1398,6 +1414,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, @@ -1405,6 +1422,44 @@ 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 || config.minTotalUnicamBuffers < 1) { + LOG(RPI, Error) << "Invalid Unicam buffer configuration used!"; + return -EINVAL; + } + return 0; } @@ -1471,6 +1526,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 Fri Oct 14 13:18:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17601 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 B0A62C3286 for ; Fri, 14 Oct 2022 13:19:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5E42A62DD1; Fri, 14 Oct 2022 15:19:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753541; bh=Z09FsJ1eeq8/QE9utbzWP8pRJbtszBu1HTsfzhspEU8=; 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=fyp7x+rREq1wEQa895Ix0ZX//2SG4RR/zkdLeUKTPUJI2Iua3StxiZkItykOCX08Y KtnLIbd7kESaH28B5JJ5Mjjr9dCxfbFFY+uH3FJjzYBtLp/gAtCKCZVS5dQSXL+CMo 95fFLzoaCjuLAV/x+pGF8jzyd4mNt8zyCgK4lKsKqswKMrYjIEiZMGWAJWYfB2h2ya vei2dbEC683R/rgJYRwuMpkFYqQXE+yzA9PMBe9yB/ps7RFeiryDnpAuVSjHGebo/B nnvzuG95Kc8socAVzIJXTkarWLcTNGBJZtWCB2uAJock9jnuwmXmRkJOYZWjHFAAJt D3u4x6MkwTLYw== 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 1D86F62DBC for ; Fri, 14 Oct 2022 15:18:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mq+hM1ZE"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id o20-20020a05600c4fd400b003b4a516c479so3506547wmq.1 for ; Fri, 14 Oct 2022 06:18:56 -0700 (PDT) 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=JxiJ0YIUaJLrBxVyStnydR+o/sXghSBmFy3EK7DLEUo=; b=mq+hM1ZEBTkBBT0hqJZpYrbBpctJEZDWlMGoKbZA9X7Gqane1IF4p9h2qZfa+P540N HhimNLB68itazPznfUxg42kyGivsg4Q7SAio7ceKgb9LTHGV0Fctfk5DQfM48wFUwQgK PayzEIidgGcOr4H8F26oFX6hesOWgfri/JIFrsz+3JqHVN8Fwecb5yeegE7JNvOmGjqA 56hnuPXkT0SPhHJbjWfSVfEMs/IwvZB2fURcWHG0UNWqdPCP6IcxitGkyOiK/462JeCa REB2fSO5m96fzHAPpnaxqfmjOhzNONbsAIFVTGP+ikh77v2qfyx7AKd4ePo/I+5el3MY biPg== 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=JxiJ0YIUaJLrBxVyStnydR+o/sXghSBmFy3EK7DLEUo=; b=kA2O+O6krNt88cU0AlV5MqRpSC2EKzgAWmzGsy8l3p6wiD6zwMOhy4BdJLZ/crnXd2 wBSYpkBPBj3b/qxIVc8/BmmKUyvwty7VKtWt18ayveyJ9DaCQYLOWEi3stW+SNfCQ4E1 Gd2KSyMEqQeqRM2995rcr7mspoZjv/sjAsLxzO5o8gH4JBGF51f/XbYyIy+F91ZG2mgv dgs7Pncp4AVvpuoyuFg2shacgewIDoqx70p1o23lk/pXDkSJIz8bwPrJ8vGwPX60WaH4 jaoz0GYu7BLGvPb8h+LefPqww12ptFBlH1jza3ukdoa5h0TLaHZuSP1ZgNh95fZz9h0j R1Vw== X-Gm-Message-State: ACrzQf2iD48S0gv6M2B0IwjQFnEyS4du1dyJAtpveZpMKAA2mN1uhFJt mUvN8j0ZaUhncJkiKlPfr7SqAkUXMTwgJQ== X-Google-Smtp-Source: AMsMyM5vIkOgqEfFx7ccvQsz5PfgpXs2HTFsHXk7eQ4OsFQ/4c39Dr6eTlBZvS2Zdl4xRnZ5l7W4uQ== X-Received: by 2002:a7b:cb41:0:b0:3b3:34d6:189f with SMTP id v1-20020a7bcb41000000b003b334d6189fmr10476579wmj.6.1665753535483; Fri, 14 Oct 2022 06:18:55 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:41 +0100 Message-Id: <20221014131846.27169-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 35 ++++++++++++++++--- 2 files changed, 32 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 bac7a66ba900..fc674e4f5bdd 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1080,8 +1080,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); @@ -1474,6 +1484,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 @@ -2143,16 +2160,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 ahve 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 Fri Oct 14 13:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17602 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 3A7D6C3285 for ; Fri, 14 Oct 2022 13:19:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2E6262DDC; Fri, 14 Oct 2022 15:19:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753542; bh=o6vkO44sTYo09jqM8FE/PBg/ldHf52mz0DXOsl9R4Lc=; 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=FykogZo8aA7Oi7LMdib9hrQsyRmeMswGRZ7Qw38jFi6wA8PmipG4JUfDAtVHH0+dt CsYizI7u28PsZbbbEoh4SLpOgHjkdzCY3PbfnzrlPpO+G2nbt/457f4vOBaDNYEP9Y yGlYc6yiKtLWkuJIaroi9UT1gSDRQc6bpWbQ2DXH+B0y6E9XZvWT/BoKmc/3nBxjGl SDm2rylScAeBPoNg3FH9LTkRsOdccwvwZRSrTAK9QEpv4X2oLUOhAAMUFjoO02bFdT /h1Ip1rPHkre/saDtIQIStjjPWvQMfl0BXZi/hl/bHYCBfsgfONiodVsR0ELvEFu/k 43eGgk/+XgbrA== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B700962DB8 for ; Fri, 14 Oct 2022 15:18:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="msQGbA2q"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id a3so7614218wrt.0 for ; Fri, 14 Oct 2022 06:18:56 -0700 (PDT) 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=lxqK9ryVYJYYkTjSeTRaI0AsUv563issP0mEV9l+D1I=; b=msQGbA2qUAFct6K8hxjD2tuaMT17RbeKilvGy1/L/TE7m4bNY8zLgMPpm60UrC0po5 8clWlk6hqzOyO1D1Z/XGkPRPbq/YjCq/H0mo9JsQTYT1JQJFRpDLwxe2wCWC2YIjILoJ zJy6YDbSOjQttua+dIEqYYio5dwA6gnG7lx7sG8M5CJt01e9OdpUiXHvtZkT8pdlBB9I 525mTvqMav+CKuQ037JfbwDePEtw++TjiJqvH5MBudM9hL3f6aqFeInKAJIL+GQCma3I bbOTl9YCcHThb3aOfff4aVc4Aji72haMZCHYtLiQLqEY4tz1eeGyh5XcZ/O6qSF1tyE3 JWXQ== 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=lxqK9ryVYJYYkTjSeTRaI0AsUv563issP0mEV9l+D1I=; b=zLHfGbrKhLnIDi9iAIGAveaW61he8OSUDrv+1O2LETstmTDYTjySVGpi6qNFE3FvOW Br8ZaUvIJsP7fVNGA2FBW4lkzGnbAMTEfcOf1Sr6Sbd0jjxKpugzcdBbpIxKvA5bHaO4 qKf8HHPmTHLUGtTYAuJO4n12zeBssWfnFS7F9k7Pp9hbb9nXV8wYOZUkB+PsortNgL9w MedlaiiKQD+PXeXD6/iRCTpxEAl8T+Y+hQMwiieiMxwchCrsBATCXnsS2XGu+LAAMom8 fq8xxRyLgpVdtiC5GcmTT0jm0jGZ/t3IbfXqE9Hm6G9HsLSCdq//hy6BQOpPRGuUHqxb ab4A== X-Gm-Message-State: ACrzQf2rZILA/I7bbn2gfuymtRjK0bFdKVsm+khfCzEA4WoTix+tjkW4 9L08yYz4MjwKBeooI64BO6YN3oR0GaQYZQ== X-Google-Smtp-Source: AMsMyM7fWxEMz4Df4F0StJml//8dtQ8ZUWDdZm+p77DCgIZSh2i8St1xrYIpSAmRY40XI87BhSS9jg== X-Received: by 2002:a05:6000:184e:b0:22e:4612:496d with SMTP id c14-20020a056000184e00b0022e4612496dmr3431400wri.91.1665753536214; Fri, 14 Oct 2022 06:18:56 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:42 +0100 Message-Id: <20221014131846.27169-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 --- .../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 fc674e4f5bdd..2aba0430c02e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1030,21 +1030,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); @@ -1061,6 +1046,21 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) /* Configure the number of dropped frames required on startup. */ data->dropFrameCount_ = startConfig.dropFrameCount; + for (auto const stream : data->streams_) + stream->resetBuffers(); + + if (!data->buffersAllocated_) { + /* Allocate buffers for internal pipeline usage. */ + ret = prepareBuffers(camera); + if (ret) { + LOG(RPI, Error) << "Failed to allocate buffers"; + data->freeBuffers(); + stop(camera); + return ret; + } + data->buffersAllocated_ = true; + } + /* We need to set the dropFrameCount_ before queueing buffers. */ ret = queueAllBuffers(camera); if (ret) { From patchwork Fri Oct 14 13:18:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17603 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 B342BC3287 for ; Fri, 14 Oct 2022 13:19:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4A61E62DCF; Fri, 14 Oct 2022 15:19:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753543; bh=yPJ3S5ePksDxI13TuKjRrYLoz3QD65zs4J/EG6QH2Gs=; 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=C+tb0tOlNM8bj54ceSui2bjiriZE16hp1M7p7uxP/Sn51MyksHwcFjiG+VuDqNUZC 4EIqx2G7QbPQlEGUf9qcQVEAsldSDKE2ULVlWhGgARltmVHe3C41KsMiS1f+k/2V27 5esbEBXMOjg2iA0VEmq7vv85HkV3Jh5P7H8uz8Rc4kVVMpElinL+5PjnaK/TQVmccg FneYi7L4UXPXCGKQb9rMEDBe5DU59YbUn7QrzGRGZugAsj3Qe0SsWVMw+GdncMRSLV rIBo63I0XNouiawTEzqfHmv2e/AwjRJ6qujuTBCDdxlCQSqtKjHsgjcKYfLmj+F9Gn 3QYp3u/D6tnoA== 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 79FAC62DC2 for ; Fri, 14 Oct 2022 15:18:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="VyxR7uBG"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so3489844wmb.3 for ; Fri, 14 Oct 2022 06:18:57 -0700 (PDT) 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=9MEcdherGyKKJA3fExM5ot5SzxT8Cp9XWWgwst113Kw=; b=VyxR7uBGRO8lL5b6ag4t5alQSKYqGVPjk0f78Yw5bgHYIf0JQ70o9Zg9VmuDsmO0Vc U1xY2E+SEx1seCUXgFOElUfrZpKM39MJnirZKLrA9jd5sHIB0EQ+O5KDEbabXfwGOmHg U26OcH/7taul+B7rdLfpkJpoKkxBut9EeNawcxVS9ep3O3LHz5GylFCMTAGp4vN6cwIA 0/UtYfruVcPxvfvnXtnFxisws0BIFilnAF8p0tV9AnxmgZL/4zUvQjICejB+4ydufJ9i z5LbDIm4zX8GNJM8BUvyeGDmbF99IEV1jBmi9FxyZQ2u7XsAEK554WC5SJxZAwEYs6ui Sthw== 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=9MEcdherGyKKJA3fExM5ot5SzxT8Cp9XWWgwst113Kw=; b=Z0PKZTF9O0ljjZ/K2ot3adWMxQVs0zpO+BZZ1vY70CT9Bc8UA1Fk7KwffyXIKR1I+N GZXATHIPl17i7QBRyjcI0IW2AawjyG7LCbSmWLZX/v/HSf3xbLgP7cfaWvginM3GpkkJ me/Z3qeWtgdFOkiU2zxtGKrCRTOj/qQ2N5Ku0b6y+kinYg3clYMrpKeOY+EQvgRCaZ48 kc+S2JqjndNGTa2V/uAqms4otbSN3XR4H1Is+dSrMoccjQTsROjPi4UjCAN8wBqqCtmn o67XC3l6aC6+gNQSCF9WHVJXZ8n/SohopOCG1LmHAa8qPYwqnjjr3WNSDv/au1ks/1N6 onrg== X-Gm-Message-State: ACrzQf038OxLiN2vcxBLsUDdmEvuG43LwO7vx/gP8rV3onTOcZe90ElC CCWPPSY+4ARuV6Npyb91T+lfJvHsLxfydg== X-Google-Smtp-Source: AMsMyM6lSi/aojev0iSoDyNQTEZsodhslEC/3GJCJQsULQ2vwYWYbC5fZodCGeRa9wS2kPcJsQIprg== X-Received: by 2002:a05:600c:3147:b0:3c6:d28e:4440 with SMTP id h7-20020a05600c314700b003c6d28e4440mr9280868wmo.68.1665753536853; Fri, 14 Oct 2022 06:18:56 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:56 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:43 +0100 Message-Id: <20221014131846.27169-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 15 ++++++++++++++- 2 files changed, 19 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 2aba0430c02e..135948d82f41 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -300,6 +300,7 @@ public: unsigned int minUnicamBuffers; unsigned int minTotalUnicamBuffers; unsigned int numOutput0Buffers; + bool disableStartupFrameDrops; }; Config config_; @@ -1044,7 +1045,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(); @@ -1430,6 +1431,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, .numOutput0Buffers = 1, + .disableStartupFrameDrops = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1464,6 +1466,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 || config.minTotalUnicamBuffers < 1) { LOG(RPI, Error) << "Invalid Unicam buffer configuration used!"; @@ -1543,6 +1547,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 Fri Oct 14 13:18:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17604 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 516CDC0DA4 for ; Fri, 14 Oct 2022 13:19:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0A29B62DE1; Fri, 14 Oct 2022 15:19:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753544; bh=Sx94jdwybthZB2u6g3tjU5CI9+F1KFjRSPOcsPRcxLE=; 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=J078x1/avHt2CWZvPT2KVV6Lt77kiBaq9QLBuTTE+1J/2PY9Lsj2lbgTAmACrGdUz NmvMS70rqHiUR/TCRo97X+wxtCxjkUH9jIR/oeLk/iY+9NhPaYAoOT+5LdQueFA6KF 4CxyNfVAfgL55c3gDnJL8kPZ3wwBorA53OQvmhCljqAFImvKPXhKHktu/ISdohsCV3 D18YavjgJ6e7qMHd6F/2CXkIKP+ZYcZcxuP6o7HmSu6Xj1rHi+kwVKTF8ty6wLgFpI QCFjSfZguMmKnyTDigOSBbo5+tG4QqEXsr0wJ91Z4+MG6YRGDvZcTo5AHJHLtyYDOM kGVGUII1G3PXA== 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 7B6CB62DC7 for ; Fri, 14 Oct 2022 15:18:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ElZ+RUkp"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id j7so7547672wrr.3 for ; Fri, 14 Oct 2022 06:18:58 -0700 (PDT) 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=/JfxSj6icGHMD+GjblGRyWFSbev1nXgdNOIATEO+/Es=; b=ElZ+RUkp/958Iwu9OCQEOAlUo5Z5wbJGZAPvPwry5lV3Pt4LtLkCLISfA63g29J3re 81UZjwZG9p5PoJdtYbUAAVS7wYIV99+dSb9/3rwxEp5XFsrteqec2n3rxNfaTT7Pa8Mr 8+1Sq/jjNfP3Ghv/F/5I7Xns5PpwfizrGuoNnUbqY0fCgT9nsyRWaKNRe2ZL7Dr/WZrE 9ulXR5Ah+UHIkdr3y3cDNXxZ7Vzv8rkgjrj7lFq2x+XzMd9SpShV2aSkDBF+50696tr8 GUKKSUJfjvKs3NSDVmDSAcr+ftF9Y0BV+qEok33G661AbNKDThC4bne5AkNffRDWPWB0 mUPw== 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=/JfxSj6icGHMD+GjblGRyWFSbev1nXgdNOIATEO+/Es=; b=Hl2gE8l2S9y+jUwkDYmtP5u+7blvHvv2fUWJHSn0lWGje9inKiuQzGh+DZnQV94L/w wUW30JvbOfDgxEKOm94AFcZJVzVN7XxCGzEk+cXPLym+ZnrlQqoOE7Q5sFPh1XFGs6VP HtfMInvReo/M0Ainy7zBLnnoJh4QXAqIn8qW7Jvyf1Q1PqXpuNd8/ZMQnf5nFQj/7iGI Q4S1WKQWeXCOerA5Oc8JfwQ34xK4Sb4fQyYqS2uPyfEyNfkoZxVX0VJSBABNqZmdAE9C Y9rvQS+IOi4/VWl3UHOT6lXpHgX/xV9Ds15XkrkjWs7rqk8J5XF6f/kKWfYndolLmzB+ YSAw== X-Gm-Message-State: ACrzQf2idR3jRiIaUGNW6pwpSxRJeyuZzcg6/pk7sLLzWSR+tQYBLMDT e0JDJXyQrSkXaCesamvLxgav0E5SPPWkRg== X-Google-Smtp-Source: AMsMyM4odAL1BT9hLc0THqF2wVvfB49vmy1ADwpHSKLhiBkA4MGn3gQlMLy0HZbAb1h0UDcnGVOxNg== X-Received: by 2002:a5d:4683:0:b0:22e:6be0:dfc6 with SMTP id u3-20020a5d4683000000b0022e6be0dfc6mr3412587wrq.573.1665753537527; Fri, 14 Oct 2022 06:18:57 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:44 +0100 Message-Id: <20221014131846.27169-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json index 707414bcc5c5..f900ca824523 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 heavey CPU loading. + "return_newest_frames": false } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 135948d82f41..d9bea35c88a3 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -301,6 +301,7 @@ public: unsigned int minTotalUnicamBuffers; unsigned int numOutput0Buffers; bool disableStartupFrameDrops; + bool returnNewestFrames; }; Config config_; @@ -1432,6 +1433,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) .minTotalUnicamBuffers = 4, .numOutput0Buffers = 1, .disableStartupFrameDrops = false, + .returnNewestFrames = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1468,6 +1470,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 || config.minTotalUnicamBuffers < 1) { LOG(RPI, Error) << "Invalid Unicam buffer configuration used!"; @@ -2320,6 +2324,21 @@ bool RPiCameraData::findMatchingBuffers(BayerFrame &bayerFrame, FrameBuffer *&em if (bayerQueue_.empty()) return false; + /* + * If the pipeline is configured to only ever return the most recently + * captured frame, empty the buffer queue until a single element is + * left, corresponding to the most recent buffer. Note that this will + * likely result in possibly avoidable dropped frames. + */ + if (config_.returnNewestFrames && !unicam_[Unicam::Image].isExternal()) { + while (bayerQueue_.size() > 1) { + FrameBuffer *bayer = bayerQueue_.front().buffer; + + unicam_[Unicam::Image].returnBuffer(bayer); + bayerQueue_.pop(); + } + } + /* * Find the embedded data buffer with a matching timestamp to pass to * the IPA. Any embedded buffers with a timestamp lower than the From patchwork Fri Oct 14 13:18:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17605 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 27B48C3288 for ; Fri, 14 Oct 2022 13:19:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BDE6862DE3; Fri, 14 Oct 2022 15:19:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753544; bh=2Sy/DBqiypKC+W+kxP3byCJXUzU49e8NfVm12XkvPo8=; 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=MKW3mTYF2slIeet+PfjQJzM7L/i7HmcKUAZftCp7J0NYoSia1P7x+J2AZOmcyyXSC jZIuHb8bwKwfWjVGiNhdannDwGkt0nNFwxT1+syLVYQKQM6jntAN21oKL679Dnlu3H YE32PIa4EvPy0ukEoQ/ORqiIK0eAS7XqBX1dJXy01nwqO0/B9UeEkv7IwSaFA3rdsF 9WJYztSek0uPW6P3+QGw50g6Dc4IpIaN/Xk8sBX9lyb98Cq6n09MNr9GlTtwUsLe7z Usu4oL/nr9g3JP9OvC8+0iGxjOPKUXwJ4Ov50SpoijQr4069Bgc/ngavfMF4afdeo6 OoB7jTKfHfk8A== 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 CFC8E62DCF for ; Fri, 14 Oct 2022 15:18:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="omazfqa+"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id o20-20020a05600c4fd400b003b4a516c479so3506628wmq.1 for ; Fri, 14 Oct 2022 06:18:58 -0700 (PDT) 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=4AWqYSoWbUS8BtecNwzpxgH9URcP2OOV0lO91UAnwdI=; b=omazfqa+MPZ0rd+BFv0rnNzJ52pXillSPep8KIXvhACWG3eZjVn8fFiMfe6txHWjNO NdfIEWLQm3xYpi1LQRSwiU/afCIBcqqUjj2YJiPLDxMpU95GZJ0LS40Bx1e8cetfl6Nx 0YyJYPtvzVbK5Er+40aZTQm+cUVi1GeI2AQLYJADEWwUwgSLwLLzvN/W4VHSPV4828wE 2c0L2Tis5r0rFw0yS9Ij0BhMPJa7GKFVC4QubAuFWBZHNRm1G+aSWjNDDzdtQvCP0r+r uLYKETtyyztDkBIpBf861o92OGxje2xr3I+hEQ/zuhatxc/4UF2P7Rl6x5/JB2ftM+a/ uB8A== 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=4AWqYSoWbUS8BtecNwzpxgH9URcP2OOV0lO91UAnwdI=; b=Y+Yb7Uqv1MiOrXHV3Z7LSwXtv7OgMblAJidjkovxvMaY10UhsIn/oa2cEoPI04L4Mj XqGDTptIauxt9cYSSdt2RjPBTCCbSMSjwLzmZK5divwfWGj8+AVnp2Q/7ZJkXHuWKh2r Q20aN6cq+d0WPjs4cYHNzXS8XYODH4D+RuoTLmUkOktl+bhdb27e6WlwdxiD6HtV17Rm MXmLRZSfJ/BeQpwfjdtN83ucyyJ1++n7H5wyXxbFvOHgt+j9DMQMFeuE9CFYvbiBnOxa EJo3YMjU+aqyw3yi4Ewryt1jgZvuWUHI/TEI+x+TS+M/2QhLhwtBVx+d8LUZeza1wNiT RTlg== X-Gm-Message-State: ACrzQf2+TtbMJwdtOYuv8LRsdnp/OrgfjqgauRR2B+grleBd64VvY0kt 7LOpSChw1qPJgNVuzhPDcLsTYMovQhTRnA== X-Google-Smtp-Source: AMsMyM5OE977jpOMddr+WGv9LnfyVSbQQQwrSa0brto/kgYloYPYXh4bkv66e8/T1PYvahiooS72AA== X-Received: by 2002:a05:600c:358b:b0:3c6:e3e4:828f with SMTP id p11-20020a05600c358b00b003c6e3e4828fmr3529084wmq.10.1665753538331; Fri, 14 Oct 2022 06:18:58 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:45 +0100 Message-Id: <20221014131846.27169-10-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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..fb306aa08f94 --- /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 heavey CPU loading. + "return_newest_frames": false + } +} From patchwork Fri Oct 14 13:18:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17606 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 D89CFC3289 for ; Fri, 14 Oct 2022 13:19:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8158562DE5; Fri, 14 Oct 2022 15:19:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753545; bh=ERKArs7cOeZTf0Yw25fWwNSNlv+k2iN2RGQWLJgVFpY=; 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=2D2Xwn++UQla5GX/IqYyPdSZgqT6eWm2jgGoMY2fQAuCPrA9UsHSP9cPUiWb7HCGy xgB154pyjjrcsnFwTqgr22H32kCuQm8PTnrL6J049AKIGRqESCpVP2YlUX/gbnsZeV S908/pMQJZsIOzT+hqNGlaNvEB3LoUgU5hMM1RnWBhyvuIk64Lfxv3mmrBBwBA92Iu AVrpk6m5Z4owZQS9hEH+4qw0n/EYszpGo25oIGTOxOVCQuBNypsCKYhTJA4M7w3O3T FrFeJR6hLwfjU6abmM7aC5Jxu299kfa9/aTYgXCB5SWeoEH4Z4mqgVis8Ezk6gB2RJ Gu+xZmF9nFD7w== Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5E5062DBC for ; Fri, 14 Oct 2022 15:18:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="oJW9Tx5q"; dkim-atps=neutral Received: by mail-wr1-x42a.google.com with SMTP id a10so7490070wrm.12 for ; Fri, 14 Oct 2022 06:18:59 -0700 (PDT) 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=6br7n78pq5/RQvdP/HX1IT/EAJ79ReExaMx4vcs66GE=; b=oJW9Tx5qe4QEtNKtFQkgiucf+fT2wSGJqEf12oH5mKcVf6M6IaTQK9t5KC7k6MpJH4 sP3VBW71dE+zGsedDHpO2B2fHAMnHFqovEWHOeBBjmAQs5zzsf8ZPwejdVfwJK5ZBOzn tvNUHEIoZjFZFtnknh/jhoOqT7TmjBHsEAp4vGsw/4vBm9rBmM/z9DR1vlZRGuB539Lg tSexT5AIZXlW7VFQ+eVwZmolxuBPH/ELnBKyLLXV4547kpfifFe4wdFqk7GuyXgXFRUU Ma5tKpegDqIETzLuJWKO1tCvlhlaeT6+3g3sN0TwFScllTkWFFDc02A2V26U1bTjVibJ t62g== 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=6br7n78pq5/RQvdP/HX1IT/EAJ79ReExaMx4vcs66GE=; b=f2n2NSi+4uCAIG5UVdjxg2ciEPkaIvItIYmdkBXadI613jDqDNuJ1oqZZ7jio5+Htk 7HX1fX0Q8REDEkT+uaz72FoYhJtYhuf1O45RFRKVzFRsGZiBjRGb2/i9KmHqo+BAE+u7 dx8zYUKcElQR/LmLj5qVw9wnlGTQxgnUaBSC3wnzT4FwYFWpVMbyLhqFdwwsxEYu8E82 k0XUsyyaf1qWPK2ddCBBzmZD9xaaRk8wVkF4XPa+qR3WOEWCrk516TM8BA3jbDq1SIM4 R1EkPwQdZGmBCHeq6hXirsx4PU8x6lpdNh5vUbVKBHSJfmb3OBT+l9kYxCfFX481RKfV PTNw== X-Gm-Message-State: ACrzQf0MILF3c9yWj8LdEzcZFMAW5lmO5Xdl17aBpgHYD60RuxW4xxAt m4hmaW2wJyLad0fHisuP5wfggh/Lor0/iQ== X-Google-Smtp-Source: AMsMyM6C06d2AGlAfTj3wWq2HK34op6PR1yZ7jYKs3JFq3SXuMwD8WEHTYC1bVEsHpUWiRN7fn/hhA== X-Received: by 2002:a5d:6c6b:0:b0:225:dde:ab40 with SMTP id r11-20020a5d6c6b000000b002250ddeab40mr3394490wrz.690.1665753539070; Fri, 14 Oct 2022 06:18:59 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:46 +0100 Message-Id: <20221014131846.27169-11-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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..6a3eebf4fac7 --- /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 heavey CPU loading. + "return_newest_frames": false + } +} \ No newline at end of file