From patchwork Wed Jan 18 08:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18129 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 EED25C3294 for ; Wed, 18 Jan 2023 09:01:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5ABC8625F8; Wed, 18 Jan 2023 10:01:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032481; bh=DCEFzNUHEZLbcUeoR1xC2Lch1oiujuK9RPYAtZWf5Ro=; 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=yr73IGC2TtWLyemfitYoN2RLi8s0aHFsDceJOtMEebXjrgzCruRlWn7gcgogdOmO2 IuUZOrq2I1Xr7g7fuEi6F/Ss16667k23lOO03Mw6yTCG8TegzdrvPdwABEuB0+w6bE 2Hq49IqiyEkpUBecr1SzL5JpaSCXJYtL52bhF9Ctu3TynS05HKJBJXKP7w9PtbsnBS Z9TjGj4s5aIo/gaIf+KpzN8jHtteBvOT4mgPTkJaGby5vYKqbdV5G/5/vkdmmcZzBD N4Q6KpPU42U62GsfOfugeRAiJ5dSqr4u8IxLFmJoZvLUY0V1K5Tk9Chto9yeYb8ztE 1lFpwHM7sTx1A== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F90D61EFD for ; Wed, 18 Jan 2023 10:01:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Ib4QRsEx"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id b5so12018859wrn.0 for ; Wed, 18 Jan 2023 01:01:18 -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=fbgMUqKNkGfg+xlrxfdo3R2wbqR2znQt6T4Zz6boTAM=; b=Ib4QRsExtVvYhsMek2Hj2SNzfgy81L2iBLNJrfv0wKtolnQ7B1GLEabc8uD/i7qUxG kFo43GypR1RIU85E7jSzV0KtEKiNtapSkq93ciyO2we8sNb5J8mL3hMskdWw4BXnoFpU MaZXiYin6pZ2viFMtL8VKLsEbvDvNJ/ustXSZ33JoQIZTtEauGqHe7b4k+t2OjgFK/R4 YHnPPVS6zfKbhj7pIlx0TSJE/0t2Spb9Gtiv9Q2VLNWe5oHXln11940VGH6XEDr9BSoW Nvifu7PM4O1t3H4+4xrdrJkeQVwgwsNVCeeWXV1eR/D6UZQ1hiIK+NgN2ivaHKRDMtLf FVmA== 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=fbgMUqKNkGfg+xlrxfdo3R2wbqR2znQt6T4Zz6boTAM=; b=54WzArUGguk+nVfOvV841EPubGON+H0hp7SObnTBBX6KhrD0mVj/7L0NHFZF26gxX8 0vAEU81aEoRLV0ONMM2CFSX2rtGdRT/L2BUnDHNewQX7ZGR6rY/kU+RhLCF1FaU8Crpy hA+6Si+57pjzLVLSt2YuJa1Z8ZJ+UVRxoGJkT7vEMbMc9+fZFFOctFV6gd2X1Uv84nlY 8EEb3S6onprV8aZh3tNALF4cJGMhTWMwkyF0cu8JsEcxqlyc3g3xJExsKykDXoBPg4n8 BZ0qJB4rB3mNr/4Gflu4USQcp2W9TyivTk5HhnSfuA+yJ/StGRZim3YEOKTY23JeX2t+ XTkw== X-Gm-Message-State: AFqh2kon+aFUJR8JZBxVl0ikU4UO/JvWbEZ6ujzYHUgslLFHVFAUSdZ3 puiYkcQoLSZokXSx7GJF7INjFPdZX4WaqB5RUes= X-Google-Smtp-Source: AMrXdXuhGOzbAat5YEhJmVOoVx1KoKsddScs2uy6MsW22LYzv94grAw5R7MInW9w+Usuf/Y0W2sPYw== X-Received: by 2002:a5d:59c3:0:b0:2be:1535:e5b3 with SMTP id v3-20020a5d59c3000000b002be1535e5b3mr6615040wry.41.1674032477468; Wed, 18 Jan 2023 01:01:17 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:17 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:44 +0000 Message-Id: <20230118085953.7027-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 03/12] 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 | 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 8569df17976a..6bf9a669c679 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); @@ -295,6 +296,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, @@ -1378,6 +1394,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 = @@ -1440,25 +1462,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 +1656,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