From patchwork Tue Nov 29 13:45:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17909 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 94C55C3286 for ; Tue, 29 Nov 2022 13:45:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 564B163348; Tue, 29 Nov 2022 14:45:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729543; bh=OpGSWEhXix31IAek7o7Hhe3Prmyd2LN6h4IiThhE2Vo=; 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=SU4UpU/vmshwsHLhMzAzjZOU1zgb/VRSnHuSmfTxl8vnVEKYA5hAF1R0s3PhyTvts gosVjbaE8Fxr2VvV4X7pH5nXztirO1r90De4wuBvD+e6orLZ4UPU92Uz72YUNgrX8y 3b+1b0fFP/HE8YrAFtLRcjh6ECGs8Kqd8syeo3uQEGYB2kIL5dqm/6TCsbZOgVElR3 exgnoIx65JqAW2QpUZp+qYBp0ED2x3loAVzpNzi+4ikfoeTP015L3giJ2BDoKU67uu kq6Ffvg78JtPPRcF0I0bcSc5qwXhbvkrjxvJX9SSBoRqgGxamERhm49Ha63JW6yeUJ ZiIIDj90oHxUg== Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E1D3263343 for ; Tue, 29 Nov 2022 14:45:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EEFCo+e+"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id 83-20020a1c0256000000b003d0683389e1so873842wmc.4 for ; Tue, 29 Nov 2022 05:45:39 -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=ciBbWTK2dRMSlcTDs0GHUazmwee/kR44mG6SsNS5Crc=; b=EEFCo+e+vVBysbgYdj7qNWmSACjXIQmHzDVubVTJXpOS+jj8cagdntetcxzwDZ9Q0f gLoS8xT0OPicBi8jq1BSHyhFA4kswYg0Ug6OZzjaMN5yxF442ePXFT5rkxo10x9/IW4E IEVvRu42Oa6x2J5ii9iUm4lGXn9SL6I5MXFEW3Jbu6IOI4h0Q9aS46O+3KWOHFsf4WkA VOfiR7qYB3sTjcUDuI5gyTNm8eOPWvcIOkzMEKqbFlipe6MiOkE3fcXW1s5amju44NTR yi2mA/PBgc7GvNqv/aT75tIFllCtxZyOhmadvi3vX4rikpP3TgPF8RAzPEkSNxuQSnq3 Djjw== 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=ciBbWTK2dRMSlcTDs0GHUazmwee/kR44mG6SsNS5Crc=; b=v6cKmdtgyXb5d2NhzSiXkMO/nD3SKiyCw95gVV8M6vJEzRTVbXduiea8HffTuL4eVp iTalxNXXwVd+vX2pCwX8ZI/R7OegzUtBF0GzzpOv090/251Fzq8keZ+gIIEpnA0azt/n sZ9emrXsWGDE5voi2j0p6ZLVOwGafoqgmzFbRrMSK6cMuPWmiqIN2QvfHhUcvPFDlv4D XHOa24eyqRsTk5hBB9vcdzLziA2nDlYTb17Br5HNcCwZWF4id13TELAfyfFcLRRC6s9L C0jZ6wj5eYXXmPleD1ZPuyMbx2rFW8z7rMmPbPRd/isc3y6FJRD58jjTuj6+RLBoxFg4 fuoQ== X-Gm-Message-State: ANoB5plamJfn9w2Qfnn1RZ5/Tv/+WIKDlTnKoimPKAjMAVjvbrj5KCP3 RBhfyPY/eYj1bwAyv8pk8yXrLm28AWFAZg== X-Google-Smtp-Source: AA0mqf6xtwuC1tt4i6GiM8fxLsP5hzltNsO/jcSYOLQI/ekL6dFzAAl0QPw3lXVsn7UUhWyV+r05AA== X-Received: by 2002:a05:600c:6023:b0:3cf:6c05:b4d5 with SMTP id az35-20020a05600c602300b003cf6c05b4d5mr27475877wmb.120.1669729539136; Tue, 29 Nov 2022 05:45:39 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:38 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:26 +0000 Message-Id: <20221129134534.2933-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0e0b71945640..4486d31ea78d 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -294,6 +294,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 steram. + */ + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -346,6 +361,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); @@ -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 = 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 = @@ -1389,6 +1411,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); @@ -1439,25 +1473,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]) { /*