From patchwork Fri Dec 9 09:00: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: 17967 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 CA265C3284 for ; Fri, 9 Dec 2022 09:01:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 42EAB63359; Fri, 9 Dec 2022 10:01:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576494; 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=ddnXIX5t/MfnzWjcwbSs0rrE6YTW0+Cy5UBDzzRP0LaSREKFmX81toK2b8Lor/Wey fMUUeN7k4yARUMF4bXIalhOx4He3zE5f3UnV6a1kI0SeX5em7C9o3wUMWNEvnMNg6G K8zO8a2BTwoJSlThTzms8M0/7Wo8U0j7tx6H8/qLuEXEWPvksQt8NBxQO92LixdZ8X nkDQGeAD5eSmJum011g39Ezz3qSEr1X8lbM8ABeiuldMRLLOsSrMRwJd4LCaASFdV0 RhFrs1Fx1u970LzXD65t8jvB3NhGihJDwoPVW1BomTwkEbbKU47oGUlmTI7Ov7L/rD OhdSTZPnuWc7w== 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 4CB1063354 for ; Fri, 9 Dec 2022 10:01:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="r39S8mml"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so5275995wma.1 for ; Fri, 09 Dec 2022 01:01:31 -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=r39S8mmlRUgKRTOIJVAPHd/sDSbc/whV+N0tC6dj+hcUelaz2bvMAjGCaKFOBM8L2x JIwOkzYutnoofudStvpm8OHrrt+m4d7gRc8lQcvcGR8AahwQ5Vj0m9f1Uj6WvpC8dltf B5sPeCA5+fr7K6oZZ6HaYBG9KbIAmoDvGw/QVQsNqqn9gUrMQfpotTubY3wglofTBiO5 PQnSBxRA8ujykFDCy4YS/s2XT/nCpktrBnuFk5g4L0+y7pahC2wAdy/bBzUgtFNJwF8J X1rkIOa8rwE3dQjpMBDdIwa8KTjyMVfbHqHSPcSmXV6IaU1cq0Ropb84/1KZ/KL9I5G7 2Wyw== 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=6UhKxnnr/yUVoXP6vwbdjKMxQiLsA+CXk6QN/LoZS7zsRo+xqscx4MZpsvt9ywdJp6 AslrY12590DSAlBN1E0sN5o75A9gUdVsDKIP+P0LaPA2GTDuJmuPcT9/XVfsJwgCJpxX gzhAM2zjaTsgmSVj2+yW71TYhbxo3iG9SZWbBpmREO9lbpWDr3nVoGQUD35C8zoelifq gz64wsvLV0jFSqXYNyjG1p+5PFEOLfFFrW3g790yPIYVRf/HZgfKCUGKuL9aglRwdJqx D5Y2gAedYmVkMlfhgByaj/7Io5RJWtEWOE/jlf5SK2/GDSBl32J2Pg043vb6iOXZdeG1 onXw== X-Gm-Message-State: ANoB5plmu7yCZhS2dnhDJDSOB11PbZPECQQs8jrjr55X1X94ZYOgKKTr qeZCW8zfZtkie+WZvicTFcMBoZk3POyDCOq3 X-Google-Smtp-Source: AA0mqf6F3x8ewWvCo7ZkelgAXgz0+3sDagsQT5cf/tZb61aySkvcuwpbBGfeGim3COYONWime86bQQ== X-Received: by 2002:a7b:c30e:0:b0:3c6:e63d:fcf6 with SMTP id k14-20020a7bc30e000000b003c6e63dfcf6mr4345931wmj.29.1670576490551; Fri, 09 Dec 2022 01:01:30 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:29 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:41 +0000 Message-Id: <20221209090050.19441-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- .../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