From patchwork Wed Jul 13 08:43:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16601 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 89F99BD1F1 for ; Wed, 13 Jul 2022 08:43:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C0DF6331B; Wed, 13 Jul 2022 10:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657701819; bh=3PwVJbBvJmfeOkck+hHDrKlm2mNGUdi/IampTEFq/pQ=; 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=0fH+pobQpcAfKxvWWjRB+vcdLd9SKoL4qiC+P4+HwQ35dYMjdSKPnjbvuDFDmJUw5 vWuTKhciGvUBZinj7FEEwHsiW69GhRoHK8G86LFBbdirIEwrwZ13ughHyTi4aVXA1i XiH/3CdRyMW3AuRMXCBbmNR+PnnTFs5QgzbsxgNVqHYe5x6O5GnvwwiL9LVg5bMoQq Ft+HWt5a52Za5ENXPw7THGAV7O5jcyPe5iVBlZ5vQoTPvKtIY28OT8Zuo7f+XfOd/x M0Wb68tnanCAVO8Jmxiq5wI8BeK97+j5/3SuyJ4hKif2A/byNSkLN/f9bJ1nvSesMn O1LtOUFFFzDaA== 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 DF23063315 for ; Wed, 13 Jul 2022 10:43:36 +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="8EGeQgKO"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id d16so14448614wrv.10 for ; Wed, 13 Jul 2022 01:43:36 -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=LNUrI0Wv0kp01lau6uWaUf3XyBtzo2JjTSprG0e5S14=; b=8EGeQgKOOOisH7P0dTOndC1qlw2bK4ghXGI+UkDzvEMC+cN4F0gxaUKEa8jxjsP9gF r5W54MuvcPKYH1DRsV1TSrh3miFtfPYyG200zJiTo6h+zM5Ff7xJOcM5bXbm9qax64v4 T1JszZ4tNCe3aqvsYzlCCdOsPAF2wxna3ix4b3m9IREWliXu6YB7l7rRO33t6bIvm6WX u+wu1Z0X+bC3qv/cAkzolpHCECOyTOugqvLNN3NNR99pfZeqatKBq8CpeTVzuXWG45Ml ODE2uff+sXUo7aK+9iaiaQwqlzr0Sg+vGc8/Sc+bPSkNJ6YGfhCf2rl12stIy34Vp5KN PFSw== 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=LNUrI0Wv0kp01lau6uWaUf3XyBtzo2JjTSprG0e5S14=; b=Zy6l46vWPwrc9DtoUU9Z6AaLaRa6YQEOdgQHptbNE2Yr1qOaEbLk/4exQJ0/0u1b6k /OYqlyI8/uOqWpkosshfpKafV1K14Pr9lS5VOszJz6JkBpEJD2Q77F36esnB2tvMb6hW nyHcs1aXZLz5GLpw4QuIxrsTAVM0nJPXx2n0UTNrRkhxawqZU8GjJmxKMboRaoUJ/52F D/+2cC8A/wtwO46wCuWWlMvbmQV2Iuf0BQJbSE74fKsbpQxEU2KnCeoQDwmeLFUUxdG/ TL9bTUOIQv1y0JpvB2XqGdIT9AOH0wv6f3HHEN4HDDNeZle9Y/Dd+PzzOnGYUQRMX73m mCSA== X-Gm-Message-State: AJIora8ifm4eCJffFqzkfSGyozxhYCy4pFUE4fJfKnu1cawDdnLa4TQT 8Sccda7sEp/9466H9fKszJ0qPghsJHSjnA== X-Google-Smtp-Source: AGRyM1v5FO/Brnvq/4vMKsvTqkC++lddNc8hqxqWtIaz/2nIVBbfUMt25Dggj0QbBZjMPsfsEuFWUQ== X-Received: by 2002:a5d:530f:0:b0:21d:9669:1f44 with SMTP id e15-20020a5d530f000000b0021d96691f44mr2036275wrv.644.1657701816664; Wed, 13 Jul 2022 01:43:36 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id bg32-20020a05600c3ca000b003a04d19dab3sm5667468wmb.3.2022.07.13.01.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 01:43:36 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Jul 2022 10:43:09 +0200 Message-Id: <20220713084317.24268-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713084317.24268-1-dse@thaumatec.com> References: <20220713084317.24268-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 03/11] 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..6e047804 --- /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 - RkISP1 AF hill climbing based 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..e9afbb98 --- /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 - RkISP1 AF hill climbing based 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',