From patchwork Fri Jan 29 15:11:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11062 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 5B9BEBD808 for ; Fri, 29 Jan 2021 15:12:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D97A8683B0; Fri, 29 Jan 2021 16:12:03 +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="mUBgC9J1"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E8FE6683A2 for ; Fri, 29 Jan 2021 16:12:01 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id m2so7109626wmm.1 for ; Fri, 29 Jan 2021 07:12:01 -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=mUBgC9J1eoomV72THSQAx7Aa+tNpLMdD1w0xwnIWANFHB4p3jv5x2AkZOJpc5ZrJW2 M6gvckjDYEtL2EgOb89IJOoOs7IUXxoHMmFrHoMh3oANvmPc6puZU+FYd3/c1epTm9CS OEcuhaVsy46Rq7a+KjH9IcjHuOZ/Amin4qXdCPPrTq01sZDYLUM9CS61YXoBut1di8qW XVtH+LUVbvDWLhrDRBE9yKXlR+SVhpyw0P3wJ9TWUWrAh1BXrHGxl3r3WvQjh2gE1A6u +DCaeWha3wzYjXZFkIMalkpH+WIiZiAvbyNFRTisgTbDMd2gnK4USa0ASX/+oGoZvxB8 nEEA== 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=Nl67LfL7X3XOQC0VtKE0EmGQEkBEhAESxyMDpN2HEZ1G8bPAIBeFwY3WuHPZMANBvi 1+bM3911Z/rXh8Qy97hOjbURNsGpPuxcL7QBxITlxrrvWbEL8ZKitIeBVS2FsNF+GsDO mlNmh8rBMhOO57RVH4JLrAl4od4cZOKwrAUEpilkjETsOJFivCk7v8JoN+lKGxQ4tNRD 0w+vyXNdWJz+gXXtU3NzV4N0dqnLqDJyQuTZ9iE37ppOTG6GmbFA/dlAnf090i9yECEL NLnAyhyGBzym/rcaRcqV97HI2DP3LREHDJ/B9GQ8FMvlDY/SbBVqqkJ1JEpGuUA+3ENb 2Pow== X-Gm-Message-State: AOAM530/g5PGt7jLbhBB5+bzIHUYOdyA/Ox7hiKwJCX28N/10+yHmTnR qF2shNrSiJuo9DJMLO2wMvpCoNT4VlnXG70i X-Google-Smtp-Source: ABdhPJxOSLoiUsuLL1kPthJNnVczqY+ARZsUUSogNwdhC7vj6mGnAkFg4N4A7jPi8S/By5Kros3JTg== X-Received: by 2002:a1c:8157:: with SMTP id c84mr4361518wmd.24.1611933121101; Fri, 29 Jan 2021 07:12:01 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id f13sm6517461wmf.1.2021.01.29.07.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 07:12:00 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jan 2021 15:11:50 +0000 Message-Id: <20210129151154.1051163-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210129151154.1051163-1-naush@raspberrypi.com> References: <20210129151154.1051163-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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. */