From patchwork Thu Jun 30 14:35:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16485 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 CD4DEBE173 for ; Thu, 30 Jun 2022 14:35:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 458CC65654; Thu, 30 Jun 2022 16:35:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656599757; bh=D6mWfExN4PL82RnT4O1sKrGXxjVAv1vqtWJnSUSNSUk=; 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=rbVuy3OSj9X2lvTCSU/DmuArQryWE268MQLNHJmKcpSmtZ+gXa6ml+1F4LNlrlIMA FjNn/Usd4DLXkpgTBB+tFS92q62LZ1EatVK/7Lm9wAO6cKLSBMIOM6tDtXRrBqoMXl xpkVOlTiIzf988vwaoQD86kQWfRXDdu8DC97Huj/qPAwe7vYxNvhVMLTfbsI/aJk0P K2ujQQIltST2dY80QANlb1E7MN0ciyZ/uER3vV11f/+ID+xeWBuWThu1W6J1pvlfoc quTcBJ1kGZS2RTkbDmA4jTkANMDQBdSApA/qPAbdBr4N9Sxksr4CTGQ0UJBGLGbtKt 6i7dRf1v+s/CQ== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 343A565652 for ; Thu, 30 Jun 2022 16:35:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="zRstArdb"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id n185so11466745wmn.4 for ; Thu, 30 Jun 2022 07:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cluHbp3ZozxQ7erXZ6WbYUVfdEdHHTItUQcZGF8SkjE=; b=zRstArdb4ZGRNC8LnMSsbTCyWLgSSOi1s22LuC/C+FlydU3ZEnTZXw0PirbSbJTNp3 lgRDoIKbTUFQKsvmq+Azj4n8NIvMyc8Mu5n0wOAcVZiniV4smjFcJU0m/VrHH3sz1tFk YZNfmJm/Ap54p6eaj/YxN7VpML5KdVCvjsVxEZmvQ/F4KKim/t7N53w6SWyXxihezj+j q9AInIN3ht2hek7F+VCJIOAe474NEeGVhc7RSg/XVy59SNz2uS0LzBFrtYMFbxPhytOG lFgaDwg0+tgiI9etrc8ZI3NqrPMiZ1rwMhVICfSh5hcH6lioTEEgOJXq1QhsmB+3m+fM QN3g== 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=cluHbp3ZozxQ7erXZ6WbYUVfdEdHHTItUQcZGF8SkjE=; b=pLW8RCHd+L7OlK0wnNVNTIPx5HyzMEem6B9B7c4O7rGoRI/MRxdoh2/GCwi6AKauRL cdU3r5FVI5tUgQ0oQtzOIzCSvmML1YYzimMNgLwHq7vYgBJWrCovmkUGiSaSdj3oF3tN 4IZnnQd4T5HVT5mutxdPEmtgJRveLVugyGDXwYFblcxhg/t9Y8ZFZu3U8aiirjHGiOGL CJqxDN4nZFrCV04Ghe8aAEUyvZ2R0dYQl131RZ+TdHRmx6Y3+vWXapMkFdD8/xFOfIOF hcu58IRTkw3ftFDvCe2EDQZHJRWC94MoH/p/6YoyFmL4oLl3ZO9slt8Mv7IzSDx1n9IY qKpg== X-Gm-Message-State: AJIora+WTqBwliBY55CgI4OTD98mCpaJkyV4HSuX1eEgnftUTU78XKx2 /GJ0CsnrKzrc9Bpb8wd9jNCtM/JgLo69Lw== X-Google-Smtp-Source: AGRyM1vNhcSQ4cLesuGgv3qkfE3jY1AKVsWNIcxW+BBa7sx88QElYkvOiAzS9DiPMgbPJJK3sw+ieQ== X-Received: by 2002:a1c:f60f:0:b0:3a0:3e0c:1de1 with SMTP id w15-20020a1cf60f000000b003a03e0c1de1mr12642265wmc.56.1656599755952; Thu, 30 Jun 2022 07:35:55 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r5-20020a05600c320500b0039db500714fsm6405945wmp.6.2022.06.30.07.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 07:35:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 30 Jun 2022 16:35:38 +0200 Message-Id: <20220630143543.39599-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220630143543.39599-1-dse@thaumatec.com> References: <20220630143543.39599-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/8] ipa: rkisp1: Add AF algorithm basing on common AfHillClimbing 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: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Rockchip ISP AF block allows calculation of sharpness and luminance in up to three user defined windows. If no windows are set, there are some default settings applied for the first window and exposed through the driver. For each frame, use the sharpness value calculated for this default window and feed the hill climbing algorithm with them. Then set the lens position to value calculated by the algorithm. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/algorithms/af.cpp | 70 +++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/af.h | 32 ++++++++++++ src/ipa/rkisp1/algorithms/meson.build | 1 + 3 files changed, 103 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/af.cpp create mode 100644 src/ipa/rkisp1/algorithms/af.h diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp new file mode 100644 index 00000000..8da970e3 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Theobroma Systems + * + * af.cpp - AF control algorithm + */ + +#include "af.h" + +/** + * \file af.h + */ + +namespace libcamera::ipa::rkisp1::algorithms { + +/** + * \class Af + * \brief AF control algorithm + */ + +LOG_DEFINE_CATEGORY(RkISP1Af) + +/** + * \copydoc libcamera::ipa::Algorithm::configure + */ +int Af::configure([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const IPACameraSensorInfo &configInfo) +{ + return 0; +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void Af::prepare([[maybe_unused]] IPAContext &context, [[maybe_unused]] rkisp1_params_cfg *params) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::process + */ +void Af::process(IPAContext &context, + [[maybe_unused]] IPAFrameContext *frameCtx, + const rkisp1_stat_buffer *stats) +{ + uint32_t sharpness = stats->params.af.window[0].sum; + uint32_t luminance = stats->params.af.window[0].lum; + + LOG(RkISP1Af, Debug) << "lensPosition: " << context.frameContext.af.focus + << ", Sharpness: " << sharpness + << ", Luminance: " << luminance; + + uint32_t lensPosition = processAutofocus(sharpness); + + context.frameContext.af.focus = lensPosition; +} + +void Af::setMetering([[maybe_unused]] controls::AfMeteringEnum metering) +{ + LOG(RkISP1Af, Error) << __FUNCTION__ << " not implemented!"; +} + +void Af::setWindows([[maybe_unused]] Span windows) +{ + LOG(RkISP1Af, Error) << __FUNCTION__ << " not implemented!"; +} + +REGISTER_IPA_ALGORITHM(Af, "Af") + +} /* namespace libcamera::ipa::rkisp1::algorithms */ diff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h new file mode 100644 index 00000000..c470c9b2 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Theobroma Systems + * + * af.h - AF control algorithm + */ + +#pragma once + +#include + +#include "libipa/algorithms/af_hill_climbing.h" +#include "module.h" + +namespace libcamera::ipa::rkisp1::algorithms { + +class Af : public ipa::common::algorithms::AfHillClimbing +{ +public: + Af() = default; + ~Af() = default; + + int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; + void prepare(IPAContext &context, rkisp1_params_cfg *params) override; + void process(IPAContext &context, IPAFrameContext *frameCtx, + const rkisp1_stat_buffer *stats) override; + + void setMetering(controls::AfMeteringEnum metering) override; + void setWindows(Span windows) override; +}; + +} /* namespace libcamera::ipa::rkisp1::algorithms */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index 7ec53d89..81addcc9 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 rkisp1_ipa_algorithms = files([ + 'af.cpp', 'agc.cpp', 'awb.cpp', 'blc.cpp',