From patchwork Fri Oct 14 13:18:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17598 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 D1895C3285 for ; Fri, 14 Oct 2022 13:18:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BAE4162DCA; Fri, 14 Oct 2022 15:18:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753537; bh=goFAaoDI8o03/gfiSute0UE3zr84ty9OOkq2eNc+11E=; 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=s3gYPMxaxU50zqMXZCTjCgEaUX0i1npvQLvXdlhXLV85mToefaN2pflodUaAIaN5T zJ8GU7vYH1eOoe6qEg/t4iuuogz0+oxHMHbH2qgs5x0cWEe3TM25fL2tBZAKrbaRJv GUL5s+zDdNyvFk2j/C4+SLLekWUnfF5TEJqXGHw3jqzvUecMNGLYINxDui7hZ/o6FK zILym0bPzFxXiLgCETiHqERaLL5kn40qXoSvr+AWTJ9xdIKsTkeHBHh6Wmhk4p4uU3 mf3w8ik6tZ52izcPWQ/ruyUXMNH3jjiasPtt60mxH3aPjxu6uETr9VCGPt2hMJYx+O qyfjgRIYarfuQ== 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 C429F62D8E for ; Fri, 14 Oct 2022 15:18:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="RJVk8DxQ"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so3519279wmb.0 for ; Fri, 14 Oct 2022 06:18:53 -0700 (PDT) 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=e/GW87CqgWqh4eKNVRigDH08aPTFQ6MgXDRPJsXtl+8=; b=RJVk8DxQsYoV1kNYOxQqH+bNtuUoOpPczpEKGqv6HMpXDx1WVLxqdqUKQkxXMrnC7b 3Y9WNZ3CcxvS4wLuUTJLSP3CdCrCV6joAUWwVFRY7xq9R0x3DgBn1qZTsRZp5ZF/tDTi bJI/K4oKQ0ptPTOxQAulQknBF0vLfAs9EKRiyKoqoQiL6dS6nwnjkzoe7wwHpJAXa9cH ui+FcEbUti2mp6goTVtQoEEfA+/8s2SrEj1ZAqR+4WTLEDwYn5adZ2homk9ci+6tz77j lpRk8V3KkkwpeZ3b+6Dln/83UGre4NvsDunRwrZwX63E65XMHOhCAQwOr3XbT+LNeMWm JRvQ== 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=e/GW87CqgWqh4eKNVRigDH08aPTFQ6MgXDRPJsXtl+8=; b=P8HPqToPkkBzVbBM4mNVxVE0CXvsvFcrCMkGZagv85WtuBitR3fEP8yaYJfEWXC/Iq 3BXz1HGPHPUJUs4ndS2BM1i9bUnExrl7USdTF19w4/r0y9+Q4Hl7jGyPajHfdBlDA9sO 0assMwtPLJiO4x7AFFjPGdIp8apBNx5l+xGgjD3INOs2ljnHtmXZ9TgYccUqqfccGiIl kvbrkxg7CRY78oJ9gMNzlVSZa0oo5Eg2zZJNj/1iV/tX8Ler4wfUz5BN0uiWEU6ZJ3c+ Jvcsrx+8R/UhIYFgjqcErujSf3B+M7tFXJeHyfmjyj8vXy2//7HJoqg46RSlpNeSXKBJ DODg== X-Gm-Message-State: ACrzQf0l9SxjDJ11EI6Oh13wb3/+PB1ltXRnVycDDjGYuQCmlbSf1iT+ ZULWtXnNjIiXlJHN/x1Q0FrGKPO/g6NZCw== X-Google-Smtp-Source: AMsMyM7193NQTN8PM0BYQTCUGNy/WyFslE9SFPG2tW+C6CUVzkB6AEfgZ35GicjF9KSQtOJYrHPnug== X-Received: by 2002:a05:600c:4fcf:b0:3c6:cdb9:b68f with SMTP id o15-20020a05600c4fcf00b003c6cdb9b68fmr10621950wmq.73.1665753533147; Fri, 14 Oct 2022 06:18:53 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 14 Oct 2022 14:18:38 +0100 Message-Id: <20221014131846.27169-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221014131846.27169-1-naush@raspberrypi.com> References: <20221014131846.27169-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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 | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d366a8bec007..7d1e454cddcd 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -294,6 +294,13 @@ public: /* Have internal buffers been allocated? */ bool buffersAllocated_; + struct Config { + unsigned int minUnicamBuffers; + unsigned int minTotalUnicamBuffers; + }; + + Config config_; + private: void checkRequestCompleted(); void fillRequestMetadata(const ControlList &bufferControls, @@ -343,6 +350,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); @@ -1368,6 +1376,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 = @@ -1380,6 +1394,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); @@ -1430,25 +1456,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]) { /*