From patchwork Fri Jan 22 09:25:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10946 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 16620BD808 for ; Fri, 22 Jan 2021 09:25:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D5C9568235; Fri, 22 Jan 2021 10:25:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gLyf/Urm"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A46468238 for ; Fri, 22 Jan 2021 10:25:45 +0100 (CET) Received: by mail-wr1-x42f.google.com with SMTP id a12so4384268wrv.8 for ; Fri, 22 Jan 2021 01:25:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4t5pQWPhDpMTniEtHAIBP1ASHlzXWrJc0UXCliO3GZg=; b=gLyf/Urm33Hrl1kN4Ykx7cLMXMWUGLs9O+3aLnft/6DOFQirGeysKUzpuN2jnSz8Lz H6e60ICK5eqirrw3qIiVX4leQWitRKQe0Yhp3JDfqoXIt/iq3t8gJypv6wMmoHyF9xVK J4Iu9A6Cr2tWDDXuLy6sjR/P1pwR3LaIFTFhYvdx39ig85ZGQZpjr/uShe+RRa4bCQq1 XOCDCJguG+r5IrZEQ1wVcX3Ewx+sNDSe4BUp7uLYxro+hIdZnAGD8dGSXnChPOikhWfL 3DnxyfMqMsoOWaU9xZ8NpFWPMfdvxz8HA6JX+DEmnNeWKyG57ekSkdxdE6rMwSYFT79h WzcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4t5pQWPhDpMTniEtHAIBP1ASHlzXWrJc0UXCliO3GZg=; b=nXF3uplsECMP6vRyk4PCyymFMHYhLuvrOfb4QmYY2VjpTfj68TriZGIzCk7pFVQxca MWANhWXWzE1Fz6hCtndeu1tn810flJ35YHxcsiMMUqsriHWG1M+6GrVJbRKzn9ZExHrE 3GdRTiPFvKp5bUENrZKLO5N9Ud5RYiQyRs5C+qsPg3eFEw1u4kkwAYYP9/+zHpmlLgbM zUGG0p4uz+hrQpJkf6k9VsfmaKvq/k+7iTy5DUB7yInpkJlqL4UnyWfMdvwhG9QXqajX sIJ8Q1tzENxT0efgwIs6MKizduiG1LH2ij+j+bhEnE8RLQ6ZmBVztAFzff+QxwViex6/ lCYQ== X-Gm-Message-State: AOAM530MzzAv9jpxxDKfJWrh4gnCPUNStr5rNiqrzz5IHw7e3B1gFxD+ 0WSOeJjWuj/wZLgGq8z16vGBMX13CAR3ww== X-Google-Smtp-Source: ABdhPJztsPDb+kZ6GeGFzsOK2Fze+gyJnYKazJ8LRLTyDpn8DxrG8y0/PdSpK+C+MtUx24yu0n48tQ== X-Received: by 2002:adf:ef8b:: with SMTP id d11mr3614909wro.156.1611307544686; Fri, 22 Jan 2021 01:25:44 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:43 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:33 +0000 Message-Id: <20210122092537.708375-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/6] pipeline: raspberrypi: Set the ISP Output1 to 1/4 resolution if unused 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In preparation for fast colour denoise, set the low resolution ISP output stream (Output1) to a 1/4 resolution of the application requested stream (Output0). This only happens if the application has not requested an additional YUV or RGB stream. We also constrain this 1/4 resolution to at most 1200 pixels in the largest dimension to avoid being too taxing on memory usage and system bandwidth. Also switch the default StreamRole::VideoRecording to YUV420 to allow fast colour denoise to run. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 7e92f7669126..a0d3ac7ce49f 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -496,7 +496,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, case StreamRole::VideoRecording: fmts = data->isp_[Isp::Output0].dev()->formats(); - pixelFormat = formats::NV12; + pixelFormat = formats::YUV420; size = { 1920, 1080 }; bufferCount = 4; outCount++; @@ -608,6 +608,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) * StreamConfiguration appropriately. */ V4L2DeviceFormat format; + bool output1Set = false; for (unsigned i = 0; i < config->size(); i++) { StreamConfiguration &cfg = config->at(i); @@ -632,6 +633,9 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) format.size = cfg.size; format.fourcc = fourcc; + LOG(RPI, Info) << "Setting " << stream->name() << " to a resolution of " + << format.toString(); + ret = stream->dev()->setFormat(&format); if (ret) return -EINVAL; @@ -645,6 +649,32 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) cfg.setStream(stream); stream->setExternal(true); + + if (i != maxIndex) + output1Set = true; + } + + /* + * If ISP::Output1 stream has not been requested by the application, we + * set it up for internal use now. This second stream will be used for + * fast colour denoise, and must be a quarter resolution of the ISP::Output0 + * stream. However, also limit the maximum size to 1200 pixels in the + * larger dimension, just to avoid being wasteful with buffer allocations + * and memory bandwidth. + */ + if (!output1Set) { + V4L2DeviceFormat output1Format = format; + constexpr unsigned int maxDimensions = 1200; + const Size limit = Size(maxDimensions, maxDimensions).boundedToAspectRatio(format.size); + + output1Format.size = (format.size / 2).boundedTo(limit).alignedDownTo(2, 2); + + LOG(RPI, Info) << "Setting ISP Output1 (internal) to a resolution of " + << output1Format.toString(); + + ret = data->isp_[Isp::Output1].dev()->setFormat(&output1Format); + if (ret) + return -EINVAL; } /* ISP statistics output format. */