From patchwork Fri Jan 22 13:14:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10959 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 D976ABD808 for ; Fri, 22 Jan 2021 13:14:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 930C46827A; Fri, 22 Jan 2021 14:14:57 +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="bdG5S6nb"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E99A268279 for ; Fri, 22 Jan 2021 14:14:56 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id s24so6691153wmj.0 for ; Fri, 22 Jan 2021 05:14:56 -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=bdG5S6nbDtcZL8UdnsL5Bls7SgJ69EvTLamMeL4KCXZuaMevrgEO9m8SESMIK2vEeS 1iXd5fMC9OTa4PP7Y84S+zMHI86p3PjTXuAzV7Yl1rzK31oezPZ7ZL+gSlWm7RLUBUIz qYKtPq/b51TdGnQpv45Xvk8WUWHwG35Q4vCfVIMO3RzHtcwz297ftPeVi/UMLdYA1cCl WkWItfoTOSXWUMbf3GpHLn7ZGP65I6e6HaIa1p3zPc+C3FE6B9wNkgqNVsbqXEHhQPDQ rJ+EYU20/zwdRjO1e3EO8SAcf9Atv0kyHyKuVIcr179q+lSUDo8j6yVBSl+tPl+3v3Ef xJoQ== 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=YFFaV3IlPTtI+Fn5NAllHD66/zRF7nY5LS9N4oU3Pnc+7dUjo0wk6g41Cz8OIrkwZK hrBjwgDscKZvZE6bT0K1mCPwiB3R8Rjf6YeLVFspp2q7QeabM3z9bAjKX5swTpi7UM8A pD3QaMrCU9EXliwsSxQvdA+IA8dCinWclmRTfU7gY4zXJN4Yf6uR98i0sWFPo3IXJ2WU P+pgf9B3n/ljNkualGdmjuG024TSzrBWmGrpOLsNI99WFamUQwSL89LvmGraoebJCf2O 8/L0BvLcAvPV6DP7wO/sJhzQP/f24Y1LYbhIGiTRJZmFm8gYi6tfsqgGUO1dTvWODrvf hmow== X-Gm-Message-State: AOAM531yEVrI9flMHoT3Muo1KQiYfvTmXeSDzmytk3OleXAknWgM+HsO 2gBnf/Qs9QUz6/UnkMBjqGTotNVeY8TUQg== X-Google-Smtp-Source: ABdhPJzmjwG4kiC48f+R7ZFjUkb4YAIJ44Mk/OQDFJQWKBLma4K+t9Rk2BwHT/pjRwf0dAL8cpk8SQ== X-Received: by 2002:a1c:dc41:: with SMTP id t62mr3979431wmg.106.1611321296475; Fri, 22 Jan 2021 05:14:56 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id i8sm7228870wry.90.2021.01.22.05.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:14:55 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 13:14:47 +0000 Message-Id: <20210122131451.726584-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122131451.726584-1-naush@raspberrypi.com> References: <20210122131451.726584-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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. */