From patchwork Thu Jan 19 08:41:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18140 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 183BCC3240 for ; Thu, 19 Jan 2023 08:42:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C268E625E3; Thu, 19 Jan 2023 09:42:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117729; bh=wiJDd7y1fycJxQBDca5N59hZkPVi42l9UKQoTsqJ2Hg=; 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=fHU/KwxI1OmStEXXi6XaSZEx7y7sA4HmHwGB3NolQR+mAfYEKwnUhQGMZ5sOct01p qKSQ4HEwkDkXpqZQTXOOvbOqH4zThjYUId5sIUvQfnc/HIAvX5DEoD5Ht2A5AQvP7I dxHwXHruhmn4Vvrz1ZEDtER0kQy6mwZ+Ho8P7kbhI3VTNnLdM8Rt/DZmtNjUnRfS+q bB95UZ8RANWuwVKn22MSzLB4d5GkwkWXwLxZBw3hbEs7QuQ861NNXuwh9PyUPyv+6K I77rwm0Szpo50LA0SvATXeH5dxjdPPnvXami9OIfAB/MIjNMlXjSkUWarL1wv/RD9C n4rVXW5/5b9tw== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0667F61EFC for ; Thu, 19 Jan 2023 09:42:08 +0100 (CET) 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="katmaffj"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id fl11-20020a05600c0b8b00b003daf72fc844so3065354wmb.0 for ; Thu, 19 Jan 2023 00:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e7gmClNwwbQ5j37r/NYsnEON5vAdMEldk/3IHa6ctl4=; b=katmaffj+oTS0pfQf7rYfNgFP7mcc7Dkla3H1fa1KZ87Bs4vpQInfQnh5gupLh2eWJ TPCmiYWmHtcSww4WpQ7d1Ip19W7ykwbR/4QsESpxuvTCcoLBmE872HiFgU0QvRILdzdk tdHJKCn0xQdVauntuwyciFcs15dZj30qOP5W0YFKV/+h+otAjcW7EsLYIKIKht/aFa3J 4JVkFIY2N0rpQ5gbkrVV0dDBpa2nR7KP+nMVObvB+eSq3XULCMD/D6x2tZO0CU3Xp4Ff 5mtTLoZJEN8NN61IqKcu65aABLvXIvl8cCF+2TK4kc1fV5Yw/VBUaJHYCKu5SW3+AaC7 teuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e7gmClNwwbQ5j37r/NYsnEON5vAdMEldk/3IHa6ctl4=; b=kw1AJb1OfPmsDA4Ba5m4SAS/s1iVB7LAEUzluyH0Fi8vADnJ/COHki6TBOicmTkftr F0mr+0x9GEPmXxFjeW2ZZDbe2E48q2ehSQcaJb/NRPPsz3q3PMMtyhPPV15Jlm62nhDG 8lIo5WuVcV67j4PUyoUHqCo3vA5ZM33hgpi80bIozZaouDWhdQQqVVRyRBmbedrM/llO 65Fw92+wLgV23aZmljXE/lFBNhhqp4ad1Yh7eDTmgF8sP2K98GNyEDAVFF2ZaVqwsDNo irUvocR+arP6dPzMTcZdklKVE0XAJBNl22cj8y7872WOGJ7Re55EYa2Vs4Y6bMdHVKEr GNfQ== X-Gm-Message-State: AFqh2kqDlWW0+4JuL1CMBDho7np8TxrNCqvsqkDmCp3pfgiJA2aOyEk6 x98aYggM6EKcqYe0F/YiRaHST3o1iqGVE7riTzs= X-Google-Smtp-Source: AMrXdXtgfMtfQ1RJ0yYQTVE/8MTFole2zvm8W393kIIDzo0+x/plubGdX1XncLDMlcPZ4gyOtvemIg== X-Received: by 2002:a05:600c:601c:b0:3d3:4f56:62e1 with SMTP id az28-20020a05600c601c00b003d34f5662e1mr9390438wmb.27.1674117727760; Thu, 19 Jan 2023 00:42:07 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:07 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:05 +0100 Message-Id: <20230119084112.20564-2-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/8] rkisp1: Add camera lens to PH and expose it to the IPA 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" Check in pipeline handler if camera lens exists, add expose its controls to the IPA. Signed-off-by: Daniel Semkowicz Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- include/libcamera/ipa/rkisp1.mojom | 1 + src/ipa/rkisp1/rkisp1.cpp | 5 +++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 1009e970..bf6e9141 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -11,6 +11,7 @@ import "include/libcamera/ipa/core.mojom"; struct IPAConfigInfo { libcamera.IPACameraSensorInfo sensorInfo; libcamera.ControlInfoMap sensorControls; + libcamera.ControlInfoMap lensControls; }; interface IPARkISP1Interface { diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 6544c925..9e861fc0 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -80,6 +81,7 @@ private: std::map mappedBuffers_; ControlInfoMap sensorControls_; + std::optional lensControls_; /* revision-specific data */ rkisp1_cif_isp_version hwRevision_; @@ -215,6 +217,9 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, { sensorControls_ = ipaConfig.sensorControls; + if (!ipaConfig.lensControls.empty()) + lensControls_ = ipaConfig.lensControls; + const auto itExp = sensorControls_.find(V4L2_CID_EXPOSURE); int32_t minExposure = itExp->second.min().get(); int32_t maxExposure = itExp->second.max().get(); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 5bdb4d25..0559d261 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -31,6 +31,7 @@ #include #include "libcamera/internal/camera.h" +#include "libcamera/internal/camera_lens.h" #include "libcamera/internal/camera_sensor.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" @@ -807,6 +808,10 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) ipaConfig.sensorControls = data->sensor_->controls(); + CameraLens *lens = data->sensor_->focusLens(); + if (lens) + ipaConfig.lensControls = lens->controls(); + ret = data->ipa_->configure(ipaConfig, streamConfig, &data->controlInfo_); if (ret) { LOG(RkISP1, Error) << "failed configuring IPA (" << ret << ")"; From patchwork Thu Jan 19 08:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18141 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 DB73FC3294 for ; Thu, 19 Jan 2023 08:42:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 70C01625EB; Thu, 19 Jan 2023 09:42:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117730; bh=MHzwZkPrjFZzqFqY+IIHDDrrED15mLTFTjZlBdvTItc=; 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=OXOIgBoQBvFZPJG4aBNla6KfgIEDwB6+5RWoYE2Uc8QthAbzpDD8zttLuOY/Qvqra gNWAeoLPUg0XRlzqvP2KdT9hlTYWg3fUIsLI+n2/IfxVBE0b0GGPwQdCm0c7k/kQwT bzymZgyrarUBf8k3Y8znk33vFP5tYsA+RqWrKDmD7t5tsYBUglIyvA9zRhpTjJH0Om Icrr4+1ZxLTQJq97Dz4O8avFVt5tG+SIJbqEMjKpbFMDfbKa5wi93/7p17tIQp1Mi9 874KQ2BWYGg4Aa8QFgzSjKbG5clXKspVWxMLVNt8n5VWUDaz5JIA3EcKXLOUV1OYmM uIQJMoE1DZO4Q== 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 2542361EFC for ; Thu, 19 Jan 2023 09:42:09 +0100 (CET) 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="QEx+T+Bs"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so3027904wml.3 for ; Thu, 19 Jan 2023 00:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ruQTIYdis1jrfTOZQl3cOInBkB3eyVJBswJS5xkktXk=; b=QEx+T+Bs5xexf697oj9h1b/guMUTM7yYtVbvizOmlJYhN5rgO79oZNq+gJnZdscC0/ +HYgc3xMj1ZzTkH//qPfQqWuOxqURYx3SZC1/u++GmW7KW/I5teFgbYMtwM2WMzN6GE7 wahxihZCZAqWCLbWWS8axDR0P32c3fC03F3gPARMs2Rb4IiC/9B5PFvYZhUGCxVaNACL U/MBcWHUbXN5q8CyvDqVGdw5TxoTGZcSQJeN3PN/zqbSInlB8RnBpY9H82zV/Ja66vTC v7V62Q7Hc1R/O8+EIVenisIvRL2lOfPPxNtDbDufGcLCcKMfB9ri4NaEKFmfFHmrQ1nN 8dEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ruQTIYdis1jrfTOZQl3cOInBkB3eyVJBswJS5xkktXk=; b=Z5+X1Zvh5Nwjdhfk08VzE0a33dBs7KUXtkAjnwZ7AI/4DEg7kGEMLLNRTgkETb+g6f j0ZJiknMXnjw1pZCwB04pKtM0p6Rr1hYh/g0ZvAY7Oy0v34MLVNR5LzeXNyoncmum7cD /NdebZxZH7mf8QMaR9O5qOdntHHCEW/WASiI6SMqqN1wYC4d+y8KjUChJA4wl46Tl6su ng6O1YkfMq7XQhsfZcMGLdHutnmcvH0+mh3I+03eG8766U1iPlecAx/UAhD20bwYmoIM 3686kNWxVhEjs6YQ6YYkyFwLLXqgCVyOj/2FMwWjasHLtIFZaCtVsnkqgxle+oRmxM7K uAKg== X-Gm-Message-State: AFqh2kooLG4uC5BY2igvDK+VfQHR+iYBr+X6ZsNX0E3u6XUCsnKQ87wu Mz2mLlbec71913IwJEdqPVBFPbUn01+N1R3efxg= X-Google-Smtp-Source: AMrXdXu/6QSSIZbHtHdJqZ6kP/Ig7yA2INmPsp/rbahcU7780NiXuxXCZpjE7VY6qgWBU0aayn0fuA== X-Received: by 2002:a05:600c:13c8:b0:3db:3e8:feca with SMTP id e8-20020a05600c13c800b003db03e8fecamr9923463wmg.15.1674117728880; Thu, 19 Jan 2023 00:42:08 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:08 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:06 +0100 Message-Id: <20230119084112.20564-3-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/8] rkisp1: Control camera lens position from IPA 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" Allow control of lens position from the IPA, by setting corresponding af fields in the IPAFrameContext structure. Controls are then passed to the pipeline handler, which sets the lens position in CameraLens. Signed-off-by: Daniel Semkowicz --- include/libcamera/ipa/rkisp1.mojom | 1 + src/ipa/rkisp1/ipa_context.h | 5 +++++ src/ipa/rkisp1/rkisp1.cpp | 12 ++++++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 16 ++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index bf6e9141..c3ed87aa 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -39,5 +39,6 @@ interface IPARkISP1Interface { interface IPARkISP1EventInterface { paramsBufferReady(uint32 frame); setSensorControls(uint32 frame, libcamera.ControlList sensorControls); + setLensControls(libcamera.ControlList lensControls); metadataReady(uint32 frame, libcamera.ControlList metadata); }; diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b9b20653..1fac6af9 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -53,6 +53,11 @@ struct IPASessionConfiguration { }; struct IPAActiveState { + struct { + uint32_t lensPosition; + bool applyLensCtrls; + } af; + struct { struct { uint32_t exposure; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e861fc0..297161b2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -270,6 +270,10 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + /* Lens position is unknown at the startup, so initilize the variable + * that holds the current position to something out of the range. */ + context_.activeState.af.lensPosition = std::numeric_limits::max(); + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); @@ -452,6 +456,14 @@ void IPARkISP1::setControls(unsigned int frame) ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); setSensorControls.emit(frame, ctrls); + + if (lensControls_ && context_.activeState.af.applyLensCtrls) { + context_.activeState.af.applyLensCtrls = false; + ControlList lensCtrls(*lensControls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + static_cast(context_.activeState.af.lensPosition)); + setLensControls.emit(lensCtrls); + } } } /* namespace ipa::rkisp1 */ diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 0559d261..b2fedc5f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -113,6 +113,7 @@ private: void paramFilled(unsigned int frame); void setSensorControls(unsigned int frame, const ControlList &sensorControls); + void setLensControls(const ControlList &lensControls); void metadataReady(unsigned int frame, const ControlList &metadata); }; @@ -337,6 +338,7 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return -ENOENT; ipa_->setSensorControls.connect(this, &RkISP1CameraData::setSensorControls); + ipa_->setLensControls.connect(this, &RkISP1CameraData::setLensControls); ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled); ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady); @@ -400,6 +402,20 @@ void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame, delayedCtrls_->push(sensorControls); } +void RkISP1CameraData::setLensControls(const ControlList &lensControls) +{ + CameraLens *focusLens = sensor_->focusLens(); + if (!focusLens) + return; + + if (!lensControls.contains(V4L2_CID_FOCUS_ABSOLUTE)) + return; + + const ControlValue &focusValue = lensControls.get(V4L2_CID_FOCUS_ABSOLUTE); + + focusLens->setFocusPosition(focusValue.get()); +} + void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) { RkISP1FrameInfo *info = frameInfo_.find(frame); From patchwork Thu Jan 19 08:41:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18142 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 E0EB8C3240 for ; Thu, 19 Jan 2023 08:42:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 89974625F5; Thu, 19 Jan 2023 09:42:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117733; bh=y3vF8V8I3AUjjNn+AFv2YT48BWnRplFjpI7zOyj/uWw=; 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=VlcMB4RW5/lTxsHyKtIsV28EwkUuAuilwVR/iKPX9iTNrMiVhjLGeenWay5Hf3R71 WF6VccxNEmbJyhS6rha+Qc4Q3f9ll3a76DQeTvV1PGxEmSBYCsL7Rf7r1NDPWV8Ogr CJPoN7S9pCz02lD8dZZzuvWSlxTYDgQvipfFrp0h+C/GR61v5px8h95xe1MB2lvCcD 31X8KQKTcE9JQqVQkUKRvMNlGrWEE5nOWbxCPwZHomBPZu/hmH04mjZN4+ks5R8l6f 5e/46p0/OiFYJ21CHJ5g8J75tTOOWoN0zJ9fjwiSyUYiXBM3nCUYesFd3EibQTgLAL hxSSlulLstpLA== 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 3FF70625D8 for ; Thu, 19 Jan 2023 09:42:10 +0100 (CET) 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="BltcjWGN"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id m15so900450wms.4 for ; Thu, 19 Jan 2023 00:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xm49jR5et7fNPrzF0NIG3A+f0aOzkc1oiwUtbL9VUBg=; b=BltcjWGNEKiKttvTJwsFXyVAh7Kt2ucu4MFXdB4+BGD1RYw9gZRrCXYsjx0ld0Dl5K j1TlKVMBfjOxI/LhR/1ickVLvTAGIo2jUXddVchHVfWveYOV3r5T4SOd9CluM2n+lfub Zt2v2gzhZZTMyMxxnzmnUfAK+QAyGuQ7i28u0aqEZJMqJO5crPBRQ9CJxDk38VLO91NX pFwUk5Va/amfs1kh4yK2mbWeSZikyLgJRupgFUqwJ1h1XlU0R85oyE9ZxgLX0DAVHxYF 7HxhRW2OrsL80H9xBjl21riwg/oAdFgEOVccFibGDdTnfvQ0Cn3EhGZ/Kxf9LLae6vSt bBFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xm49jR5et7fNPrzF0NIG3A+f0aOzkc1oiwUtbL9VUBg=; b=tjb8SOJb49ew1kOSXV3OtDw0roQwtgFbSvE/T2NnebDiQrla1YmKKf1Nf43Xcj3yBY ydXr0AB0A98ax+uP1Rpkiee3MZKNjN+jnbfTBCVmh6aEfB9XhUhJkGaBFuXKJJkt5gzj NV1EtZjaoBIhscz6vg2CWvn6ltclc7uT61sDxy+9I2E90yPX/GoiQhXhMqLUY+rBgo2b 8nIyXV0sl1fg5PsOsxB85iu+1EQifwMqTsQwPF1sjJniMGUbltp7V+f1wvAcKdf624vB vv4ZalYMhx4AruVyWNGAeAPw0monN7oIAdmdiFvOm61KSeNPcssFQTO1mCQSpFIVHZl3 WasQ== X-Gm-Message-State: AFqh2krnxpmmrirTVnazFitTuC0vbj9q9fSK+HvgGaXq9173lAYWi2G5 ZH8+B9lDaUBKG5IE0SY98Xiy7oXyNcAUVUSxXoE= X-Google-Smtp-Source: AMrXdXujQzmcyAN+bIbLFMQ5hZEi0yJVcCYPC7THWY4HWEMMCMZQKwuSzG6D2QqZnIp7Sq1zzcKocg== X-Received: by 2002:a05:600c:1c2a:b0:3cf:d0b1:8aa1 with SMTP id j42-20020a05600c1c2a00b003cfd0b18aa1mr9371352wms.0.1674117729729; Thu, 19 Jan 2023 00:42:09 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:09 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:07 +0100 Message-Id: <20230119084112.20564-4-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/8] ipa: Add base class defining AF algorithm interface 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" Define common interface with basic functions that should be supported by Auto Focus algorithms. Signed-off-by: Daniel Semkowicz --- src/ipa/libipa/algorithms/af_interface.cpp | 92 ++++++++++++++++++++++ src/ipa/libipa/algorithms/af_interface.h | 41 ++++++++++ src/ipa/libipa/algorithms/meson.build | 9 +++ src/ipa/libipa/meson.build | 6 ++ 4 files changed, 148 insertions(+) create mode 100644 src/ipa/libipa/algorithms/af_interface.cpp create mode 100644 src/ipa/libipa/algorithms/af_interface.h create mode 100644 src/ipa/libipa/algorithms/meson.build diff --git a/src/ipa/libipa/algorithms/af_interface.cpp b/src/ipa/libipa/algorithms/af_interface.cpp new file mode 100644 index 00000000..af341d13 --- /dev/null +++ b/src/ipa/libipa/algorithms/af_interface.cpp @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Theobroma Systems + * + * af_interface.cpp - Autofocus control algorithm interface + */ + +#include "af_interface.h" + +/** + * \file af_interface.h + * \brief AF algorithm common interface + */ + +namespace libcamera::ipa::common::algorithms { + +/** + * \class AfInterface + * \brief Common interface for auto-focus algorithms + * \tparam Module The IPA module type for this class of algorithms + * + * The AfInterface class defines a standard interface for IPA auto focus + * algorithms. + */ + +/** + * \fn AfInterface::setMode() + * \brief Set auto focus mode + * \param[in] mode AF mode + */ + +/** + * \fn AfInterface::setRange() + * \brief set the range of focus distances that is scanned + * \param[in] range AF range + */ + +/** + * \fn AfInterface::setSpeed() + * \brief Set how fast algorithm should move the lens + * \param[in] speed Lens move speed + */ + +/** + * \fn AfInterface::setMeteringMode() + * \brief Set AF metering mode + * \param[in] metering AF metering mode + */ + +/** + * \fn AfInterface::setWindows() + * \brief Set AF windows + * \param[in] windows AF windows + * + * Sets the focus windows used by the AF algorithm when AfMetering is set + * to AfMeteringWindows. + */ + +/** + * \fn AfInterface::setTrigger() + * \brief Starts or cancels the autofocus scan + * \param[in] trigger Trigger mode + */ + +/** + * \fn AfInterface::setPause() + * \brief Pause the autofocus while in AfModeContinuous mode. + * \param[in] pause Pause mode + */ + +/** + * \fn AfInterface::setLensPosition() + * \brief Set the lens position while in AfModeManual + * \param[in] lensPosition Lens position + */ + +/** + * \fn AfInterface::getState() + * \brief Get the current state of the AF algorithm + * \return AF state + */ + +/** + * \fn AfInterface::getPauseState() + * \brief Get the current pause state of the AF algorithm. + * \return AF pause state + * + * Only applicable in continuous (AfModeContinuous) mode. In other modes, + * AfPauseStateRunning is always returned. + */ + +} /* namespace libcamera::ipa::common::algorithms */ diff --git a/src/ipa/libipa/algorithms/af_interface.h b/src/ipa/libipa/algorithms/af_interface.h new file mode 100644 index 00000000..b6b7bea6 --- /dev/null +++ b/src/ipa/libipa/algorithms/af_interface.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2022, Theobroma Systems + * + * af_interface.h - Autofocus control algorithm interface + */ +#pragma once + +#include + +namespace libcamera::ipa::common::algorithms { + +class AfInterface +{ +public: + AfInterface() = default; + + virtual ~AfInterface() {} + + virtual void setMode(controls::AfModeEnum mode) = 0; + + virtual void setRange(controls::AfRangeEnum range) = 0; + + virtual void setSpeed(controls::AfSpeedEnum speed) = 0; + + virtual void setMeteringMode(controls::AfMeteringEnum metering) = 0; + + virtual void setWindows(Span windows) = 0; + + virtual void setTrigger(controls::AfTriggerEnum trigger) = 0; + + virtual void setPause(controls::AfPauseEnum pause) = 0; + + virtual void setLensPosition(float lensPosition) = 0; + + virtual controls::AfStateEnum getState() = 0; + + virtual controls::AfPauseStateEnum getPauseState() = 0; +}; + +} /* namespace libcamera::ipa::common::algorithms */ diff --git a/src/ipa/libipa/algorithms/meson.build b/src/ipa/libipa/algorithms/meson.build new file mode 100644 index 00000000..0a1f18fa --- /dev/null +++ b/src/ipa/libipa/algorithms/meson.build @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: CC0-1.0 + +common_ipa_algorithms_headers = files([ + 'af_interface.h', +]) + +common_ipa_algorithms_sources = files([ + 'af_interface.cpp', +]) diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index 016b8e0e..0cfc551a 100644 --- a/src/ipa/libipa/meson.build +++ b/src/ipa/libipa/meson.build @@ -1,5 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 +subdir('algorithms') + libipa_headers = files([ 'algorithm.h', 'camera_sensor_helper.h', @@ -8,6 +10,8 @@ libipa_headers = files([ 'module.h', ]) +libipa_headers += common_ipa_algorithms_headers + libipa_sources = files([ 'algorithm.cpp', 'camera_sensor_helper.cpp', @@ -16,6 +20,8 @@ libipa_sources = files([ 'module.cpp', ]) +libipa_sources += common_ipa_algorithms_sources + libipa_includes = include_directories('..') libipa = static_library('ipa', [libipa_sources, libipa_headers], From patchwork Thu Jan 19 08:41:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18143 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 9F966C3294 for ; Thu, 19 Jan 2023 08:42:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B9D2625EF; Thu, 19 Jan 2023 09:42:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117734; bh=cdDw3wLjtAxgG2wNWJVhKXvwAFh7apoEwpxuDYly+Ho=; 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=0pwEyM0xqnLIvNjInm5+JqyhWuu80Ew5XiEPOPmgwZSgN/4tMGE2SHgYsX6VOD/rc t3QhEpeMJlN3fqzIrry5keo0ckcb60MHoteSxf2la7RV37OdvUHiUaF7EQKtlmYnK/ a26RELrfqp6WJ+aOLfnJWTqDcz81v1taTmC2IT/4bGRh+kjvW0Kw2yHoNpSyxTA2dn jnRtTYyVrYNwzB0T37qGMugRvYw790UfxjuXLADYjnFmQfbBanE7nITqgQXWIS+15v 9LUrLBrfw2WuXeKjZqm8/TgFLc37gIMEBTSMUpR0B9sJvPPKu7D4zNTO1QXzBguAz/ kwq4xkvMKUl6g== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E86AE625E4 for ; Thu, 19 Jan 2023 09:42:10 +0100 (CET) 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="drqI85D8"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id fl11-20020a05600c0b8b00b003daf72fc844so3065416wmb.0 for ; Thu, 19 Jan 2023 00:42:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=itD8A+wtqRccuaPMhFqApXoteZFJJSNNTdE3362xvIY=; b=drqI85D8+0Ndms2FhdgjVhGTC1JLruAHV370O5eoAtPqqGBaCeLU7wMESP6o7OMoAt CIV52wsrtJJWhgTz8FcUGZj7k4RXw89FSE+VpbyGq1makA9eA6SW1rrVPjKueCp2GJ0z HQdrqnKQrNEMPFLtv6ZcAN6Dkq2ofzUgwHCYm+y2iUyqNXlJC3Q3KUFXdmEDZNRvXARa WUAUYJNGdHNCGxBLbweVrZa6y6blpshyftzSDrlSrDEgBfEQQKcnF4vjEgPJs2motj8R QcAGyKcpTrkUdwpT5KU8XwTmdr2sWOPBQ8JJgsoZie//7OTwDBSdSJ1wUIzourZ/065m pFRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=itD8A+wtqRccuaPMhFqApXoteZFJJSNNTdE3362xvIY=; b=YLVp5ZqMaiGSg3TdsMV+FZ9cA1kZCVx+ATl3Kyf6qmvkT+zxpgqcx64L6Uc1Bf1pNQ QI152Q92eXLe/pKxLmvsdyMJE+zDmse7VKwZhcsQH8a9sGSuh0ITscCeAEijx/fhNPsr vhinl/t6kkoH5QKfWp7bswkb8SjTw2HtcVjEzYkj8Y7Sn5sWSb0bNiY0stkgGwewxuKa MFhn2PbdZwSx6RPI+3/zeNM/5Fcu+PFhC3z1kNsHI/YJNVaqKF8OAk1fieokqBYKqK6n AZP1IDUKMsuYYe/dWl+GVxTFhjShfToO0kTV1MbJHHu7nokCJQ1dCgaaDc+H8twh0boL tkbg== X-Gm-Message-State: AFqh2krHjtwtA0Dqpea1o7PKzLRsFCPNH7QEDLBx9WypECoTQawXtWBf /jr9MkjATLHeLsV/H+w/I/WFsqJtJKvrDQFl60Q= X-Google-Smtp-Source: AMrXdXsg3AZCh8+rDuRnuQYUXxFMs5GDOPHUJpRRb63sLPA5ORDZTfQy/oh29kZCT1Y65hJooYqPXg== X-Received: by 2002:a05:600c:2d4c:b0:3da:fada:e38a with SMTP id a12-20020a05600c2d4c00b003dafadae38amr9114296wmg.24.1674117730648; Thu, 19 Jan 2023 00:42:10 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:10 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:08 +0100 Message-Id: <20230119084112.20564-5-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/8] ipa: Add class that implements base AF control 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: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Move the code that was common for IPU3 and RPi AF algorithms to a separate class independent of platform specific code. This way each platform can just implement contrast calculation and run the AF control loop basing on this class. Signed-off-by: Daniel Semkowicz --- .../libipa/algorithms/af_hill_climbing.cpp | 374 ++++++++++++++++++ src/ipa/libipa/algorithms/af_hill_climbing.h | 102 +++++ src/ipa/libipa/algorithms/meson.build | 2 + 3 files changed, 478 insertions(+) create mode 100644 src/ipa/libipa/algorithms/af_hill_climbing.cpp create mode 100644 src/ipa/libipa/algorithms/af_hill_climbing.h diff --git a/src/ipa/libipa/algorithms/af_hill_climbing.cpp b/src/ipa/libipa/algorithms/af_hill_climbing.cpp new file mode 100644 index 00000000..e2eaf3d4 --- /dev/null +++ b/src/ipa/libipa/algorithms/af_hill_climbing.cpp @@ -0,0 +1,374 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Red Hat + * Copyright (C) 2022, Ideas On Board + * Copyright (C) 2022, Theobroma Systems + * + * af_hill_climbing.cpp - AF Hill Climbing common algorithm + */ + +#include "af_hill_climbing.h" + +#include "libcamera/internal/yaml_parser.h" + +/** + * \file af_hill_climbing.h + * \brief AF Hill Climbing common algorithm + */ + +namespace libcamera::ipa::common::algorithms { + +LOG_DEFINE_CATEGORY(Af) + +/** + * \class AfHillClimbing + * \brief The base class implementing hill climbing AF control algorithm + * \tparam Module The IPA module type for this class of algorithms + * + * Control part of auto focus algorithm. It calculates the lens position basing + * on contrast measure supplied by the higher level. This way it is independent + * from the platform. + * + * Derived class should call processAutofocus() for each measured contrast value + * and set the lens to the calculated position. + */ + +/** + * \brief Initialize the Algorithm with tuning data + * \param[in] tuningData The tuning data for the algorithm + * + * This function should be called in the init() function of the derived class. + * See alse: libcamera::ipa::Algorithm::init() + * + * \return 0 if successful, an error code otherwise + */ +int AfHillClimbing::initBase(const YamlObject &tuningData) +{ + minVcmPosition_ = tuningData["min-vcm-position"].get(0); + maxVcmPosition_ = tuningData["max-vcm-position"].get(100); + coarseSearchStep_ = tuningData["coarse-search-step"].get(30); + fineSearchStep_ = tuningData["fine-search-step"].get(1); + fineRange_ = tuningData["fine-scan-range"].get(0.05); + maxChange_ = tuningData["max-variance-change"].get(0.5); + + LOG(Af, Debug) << "minVcmPosition_: " << minVcmPosition_ + << ", maxVcmPosition_: " << maxVcmPosition_ + << ", coarseSearchStep_: " << coarseSearchStep_ + << ", fineSearchStep_: " << fineSearchStep_ + << ", fineRange_: " << fineRange_ + << ", maxChange_: " << maxChange_; + + return 0; +} + +/** + * \brief Provide control values to the algorithm + * \param[in] frame The frame number to apply the control values + * \param[in] controls The list of user controls + * + * This function should be called in the queueRequest() function of the derived class. + * See alse: libcamera::ipa::Algorithm::queueRequest() + */ +void AfHillClimbing::queueRequestBase([[maybe_unused]] const uint32_t frame, const ControlList &controls) +{ + for (auto const &[id, value] : controls) { + switch (id) { + case controls::AF_MODE: { + setMode(static_cast(value.get())); + break; + } + case controls::AF_TRIGGER: { + setTrigger(static_cast(value.get())); + break; + } + case controls::AF_PAUSE: { + setPause(static_cast(value.get())); + break; + } + case controls::LENS_POSITION: { + setLensPosition(value.get()); + break; + } + default: + break; + } + } +} + +/** + * \brief Run the auto focus algorithm loop + * \param[in] currentContrast New value of contrast measured for current frame + * + * This method should be called for each new contrast value that was measured, + * usually in the process() method. + * + * \return New lens position calculated by AF algorithm + */ +uint32_t AfHillClimbing::processAutofocus(double currentContrast) +{ + currentContrast_ = currentContrast; + + if (shouldSkipFrame()) + return lensPosition_; + + switch (mode_) { + case controls::AfModeManual: + /* Nothing to process. */ + break; + case controls::AfModeAuto: + processAutoMode(); + break; + case controls::AfModeContinuous: + processContinousMode(); + break; + default: + break; + } + + return lensPosition_; +} + +void AfHillClimbing::processAutoMode() +{ + if (state_ == controls::AfStateScanning) { + afCoarseScan(); + afFineScan(); + } +} + +void AfHillClimbing::processContinousMode() +{ + /* If we are in a paused state, we won't process the stats */ + if (pauseState_ == controls::AfPauseStatePaused) + return; + + if (state_ == controls::AfStateScanning) { + afCoarseScan(); + afFineScan(); + return; + } + + /* We can re-start the scan at any moment in AfModeContinuous */ + if (afIsOutOfFocus()) { + afReset(); + } +} + +/** + * \brief Request AF to skip n frames + * \param[in] n Number of frames to be skipped + * + * Requested number of frames will not be used for AF calculation. + */ +void AfHillClimbing::setFramesToSkip(uint32_t n) +{ + if (n > framesToSkip_) + framesToSkip_ = n; +} + +/** + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setMode + */ +void AfHillClimbing::setMode(controls::AfModeEnum mode) +{ + if (mode == mode_) + return; + + LOG(Af, Debug) << "Switched AF mode from " << mode_ << " to " << mode; + mode_ = mode; + + state_ = controls::AfStateIdle; + pauseState_ = controls::AfPauseStateRunning; + + if (mode_ == controls::AfModeContinuous) + afReset(); +} + +/** + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setRange + */ +void AfHillClimbing::setRange([[maybe_unused]] controls::AfRangeEnum range) +{ + LOG(Af, Error) << __FUNCTION__ << " not implemented!"; +} + +/** + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setSpeed + */ +void AfHillClimbing::setSpeed([[maybe_unused]] controls::AfSpeedEnum speed) +{ + LOG(Af, Error) << __FUNCTION__ << " not implemented!"; +} + +/** + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setTrigger + */ +void AfHillClimbing::setTrigger(controls::AfTriggerEnum trigger) +{ + if (mode_ != controls::AfModeAuto) { + LOG(Af, Warning) << __FUNCTION__ << " not possible in mode " << mode_; + return; + } + + LOG(Af, Debug) << "Trigger called with " << trigger; + + if (trigger == controls::AfTriggerStart) + afReset(); + else + state_ = controls::AfStateIdle; +} + +/** + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setPause + */ +void AfHillClimbing::setPause(controls::AfPauseEnum pause) +{ + if (mode_ != controls::AfModeContinuous) { + LOG(Af, Warning) << __FUNCTION__ << " not possible in mode " << mode_; + return; + } + + switch (pause) { + case controls::AfPauseImmediate: + pauseState_ = controls::AfPauseStatePaused; + break; + case controls::AfPauseDeferred: + /* \todo: add the AfPauseDeferred mode */ + LOG(Af, Warning) << "AfPauseDeferred is not supported!"; + break; + case controls::AfPauseResume: + pauseState_ = controls::AfPauseStateRunning; + break; + default: + break; + } +} + +/** + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setLensPosition + */ +void AfHillClimbing::setLensPosition(float lensPosition) +{ + if (mode_ != controls::AfModeManual) { + LOG(Af, Warning) << __FUNCTION__ << " not possible in mode " << mode_; + return; + } + + lensPosition_ = static_cast(lensPosition); + + LOG(Af, Debug) << "Requesting lens position " << lensPosition_; +} + +/** + * \fn AfHillClimbing::setMeteringMode() + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setMeteringMode + */ + +/** + * \fn AfHillClimbing::setWindows() + * \copydoc libcamera::ipa::common::algorithms::AfInterface::setWindows + */ + +void AfHillClimbing::afCoarseScan() +{ + if (coarseCompleted_) + return; + + if (afScan(coarseSearchStep_)) { + coarseCompleted_ = true; + maxContrast_ = 0; + lensPosition_ = lensPosition_ - (lensPosition_ * fineRange_); + previousContrast_ = 0; + maxStep_ = std::clamp(lensPosition_ + static_cast((lensPosition_ * fineRange_)), + 0U, maxVcmPosition_); + } +} + +void AfHillClimbing::afFineScan() +{ + if (!coarseCompleted_) + return; + + if (afScan(fineSearchStep_)) { + LOG(Af, Debug) << "AF found the best focus position!"; + state_ = controls::AfStateFocused; + fineCompleted_ = true; + } +} + +bool AfHillClimbing::afScan(uint32_t minSteps) +{ + if (lensPosition_ + minSteps > maxStep_) { + /* If the max step is reached, move lens to the position. */ + lensPosition_ = bestPosition_; + return true; + } else { + /* + * Find the maximum of the variance by estimating its + * derivative. If the direction changes, it means we have passed + * a maximum one step before. + */ + if ((currentContrast_ - maxContrast_) >= -(maxContrast_ * 0.1)) { + /* + * Positive and zero derivative: + * The variance is still increasing. The focus could be + * increased for the next comparison. Also, the max + * variance and previous focus value are updated. + */ + bestPosition_ = lensPosition_; + lensPosition_ += minSteps; + maxContrast_ = currentContrast_; + } else { + /* + * Negative derivative: + * The variance starts to decrease which means the maximum + * variance is found. Set focus step to previous good one + * then return immediately. + */ + lensPosition_ = bestPosition_; + return true; + } + } + + previousContrast_ = currentContrast_; + LOG(Af, Debug) << "Previous step is " << bestPosition_ + << ", Current step is " << lensPosition_; + return false; +} + +void AfHillClimbing::afReset() +{ + LOG(Af, Debug) << "Reset AF parameters"; + lensPosition_ = minVcmPosition_; + maxStep_ = maxVcmPosition_; + state_ = controls::AfStateScanning; + previousContrast_ = 0.0; + coarseCompleted_ = false; + fineCompleted_ = false; + maxContrast_ = 0.0; + setFramesToSkip(1); +} + +bool AfHillClimbing::afIsOutOfFocus() +{ + const uint32_t diff_var = std::abs(currentContrast_ - maxContrast_); + const double var_ratio = diff_var / maxContrast_; + LOG(Af, Debug) << "Variance change rate: " << var_ratio + << ", Current VCM step: " << lensPosition_; + if (var_ratio > maxChange_) + return true; + else + return false; +} + +bool AfHillClimbing::shouldSkipFrame() +{ + if (framesToSkip_ > 0) { + framesToSkip_--; + return true; + } + + return false; +} + +} /* namespace libcamera::ipa::common::algorithms */ diff --git a/src/ipa/libipa/algorithms/af_hill_climbing.h b/src/ipa/libipa/algorithms/af_hill_climbing.h new file mode 100644 index 00000000..6ce95884 --- /dev/null +++ b/src/ipa/libipa/algorithms/af_hill_climbing.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Red Hat + * Copyright (C) 2022, Ideas On Board + * Copyright (C) 2022, Theobroma Systems + * + * af_hill_climbing.h - AF Hill Climbing common algorithm + */ + +#pragma once + +#include + +#include "af_interface.h" + +namespace libcamera { + +class YamlObject; + +namespace ipa::common::algorithms { + +LOG_DECLARE_CATEGORY(Af) + +class AfHillClimbing : public AfInterface +{ +public: + AfHillClimbing() = default; + virtual ~AfHillClimbing() {} + + controls::AfStateEnum getState() final { return state_; } + controls::AfPauseStateEnum getPauseState() final { return pauseState_; } + + /* These methods should be implemented by the derived class: */ + virtual void setMeteringMode(controls::AfMeteringEnum metering) = 0; + virtual void setWindows(Span windows) = 0; + +protected: + int initBase(const YamlObject &tuningData); + void queueRequestBase(const uint32_t frame, const ControlList &controls); + uint32_t processAutofocus(double currentContrast); + void setFramesToSkip(uint32_t n); + +private: + void setMode(controls::AfModeEnum mode) final; + void setRange(controls::AfRangeEnum range) final; + void setSpeed(controls::AfSpeedEnum speed) final; + void setTrigger(controls::AfTriggerEnum trigger) final; + void setPause(controls::AfPauseEnum pause) final; + void setLensPosition(float lensPosition) final; + + void processAutoMode(); + void processContinousMode(); + void afCoarseScan(); + void afFineScan(); + bool afScan(uint32_t minSteps); + void afReset(); + bool afIsOutOfFocus(); + bool shouldSkipFrame(); + + controls::AfModeEnum mode_ = controls::AfModeManual; + controls::AfStateEnum state_ = controls::AfStateIdle; + controls::AfPauseStateEnum pauseState_ = controls::AfPauseStateRunning; + + /* VCM step configuration. It is the current setting of the VCM step. */ + uint32_t lensPosition_ = 0; + /* The best VCM step. It is a local optimum VCM step during scanning. */ + uint32_t bestPosition_ = 0; + + /* Current AF statistic contrast. */ + double currentContrast_ = 0; + /* It is used to determine the derivative during scanning */ + double previousContrast_ = 0; + double maxContrast_ = 0; + /* The designated maximum range of focus scanning. */ + uint32_t maxStep_ = 0; + /* If the coarse scan completes, it is set to true. */ + bool coarseCompleted_ = false; + /* If the fine scan completes, it is set to true. */ + bool fineCompleted_ = false; + + uint32_t framesToSkip_ = 0; + + /* + * Focus steps range of the VCM control + * \todo should be obtained from the VCM driver + */ + uint32_t minVcmPosition_; + uint32_t maxVcmPosition_; + + /* Minimum focus step for searching appropriate focus */ + uint32_t coarseSearchStep_; + uint32_t fineSearchStep_; + + /* Fine scan range 0 < fineRange_ < 1 */ + double fineRange_; + + /* Max ratio of variance change, 0.0 < maxChange_ < 1.0 */ + double maxChange_; +}; + +} /* namespace ipa::common::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/libipa/algorithms/meson.build b/src/ipa/libipa/algorithms/meson.build index 0a1f18fa..a8d94056 100644 --- a/src/ipa/libipa/algorithms/meson.build +++ b/src/ipa/libipa/algorithms/meson.build @@ -2,8 +2,10 @@ common_ipa_algorithms_headers = files([ 'af_interface.h', + 'af_hill_climbing.h', ]) common_ipa_algorithms_sources = files([ 'af_interface.cpp', + 'af_hill_climbing.cpp', ]) From patchwork Thu Jan 19 08:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18144 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 C8DD0C3240 for ; Thu, 19 Jan 2023 08:42:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 333C0625FE; Thu, 19 Jan 2023 09:42:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117735; bh=gscmoJ/hmm/k0IzEqmPI5QVJOjA+vf+JMdzx/ZsIgbo=; 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=Iv0FHxHyMOvXNwKQiwEkE50tE5fkVmJ3cCPze2wt+m62OYDuRqr6fNfXGRTBtCbk2 a+spnWjsGwVC3Ut+GXqnVNp9TBke1RD7vWoz1m3Jna4BPt7QEawGKX2BN8SOj9XM9x 4636YrHA+EQdfRt0sCnvOnvVG7b3uJltG9/8O9LSu6YOSdJl65FCnER2Rpd/l7PN6S B5ei2dOLGg1i3iFsFvPG/OImVuWRePzxo2cr68ucA+1N9kRvnjHniqg1b/1WGOOOMo F0TcWStx73G/1MQba6bzQGRlUNQCl9lGgJNzf+9Fm3liVW1LJwV4AGmDn0Qwqzj9mx d8et4B5dGFF7A== 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 D2DC4625EA for ; Thu, 19 Jan 2023 09:42:11 +0100 (CET) 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="ryhjO1PV"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso679426wmq.5 for ; Thu, 19 Jan 2023 00:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kprmtRGy07+WJsHQiGi/OEpWYVBfWR8o/DjLzEG6T0c=; b=ryhjO1PV1mUiTqRiFrQuMEUV5l3eOgd0aK1Upw6EC9MCFEi9WdJppZr/c7rqZy+W/8 C7vE8WKwD+fBbCcG0kVyBunXXqwpJ+udZa9eiTHHk3ePESb5g/myaBlHoZmuzc+BQcVU bu56ENSQsNPQ0tsb4UsVwdxjUnyw9ItKYJQfPEgNQHEjN55Jh8fyw8TC9Rg4HE5iNpVA Tp476tWVCrSMankxF75ulIsuOssp9fTNRPUQ4cAZk/iDgU12AZi2S7rnVrezemhG3vbK 3z8STqEMxR81Ap4z37eA5QrrapwxwRDMm/pLNyVM2iqtQyqzmoBHpUUqVJrZMsn/me7w tgAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kprmtRGy07+WJsHQiGi/OEpWYVBfWR8o/DjLzEG6T0c=; b=FlRiFsaj/chSTcuZTNiJ434cUenijaRQmK/MVx4VQX9o9gPLqPfuEK84vHGzyTWl0M F0aJoqHm1e7prJxTJzUsZ2ac5L9DuAYQdP17/hgUNx34htTv1dNHMwwUEHeGS8LZBuVo nQ3iUIShDZnsAv7DVQhwl9cB/V3Zhn71wQXi21mS5fJ6n3zicbIqAH5dz6WDdaNgXBNC AhlgxV81FXJG3VCEpBVjNXEhlIPCSiXZwNo+DFKH5QJPNpeSTjmiWcl2W1zaZlPO1d7e A8Vn2mCeYXyJE3yxbCn4J0LclBTwksQlZWSuQQ2frPFwWMVCuv61zRRWGs2jIR8XyYwt 1zIw== X-Gm-Message-State: AFqh2kp3vcbvy+H4O+0lhdrHZDv4j2WREwCAvH4+6pa/a6Tlhoce1Vd4 wmn8XfP+sOhKqaVpXuCqTknf+8k04pvSL07wt1Q= X-Google-Smtp-Source: AMrXdXuiHsxfnR/BDIKAbQakqOzseeiNHabpbpwFENhtVX1w5SPPlXYX/kcqYlFot+MW6Vd8zehnDw== X-Received: by 2002:a05:600c:1c83:b0:3da:fbd8:59a0 with SMTP id k3-20020a05600c1c8300b003dafbd859a0mr9484212wms.11.1674117731561; Thu, 19 Jan 2023 00:42:11 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:11 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:09 +0100 Message-Id: <20230119084112.20564-6-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/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 | 101 ++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/af.h | 42 +++++++++++ src/ipa/rkisp1/algorithms/meson.build | 1 + 3 files changed, 144 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..c2a321cd --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -0,0 +1,101 @@ +/* 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::init + */ +int Af::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) +{ + waitFramesLens_ = tuningData["wait-frames-lens"].get(1); + + LOG(RkISP1Af, Debug) << "waitFramesLens_: " << waitFramesLens_; + + return initBase(tuningData); +} + +/** + * \copydoc libcamera::ipa::Algorithm::configure + */ +int Af::configure([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const IPACameraSensorInfo &configInfo) +{ + return 0; +} + +/** + * \copydoc libcamera::ipa::Algorithm::queueRequest + */ +void Af::queueRequest([[maybe_unused]] IPAContext &context, + const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + const ControlList &controls) +{ + queueRequestBase(frame, controls); +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void Af::prepare([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + [[maybe_unused]] rkisp1_params_cfg *params) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::process + */ +void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + const rkisp1_stat_buffer *stats, + [[maybe_unused]] ControlList &metadata) +{ + uint32_t sharpness = stats->params.af.window[0].sum; + uint32_t luminance = stats->params.af.window[0].lum; + + LOG(RkISP1Af, Debug) << "lensPosition: " << context.activeState.af.lensPosition + << ", Sharpness: " << sharpness + << ", Luminance: " << luminance; + + uint32_t lensPosition = processAutofocus(sharpness); + + if (lensPosition != context.activeState.af.lensPosition) { + context.activeState.af.lensPosition = lensPosition; + context.activeState.af.applyLensCtrls = true; + setFramesToSkip(waitFramesLens_); + } +} + +void Af::setMeteringMode([[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..882be952 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.h @@ -0,0 +1,42 @@ +/* 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 "algorithm.h" + +namespace libcamera::ipa::rkisp1::algorithms { + +class Af : public ipa::common::algorithms::AfHillClimbing, public Algorithm +{ +public: + Af() = default; + ~Af() = default; + + int init(IPAContext &context, const YamlObject &tuningData) override; + int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; + void queueRequest(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, const ControlList &controls) override; + void prepare(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, rkisp1_params_cfg *params) override; + void process(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats, + ControlList &metadata) override; + +private: + void setMeteringMode(controls::AfMeteringEnum metering) final; + void setWindows(Span windows) final; + + /* Wait number of frames after changing lens position */ + uint32_t waitFramesLens_; +}; + +} /* namespace libcamera::ipa::rkisp1::algorithms */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index 93a48329..ab7e44f3 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', From patchwork Thu Jan 19 08:41:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18145 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 9F4DBC3294 for ; Thu, 19 Jan 2023 08:42:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 29361625F5; Thu, 19 Jan 2023 09:42:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117736; bh=IZZ5Wh2pvaVQNIJJ8KSNaIOZYWKPqd9L61yGyhai0do=; 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=DHZ1T8SevMbm4sDA5W8b9kc56RX3DOjAdIZHkhp5Cmbf98V32RTPMcz937uaJgSUr X/HdojQk6VzZ3ywnCoDTtc4yJKbFVDMEvO+TMbWyYBi65Tauwge4tMJYClc6Z5COvE OjNtCD4/RwlPocq4YJSlMqQ8aEQPbwxt802J9w8KgD9kKPwcKdiRiqCdQqAgDSEuXC 952Wcun0NNhc5htzLAdxhEWIKpMTIeIbmeFjFakBPxEl+fhQ2DJ61meGyZNilIckHF 1u4EaOIXD07YDz2GIIdHU8lN/yyK+VAH6RY3yeeIn5+4rGYHWvL04I7d7jCf4rF8jv SA6hm9OReqPKg== 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 B35F5625EA for ; Thu, 19 Jan 2023 09:42:12 +0100 (CET) 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="RHddAhf2"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id c10-20020a05600c0a4a00b003db0636ff84so709546wmq.0 for ; Thu, 19 Jan 2023 00:42:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8Rg5efG+ONNAzDMKsRD/WP/E/KL6zi12dSbPHOjcxRc=; b=RHddAhf2T1BywXkCChFzkAu2BQHXGbU6zBhSCMpngDfjl68PvNBzogLYceVyDQ+QOK JakaNTSE4fAv9qK9zfl/IqF2e5oe40/IZbRNV11gxFKvXyBTU7QERvVjRSbC9/eG/9+o mAzZTXedpa+YDDJ6mC/RmT1vqIuMXNkP/isYUzwc+Dq5nr7fcrKJPIsxATDeQ7G9bcaU Rx33oi/jPwMKCSGAsMPPPxmYD7PHnVQwW8Xmjpw64kATMU+CbB1+F52fTCpNFlR3YSjs QbK3LV2jkdRUeOcZS5GJ5QJgd3TEg2TI0fq9LI5sgqEKQ4zU2WAhy6KwMuaOSMpgnPxw IQBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Rg5efG+ONNAzDMKsRD/WP/E/KL6zi12dSbPHOjcxRc=; b=8PWqyElp9k3MaKgp1hYkCWaTzmGCZ25cP0ZdEECyGD3ibkvvJF3jucRLQzeg/LpvuR r4egMr1Ceqj+K8/vtYaVBNCKkOqV4pN1w61EZP/0wQ3HItCip75hzQo43PvRN7i1onxf vc9gybJAJe4UV6lCy8DEfFvPvBZvZWnq1wl105HdxeyZw8zG0APmqTiptPH/3KRZReDJ EwktTyFh44o5NwE6b8yRj4qYIZEg3EMjQ3UVA/dKzyOCpjFMhoDkt2n0hIAn7BgEi9ra uI3AljfQ/0EjGor/OvxkIwkZuiMnMEHVWfwvWadbbS3ZjrDiZaazNamM+kjnJNt97Zon RgfA== X-Gm-Message-State: AFqh2kpVtTmFA1fLrCUrBFqggm9URbtB0r4EyqK1mLufUQcQhMjvNNeh c2EAjJHTPgm8Gk/QkNAHjaxSUbxjYeOZEeEtbUM= X-Google-Smtp-Source: AMrXdXtH6rONd7NGfcgFTCtWuW5OnKDSkXnZf5+G7hpIxEjYu4P9WKZh1oqK8iQo2cEJt8ticTp+yg== X-Received: by 2002:a05:600c:540c:b0:3da:fa18:a535 with SMTP id he12-20020a05600c540c00b003dafa18a535mr9457239wmb.29.1674117732412; Thu, 19 Jan 2023 00:42:12 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:12 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:10 +0100 Message-Id: <20230119084112.20564-7-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/8] pipeline: rkisp1: Add basic AF controls to the supported controls list 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" This will expose the AF controls and will allow controlling them using the top level API. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/rkisp1.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 297161b2..bc2508a2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -101,10 +101,14 @@ namespace { /* List of controls handled by the RkISP1 IPA */ const ControlInfoMap::Map rkisp1Controls{ { &controls::AeEnable, ControlInfo(false, true) }, + { &controls::AfMode, ControlInfo(controls::AfModeValues) }, + { &controls::AfPause, ControlInfo(controls::AfPauseValues) }, + { &controls::AfTrigger, ControlInfo(controls::AfTriggerValues) }, { &controls::AwbEnable, ControlInfo(false, true) }, { &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) }, { &controls::Brightness, ControlInfo(-1.0f, 0.993f, 0.0f) }, { &controls::Contrast, ControlInfo(0.0f, 1.993f, 1.0f) }, + { &controls::LensPosition, ControlInfo(0.0f, 2147483647.0f) }, { &controls::Saturation, ControlInfo(0.0f, 1.993f, 1.0f) }, { &controls::Sharpness, ControlInfo(0.0f, 10.0f, 1.0f) }, { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, From patchwork Thu Jan 19 08:41:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18146 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 150DAC3240 for ; Thu, 19 Jan 2023 08:42:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC530625EB; Thu, 19 Jan 2023 09:42:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117744; bh=/sWMrM0yDvzVCpeO45m6mMKX2012/YfF5BROtCocLs8=; 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=q+qP9boHawxIJW6aJJDT4Rpd24h6HbKn/w2R2eXN/0QRwRNj8S8W0FgPzZ5RJGlKf qBtIraDBBk/UrqUo+aDGVWgD4kJXKbLrK480zSP+xIiL3Wxi3WrNfXsaFgtVM120dn k9w71SNef2BAMg/vt263O+pTfOGiutUCI4bYxU55H3QZ99dYaTQ2NANI5Sd4ecDEWv 4q9zAB9SAGsydTRhBGFr5GgfeFyJB55A+DW5H406u+QHs1YTUTaP3Yczuqk76eqaj8 WIMRFh35tzhzUogxt1sOnfJBmOx0JV/0jM0sgxEwNtrD5Mo1Hc542R98hMmCqB7Z39 t6LkH82pvm5Eg== 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 9939F625F6 for ; Thu, 19 Jan 2023 09:42:13 +0100 (CET) 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="dRdmPQa/"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so3044568wma.1 for ; Thu, 19 Jan 2023 00:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZdYpCqlVgBVjIXhtQANwxiepcG4LDSc5L3JxbSsR2KI=; b=dRdmPQa/2FfkiDhcclksM8LF+gn1x1tG7Fk9lwvzWmEDGiX0cAV3QMgO90SN9g25Dh bn10FV2R9aO72fFlISTdF/8FaV3njHioORxWF7O4H9JKJxhEzB6Qfhg/ksB5vNYPnQfN y5Xa7PN3SbmWIQWdNvjQJdkTewS1Ins3+U9Zf/2nm8S1+0J4gA2JdCzAuwoD9sX8wYsO kubQo/PkzP8Q353ICf43YCGbbVN7G4VWZ66JEoCpoX8oyoT+UxfdQ6OP8+mAUMycs+kj bbxy/Cc1hY5OpP2pnP7G40HAJPabfDq9umcfwfP80LksLJO0umreXjsBygJSL6f84Pe7 kMyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZdYpCqlVgBVjIXhtQANwxiepcG4LDSc5L3JxbSsR2KI=; b=K5gTNUpo3pZ1r8t514kJzZccsULFF39T4EZoBCsxgLevfxXUtL7U2Pv8JMEhYWk3c1 uKQc4HGMqTw92hIDiG9w+pAmUi2/FAXPWqoxTv0wGb8V6G24Lk1wgkjQMk1FTVnZCrG3 XXRVpqwZIxZZWh4SuXWuScG/qoNerko2e78Et2/vPRceDJ47EbWyB+GaM4ySQkbN4cfe DXuiU7k4DZjWnKFSs3YfkTZkQUPUpkYCZ0+DMxrfkz2nf5m0lAqsOWbUr1P9sRDn8CrH xnDLKHTaeDz5M42lc6UUBnNLaoZDth6TMTqHjE0KDunHKr8d066/q+E2DuY7flTEfzJG FvzQ== X-Gm-Message-State: AFqh2kpgWQbXbhgdXM1xIEg5yNSxLcE7t3DV0iAHrGSoCumXbIf07tqT C5HRfWbM9yrTCq2NKyAKw68Aar/62thm3S+RIJ4= X-Google-Smtp-Source: AMrXdXvd+oyp7qnUJ5BSw0OuEe7OaPrIKGJokgLkgwY/HnieD5B/pWyLQgeqIneK68tQRa3pig64Fw== X-Received: by 2002:a05:600c:3495:b0:3db:a3a:4594 with SMTP id a21-20020a05600c349500b003db0a3a4594mr8239090wmq.28.1674117733262; Thu, 19 Jan 2023 00:42:13 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:12 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:11 +0100 Message-Id: <20230119084112.20564-8-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/8] ipa: rkisp1: Add "Windows" Metering mode to auto focus 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: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow manually setting auto focus window. Currently only one window is enabled, but ISP allows up to three of them. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/algorithms/af.cpp | 93 +++++++++++++++++++++++++++++--- src/ipa/rkisp1/algorithms/af.h | 9 ++++ src/ipa/rkisp1/rkisp1.cpp | 2 + 3 files changed, 98 insertions(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp index c2a321cd..65768fc4 100644 --- a/src/ipa/rkisp1/algorithms/af.cpp +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -20,14 +20,32 @@ namespace libcamera::ipa::rkisp1::algorithms { LOG_DEFINE_CATEGORY(RkISP1Af) +namespace { + +constexpr rkisp1_cif_isp_window rectangleToIspWindow(const Rectangle &rectangle) +{ + return rkisp1_cif_isp_window{ + .h_offs = static_cast(rectangle.x), + .v_offs = static_cast(rectangle.y), + .h_size = static_cast(rectangle.width), + .v_size = static_cast(rectangle.height) + }; +} + +} /* namespace */ + /** * \copydoc libcamera::ipa::Algorithm::init */ int Af::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) { waitFramesLens_ = tuningData["wait-frames-lens"].get(1); + ispThreshold_ = tuningData["isp-threshold"].get(128); + ispVarShift_ = tuningData["isp-var-shift"].get(4); - LOG(RkISP1Af, Debug) << "waitFramesLens_: " << waitFramesLens_; + LOG(RkISP1Af, Debug) << "waitFramesLens_: " << waitFramesLens_ + << ", ispThreshold_: " << ispThreshold_ + << ", ispVarShift_: " << ispVarShift_; return initBase(tuningData); } @@ -36,8 +54,15 @@ int Af::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData) * \copydoc libcamera::ipa::Algorithm::configure */ int Af::configure([[maybe_unused]] IPAContext &context, - [[maybe_unused]] const IPACameraSensorInfo &configInfo) + const IPACameraSensorInfo &configInfo) { + /* Default AF window of 3/4 size of the screen placed at the center */ + defaultWindow_ = Rectangle(configInfo.outputSize.width / 8, + configInfo.outputSize.height / 8, + 3 * configInfo.outputSize.width / 4, + 3 * configInfo.outputSize.height / 4); + updateCurrentWindow(defaultWindow_); + return 0; } @@ -50,6 +75,21 @@ void Af::queueRequest([[maybe_unused]] IPAContext &context, const ControlList &controls) { queueRequestBase(frame, controls); + + for (auto const &[id, value] : controls) { + switch (id) { + case controls::AF_METERING: { + setMeteringMode(static_cast(value.get())); + break; + } + case controls::AF_WINDOWS: { + setWindows(value.get>()); + break; + } + default: + break; + } + } } /** @@ -58,8 +98,23 @@ void Af::queueRequest([[maybe_unused]] IPAContext &context, void Af::prepare([[maybe_unused]] IPAContext &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] IPAFrameContext &frameContext, - [[maybe_unused]] rkisp1_params_cfg *params) + rkisp1_params_cfg *params) { + if (updateWindow_) { + params->meas.afc_config.num_afm_win = 1; + params->meas.afc_config.thres = ispThreshold_; + params->meas.afc_config.var_shift = ispVarShift_; + params->meas.afc_config.afm_win[0] = rectangleToIspWindow(*updateWindow_); + + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AFC; + params->module_ens |= RKISP1_CIF_ISP_MODULE_AFC; + params->module_en_update |= RKISP1_CIF_ISP_MODULE_AFC; + + updateWindow_.reset(); + + /* Wait one frame for the ISP to apply changes */ + setFramesToSkip(1); + } } /** @@ -88,12 +143,38 @@ void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, void Af::setMeteringMode([[maybe_unused]] controls::AfMeteringEnum metering) { - LOG(RkISP1Af, Error) << __FUNCTION__ << " not implemented!"; + if (metering == meteringMode_) + return; + + if (metering == controls::AfMeteringWindows) { + updateCurrentWindow(userWindow_); + } else { + updateCurrentWindow(defaultWindow_); + } + + meteringMode_ = metering; +} + +void Af::setWindows(Span windows) +{ + if (windows.size() != 1) { + LOG(RkISP1Af, Error) << "Only one AF window is supported"; + return; + } + + /* \todo Check if window size is valid for ISP */ + + LOG(RkISP1Af, Debug) << "setWindows: " << userWindow_; + + userWindow_ = windows[0]; + + if (meteringMode_ == controls::AfMeteringWindows) + updateCurrentWindow(userWindow_); } -void Af::setWindows([[maybe_unused]] Span windows) +void Af::updateCurrentWindow(const Rectangle &window) { - LOG(RkISP1Af, Error) << __FUNCTION__ << " not implemented!"; + updateWindow_ = window; } REGISTER_IPA_ALGORITHM(Af, "Af") diff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h index 882be952..72cc7932 100644 --- a/src/ipa/rkisp1/algorithms/af.h +++ b/src/ipa/rkisp1/algorithms/af.h @@ -35,6 +35,15 @@ private: void setMeteringMode(controls::AfMeteringEnum metering) final; void setWindows(Span windows) final; + void updateCurrentWindow(const Rectangle &window); + + controls::AfMeteringEnum meteringMode_ = controls::AfMeteringAuto; + Rectangle defaultWindow_; + Rectangle userWindow_; + std::optional updateWindow_; + uint32_t ispThreshold_; + uint32_t ispVarShift_; + /* Wait number of frames after changing lens position */ uint32_t waitFramesLens_; }; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index bc2508a2..c300c3b0 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -101,9 +101,11 @@ namespace { /* List of controls handled by the RkISP1 IPA */ const ControlInfoMap::Map rkisp1Controls{ { &controls::AeEnable, ControlInfo(false, true) }, + { &controls::AfMetering, ControlInfo(controls::AfMeteringValues) }, { &controls::AfMode, ControlInfo(controls::AfModeValues) }, { &controls::AfPause, ControlInfo(controls::AfPauseValues) }, { &controls::AfTrigger, ControlInfo(controls::AfTriggerValues) }, + { &controls::AfWindows, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::AwbEnable, ControlInfo(false, true) }, { &controls::ColourGains, ControlInfo(0.0f, 3.996f, 1.0f) }, { &controls::Brightness, ControlInfo(-1.0f, 0.993f, 0.0f) }, From patchwork Thu Jan 19 08:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18147 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 9ADE3C3294 for ; Thu, 19 Jan 2023 08:42:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 400C2625E7; Thu, 19 Jan 2023 09:42:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117745; bh=GIMpXaryP7znzBiZXQMH5sz0PRMIQ+ST6Rz0P8qjbNo=; 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=rMTfl4IlurC68P6OtV8L81swoiyAqUEWWMlxK0wk/LMp0wqrr7tWL/U57eW8F5ZIk KT35pB3qnehzXBuCuOYHnkRQTJFJqnFNvibUZNMTXlBHdoko6pvGAj2uJpQUl1r6m6 o8bQdZRu74YWW6qVkozwLjf3hcOR5qq4+XXVH4mWFGjUMb1r8iLlGajsnCCAQA0BpJ NQL8GVjEy1EkAV0j5MPav5U2O9nwIxy5XSkuB0B0iTwpB+wk9o+o5qvFjzsOPNmRCQ bgBVCLwwS8qDcOaZmHVbqZPbQn4nLcznAtBYdA9EVN4SWEG//5bzn3IzDhLnZa3hUm HTUD6vrCSkBbg== 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 C255A625E4 for ; Thu, 19 Jan 2023 09:42:14 +0100 (CET) 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="6EWTIpPk"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id k16so915206wms.2 for ; Thu, 19 Jan 2023 00:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rnBHv/p55smbyokZqUcRz3Y27DY7OeF7uOKvhY6JMak=; b=6EWTIpPkv4FVxtkfSj2vytZmPUoEI0ytVRB1lmGJBuTXoUIqqC3p/ttu0D3ArCdHA7 GG1w366uDlPNnz7wLOheagYmf9LUfXe406756iK9FSeCQLfGQqC4A0xDsdwGmdj1O+B9 l6it9sCP5mk1ZDR93HEczd3AuegrcTeWk/ncEjpc9c2p3VJgQ4+MF7d5KxUGNawcf6k4 khJPV9VMAzhrT+EvZ37fv0soXem/TO+mXP4sKSXXmCx6F0FHnrFaLqZ2NjzurFzfSPvc otBWTP6cSl8epKm/pmu3LVeqD6U2uBsKJyHz63g6mNl1ScCqYL06yf6YCyqc/VHxcDTc Y//w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rnBHv/p55smbyokZqUcRz3Y27DY7OeF7uOKvhY6JMak=; b=AC+XlDw8sUqx4Mj9E3/hSWei7Wo/LL8jw9tMDBJRB3weX+ehQgqYWJ6kbSO1mXWN5J 0ty//porQywvfzqYteaKOpv2kH4tYyL6jWQ9XnJzTuzGa0bRQ2lek4I/lRMDKc3spXhn eJSoy80MwfndZJtMToWJK+no/1GXRvZ4QOBxFh4yfnp4zslUJdX9f2r/SsOCeEjNDmnv dBiEWg+DvSn1xqS4ALPmd4ini4/O6DWNI75U9II2vIHhIH17bftVRdgHeiI1OGk/Gg3M 4eAgEKP9mLPNLGYnCmdCYJ6FEELAQmhVIvap6102DZPn7ioan27eICCDjpWKukcc2ZOS k2eA== X-Gm-Message-State: AFqh2krTXj0mw/M8xT8JYWIZfmJB8GIc1zic34YrxqpLZFO05T/H7Hif 5In0t8NY7MgYnbupivWp5ngzbX7rxkheQZahs0Y= X-Google-Smtp-Source: AMrXdXuJe0NhWL4znwyrF4ozydXcCCFqw4Yg5pQ/2FkrfASnCQYcqVDX5O9hjalHWysPPA2sO59yQw== X-Received: by 2002:a05:600c:35c1:b0:3db:1424:e781 with SMTP id r1-20020a05600c35c100b003db1424e781mr4717650wmq.23.1674117734103; Thu, 19 Jan 2023 00:42:14 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:13 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:12 +0100 Message-Id: <20230119084112.20564-9-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 8/8] ipa: rkisp1: Add OV5675 tuning file 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" Add the OV5675 tuning file with default values and enabled AF algorithm. Signed-off-by: Daniel Semkowicz Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/data/meson.build | 1 + src/ipa/rkisp1/data/ov5675.yaml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/ipa/rkisp1/data/ov5675.yaml diff --git a/src/ipa/rkisp1/data/meson.build b/src/ipa/rkisp1/data/meson.build index c3b4e388..03d71cbf 100644 --- a/src/ipa/rkisp1/data/meson.build +++ b/src/ipa/rkisp1/data/meson.build @@ -3,6 +3,7 @@ conf_files = files([ 'imx219.yaml', 'ov5640.yaml', + 'ov5675.yaml', 'uncalibrated.yaml', ]) diff --git a/src/ipa/rkisp1/data/ov5675.yaml b/src/ipa/rkisp1/data/ov5675.yaml new file mode 100644 index 00000000..2c088d18 --- /dev/null +++ b/src/ipa/rkisp1/data/ov5675.yaml @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: CC0-1.0 +%YAML 1.1 +--- +version: 1 +algorithms: + - Af: + min-vcm-position: 0 + max-vcm-position: 1023 + coarse-search-step: 30 + fine-search-step: 1 + fine-scan-range: 0.05 + max-variance-change: 0.5 + wait-frames-lens: 2 # tuned for 30fps stream + isp-threshold: 128 + isp-var-shift: 4 + - Agc: + - Awb: + - BlackLevelCorrection: + - ColorProcessing: +...