From patchwork Tue Jan 26 16:24:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11010 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 4C928C0F2B for ; Tue, 26 Jan 2021 16:24:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F4D66831C; Tue, 26 Jan 2021 17:24:20 +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="X8EeQbms"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4ACE168312 for ; Tue, 26 Jan 2021 17:24:18 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id j18so2961184wmi.3 for ; Tue, 26 Jan 2021 08:24:18 -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=UyFjSnujeS0bFhaSast+12b5DEuvqd6mLGYgdgtqrLs=; b=X8EeQbmstPDazgYMl25LVW5B8LFWsNNmXmhY4eNytAwPgxaFsfudt8OPlL6AgGour6 1lgeKBmN1cAq+GYd94L3q+H5Ue2Mlrix5uI6KzK7PTBkV6tzj9X8MqKUy9Nudf92pOLZ 3DbHsIY3S2Y/2HCTGpi0vM6cjEwYgbozEOaAVXaEVGZs3+s9rI0S+RDBKbZid4KAmrWB BhLvLVZsN+e6Na4jBP90wmxK2LR2fBPWvNGxmRA4KNHjeEYe1lrVgiVpwkpk/qIx1kFe 6/Itfq4tqMSFQIQWDcWRWRbHdldOy8yiFby4nTbzSeC/M5Un6q+x7rgs0u0dF0Edmrwy yg1A== 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=UyFjSnujeS0bFhaSast+12b5DEuvqd6mLGYgdgtqrLs=; b=mQX6v1LbeeNno/uevPsBC8KbDUxdJ4TBs7RhvC7+ZxTEfBwyrTy/1UnF4XZ4AkmLE1 Au5YQrpwUbPu931k1skUXpArck+Sesv4pdYI0sizk33FcMuqHrexhP0siiIzpOx29I8u /nzvIUiXwf4OnbA8lsQlAqUxKJyjmaIo1uCu/NflKGnOHCzvkLEcWG9ARedwjA3DdG46 PkQmPxtPijyO+qkScRl0oMq/zhU4nvq1ixN6TRFavNsvGCyc+ScNqUUh0fv7GGX9Egi2 QB/9OWvAXfLmMOEFsnz/PmN67oWcTuuDHzhMt7bzSWmEj8YGwWcYf+8fnm9An9vJ+Sd2 tvvw== X-Gm-Message-State: AOAM530qtKpEJNJjmmFgDRTryCkdNLqeya2472VZz/76a16aP/+kP0Wj JSC500CSViWBDL8G+4JYv7BFJfoqv0MIFxfV X-Google-Smtp-Source: ABdhPJwYeYmBSxdbo3VDSZ/rKwOVtmI8+WDid0CNYd0ItJHBQbdNXhNpooDmu5wd2iOlwXbRWHWt8A== X-Received: by 2002:a1c:3b02:: with SMTP id i2mr438213wma.141.1611678257693; Tue, 26 Jan 2021 08:24:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:17 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:07 +0000 Message-Id: <20210126162412.824033-2-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 1/6] pipeline: raspberrypi: Refactor stream configuration routine 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" Refactor the high/low resolution stream format and output selection routine. This change is in preparation of adding 1/4 resolution output for fast colour denoise. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 57 ++++++------------- 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 524cc960dd37..d9895c779725 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -624,52 +624,27 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) continue; } - if (i == maxIndex) { - /* ISP main output format. */ - V4L2VideoDevice *dev = data->isp_[Isp::Output0].dev(); - V4L2PixelFormat fourcc = dev->toV4L2PixelFormat(cfg.pixelFormat); - format.size = cfg.size; - format.fourcc = fourcc; - - ret = dev->setFormat(&format); - if (ret) - return -EINVAL; - - if (format.size != cfg.size || format.fourcc != fourcc) { - LOG(RPI, Error) - << "Failed to set format on ISP capture0 device: " - << format.toString(); - return -EINVAL; - } - - cfg.setStream(&data->isp_[Isp::Output0]); - data->isp_[Isp::Output0].setExternal(true); - } + /* The largest resolution gets routed to the ISP Output 0 node. */ + RPi::Stream *stream = (i == maxIndex) ? &data->isp_[Isp::Output0] + : &data->isp_[Isp::Output1]; - /* - * ISP second output format. This fallthrough means that if a - * second output stream has not been configured, we simply use - * the Output0 configuration. - */ - V4L2VideoDevice *dev = data->isp_[Isp::Output1].dev(); - format.fourcc = dev->toV4L2PixelFormat(cfg.pixelFormat); + V4L2PixelFormat fourcc = stream->dev()->toV4L2PixelFormat(cfg.pixelFormat); format.size = cfg.size; + format.fourcc = fourcc; - ret = dev->setFormat(&format); - if (ret) { + ret = stream->dev()->setFormat(&format); + if (ret) + return -EINVAL; + + if (format.size != cfg.size || format.fourcc != fourcc) { LOG(RPI, Error) - << "Failed to set format on ISP capture1 device: " - << format.toString(); - return ret; - } - /* - * If we have not yet provided a stream for this config, it - * means this is to be routed from Output1. - */ - if (!cfg.stream()) { - cfg.setStream(&data->isp_[Isp::Output1]); - data->isp_[Isp::Output1].setExternal(true); + << "Failed get requested format on " << stream->name() + << ", returned " << format.toString(); + return -EINVAL; } + + cfg.setStream(stream); + stream->setExternal(true); } /* ISP statistics output format. */ 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. */ From patchwork Tue Jan 26 16:24:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11012 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 12EBFC0F2B for ; Tue, 26 Jan 2021 16:24:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D266668325; 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="KTQ4W5Id"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8835E68319 for ; Tue, 26 Jan 2021 17:24:20 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id l12so17105196wry.2 for ; Tue, 26 Jan 2021 08:24:20 -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=bjrxqpQgzDBa9WkS2S3Mn4TK2H7Bqit1lomfmatnMZc=; b=KTQ4W5IdZvPL1Sq84nOUcjfU99Sk6btme6F/Efq823pqarj1r5Pd7KVS1b2sQVbOF1 MV4IR+ql+/j3bYNYLMV40Zkkx3MS963Y3ljx0LWjFoVhd1aztbwDNC8NCss0aobQ6wN7 PYowtsmHmY8ksR1YlnMQCTLAdSwEvjDabv86MO0sDI9nb6o0uUis0TlJR1cPLwUZJ2y1 158iDNDYLE/xhcJpzd4KQawnjQVDKjaUKEoA63/P5w1UNwIG5XmqxNuVA80DNtJKnEQC vJNt2W87I9mb3uaoG5lqx/f9jSELdYtBPMkByicaTTXy+CDPQKg8DOSrr1FrBMq5wglv zKKA== 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=bjrxqpQgzDBa9WkS2S3Mn4TK2H7Bqit1lomfmatnMZc=; b=sozB9MKAiKYIK4a084rojGwYWQ0k1Yd3btxw5QZhuO8ZgkoP4KOGXS2guqEUkpNpJ9 eaX7js2FwGY9cXVMfVGtjAqIaqJn97AQ5jSmj//rEAQ+7GHbeE6svLCeKkqZQOzLjW6C siO8Bw5N43ce4JdZC9e7dQtdrjagqtaNsh/BxMTkqpiKN/Qmmkk+OWaEI/APU22daI6f ONdehpLGb5tUQ0rnCtIj1uy2s4l8D9lM3tiXyC7xhBCP/76AqZEBTEgVaEmV8iyFz1QJ yCl9rHq6ojocBxONp6s5xlLLHBD0zXY3Yteqpg7nr3kNK68h0S1/Jnk1B1hn8jcz8ntd bLbw== X-Gm-Message-State: AOAM5327jno0gN7QrKrtuEBCM9kNedaw/B7cOSFJq9J+N+aBvZttfirW /ORujYZl8m5dTlx9y8+zghNh80Ck/8G9tKKj X-Google-Smtp-Source: ABdhPJwze0M+nfemMuY3tu8VbL/TAUtAeEvTKU/nOtZ7OcN/YXzJXsh81qcCtpNX0ncJ3FOzpsztzQ== X-Received: by 2002:a05:6000:1082:: with SMTP id y2mr6717494wrw.27.1611678260089; Tue, 26 Jan 2021 08:24:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:19 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:09 +0000 Message-Id: <20210126162412.824033-4-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 3/6] uapi: raspberrypi: Update the bcm2835-isp header definition 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" Update the bcm2835-isp.h file with the latest version available in the downstream Raspberry Pi linux repo. This change adds support for colour denoise processing, and the following downstream kernel changes must be available: https://github.com/raspberrypi/linux/pull/4069 https://github.com/raspberrypi/linux/pull/4083 The Raspberry Pi image must also be running the latest firmware, obtained by running rpi-update. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Acked-by: Kieran Bingham --- include/linux/bcm2835-isp.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/include/linux/bcm2835-isp.h b/include/linux/bcm2835-isp.h index 45abb681517e..94c3af947883 100644 --- a/include/linux/bcm2835-isp.h +++ b/include/linux/bcm2835-isp.h @@ -31,7 +31,8 @@ (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0007) #define V4L2_CID_USER_BCM2835_ISP_DPC \ (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0008) - +#define V4L2_CID_USER_BCM2835_ISP_CDN \ + (V4L2_CID_USER_BCM2835_ISP_BASE + 0x0009) /* * All structs below are directly mapped onto the equivalent structs in * drivers/staging/vc04_services/vchiq-mmal/mmal-parameters.h @@ -46,7 +47,7 @@ */ struct bcm2835_isp_rational { __s32 num; - __s32 den; + __u32 den; }; /** @@ -140,7 +141,7 @@ struct bcm2835_isp_black_level { __u16 black_level_r; __u16 black_level_g; __u16 black_level_b; - __u8 pad_[2]; /* Unused */ + __u8 padding[2]; /* Unused */ }; /** @@ -175,6 +176,31 @@ struct bcm2835_isp_gamma { __u16 y[BCM2835_NUM_GAMMA_PTS]; }; +/** + * enum bcm2835_isp_cdn_mode - Mode of operation for colour denoise. + * + * @CDN_MODE_FAST: Fast (but lower quality) colour denoise + * algorithm, typically used for video recording. + * @CDN_HIGH_QUALITY: High quality (but slower) colour denoise + * algorithm, typically used for stills capture. + */ +enum bcm2835_isp_cdn_mode { + CDN_MODE_FAST = 0, + CDN_MODE_HIGH_QUALITY = 1, +}; + +/** + * struct bcm2835_isp_cdn - Colour denoise parameters set with the + * V4L2_CID_USER_BCM2835_ISP_CDN ctrl. + * + * @enabled: Enable colour denoise. + * @cdn_mode: Colour denoise operating mode (see enum &bcm2835_isp_cdn_mode) + */ +struct bcm2835_isp_cdn { + __u32 enabled; + __u32 mode; +}; + /** * struct bcm2835_isp_denoise - Denoise parameters set with the * V4L2_CID_USER_BCM2835_ISP_DENOISE ctrl. From patchwork Tue Jan 26 16:24:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11013 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 AB508C0F2B for ; Tue, 26 Jan 2021 16:24:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 347BA68327; Tue, 26 Jan 2021 17:24:26 +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="eL9eQEv6"; dkim-atps=neutral Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C14C268317 for ; Tue, 26 Jan 2021 17:24:21 +0100 (CET) Received: by mail-wm1-x32f.google.com with SMTP id u14so2957052wml.4 for ; Tue, 26 Jan 2021 08:24:21 -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=r60/x9D2wFvPc1qF59Lv1Xv7mQ0M3HtfAuQgufi2E88=; b=eL9eQEv6EUb+iqTyv5wWf9Y34pZ0WTOigRwMAJgab/JBz3YKRTYW69+y5cExhtlfHN LWUbsaI0WC/IyNcPPLIhPKXHsEKIGPPwIzElygtecC6SEdGx9fysYgjvrHb4PzgFXY6L eg8+/1YVOeFjx3efDLOknBywDZAlO+jtjI4ZjkQ/r5DZx70XtJg1oj1Vc1szL0Yl3AWE 1tghjH+sOoR//Nift+Lxalnq23CgkeCT5++7KKlk/Gz01xlEvTLvDxpkMhTCjPey13Hh 3LBz+Vla5mg0tsaTP6DiDucJFGD9X7evRRnCuQfNqKe7ARIxCvqm9lx3HAQJ6xOlp4Dx /ugA== 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=r60/x9D2wFvPc1qF59Lv1Xv7mQ0M3HtfAuQgufi2E88=; b=nZKgAyls0DepXkN4YPCMJpUh/hU119E1YZf12GuANZQnCVaM8iUhcEzp5lrdfsTlH4 zSZpr32AEiWp+VHsr0zel8/afTalHIoJD+yc3ysMPVk7my6fgYRvP8/wRBNBFFrcFCCR i5k2I2iUvneFvl6Uba37Rq0fkP9SsiVfurI4SzUej54ybGQyXpd3LONIDEm/YQ9nMPKl HCb5VUWpGRlMaL9dfQnHcm/g03+KlUJ3DvU1iLC1T1lxJbuyoJ7pb/EOsLUiG5iQbb4e jGb0rS22EVqxenc3j4z3SnbpbV+KS8/mgB72VbnEbHe2jubuDbmqn0+/48yzHXw890vP Cjkg== X-Gm-Message-State: AOAM531LB7ID7HGlzYVBO8lLMB1IxU4HqPy00IVp/Po8APUAJLBgHaTf HFQDIZspk4Fs3futYFZJbyIbziQKXYKPVCpM X-Google-Smtp-Source: ABdhPJxytg8d9vOIWRIBtakDlZZrnvHCcUk8tM2FGCDWgZbxr532Osa9jSx18jHBWc8vGz+DSBDnhg== X-Received: by 2002:a05:600c:4ec6:: with SMTP id g6mr519081wmq.2.1611678261274; Tue, 26 Jan 2021 08:24:21 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:20 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:10 +0000 Message-Id: <20210126162412.824033-5-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 4/6] ipa: raspberrypi: Rename SdnStatus to DenoiseStatus 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" This change is in anticipation of the addition of a DenoiseAlgorithm base class which the SDN class will derive from. We want to match the metadata object name with the base class algorithm name. This renames: - SdnStatus metadata object to DenoiseStatus - "sdn.status" metadata string key to "denoise.status" - sdn_status.h header file to denoise_status.h Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- .../controller/{sdn_status.h => denoise_status.h} | 6 +++--- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 6 +++--- src/ipa/raspberrypi/raspberrypi.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) rename src/ipa/raspberrypi/controller/{sdn_status.h => denoise_status.h} (65%) diff --git a/src/ipa/raspberrypi/controller/sdn_status.h b/src/ipa/raspberrypi/controller/denoise_status.h similarity index 65% rename from src/ipa/raspberrypi/controller/sdn_status.h rename to src/ipa/raspberrypi/controller/denoise_status.h index 871e0b62af1f..06d7cfb91ae8 100644 --- a/src/ipa/raspberrypi/controller/sdn_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * - * sdn_status.h - SDN (spatial denoise) control algorithm status + * denoise_status.h - Spatial Denoise control algorithm status */ #pragma once @@ -12,7 +12,7 @@ extern "C" { #endif -struct SdnStatus { +struct DenoiseStatus { double noise_constant; double noise_slope; double strength; diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index aa82830b02b4..d8c1521a6633 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -5,8 +5,8 @@ * sdn.cpp - SDN (spatial denoise) control algorithm */ +#include "../denoise_status.h" #include "../noise_status.h" -#include "../sdn_status.h" #include "sdn.hpp" @@ -44,11 +44,11 @@ void Sdn::Prepare(Metadata *image_metadata) RPI_LOG("Noise profile: constant " << noise_status.noise_constant << " slope " << noise_status.noise_slope); - struct SdnStatus status; + struct DenoiseStatus status; status.noise_constant = noise_status.noise_constant * deviation_; status.noise_slope = noise_status.noise_slope * deviation_; status.strength = strength_; - image_metadata->Set("sdn.status", status); + image_metadata->Set("denoise.status", status); RPI_LOG("Sdn: programmed constant " << status.noise_constant << " slope " << status.noise_slope << " strength " diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 5ccc7a6551f5..220cf174aa4f 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -43,13 +43,13 @@ #include "contrast_algorithm.hpp" #include "contrast_status.h" #include "controller.hpp" +#include "denoise_status.h" #include "dpc_status.h" #include "focus_status.h" #include "geq_status.h" #include "lux_status.h" #include "metadata.hpp" #include "noise_status.h" -#include "sdn_status.h" #include "sharpen_algorithm.hpp" #include "sharpen_status.h" @@ -109,7 +109,7 @@ private: void applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, ControlList &ctrls); void applyGamma(const struct ContrastStatus *contrastStatus, ControlList &ctrls); void applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls); - void applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ctrls); + void applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList &ctrls); void applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls); void applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls); void applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls); @@ -899,7 +899,7 @@ void IPARPi::prepareISP(unsigned int bufferId) if (geqStatus) applyGEQ(geqStatus, ctrls); - SdnStatus *denoiseStatus = rpiMetadata_.GetLocked("sdn.status"); + DenoiseStatus *denoiseStatus = rpiMetadata_.GetLocked("denoise.status"); if (denoiseStatus) applyDenoise(denoiseStatus, ctrls); @@ -1083,7 +1083,7 @@ void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls) ctrls.set(V4L2_CID_USER_BCM2835_ISP_GEQ, c); } -void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ctrls) +void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList &ctrls) { bcm2835_isp_denoise denoise; From patchwork Tue Jan 26 16:24:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11014 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 304B7C0F2B for ; Tue, 26 Jan 2021 16:24:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E639068329; Tue, 26 Jan 2021 17:24:26 +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="rJUau6ps"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E190868317 for ; Tue, 26 Jan 2021 17:24:22 +0100 (CET) Received: by mail-wr1-x42d.google.com with SMTP id c12so17126277wrc.7 for ; Tue, 26 Jan 2021 08:24:22 -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=Rw87xwJK3AixxcnAnpe8KJpYLB6K0bNSkqy7I+Uuq+w=; b=rJUau6psBZpNwIiOzCEXvXI3AXFGDNmrGdQtguECqtHip+5oKeydh73skY12fTwr2d sWalhEtDN5uCBCOMg1k4DrfRcQhl8FrMVmgJNBTmtosVwnAcixhw4olGfpkywgaFnxfm 7/1KjFoj4Hh3itNbYvxPw4SKTnwp7tI/CO0DcMzAEqMbT7D430UMYqQVhD38lwsO9P3p sbNUywseLXgG9pB7fYfbmhV1Zn3Ht/bAWBhjLTfUgpAY1KVFnjefhh6+eN3T43EjkhuY 2si6nWvQZGAuH/cTcnF3SBeDaZ/hWHrvqjLzRy+tZaFc09OUH8t/iH0eC7Xxu0IfJ3Sh BZdg== 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=Rw87xwJK3AixxcnAnpe8KJpYLB6K0bNSkqy7I+Uuq+w=; b=Lc0Dzx3w67Mk2GVAJ0LmAWkZ9OVy/snYFnC2xsdDyIAAfqUtCLZvgyJUHGHfvdxm4c JL2HugqrljK+XPoyWvi+RKSYZQrYh7MuIgUrLS8j+UiRq6J+sq2X3E0g4R+A2/f6bA+G B2mdBu97fs+onWXrthaIy7IVFsvmclsbc4crPzWk07q0/dtf/swlaJy3JEThPqU9+BNC Gl1x5Ff6ZIddG8ibBZ3o7XqtHK/jIQhpyK00P7bzRI9HhF/YRM5A1EMcIMjwC5pF7SVp 2YhL4qtlVQctKdU08n0ijODusD1PlG0o32sqM3kFXxumDZKzbbeyaxZV+q2NB7Q+QXNv mYkQ== X-Gm-Message-State: AOAM533OdMD5IsCajcEm8gW77gelHpa9JftmzNKLNnVF6ytVjr1swM69 8aU1CNy5XpsYQtyg1ZyrlNd5kQhD/jQWv+ny X-Google-Smtp-Source: ABdhPJzKl4aIFtUavNq3EpvA0uVoST99vZBVSiQY+aXjnwAmjO9gbG5dvbjpBwBRFN/bgRBeyj9pFA== X-Received: by 2002:a5d:55c3:: with SMTP id i3mr6839224wrw.190.1611678262376; Tue, 26 Jan 2021 08:24:22 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:21 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:11 +0000 Message-Id: <20210126162412.824033-6-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 5/6] ipa: raspberrypi: Add a DenoiseAlgorithm class to the Controller 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" This denoise algorithm class will be used to pass in the user requested denoise operating mode to the controller. The existing Denoise controller will derive from this new DenoiseAlgorithm class. Add a denoise mode field in the denoise status metadata object for the IPA to use when configuring the ISP. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- .../controller/denoise_algorithm.hpp | 23 +++++++++++++++++++ .../raspberrypi/controller/denoise_status.h | 1 + src/ipa/raspberrypi/controller/rpi/sdn.cpp | 11 +++++++-- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 5 +++- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 src/ipa/raspberrypi/controller/denoise_algorithm.hpp diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp new file mode 100644 index 000000000000..df1f35cc9e5f --- /dev/null +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +/* + * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * + * denoise.hpp - Denoise control algorithm interface + */ +#pragma once + +#include "algorithm.hpp" + +namespace RPiController { + +enum DenoiseMode { Off, ColourOff, ColourFast, ColourHighQuality }; + +class DenoiseAlgorithm : public Algorithm +{ +public: + DenoiseAlgorithm(Controller *controller) : Algorithm(controller) {} + // A Denoise algorithm must provide the following: + virtual void SetMode(DenoiseMode mode) = 0; +}; + +} // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h index 06d7cfb91ae8..6064cc2c192e 100644 --- a/src/ipa/raspberrypi/controller/denoise_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -16,6 +16,7 @@ struct DenoiseStatus { double noise_constant; double noise_slope; double strength; + unsigned int mode; }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index d8c1521a6633..ecc7845eda4c 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * * sdn.cpp - SDN (spatial denoise) control algorithm */ @@ -18,7 +18,7 @@ using namespace RPiController; #define NAME "rpi.sdn" Sdn::Sdn(Controller *controller) - : Algorithm(controller) + : DenoiseAlgorithm(controller), mode_(DenoiseMode::ColourOff) { } @@ -48,6 +48,7 @@ void Sdn::Prepare(Metadata *image_metadata) status.noise_constant = noise_status.noise_constant * deviation_; status.noise_slope = noise_status.noise_slope * deviation_; status.strength = strength_; + status.mode = mode_; image_metadata->Set("denoise.status", status); RPI_LOG("Sdn: programmed constant " << status.noise_constant << " slope " << status.noise_slope @@ -55,6 +56,12 @@ void Sdn::Prepare(Metadata *image_metadata) << status.strength); } +void Sdn::SetMode(DenoiseMode mode) +{ + // We only distinguish between off and all other modes. + mode_ = mode; +} + // Register algorithm with the system. static Algorithm *Create(Controller *controller) { diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.hpp index 486c000d7b77..2371ce04163f 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.hpp @@ -7,12 +7,13 @@ #pragma once #include "../algorithm.hpp" +#include "../denoise_algorithm.hpp" namespace RPiController { // Algorithm to calculate correct spatial denoise (SDN) settings. -class Sdn : public Algorithm +class Sdn : public DenoiseAlgorithm { public: Sdn(Controller *controller = NULL); @@ -20,10 +21,12 @@ public: void Read(boost::property_tree::ptree const ¶ms) override; void Initialise() override; void Prepare(Metadata *image_metadata) override; + void SetMode(DenoiseMode mode) override; private: double deviation_; double strength_; + DenoiseMode mode_; }; } // namespace RPiController From patchwork Tue Jan 26 16:24:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11015 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 B349CC0F2B for ; Tue, 26 Jan 2021 16:24:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D2326832B; Tue, 26 Jan 2021 17:24:27 +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="TbIl6+o1"; 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 2C28068317 for ; Tue, 26 Jan 2021 17:24:24 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id e15so3323323wme.0 for ; Tue, 26 Jan 2021 08:24:24 -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=3ZYhPdULvZq/EnTHm6ygjpIfhRmMIoozxAeMmAF9z/E=; b=TbIl6+o1NjZgyX4a1AMjWqzM6NFKxkdTOCDbKo0AJCJDFYBVWKnRs9QuCvQAV+vW+M 7nl3tSCyAlokEoeXJgRBIIYNT+ItrC4i2wPCW8tcfaS26ILrG8O+iXZSikE6a1QNHSAw 9mtcY3yiDbAzTwXSUpREyxchRdpG151Imis/UfTcbcXOR+xvqr762eoxM0TMK+ndPOui Q9fNjPNW2lTqhJfCQqjkBf80plEc2doh+9lwfxf9HG0jc1zjT1kwBp0JIYblX0xu3Tcu YRpdbLBAyf/5EyGJ4mesyKsnRD6ECr9CFYzI+Sn0S59fKocMn4huyAekoWCcb7We3O1G YpJg== 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=3ZYhPdULvZq/EnTHm6ygjpIfhRmMIoozxAeMmAF9z/E=; b=jmhTfAzsEl+i/okn0oyJ7aJGRqc8xhYKU2KZ/D5qTZ8uXSTo1xZbxkRXpEgv9s5JPx jo+OaarJkHZvlkE1dVYys/vpAyPfIdBOUxCcDqcYfYbCIbxXcIR76La31rK0icwoS6S2 nnAOPCkD71ZERNlyxW1GKDX94iM+bMT7T/YDS6ZDM3j4VOSjaxYdEzYhLdQGatfEAtE6 6AKrJFsH6jJ4Rq1x5J3U3v273ha8T/8MbeWYotwQdyQJruCsI0y+QKWVy9MsKgJy5tjP 8m+GKF7ER2ifWORXcyWghXaf8f4yNLZot7nI9VGPr+NkswsypGNVxt7zZ9oZ0JtK74A9 qIsw== X-Gm-Message-State: AOAM531q/AVC95v4WZKRa2h1++9ZzW6/jlRStNba3WPCoiKhhPox8xsI fw+H8CVdjQe31xo6GETIQ+s9dwVujPwC/TIF X-Google-Smtp-Source: ABdhPJzK8uaWmxdIhNkvnOzbheyiyZ0oKCYTeXk20milo4Kf1ZA2NrOYb/xFc3GjsV/pjMih5QgecA== X-Received: by 2002:a1c:7f94:: with SMTP id a142mr450938wmd.145.1611678263653; Tue, 26 Jan 2021 08:24:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 08:24:23 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 16:24:12 +0000 Message-Id: <20210126162412.824033-7-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 6/6] ipa: raspberrypi: Handle control::NoiseReductionMode in the controller 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" The application provided noise reduction mode gets passed into the denoise controller. The denoise controller in turn returns the mode to the IPA which now sets up the colour denoise processing appropriately. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 47 ++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 220cf174aa4f..8f80bb80c129 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -43,6 +43,7 @@ #include "contrast_algorithm.hpp" #include "contrast_status.h" #include "controller.hpp" +#include "denoise_algorithm.hpp" #include "denoise_status.h" #include "dpc_status.h" #include "focus_status.h" @@ -565,6 +566,7 @@ bool IPARPi::validateIspControls() V4L2_CID_USER_BCM2835_ISP_SHARPEN, V4L2_CID_USER_BCM2835_ISP_DPC, V4L2_CID_USER_BCM2835_ISP_LENS_SHADING, + V4L2_CID_USER_BCM2835_ISP_CDN, }; for (auto c : ctrls) { @@ -614,6 +616,14 @@ static const std::map AwbModeTable = { { controls::AwbCustom, "custom" }, }; +static const std::map DenoiseModeTable = { + { controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, + { controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, + { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, + { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff }, + { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, +}; + void IPARPi::queueRequest(const ControlList &controls) { /* Clear the return metadata buffer. */ @@ -836,6 +846,22 @@ void IPARPi::queueRequest(const ControlList &controls) break; } + case controls::NOISE_REDUCTION_MODE: { + RPiController::DenoiseAlgorithm *sdn = dynamic_cast( + controller_.GetAlgorithm("SDN")); + ASSERT(sdn); + + int32_t idx = ctrl.second.get(); + if (DenoiseModeTable.count(idx)) { + sdn->SetMode(DenoiseModeTable.at(idx)); + libcameraMetadata_.set(controls::draft::NoiseReductionMode, idx); + } else { + LOG(IPARPI, Error) << "Noise reduction mode " << idx + << " not recognised"; + } + break; + } + default: LOG(IPARPI, Warning) << "Ctrl " << controls::controls.at(ctrl.first)->name() @@ -1087,16 +1113,35 @@ void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList { bcm2835_isp_denoise denoise; - denoise.enabled = 1; + denoise.enabled = denoiseStatus->mode == RPiController::DenoiseMode::Off ? 0 : 1; denoise.constant = denoiseStatus->noise_constant; denoise.slope.num = 1000 * denoiseStatus->noise_slope; denoise.slope.den = 1000; denoise.strength.num = 1000 * denoiseStatus->strength; denoise.strength.den = 1000; + /* Set the CDN mode to match the SDN operating mode. */ + bcm2835_isp_cdn cdn; + switch (denoiseStatus->mode) { + case RPiController::DenoiseMode::ColourFast: + cdn.enabled = 1; + cdn.mode = CDN_MODE_FAST; + break; + case RPiController::DenoiseMode::ColourHighQuality: + cdn.enabled = 1; + cdn.mode = CDN_MODE_HIGH_QUALITY; + break; + default: + cdn.enabled = 0; + } + ControlValue c(Span{ reinterpret_cast(&denoise), sizeof(denoise) }); ctrls.set(V4L2_CID_USER_BCM2835_ISP_DENOISE, c); + + c = ControlValue(Span{ reinterpret_cast(&cdn), + sizeof(cdn) }); + ctrls.set(V4L2_CID_USER_BCM2835_ISP_CDN, c); } void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls)