From patchwork Fri Jan 29 15:11: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: 11061 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 17433BD808 for ; Fri, 29 Jan 2021 15:12:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D859F683B9; Fri, 29 Jan 2021 16:12: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="qRavClEI"; dkim-atps=neutral Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 523E5683AC for ; Fri, 29 Jan 2021 16:12:00 +0100 (CET) Received: by mail-wr1-x429.google.com with SMTP id v15so9205069wrx.4 for ; Fri, 29 Jan 2021 07:12:00 -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=qRavClEIUZL/rkhoWiuC2LiuO6fBB4Q85NSW0hF9FgW4Wda9a7BP9mBCHxFCeobaGG irbUMUxf56QTSxvWgTIheeYL1Tme9FItjdB9MKAPt7lPkSO3nHYlHd0St6sbQGv0kti7 xBqhUB57AoNZ6yVgHzqGyHLQdt7zL6ZRBlvep0NDk7+JonkqR9aeax/aPw/m1uUZD25D +Xc3xP4taR0H7yMZcDemKLS7eVaFVO77tLQ9Uz2zJSfvNeWiUgXvy0tE2jhfwt4Pybj/ erVWPO69xmZ8TXQym4kovnzTUZCWjoZoKqkzUSWyPRca+rnEtp9LzwFDKdOulW1/PXTl 6bgg== 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=W7sA28Y45AxOhyrGHw1TSmRLs6LB2+dSBOkYSUcCUpDx+XD2X4kJvqHIC+S3sNhvLj oymYIbGqgweS6Q5ld0bRQraHMQJJZvtFGY7S5HsndHlvU3FrcunzQRLzKUw2TvRRCYN7 n0VkgxIz+G84hSNX28s7s4x17TEtQh9baUyuUbvaxySDYGhHHAHySilrt4cDWHi0sblA 5Lsi/I3puvyTtxFEwTJJu6NyeTrpfa0atAGCPuIsBvAz4mAlCrafPw8EJvUMgmCB9XeI 6ZR93Jf6OalZhh4iOczuutXNei7LGuqTnSsYkU1FTtuBAUcV1pfEm9aDz96jUSzZ2t0v Ek2A== X-Gm-Message-State: AOAM5320xTHVHHgJd7u5ZKqvcnqyWbMDW3KCbBK+xb+Nu+6FOpQ2s+Lq eNgk1ag/Zjm9tRGE76nrlrcUc1p4UdZSJQKc X-Google-Smtp-Source: ABdhPJwLD+HYqowTBlCspqLvipy9TbG4lpyhlspMxNuygK3HkfIefmwMAoQf4kzFZaruHHPdYxIuHw== X-Received: by 2002:adf:fd52:: with SMTP id h18mr5065920wrs.295.1611933119522; Fri, 29 Jan 2021 07:11:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 07:11:58 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jan 2021 15:11:49 +0000 Message-Id: <20210129151154.1051163-2-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 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 Reviewed-by: Laurent Pinchart --- .../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 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. */ From patchwork Fri Jan 29 15:11: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: 11063 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 79BF3BD808 for ; Fri, 29 Jan 2021 15:12:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2D0A3683C0; Fri, 29 Jan 2021 16:12:05 +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="SYtjOHn9"; 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 21E44683BB for ; Fri, 29 Jan 2021 16:12:03 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id f16so7093835wmq.5 for ; Fri, 29 Jan 2021 07:12:03 -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=SYtjOHn9o9XUAQzSp8230RQXlTowDmXY/7zMw9hFVYxQp++A6LA5zN+bVYptIEhTLJ vQGLZeabciUUBx0Cvdp97oITo4NgDH35eMV8t7GvHhsK8wW63RKJPUtxM9j+Lv+mMVeb s3b/UKXkQBsfZ9v5diwqhi8PCilaRgmvzJT782rYju1T5AznufG+7TlCipYczdC2O7BK Iz8OI50xVuLvSmvEBOCdcjZ8Yp0PEkPYUl7VEP4YOdAfSO2rEgzt/btJWTiQA++22Svi JiA8NUy4i3LJYDtg+ODDgsIdr1ajs4faxqC4KAlF+4P0WISiWWuyvrzoHaZvLM3MC29X 2zhw== 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=mACV97BLPg6Ou7qbTIj3glNK2nQdRcb1ecn8nhqoZ6Gw+HGVP2la7y+BFepJMhhr// g89cvV4zmXi8GLKujEVkpO1KXlzOocAdwukgZNNIgYdwJRcbwSPTlrA1qgHK7jF6bpAN U1DaLEzUWrUnxv0JifZ+fDrCb48sSWkPMIYXS4gviCFETZLLYH19e/SV/wucFP9a0mAx X3TTzFk3g5vuauuaFmWI4ptMbFTzM0SrB3qCP1rovURSDqsmm53DFo2QFgJ1wK0KwxRh hd6GSN3RbmxPMfesUtNCpXni06qy2Dw+Xu0S8aohOBVTOdeGXZLi3O7gODjQm5UM7Yxm zC4Q== X-Gm-Message-State: AOAM532AjQRYVPNMl9jfq/Y+97Zs9H1pvjOF3mdDvY+4sCuk/I3YJG22 quxU/kXSuaTaw585K+Mg3EY9hmjcQPflISKZ X-Google-Smtp-Source: ABdhPJzfzFItz3R3dr48sfv8hebCVa5FfdzEjRgUrq10RXsUSNPs35EmaPsx09A8Cut35/RLDVBo2A== X-Received: by 2002:a1c:68d5:: with SMTP id d204mr4273367wmc.178.1611933122552; Fri, 29 Jan 2021 07:12:02 -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.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 07:12:01 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jan 2021 15:11:51 +0000 Message-Id: <20210129151154.1051163-4-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 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 Reviewed-by: Laurent Pinchart --- 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 29 15:11:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11064 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 EC6DCBD808 for ; Fri, 29 Jan 2021 15:12:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B23AB683C4; Fri, 29 Jan 2021 16:12:06 +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="KdfPJVr8"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 10B04683BF for ; Fri, 29 Jan 2021 16:12:05 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id m1so4179784wml.2 for ; Fri, 29 Jan 2021 07:12:05 -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=KdfPJVr8XNYFDfrt7/61+O9Bxws4nl34oX46ltimWgRrx96BQTFzYSxoJwkarNi6tu ZzM7mleoYKxzS8FIZxlBsWns8YvTpw3wJZsi1C4J1SJHDi1Ybl9SBOpmsxwemfcJ03Sn K9n8kVI79lPC+bAaRB8OwuoGxG76m1Oreps/TmSsVIxKl+bvOo3Xw5vGStgnGjimLwFF o7GnY++/m42hxJyBG7PA3/DaHCDxbZnMqJiQnXfteMzzpw7NOQ1OsDhi8sQF+hCmzPNN +t/6fswx4Ls1HfKOMhFFwvjxbU0/+bH8R3+rYSi1EcQB+qn6YbAV5zl5Ud4Xn5DzgYj4 nFoQ== 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=eKEG1n1fJUYhEGOowgEkQ9WQxuacqTT9DwAlKdwux+X5LDpl54jjV9hNkA8g7HQ2kX Gb/hCi/cN7X3JI/OkYm8Y7mB4wA9gxBXPG7zcrw2uDmLTtEpyS8GmnkOoPo4fpW4nGEa jEYMRR/8l+zvLodmSt8Yr09vEHR5WA3csMDwt3za+IdW1w2BNL5dVYRixji2IFrOjYkf buuiNTjN4pBkd11Kal48L4IhQ1zH4hR95PjtntQOZD1lq/4q3MFJwTzHHBtJ8f2d+FKz lM8aCgxnez8m0TkyUCWiH6/sjp4ckIBbVMNMuRSYzrRX+V2tn5/rWCjkoIskfMApPxlj buCQ== X-Gm-Message-State: AOAM533WpX1js+A0atbEQ11wmJS4RXOmhbgXAMnVRMD+PF4XeMnZr2VT Ducitk5LClMTaa4dMdGIXHoNeR7FTiVvu5MU X-Google-Smtp-Source: ABdhPJweOnvATuoaV2jQEQnZT5SkjF3w6Hd53eFsrgUxQpTdmUwo/2Oz2lTHtnkWWheOyBEklesC0A== X-Received: by 2002:a1c:1b83:: with SMTP id b125mr4327363wmb.8.1611933123893; Fri, 29 Jan 2021 07:12:03 -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.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 07:12:03 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jan 2021 15:11:52 +0000 Message-Id: <20210129151154.1051163-5-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 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 Reviewed-by: Laurent Pinchart --- .../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 29 15:11:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11065 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 44C1EC33BC for ; Fri, 29 Jan 2021 15:12:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 15CBF683C7; Fri, 29 Jan 2021 16:12:07 +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="RYPldepY"; 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 A4EB4683B6 for ; Fri, 29 Jan 2021 16:12:05 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id m2so7109775wmm.1 for ; Fri, 29 Jan 2021 07:12:05 -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=iwnNrKsV/xYxZPRzhrJJ1mgdq4Q4/EZMa12+RsX8AcY=; b=RYPldepYdEp5yoGgDk+EflFCTV8gYJ+G3xcwP3kCS3e/DB0LQp0m6jJTOCYbBXcwAM c17JECt2PWpBvAiuYg52tDiaWPnUvWACXkvDm+DPmEP7YbeYWbjMaiEGh/gUZOGoOcC8 CKPH1qTMHb5r72TPj/He2KQO1nIV8FdumJruugkxAKyE0rau+o9FxhVMNhbfBHzNYuj9 q5q4ab1ta35k7OhaUTMEAzK7s4RfHG6NoAih9wAv259JeJJ5QETR+7PEOZuqbo7LJbGb c0kONWV66MRxyiD+uybUndr7rBEqVdTY5Xrr0BU/cOMZy8CsLyNtzYize8trcoIHjBoG SyXw== 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=iwnNrKsV/xYxZPRzhrJJ1mgdq4Q4/EZMa12+RsX8AcY=; b=pO1EaQveOw1SEmp4wjiOtzmsjAR4EhiwSmwioRtL5V8r0oDSHNTTIpzI/1TI5yMx3K ba+NdSOKCXGLsu6A8iVP5pdEVViuzgNJX7x6ST7Pzenu1zs9hjvVjc7Zb+hG1YAbuUnA g13RJIEN2iZtQxvUWr6ygvP7HrfefI3g7HdpcJSkK/UR8Uf1tlMcE9Vw7hPEjZnqNeFI MiZrPaqHKM9SNf7PghNNA+z1JZ0YSMFH28UlZZD0AvtouDcq4cgWXP7BzdQKJZJ2HB4X Onn6CtfNxRlkIlgxXGsfM4wcpMfOw4XpfKYLGIajT+J/+Iw+6do3lUC7uj0Ykdt2vs2E PahA== X-Gm-Message-State: AOAM5308qcIG88VkboI8Gs5AvuBp2ueVurSafoE6olX/2j3wE/931r/l HsgBFfXoQa/0Z3iUKn1czcA90xbwYGhiwEVN X-Google-Smtp-Source: ABdhPJzTiEOThmcvOqpRMCP9EwopYWOj9yjvLtSvZBWu3E1u0D5OyRMHudUUi1NDPL/kQLNHAr55vA== X-Received: by 2002:a1c:3c04:: with SMTP id j4mr4262068wma.147.1611933124918; Fri, 29 Jan 2021 07:12:04 -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.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 07:12:04 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jan 2021 15:11:53 +0000 Message-Id: <20210129151154.1051163-6-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 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 Reviewed-by: Laurent Pinchart --- .../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..39fcd7e94df2 --- /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 class 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..8e66fc7ec8ac 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 = static_cast>(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 29 15:11:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11066 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 BB325BD808 for ; Fri, 29 Jan 2021 15:12:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8C191683C0; Fri, 29 Jan 2021 16:12:08 +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="rXa9LedQ"; 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 D4637683B5 for ; Fri, 29 Jan 2021 16:12:06 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id f16so7093987wmq.5 for ; Fri, 29 Jan 2021 07:12:06 -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=LmT4odllwsOAcspD1V4FNjd+YRe6YykQ2WFPVm9Zw2Y=; b=rXa9LedQ2IYmeIAbrEpK/MCTPh8oDLIqnWyXTFV/kCOsu3Qaa8WNHJmJvK2NeuEACc 0D7XByR2/FCp/SXZAEduo4GC/uOavtLa4AMHcZsw19dZdpGMF5+8TUeiVeC6GPwpwxUu xYjDfpUv/5Oy96gZ1zrSsVQZjMUGV5UL78IpdTz9BoS9xtfM3c1b+ZqIdxObH3a7VjOD IYpi+9+kGvN9OIb6o1sbTiASHc/9TgZ/r+nltwnmzOCOayftoFOuF1bR7qehWAgCgFbe UfmOHN2QT2IIFSqlN0gaJob87RDJCW4H3m9jTGfeWjhKMI8So4rKDe5tovP293Etz/wB pTAQ== 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=LmT4odllwsOAcspD1V4FNjd+YRe6YykQ2WFPVm9Zw2Y=; b=Tw4lW+VCp1EzPWph3TEFnx92NF8QEIm0EIy+wT11CcTajuHWdIbqIEfd7wnvQ07KUc rBlgw3BzGchpgccCgQi9Jmcb3kUaC/bESXMSFYf8gp3Lcn3x0CJEVniyK7x31rP9AA/Z KM5jFQDAG4/StQbBqLqMbX9RXjGTwhOcQm9vAfNoe2c9KeD+0NVNS2ZwjNuc6ihVL6St nDVPCVUb0E310CXrL/smAJVyjiDTqDKrAN0DYMdYsSkmJzAtC/OH3RFzyvMTaFLB6j/b gILr4dU/CqWnEFVqQO7HSYexWdPL36A2Cm37rx3xU/z0IU1eFGzPj2OC3977pNmAEgkR +u2g== X-Gm-Message-State: AOAM530uWCbBOacGKzHvjcGKwqgTvDI4n6Qy9mnUdf6Vo8bOK/CPMgeQ 8li/YChBOd2yuTHG6s5l/hr1k3Hld7mDgUKz X-Google-Smtp-Source: ABdhPJyvAdQC1C7oF4PnFc4fj3r9hGZXDOC4oSlUupZCnVzeZO1Heg1EpyRKpYOaRBEqbW19fcqZxg== X-Received: by 2002:a7b:c246:: with SMTP id b6mr4340791wmj.118.1611933126297; Fri, 29 Jan 2021 07:12:06 -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.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 07:12:05 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Jan 2021 15:11:54 +0000 Message-Id: <20210129151154.1051163-7-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 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 Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/raspberrypi.h | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 51 ++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 1de36039cee0..3be79fc5ed73 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -66,6 +66,7 @@ static const ControlInfoMap Controls = { { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurations, ControlInfo(1000, 1000000000) }, + { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, }; } /* namespace RPi */ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 220cf174aa4f..862c52bde082 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,23 @@ 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(); + auto mode = DenoiseModeTable.find(idx); + if (mode != DenoiseModeTable.end()) { + sdn->SetMode(mode->second); + 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() @@ -1085,18 +1112,40 @@ void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls) void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList &ctrls) { + using RPiController::DenoiseMode; + bcm2835_isp_denoise denoise; + DenoiseMode mode = static_cast(denoiseStatus->mode); - denoise.enabled = 1; + denoise.enabled = mode != DenoiseMode::Off; 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 (mode) { + case DenoiseMode::ColourFast: + cdn.enabled = 1; + cdn.mode = CDN_MODE_FAST; + break; + case 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)