From patchwork Fri Jan 22 09:25:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10945 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 C7EC4BD808 for ; Fri, 22 Jan 2021 09:25:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8359D68234; Fri, 22 Jan 2021 10:25:45 +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="BzNDN7Fj"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 189E56822E for ; Fri, 22 Jan 2021 10:25:44 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id i63so3645789wma.4 for ; Fri, 22 Jan 2021 01:25:44 -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=1n89ZRC5Vh+k3ELtf1Atij889tc9bzPmkfqXvkbD0y0=; b=BzNDN7Fj5Oulw9csNipRJaaCVFAi2WdmMwWZZGy7O11rfZ3NC5mG2SMyO8tQb/j1aH VSRhNW5tkcbFf3Pua4Y707AwXBcYZ7/ynbKtN5EBuINSeKi+zGEjRAlP51SekN+ZJeQW 76S+RvOaQxntJFO2vYfR0xlEM2V/bkmsvr7/+CzY1dQsFUuNVRHJ+GXUT9cWAIPkiNfu RciknD/FFmamtUcrraeDe0Yt4O4a/LImhihYp4eFi9g+0tdkhXVO0UK7J9Vb0T9TL1KA ZojbYoiMlw80b4enaeY9kEGJSYuEIV25AdqVWvj8REtqjbii8FrA0upytRuhCFrLWzqs KD5g== 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=1n89ZRC5Vh+k3ELtf1Atij889tc9bzPmkfqXvkbD0y0=; b=FMmEEMJsvJKQZXaQjl23zzdFD5l91gVu9UTwu90Cz7zWSnt2Thkk9lRtnb0qrGbiXL grP93ImFZsIN2vu4Yi9wmxMnKe6fQpt/SFwCP1/vlZhG9aeAsYNIuxEjE4SVNLG7B7nL UP0jdyFZKT4ANYA7zGAQVaYW5qIIkE6/o6nOTvpoZNQVYUkiEUm3Z9dZxCKDnV9lQuk+ EvURdUV7xnNRc3y3aSLOTpzmSjprRMxA1QlGl1d1SiYJsHOGplFz856d4dbIEovtkIhE YE5PGPWG9jXWdmegLaqyNE2xBYcmIlLrd7pIU5bMkvMiPhSRs4g0G0/PrWtMO7IPUnSd w5Wg== X-Gm-Message-State: AOAM530Gt/riw8NwR4fErcrsirWz5/qUS7YiX0yqboNo4uGt62gl4u+K eZ0txdelIOjag5qG6Y1poyWYELf6ysfzag== X-Google-Smtp-Source: ABdhPJxqD1znKl5oKHElBjBqSJtD/wMi9ouq82YQF3OVtl33aR1K2KOq2hf+mNsEnerXjv26u9ctLA== X-Received: by 2002:a05:600c:2255:: with SMTP id a21mr3017444wmm.79.1611307543548; Fri, 22 Jan 2021 01:25:43 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:42 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:32 +0000 Message-Id: <20210122092537.708375-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 --- .../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..7e92f7669126 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 to set format on " << stream->name() + << " to " << format.toString(); + return -EINVAL; } + + cfg.setStream(stream); + stream->setExternal(true); } /* ISP statistics output format. */ From patchwork Fri Jan 22 09:25:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10946 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 16620BD808 for ; Fri, 22 Jan 2021 09:25:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D5C9568235; Fri, 22 Jan 2021 10:25:47 +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="gLyf/Urm"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A46468238 for ; Fri, 22 Jan 2021 10:25:45 +0100 (CET) Received: by mail-wr1-x42f.google.com with SMTP id a12so4384268wrv.8 for ; Fri, 22 Jan 2021 01:25:45 -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=4t5pQWPhDpMTniEtHAIBP1ASHlzXWrJc0UXCliO3GZg=; b=gLyf/Urm33Hrl1kN4Ykx7cLMXMWUGLs9O+3aLnft/6DOFQirGeysKUzpuN2jnSz8Lz H6e60ICK5eqirrw3qIiVX4leQWitRKQe0Yhp3JDfqoXIt/iq3t8gJypv6wMmoHyF9xVK J4Iu9A6Cr2tWDDXuLy6sjR/P1pwR3LaIFTFhYvdx39ig85ZGQZpjr/uShe+RRa4bCQq1 XOCDCJguG+r5IrZEQ1wVcX3Ewx+sNDSe4BUp7uLYxro+hIdZnAGD8dGSXnChPOikhWfL 3DnxyfMqMsoOWaU9xZ8NpFWPMfdvxz8HA6JX+DEmnNeWKyG57ekSkdxdE6rMwSYFT79h WzcQ== 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=4t5pQWPhDpMTniEtHAIBP1ASHlzXWrJc0UXCliO3GZg=; b=nXF3uplsECMP6vRyk4PCyymFMHYhLuvrOfb4QmYY2VjpTfj68TriZGIzCk7pFVQxca MWANhWXWzE1Fz6hCtndeu1tn810flJ35YHxcsiMMUqsriHWG1M+6GrVJbRKzn9ZExHrE 3GdRTiPFvKp5bUENrZKLO5N9Ud5RYiQyRs5C+qsPg3eFEw1u4kkwAYYP9/+zHpmlLgbM zUGG0p4uz+hrQpJkf6k9VsfmaKvq/k+7iTy5DUB7yInpkJlqL4UnyWfMdvwhG9QXqajX sIJ8Q1tzENxT0efgwIs6MKizduiG1LH2ij+j+bhEnE8RLQ6ZmBVztAFzff+QxwViex6/ lCYQ== X-Gm-Message-State: AOAM530MzzAv9jpxxDKfJWrh4gnCPUNStr5rNiqrzz5IHw7e3B1gFxD+ 0WSOeJjWuj/wZLgGq8z16vGBMX13CAR3ww== X-Google-Smtp-Source: ABdhPJztsPDb+kZ6GeGFzsOK2Fze+gyJnYKazJ8LRLTyDpn8DxrG8y0/PdSpK+C+MtUx24yu0n48tQ== X-Received: by 2002:adf:ef8b:: with SMTP id d11mr3614909wro.156.1611307544686; Fri, 22 Jan 2021 01:25:44 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:43 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:33 +0000 Message-Id: <20210122092537.708375-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 7e92f7669126..a0d3ac7ce49f 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,32 @@ 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) + return -EINVAL; } /* ISP statistics output format. */ From patchwork Fri Jan 22 09:25:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10947 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 70467BD808 for ; Fri, 22 Jan 2021 09:25:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F1D268241; Fri, 22 Jan 2021 10:25:49 +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="gSiwM3yk"; 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 5D0EF68237 for ; Fri, 22 Jan 2021 10:25:46 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id j18so3648533wmi.3 for ; Fri, 22 Jan 2021 01:25:46 -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=oC5yi0rJCSJ++JryJM1jZt2Wbpib6spC2ceO5Cza75Y=; b=gSiwM3ykpvl1ogwZlqwEXenWeYrPU0AwiOB/MEvkgiBqQivK5D8UuacU5Re9UZ8+5n f0vLzakTwg/GG56c3P6iHc1Qs2VjTnqyu1QwwiORXWFD6pIqRlLVfYj4WYSuFhUlMaz6 nfSf4yL2FK+9XAWOSP45DSewcHeBJ0TCxcsYSm6MmJDkmNd5rQOHdDfI7n8EkTMJmeuN xzS9am2M3RXRJ+6Y5A79dOHKL5gr92N4/VUrmfmvmUQ63RwGO9rQo+BsCwEoxGDzFefT Uhx2ClrJIW/w8Q6e5nTTOdIuCmo8Gd41d0PDNlrdDJHnl+2Mr193eroy4YH3azucVhYP xJtw== 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=oC5yi0rJCSJ++JryJM1jZt2Wbpib6spC2ceO5Cza75Y=; b=PDDcnLvHhNU8NCgr7ocQCKbr/+OrWofsURZtbZzndXgESHxyzC6JTcD9rV2tKRIgG4 efigBokaQnmruhuUBlhVxzOwDjVaT6TTSOFQNKLpXcVBd4fO7WZfehAn81tWDdQisYzq 8WmoeD5r2xXnrk6ONNKLFU/LTvWhGa83MyrEGjIeGURgE3Y41dj4xgTrdz2wXGdflpja tTKEf735sTFoSsOX+Y9MuewYosbUluLuWYtwovF3XOR6yCmjgsh8PYlFOcinG1D9IOz1 n/lizM2iNJHmjFBbCE1C2eiAmjO4N/+qLhXiV3O3R6KwbBCYHDbQMujT385Inn9TeYlf IQjQ== X-Gm-Message-State: AOAM532mZ51BWgKaaRactLr6JWAEzJradZTaYh57HS1B8eg5JWsjre2v 2Ud83E654WAplh6BZ2aF0zxW0ElbOqSqMQ== X-Google-Smtp-Source: ABdhPJwNiHkw3qrsLUr2WFgK/1xWE/0B8lv2G4Hb8XRr/xWlPYphR9E1SLzQ2UXsJH6srKcNn0L01Q== X-Received: by 2002:a05:600c:1986:: with SMTP id t6mr3058448wmq.92.1611307545842; Fri, 22 Jan 2021 01:25:45 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:44 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:34 +0000 Message-Id: <20210122092537.708375-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Acked-by: Kieran Bingham Reviewed-by: David Plowman --- 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 09:25:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10948 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 EB83EBD808 for ; Fri, 22 Jan 2021 09:25:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A9DA46823F; Fri, 22 Jan 2021 10:25:49 +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="PfswshWR"; dkim-atps=neutral Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 61A6C68237 for ; Fri, 22 Jan 2021 10:25:47 +0100 (CET) Received: by mail-wr1-x430.google.com with SMTP id 6so4391133wri.3 for ; Fri, 22 Jan 2021 01:25:47 -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=Vzzrj/KlOj+CqFi/Wht/455yZW2spTHYWAEfF1rC0TE=; b=PfswshWRNP2XAReGXK4hN01ZQ+YHrUq/+6RzmQrEI+NbPv9BTXpQzp9bRNMzQOytcP Tg0JTBgDcSZTSe5yV+4W4iCoyasGxB93/udNiqKTngOL0T0q2LHjUrOSEMq2DueOo5FG HqlVwvREqpZbZkrlJGdl3DWDABdNUYzMkYNXNttZZBu2zbKIe8+bpqJRt5luH1N+lyV7 ihq+uqVxwPfQ7qSFhtI24CGuOivlLrTBRfklOqjoFmzl01MuB4URXeOMUWVrIdx/B1Bc pUvJvPNCgakItb2/mMyTL0KdKQkCburfBX/0tZ2KwUL8x+8nordej6BjJKCn55vYi757 MfBg== 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=Vzzrj/KlOj+CqFi/Wht/455yZW2spTHYWAEfF1rC0TE=; b=RF/n7bf965KmSv852jto7mmUHft5b9XvC6xZ+XAN8AyO2NLNBsIV3STCpjpQz9mNGv /FxTePuDK9GTUW8+g4eiIhPUzWrRJ9xk00A7FAyXtVs68GbQYeTxGitWwR9SOS0qHOcc g1g//HCQkEtOH/AlNl7MpLnFanCGg4F3GZ6FkbWmLJxdHeCjtFuZopqiAVcaQMCpNJbO VvNPpe2xt4VEppI0zoL8ZBs0+5z81pdh6ecMqfg5K5S59Jyrbgz4WvkFmmxnfYPGsshu d+q4lJBrv2wyeAsuHwwum4S3DJCZYCvcKN1H9JaRzD3ZMA0koRrS91PhxtBmFEvF59sI Dpqg== X-Gm-Message-State: AOAM531zlljaAedqz2iU1GAw0du6TWV8KKhS37hjwq5Or3d1ymYxNata EWOZvqx3HklLPiToXItGzMq9crbvslfOVw== X-Google-Smtp-Source: ABdhPJwPdQfSqoxqPwR5ztpK0HeCL0bWlbMH4I085K6OnCmq/RYKvEOO0q2BOUqhw52oNPl/uGiUKw== X-Received: by 2002:adf:80d0:: with SMTP id 74mr3621348wrl.110.1611307546876; Fri, 22 Jan 2021 01:25:46 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:46 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:35 +0000 Message-Id: <20210122092537.708375-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 09:25:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10949 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 6D650BD808 for ; Fri, 22 Jan 2021 09:25:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C67D68243; Fri, 22 Jan 2021 10:25:51 +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="DT6RU1PP"; 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 89A076823C for ; Fri, 22 Jan 2021 10:25:48 +0100 (CET) Received: by mail-wr1-x433.google.com with SMTP id b5so4366721wrr.10 for ; Fri, 22 Jan 2021 01:25:48 -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=BTpjYOrcjlceLBb0AKVugpXyOog6QXBLRO6JWmeoLBw=; b=DT6RU1PPvsJPXVuoVIsHIR60t4lNKhrUpRNgQ3IRE3ylpzZDP3we79BvsmLoEasCuo ZfGfmFWZGr5VCxM0ZKgIk/KyjmYXee/xTqjhRyc2H5/mfoHTd6mBOxOwRkuR22AQEuwe MRE8N3vRwCStmVSgJ+Lll1C9+eSXUSvNSi7PsuUqceRLFYEee75BABoo+xf33/X811NW bNxKGjIKzTaaczhPX6bZP1isI8W7zXZo5LFSD67iY+tJQISiU3pXaS+PJA9IrsW9cK0q OqC0yE7BMzDeBKtvg/jp694KaIYfKNcZm1TJ+uKZdhGSWl0w2+2jt6zMwPJgyovdmBbz 6+Qg== 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=BTpjYOrcjlceLBb0AKVugpXyOog6QXBLRO6JWmeoLBw=; b=l8KwazDew36OSa9H49ifdmBbA24f+x4X0Fm5jYa2h/FThSBnET2BiUPcWG/KY7kOdL rSaXmWCLPzMP4k6U9zYOjCMBxMNTttS4sRKiq+HK9n1C80epdlJWYt2V6w8teZ6RUHRV bMCJYA9b3N9QnK73a7VUfSWI65U1RWZvNKHThWj6WkBul4grTs2BuDvVRse6c79+7wg4 WvHfxt7cDcoLom/vGyoRANXwOfrPULNAIYeMOEpZgiojySst7Rqy3khFf31sL69VhyC4 BWQwm1Q+3wPtlPdP4SBfonuJJRi/NpPIpCioDlnCNrm7vJNF7DyYbYqOBj5zcxnt2eAr s/vQ== X-Gm-Message-State: AOAM532caBbwPsXjGglqzh1D878/9ZWbqRwTe2hXy+bRSkb9/v7GqRei IJ37yaR8gNrZJ5CIO2+2yvJBx1EJhk+hzw== X-Google-Smtp-Source: ABdhPJwjqUDb38G1/QlqKCAcWkZbOi05W1mR2uu+0ipkhfOuwX64Q3LkXoHuijSckawSqKMXeAuV8A== X-Received: by 2002:a5d:55c3:: with SMTP id i3mr3505049wrw.190.1611307547988; Fri, 22 Jan 2021 01:25:47 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:47 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:36 +0000 Message-Id: <20210122092537.708375-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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..f85a09afb380 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::ColourFast) { } @@ -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 09:25:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 10950 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 097DBBD808 for ; Fri, 22 Jan 2021 09:25:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C581368240; Fri, 22 Jan 2021 10:25:51 +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="lxXM0n83"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AB27F68243 for ; Fri, 22 Jan 2021 10:25:49 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id 7so4396237wrz.0 for ; Fri, 22 Jan 2021 01:25:49 -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=lxXM0n83Z/YRjkjnLxNdFAv4N3sx/X9mSGrqGy7dorAiO6gXv1TUGFpxapZ6zcGo1P p16i/uE7jHxfuKXeJNC6udOCL0JEdMSkxV1e8QdDXDk8+LaSiQJfFersgE2VwzozGYIv RYuTRWOCiFUaLuEW7PJJZmCtn3HEZHJc9BFWQaU8Hpy0cDu6Eoh6ii0XSAj96HTUHsX5 m5gaEftTkXjljCQglhVf1NGhkj/FSUEhdLhFPr83N2dEwo4D/jN3E9Kz5pZcwNmWNdxr PlUUY4Wb8+FW+gFmhC6Z6dSvcjRNy0JUo+hIikijYHVbRDi4fB8Uqc6ltjlQ3lHg7jsU QvzA== 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=Njk1VuFgOPDevFkB5yTe0a+K1CfeJz6tCp5MdWxQj9UfQ6oLVTGVWD1ql/2hzIqBqf /IRM/Rm6bmjxBzIE/pVpRgfm4ftLa6G2RzxhLitYUlsaxlrCdn+JrZOBL5vfEzTHTBUI DinWXSyYFOCHukmlmpcGweT6cL+0fCRVfocOZipQjgNajcLAUtdeJdXd5Xv4qpE/igEd SjoCSsb1jgcbXjWQNM1omlu+bTu1rpDYEosiIX34t7RQQgMWP85IsW4GfVETl9aDYmuy koO2EfPyJ+uxgPDbjOdE5D/CxXXTDtmCRzJfjHtglwMUEOe/8GqRJLQ8Ed2pTggOR0E5 Ryiw== X-Gm-Message-State: AOAM5315VVdgpRJqI2dfkqPpBdz/lxmK1XfcyFOYM2AI5kGA2HvQMmZ6 PveOp3y9SpZaGCXSkNEEEyK0JHJbmEAYOg== X-Google-Smtp-Source: ABdhPJzqxMLhkKw0prDkTkD2EDBion+e7hPJeTWvMQhanxQ63mTfmbfhBhV4rsEyOk/xFNEmPz9mvw== X-Received: by 2002:a5d:6a02:: with SMTP id m2mr913006wru.364.1611307549161; Fri, 22 Jan 2021 01:25:49 -0800 (PST) Received: from naushir-VirtualBox.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id h15sm10664801wru.4.2021.01.22.01.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 01:25:48 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 22 Jan 2021 09:25:37 +0000 Message-Id: <20210122092537.708375-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210122092537.708375-1-naush@raspberrypi.com> References: <20210122092537.708375-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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)