From patchwork Wed Jan 20 08:34:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10906 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 66A27C0F2A for ; Wed, 20 Jan 2021 08:34:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 27A0668182; Wed, 20 Jan 2021 09:34:59 +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="iNwfnctw"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D9AD460312 for ; Wed, 20 Jan 2021 09:34:56 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id u14so2024355wmq.4 for ; Wed, 20 Jan 2021 00:34: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=H6uWx2Ho8qpRpkD8knmJwuY9KThGww4e7VlCQWcrh20=; b=iNwfnctwDDReQEnuPTm17r6z/qHMK0tkC6Tfw2d4ik1HNo++WdpBCSqxahd+xOq2fb mmWTw+GL3NxNLzv3tRIPxmxV7tZ5aPdKoyeX6EEdzqLeIVVexxh7GjsTP4c2LgxYQCtO MdbWc7o+5XvSPYbvPobAnJr9XGFWIaAh+jqSnFTfl9xuxwgXIa8fkc/QV8L6UThUbMbp iFv2YjHSUzu8HaX2EeHKbyk9kMe2i/pBPIsjKivjQAvrPHS4ezIWSeIKTd8tsJeICBZe KqcqF9VhjGL5DnonpP5FQhPbVN60NUZWcsf/r9kYsN2ub2rUHCCGiEs6imH39xvX6/1e srdA== 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=H6uWx2Ho8qpRpkD8knmJwuY9KThGww4e7VlCQWcrh20=; b=WRIMMFm5YAWwNp6zixbN4UVGNZFPy/HGMMbqWb4L+XyLx6jwC7Nwg6G0fr5xHoIQi2 k22uZITHRgu/qhCcNaWEmCFNF91BbIl7dr6uArOUe0Ect7995SkkI31CHrcte+C2lvD8 kAV9rBvki4iKzD1Fabod7qdMAfXeMwcdvJxTo1rvxEexXxyo/m9z5L7PkcBia0jLsTiq gHzJsxGNu0aZwhhMx35OHgPK6k2ACmmURMd4LTPmQtJ/B/N9ck3y0umVx5Rys7m9sEMH XAcfaoIqUYIb/xhkN1DIfcFU89R16sh24Vgtv1OOMt/wLsYTojg4QSSs4vTq8yNXGI8C QJ9Q== X-Gm-Message-State: AOAM530kXYWP5LJbH5gu7X8KW6OcZndPU4/gjbKfx8SPxGUJ1M8bKM4K uLXxlhl8cKSRUlOrbqTHYqA/w9vII3Gf1Q== X-Google-Smtp-Source: ABdhPJzAR5o6ow3rT/L5u0eothP9WnqFLniSylHtkgLGNe6AMLOkxW8w+UuGYSee/yB4D9+AQO2AQg== X-Received: by 2002:a1c:a145:: with SMTP id k66mr3218927wme.18.1611131696321; Wed, 20 Jan 2021 00:34:56 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id 33sm2809284wrn.35.2021.01.20.00.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 00:34:55 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Jan 2021 08:34:46 +0000 Message-Id: <20210120083449.642418-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210120083449.642418-1-naush@raspberrypi.com> References: <20210120083449.642418-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] 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 --- .../pipeline/raspberrypi/raspberrypi.cpp | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index e03bcb036f9f..282c4ba75d89 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,42 @@ 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; + + output1Format.size = format.size / 2; + if (output1Format.size.width > maxDimensions) { + output1Format.size.height = maxDimensions * output1Format.size.height / + output1Format.size.width; + output1Format.size.height &= ~1; + output1Format.size.width = maxDimensions; + } else if (output1Format.size.height > maxDimensions) { + output1Format.size.width = maxDimensions * output1Format.size.width / + output1Format.size.height; + output1Format.size.width &= ~1; + output1Format.size.height = maxDimensions; + } + + LOG(RPI, Info) << "Setting ISP Output 1 (internal) to a resolution of " + << output1Format.toString(); + + ret = data->isp_[Isp::Output1].dev()->setFormat(&output1Format); + if (ret) + return -EINVAL; } /* ISP statistics output format. */