From patchwork Tue Dec 6 13:54:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17946 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1FD84C3284 for ; Tue, 6 Dec 2022 13:55:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B95A76334D; Tue, 6 Dec 2022 14:55:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334911; bh=bvVkHJiRMJT6sy5clbtelAObI9I7JqaXleneN4SN/4M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=CGXcjuwirnwjwOMBfkmkv5znO1zWtb9zHoTMLwgwAH44BDykc/rgLnLue2BLmvkn8 NW6jYPL+83aTRw+mlBHE8E9rNZ/rVmEYK1WMxNQQFrSoMJyscDAr8oOAD0oqOl6GEu lvnsZXHqEiy2/lWeRb+AOXEGByDwFMSjxhbI+Ucj8kRPf38n2wtmNCZ9gbSQvmH/Mt KJAFgVyIchHo0qneUExh93h8yLZFQ4ww2KwCjHVra88b/tdKiQZwepNmt9wTOBiPpJ XnrK2BCb5ApH2A95qRtdz9qfudzS6iW2kT69E92EHWva9Vj/FSUvc5wltygs50Uj14 KN68+Pj/IBxJw== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6173563331 for ; Tue, 6 Dec 2022 14:55:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gSRksd6B"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id f13-20020a1cc90d000000b003d08c4cf679so8874745wmb.5 for ; Tue, 06 Dec 2022 05:55:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zdIqKZFO5XnrvS7lzwMoLcIDnFJDKdJhRwo2YCjQSZo=; b=gSRksd6BkX1wJd325ElWc8YAFNdbgmjgUx/SfiCgLu0ztz5w1uwG77daCZ0qGxPzDT 2FO4Qr2sLMmz3v3syNX34Ue6O09bVV3kMAcrSoAZtmsQ2zOBPQRm6DN4vvIvj4PRZyfU gGLR7IX0CF06UsWl9+dcd+A5OTgSMfxmWx+TRhocOK+221IPNXxOR//CG8B7W+YYH0/b aQ3aPtGCXq6x0zNCzUjRQVkrpQCid9klrpAHQIRR/NCkz3vchY8HOdQyqmwdA1RkK8WG Lw1Gq9IvXyuWKK+dNedBUE8KLg0+xRV4ka05WAr3NWAZPX+HhzbSmHEz2U9bcBXvwn7M lrkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zdIqKZFO5XnrvS7lzwMoLcIDnFJDKdJhRwo2YCjQSZo=; b=Y78pPrZleJz6SRuYaoKA43XovZTJ5D5WygEK+lHxl0wajAnNArJtAI5DSqfZjRLX9U CvbFtth18aL7if7nd1hoKVh3C5HVlArgYQZWILC5ODVcBJcwEE5WlMwNRaIGBQQYo3zM 2/UVqr53eosaFE0l4NIQ0Yku/WFMCGxeeL9WtcSlGcZfgQk4DvBXNJQ32jqlhjjjHnJq ddBZEk+0wQ/AO5PTt5MmTlti2hau9ax6NVmeW6mwXAEG7UdrQD0ZvAn3vQ90iuow9kxD hAsQu/+bNOq0T8/QTE98OXoKAVRdl27+lhDkaspAWtGOMjNcjdsmwSZwwRGApioBAwVa aEYw== X-Gm-Message-State: ANoB5pkeFAqylPQ8/25Y075joQINkQm5YaSqURf/Dtx+YJgV063vT7I5 qo/A7KtTXDnqkQVwqWF+RXfzft1bi72h35nm X-Google-Smtp-Source: AA0mqf7mswJg4oTAjcomSEwenScxiSaXN45hXidJUXakU348HfsMuyu2n6vxgBm6uOeUY0WxyTe8eQ== X-Received: by 2002:a05:600c:1ca1:b0:3d0:a68b:f7b9 with SMTP id k33-20020a05600c1ca100b003d0a68bf7b9mr9309789wms.87.1670334907425; Tue, 06 Dec 2022 05:55:07 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:06 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:49 +0000 Message-Id: <20221206135459.25521-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 03/13] pipeline: raspberrypi: Add a pipeline config structure X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a configuration structure to store platform specific parameters used by the pipeline handler. Currently, these only store Unicam buffer counts, replacing the hardcoded static values in the source code. In subsequent commits, more parameters will be added to the configuration structure, and parameters will be read in through a config file. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 49 ++++++++++++++++--- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0e0b71945640..f6388d63416b 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -199,6 +199,7 @@ public: int loadIPA(ipa::RPi::IPAInitResult *result); int configureIPA(const CameraConfiguration *config, ipa::RPi::IPAConfigResult *result); + int configurePipeline(); void enumerateVideoDevices(MediaLink *link); @@ -294,6 +295,21 @@ public: /* Have internal buffers been allocated? */ bool buffersAllocated_; + struct Config { + /* + * The minimum number of internal buffers to be allocated for + * the Unicam Image stream. + */ + unsigned int minUnicamBuffers; + /* + * The minimum total (internal + external) buffer count used for + * the Unicam Image stream. + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -1377,6 +1393,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me streams.insert(&data->isp_[Isp::Output0]); streams.insert(&data->isp_[Isp::Output1]); + int ret = data->configurePipeline(); + if (ret) { + LOG(RPI, Error) << "Unable to load pipeline handler configuration"; + return ret; + } + /* Create and register the camera. */ const std::string &id = data->sensor_->id(); std::shared_ptr camera = @@ -1439,25 +1461,28 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) for (auto const stream : data->streams_) { unsigned int numBuffers; /* - * For Unicam, allocate a minimum of 4 buffers as we want - * to avoid any frame drops. + * For Unicam, allocate a minimum number of buffers for internal + * use as we want to avoid any frame drops. */ - constexpr unsigned int minBuffers = 4; + const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate * additional buffers to make up the minimum, but ensure - * we have at least 2 sets of internal buffers to use to - * minimise frame drops. + * we have at least minUnicamBuffers of internal buffers + * to use to minimise frame drops. */ - numBuffers = std::max(2, minBuffers - numRawBuffers); + numBuffers = std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow * similar logic as above to count all the RAW buffers * available. */ - numBuffers = numRawBuffers + std::max(2, minBuffers - numRawBuffers); + numBuffers = numRawBuffers + + std::max(data->config_.minUnicamBuffers, + minBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* @@ -1630,6 +1655,16 @@ int RPiCameraData::configureIPA(const CameraConfiguration *config, ipa::RPi::IPA return 0; } +int RPiCameraData::configurePipeline() +{ + config_ = { + .minUnicamBuffers = 2, + .minTotalUnicamBuffers = 4, + }; + + return 0; +} + /* * enumerateVideoDevices() iterates over the Media Controller topology, starting * at the sensor and finishing at Unicam. For each sensor, RPiCameraData stores