{"id":17598,"url":"https://patchwork.libcamera.org/api/patches/17598/?format=json","web_url":"https://patchwork.libcamera.org/patch/17598/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221014131846.27169-3-naush@raspberrypi.com>","date":"2022-10-14T13:18:38","name":"[libcamera-devel,v1,02/10] pipeline: raspberrypi: Add a pipeline config structure","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"17eac57f54ceaa210d9c30bb44bfba34fad98563","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17598/mbox/","series":[{"id":3555,"url":"https://patchwork.libcamera.org/api/series/3555/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3555","date":"2022-10-14T13:18:37","name":"Raspberry Pi: Platform configuration and buffer allocation improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/3555/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17598/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17598/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D1895C3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Oct 2022 13:18:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BAE4162DCA;\n\tFri, 14 Oct 2022 15:18:57 +0200 (CEST)","from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C429F62D8E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Oct 2022 15:18:53 +0200 (CEST)","by mail-wm1-x334.google.com with SMTP id\n\tfn7-20020a05600c688700b003b4fb113b86so3519279wmb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Oct 2022 06:18:53 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tg17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.51\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 14 Oct 2022 06:18:52 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665753537;\n\tbh=goFAaoDI8o03/gfiSute0UE3zr84ty9OOkq2eNc+11E=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=s3gYPMxaxU50zqMXZCTjCgEaUX0i1npvQLvXdlhXLV85mToefaN2pflodUaAIaN5T\n\tzJ8GU7vYH1eOoe6qEg/t4iuuogz0+oxHMHbH2qgs5x0cWEe3TM25fL2tBZAKrbaRJv\n\tGUL5s+zDdNyvFk2j/C4+SLLekWUnfF5TEJqXGHw3jqzvUecMNGLYINxDui7hZ/o6FK\n\tzILym0bPzFxXiLgCETiHqERaLL5kn40qXoSvr+AWTJ9xdIKsTkeHBHh6Wmhk4p4uU3\n\tmf3w8ik6tZ52izcPWQ/ruyUXMNH3jjiasPtt60mxH3aPjxu6uETr9VCGPt2hMJYx+O\n\tqyfjgRIYarfuQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=e/GW87CqgWqh4eKNVRigDH08aPTFQ6MgXDRPJsXtl+8=;\n\tb=RJVk8DxQsYoV1kNYOxQqH+bNtuUoOpPczpEKGqv6HMpXDx1WVLxqdqUKQkxXMrnC7b\n\t3Y9WNZ3CcxvS4wLuUTJLSP3CdCrCV6joAUWwVFRY7xq9R0x3DgBn1qZTsRZp5ZF/tDTi\n\tbJI/K4oKQ0ptPTOxQAulQknBF0vLfAs9EKRiyKoqoQiL6dS6nwnjkzoe7wwHpJAXa9cH\n\tui+FcEbUti2mp6goTVtQoEEfA+/8s2SrEj1ZAqR+4WTLEDwYn5adZ2homk9ci+6tz77j\n\tlpRk8V3KkkwpeZ3b+6Dln/83UGre4NvsDunRwrZwX63E65XMHOhCAQwOr3XbT+LNeMWm\n\tJRvQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"RJVk8DxQ\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=e/GW87CqgWqh4eKNVRigDH08aPTFQ6MgXDRPJsXtl+8=;\n\tb=P8HPqToPkkBzVbBM4mNVxVE0CXvsvFcrCMkGZagv85WtuBitR3fEP8yaYJfEWXC/Iq\n\t3BXz1HGPHPUJUs4ndS2BM1i9bUnExrl7USdTF19w4/r0y9+Q4Hl7jGyPajHfdBlDA9sO\n\t0assMwtPLJiO4x7AFFjPGdIp8apBNx5l+xGgjD3INOs2ljnHtmXZ9TgYccUqqfccGiIl\n\tkvbrkxg7CRY78oJ9gMNzlVSZa0oo5Eg2zZJNj/1iV/tX8Ler4wfUz5BN0uiWEU6ZJ3c+\n\tJvcsrx+8R/UhIYFgjqcErujSf3B+M7tFXJeHyfmjyj8vXy2//7HJoqg46RSlpNeSXKBJ\n\tDODg==","X-Gm-Message-State":"ACrzQf0l9SxjDJ11EI6Oh13wb3/+PB1ltXRnVycDDjGYuQCmlbSf1iT+\n\tZULWtXnNjIiXlJHN/x1Q0FrGKPO/g6NZCw==","X-Google-Smtp-Source":"AMsMyM7193NQTN8PM0BYQTCUGNy/WyFslE9SFPG2tW+C6CUVzkB6AEfgZ35GicjF9KSQtOJYrHPnug==","X-Received":"by 2002:a05:600c:4fcf:b0:3c6:cdb9:b68f with SMTP id\n\to15-20020a05600c4fcf00b003c6cdb9b68fmr10621950wmq.73.1665753533147; \n\tFri, 14 Oct 2022 06:18:53 -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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 02/10] pipeline: raspberrypi: Add a\n\tpipeline config structure","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a configuration structure to store platform specific parameters used by\nthe pipeline handler. Currently, these only store Unicam buffer counts,\nreplacing the hardcoded static values in the source code.\n\nIn subsequent commits, more parameters will be added to the configuration\nstructure, and parameters will be read in through a config file.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 43 ++++++++++++++++---\n 1 file changed, 36 insertions(+), 7 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex d366a8bec007..7d1e454cddcd 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -294,6 +294,13 @@ public:\n \t/* Have internal buffers been allocated? */\n \tbool buffersAllocated_;\n \n+\tstruct Config {\n+\t\tunsigned int minUnicamBuffers;\n+\t\tunsigned int minTotalUnicamBuffers;\n+\t};\n+\n+\tConfig config_;\n+\n private:\n \tvoid checkRequestCompleted();\n \tvoid fillRequestMetadata(const ControlList &bufferControls,\n@@ -343,6 +350,7 @@ private:\n \t}\n \n \tint registerCamera(MediaDevice *unicam, MediaDevice *isp, MediaEntity *sensorEntity);\n+\tint configurePipelineHandler(RPiCameraData *data);\n \tint queueAllBuffers(Camera *camera);\n \tint prepareBuffers(Camera *camera);\n \tvoid mapBuffers(Camera *camera, const RPi::BufferMap &buffers, unsigned int mask);\n@@ -1368,6 +1376,12 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n \tstreams.insert(&data->isp_[Isp::Output0]);\n \tstreams.insert(&data->isp_[Isp::Output1]);\n \n+\tint ret = configurePipelineHandler(data.get());\n+\tif (ret) {\n+\t\tLOG(RPI, Error) << \"Unable to configure the pipeline handler!\";\n+\t\treturn ret;\n+\t}\n+\n \t/* Create and register the camera. */\n \tconst std::string &id = data->sensor_->id();\n \tstd::shared_ptr<Camera> camera =\n@@ -1380,6 +1394,18 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me\n \treturn 0;\n }\n \n+int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data)\n+{\n+\tRPiCameraData::Config &config = data->config_;\n+\n+\tconfig = {\n+\t\t.minUnicamBuffers = 2,\n+\t\t.minTotalUnicamBuffers = 4,\n+\t};\n+\n+\treturn 0;\n+}\n+\n int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n@@ -1430,25 +1456,28 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \tfor (auto const stream : data->streams_) {\n \t\tunsigned int numBuffers;\n \t\t/*\n-\t\t * For Unicam, allocate a minimum of 4 buffers as we want\n-\t\t * to avoid any frame drops.\n+\t\t * For Unicam, allocate a minimum number of buffers for internal\n+\t\t * use as we want to avoid any frame drops.\n \t\t */\n-\t\tconstexpr unsigned int minBuffers = 4;\n+\t\tconst unsigned int minBuffers = data->config_.minTotalUnicamBuffers;\n \t\tif (stream == &data->unicam_[Unicam::Image]) {\n \t\t\t/*\n \t\t\t * If an application has configured a RAW stream, allocate\n \t\t\t * additional buffers to make up the minimum, but ensure\n-\t\t\t * we have at least 2 sets of internal buffers to use to\n-\t\t\t * minimise frame drops.\n+\t\t\t * we have at least minUnicamBuffers sets of internal\n+\t\t\t * buffers to use to minimise frame drops.\n \t\t\t */\n-\t\t\tnumBuffers = std::max<int>(2, minBuffers - numRawBuffers);\n+\t\t\tnumBuffers = std::max<int>(data->config_.minUnicamBuffers,\n+\t\t\t\t\t\t   minBuffers - numRawBuffers);\n \t\t} else if (stream == &data->isp_[Isp::Input]) {\n \t\t\t/*\n \t\t\t * ISP input buffers are imported from Unicam, so follow\n \t\t\t * similar logic as above to count all the RAW buffers\n \t\t\t * available.\n \t\t\t */\n-\t\t\tnumBuffers = numRawBuffers + std::max<int>(2, minBuffers - numRawBuffers);\n+\t\t\tnumBuffers = numRawBuffers +\n+\t\t\t\t     std::max<int>(data->config_.minUnicamBuffers,\n+\t\t\t\t\t\t   minBuffers - numRawBuffers);\n \n \t\t} else if (stream == &data->unicam_[Unicam::Embedded]) {\n \t\t\t/*\n","prefixes":["libcamera-devel","v1","02/10"]}