From patchwork Mon Jul 4 15:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16531 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 93CE5BD808 for ; Mon, 4 Jul 2022 15:23:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5437A6564E; Mon, 4 Jul 2022 17:23:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656948206; bh=F0jri/bMLzBTIseBjTeOIjla4H+7zBN1XS4U9gcH06U=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xnf4f7WylorvWEFQ6pd8tZr2CHgSRjX+sZ8KQQ83+71jXzPnksP8Lh1Hd/VfMpEAt kMm0iOPWI+jew1tH1Xa6zyk66L3eGJfDTaOCfDhzZxgxuQHRC9h5lVlra0j0dw9lHA XreVU3s9gKrUv8SNgDL+f5cFjhBQyvjOlFpDu4YkIc9vsi3tCQ7oA6wzGQ8JKh2ima 82HTuemzumlY+GcI5XnXs6BsTVc/BmGyhX6uCzCeoikAURpq/bnmlOXe4Wcq+wiGjd dF9Wl8ZNNiAvy5AXd1jnH+8sgOh2fhlARATxfMO44tE0nqiNCjQWRTsf1XhXahAfqE Q5GK2F3aGj0vA== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 89A9B6564A for ; Mon, 4 Jul 2022 17:23:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="U2RmQ8lX"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id be14-20020a05600c1e8e00b003a04a458c54so5852456wmb.3 for ; Mon, 04 Jul 2022 08:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7dqw86XhV/+eZ0xQ2KZBrqn22bOd7txa8tBccccq8PI=; b=U2RmQ8lXIwsRpXVtZWnQftebYt6eW13mk0SVxWYMzRs/Q/I/JN/7fRMuU857EGADWC Ug786ZBUAQSFSONuuKv62jb2EOT3x45FZ8h2iKrmumUQjZ8CrmIPjbRCnTLA0lTQyV2Y 1kBQ1RaQB+zYELJXJ9y6kEY6nd89eu33ZforrZqN3Zq4Vwp0hFXTx6T13rW+D2Dwl1Gv Fpef+ooZjbt8kzcVTlG43lGjkX5Og6RUCNE60+UmiwgxoUakMr/lYFZjNt3hW/loKSam 49PZEUS4HWkB3zDP/RFyN06iqGld9VFD804GBoz27dpqErzv3pOTIxL2ykRzYoQ27MI7 z4sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7dqw86XhV/+eZ0xQ2KZBrqn22bOd7txa8tBccccq8PI=; b=D1wcsPdlUgf8D5GeC4cT/xkKxA4LBoS1UWsNbyOCQSSghM0KIxOrMmwrRuayDOiB9m r38hEkjvh+q3hN5iotVQxblFZqujEfXN/sWT0Qe/6DlIJO2aMSSuPkMLtoASkwuFivuH etfv4NHKSGw2T+GLpdatiFPQvuexTbjcnfpA2W5YBXpAApbws7ZMoOuEI5bfcYQJAd+o Sjw+l5whozxCVneI6cR1veK3lx9Cy+8/Z6S+EftOcWYAiOUyAev7UgGwNQGxgWa8JIUx tC1HbckKNuQ1BeNkUPs0BD02YuozlxjyPrBjxyjJsq5iDpd3gPkZs3B06u8Zd96I7icJ oCSg== X-Gm-Message-State: AJIora91h8ds24mMLXHJ9AbqNi9gNo3xN3/qDbtEpp8EHSgIihqf5NJl VH3CBycTBxQKVCidUFOtq91dcHJag39R7Q== X-Google-Smtp-Source: AGRyM1slce4K6GQYyYI/iKpSYFszHg5TY/JJdc/zMDYXcPtp4dFS3SoA8Ta9oybb28cAqv4awL6ceg== X-Received: by 2002:a7b:cb94:0:b0:3a2:af9a:e569 with SMTP id m20-20020a7bcb94000000b003a2af9ae569mr4232064wmi.144.1656948202886; Mon, 04 Jul 2022 08:23:22 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:ca4a:68b5:560f:5682]) by smtp.gmail.com with ESMTPSA id p15-20020a05600c204f00b0039c5cecf206sm19603199wmg.4.2022.07.04.08.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 08:23:22 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Jul 2022 17:23:15 +0200 Message-Id: <20220704152318.221213-2-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704152318.221213-1-fsylvestre@baylibre.com> References: <20220704152318.221213-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] ipa: libipa: algorithm: Add queueRequest() to the Algorithm class 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: , X-Patchwork-Original-From: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add queueRequest() function to the Algorithm class. The queueRequest() function provides controls values coming from the application to each algorithm. Each algorithm is responsible for retrieving the controls associated to them. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/ipu3/module.h | 2 +- src/ipa/libipa/algorithm.cpp | 13 +++++++++++++ src/ipa/libipa/algorithm.h | 6 ++++++ src/ipa/libipa/module.cpp | 5 +++++ src/ipa/libipa/module.h | 3 ++- src/ipa/rkisp1/module.h | 2 +- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/ipa/ipu3/module.h b/src/ipa/ipu3/module.h index d94fc459..5c2179e0 100644 --- a/src/ipa/ipu3/module.h +++ b/src/ipa/ipu3/module.h @@ -20,7 +20,7 @@ namespace libcamera { namespace ipa::ipu3 { using Module = ipa::Module; + ipu3_uapi_params, ipu3_uapi_stats_3a, ControlList>; } /* namespace ipa::ipu3 */ diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp index 8549fe3f..1fb811ef 100644 --- a/src/ipa/libipa/algorithm.cpp +++ b/src/ipa/libipa/algorithm.cpp @@ -81,6 +81,19 @@ namespace ipa { * includes setting fields and flags that enable those processing blocks. */ +/** + * \fn Algorithm::queueRequest() + * \brief Provide control values to the algorithm + * \param[in] context The shared IPA context + * \param[in] frame The frame number to aplly the control values + * \param[in] controls The list of user controls + * + * This function provides controls values coming from the application to the + * algorithm. A frame number is provided to indicate the concerned frame. + * Each algorithm is responsible for retrieving the controls associated to + * them. + */ + /** * \fn Algorithm::process() * \brief Process ISP statistics, and run algorithm operations diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h index 2a8871d8..aa846625 100644 --- a/src/ipa/libipa/algorithm.h +++ b/src/ipa/libipa/algorithm.h @@ -40,6 +40,12 @@ public: { } + virtual void queueRequest([[maybe_unused]] typename Module::Context &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] const typename Module::ControlList &controls) + { + } + virtual void process([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] typename Module::FrameContext *frameContext, [[maybe_unused]] const typename Module::Stats *stats) diff --git a/src/ipa/libipa/module.cpp b/src/ipa/libipa/module.cpp index 77352104..e87a52fc 100644 --- a/src/ipa/libipa/module.cpp +++ b/src/ipa/libipa/module.cpp @@ -77,6 +77,11 @@ namespace ipa { * \brief The type of the IPA statistics and ISP results */ +/** + * \typedef Module::ControlList + * \brief The type of the ISP runtime controls list + */ + /** * \fn Module::algorithms() * \brief Retrieve the list of instantiated algorithms diff --git a/src/ipa/libipa/module.h b/src/ipa/libipa/module.h index 4149a353..81d3bf7f 100644 --- a/src/ipa/libipa/module.h +++ b/src/ipa/libipa/module.h @@ -26,7 +26,7 @@ LOG_DECLARE_CATEGORY(IPAModuleAlgo) namespace ipa { template + typename _Params, typename _Stats, typename _ControlList> class Module : public Loggable { public: @@ -35,6 +35,7 @@ public: using Config = _Config; using Params = _Params; using Stats = _Stats; + using ControlList = _ControlList; virtual ~Module() {} diff --git a/src/ipa/rkisp1/module.h b/src/ipa/rkisp1/module.h index 89f83208..08381a08 100644 --- a/src/ipa/rkisp1/module.h +++ b/src/ipa/rkisp1/module.h @@ -20,7 +20,7 @@ namespace libcamera { namespace ipa::rkisp1 { using Module = ipa::Module; + rkisp1_params_cfg, rkisp1_stat_buffer, ControlList>; } /* namespace ipa::rkisp1 */ From patchwork Mon Jul 4 15:23:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16532 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 66B7EBD808 for ; Mon, 4 Jul 2022 15:23:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BF65865651; Mon, 4 Jul 2022 17:23:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656948206; bh=+Nga6QCczRCHDYA8vGG8oeRrwRHQFtYoydvMcCmijh0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LiRYAT76hOs9KlzRfQw6t5Jk2y8wG3zNFuzYxhfaIHjb49ClKdUNOr0xo9e1toHpn aPSheQMh+GBnsfyKnBepSHY94QRxlNbtprSOO4KUnppHNET5rrPCe4bvDcwuJ/i4Yr 0my3PLMDmoeBMEeh8fsmOHNMCvRgshZwErVHV/4R2fIU5t2ajkJ9DISgl8GSraErNK BIco/+DsK8LSpBXlTW9aEf6jL32IUD62uiEA3zKhdJfp1QxPTfe6jpMMFsXqb+MFXm IpSOgf/c1c/VpUEcPoz9twMNe68jDaA/0Rtibtkaiw4qGxYIgSveMCzbsKPMFbvUK8 aJgrFPfzk8tuw== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC5966564B for ; Mon, 4 Jul 2022 17:23:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="6BHj40P8"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id g39-20020a05600c4ca700b003a03ac7d540so8191241wmp.3 for ; Mon, 04 Jul 2022 08:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rftLrhBobROBzZJz5X3Yo8uPXhcnO3e+6JPwXZtQ2tU=; b=6BHj40P8vhL4JSbrocROzwsuMQrctwFzVLdWHtSNVeq3ovNlXIYkeO7SWZE/Elqs/F CkCtH1J17HV50fkPPzvK8fxAhtiQJFmwQFUYTCAzcqrrcM3hlsFPMHHo8mFPCsiYZ6QZ OBi+eoe1AOBIrLBij/D3gRBzr9WYlfGUYRH90lGJ3b+4KISRsbSvwds0D04JSg20SMV5 5ualXwH6jVCCOND4hLaVH15Zm6W/i6Yu/a03ClKUncEhM9+oSDnEBPAGtRZhJv7mGzCB OJNPf+S4M4oXT969RemS4WmnIWY62UxWpjB/slKwS5nVoamaUeTZKD/J3uS75WQkuwZr 5a1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rftLrhBobROBzZJz5X3Yo8uPXhcnO3e+6JPwXZtQ2tU=; b=cPNDmZ4V+6tMtTOz9/oTKvX0cr/5T2WQlAQiXIUrrX0Q64DqqAYopE3qBcisCDFJn6 tyWQWTZtwCbqLbP3rvKUUXgCdI08NKT4lOtS1MSjpdnlw3zAzrJmp+Cfis4jfP6O5Jlm 9YTPdYXFRYo3rpBIVDf32ImcnkWfqYHNd0hRxG3/2jQNQt0smjtf6Tk9dOAx4r7Uslg+ ezx7NA65kar/iBc9W75VAe7oKazDM2UF46N1Ojc6XakRoa99SMYxKn6ybf2TWOUMTYsh YYXp+kfLm1CpsRfukC7u2Qqf4zQRUtSdRG9NZR5FnhQ0CzQB8mzOYE08I/YNVtXlbO30 VhdQ== X-Gm-Message-State: AJIora/I1vrIPAnGXAzuMjHPL8IjYS2v+UvhrRfAOXy93vRNjchzB03R WMnfsl7svMbapkTI0lu6xVtuhPTB/AuzUA== X-Google-Smtp-Source: AGRyM1t3yL72LC+DKPzYKRHRSkFUckRbh1t8KwvQwICtUXTZrqdQkMNjRTYkhVoIHNrhpUWgwOhXBw== X-Received: by 2002:a7b:ca54:0:b0:3a0:522c:d0ec with SMTP id m20-20020a7bca54000000b003a0522cd0ecmr31512734wml.63.1656948204099; Mon, 04 Jul 2022 08:23:24 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:ca4a:68b5:560f:5682]) by smtp.gmail.com with ESMTPSA id p15-20020a05600c204f00b0039c5cecf206sm19603199wmg.4.2022.07.04.08.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 08:23:23 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Jul 2022 17:23:16 +0200 Message-Id: <20220704152318.221213-3-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704152318.221213-1-fsylvestre@baylibre.com> References: <20220704152318.221213-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] ipa: rkisp1: Transfer queueRequest() call to each algorithm 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: , X-Patchwork-Original-From: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Implement rkisp1 queueRequest() function to update each algorithm with user controls. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/rkisp1.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index a32bb9d1..9b0d675c 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -270,9 +270,10 @@ void IPARkISP1::unmapBuffers(const std::vector &ids) } void IPARkISP1::queueRequest([[maybe_unused]] const uint32_t frame, - [[maybe_unused]] const ControlList &controls) + const ControlList &controls) { - /* \todo Start processing for 'frame' based on 'controls'. */ + for (auto const &algo : algorithms()) + algo->queueRequest(context_, frame, controls); } void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) From patchwork Mon Jul 4 15:23:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16533 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 821E9BD808 for ; Mon, 4 Jul 2022 15:23:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 340BC65658; Mon, 4 Jul 2022 17:23:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656948208; bh=iXL+jHJnilrNPSpBrMwT2ff6nImvQJ84SN4WCPAgZqo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=L0Fg1eWaaJm7eYbESJ9jgWXa5FRv2puLerCzR9awaCp6TTvBSUwITtHbwxkUhUVIc ntroXFYibVzHz3l4lpCi85XbXEJgBO5291Xl8htXY/VYL0/Y1mCrD5+ufOP939vNUc gahSEOWH9JDap8WxeOdYTYkME4XJpplCna2ZrAfFugPP17uacYeUKGQMDxgyInF0NZ mYxKf+cviUjOb67sd2Hdec4SBUal0AVJ2VQFMz4bwDQzERsSyNC5o6xb8vKSmcvmqy blZ+3zvfpLhF7050zIcbss1T1aqMjt8MkPeHc5nx/KhKIVGcesmEy6pPpMQ8N6GT0a YNVHKwQnDIKjw== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2BC4F6564A for ; Mon, 4 Jul 2022 17:23:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="4bt4nhVL"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id k7so13928242wrc.12 for ; Mon, 04 Jul 2022 08:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CDoBwHVa9kSCalHII9c48Kh0yJn7kLuxldxFCHrqLsk=; b=4bt4nhVLLB2dtLfzW7lWUl/MjabsXVhLwp4dI8RS1i8GzfBDTOu6VQq+lmDOQJaEs3 zyVFAlKhFm8Cm9WJNj/9h+qtcrbRGz97TeRMWYRNjUjH+pT2CC/iaGc1DiwE9Gt5ivyf N99pXAGADY+qi8eJV9xNSZEv2lRoLVRIzXiDrBWUCBSTmoghPKMhwdmmSdUwBCcTobGB FhTJEfQWb2fqyOxnwZ7iiH6WDFfXLRQ1KmyuIEhLnXQgvdwYGLFC+S/JHGYTusj7F9Vk jPjm/P139C1oCapomWqi/d7k+rYwMvARDOUBX7m35cajn5yoJKe1im7RffleMJxFcVCy XKuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CDoBwHVa9kSCalHII9c48Kh0yJn7kLuxldxFCHrqLsk=; b=T9/j3LZj5uPhH09Ga+QGruEYYBKYbdLV+vtGE04KCpDasdu2PYw020lXqTE5ldmyW5 TR+X2IAl+9s6dyHdJJp2zAq0SQsX+QiMBxpDsSv5AnDWMHZjQjSQ8/lW7EObgRvGFgT8 9pxO5fK5nSlVayS20ISLGcAlgXVIAb9wGIjY+L27V/VW6sTjtfqayZy0BkJznQreOHyN am6sDqQhmFs8Xq+Vn1wzAuzCDeLuNajI/Ds6qClORNU6k7xblTotlMkYHoRITvK0SX1i eRNl8Gu77ScRGLux2qTPTB6Gm4lRmIeraMw4bayj5cMchw4V32dt+rHnYsh3baqgnxUX e0MQ== X-Gm-Message-State: AJIora+EuXs9uwQo87n+8fWYWSVdSnIODRlAYImeItXdqsmXAW4BNfvA 7t9ieDhA8joN/Lmibp0xN8mEJ7OnogcXWA== X-Google-Smtp-Source: AGRyM1vzpqDwQ/0bDwyjtnLesjrtZoPr6z8ylLUqD+WWAz4pdMw8u8CfB2tGnXUP+t5GKbvBblpsfA== X-Received: by 2002:a5d:6da3:0:b0:21b:aaf5:b814 with SMTP id u3-20020a5d6da3000000b0021baaf5b814mr27176867wrs.140.1656948205424; Mon, 04 Jul 2022 08:23:25 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:ca4a:68b5:560f:5682]) by smtp.gmail.com with ESMTPSA id p15-20020a05600c204f00b0039c5cecf206sm19603199wmg.4.2022.07.04.08.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 08:23:24 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Jul 2022 17:23:17 +0200 Message-Id: <20220704152318.221213-4-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704152318.221213-1-fsylvestre@baylibre.com> References: <20220704152318.221213-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] ipa: rkisp1: Add support of Demosaicing control 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: , X-Patchwork-Original-From: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" During the demosaicing step, rkisp1 ISP is processing denoising and sharpness control. Add demosaicing algorithm with denoise and sharpness values based on user controls. Signed-off-by: Florian Sylvestre --- src/ipa/rkisp1/algorithms/demosaicing.cpp | 208 ++++++++++++++++++++++ src/ipa/rkisp1/algorithms/demosaicing.h | 37 ++++ src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/data/ov5640.yaml | 1 + src/ipa/rkisp1/rkisp1.cpp | 1 + src/libcamera/pipeline/rkisp1/rkisp1.cpp | 8 + 6 files changed, 256 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/demosaicing.cpp create mode 100644 src/ipa/rkisp1/algorithms/demosaicing.h diff --git a/src/ipa/rkisp1/algorithms/demosaicing.cpp b/src/ipa/rkisp1/algorithms/demosaicing.cpp new file mode 100644 index 00000000..2597735e --- /dev/null +++ b/src/ipa/rkisp1/algorithms/demosaicing.cpp @@ -0,0 +1,208 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * lsc.cpp - RkISP1 Defect Pixel Cluster Correction control + */ + +#include "demosaicing.h" + +#include + +#include + +#include "libcamera/internal/yaml_parser.h" + +/** + * \file demosaicing.h + */ + +#define ISP_FILT_LUM_WEIGHT_DEFAULT 0x00022040 +#define ISP_FILT_MODE_DEFAULT 0x000004f2 + +/* Default values : should be updated with automatic control implementation. */ +#define SHARPNESS_DEFAULT 2 +#define DENOISE_DEFAULT 2 + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +/** + * \class Demosaicing + * \brief RkISP1 Demosaicing control + * + * The Demosaicing algorithm is responsible to reconstruct a full color image + * from the sensor raw data. During the demosaicing step, rkisp1 ISP is + * processing denoising and sharpness control. + * + * /todo In current version the denoise and sharpness control is based on user + * controls. In a future version it should be controlled automatically by the + * algorithm. + */ + +LOG_DEFINE_CATEGORY(RkISP1Demosaicing) + +Demosaicing::Demosaicing() + : userSharpness_(SHARPNESS_DEFAULT), userDenoise_(DENOISE_DEFAULT), + updateUserControls_(true) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::queueRequest + */ +void Demosaicing::queueRequest([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + const ControlList &controls) +{ + for (auto const &ctrl : controls) { + if (ctrl.first == controls::SHARPNESS) { + userSharpness_ = ctrl.second.get(); + updateUserControls_ = true; + + LOG(RkISP1Demosaicing, Debug) + << "Set sharpness to: " + << int(userSharpness_); + } else if (ctrl.first == controls::NOISE_REDUCTION_MODE) { + int32_t denoiseControl = ctrl.second.get(); + + switch (denoiseControl) { + case controls::draft::NoiseReductionModeOff: + userDenoise_ = 0; + break; + case controls::draft::NoiseReductionModeMinimal: + userDenoise_ = 1; + break; + case controls::draft::NoiseReductionModeHighQuality: + case controls::draft::NoiseReductionModeFast: + userDenoise_ = 3; + break; + default: + LOG(RkISP1Demosaicing, Error) + << "Unsupported denoise value: " + << int(denoiseControl); + continue; + } + + updateUserControls_ = true; + + LOG(RkISP1Demosaicing, Debug) + << "Set denoise to: " + << int(userDenoise_); + } + } +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void Demosaicing::prepare([[maybe_unused]] IPAContext &context, + rkisp1_params_cfg *params) +{ + /* Check if the algorithm configuration has been updated. */ + if (!updateUserControls_) + return; + + updateUserControls_ = false; + + static constexpr uint16_t filt_fac_sh0[] = { + 0x04, 0x07, 0x0A, 0x0C, 0x10, 0x14, 0x1A, 0x1E, 0x24, 0x2A, 0x30 + }; + + static constexpr uint16_t filt_fac_sh1[] = { + 0x04, 0x08, 0x0C, 0x10, 0x16, 0x1B, 0x20, 0x26, 0x2C, 0x30, 0x3F + }; + + static constexpr uint16_t filt_fac_mid[] = { + 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x10, 0x13, 0x17, 0x1D, 0x22, 0x28 + }; + + static constexpr uint16_t filt_fac_bl0[] = { + 0x02, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x10, 0x15, 0x1A, 0x24 + }; + + static constexpr uint16_t filt_fac_bl1[] = { + 0x00, 0x00, 0x00, 0x02, 0x04, 0x04, 0x06, 0x08, 0x0D, 0x14, 0x20 + }; + + static constexpr uint16_t filt_thresh_sh0[] = { + 0, 18, 26, 36, 41, 75, 90, 120, 170, 250, 1023 + }; + + static constexpr uint16_t filt_thresh_sh1[] = { + 0, 33, 44, 51, 67, 100, 120, 150, 200, 300, 1023 + }; + + static constexpr uint16_t filt_thresh_bl0[] = { + 0, 8, 13, 23, 26, 50, 60, 80, 140, 180, 1023 + }; + + static constexpr uint16_t filt_thresh_bl1[] = { + 0, 2, 5, 10, 15, 20, 26, 51, 100, 150, 1023 + }; + + static constexpr uint16_t stage1_select[] = { + 6, 6, 4, 4, 3, 3, 2, 2, 2, 2, 2 + }; + + static constexpr uint16_t filt_chr_v_mode[] = { + 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 + }; + + static constexpr uint16_t filt_chr_h_mode[] = { + 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 + }; + + params->others.flt_config.fac_sh0 = filt_fac_sh0[userSharpness_]; + params->others.flt_config.fac_sh1 = filt_fac_sh1[userSharpness_]; + params->others.flt_config.fac_mid = filt_fac_mid[userSharpness_]; + params->others.flt_config.fac_bl0 = filt_fac_bl0[userSharpness_]; + params->others.flt_config.fac_bl1 = filt_fac_bl1[userSharpness_]; + + params->others.flt_config.lum_weight = ISP_FILT_LUM_WEIGHT_DEFAULT; + params->others.flt_config.mode = ISP_FILT_MODE_DEFAULT; + params->others.flt_config.thresh_sh0 = filt_thresh_sh0[userDenoise_]; + params->others.flt_config.thresh_sh1 = filt_thresh_sh1[userDenoise_]; + params->others.flt_config.thresh_bl0 = filt_thresh_bl0[userDenoise_]; + params->others.flt_config.thresh_bl1 = filt_thresh_bl1[userDenoise_]; + params->others.flt_config.grn_stage1 = stage1_select[userDenoise_]; + params->others.flt_config.chr_v_mode = filt_chr_v_mode[userDenoise_]; + params->others.flt_config.chr_h_mode = filt_chr_h_mode[userDenoise_]; + + if (userDenoise_ == 9) { + if (userSharpness_ > 3) + params->others.flt_config.grn_stage1 = 2; + else + params->others.flt_config.grn_stage1 = 1; + } else if (userDenoise_ == 10) { + if (userSharpness_ > 5) + params->others.flt_config.grn_stage1 = 2; + else if (userSharpness_ > 3) + params->others.flt_config.grn_stage1 = 1; + else + params->others.flt_config.grn_stage1 = 0; + } else if (userDenoise_ > 7) { + if (userSharpness_ > 7) { + params->others.flt_config.fac_bl0 = + params->others.flt_config.fac_bl0 / 2; + params->others.flt_config.fac_bl1 = + params->others.flt_config.fac_bl1 / 4; + } else if (userSharpness_ > 4) { + params->others.flt_config.fac_bl0 = + params->others.flt_config.fac_bl0 * 3 / 4; + params->others.flt_config.fac_bl1 = + params->others.flt_config.fac_bl1 / 2; + } + } + + params->module_en_update |= RKISP1_CIF_ISP_MODULE_FLT; + params->module_ens |= RKISP1_CIF_ISP_MODULE_FLT; + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_FLT; +} + +REGISTER_IPA_ALGORITHM(Demosaicing, "Demosaicing") + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/demosaicing.h b/src/ipa/rkisp1/algorithms/demosaicing.h new file mode 100644 index 00000000..6d05b0e4 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/demosaicing.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * dpcc.h - RkISP1 Demosaicing control + */ + +#pragma once + +#include +#include + +#include "algorithm.h" + +namespace libcamera { + +struct IPACameraSensorInfo; + +namespace ipa::rkisp1::algorithms { + +class Demosaicing : public Algorithm +{ +public: + Demosaicing(); + ~Demosaicing() = default; + + void queueRequest(IPAContext &context, const uint32_t frame, + const ControlList &controls) override; + void prepare(IPAContext &context, rkisp1_params_cfg *params) override; +private: + uint32_t userSharpness_; + uint32_t userDenoise_; + bool updateUserControls_; +}; + +} /* namespace ipa::rkisp1::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index 87007493..7e078b0d 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -4,6 +4,7 @@ rkisp1_ipa_algorithms = files([ 'agc.cpp', 'awb.cpp', 'blc.cpp', + 'demosaicing.cpp', 'dpcc.cpp', 'gsl.cpp', 'lsc.cpp', diff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml index 51228218..4ae0ffc0 100644 --- a/src/ipa/rkisp1/data/ov5640.yaml +++ b/src/ipa/rkisp1/data/ov5640.yaml @@ -157,4 +157,5 @@ algorithms: rnd-offsets: green: 2 red-blue: 2 + - Demosaicing: ... diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9b0d675c..85a75070 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -31,6 +31,7 @@ #include "algorithms/algorithm.h" #include "algorithms/awb.h" #include "algorithms/blc.h" +#include "algorithms/demosaicing.h" #include "algorithms/dpcc.h" #include "algorithms/gsl.h" #include "algorithms/lsc.h" diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 72689c88..3d0075ee 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -953,6 +953,14 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) std::make_unique(this, &mainPath_, &selfPath_); ControlInfoMap::Map ctrls; + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(&controls::Sharpness), + std::forward_as_tuple(0.0f, 10.0f, 1.0f)); + + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(&controls::draft::NoiseReductionMode), + std::forward_as_tuple(controls::draft::NoiseReductionModeValues)); + ctrls.emplace(std::piecewise_construct, std::forward_as_tuple(&controls::AeEnable), std::forward_as_tuple(false, true)); From patchwork Mon Jul 4 15:23:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16534 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 06A74BD808 for ; Mon, 4 Jul 2022 15:23:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B06EA6565A; Mon, 4 Jul 2022 17:23:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656948209; bh=QzRrqs99qNCE6wYpDgldZ1zuCI/Mo1WhxRQz6bRcTiA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=MNHFgyL2YlCFTJe0jomBlpeEfh0q0K3komjirmUpMOKpLdHU8djvnjJlIpq1EeDXP A1RK93q0UBJtQhUjf6VRUWIzH3sFZkgaATuXGUR7dOxZFbVewUJmxBWSUzD8Th18Vz h7UThoNjGiSg72kHQTUu2mTFpaUZ17x/+QvnDXA5l/76TEqGQgEmyYjT/zxvqXSsPm 45HN/M+PoNE0a5oZJwXWCLFmAa5bJcuBDf+ViakPEDykXvxp7ih4rdGUMrHBXmV9Z+ toh/qTnX7BxdTq4qJsYZiciE1LdFhfZ9asmRnQ/UrveZ+lJnngyeEI7Od87q+Uo9KC 9+C4DtivY3JWg== 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 01D3565656 for ; Mon, 4 Jul 2022 17:23:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="A1Qpifi4"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id o16-20020a05600c379000b003a02eaea815so6820096wmr.0 for ; Mon, 04 Jul 2022 08:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZHdKIv5kQQXb0EA7dV48Tixdt7wNv4+1ifWMHIKgfa0=; b=A1Qpifi44YEIjFwXHnwyvnLLUbFVzcj3IrJiyLuLMjIFVQmHVayWp7P7n+gFFaIhMY LXYCH3iurgb3UUJLgnV/cCCartpCb8fXo//G2TjCJEOwh/lz1xqfIpTFT5afwevU3FLV jLH/OFxltoXPZqbM4//chDBkFTYFYyfATop7Zp7/2U3eM6/nq+7OGRoEWuAkL9KLI5n7 aQp9nbUjk01pSQYKg0Id1vMvYctlD6WrE6sj7Eiyrzj4cej0g/r3a9j7V3mvST4R6bt1 OLe+9/sy9CILyeLTyDA/rcBZb+0Xv/ps5D4qV+lc/AhXGlKEh1sxgyeYDcekqrDCq7A8 Gkjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZHdKIv5kQQXb0EA7dV48Tixdt7wNv4+1ifWMHIKgfa0=; b=dMn5RtIXUQJF38WQyFSpcxPz5Np6OXKPqlnX0b0mysVLWpxxkYU5kW8050LoFEFikf DNC1da7SmJWpwVQb/7G4e65FURTrIiSW4tctakz/0FETO/mBoC8Jvvh4nwE2PbIZNEvG FlLQ0dFRHoLWHQcaKO9mAAveDVn0cUSXD5a6/L8MiP6C0WqZRNdeuXLF9qVdZceEPmYB m2oEUO+WAVBO/Fkxhri5zJlULnUYw/H7fcRouC4kBIGHJTUXXEiXFSCFQlX/YCMsr/RO EfAAFQtvnct3DTX8kL05d7arhI2O5MRSEzhDwEihxVu72Pdv7T1Kth8xFISBUv/NfHyE OQ6A== X-Gm-Message-State: AJIora9DkrvEvaEEY1GnNVsbZpoQituf4FcnJ5l+gtvq5qQ5rkcjcQLm /ZTdw0XmgfQXelkF81/XlsteTrFuZfHXaA== X-Google-Smtp-Source: AGRyM1uMa37m+ztKEEgliZQu/K0h0GVIAV+x6wtgHDijYuXkBaw4jSretUCN8+oHaBJidNW1RME1kg== X-Received: by 2002:a7b:c381:0:b0:3a2:aef9:8df4 with SMTP id s1-20020a7bc381000000b003a2aef98df4mr4683209wmj.7.1656948207217; Mon, 04 Jul 2022 08:23:27 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:ca4a:68b5:560f:5682]) by smtp.gmail.com with ESMTPSA id p15-20020a05600c204f00b0039c5cecf206sm19603199wmg.4.2022.07.04.08.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 08:23:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Jul 2022 17:23:18 +0200 Message-Id: <20220704152318.221213-5-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704152318.221213-1-fsylvestre@baylibre.com> References: <20220704152318.221213-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] ipa: rkisp1: Add support of ColorProcessing control 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: , X-Patchwork-Original-From: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add ColorProcessing algorithm that is in charge to manage brightness, contrast and saturation controls. These controls are currently based on user controls. Signed-off-by: Florian Sylvestre --- .../rkisp1/algorithms/color_processing.cpp | 101 ++++++++++++++++++ src/ipa/rkisp1/algorithms/color_processing.h | 38 +++++++ src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/data/ov5640.yaml | 1 + src/ipa/rkisp1/rkisp1.cpp | 1 + src/libcamera/pipeline/rkisp1/rkisp1.cpp | 12 +++ 6 files changed, 154 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/color_processing.cpp create mode 100644 src/ipa/rkisp1/algorithms/color_processing.h diff --git a/src/ipa/rkisp1/algorithms/color_processing.cpp b/src/ipa/rkisp1/algorithms/color_processing.cpp new file mode 100644 index 00000000..a7f2a470 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/color_processing.cpp @@ -0,0 +1,101 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * lsc.cpp - RkISP1 Defect Pixel Cluster Correction control + */ + +#include "color_processing.h" + +#include + +#include + +#include "libcamera/internal/yaml_parser.h" +#include "linux/rkisp1-config.h" + +/** + * \file color-processing.h + */ + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +/** + * \class ColorProcessing + * \brief RkISP1 Color Processing control + * + * The ColorProcessing algorithm is responsible to apply brightness, contrast + * and saturation corrections. + * The coefficient applied for brightness, contrast and saturation are directly + * provided by user controls. + */ + +LOG_DEFINE_CATEGORY(RkISP1ColorProcessing) + +ColorProcessing::ColorProcessing() + : userBrightness_(0), userContrast_(0), + userSaturation_(0), updateUserControls_(true) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::queueRequest + */ +void ColorProcessing::queueRequest([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + const ControlList &controls) +{ + for (auto const &ctrl : controls) { + if (ctrl.first == controls::BRIGHTNESS) { + userBrightness_ = ctrl.second.get(); + updateUserControls_ = true; + + LOG(RkISP1ColorProcessing, Debug) + << "Set brightness to: " + << int(userBrightness_); + } else if (ctrl.first == controls::CONTRAST) { + userContrast_ = ctrl.second.get(); + updateUserControls_ = true; + + LOG(RkISP1ColorProcessing, Debug) + << "Set contrast to: " + << int(userContrast_); + } else if (ctrl.first == controls::SATURATION) { + userSaturation_ = ctrl.second.get(); + updateUserControls_ = true; + + LOG(RkISP1ColorProcessing, Debug) + << "Set saturation to: " + << int(userSaturation_); + } + } +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void ColorProcessing::prepare([[maybe_unused]] IPAContext &context, + rkisp1_params_cfg *params) +{ + /* Check if the algorithm configuration has been updated. */ + if (!updateUserControls_) + return; + + updateUserControls_ = false; + + params->others.cproc_config.brightness = userBrightness_; + params->others.cproc_config.contrast = userContrast_; + params->others.cproc_config.sat = userSaturation_; + + params->module_en_update |= RKISP1_CIF_ISP_MODULE_CPROC; + params->module_ens |= RKISP1_CIF_ISP_MODULE_CPROC; + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_CPROC; +} + +REGISTER_IPA_ALGORITHM(ColorProcessing, "ColorProcessing") + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/color_processing.h b/src/ipa/rkisp1/algorithms/color_processing.h new file mode 100644 index 00000000..bdb40bd1 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/color_processing.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * dpcc.h - RkISP1 Color Processing control + */ + +#pragma once + +#include +#include + +#include "algorithm.h" + +namespace libcamera { + +struct IPACameraSensorInfo; + +namespace ipa::rkisp1::algorithms { + +class ColorProcessing : public Algorithm +{ +public: + ColorProcessing(); + ~ColorProcessing() = default; + + void queueRequest(IPAContext &context, const uint32_t frame, + const ControlList &controls) override; + void prepare(IPAContext &context, rkisp1_params_cfg *params) override; +private: + uint32_t userBrightness_; + uint32_t userContrast_; + uint32_t userSaturation_; + bool updateUserControls_; +}; + +} /* namespace ipa::rkisp1::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index 7e078b0d..7f9c3899 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -4,6 +4,7 @@ rkisp1_ipa_algorithms = files([ 'agc.cpp', 'awb.cpp', 'blc.cpp', + 'color_processing.cpp', 'demosaicing.cpp', 'dpcc.cpp', 'gsl.cpp', diff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml index 4ae0ffc0..331f9d2d 100644 --- a/src/ipa/rkisp1/data/ov5640.yaml +++ b/src/ipa/rkisp1/data/ov5640.yaml @@ -10,6 +10,7 @@ algorithms: Gr: 256 Gb: 256 B: 256 + - ColorProcessing: - GammaSensorLinearization: x-intervals: [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ] y: diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 85a75070..d380c59b 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -31,6 +31,7 @@ #include "algorithms/algorithm.h" #include "algorithms/awb.h" #include "algorithms/blc.h" +#include "algorithms/color_processing.h" #include "algorithms/demosaicing.h" #include "algorithms/dpcc.h" #include "algorithms/gsl.h" diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 3d0075ee..4e82ab39 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -957,6 +957,18 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) std::forward_as_tuple(&controls::Sharpness), std::forward_as_tuple(0.0f, 10.0f, 1.0f)); + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(&controls::Brightness), + std::forward_as_tuple(-128.0f, 127.0f)); + + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(&controls::Contrast), + std::forward_as_tuple(0.0f, 1.992f)); + + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(&controls::Saturation), + std::forward_as_tuple(0.0f, 1.992f)); + ctrls.emplace(std::piecewise_construct, std::forward_as_tuple(&controls::draft::NoiseReductionMode), std::forward_as_tuple(controls::draft::NoiseReductionModeValues));