{"id":18131,"url":"https://patchwork.libcamera.org/api/patches/18131/?format=json","web_url":"https://patchwork.libcamera.org/patch/18131/","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":"<20230118085953.7027-6-naush@raspberrypi.com>","date":"2023-01-18T08:59:46","name":"[libcamera-devel,v5,05/12] pipeline: raspberrypi: Handle OptionalStream hints for Unicam Image","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"088317847438aa60e352964d8da30ce7bbf8d081","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/18131/mbox/","series":[{"id":3713,"url":"https://patchwork.libcamera.org/api/series/3713/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3713","date":"2023-01-18T08:59:41","name":"Raspberry Pi: Platform configuration and buffer allocation improvements","version":5,"mbox":"https://patchwork.libcamera.org/series/3713/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18131/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18131/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 4199DC3295\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Jan 2023 09:01:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 98314625FA;\n\tWed, 18 Jan 2023 10:01:22 +0100 (CET)","from mail-wr1-x434.google.com (mail-wr1-x434.google.com\n\t[IPv6:2a00:1450:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F28261EFD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Jan 2023 10:01:19 +0100 (CET)","by mail-wr1-x434.google.com with SMTP id n7so7117659wrx.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Jan 2023 01:01:19 -0800 (PST)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ti6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.18\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 18 Jan 2023 01:01:18 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674032482;\n\tbh=jhW47XycTJeJKViSSbDzQOA0ZeuaoMQvJsIW4Wz891g=;\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=qq+lbWLtaJASzBFws9XupzDV4V2NYSjJVMKqC2aELekNSm5cCMkXoHB/84cO2ywE2\n\teDEa55EwQ6J/OOgtrK49etTEmURFleGro/riRtEy61QaYO4im6QrsNb8oLnd/ZubiF\n\tOtQ4EkeUnHID0/Tg+KVgq+VUTrNDkKCx7RfMeV4isvEiVz2GBcxZX0KwRbvD4OSRFE\n\tFFzcP1xUFNoe991sLTVZqqVKYmChaBqJII22BCmDs2DCSmqQwZn/VbbN6/vdVIqxB3\n\tWQIYCvt817/DvJOXPoilcdn+LW+Te7D/CQ6KGOG7tF1gQvbhGxKqruEcP7hGS0M+mB\n\tbzj/AlRpe5Cdg==","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=MF/+iG7HIHFeXPj2IZioMbRFhVvgaszMfkZq5nsWvdw=;\n\tb=OO7hxI4Iya5vUbhk+KHdOtX1hJf3OPBlxmJjpEsB3Z5XsZxNSWyCaIeDVoi0bsjaoD\n\tNLOtTEjevAg8GAT0dmOs6koUowv5jpgBVLy627N4D2w02pRB5Y2E3HoG8xNisI56q+hi\n\tAtrZv9OQqb1FJpMPqjBMqlDT19wGIeq7uGbOCv0Lrop1PLY0xXOR5Bm6znmvz5BlJeJe\n\t9bvCnGXRfYb1S9TSyx6M2nt8HigEnfa0Pk9O2PH0FO46/6pev7r04h8Q0ZKqlPNOqfLk\n\tfzdiCme3Rh624YIYJoW/+8FoJ4Gb4i5YkKge4tzgw1YVNXn37mmt82/yLnbx2hPzYtJr\n\t4HgA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"OO7hxI4I\"; 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=MF/+iG7HIHFeXPj2IZioMbRFhVvgaszMfkZq5nsWvdw=;\n\tb=tVSs2Jo6MWqyGb+ZHoqd1Y3BDIZJ4ax9JCmyG8feQHVJc8I0l1sOcwV+99hHwTfwB7\n\tpgTi/la6cit/oNZIREv113MH10fsUY0jp1uwL8evqb6kqnjeXr5p3xpDyQMekYg4S44C\n\txmx4kqizgpfHB0gkAdxzu6iiAKFjJqZkcCyILm8kSgietnwVPAWid+gbps2pleU7ITdq\n\tOpzpA6ZxIGMWGjy2ab4YK4v1GDsJAaZLFws4ao6FduN/WSPvRoN044D64GYZ+0r5SmBZ\n\tsBYQ+Ff09VEPPKrIpm0u0J9E7v+0OE7MxwRfscg6RY4c56rmoB0Nh59ud0Vz0IJoZ2Ex\n\tjhfw==","X-Gm-Message-State":"AFqh2kqVJJEfFWpe+YjtR9uOe4oJbYwNBhW0QdbkBsisn8I3phB00CR7\n\tsKrQWOcSCgKU+JbbyVpDAKc+ui+fqcvForoFUmg=","X-Google-Smtp-Source":"AMrXdXsNSb5pPN8Ey2hLWPziQkgq56hIFDQICQrKzEGB9VhZIRsF+TCKmPMv83X17hJP3Yr+Fd9D7w==","X-Received":"by 2002:adf:e991:0:b0:2b9:1a52:4f50 with SMTP id\n\th17-20020adfe991000000b002b91a524f50mr13724505wrm.6.1674032478718; \n\tWed, 18 Jan 2023 01:01:18 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 18 Jan 2023 08:59:46 +0000","Message-Id":"<20230118085953.7027-6-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 05/12] pipeline: raspberrypi: Handle\n\tOptionalStream hints for Unicam Image","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":"Look for OptionalStream flag in the hints field of the Unicam Image\nStreamConfiguration structure. If this flag is not set, it guarantees that the\napplication will provide buffers for Unicam Image, so override the\nminUnicamBuffers and minTotalUnicamBuffers config parameters in the following\nway:\n\n- If startup drop frames are required, allocate at least 1 internal buffer.\n- If no startup drop frames are required, do not allocate any internal buffers.\n\nAll other buffer allocations remain unchanged.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 36 ++++++++++++++-----\n 1 file changed, 28 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 8d325c7a18c5..6ed4cc2c7ba7 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1448,12 +1448,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n {\n \tRPiCameraData *data = cameraData(camera);\n-\tunsigned int numRawBuffers = 0;\n+\tunsigned int minUnicamBuffers = data->config_.minUnicamBuffers,\n+\t\t     minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers,\n+\t\t     numRawBuffers = 0;\n \tint ret;\n \n \tfor (Stream *s : camera->streams()) {\n-\t\tif (isRaw(s->configuration().pixelFormat)) {\n+\t\tif (s == &data->unicam_[Unicam::Image]) {\n \t\t\tnumRawBuffers = s->configuration().bufferCount;\n+\t\t\t/*\n+\t\t\t * If the application provides a guarantees that Unicam\n+\t\t\t * image buffers will always be provided for the RAW stream\n+\t\t\t * in a Request, we need:\n+\t\t\t * - at least 1 internal Unicam buffer to handle startup frame drops,\n+\t\t\t * - no internal Unicam buffers if there are no startup frame drops.\n+\t\t\t */\n+\t\t\tif (!(s->configuration().hints &\n+\t\t\t      StreamConfiguration::Hint::OptionalStream)) {\n+\t\t\t\tif (data->dropFrameCount_) {\n+\t\t\t\t\tminUnicamBuffers = std::max(1u, minUnicamBuffers);\n+\t\t\t\t\tminTotalUnicamBuffers =\n+\t\t\t\t\t\tstd::max(minUnicamBuffers, minTotalUnicamBuffers);\n+\t\t\t\t} else {\n+\t\t\t\t\tminUnicamBuffers = 0;\n+\t\t\t\t\tminTotalUnicamBuffers = 0;\n+\t\t\t\t}\n+\t\t\t}\n+\n \t\t\tbreak;\n \t\t}\n \t}\n@@ -1465,7 +1486,6 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\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\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@@ -1473,8 +1493,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\t * we have at least minUnicamBuffers of internal buffers\n \t\t\t * to use to minimise frame drops.\n \t\t\t */\n-\t\t\tnumBuffers = std::max<int>(data->config_.minUnicamBuffers,\n-\t\t\t\t\t\t   minBuffers - numRawBuffers);\n+\t\t\tnumBuffers = std::max<int>(minUnicamBuffers,\n+\t\t\t\t\t\t   minTotalUnicamBuffers - 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@@ -1482,15 +1502,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\t * available.\n \t\t\t */\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+\t\t\t\t     std::max<int>(minUnicamBuffers,\n+\t\t\t\t\t\t   minTotalUnicamBuffers - numRawBuffers);\n \n \t\t} else if (stream == &data->unicam_[Unicam::Embedded]) {\n \t\t\t/*\n \t\t\t * Embedded data buffers are (currently) for internal use,\n \t\t\t * so allocate the minimum required to avoid frame drops.\n \t\t\t */\n-\t\t\tnumBuffers = minBuffers;\n+\t\t\tnumBuffers = data->config_.minTotalUnicamBuffers;\n \t\t} else {\n \t\t\t/*\n \t\t\t * Since the ISP runs synchronous with the IPA and requests,\n","prefixes":["libcamera-devel","v5","05/12"]}