From patchwork Fri Feb 3 09:44:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18246 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 922CFC3243 for ; Fri, 3 Feb 2023 09:44:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4AC5A625EB; Fri, 3 Feb 2023 10:44:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417470; bh=1NQfkm46gkmlgegsWn0lnrEGMhw+21+M3ZnxqhkEqek=; 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=MJMAWdoB9XlLnvxPSB8FP9fYUXe+mp/LsGmmqY0q5OFIxPYBnrp6L/TgqkMlMsGtV 0g+Gk7xSx3VnsQU7yU0gZa1oy9VXnS7D8Hq5dAWk0D7C8/olKbih9Ll4qMKLxwS/zE 9N0dH1QROEfYQO8snhiWUvFPaXiBGS9VKvHiozrXyu1ASCfMjnkcKRV7o+EgwFpoZI QQpcIjsIBU1ZlfEzkj/J06XOn0MpVEn3uG4tUBP4kPUCQp6TxBjVePXaFnrkQcKsoq F3cdTdM53FfZW6cxyhIjX6xhVhvaeEX7/NehqokCSmkZ+il9b5hsdXS75ju88xjSQy 2LOSYTSDJ8M3w== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71AA661EF4 for ; Fri, 3 Feb 2023 10:44:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="crDRBVLY"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id a2so3825606wrd.6 for ; Fri, 03 Feb 2023 01:44:28 -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=/Puf9MTPyfFZF0uns/wRRwCfjTobp9ecB2pODryenMo=; b=crDRBVLYdCn1zaQETs2AOz3gG/uoK/KQMv4pygtjKfqb3GlXa7WyidXkIXVBHiefVA E3HEI6hEDcMwWsiNr4Q0guMKbGt/n4h8733wcR1zqtGGsfS+fzxc9xnPtNoW2jO2ELuH bUSZiNmwqjIIQdXLsyFcPSCPohdSNGpJa6S5D8Vah9Dxx6E6L92eLYbC5KyvWDorvmy7 O06S1yIh4OuQW/79bXVmYCven0safP5mogvnuoSDgJ11MXPoGDGkW1E5DI6iA02/XBNu srL0JgsIoyJHmmQokhC7ZJmGhBJowvSk2HWkmQyaMsUKQT5ZmOvzeDZccfiNR7sAUos4 HJCQ== 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=/Puf9MTPyfFZF0uns/wRRwCfjTobp9ecB2pODryenMo=; b=phBqpOPt4i+AGzldmvfr+9ur5itMflgKcZTXi14OJ/7qwxRS608xTc/FE7bey97ble D+m1eEkmceyQlC/oepSbOBQfF5cmuFvJqlCWh+0m1vG2CjoChQJszS6oyAUdFadXWPRI /f3OGSiCl6/EFRtl7Qw4QOkzBVK03EX+mj7wpdzRx4fo+KVrq2jHL0LAWbS38KDDy/kl kypqYueD8TXapyrBcOdvy2cUKrsKMmIj0Go1ZLm8HBqMrmf1ZwIbtVkcTAh+8fRshDmo 8l1l1V0vT0JkJ1E4ect96zYvM3NXk/Ek6KM51YI6cqMA3mZourW+QgQIMWsSOk9DIO0N TSrA== X-Gm-Message-State: AO0yUKVQ/XbZhfa65bH1P+qrLx+C9qM/7Prv/a77aIkHbG2N1yvfG/WN +dHtO27h8cvUAzp1tkdn27Vy7YklIs67m3Zlup+YRg== X-Google-Smtp-Source: AK7set/wXMmExU+hil82JZOZ4jXdrTMad8/PT6mwOJIRj2OPp0vhbO6XixVcAmTbAd+kbrjbDpmsCA== X-Received: by 2002:adf:dc03:0:b0:2bf:f2f2:7d64 with SMTP id t3-20020adfdc03000000b002bff2f27d64mr8415689wri.33.1675417467848; Fri, 03 Feb 2023 01:44:27 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:27 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:17 +0000 Message-Id: <20230203094424.25243-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/8] libcamera: stream: Add stream hints to StreamConfiguration 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 new hints flags field in the StreamConfiguration structure to allow the application to specify certain intended behavior when driving libcamera. Pipeline handlers are expected to look at these hint flags and may optimise internal operations based on them. Currently, only one flag is listed, MandatoryStream, which the application can set to inform the pipeline handler that a buffer will always be provided on every Request for a given stream. Signed-off-by: Naushir Patuck --- include/libcamera/stream.h | 8 ++++++++ src/libcamera/stream.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h index 29235ddf0d8a..56e5a74b2aab 100644 --- a/include/libcamera/stream.h +++ b/include/libcamera/stream.h @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -51,6 +53,12 @@ struct StreamConfiguration { std::optional colorSpace; + enum class Hint { + None = 0, + MandatoryStream = (1 << 0), + }; + Flags hints; + Stream *stream() const { return stream_; } void setStream(Stream *stream) { stream_ = stream; } const StreamFormats &formats() const { return formats_; } diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 67f308157fbf..9b0e8dd548cf 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -349,6 +349,31 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) * color spaces can be supported and in what combinations. */ +/** + * \enum StreamConfiguration::Hint + * \brief List of available hint flags provided by the application for a stream + * + * \var StreamConfiguration::Hint::None + * No hints for this stream. + * \var StreamConfiguration::Hint::MandatoryStream + * Informs the pipeline handler that the application will always provide a + * buffer for the configured stream in every Request. This may ensure the + * pipeline handler does not need any additional stream buffer allocations for + * internal use. + */ + +/** + * \var StreamConfiguration::hints + * \brief Application provided StreamConfiguration::Hint flags for specific + * stream behavior + * + * Provides hints from the application to the pipeline handlers on how it + * intends on handling a given configured stream. These hints may alter the + * behavior of the pipeline handlers, for example, by not allocating additional + * buffers for internal use if an application guarantees buffers will be + * provided in every Request for a stream. + */ + /** * \fn StreamConfiguration::stream() * \brief Retrieve the stream associated with the configuration From patchwork Fri Feb 3 09:44:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18247 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 DA0B7C323E for ; Fri, 3 Feb 2023 09:44:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D769A625EA; Fri, 3 Feb 2023 10:44:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417471; bh=WsKEAbgG9IiE5tFzEqPV+5BgzO8xIyNo52sfMFQqOyo=; 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=iSaMcTGfwx4Gommcjq+rij+YagSCelrPS88uJYVaNIiVRlhdgCHGVv0C1USyKzml+ U+s0EYc+CpllvawJybYyeQXOOOefftOR+Srr4aEfLODU9wuv24oVMRoaku0v1NUQ6G rGUI2BUQ8bGm9p2AmCpIp6snP6UPOVYVFRqXveFWEMiRtD1Y1/VF1YtSpIHRE4jRk1 UlLKYZZ8+PpMA3WDx6OwqH3LCTIesI5mg6S++Z/TttSrwpiGChvdnHZ7nMbDRzHHay 8deJ1Ts3LiKwj5MP2HUVbhxSR5XqNMG+C20i0lEo9CihTPZVVOfiem5N8+Lgr2eDKO gXTtWB3rxD7sQ== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BE38625E8 for ; Fri, 3 Feb 2023 10:44:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cU6m2sJf"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id d14so4088636wrr.9 for ; Fri, 03 Feb 2023 01:44:29 -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=xsXDGZ71N+GwEVQMLu8d8M3IAh85egvxBwrqphOJo0g=; b=cU6m2sJfTCx45df1eJFGTyXv9Ua+NnNCv5PsX+amdOCtiwK7pnlkhU17W9XcAv4Tp2 yVDfDnOtunuAge6Wpm4+lwcEhKLDrgDq4W9GP+2QSweSqo9b64AFdynv2/HIcY7T+Y6j n9sLsiIOVdHJKYLhpb+4GSvLEVwKGRgSs3D9l/pApQwEfvXcnL+R3Si2k0t8jO/qLgJR mSBtzsenepFZB5waLX5y0yZxqDS/WfTnfj9wfdNVYAj2hfG9gsJbFGbZdEcn+MIGMJKG C8MbC36q9c50zRF3vGhK0o8b9ALxkO1Hn5sKe1xaxt4WZ7ilQn0D9wQaJE+8eLrbH3Gn +2Bg== 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=xsXDGZ71N+GwEVQMLu8d8M3IAh85egvxBwrqphOJo0g=; b=0LBEXaC2ICmpMEFKZn0k5hVPRcZ53ARXOuQiOOTJgJu/0sHN6Oz9ZJNPlNJi3+aqLK XBdfRZUg8tyX5+ulFSUv3bx5yuSU9H88sI9v36bqavJfcvhgnxle7QiaoMbZkHJkQS7f rR+7r73CPKh7OMgIumrRRqcAHSxcq0QwRxCycvr0aWQcfKPViI3/uOhP+Giy3f3rrT5i ow3DZXwx/w9I6RvYRxPyIU0toAV/JWlItpuV7JnyHRs7VnFClKPlNk0nGYaeJJoXoRhM HOYLhhSi9E4ISLs5lKmNDrw/X2q/1evRA3NONFRmcZZvRc3Scnug+r/fjX6FZpnRBAy+ D7mw== X-Gm-Message-State: AO0yUKUjyDBy1XDSS9bT94EgHozaHxCCylgF3xmHL45BKZC5k7HjHssd wMR1hCg7nMGUBBDtrvLYog+OvPyS5u3fOPa+v1Na4A== X-Google-Smtp-Source: AK7set9qm4FtxfCgwu6JeJaCTvTCOQV1OwSfHuj70zaAqhYxNjyD4f7wqmm4gQZtZZUeG1mwobrNwg== X-Received: by 2002:a5d:6d05:0:b0:2bf:dd84:adf6 with SMTP id e5-20020a5d6d05000000b002bfdd84adf6mr10270074wrq.60.1675417468543; Fri, 03 Feb 2023 01:44:28 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:28 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:18 +0000 Message-Id: <20230203094424.25243-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/8] pipeline: raspberrypi: Handle MandatoryStream hints for Unicam Image 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" Look for MandatoryStream flag in the hints field of the Unicam Image StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for Unicam Image, so override the minUnicamBuffers and minTotalUnicamBuffers config parameters in the following way: - If startup drop frames are required, allocate at least 1 internal buffer. - If no startup drop frames are required, do not allocate any internal buffers. All other buffer allocations remain unchanged. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d752911ddfff..7d786fe839f7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1520,12 +1520,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) int PipelineHandlerRPi::prepareBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); + unsigned int minUnicamBuffers = data->config_.minUnicamBuffers; + unsigned int minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers; unsigned int numRawBuffers = 0; int ret; for (Stream *s : camera->streams()) { - if (isRaw(s->configuration().pixelFormat)) { + if (s == &data->unicam_[Unicam::Image]) { numRawBuffers = s->configuration().bufferCount; + /* + * If the application provides a guarantees that Unicam + * image buffers will always be provided for the RAW stream + * in a Request, we need: + * - at least 1 internal Unicam buffer to handle startup frame drops, + * - no internal Unicam buffers if there are no startup frame drops. + */ + if (s->configuration().hints & + StreamConfiguration::Hint::MandatoryStream) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1537,7 +1558,6 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * For Unicam, allocate a minimum number of buffers for internal * use as we want to avoid any frame drops. */ - const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate @@ -1545,8 +1565,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * we have at least minUnicamBuffers of internal buffers * to use to minimise frame drops. */ - numBuffers = std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + numBuffers = std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow @@ -1554,15 +1574,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * available. */ numBuffers = numRawBuffers + - std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* * Embedded data buffers are (currently) for internal use, * so allocate the minimum required to avoid frame drops. */ - numBuffers = minBuffers; + numBuffers = data->config_.minTotalUnicamBuffers; } else { /* * Since the ISP runs synchronous with the IPA and requests, From patchwork Fri Feb 3 09:44:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18248 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 EA3A4C3243 for ; Fri, 3 Feb 2023 09:44:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 953A0625F0; Fri, 3 Feb 2023 10:44:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417473; bh=q0n+bsQd9y0IXZxkCQPhfDQxPM/SW3RNIbYmUmff3aw=; 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=AIzwJsfHjPocDcXpkbDT/t05e6Dqekz84nig4aCDJSNafmP4mmvAoPXYjpCoSAbbe 6lKCXILImQ98VRmRB6WfJYHDWgSbJ1cpAtj1V0DJ+44ITT0NvYunkKO2Ntvb/aKa0P FIbhESwq5O7cAnDxzeTyhdgYL+iEmOgPmWSYN+0GxM88oEwTCejjbn36O3Q/ukso3U 5GU35yGoQv/7SwR0P72SNn4j/kE+8h6sphryQtUVeKXx7yjTvoQ9X8aE4LEtjGJOp6 6VFFcJFBBeOvNz4iWYtdFo3kL7fot65cjqSRh/DqC8hKFZjShtj98j9jhaXTO0gzGy f/y6N0VtHoMXQ== Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E51F625E6 for ; Fri, 3 Feb 2023 10:44:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="a6+TTmIw"; dkim-atps=neutral Received: by mail-wr1-x435.google.com with SMTP id q5so4149665wrv.0 for ; Fri, 03 Feb 2023 01:44:29 -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=n81f6GVEXqXm46yv+qRxoawmXUIHe4ldi9NYE18ruYg=; b=a6+TTmIwCSkgwpXi8MGi/y5HBLFZqkOQZg8CwuCihfS3ipmO4Scd9lTBpkJjeTJBQ0 MnUnIXxSompSvVJJutoEk9VU76nBcfo9uoUkpzlI/l2tsbHS4Fu3fEZ0d27aK68H33rS dVf24pEi1paA9E7uWRf7cGSONhYWWrMDVH2nML23iK1EPevH6emoClywrl+PRXTyjxnS e+KLXF3oQnyBcOxYJR6iWOaWQmTcPB/5NYp8LLddkTvSxOfXIEqoPBlxfIfPTurWeSQt a3nfmTKNkw7u7o8qL0x0DtUMZmbREuRBWIiyj7TxTzuZ1q/jz1wUc08SCEuusBfHdVI+ hKkg== 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=n81f6GVEXqXm46yv+qRxoawmXUIHe4ldi9NYE18ruYg=; b=m6qyePb5D0K8B/AKDQlREAnAwpwoLzM21ELZkUtQLVJhY2/dAbsA9jYbLpI2Dy9Uju U7aCgfgq1UUHg1YQLFudaYHWj/ZJtRUPFNpAurorArKU8dOmBVJRrA0MJ/uNfnnZWTJS j6/ppGvsFBihwghzvuk2jfYbLiBIaEBx1DORxYLErNUx2KAJR07HNwxSco8dw4y1oNsH BT15Isay+7FQF768a1Flq0lwVud0YBMDG6MRG2VK0Plv8SuImtUqcDRY4GEYjZllTMSx 6a9VuYntphJfR6AKr5ijtUh2tJ4/WJSWb46frKihPo1W2KHaIVIcwe9LGLC0ql53Z6rV Z8qA== X-Gm-Message-State: AO0yUKXK0C0YHc1hXlW42bEeNpbFZ69f4eBTBjFyu0OX+ye2z6vMTA+U e1ZcauebEn9FtUouE8fcr++4uEG4MYvXdGYb3+bHWQ== X-Google-Smtp-Source: AK7set/qxFvRB9WwmvTdbaoGiJ0RVJv1/yoYj85uq6n5mVkTAacIW82y4DrXAwe94FTYAdaOiE1vhQ== X-Received: by 2002:a5d:6512:0:b0:2be:5ca0:a7f9 with SMTP id x18-20020a5d6512000000b002be5ca0a7f9mr7915543wru.33.1675417469116; Fri, 03 Feb 2023 01:44:29 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:28 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:19 +0000 Message-Id: <20230203094424.25243-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/8] pipeline: raspberrypi: Handle MandatoryStream hints for ISP Output0 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" Look for MandatoryStream flag in the hints field of the ISP Output0 StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for the ISP, do not allocate any internal buffers for the device. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 7d786fe839f7..b6ed66a1cf46 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1522,7 +1522,7 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) RPiCameraData *data = cameraData(camera); unsigned int minUnicamBuffers = data->config_.minUnicamBuffers; unsigned int minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers; - unsigned int numRawBuffers = 0; + unsigned int numRawBuffers = 0, minIspBuffers = 1; int ret; for (Stream *s : camera->streams()) { @@ -1546,8 +1546,21 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) minTotalUnicamBuffers = 0; } } - - break; + } else if (s == &data->isp_[Isp::Output0]) { + /* + * Since the ISP runs synchronous with the IPA and requests, + * we only ever need a maximum of one internal buffer. Any + * buffers the application wants to hold onto will already + * be exported through PipelineHandlerRPi::exportFrameBuffers(). + * + * However, as above, if the application provides a guarantee + * that the buffer will always be provided for the ISP Output0 + * stream in a Request, we don't need any internal buffers + * allocated. + */ + if (!data->dropFrameCount_ && + s->configuration().hints & StreamConfiguration::Hint::MandatoryStream) + minIspBuffers = 0; } } @@ -1583,12 +1596,14 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * so allocate the minimum required to avoid frame drops. */ numBuffers = data->config_.minTotalUnicamBuffers; + } else if (stream == &data->isp_[Isp::Output0]) { + /* Buffer count for this is handled in the earlier loop above. */ + numBuffers = minIspBuffers; } else { /* - * Since the ISP runs synchronous with the IPA and requests, - * we only ever need one set of internal buffers. Any buffers - * the application wants to hold onto will already be exported - * through PipelineHandlerRPi::exportFrameBuffers(). + * Same reasoning as for ISP Output 0, we only ever need + * a maximum of one internal buffer for Output1 (required + * for colour denoise) and ISP statistics. */ numBuffers = 1; } From patchwork Fri Feb 3 09:44:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18249 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 5E2DCC323E for ; Fri, 3 Feb 2023 09:44:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19497625EC; Fri, 3 Feb 2023 10:44:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417474; bh=e22OhAuSZ6QaESVtJ12ytzqvo4NrIJzbJGLoYQg+cPE=; 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=Qdyoumh0N3Loe78jjRvTMeBdCxGSe7za/fUBAXMZkbuGSIr4fbtuhMNuYFOhWKBvo SUonlvn31u+A1KQp/pKobU21VIRMsLkCwxDVFYvU/ptAYkqA5o4rfIo9gGwOoOeSXa TyLbCd/a+L1RRn+tcv4zG0yIpTBHWUsH2bqpkl/VieK8wkBB6XMpdv/Pu4H3rr6rrm XaRJF95GYekbAteAPWDk/dC+X2jGxi9xxWQ1xnmo9sTnK6Sl//M/8IG9xcPb48caRV 5TO/3oqAZQeI5OjFLD24J6vYKuNTyFn42sBXoNW1a9Sve5FoCW3kutYcJiyJgNaMKP mCkEEZdOKksug== Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 659ED625E8 for ; Fri, 3 Feb 2023 10:44:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ZsuqgAtW"; dkim-atps=neutral Received: by mail-wr1-x429.google.com with SMTP id y1so4119786wru.2 for ; Fri, 03 Feb 2023 01:44:30 -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=CGZwAAnS7t1YLpDptrdLrTgq6Xa1I7+cWVR6KStCMIA=; b=ZsuqgAtW4Xsm0KdKbXJhY64IVZZJpx+MOsUxXJV5IFIwl64oWep2kIWlNPEQTe2fpS 4RHvjXJTPTHocLpLtqGMr49GJ1gtrdpr7jaaMVMZ/GEy4z1YaP8cvu3iVctqvT8eSYhf IfD83tAKlRM9m5TJcgYPAQ1Egt82eB/1+bxF7lK9LAaptMw0oLfptxn0PgOF+gkNjeyo yoMVEFqmQnOaxcW4gXi+PEUum02k92vxp8Z06nUEoVB/3ZenBVIAvEyDivJRndl9my30 4W5e1Nwo4KYg3BeSTjFXuCVezwEH8/9I/tXjqkdKUIhQI/137KAsA1Hy46lUmoNZ/LXk 1J0Q== 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=CGZwAAnS7t1YLpDptrdLrTgq6Xa1I7+cWVR6KStCMIA=; b=n7z9l4Ga/t7x1Nclumk/IlOnKACLPINYzzF5I2zkvXrSWlnic9Rgtep4Q+a/e/31ge z8Dju4WcdZCnNujeMawRwgMYR/eqZTzTF2kJFsCNHx0BFcI0r2mXBIGrZXzq38r1+tgT 31wdDZxIWeCa+6msCmxsaGpIMk+lNqoKvZa0LrU788HgdSJAJAdIvXcaCB3122EsduTu pveVHRHg7TZ33AYVaeUSK6b/2Qtfg83nt83bhssLy7k4qSjE1/KcsfqyB3nNnc7PGI9+ f8CNetvfLdx1BbZ/L6VoyLe+uBRPV9en8ycK5e5HboGu/nRr/NUc8gndrM8LECG5XGi1 AmMg== X-Gm-Message-State: AO0yUKUt6EB7lEoAPrTM9M26nhtk5wtWaKn/Mlx47QUl7fDDlEVYqA0k oQljC+hyvrUhBRDX3ypzja6WoO048mwA4SxhX4HiyQ== X-Google-Smtp-Source: AK7set8kEEqjGGc2jkZs7WeGuKpJSDSkKgR/3isVn1h3pJDHP/Pf7h+tJxRLQM9s3oqROupjp0roNA== X-Received: by 2002:a05:6000:18cd:b0:2c3:da85:ad7e with SMTP id w13-20020a05600018cd00b002c3da85ad7emr361409wrq.36.1675417469708; Fri, 03 Feb 2023 01:44:29 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:29 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:20 +0000 Message-Id: <20230203094424.25243-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 4/8] libcamera: camera: Validate MandatoryStream in queueRequest() 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 some validation in queueRequest() to ensure that a frame buffer is provided in a Request if the MandatoryStream flag has been set in the StreamConfiguration for every active stream. Signed-off-by: Naushir Patuck --- src/libcamera/camera.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index 0da167a7bc51..c0a368c1e66c 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -1146,6 +1146,18 @@ int Camera::queueRequest(Request *request) } } + for (auto const stream : d->activeStreams_) { + const StreamConfiguration &config = stream->configuration(); + FrameBuffer *buffer = request->findBuffer(stream); + + if (!buffer && config.hints & StreamConfiguration::Hint::MandatoryStream) { + LOG(Camera, Error) + << "No buffer provided for mandatory stream"; + request->_d()->reset(); + return -ENOMEM; + } + } + d->pipe_->invokeMethod(&PipelineHandler::queueRequest, ConnectionTypeQueued, request); From patchwork Fri Feb 3 09:44:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18250 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 3781FC329C for ; Fri, 3 Feb 2023 09:44:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7470625EB; Fri, 3 Feb 2023 10:44:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417474; bh=oJDUAEahPnQTy8VjBnFaA8X0iM7MlZ41x4e3hveQ0hw=; 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=ZxOpmY8K1sG4vPIzCzztvCtHySu8+o8unfxHmMouWEnsfOL9JTjHmxfCUGjoCOYqy fuobu+Xs3Z9rQXUhdk+s0+r6a0U2Ng2OMnsDcIuYMthXeLGJR1wuOGgNXepSATZcls pfU/Fhlaod7kLEZMwBvVV7Gi6NswfvXcVZ7nFqkGcpM++1txQNSHE7GkgEAz17m66T imcib2fTjbatmgD/+ZG6bY56S8PfvHVIa2f+YeVK1YFZbCRg1+DeSA8PW15v5gvbhc mQUvGO1H/xNcvCSA0DiI7L6EZ7Y5KG5rgLO8t2m9182NQiqtkLfc09pZFy0UD6JBj5 qgDKKmIljjyRQ== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA24D625EF for ; Fri, 3 Feb 2023 10:44:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NRb+2/HC"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id h16so4078210wrz.12 for ; Fri, 03 Feb 2023 01:44:30 -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=jWVV/JyEAPl4kBWc5ldf5h6NOU1c89AUGkoy8ucYGBU=; b=NRb+2/HCd1oet1cyBj66yj8cZF54g/7Q0a75cobvK0oIidV5L5esSjT+1eBX1GY53u ymeDZ3QyVBy5mUmf0SnwVpMFUEpj9wZqoHhbByXRX0/QKGRUbiEEESBNhzfkfxkl+YYr 4MpZPIdsNU+ftjCdITynvgzuJq2IU+iNV61stqL1Cn8FO+z5CWLDfxJUujp6EhBJjkJM dk1PK3zM15af2nvimEfqPHNkJ9vOPQ3nlWiSrLdSul75X5U+N0Rrvl3WZGnMHOtk6zlL Fq96iKCsdg2Ll+9JZ3TraI+NYqV/CqqiK2e8+7ONsq5bjWYxZmnA+3RoS02hmGO1sedq ewlA== 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=jWVV/JyEAPl4kBWc5ldf5h6NOU1c89AUGkoy8ucYGBU=; b=X0CFK0GTwHm5eMQgc62KgMvwHn8kvDAgeBIGLhIyq/fLnK3MuX0HfInlbQxOdfBZWz IZG/IxGrm2gkreBryXS4ZZhCCsjlgANFa4XwVATNnboa+g6GBVtoS9R0pqfj/6eFuRva czXcaRvdSa9Rjp5qo0u6y2KwJUWoqGBpAE1Ao5ZrPLf2DKKjS9HpfC+Z/G9lN6G+eCs0 DUuYrkgrxQ9bT3xfxkydocyx9cfH/8zZR1SZrJCHT8dUqLHn4V4LPPSM27032wzGED4l LAVMzwuqULbIswRQFJB1vDyBEBk47xchG7QiN6Zuso+ixNQyq9lQ1U1KqmeArxfOkn2B w3+Q== X-Gm-Message-State: AO0yUKXTq/z4y0k4xUVetoSznFNol2r9uZ81AmYY749g0MvGMMJ9iBO/ hSwi/N9itbB0v9TScquAqRNHTV2ADU6VG1Y6TaEgag== X-Google-Smtp-Source: AK7set+b0FVVXL6Tr46NO40Kp8aqeSMuPusH1IxWt9QIfv6Vd2dOlDlcYCfl9lYbpqL96Oz+kUA4Wg== X-Received: by 2002:adf:c644:0:b0:2c3:d707:7339 with SMTP id u4-20020adfc644000000b002c3d7077339mr736984wrg.6.1675417470285; Fri, 03 Feb 2023 01:44:30 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:29 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:21 +0000 Message-Id: <20230203094424.25243-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/8] libcamera: apps: lcc: Make rolesMap global 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" Move rolesMap out of the nameParameters() function to allow use with other functions in the file. Additionally enclose all global variables in an unnamed namespace. Signed-off-by: Naushir Patuck --- src/apps/lc-compliance/capture_test.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 1dcfcf92fc8c..37138dfb3d2e 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -15,6 +15,15 @@ using namespace libcamera; +namespace { + +std::map rolesMap = { + { StreamRole::Raw, "Raw" }, + { StreamRole::StillCapture, "StillCapture" }, + { StreamRole::VideoRecording, "VideoRecording" }, + { StreamRole::Viewfinder, "Viewfinder" } +}; + const std::vector NUMREQUESTS = { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }; const std::vector ROLES = { StreamRole::Raw, @@ -23,6 +32,8 @@ const std::vector ROLES = { StreamRole::Viewfinder }; +} /* namespace */ + class SingleStream : public testing::TestWithParam> { public: @@ -59,13 +70,6 @@ void SingleStream::TearDown() std::string SingleStream::nameParameters(const testing::TestParamInfo &info) { - std::map rolesMap = { - { StreamRole::Raw, "Raw" }, - { StreamRole::StillCapture, "StillCapture" }, - { StreamRole::VideoRecording, "VideoRecording" }, - { StreamRole::Viewfinder, "Viewfinder" } - }; - std::string roleName = rolesMap[std::get<0>(info.param)]; std::string numRequestsName = std::to_string(std::get<1>(info.param)); From patchwork Fri Feb 3 09:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18251 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 A59F2C3243 for ; Fri, 3 Feb 2023 09:44:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 53ACB625F3; Fri, 3 Feb 2023 10:44:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417475; bh=NxhZeUKE1nvXap0YMG8vugqatVNdph4Ii/SKNyji8+Q=; 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=LvYvOKyHWAuqiBTtUdgVlq2mFtigLix+hV56Ac+xjEzJ8SYHIExkl/9iT2mOBET+w /c8LTQB+Q4kY4nKa6GUdZWK5zqFHUiyfZZy57lRK1y08mN8hJzSgjGzA5KmvFRWXCB 5RxLeFvKJU/qSBoVqHNb2CSQMiVinLUs/XixcjBnVlE5UROwce9v/CxkOXwN7Yz73V 8CIHoabNJaCPyQzI9fikji0qfvegTy5QWrL1hopDCEkjqIkTjEOnr+6qkQtoDtJAQV Y2q6t2yNTAWuyNVGfsMeRboWvdVa0PUUlTTN5nwsvZ7xG/q2EhS4zLi5TOV1a3+7YE N5LOWKbtF77WQ== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 691B2625E4 for ; Fri, 3 Feb 2023 10:44:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ojeDGagq"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id o18so4115408wrj.3 for ; Fri, 03 Feb 2023 01:44: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=nytONP2YDrHV/JpeWzsmettXZPjzIzkspdiWeo6WEy0=; b=ojeDGagqcTXV80rDOVET1k4HOtW57O1a1iWnyk8a9ngMEj8ptd5gNie5QVHb632QyG cD9XCQ57h2zSKYtEyLeU7QFu8ikREJFODnZreZaz4Hv8GwEKifhaow9CwzYp9f+GZVzN Hy08i66M+0A7kmqKEUOgBGQScSuaHEufRMIar0UF3bFQyCHR4KTJcGUSRV4GaAWHcOKU BzSvbwF/FY5iY/d7Y5Q8DU0wkwsrAdS98FcJUCV6PtEXyPF2D/jsEYJSCCCqgUpa5Nlf LbGgG49bBfhf57WwvV5PMX+EY6fDxXNIx49uCrO5w2Lg6i/wNBP/dTGG0gt5b3llVQEZ 1ioQ== 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=nytONP2YDrHV/JpeWzsmettXZPjzIzkspdiWeo6WEy0=; b=XDZQh/l77g2/Zj+CS/5mDSmMy3aJtBGGDWKwd0Z0C8v9daNMQkxd+Rg4uUEt9En1Nh z6J7NRLkicJR1LHa79DsnHt/C0/UCx3BjzRKMzNmvvV9KgR7iyUr084g21hHb8I66sAU xhpVvsfP3HlrSBCJFDBF6vOwqghwAfL6VKgAscr/Bmu2vR01UFtq1bgKKM2dqz5Rplmn e3yjORXJVpz1nrQEXpqjsXShze5gtxPyJNtlQ5m0LC1PC/8ABwKopCPyTB5/fkOe/BBF CBEOLkBAXuTqHmDVOzHcDSbi77sqzlIFhT7VR8sJVX5GfR7SleadF3sR5GIciFSoYINe x3Qw== X-Gm-Message-State: AO0yUKXDdikqNMx5wWfHHDDa5N/CuPZJZyEJkiLeRM2RRsdZAb3YZlp5 39FYxzuRS4F6Ox5294/i3F78Hlbnny8XpDPJS+S/MA== X-Google-Smtp-Source: AK7set+f7Fd9anaaFY3vn+5nDamJRU2/Ug1DUFtORdvwxS6qEkRdQNpb43xlphrDRlV4msEj6GpPxQ== X-Received: by 2002:adf:f5ca:0:b0:2bf:d686:c873 with SMTP id k10-20020adff5ca000000b002bfd686c873mr2906188wrp.28.1675417470768; Fri, 03 Feb 2023 01:44:30 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:30 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:22 +0000 Message-Id: <20230203094424.25243-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 6/8] libcamera: apps: lcc: Add multi-stream capture test framework 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 framework for testing multi-stream captures with lcc. To start with, a single test class, MultiStream, has been implemented. This class is based off the SimpleCaptureBalanced behavior, and tests that the pipeline handler completes the exact number of requests queued to it. Add a test to capture_test.cpp using the MultiStream class to test the pipeline handler running with two simultaneous streams. The test framework permutate across a list of named stream pairs. Signed-off-by: Naushir Patuck --- src/apps/lc-compliance/capture_test.cpp | 77 ++++++++++ src/apps/lc-compliance/meson.build | 1 + src/apps/lc-compliance/multi_capture.cpp | 187 +++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 61 ++++++++ 4 files changed, 326 insertions(+) create mode 100644 src/apps/lc-compliance/multi_capture.cpp create mode 100644 src/apps/lc-compliance/multi_capture.h diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 37138dfb3d2e..8d534161e985 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -11,6 +11,7 @@ #include #include "environment.h" +#include "multi_capture.h" #include "simple_capture.h" using namespace libcamera; @@ -32,6 +33,13 @@ const std::vector ROLES = { StreamRole::Viewfinder }; +const std::vector> MULTIROLES = { + { StreamRole::Raw, StreamRole::StillCapture }, + { StreamRole::Raw, StreamRole::VideoRecording }, + { StreamRole::StillCapture, StreamRole::VideoRecording }, + { StreamRole::VideoRecording, StreamRole::VideoRecording }, +}; + } /* namespace */ class SingleStream : public testing::TestWithParam> @@ -137,3 +145,72 @@ INSTANTIATE_TEST_SUITE_P(CaptureTests, testing::Combine(testing::ValuesIn(ROLES), testing::ValuesIn(NUMREQUESTS)), SingleStream::nameParameters); + +class MultiStream : public testing::TestWithParam, int>> +{ +public: + static std::string nameParameters(const testing::TestParamInfo &info); + +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr camera_; +}; + +/* + * We use gtest's SetUp() and TearDown() instead of constructor and destructor + * in order to be able to assert on them. + */ +void MultiStream::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void MultiStream::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +std::string MultiStream::nameParameters(const testing::TestParamInfo &info) +{ + std::string roleName = rolesMap[std::get<0>(info.param).first] + "_" + + rolesMap[std::get<0>(info.param).second]; + std::string numRequestsName = std::to_string(std::get<1>(info.param)); + + return roleName + "_" + numRequestsName; +} + +/* + * Test multi-stream capture cycles + * + * Makes sure the camera completes the exact number of requests queued. Example + * failure is a camera that completes less requests than the number of requests + * queued. + */ +TEST_P(MultiStream, Capture) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCapture capture(camera_); + + capture.configure({ roles.first, roles.second }); + + capture.capture(numRequests, NumStreams); +} + +INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, + MultiStream, + testing::Combine(testing::ValuesIn(MULTIROLES), + testing::ValuesIn(NUMREQUESTS)), + MultiStream::nameParameters); diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index 51d9075ac30b..0357cda2f301 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -13,6 +13,7 @@ lc_compliance_enabled = true lc_compliance_sources = files([ 'environment.cpp', 'main.cpp', + 'multi_capture.cpp', 'simple_capture.cpp', 'capture_test.cpp', ]) diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp new file mode 100644 index 000000000000..23becf964fd7 --- /dev/null +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -0,0 +1,187 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Raspberry Pi Ltd + * + * multi_capture.cpp - Multi-stream capture helper + */ +#include "multi_capture.h" + +#include + +#include + +using namespace libcamera; + +MultiCaptureBase::MultiCaptureBase(std::shared_ptr camera) + : loop_(nullptr), camera_(camera), + allocator_(std::make_unique(camera)) +{ +} + +MultiCaptureBase::~MultiCaptureBase() +{ + stop(); +} + +void MultiCaptureBase::configure(const libcamera::StreamRoles &roles) +{ + config_ = camera_->generateConfiguration(roles); + + if (!config_) { + std::cout << "Roles not supported by camera" << std::endl; + GTEST_SKIP(); + } + + /* Set the buffer counts to the largest value across all streams */ + auto largest = + std::max_element(config_->begin(), config_->end(), + [](libcamera::StreamConfiguration &l, libcamera::StreamConfiguration &r) + { return l.bufferCount < r.bufferCount; }); + + for (auto &stream : *config_) + stream.bufferCount = largest->bufferCount; + + updateConfig(); + + if (config_->validate() != CameraConfiguration::Valid) { + config_.reset(); + FAIL() << "Configuration not valid"; + } + + if (camera_->configure(config_.get())) { + config_.reset(); + FAIL() << "Failed to configure camera"; + } +} + +void MultiCaptureBase::start() +{ + unsigned int i = 0; + + for (auto const &config : *config_) { + Stream *stream = config.stream(); + int count = allocator_->allocate(stream); + + ASSERT_GE(count, 0) << "Failed to allocate buffers for stream " + << i; + EXPECT_EQ(count, config.bufferCount) + << "Alocated less buffers than expected for stream " + << i; + i++; + } + + camera_->requestCompleted.connect(this, &MultiCaptureBase::requestComplete); + + ASSERT_EQ(camera_->start(), 0) << "Failed to start camera"; +} + +void MultiCaptureBase::stop() +{ + if (!config_ || !allocator_->allocated()) + return; + + camera_->stop(); + + camera_->requestCompleted.disconnect(this); + + requests_.clear(); + + for (auto const &config : *config_) { + Stream *stream = config.stream(); + allocator_->free(stream); + } +} + +std::vector +MultiCaptureBase::prepareBuffers(unsigned int numRequests, unsigned int numStreams) +{ + std::vector buffers; + + for (unsigned int i = 0; i < numStreams; i++) { + Stream *stream = config_->at(i).stream(); + + buffers.emplace_back(&allocator_->buffers(stream)); + + /* No point in testing less requests then the camera depth. */ + if (buffers.back()->size() > numRequests) { + std::cout << "Stream " << i + << " needs " << std::to_string(buffers.back()->size()) + << " requests, can't test only " + << std::to_string(numRequests) << std::endl; + return {}; + } + } + + return buffers; +} + +/* MultiCapture */ + +MultiCapture::MultiCapture(std::shared_ptr camera) + : MultiCaptureBase(camera) +{ +} + +void MultiCapture::capture(unsigned int numRequests, unsigned int numStreams) +{ + start(); + + queueCount_ = 0; + captureCount_ = 0; + captureLimit_ = numRequests; + + std::vector + buffers = prepareBuffers(numRequests, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue the recommended number of requests. */ + const unsigned int inFlightRequests = config_->at(0).bufferCount; + for (unsigned int i = 0; i < inFlightRequests; i++) { + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[i].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(queueRequest(request.get()), 0) + << "Failed to queue request"; + requests_.push_back(std::move(request)); + } + + /* Run capture session. */ + loop_ = new EventLoop(); + loop_->exec(); + stop(); + delete loop_; + + ASSERT_EQ(captureCount_, captureLimit_); +} + +int MultiCapture::queueRequest(Request *request) +{ + queueCount_++; + if (queueCount_ > captureLimit_) + return 0; + + return camera_->queueRequest(request); +} + +void MultiCapture::requestComplete(Request *request) +{ + captureCount_++; + if (captureCount_ >= captureLimit_) { + loop_->exit(0); + return; + } + + request->reuse(Request::ReuseBuffers); + if (queueRequest(request)) + loop_->exit(-EINVAL); +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h new file mode 100644 index 000000000000..9037099988e5 --- /dev/null +++ b/src/apps/lc-compliance/multi_capture.h @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Raspberry Pi Ltd + * + * multi_capture.h - Multi-stream capture helper + */ + +#pragma once + +#include +#include + +#include + +#include "../common/event_loop.h" + +using FrameBufferList = std::vector>; + +class MultiCaptureBase +{ +public: + void configure(const libcamera::StreamRoles &roles); + +protected: + MultiCaptureBase(std::shared_ptr camera); + virtual ~MultiCaptureBase(); + + void start(); + void stop(); + + std::vector + prepareBuffers(unsigned int numRequests, unsigned int numStreams); + + virtual void requestComplete(libcamera::Request *request) = 0; + virtual void updateConfig() = 0; + + EventLoop *loop_; + + std::shared_ptr camera_; + std::unique_ptr allocator_; + std::unique_ptr config_; + std::vector> requests_; +}; + +class MultiCapture : public MultiCaptureBase +{ +public: + MultiCapture(std::shared_ptr camera); + + void capture(unsigned int numRequests, unsigned int numStreams); + +protected: + int queueRequest(libcamera::Request *request); + void requestComplete(libcamera::Request *request) override; + + void updateConfig() override {} + + unsigned int queueCount_; + unsigned int captureCount_; + unsigned int captureLimit_; +}; From patchwork Fri Feb 3 09:44:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18252 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 077B8C329D for ; Fri, 3 Feb 2023 09:44:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C02BA625F5; Fri, 3 Feb 2023 10:44:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417475; bh=CR3beotvVv+IR6MJ9i1aC77DfZeOx13xFujkR6NZtX0=; 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=O9QqS1nyPznxlk+ev8K9CIGoQKSVXrr8UQ2uKsXYIdiBP0ooltcrLxcJycXn+BTre i1goqu3KyFittQ8g+uglNNm43V6U/wSIkg+C+xZSpNOzkIMVQLN2yzJFmBaVqeAVh7 uKky+fd7Ma53C2UGVjgu9+hSprV3K6w6OYgVue0mHvyxDwStfe4bosciUxAABLO5b1 cdTihFK8hao+vbkhtccUR5Z8tRMawG7mvuSQBHxbuh6LUlknLKS8HDG/GDLaosXUU/ wwUEBcte2qZguWBUHYQ5YYMb82V8iBBSRof6YFZCAcyNvqQ05EmiFdfDLASiBNEvBr 1zIq7+GKZ6xzQ== Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BF42C625EE for ; Fri, 3 Feb 2023 10:44:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ZURSzyR6"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id bt17so1065507wrb.8 for ; Fri, 03 Feb 2023 01:44: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=/hgBGNe9687TY2y9ydcpdr81a5GOgRL+7LnWjqWMLcw=; b=ZURSzyR6AuhgxTHyw+Yv2cAvotH9yofaZEyGsjUgmMtVgNTGtvrgtf57mGj+SJyxCI jplku1R4dYgB2PCK4HSOxOE5hZcjy/xsfCeiEJ4SBTrv06APFYA5AXSC4XrNk92VpP4q vb3kuLjy31//qk+kxMZNBM4TSL240br59jEnS8ZVtlf/gqWI2OR21EjIZT+nfu5SUCoQ agW8ogQAkRf1yyPSSK0emmPjvyKUBe0DS12Eh4pjRS+XHRnUJFIF25kIhY4rEDJERHY8 zRI8VxF7Eg2OW2BPnUgwK9Up1sl9E9c5SDWaV0lPHKzmbO8fKsopaSF0I/ALd/QjA3sC rTFg== 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=/hgBGNe9687TY2y9ydcpdr81a5GOgRL+7LnWjqWMLcw=; b=dhoBTSuNWifxjLRS/GnTo15lPTqgIC0i8xdxjXzFUWMBfyW1hVeExBm1rOHULOhzVf vNgpr+tU294X/cc+7E0XA3KBLGyVeOvNfVZWi2SAwFxURcVEWCnkEPLrNNO53n0kg6rZ nX0uhX9+WgS+4snt5UkjoamjYjBieEzCU/qJpOtv7x1KxiS8PKZpHgklo7iePKrGYYZs Xj16DiJcGYykcHhpEjyzA0D1lRl59CE0Dw0gPyPsi6MSisDTLyUG00UFVuwM1nwa/775 HeT6Annl8SYug8UwW4R4WiSTVlN+hLf2Ty/HTP55PS46sU/GHIxFPUMDWYmp4wdV8AyE 0Dcg== X-Gm-Message-State: AO0yUKUy076c5YoEQN4y8OTeoFu9RbWruhBzlRtGtlTTqjnWSg+VQ3uh keYmIvrySbqQSGeEK4o8n2a6f1kFt/pW9wNJ+i5PTA== X-Google-Smtp-Source: AK7set/9jaD9mTeL8acBBAyrmWk4TWNZBhQzFqYYPiY63DX++QmPTT5I6LjAj6A2CYbPZ1jV65oW/Q== X-Received: by 2002:a5d:4537:0:b0:2bf:adfb:58cd with SMTP id j23-20020a5d4537000000b002bfadfb58cdmr8353690wra.30.1675417471271; Fri, 03 Feb 2023 01:44:31 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:30 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:23 +0000 Message-Id: <20230203094424.25243-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 7/8] libcamera: apps: lcc: Add optional stream tests 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 new test class, MultiCaptureOptional. This tests operating with multiple streams, where one of the two streams is not provided buffers in certain requests. Signed-off-by: Naushir Patuck --- src/apps/lc-compliance/capture_test.cpp | 20 +++++++++ src/apps/lc-compliance/multi_capture.cpp | 53 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 9 ++++ 3 files changed, 82 insertions(+) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 8d534161e985..c6a09a63248a 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -209,6 +209,26 @@ TEST_P(MultiStream, Capture) capture.capture(numRequests, NumStreams); } +/* + * Test optional stream capture cycles + * + * Do not provide buffers for all streams in all Requests, testing that stream + * output can be optional. + */ +TEST_P(MultiStream, CaptureOptional) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCaptureOptional capture(camera_); + + capture.configure({ roles.first, roles.second }); + + capture.capture(numRequests, NumStreams, 0); + capture.capture(numRequests, NumStreams, 1); +} + INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, MultiStream, testing::Combine(testing::ValuesIn(MULTIROLES), diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp index 23becf964fd7..a011dfb285c8 100644 --- a/src/apps/lc-compliance/multi_capture.cpp +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -185,3 +185,56 @@ void MultiCapture::requestComplete(Request *request) if (queueRequest(request)) loop_->exit(-EINVAL); } + +/* MultiCaptureOptional */ + +MultiCaptureOptional::MultiCaptureOptional(std::shared_ptr camera) + : MultiCapture(camera) +{ +} + +void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStreams, + unsigned int optionalStream) +{ + start(); + + queueCount_ = 0; + captureCount_ = 0; + captureLimit_ = numRequests; + + std::vector + buffers = prepareBuffers(numRequests, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue the recommended number of requests. */ + const unsigned int inFlightRequests = config_->at(0).bufferCount; + for (unsigned int i = 0; i < inFlightRequests; i++) { + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + if (j == optionalStream && !i) + continue; + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[i].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(queueRequest(request.get()), 0) + << "Failed to queue request"; + requests_.push_back(std::move(request)); + } + + /* Run capture session. */ + loop_ = new EventLoop(); + loop_->exec(); + stop(); + delete loop_; + + ASSERT_EQ(captureCount_, captureLimit_); +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h index 9037099988e5..3d92ba3d4c10 100644 --- a/src/apps/lc-compliance/multi_capture.h +++ b/src/apps/lc-compliance/multi_capture.h @@ -59,3 +59,12 @@ protected: unsigned int captureCount_; unsigned int captureLimit_; }; + +class MultiCaptureOptional : public MultiCapture +{ +public: + MultiCaptureOptional(std::shared_ptr camera); + + void capture(unsigned int numRequests, unsigned int numStreams, + unsigned int optionalStream); +}; From patchwork Fri Feb 3 09:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18253 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 80EFAC329E for ; Fri, 3 Feb 2023 09:44:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C21E625E7; Fri, 3 Feb 2023 10:44:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417476; bh=LUAtUnrEzmwGTWKwtNC+GNZf02WnRv8bO7rk/b6Yt0Y=; 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=YX0wsH50eSYajFSMDeVPNpptcJ/hDT8Inc8RHe50iuKle7wERddBctm3DNT+drVsr qZBnGRDV7QlkZO9RKtpTOETfQ2VWwAaLfQvq94OHWVQ/gDepCHg/Mfp2axS5Cj3+pw FTO0dsR9XghRbFxGmB01CqZV6DModCQgdxB2KJ8urFZwBjCVHA2B4Rrm3RefdKZ4is dQ/woWwBc30VfBYraJzvo+HQ4T/+czOUQMF6KpVGedSRUyP57jYYoJ1qAwmAweWTlc OwI1gkG3t+TqCFaJMgaZmxVtxZiR4DeCHZlvrc1MtR0Y+LUS4gBxbq7diU0n/BxGk1 /iEP7BOTE6dTA== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8878E625E6 for ; Fri, 3 Feb 2023 10:44:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="IhBsMNSB"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id h12so4087732wrv.10 for ; Fri, 03 Feb 2023 01:44:32 -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=2scObb81b/oIwD4q0wu6Jc8r9Izoe6TDhaQrbOzkfu8=; b=IhBsMNSBmLOOMY83FeBaj89LiAj3w36TPSpEPEOevAtDUi94ZmZ2sCXhfg6AXfx5f2 D6AMCSGKz7H8Og3wl3rMWi8TnNKyHJl0y2aUngjV3dnjX2VzK9hPIHxy6Pje/uZury+0 /dQYkRyBbINv/L++V0cnxGBjdRfmP1WN/fh6QFFDGH637JtBqa8JMWWz4FJFjAkqp5GA EeGp9obqhcTD/mWYVK6qaNEyf6fxh3EKTVggaNE++iAPHs8+5gz8VMcvvtuzkBhG1n3g o5KHS+tiSadTK+RFQhqMzWFZEaECX7sCsziuNRfxMEkkY5CM4ob4j6nOfe6Ru4/c06U5 ly6g== 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=2scObb81b/oIwD4q0wu6Jc8r9Izoe6TDhaQrbOzkfu8=; b=qAvHwzQ/t2ynhfUpn+DEjXQRHTs5t9hi81j3Z1qikExDy9sLGBWXdGXe/hQY/Z6vSs 5uL7rhnt0XkfgRafJ1jBZn66jh3vhgzJxiY328wo8RZ3RrHrAw3U8+CpvudOEqzjVHfc c5t3jdbMka+l1qCZxn2If5LgU4x6hCpQrCX5aEOMtMGOF5zppFvDXAelGxYYTpVbzG3P 3VR/Lt+RjyVoG+bpmqgruL7HacKbjL453tsqK11uzKl/beP1X2gm2D8dBXQwZ7VR7s7i HfYwgX51zbOPzxr4t1fKcm0Fycp3A9W1fcIkEx9b+BnSscOhx9ijIkXbEPZ/v87iz+mf lr6g== X-Gm-Message-State: AO0yUKXaMrfn5bwR2FSWKcmbwIaimWpyeuCSxFcxifkkwusme71xmvVo gtlEiwf+sbd4hnEy6sighflEcp6CG7rFWPAum6ZXvw== X-Google-Smtp-Source: AK7set8olCrDn/zhPCQqPR2VQRy1Q981eRT292dxOoeL3SxnTkWaLU4gvLcmyfuVnRzGuV6HKN89xg== X-Received: by 2002:a05:6000:2ce:b0:2bf:f805:5220 with SMTP id o14-20020a05600002ce00b002bff8055220mr11171656wry.43.1675417471860; Fri, 03 Feb 2023 01:44:31 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:31 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:24 +0000 Message-Id: <20230203094424.25243-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 8/8] libcamera: apps: lcc: Add stream hints test 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 new test class, MultiCaptureHints. This tests the MandatoryStream hint flag and ensures that requests are cancelled correctly if the flag is set and no buffer is provided. Signed-off-by: Naushir Patuck --- src/apps/lc-compliance/capture_test.cpp | 21 +++++++++++ src/apps/lc-compliance/multi_capture.cpp | 48 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 17 +++++++++ 3 files changed, 86 insertions(+) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index c6a09a63248a..9239e8b5fc8a 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -229,6 +229,27 @@ TEST_P(MultiStream, CaptureOptional) capture.capture(numRequests, NumStreams, 1); } +/* + * Test mandatory stream hints + * + * Mark a single stream as mandatory, and don't provide a buffer for it in the + * request. This should case the queueRequest call to fail. + */ +TEST_P(MultiStream, CaptureHints) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCaptureHints capture0(camera_, 0); + capture0.configure({ roles.first, roles.second }); + capture0.capture(NumStreams); + + MultiCaptureHints capture1(camera_, 1); + capture1.configure({ roles.first, roles.second }); + capture1.capture(NumStreams); +} + INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, MultiStream, testing::Combine(testing::ValuesIn(MULTIROLES), diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp index a011dfb285c8..6aa39b7e281f 100644 --- a/src/apps/lc-compliance/multi_capture.cpp +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -238,3 +238,51 @@ void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStr ASSERT_EQ(captureCount_, captureLimit_); } + +/* MultiCaptureHints */ + +MultiCaptureHints::MultiCaptureHints(std::shared_ptr camera, + unsigned int mandatoryStream) + : MultiCaptureBase(camera), mandatoryStream_(mandatoryStream) +{ +} + +void MultiCaptureHints::capture(unsigned int numStreams) +{ + start(); + + std::vector + buffers = prepareBuffers(config_->at(0).bufferCount, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue a single request */ + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + /* + * Do not add a buffer for the mandatory stream to cause a + * deliberate failure. + */ + if (j == mandatoryStream_) + continue; + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[0].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(camera_->queueRequest(request.get()), -ENOMEM) + << "queueRequest did not fail!"; + + stop(); +} + +void MultiCaptureHints::updateConfig() +{ + config_.get()->at(mandatoryStream_).hints = StreamConfiguration::Hint::MandatoryStream; +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h index 3d92ba3d4c10..c48c16e7565d 100644 --- a/src/apps/lc-compliance/multi_capture.h +++ b/src/apps/lc-compliance/multi_capture.h @@ -68,3 +68,20 @@ public: void capture(unsigned int numRequests, unsigned int numStreams, unsigned int optionalStream); }; + +class MultiCaptureHints : public MultiCaptureBase +{ +public: + MultiCaptureHints(std::shared_ptr camera, + unsigned int mandatoryStream); + + void capture(unsigned int numStreams); + +private: + void updateConfig() override; + void requestComplete([[maybe_unused]] libcamera::Request *request) override + { + } + + unsigned int mandatoryStream_; +};