From patchwork Fri Jan 22 13:14: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: 10958 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 75424BD808 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 3C36C6827B; 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="AUtk3XPv"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E9096826A for ; Fri, 22 Jan 2021 14:14:56 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id c124so4271362wma.5 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:mime-version :content-transfer-encoding; bh=dWRbgbE+HncN05cFEYdg9lbeQWBZhpOTBcbxiMPzCu8=; b=AUtk3XPv/065qGvPxz8xQlLQ5mmzoYIIYIoDsHzTuv3I2NOzfTZk5qZQrHb5yNqdiv nQ+b5PX3JJ8FGFteqBRINtpoPf1Vs2DEMuwWwPpBl6HuHHnbw/PTRydPTYF35/1msD3e tkuBYWGgso6rBp78DHoGEFF0+4RKGaMc47yjVPp5+K/B++vRNhGUcz8cPZiu46ZtN+QS V8rxMS7vqgeGRnvyn2M2BLBwgfrGhje/h7pamVsfIuGow5c3UCAwWLWSZ0QZ9HybZYIH BVtpoicIeZc/1HTAIeyipwEeBd8jnLDRVFytWm8ldpXXj/watVgVxlazJ9r0tMg4R/Pl rtJw== 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:mime-version :content-transfer-encoding; bh=dWRbgbE+HncN05cFEYdg9lbeQWBZhpOTBcbxiMPzCu8=; b=UpR6+HEY1QCfpusggRia9EGtM3C0Q3ZR+EzdL+mAFXaWQm5WWQPNLCHBa+3NwTtym0 xCFOUp2YG8ih2Knt5x52tCut/GEEZ0//zcBll+Nuh8ystcPyEFcFR/Sejd2/Jzaawygk dK1T+VxE17apXrJ6OorCQ9GaAcLDQOao/1TWgOYhOUJ4KGEpy6ycIQHk0ZFo7SzVWoxx 4uxeZT2UZFDRQdqa3Ln5n5qvV4WLnDBqrjWQdurHz3fAdbx9EYBRbLZ8+YvOY+rDk3Vk dPVXIVpBz6wDzY9CJeOcebq32OCHtDmtJealH3LiRdNNOmg0raG1dF2nssF8HvC/UM7V f5AA== X-Gm-Message-State: AOAM530gpteSg2qJC7kO1mSitdQ2zZtVAl7WEd5Rs2RANiPQPWS7g2ev CKjed+sI6Orglftk1rRiCz0YugibR6gU4w== X-Google-Smtp-Source: ABdhPJxGdTjhZPzIbLZbBl3kIYvbVA94V+gb2Oizaf0ka4C+0KRmjalfop2A+Nfjq7gcuOFxbuHqQA== X-Received: by 2002:a7b:cf3a:: with SMTP id m26mr3991369wmg.55.1611321295485; Fri, 22 Jan 2021 05:14:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:14:54 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 13:14:46 +0000 Message-Id: <20210122131451.726584-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 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. */ From patchwork Fri Jan 22 13:14:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10960 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 2D078BD808 for ; Fri, 22 Jan 2021 13:15:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E64566827A; Fri, 22 Jan 2021 14:14: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="F8YKlKj/"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DF2CD6827E for ; Fri, 22 Jan 2021 14:14:57 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id 6so5054486wri.3 for ; Fri, 22 Jan 2021 05:14:57 -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=F8YKlKj/u+wU+HmX9udoUG8DQJ1HTe6ukLmaKOVjepc+ZKD+MJcuCIgwiYzj/aAABy Wpi2UXR5FAjmaEMxh/2W34gwD691cbN7qUmSwQ5361JZ0Fg9XmprSzbFi7cJDg6IfJ8z 6YAAK7rRyBhQKWP9PguWqPDVr5a+Ap8R9lYAOQJZB74QFOuOkxNEyaVT5ZJhU4Tq2xlj KnHpOu9VOv8h+8kcB4FWpErgetBt89/og8YyzzQuZiI7lcOC/uDTVE/7WahRKRYsRmWH cV4eSw5tl10P32j0zxfgXiI5adizCiRzhGP8nTX+6R7taFvVPmwzKaRcTJUO09Lpc3tU cQ6A== 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=gvDghyQhhSNlInM1LEaLQoDrcAadoFK2Em7ORZnzG348WXSRje7d7He8ZuHwxooGyx z2nvqx4ImlG1veqAQj/wyUiLjvOgsBlb30NzJJyKMPx3Dv/vYPLm9Lk+/Q/DGrHaKJ9S EhlMD1+XyuOKi7cB7YYJ0rj5geEihkrDWzTFT+AgkyB+jcfd6QvsYSgrpyOT0w2+cQqa JZsx++Qw/iNycJmCFV6sai6xS4/Y+5ZGa+Z8cM/94Mt3OKZKv3pvaqtvn2i1hrNNXkTn ltYbAbjdyBrz8Q32Xet3Q+aiYlfrj7Vrkvtah3k8zEz+5ozrvgjqPm7Lg/l2imkIDWhw 2MWA== X-Gm-Message-State: AOAM532KP4vHpyInm2O+aTypLzBvu0hFELWFn4pZeDowxflGsrIjNytW I0BtN8mqUJ21POmJOteKK0tRxHJYgDvA3g== X-Google-Smtp-Source: ABdhPJyQPFr3qPbXncCC8KBVSinSlrZ+mMRSn3ggklXjQ2dIwtM3CBqQZ5c34kqGF7AX6fXFOZX80g== X-Received: by 2002:a5d:5549:: with SMTP id g9mr4792020wrw.244.1611321297397; Fri, 22 Jan 2021 05:14:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:14:56 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 13:14:48 +0000 Message-Id: <20210122131451.726584-3-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 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 Fri Jan 22 13:14:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10961 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 8EC04BD808 for ; Fri, 22 Jan 2021 13:15:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A72768276; Fri, 22 Jan 2021 14:15:00 +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="P3CtaZAv"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E20BB68275 for ; Fri, 22 Jan 2021 14:14:58 +0100 (CET) Received: by mail-wr1-x433.google.com with SMTP id g10so5061408wrx.1 for ; Fri, 22 Jan 2021 05:14:58 -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=P3CtaZAvfwSD845bTsKBkduICCizP4uMck2N2wevyYJOoKvaxPzjG6XELU3cZfals4 HQOO8K7CZevZRg563Bk3nlhZMasZjzM/NZ1hakwjnjzag8JTKjepQKaXkYYn3RkagFhh a4lCEHUwSRjilU6KDIdXvOEyu9zbKEObEqcvLyWe8DpUj5pb9WJAHmLROrOgx0YvL49r vB1vQWAYYP26FL1B5WTdj/00q6q50EXPdll87IwFGdBODl4b5pBn6/MOjM3ekpYi0WZX xFQJspeBatd4tVzzQAu57IBrYUewpAkTOfgJyArDILvy8ah5u1RtVss8sKQT8sPgfsmR 2MGA== 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=NW46IgKsB84I1a305RbgdgNu5Wb72L7X8iGLFKm1F+8paoxSCQWQCLiPoBjcGWuu4f aQ18AqPxLdqLXEaL0HMjD61WIqybECe8X9EoCQRppS1Md+dNjVARiN/T2T6QXw0VuBpG L+/LD6kCfUZ62nMdSnmnqQl+VtH/Sr7cJHAzVSvAhqnCUcQxEJS07etbKkSZTiuYEDMG dLUuvBC6fiQEaWvqGx27TwSQGIcrwbOzm5ONHYQKdGTSNbWre6FH4E9Wl3N7w4KhBIaU BFKgDUNgpv65g2GL375rnD5pB4/lBjaeAjgXFL+YfKl2gBo+X16/QhlbBYYvsLiOY7tn +yPQ== X-Gm-Message-State: AOAM531Py8NFM6H+2YX98GQpxeNB0JJuaFORMQ1H49oKt3nsXdL7IDH8 p8wgQaAztMkXCWbd2rsd/8DOKFJE1bnXWA== X-Google-Smtp-Source: ABdhPJzh0ZZFfS0lJbUGaCVAzD0vqaJI8X8vQGvv+TQ+NJ8yaRUyPKbsKEDcF947h10JMp+yx4ZUvg== X-Received: by 2002:a5d:44c6:: with SMTP id z6mr4509391wrr.306.1611321298416; Fri, 22 Jan 2021 05:14:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:14:57 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 13:14:49 +0000 Message-Id: <20210122131451.726584-4-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 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 Fri Jan 22 13:14: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: 10962 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 198D1BD808 for ; Fri, 22 Jan 2021 13:15:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC8786828A; Fri, 22 Jan 2021 14:15:01 +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="YfvDoCZV"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F232468281 for ; Fri, 22 Jan 2021 14:14:59 +0100 (CET) Received: by mail-wr1-x42c.google.com with SMTP id b5so5033625wrr.10 for ; Fri, 22 Jan 2021 05:14:59 -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=YfvDoCZVFvTgZG12KvaRk50FRJvGi8PsdVEV76pufkHYAg1HZUtuM/K2tURRGoUrAM r8EJ5eZXMLo3cPEziQJhn9vNKfokEUXqV3SGQq/4VJyWbWs8MoyMPiXB952cbmQCsGjp dIHJdUhO9Hk82Vi/LygsleAw/5aEPnO3sulRoVu4JYlCHRFt6xPlJsPrHovdTFAOUQOB ETBgQSezfZ1OUBkCa7//oOmn/71LCcDSh0Yy9+MQnv6df/TBaO+LMTryBE7pNL8PjPRI ySJwCqhXTw2EYWkiUlJS6IndUrY76OZ4TxP4nyfQTQ0eeVnGO//NQXRclgor5QnLJtkS PdLA== 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=ELq8DdF1kXXj++Sp9mEEs3e/MUOWM+wTadZc9/zauL3l+IOfvjTubqSyX8QJsm/9JJ 38LL6nrG47vb1YlXJ4mFL6SYCR2EjWaXhT6w5CCOJHH1BP5qU/zwTD/UTupoiWg51+6Y PBP6RQkfejyMwqgPq7TSL5kgKKi5thoLz4XHn4/w+xUjcYHqR/m1ME5qpdHA3VaZ0+b4 93vswa4GRLdJxOF5VXCN5USXevCGXelpUZu60zqIzawc67vdO+o68jFsmWjh6wlrApJq j+txewpLGI07RlDga87Gsog5IepI7IPASnMnlFYzpTi1My9YGT5C/E325fNDNQEsO5IP lF/A== X-Gm-Message-State: AOAM532Wi71zOxBLkT0lkheNsuflN8lFYUO5Sk/zs2schC404qxGXTop Ei7JETVS2ApI22GeuN+te/SoBZg+aZgQMQ== X-Google-Smtp-Source: ABdhPJxmE6q9cjWGzs9kmVYDCDovn4L2nUhi2GtZRskdwg3whUsrjK52XWrOOFAiHu1Dp76uryINqQ== X-Received: by 2002:adf:ab1d:: with SMTP id q29mr4314257wrc.415.1611321299441; Fri, 22 Jan 2021 05:14:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:14:58 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 13:14:50 +0000 Message-Id: <20210122131451.726584-5-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 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 Fri Jan 22 13:14:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10963 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 7A279C0F2B for ; Fri, 22 Jan 2021 13:15:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A6EC6828D; Fri, 22 Jan 2021 14:15:02 +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="YA7Xaj1K"; 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 23C696827E for ; Fri, 22 Jan 2021 14:15:01 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id i63so4274981wma.4 for ; Fri, 22 Jan 2021 05:15: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=pVCqr+gNQsx9WfZ9sJ8IgMa0wiB++uHzGUSNLzPguWI=; b=YA7Xaj1KqU7u5TjBAPkCRsaqvCZ9wZrFrUko9iPAEyQlQBkDVrEubvYz6V+KLJdWwC +JkWH1Mwo1rXkGyhCWw9sUn8RCcPowGxQPdR3KY7t0/hMvzNtotacY3yQgJOYc0XDptr aZ/igE3MsyI+GXx3AZRXXbyrLsypmLRcc0oS1sfDm5h0wiWFmqpbousJR+T1iwAFS22J Uy9Po9u0YytTgACpcjuSJPaKzo7yPkz01v5Ok+NKVsE4g6JlwMR+LAy77aq2CGYw39pv irfuc85//wYgABFzLvvXimsPJ0VpfliID67c9zkROqp3OI+WQOZaH7lxLr1iufEAYvfw 5fmg== 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=pVCqr+gNQsx9WfZ9sJ8IgMa0wiB++uHzGUSNLzPguWI=; b=huvcfulilUD77OrprV4sa/HOpbA/Oyy8881p8OrWNGzhZla760zju/NzxGlVsN5Ja6 vfRmMCdJIz0pMa35EOsVBUB4dTrwzXzyxT21Yxk6rGlizpE+dqfFLycmjL+ULZDTPj3F LZtet6g5SXSEK7T6iDiQrhk8sY0lxSB9wd+rSg+OMRjLlxlmh8r32CKdJL9BKpfwnx4x PQYTnqmrY8FVRjXD11pIuicQYRdntpTrSTJk1va/ohNXaZ7aR9ePTF41UkD+0MyTGNjT NIk1Yb2APNmYpRzo3oYTonCCCogt2hm3UUhFQuqR4C9w9ZYz+ghc44w/ESIwJoedpS8j nixg== X-Gm-Message-State: AOAM533KRc5c5CKwZ9hMXV4X+Qsf6xtPZJp8R3G+fCGREsAIYK3u5xuN KogvhX8uU6zK/L55dk/I3wwEgtCIBOhvNA== X-Google-Smtp-Source: ABdhPJwWjkXGSLhokA1VG9wh4l7NnC6iX/cwXDACZByHDLuifF7oQDJFc/B+kZoevGhY/Y9/2/HgBw== X-Received: by 2002:a1c:11:: with SMTP id 17mr4051819wma.12.1611321300574; Fri, 22 Jan 2021 05:15:00 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:14:59 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 13:14:51 +0000 Message-Id: <20210122131451.726584-6-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 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: 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)