From patchwork Tue Jan 26 16:24:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11011 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 A8A49C0F2B for ; Tue, 26 Jan 2021 16:24:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 773DB68319; Tue, 26 Jan 2021 17:24:25 +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="KHxT1wWQ"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81BC868316 for ; Tue, 26 Jan 2021 17:24:19 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id i9so3323031wmq.1 for ; Tue, 26 Jan 2021 08:24:19 -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=dsPixlnJZhJd5BDuTN2uW6MwnaS4GEG/CSXQPrFQY2E=; b=KHxT1wWQELcTVqd//At5OWOes07++HOKONUI6Q8qWj5hW7JO8+T4aunMRDf9iIvpfg 74+eyyoZhvnxMyq0tbwZRkmQQrgxnmL2DkJYTSX9f/NlVJNeyR2QeRYKtwG9PsoPoPd7 6DMtqY9g2Zd93m3U2fQXcGp6zndZNLrxagB/uZDVWniXSPd6YmATJnF4KTys2djAFzSK Bl2hWCvwwVQxSjO1+kKd+BY1vJuCqAQLSd104wfD/X2sV61T3tRrMEFj0atjGLB0newr 4X17rewZ3B+/RdkIeeNVSFsp3nzZvrCaWNxOIIULLZpAS7V8hdJ4BN5vxBB2UA+OMPha L7Ag== 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=dsPixlnJZhJd5BDuTN2uW6MwnaS4GEG/CSXQPrFQY2E=; b=UoOk7TyDLK8h9TsIUA83vBnkdI9EEtoihHF47nbMaZtLuVd3LNpJV9E7AsiBliN07l qAloD4SEeadWxQEOgF5ZLOYWrqfGTmXeWvnq1gma+yOHUqLOUKLSzor0q1U7CU3GK0Ot YQ1ZA5LHFrv2MBj1QtburKlaJseASn3XV5XB0v+jjd3zH0wnAYhaN2LPSHpJbxA0uP+7 i5hTXqefy+mXcMCPGmimbVWN9TYvMrhRm24C5LPTGe95n66ctoNV6Kqq4a0GamdIRFVj mk8RbLbHcfWwsuYa0FOeYf9IrdabfYxdgsy78OWlD0Th5ZuN3UUawH12JD3XszS6P2dZ 2RVA== X-Gm-Message-State: AOAM5321kmlFWgELQm8N6Lz3A5QqVvgq3Ht5DXnyLTukTFvYNZrGKtZ5 WcQFFOIKXJyfyKOj5lCdTNT0M53boPDge+Na X-Google-Smtp-Source: ABdhPJw/5r2GaUxZ7W7oFzya9qGmLK/esIulDq1Us9vX/QTQBbWnvzBsP8yy7J7ohjdAIN+Cz7ql9A== X-Received: by 2002:a05:600c:4417:: with SMTP id u23mr497044wmn.100.1611678258897; Tue, 26 Jan 2021 08:24:18 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id m18sm8725809wrx.17.2021.01.26.08.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:18 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:08 +0000 Message-Id: <20210126162412.824033-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210126162412.824033-1-naush@raspberrypi.com> References: <20210126162412.824033-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d9895c779725..fe4c75f09925 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,35 @@ 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) { + LOG(RPI, Error) << "Failed to set format on ISP Output1: " + << ret; + return -EINVAL; + } } /* ISP statistics output format. */