From patchwork Fri Jan 27 15:43:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18203 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id A8A57C3242 for ; Fri, 27 Jan 2023 15:43:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C1F90625F5; Fri, 27 Jan 2023 16:43:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834221; bh=fjUZ2Y6M5SIvy8YqXeyirbL4bFJ8DM4NFQmHEKWK8To=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=X7E46+VC9ppAYPqYf3jxlELbXC/Os02fJVl8IW5t4s7RQbV8+L09dgWDdOy1Sa0Vw XL5GClOn/Kwwt8F9ufxsIsvXUrVchWU6/ahVZAK0IdLFjVbXp5PH97tG1+12Hj7EYz Z6AS0UotHemf7iqAuuD9DFdIOhztye564DWjDRLv1ZmUTl/vV8eJ3Ague00ghy8pCR K2HdgSY3BaHC3isFr3c+YdL+XFGfoaZVtQC7Sh/hYfouFtH4kd6mkR04/rhfCVmuHG zmuvuzIWlIU3ILyst7zLiZmR1VphRfG1m70FKuuwAuhgNtB1mGzHwP1YGO2liAeqbh 09rwS6ZUt6m+A== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F87E625E4 for ; Fri, 27 Jan 2023 16:43:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EGTO0cRc"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso3769627wmq.5 for ; Fri, 27 Jan 2023 07:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u6mC/hSCt4w6JopK/0knsJmp2imtUWG/I8MNT7rGc+E=; b=EGTO0cRcPUjRMRyx4hgo5vTiZUsf7lhz0HBtXYRvDsYZW63t8WA8UTsANzT+p5K94o R9t5TEVKe8PJ4jyaJ28qh15l2h71roVueMHl/fh7FkF7VrwHOx4UJkw7kpzByruTb49p u0Xh30ltEqp6lN7ZwDS0BB+/gWHu7gTvXDy8gfaWXFF8xo3F0Nk2qzCej1QqOTeki225 YfcTQDJuLzZ//imjmQHuKwM/FNdGsozFVjhbhIYOHLOpW+xzkbng1SQLV4qoMQq0JdOK o88IGvV+wvM2GdO6zpT/IAkiwbE5550MUNkKMheXeMFKwG3CKysCH8pBFOpu9PwMhAw6 UReg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u6mC/hSCt4w6JopK/0knsJmp2imtUWG/I8MNT7rGc+E=; b=xT+lHiTM8LvQKQCKL/MSgGoNkCATw2y2BwTt7ic1ohaoEnOwGLXEZEA9tMFBw8WpkW /+Hxv/CYBj68z61/Tvn3AR6DytnZE+kOaNozndXi4HPfjzVks3WbwCx3sHOIESlZXdJ4 8lR568Zfp59d3kxkSmGoBOaIcdMrw9AxYWrdKRXRiAnA6VDhA98kE+sTo1nSSr3/lwFE JDhYUQbS2MVQVUAYF/jEUyQaPlzHDAhXFEnHZm9y4eG7fRaFNOGwHlIfTd7tI4aNa7nd 1LD8UMp/ucuA3HP/o1gtiZawP4IHYJ003iMwc5tx55mnYq/g2/Kv2Qo9fDLpJc9EUiit JbFg== X-Gm-Message-State: AFqh2kpn3hhkWQJgDe3eV9lJ6mMsuPFNtZGPhx1KTrmXTOyai4zVSohd c/D0gDIKbN21ChP7mtpsUSxY6DKItQT9lP2p7dM= X-Google-Smtp-Source: AMrXdXtBgoJbWPIeUcATjnIW2zj23eZa5z6rSLhmXQ8VguqDxyvGZjbP4pFZRNOyjfV3SdX8r/8+Cg== X-Received: by 2002:a05:600c:1d8e:b0:3d1:fcb4:4074 with SMTP id p14-20020a05600c1d8e00b003d1fcb44074mr41551146wms.22.1674834217306; Fri, 27 Jan 2023 07:43:37 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:36 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:10 +0000 Message-Id: <20230127154322.29019-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 03/15] pipeline: raspberrypi: Add a pipeline config structure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a configuration structure to store platform specific parameters used by the pipeline handler. Currently, these only store Unicam buffer counts, replacing the hardcoded static values in the source code. In subsequent commits, more parameters will be added to the configuration structure, and parameters will be read in through a config file. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 53 ++++++++++++++++--- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8569df17976a..9e959782d310 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -199,6 +199,7 @@ public: int loadIPA(ipa::RPi::IPAInitResult *result); int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result); + int loadPipelineConfiguration(); void enumerateVideoDevices(MediaLink *link); @@ -295,6 +296,25 @@ public: /* Have internal buffers been allocated? */ bool buffersAllocated_; + struct Config { + /* + * The minimum number of internal buffers to be allocated for + * the Unicam Image stream. + */ + unsigned int minUnicamBuffers; + /* + * The minimum total (internal + external) buffer count used for + * the Unicam Image stream. + * + * Note that: + * minTotalUnicamBuffers must be >= 1, and + * minTotalUnicamBuffers >= minUnicamBuffers + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -1378,6 +1398,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me streams.insert(&data->isp_[Isp::Output0]); streams.insert(&data->isp_[Isp::Output1]); + int ret = data->loadPipelineConfiguration(); + if (ret) { + LOG(RPI, Error) << "Unable to load pipeline configuration"; + return ret; + } + /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = @@ -1440,25 +1466,28 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) for (auto const stream : data->streams_) { unsigned int numBuffers; /* - * For Unicam, allocate a minimum of 4 buffers as we want - * to avoid any frame drops. + * For Unicam, allocate a minimum number of buffers for internal + * use as we want to avoid any frame drops. */ - constexpr unsigned int minBuffers = 4; + const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate * additional buffers to make up the minimum, but ensure - * we have at least 2 sets of internal buffers to use to - * minimise frame drops. + * we have at least minUnicamBuffers of internal buffers + * to use to minimise frame drops. */ - numBuffers = std::max(2, minBuffers - numRawBuffers); + numBuffers = std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow * similar logic as above to count all the RAW buffers * available. */ - numBuffers = numRawBuffers + std::max(2, minBuffers - numRawBuffers); + numBuffers = numRawBuffers + + std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* @@ -1631,6 +1660,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA return 0; } +int RPiCameraData::loadPipelineConfiguration() +{ + config_ = { + .minUnicamBuffers = 2, + .minTotalUnicamBuffers = 4, + }; + + return 0; +} + /* * enumerateVideoDevices() iterates over the Media Controller topology, starting * at the sensor and finishing at Unicam. For each sensor, RPiCameraData stores