From patchwork Tue Mar 14 14:48:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18392 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 2E9B9BD80A for ; Tue, 14 Mar 2023 14:49:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C88116270E; Tue, 14 Mar 2023 15:49:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805393; bh=Z6VTu0zidCzMXOnvglkDj64XlU2ckQvY+pnZGFLWnOY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=BpM9ZCZvt4lPQ7uLLRd3Tcf/B3jj4fRwsOCfaKTB/K9p67KVZt2RvxWnA84Tr94P0 sNoHmMDv/lU6iRhPeqMoWQwFhtNO9ungwO4oxBffN3edirhEivWgz+e4EQnQE8Trnv 6NrlSHEpjSLr3qBd68m3JLbXnYNGH8FsDuk1+yE9XukA2HTWOZ1VZAGA7o4VHkzioO a+PT4C+8UZYAwjDHFiNJH0cHLzZTI+UAHLQ2ZdPaA3bPP57HvqOBNP/neb0lKFMRQS dOPRMMxWotmwtii1Kb0UMwazXxh12JwAB/aD6+cbFngyalas34jbP0E79nRZbd3YfK sAGmm0YLoaYaQ== Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 008AD626D6 for ; Tue, 14 Mar 2023 15:49:52 +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="AORGVMt2"; dkim-atps=neutral Received: by mail-lj1-x22c.google.com with SMTP id b10so16320920ljr.0 for ; Tue, 14 Mar 2023 07:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805391; 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=r4NPnLMb4QG0NlqecrFPvrV8a7pjMAgwk3MN6og/a88=; b=AORGVMt24yxthdUL94YX1Ea9tf93Zh/t877JSlo6gT448qMnFi9etsTBgZkDxH0NML x3COgG5/jzTgh1fi2V7aZkXuwmFNU+A6u3fSJYi1NmW0RTm5rkldohsyHWhpt2rzSb1n JsYVR7nZalx6ElbcnzbMVwwcPRwwJ9R5+FceIKHc6jgfspL72zesRZCIxuQ2mCwMoeww pPhruF5FkMOMPQvx34uObHfaV9Q4wezVSXNdA+pxHAebxmhG1Qe80O/B3G8uWEYKDKJX Gl6WViLc1DZuvu3eDEUG1KVo1oHoUNwiEWiRAOcugg1hyCIjrcvo9UtMIvZCULZBR1/m Vg4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805391; 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=r4NPnLMb4QG0NlqecrFPvrV8a7pjMAgwk3MN6og/a88=; b=abw9B66wwHvLawIWhP+NgjOL7/w02JcGGR54j8naWcUldsCOLP3DmCuCUun1RL70qo 2HWQc/O1vX8w15LcFisTM/OGnMwxPFzImoSwAk68km5ttGiQFoa19rJj8pe+kQ5dAeDW LvhEFiEC0yHTCFuSHP/MHcojkKIvng0joq3N2R/yPyhTkRCKxCKwgLEylCTkXR0hap8d n+ROPZkGh08DNA//ZeHxYzrxC7AZTOifiH5bueCeNhInJVncX9jye91kXk2vyEMRWhqe Nh8c+EQDZXiWC2Y4pxlfdx0ZEa8PuWh3C/LYk9I+OndC+xnlazGO3MIzcw6jjgst1qhC aCxQ== X-Gm-Message-State: AO0yUKXFgKOiyeLGgj9clYFjt76ESl3qCb8/CPOXGL42yw3r9/VL+py0 zxvDgyqRQyPZt5XOkgtTx+jAAJmLq8dOCbhX8To= X-Google-Smtp-Source: AK7set9ntMGZ8yPlHpEaoZ896SEK5Cvgd7Nu7pzI6GMTfg7HGlDMNaOGBxoXkKibxplYHAGyaC8IQQ== X-Received: by 2002:a2e:97d1:0:b0:298:9fbf:61dd with SMTP id m17-20020a2e97d1000000b002989fbf61ddmr825963ljj.16.1678805391269; Tue, 14 Mar 2023 07:49:51 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:51 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:25 +0100 Message-Id: <20230314144834.85193-2-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 01/10] 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Check in pipeline handler if camera lens exists, and expose its controls to the IPA. Signed-off-by: Daniel Semkowicz Reviewed-by: Jacopo Mondi --- I did not include the "reviewed-by" markers from last review as there was a change in this commit. Code in IPA file has been moved a bit down to better fit with the changes from the next commit. 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..248cf5e0 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_; @@ -265,6 +267,9 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + if (!ipaConfig.lensControls.empty()) + lensControls_ = ipaConfig.lensControls; + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a30fe06..83fb6287 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -32,6 +32,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" @@ -812,6 +813,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 Tue Mar 14 14:48:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18393 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 42393C3263 for ; Tue, 14 Mar 2023 14:49:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7821462713; Tue, 14 Mar 2023 15:49:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805395; bh=ejOENZ/e1++33Ovtlo6eNchLLyXr5wDvErTCzcVI18U=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=MVUlLFcqxuNI9uSjkLGHoewrQ+i3ZFdIdqtMqreJaiKZf8D+d3DKJIr06EKG3R78+ A0R6H9us9/Rws0XdlXOBd5JbZMipPYwwPh3DD/q+IYihMJsriI41kOSwx0sjpbB5JG EId7z1zijj/yTLSEASoejIms4miUiB1xARSp7rA7310IafGToKZ4JXzFnNix0/JMC1 2kKJlus506d0jBud6rDmE/879SzoRgBC8N0kEEk2+zppEKrXw9HjwrTBr/FDXsD3h9 oZK9Fa6IdsciFD6R4QKGmJ9IB/rUB3XC6k+7P72SgJRdyVKEGTaP5pXQ11f3kKBZdh g/3MFcsLBM0fA== Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 94F29626D6 for ; Tue, 14 Mar 2023 15:49:52 +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="GklvlonF"; dkim-atps=neutral Received: by mail-lj1-x22c.google.com with SMTP id h3so16271103lja.12 for ; Tue, 14 Mar 2023 07:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805392; 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=8l6sE+OVX2uuIoyLjXNkPNCNwAZLjqHWm3i7Yg1Y6Qs=; b=GklvlonFTgBAQHZYv6XciJ2G9M/mbIedUWdDbPS/Jf8PIl2v3WRViNemKbcV5WNAIR c5LZCdjUi3L9g85OQLv7Y13WSnX6mm4T3ajeD8Y/zqeyobGS+24qsNTdykk4kyVohQKf qAwXeOAjfp4HHNt4eQRizu2knSU1EiR7yK4SZFefyLXV0grqZQRKFAT7wLa/yHHtSXK4 mUZTYHF7ey+xWcpAKIDduWX5autyFUH27XiAsGstxOuOrAcrRrI02HMBsHbDy2wI+C4U NXLkquIokC1U5xmDAq6/COHIf0xtfB3RNCurLchjVlItpo7+58JvMQ2+BmIL4rBB9Utg rDLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805392; 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=8l6sE+OVX2uuIoyLjXNkPNCNwAZLjqHWm3i7Yg1Y6Qs=; b=QLXdQvl6a3lncfEb7oA2z9BapOSBHlkRw4TlNXGM1hsBxsyBHT1HjUK+GBe0Qrmsxg dJRg3ntCojY9bu7iI76C+zowFNtLnj0znQejHl9V+eC8ynvaZZTJO+GfDhOfOyWlLNpG m86nLRdurVlD5cYuNHn27MPPGJpvP4hIYmJU8UbKvme03y+7mXh3RvRdE7z2Ny8cd/yJ 9B67E/ktKDVIi3RTppbs+GJI6PPYa/s2udl+I6BgRCKdE05VHxxOTGCFp3a2KSlXE0bk sbcBGDRhiw8XGtcKrxOIyiyzGn5JLmWWO92ICkVCGVPkJGlULiljrCvJrNuxUyZFWj+i ukOw== X-Gm-Message-State: AO0yUKVaTnSxAX+G/L+p9rSi9n5k+uZiXCPaNYYqpJwubZt0GMvnm3gl 64nh6K5psmrtyHBsMRkVBkHzJiVYVF9X1vj5hkc= X-Google-Smtp-Source: AK7set9GC8gZa4SSPe0PHbasVEPn1lA6MJuPD/+RATnROMXOfpUq14u+XGsYuwE7Vjnkk3/vWt0Hgg== X-Received: by 2002:a05:651c:2cb:b0:293:5f35:d68f with SMTP id f11-20020a05651c02cb00b002935f35d68fmr13021841ljo.31.1678805391844; Tue, 14 Mar 2023 07:49:51 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:51 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:26 +0100 Message-Id: <20230314144834.85193-3-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 02/10] ipa: rkisp1: Add lens limits to the session config 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add information about focus lens position limits to the IPA session configuration. These information can then be used by IPA algorithms to know which focus positions are valid. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/ipa_context.cpp | 12 ++++++++++++ src/ipa/rkisp1/ipa_context.h | 5 +++++ src/ipa/rkisp1/rkisp1.cpp | 13 ++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 9bbf3684..401c098f 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -89,6 +89,18 @@ namespace libcamera::ipa::rkisp1 { * \brief Sensor output resolution */ +/** + * \var IPASessionConfiguration::lens + * \brief Lens-specific information + * + * \var IPASessionConfiguration::lens.minFocusPosition + * \brief Minimum position supported by the camera focus lens + * + * \var IPASessionConfiguration::lens.maxFocusPosition + * \brief Maximum position supported by the camera focus lens + * + */ + /** * \var IPASessionConfiguration::raw * \brief Indicates if the camera is configured to capture raw frames diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b9b20653..bfb6e1b7 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -45,6 +45,11 @@ struct IPASessionConfiguration { Size size; } sensor; + struct { + int32_t minFocusPosition; + int32_t maxFocusPosition; + } lens; + struct { rkisp1_cif_isp_version revision; } hw; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 248cf5e0..cd1fbae3 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -267,9 +267,20 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); - if (!ipaConfig.lensControls.empty()) + if (!ipaConfig.lensControls.empty()) { lensControls_ = ipaConfig.lensControls; + const ControlInfo focusAbsolute = + lensControls_->find(V4L2_CID_FOCUS_ABSOLUTE)->second; + + LOG(IPARkISP1, Debug) + << "Focus lens: " << focusAbsolute.toString(); + + auto &lensConfig = context_.configuration.lens; + lensConfig.minFocusPosition = focusAbsolute.min().get(); + lensConfig.maxFocusPosition = focusAbsolute.max().get(); + } + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); From patchwork Tue Mar 14 14:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18394 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 30DE6BD80A for ; Tue, 14 Mar 2023 14:49:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C91B662719; Tue, 14 Mar 2023 15:49:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805398; bh=4WWmNqxEa3En1IFm6A+aBBWoe6pYCuvi8WpsS7o4Y6I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=pJcUSeXZscgNgAJ638bPYSEoqg6WmLHinAfwEmvA98GWj+ZxOFH9oCselg0YZh52o Ab8jFV0Y1M9cJILRBFeuhFrtRy08XH0D9sQy4JATdQfVLWyLPxO466MFG9oE5QYdpz rWLKsdquzRJJ+WzoJB/JFWQTg7uzPdAJGW36QbYkIxSBY6KBc/fcMzUccy7sXuyZQf wTIKqCj4hL8dZkOhuwRc3k+p3Q7NlHBJ+YYrD/N4I5gvSpiu/6yKaEH2fQr5OTWNti hJB0xuSw4k4aqvnMiJJMHG4aDjb/NmtIrUqab7QCw5Kb5tSTHGlnw4cyOCoBb+/nLR eOTRYt3ep5UzA== Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36B2D626D6 for ; Tue, 14 Mar 2023 15:49:53 +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="F7vPqWbk"; dkim-atps=neutral Received: by mail-lj1-x236.google.com with SMTP id z5so16269893ljc.8 for ; Tue, 14 Mar 2023 07:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805392; 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=Tf4a27wHPohwI3ltcrQGkT73Z2E4q3f/GsXTtml4cGg=; b=F7vPqWbkbGZsVidBUbxQo9ca8Hvs2k+Ip2vZFsKfmFc4Kbjgpl/gMnzA/gCz9cc+Gk 4zWe6jw2yX10PPPGJcrLahcTfkOZhM1A6Zho6Rx91sglJqk0joQlcOBt+Lw2wqYaFsrC ymtEARmXmjKo2sRsZ7EK79/Zr/yaVWNIfRj5mgnXr2cBS6bZ8H6cfdiqP2xhk2pvrqG/ fPUTq22/DliFnRksxwOf49m193ANP0LC9qd2ROf22DA8+WyhYxXHrzu+mi+tezW65T2I Tw543LwhYZVMfNZ09CglYKjIfbpUBG/FEeUdv9QImBlEcKErCB0GTPYXbM5JA0UJnOuz wmJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805392; 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=Tf4a27wHPohwI3ltcrQGkT73Z2E4q3f/GsXTtml4cGg=; b=1ElTtEEfqfdsf0RvGrmIV7Ogm8SC1xE+SSknqzd1dFLKQ37Q0gr2JmnWUV1RJ/NjD4 0ugxD3fgtPpWf976KYQV80ra6rVsr4z72e5pfTe3Hi381bZ44ngfZGZPDcp8m6lYt06X hL5mGO/Im2IWgMpjeyp/Eo7qlO6y4+D/jVl28xzyVvEKYLUs/+xbbk5gMUtzKHQpF/Y/ 3YdPcCGtXUeR7V9MgCHGUAwVNal5ysUse3gKgm5a+BVvVbUPWjuoxRc2rtmyWqQp1qEq AWQlxWBfG9yu8cwYtONAsgo6G0RFMIQRZlc9BAL1Hz9NAZExtXgOl9M0SxGOav8b5Wha uaAg== X-Gm-Message-State: AO0yUKXKxI0MiAP0rspei8TQiOI6KXEyQwrSSCnTV/bnclxEBq52hdjo GyzHmfd/72sGp4v3dkHBE84r7Kx2wJNpFVqI9B4= X-Google-Smtp-Source: AK7set+YJduw8TJ3RBbr8dvOpvu+HO88O2u1ZX2GBbVd/XPCYVTBrzpy0+4eFOwStaZinm8Cbhh6WA== X-Received: by 2002:a2e:be06:0:b0:295:9c2e:7324 with SMTP id z6-20020a2ebe06000000b002959c2e7324mr15562460ljq.4.1678805392437; Tue, 14 Mar 2023 07:49:52 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:27 +0100 Message-Id: <20230314144834.85193-4-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 03/10] 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Define common interface with basic methods that should be supported by the Auto Focus algorithms. Interface methods match the AF controls that can be set in the frame request. Common implementation of controls parsing is provided, so the AF algorithms deriving from this interface should be able to reuse it. Signed-off-by: Daniel Semkowicz --- src/ipa/libipa/algorithms/af.cpp | 155 ++++++++++++++++++++++++++ src/ipa/libipa/algorithms/af.h | 41 +++++++ src/ipa/libipa/algorithms/meson.build | 9 ++ src/ipa/libipa/meson.build | 6 + 4 files changed, 211 insertions(+) create mode 100644 src/ipa/libipa/algorithms/af.cpp create mode 100644 src/ipa/libipa/algorithms/af.h create mode 100644 src/ipa/libipa/algorithms/meson.build diff --git a/src/ipa/libipa/algorithms/af.cpp b/src/ipa/libipa/algorithms/af.cpp new file mode 100644 index 00000000..2052080f --- /dev/null +++ b/src/ipa/libipa/algorithms/af.cpp @@ -0,0 +1,155 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Theobroma Systems + * + * af.cpp - Autofocus control algorithm interface + */ + +#include "af.h" + +/** + * \file af.h + * \brief AF algorithm common interface + */ + +namespace libcamera::ipa::common::algorithms { + +/** + * \class Af + * \brief Common interface for auto-focus algorithms + * + * The Af class defines a standard interface for IPA auto focus algorithms. + */ + +/** + * \brief Provide control values to the algorithm + * \param[in] controls The list of user controls + * + * This method should be called in the libcamera::ipa::Algorithm::queueRequest() + * method of the platform layer. + */ +void Af::queueRequest(const ControlList &controls) +{ + using namespace controls; + + for (auto const &[id, value] : controls) { + switch (id) { + case AF_MODE: { + setMode(static_cast(value.get())); + break; + } + case AF_RANGE: { + setRange(static_cast(value.get())); + break; + } + case AF_SPEED: { + setSpeed(static_cast(value.get())); + break; + } + case AF_METERING: { + setMeteringMode(static_cast(value.get())); + break; + } + case AF_WINDOWS: { + setWindows(value.get>()); + break; + } + case AF_TRIGGER: { + setTrigger(static_cast(value.get())); + break; + } + case AF_PAUSE: { + setPause(static_cast(value.get())); + break; + } + case LENS_POSITION: { + setLensPosition(value.get()); + break; + } + default: + break; + } + } +} + +/** + * \fn Af::setMode() + * \copybrief libcamera::controls::AfMode + * \param[in] mode AF mode + * + * \copydetails libcamera::controls::AfMode + */ + +/** + * \fn Af::setRange() + * \copybrief libcamera::controls::AfRange + * \param[in] range AF range + * + * \copydetails libcamera::controls::AfRange + */ + +/** + * \fn Af::setSpeed() + * \copybrief libcamera::controls::AfSpeed + * \param[in] speed Lens move speed + * +* \copydetails libcamera::controls::AfSpeed + */ + +/** + * \fn Af::setMeteringMode() + * \copybrief libcamera::controls::AfMetering + * \param[in] metering AF metering mode + * + * \copydetails libcamera::controls::AfMetering + */ + +/** + * \fn Af::setWindows() + * \copybrief libcamera::controls::AfWindows + * \param[in] windows AF windows + * + * \copydetails libcamera::controls::AfWindows + */ + +/** + * \fn Af::setTrigger() + * \copybrief libcamera::controls::AfTrigger + * \param[in] trigger Trigger mode + * + * \copydetails libcamera::controls::AfTrigger + */ + +/** + * \fn Af::setPause() + * \copybrief libcamera::controls::AfPause + * \param[in] pause Pause mode + * + * \copydetails libcamera::controls::AfPause + */ + +/** + * \fn Af::setLensPosition() + * \copybrief libcamera::controls::LensPosition + * \param[in] lensPosition Lens position + * + * \copydetails libcamera::controls::LensPosition + */ + +/** + * \fn Af::state() + * \copybrief libcamera::controls::AfState + * \return AF state + * + * \copydetails libcamera::controls::AfState + */ + +/** + * \fn Af::pauseState() + * \copybrief libcamera::controls::AfPauseState + * \return AF pause state + * + * \copydetails libcamera::controls::AfPauseState + */ + +} /* namespace libcamera::ipa::common::algorithms */ diff --git a/src/ipa/libipa/algorithms/af.h b/src/ipa/libipa/algorithms/af.h new file mode 100644 index 00000000..1428902c --- /dev/null +++ b/src/ipa/libipa/algorithms/af.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Theobroma Systems + * + * af.h - Autofocus control algorithm interface + */ +#pragma once + +#include + +namespace libcamera::ipa::common::algorithms { + +class Af +{ +public: + virtual ~Af() = default; + + void queueRequest(const ControlList &controls); + + 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 state() = 0; + + virtual controls::AfPauseStateEnum pauseState() = 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..7602976c --- /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.h', +]) + +common_ipa_algorithms_sources = files([ + 'af.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 Tue Mar 14 14:48:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18396 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 1FA4FC329C for ; Tue, 14 Mar 2023 14:50:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 07C0662709; Tue, 14 Mar 2023 15:50:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805403; bh=1bstBxppEM9TyGd4rPlh5RFkJCmHXVsZ3O5DHBFeUaA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=O1ErC9y59eAUhOKQ5HLlELY8gQ5+Pm1oE7r2whZQptr5tysL/MpnsQooDsg+RKMJU F54Hzf425NedElKs6cY/gucRzlVfRt9HwZW3S4kbKd4rPndpgFW2VUCl6du70iIzGs 3Q80MnBfnIMkzoOaQupThbigDuI13XsIbNRTwzrUsXZdBDeIyg6wO4DajAwFOGsQPH 5CqpPtHBdYmiYBpn5nh8T/YjVWCOD9GgCHb62qzbqEe8xB4D8doHkbUHAyjsBOk2fM SR+3t60XNjfYFHFBDix69XpTKY52nQMhIV6i3W5U2svu0ROqpsUfXg64eCiDDUkVEh wNUWdq2MU9WNQ== Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E63A062710 for ; Tue, 14 Mar 2023 15:49:53 +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="s0QTt5Ib"; dkim-atps=neutral Received: by mail-lj1-x22b.google.com with SMTP id a32so16293423ljq.1 for ; Tue, 14 Mar 2023 07:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805393; 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=vS1Kbj5O9OP4CxUMem8zYbMA/KhxmOSW/DP3/vIXaOw=; b=s0QTt5Ibi10mwdn/8i354u2fJvdXpQG9YLQZfxJYI6KC/3S5koov8ZIbLJjKDE755e i/fKeaKm13gxcGJOBgGfpN+MrUye5zBm3KJwqVT9Qx7z4xKCeO084mEMUORGdNRM6pYn R5kcmTXiDEyMyQUQDEFWB5Ze5BsdePYhC8dkf25mT71SaZg5KsdysKKFPRg46dQSMrsw P4Bo3ijF6Qa1dfRop3jx5r0FdsN47NEK01+KUz70iysjgHYG3GXlvhdkk2tMM0ikESi5 iNiwA7+VdokjmBPb6nbFrm90Qhh+5JI5h04U0DCXBgs5mYQicZRPM5027m/JI05GwKFi UUmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805393; 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=vS1Kbj5O9OP4CxUMem8zYbMA/KhxmOSW/DP3/vIXaOw=; b=YZeSPWPV5z1ufGdoxRMzaZ+Ki2Hn1VvetV8BbUvBdPodajvjBO++6xtRc9lwK5O1sI GFt4U0IjpPDlO6+9BLdbb2TTWgFlrdTICN6xEiHkLI8uWeEkmiAjqjUY2hlvaSm2/H/7 LPsd4ipkn9sIx+8Xqt33HG/v9FmhMXoRN32W9O3FED3yWDT4onLABh2WYWF43ncYCmsR vm5trVNDyCZ24HLvvd5ne8rUYotxWsvlVHT22hVm1omi+82HZSVrVG4W1YazTjCtyWIt UboEiRwEwizzhDnCsM2d6rUFDi6KKJcD3V3B5HgT3mCegm7icP0qGh5U/j/n1g1kLbcC cGDA== X-Gm-Message-State: AO0yUKU1vZxMTk5jUvZvcvsrZy9nlNGDZVlNbQx15tVl/FjHD7VBTBCz O0ozQ/qmW8t6TudYfBhS+Gx023Zj4ZSEkMDT+VU= X-Google-Smtp-Source: AK7set8Ubo3GF8quTODs1UwgQ6b1Ih7tzgAyLvxZwzEOV3gwdtOGpCBaTkNEH3sFTPS8scew1GGSSg== X-Received: by 2002:a2e:a586:0:b0:298:39fa:b04d with SMTP id m6-20020a2ea586000000b0029839fab04dmr13988860ljp.33.1678805393018; Tue, 14 Mar 2023 07:49:53 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:28 +0100 Message-Id: <20230314144834.85193-5-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 04/10] ipa: Add common contrast based AF implementation 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Create a new class with contrast based Auto Focus implementation using hill climbing algorithm. This common implementation is independent of platform specific code. This way, each platform can just implement contrast calculation and run the AF control loop basing on this class. This implementation is based on the code that was common for IPU3 and RPi AF algorithms. Signed-off-by: Daniel Semkowicz --- .../libipa/algorithms/af_hill_climbing.cpp | 358 ++++++++++++++++++ src/ipa/libipa/algorithms/af_hill_climbing.h | 93 +++++ src/ipa/libipa/algorithms/meson.build | 2 + 3 files changed, 453 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..2b99afef --- /dev/null +++ b/src/ipa/libipa/algorithms/af_hill_climbing.cpp @@ -0,0 +1,358 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Red Hat + * Copyright (C) 2022, Ideas On Board + * Copyright (C) 2023, Theobroma Systems + * + * af_hill_climbing.cpp - AF contrast based hill climbing common algorithm + */ + +#include "af_hill_climbing.h" + +#include "libcamera/internal/yaml_parser.h" + +/** + * \file af_hill_climbing.h + * \brief AF contrast based hill climbing common algorithm + */ + +namespace libcamera::ipa::common::algorithms { + +LOG_DEFINE_CATEGORY(Af) + +/** + * \class AfHillClimbing + * \brief Contrast based hill climbing auto focus control algorithm + * implementation + * + * Control part of the auto focus algorithm. It calculates the lens position + * basing on the contrast measure supplied by the higher level. This way it is + * independent from the platform. + * + * Platform layer that use this algorithm should call process() method + * for each measured contrast value and set the lens to the calculated position. + * + * Focus search is divided into two phases: + * 1. coarse search, + * 2. fine search. + * + * In the first phase, lens are moved with bigger steps to quickly find a rough + * position for the best focus. Then, basing on the outcome of coarse search, + * the second phase is executed. Lens are moved with smaller steps in a limited + * range within the rough position to find the exact position for best focus. + * + * Tuning file parameters: + * - **coarse-search-step:** The value by which the position will change in one + * step in the *coarse search* phase. + * - **fine-search-step:** The value by which the position will change in one + * step in the *fine search* phase. + * - **fine-search-range:** Search range in the *fine search* phase. + * Valid values are in the [0.0, 1.0] interval. Value 0.05 means 5%. If coarse + * search stopped at value 200, the fine search range will be [190, 210] + * - **max-variance-change:** ratio of contrast variance change in the + * *continuous mode* needed for triggering the focus change. When the variance + * change exceeds this value, focus search will be triggered. Valid values are + * in the [0.0, 1.0] interval. + */ + +/** + * \brief Initialize the AfHillClimbing with tuning data + * \param[in] tuningData The tuning data for the algorithm + * + * This method should be called in the libcamera::ipa::Algorithm::init() + * method of the platform layer. + * + * \return 0 if successful, an error code otherwise + */ +int AfHillClimbing::init(const YamlObject &tuningData) +{ + coarseSearchStep_ = tuningData["coarse-search-step"].get(30); + fineSearchStep_ = tuningData["fine-search-step"].get(1); + fineRange_ = tuningData["fine-search-range"].get(0.05); + maxChange_ = tuningData["max-variance-change"].get(0.5); + + LOG(Af, Debug) << "coarseSearchStep_: " << coarseSearchStep_ + << ", fineSearchStep_: " << fineSearchStep_ + << ", fineRange_: " << fineRange_ + << ", maxChange_: " << maxChange_; + + return 0; +} + +/** + * \brief Configure the AfHillClimbing with sensor and lens information + * \param[in] minFocusPosition Minimum position supported by camera lens + * \param[in] maxFocusPosition Maximum position supported by camera lens + * + * This method should be called in the libcamera::ipa::Algorithm::configure() + * method of the platform layer. + */ +void AfHillClimbing::configure(int32_t minFocusPosition, + int32_t maxFocusPosition) +{ + minLensPosition_ = minFocusPosition; + maxLensPosition_ = maxFocusPosition; +} + +/** + * \brief Run the auto focus algorithm loop + * \param[in] currentContrast New value of contrast measured for current frame + * + * This method should be called in the libcamera::ipa::Algorithm::process() + * method of the platform layer for each new contrast value that was measured. + * + * \return New lens position calculated by AF algorithm + */ +int32_t AfHillClimbing::process(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; +} + +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(); +} + +void AfHillClimbing::setRange([[maybe_unused]] controls::AfRangeEnum range) +{ + LOG(Af, Error) << __FUNCTION__ << " not implemented!"; +} + +void AfHillClimbing::setSpeed([[maybe_unused]] controls::AfSpeedEnum speed) +{ + LOG(Af, Error) << __FUNCTION__ << " not implemented!"; +} + +void AfHillClimbing::setMeteringMode([[maybe_unused]] controls::AfMeteringEnum metering) +{ + LOG(Af, Error) << __FUNCTION__ << " not implemented!"; +} + +void AfHillClimbing::setWindows([[maybe_unused]] Span windows) +{ + LOG(Af, Error) << __FUNCTION__ << " not implemented!"; +} + +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; +} + +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; + } +} + +void AfHillClimbing::setLensPosition(float lensPosition) +{ + if (mode_ != controls::AfModeManual) { + LOG(Af, Warning) + << __FUNCTION__ << " not possible in mode " << mode_; + return; + } + + lensPosition_ = lensPosition; + + LOG(Af, Debug) << "Requesting lens position " << lensPosition_; +} + +void AfHillClimbing::afCoarseScan() +{ + if (coarseCompleted_) + return; + + if (afScan(coarseSearchStep_)) { + coarseCompleted_ = true; + maxContrast_ = 0; + int32_t diff = std::abs(lensPosition_) * fineRange_; + lensPosition_ = std::max(lensPosition_ - diff, minLensPosition_); + maxStep_ = std::min(lensPosition_ + diff, maxLensPosition_); + previousContrast_ = 0; + } +} + +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 steps) +{ + if (lensPosition_ + static_cast(steps) > 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_ += steps; + 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_ = minLensPosition_; + maxStep_ = maxLensPosition_; + 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 lens 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..b361e5a1 --- /dev/null +++ b/src/ipa/libipa/algorithms/af_hill_climbing.h @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Red Hat + * Copyright (C) 2022, Ideas On Board + * Copyright (C) 2023, Theobroma Systems + * + * af_hill_climbing.h - AF contrast based hill climbing common algorithm + */ + +#pragma once + +#include + +#include "af.h" + +namespace libcamera { + +class YamlObject; + +namespace ipa::common::algorithms { + +LOG_DECLARE_CATEGORY(Af) + +class AfHillClimbing : public Af +{ +public: + int init(const YamlObject &tuningData); + void configure(int32_t minFocusPosition, int32_t maxFocusPosition); + int32_t process(double currentContrast); + void setFramesToSkip(uint32_t n); + + controls::AfStateEnum state() final { return state_; } + controls::AfPauseStateEnum pauseState() final { return pauseState_; } + +private: + void setMode(controls::AfModeEnum mode) final; + void setRange(controls::AfRangeEnum range) final; + void setSpeed(controls::AfSpeedEnum speed) final; + void setMeteringMode(controls::AfMeteringEnum metering) final; + void setWindows(Span windows) 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 steps); + 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. */ + int32_t lensPosition_ = 0; + /* The best VCM step. It is a local optimum VCM step during scanning. */ + int32_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. */ + int32_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 lens */ + int32_t minLensPosition_; + int32_t maxLensPosition_; + + /* 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 7602976c..fa4b9564 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.h', + 'af_hill_climbing.h', ]) common_ipa_algorithms_sources = files([ 'af.cpp', + 'af_hill_climbing.cpp', ]) From patchwork Tue Mar 14 14:48:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18395 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 99468C3263 for ; Tue, 14 Mar 2023 14:50:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1FF1D62722; Tue, 14 Mar 2023 15:50:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805402; bh=A2RCsHkfkpU7qUA8+y5Em7gqpmln87ljqcVoTTsnXK4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=pDK/9K+q45pwhcmEO+tbxV+WDKklIcAAZ+2/RREc7bXgEzcZxLy8iyyJvEZ5wApiy n1ZXsQ+KJhkLunJaXWS8qz7gO3SLNJ8MyxJyMX/BNlBRxPjKl/qzq9jBrnIA9D5ZkB puME/t2xans3/CgVW/1ANGPrUy3F2erxOTFk2nluEhB0e5Kr47coFURyPQGPHdUo16 uirWbQZq8Nh8+E92LvMda6pMSHGiqxsr/mTi5NY7szTEKKNSeZqGniw7lfTaxC08Cd 4+xG/ctz3g9YLWIPvE+Pr+OatB+MsBJ8dfLwHtmVYGICZhZ+wqWdifW4SwBT33A8z3 64ffePNl41A8g== Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E1A016270F for ; Tue, 14 Mar 2023 15:49:53 +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="12ILASIj"; dkim-atps=neutral Received: by mail-lj1-x22c.google.com with SMTP id b10so16321036ljr.0 for ; Tue, 14 Mar 2023 07:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805393; 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=I8Rq7qVe+BzRDOtVw2SyeCLk2jE0HIkmVbPuakObb0Q=; b=12ILASIj3zvIXYDJD0gdFF96NL3qNW+NNFVV+pt4Eaf8+xEmVxgcAbZzis056E6G1I /y75Ewi2WJpJneA/K25vj2dU5WLtggo2OHGYTckv3FXt33S8nVT+9mdT8d3qHQiCtk1R J1uqZpoBNHeszegSzf5YTOF+2tDB74K4zQse6SZB1TCxqiTVGtfEGP6bmiV/KuvcBoLa Qi6veLtju3Mcs4uIJ1Zer49TpniPCNhnnFEBH9MOL9B3s7qnwW/Ses3O0BgLe2xP0AIS EB3YrqP64WMpNpgLsYCt7tedmOf303pqmxe4nq5/mY/VAe11lrlFJ8LIRa0f95OIZd/Y 5kXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805393; 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=I8Rq7qVe+BzRDOtVw2SyeCLk2jE0HIkmVbPuakObb0Q=; b=tgyCGFUOhuWBjcvpbAKPWX2+FEmEgaKtEXkr0dYbp54wwyxLA8DS881mJUwR/Dg2tH NpBhbyq5vx7hxgyJPViBx2oFkCdT+z37OuSnLkriiZ4Yz9TOIaBisORg7LT/5/fkTcAU jexu4LcV3kE3OZlWv8C0IzAZ0ALaBJPTlPB+jM7VTVGENIDD5jz7D+2RGy6RZOtZMTlA uHor2dLnd4ife6HLB23nJJ5+u6XttnE0PG3COi59t6Bf3rauw/6TQy2ik/MTNilzlpe8 5/Se5g+lcJqVlC9USUhCKTl9XvLkr685hFpv+xy4EdIl4iJ46uZfx/D18OY9djC6621I yWKQ== X-Gm-Message-State: AO0yUKUOz30Xpt4hkpQpStZ/F0xEVogKWx1tn1olrGIoeqNtm+fl0bun E6v96GX2XW4Kqn7NDK54lrFaOjHL9HUEfGvZm74= X-Google-Smtp-Source: AK7set+IuIfHpGhEAIaioBmEl5beCamarzFE5RiwE8MbVrafJUbK2Q2S7lOEh6BpniIzOQwMAt8x4Q== X-Received: by 2002:a2e:b8cb:0:b0:298:592e:113a with SMTP id s11-20020a2eb8cb000000b00298592e113amr12004257ljp.6.1678805393573; Tue, 14 Mar 2023 07:49:53 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:53 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:29 +0100 Message-Id: <20230314144834.85193-6-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 05/10] ipa: af_hill_climbing: Add "Windows" metering mode 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support for setting user defined auto focus window in the AfHillClimbing. This enables usage of AfMetering and AfWindows controls. Each time, there is a need for changing the window configuration in the ISP, the signal is emitted. Platform layer that wants to use the "Windows" metering mode, needs to connect to this signal and configure the ISP on each emission. Currently only one window is supported. Signed-off-by: Daniel Semkowicz --- .../libipa/algorithms/af_hill_climbing.cpp | 52 +++++++++++++++++-- src/ipa/libipa/algorithms/af_hill_climbing.h | 12 ++++- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/ipa/libipa/algorithms/af_hill_climbing.cpp b/src/ipa/libipa/algorithms/af_hill_climbing.cpp index 2b99afef..3421f240 100644 --- a/src/ipa/libipa/algorithms/af_hill_climbing.cpp +++ b/src/ipa/libipa/algorithms/af_hill_climbing.cpp @@ -83,15 +83,28 @@ int AfHillClimbing::init(const YamlObject &tuningData) * \brief Configure the AfHillClimbing with sensor and lens information * \param[in] minFocusPosition Minimum position supported by camera lens * \param[in] maxFocusPosition Maximum position supported by camera lens + * \param[in] outputSize Camera sensor output size * * This method should be called in the libcamera::ipa::Algorithm::configure() * method of the platform layer. */ void AfHillClimbing::configure(int32_t minFocusPosition, - int32_t maxFocusPosition) + int32_t maxFocusPosition, + const Size &outputSize) { minLensPosition_ = minFocusPosition; maxLensPosition_ = maxFocusPosition; + + /* + * Default AF window of 3/4 size of the camera sensor output, + * placed at the center + */ + defaultWindow_ = Rectangle(outputSize.width / 8, + outputSize.height / 8, + 3 * outputSize.width / 4, + 3 * outputSize.height / 4); + + windowUpdateRequested.emit(defaultWindow_); } /** @@ -165,6 +178,14 @@ void AfHillClimbing::setFramesToSkip(uint32_t n) framesToSkip_ = n; } +/** + * \var AfHillClimbing::windowUpdateRequested + * \brief Signal emitted when change in AF window was requested + * + * Platform layer supporting AF windows should connect to this signal + * and configure the ISP with new window on each emition. + */ + void AfHillClimbing::setMode(controls::AfModeEnum mode) { if (mode == mode_) @@ -190,14 +211,35 @@ void AfHillClimbing::setSpeed([[maybe_unused]] controls::AfSpeedEnum speed) LOG(Af, Error) << __FUNCTION__ << " not implemented!"; } -void AfHillClimbing::setMeteringMode([[maybe_unused]] controls::AfMeteringEnum metering) +void AfHillClimbing::setMeteringMode(controls::AfMeteringEnum metering) { - LOG(Af, Error) << __FUNCTION__ << " not implemented!"; + if (metering == meteringMode_) + return; + + if (metering == controls::AfMeteringWindows) { + windowUpdateRequested.emit(userWindow_); + } else { + windowUpdateRequested.emit(defaultWindow_); + } + + meteringMode_ = metering; } -void AfHillClimbing::setWindows([[maybe_unused]] Span windows) +void AfHillClimbing::setWindows(Span windows) { - LOG(Af, Error) << __FUNCTION__ << " not implemented!"; + if (windows.size() != 1) { + LOG(Af, Error) << "Only one AF window is supported"; + return; + } + + /* \todo Check if window size is valid for ISP */ + + LOG(Af, Debug) << "setWindows: " << windows[0]; + + userWindow_ = windows[0]; + + if (meteringMode_ == controls::AfMeteringWindows) + windowUpdateRequested.emit(userWindow_); } void AfHillClimbing::setTrigger(controls::AfTriggerEnum trigger) diff --git a/src/ipa/libipa/algorithms/af_hill_climbing.h b/src/ipa/libipa/algorithms/af_hill_climbing.h index b361e5a1..4f507010 100644 --- a/src/ipa/libipa/algorithms/af_hill_climbing.h +++ b/src/ipa/libipa/algorithms/af_hill_climbing.h @@ -10,6 +10,7 @@ #pragma once #include +#include #include "af.h" @@ -25,13 +26,16 @@ class AfHillClimbing : public Af { public: int init(const YamlObject &tuningData); - void configure(int32_t minFocusPosition, int32_t maxFocusPosition); + void configure(int32_t minFocusPosition, int32_t maxFocusPosition, + const Size &outputSize); int32_t process(double currentContrast); void setFramesToSkip(uint32_t n); controls::AfStateEnum state() final { return state_; } controls::AfPauseStateEnum pauseState() final { return pauseState_; } + Signal windowUpdateRequested; + private: void setMode(controls::AfModeEnum mode) final; void setRange(controls::AfRangeEnum range) final; @@ -54,6 +58,7 @@ private: controls::AfModeEnum mode_ = controls::AfModeManual; controls::AfStateEnum state_ = controls::AfStateIdle; controls::AfPauseStateEnum pauseState_ = controls::AfPauseStateRunning; + controls::AfMeteringEnum meteringMode_ = controls::AfMeteringAuto; /* VCM step configuration. It is the current setting of the VCM step. */ int32_t lensPosition_ = 0; @@ -87,6 +92,11 @@ private: /* Max ratio of variance change, 0.0 < maxChange_ < 1.0 */ double maxChange_; + + /* Default AF window */ + Rectangle defaultWindow_; + /* AF window set by user using AF_WINDOWS control */ + Rectangle userWindow_; }; } /* namespace ipa::common::algorithms */ From patchwork Tue Mar 14 14:48:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18397 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 641CCC329D for ; Tue, 14 Mar 2023 14:50:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77B2E62716; Tue, 14 Mar 2023 15:50:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805404; bh=AnuirllEo1Cb2hAfdXm0mYzwNlQEAJgYBUji5i6UfEE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=WV8S8MSSRHivk/s/IBc4lmvIHGXaUZbUChln2e+9uiNxfQkxODDttKXXZnd0MkrLT du+oPE5X7n2lt32jh/woxUMtsf4N+9iDmde0vEYY70t+6U0vUZBG/oVW5r2UGXQKkL vIsfqqh/5dGCO7/NCyc2ox88sTcPIQgXNZkfEYvu1UEHBm/1kl8x8QX+kDAzI2hDLF Q7UhsQznsM9s1leyPqmna/HYqBDl0SJbf2JPXHKFSOS04ep84cxuoGUZfaM/vzp4Sn OKudmjQKhekTp2JSfW13JqgFxsriVWSrD9XZFskOcGs/ysZfenDG54CXDqAqfUshgf BwGeMNaPigeRw== Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0609062709 for ; Tue, 14 Mar 2023 15:49:54 +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="H2M0l2Pq"; dkim-atps=neutral Received: by mail-lf1-x132.google.com with SMTP id d36so20348501lfv.8 for ; Tue, 14 Mar 2023 07:49:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805394; 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=P60WbR8KYzaoiKJz8hyfEKZ8GtJHFrfGVTuX5vXZzgo=; b=H2M0l2PqSgDQG37X+eCJkhdGRNE+4DbUbSwk8GuogOata95czoBv7AxCifm0IWqizV sdWt/2/sACHEHRj6Y/FHAODqPporu9UPMg1fZGK5gcDA/YEDXrViowVRN3RfqigJlo1+ aJtLW7DoeFrWSSnuz2QNCFtBsB/31LJeoz+aT4XoVkUWOuYQJdwrxv/0TMI6Lgpot3tP Bizia1clt/h+ofJpP1R+YCHfAM7u25hocTG/vzZWLVOu5kpaPGBcxA6zXa+4aWx2xfUG +PWaibssun+cLlT0EnvUoqCB5HgewUhQ5TxI3rLafejwjd74itNqF6sRzYkcfOqeqWfn RH6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805394; 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=P60WbR8KYzaoiKJz8hyfEKZ8GtJHFrfGVTuX5vXZzgo=; b=o/tKRYWB6Pi819XNtbmRd5dUSdnhZ6DftZtCyXEzhWNh/g8IfH7olzRbdP0LCqBkSO SGJjHFVHHZ7pt+qDr3eywZjXUCnXqPeHKFXBH/iJ5b5ZDQz/CB5X1wwWL73sHGNLt+kx GsnLIff1rKxK0LPgKY9xKGhZtFHrOoUjpbHycVLZRp+iM1BCqwZf4T9hRucGzUa0whzH IVXW7WcRfFPgyJfQIJAuXAht5B2boW+yMGzgkaVvVMxG/Cf0LxqziARJ02KOqfhHiks3 Dv4IczNQt+Uzliq3vypwT5VC/f6uxCQIHOscSdmBuXkEPKlNixkdXVG52xTCT+DLdUPR gsvw== X-Gm-Message-State: AO0yUKVoGGyRBZNiS9QVlXfxCENve7qPMDRJIhm4eFO5BbRwkU0S0KrP 4I5ypPh3Itk0SHB7F/d6j8WA8R9l4m1vLk6vlw4= X-Google-Smtp-Source: AK7set93uzwMz0v9NgBRQrjUyW+Wia5VWSd22o/ZvrtUhoh30GDQv+Mk2oeChvnBXFugA/EEJYytXQ== X-Received: by 2002:ac2:514b:0:b0:4d8:8ad1:a05f with SMTP id q11-20020ac2514b000000b004d88ad1a05fmr913313lfd.48.1678805394128; Tue, 14 Mar 2023 07:49:54 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:53 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:30 +0100 Message-Id: <20230314144834.85193-7-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 06/10] ipa: rkisp1: Add AF algorithm basing on AfHillClimbing 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add contrast based auto focus implementation for rkisp1 platform using the common AfHillClimbing algorithm. 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 | 107 ++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/af.h | 39 ++++++++++ src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/ipa_context.cpp | 13 ++++ src/ipa/rkisp1/ipa_context.h | 5 ++ 5 files changed, 165 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..abf5d91f --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, 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 contrast based hill climbing control algorithm for RkISP platforms + * + * Auto focus algorithm for RkISP platforms, basing on the common contrast based + * hill climbing auto focus implementation + * (libcamera::ipa::common::algorithms::AfHillClimbing). + * + * This is the platform layer of the algorithm. + * + * Tuning file parameters: + * - **wait-frames-lens:** Number of frames that should be skipped when lens + * position is changed. Lens movement takes some time and statistics measured + * during the lens movement are unstable. Currently there is no way to know + * when lens movement finished and this is a workaround for this. Wait a fixed + * amount of time on each movement. This parameter should be set according + * to the worst case - the number of frames it takes to move lens between + * limit positions. + */ + +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 af.init(tuningData); +} + +/** + * \copydoc libcamera::ipa::Algorithm::configure + */ +int Af::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) +{ + const auto &lensConfig = context.configuration.lens; + + af.configure(lensConfig.minFocusPosition, lensConfig.maxFocusPosition, + configInfo.outputSize); + + /* + * Lens position is unknown at the startup, so initialize + * the current position to something out of range. + */ + context.activeState.af.lensPosition = lensConfig.maxFocusPosition + 1; + + return 0; +} + +/** + * \copydoc libcamera::ipa::Algorithm::queueRequest + */ +void Af::queueRequest([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + const ControlList &controls) +{ + af.queueRequest(controls); +} + +/** + * \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; + + int32_t newLensPosition = af.process(sharpness); + + if (newLensPosition != context.activeState.af.lensPosition) { + context.activeState.af.lensPosition = newLensPosition; + context.activeState.af.applyLensCtrls = true; + af.setFramesToSkip(waitFramesLens_); + } +} + +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..85de0a64 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, 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 Algorithm +{ +public: + 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 process(IPAContext &context, const uint32_t frame, + IPAFrameContext &frameContext, + const rkisp1_stat_buffer *stats, + ControlList &metadata) override; + +private: + ipa::common::algorithms::AfHillClimbing af; + + /* 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', diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 401c098f..5c5f80c7 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -134,6 +134,19 @@ namespace libcamera::ipa::rkisp1 { * member may be read by any algorithm, but shall only be written by its owner. */ +/** + * \var IPAActiveState::af + * \brief State for the Automatic Focus Control algorithm + * + * \var IPAActiveState::af.lensPosition + * \brief Lens position calculated by the AF algorithm + * + * \var IPAActiveState::af.applyLensCtrls + * \brief Whether the lens position should be applied + * + * If true, IPA should send new controls to the PH to set new lens position. + */ + /** * \var IPAActiveState::agc * \brief State for the Automatic Gain Control algorithm diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index bfb6e1b7..2c2eec3b 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -58,6 +58,11 @@ struct IPASessionConfiguration { }; struct IPAActiveState { + struct { + int32_t lensPosition; + bool applyLensCtrls; + } af; + struct { struct { uint32_t exposure; From patchwork Tue Mar 14 14:48:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18398 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 6F185C329E for ; Tue, 14 Mar 2023 14:50:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5324062728; Tue, 14 Mar 2023 15:50:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805405; bh=RYSIynGlDgflsC6y+mnJZbE9L7co31kh2vCYt83mD0Y=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=R0ToUK81KijAmo6M1deIOieDoJ29ylB/Hn3OCNyzpvmPbQpaIf539gkdwPRVtrERS 45edXmL0rglxy7dEEkPU4HFlEeg6PZ9EhTWC4l6MABZDVkERsYbHPRscEvLGhWMTJw 7dmNoc+jbE5dI7bj9fa6tsTFVFe7Nes7fiCsVQiIqL0hF7MkcL31o1hC2pJ7AYTce+ GOneBVS9YkjRDDrXO2VxbfRptp9fwkVfTOCB7LOornYAx68mj237zTUg6Bl6AF6iLw MvTr5w/QzpzF4EcBq2XyK28hduWq6NRQureMgYr9Cbmm8katoGig6sqZG+wJS94XUL c1ba5EO7uokgQ== Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C03C46270A for ; Tue, 14 Mar 2023 15:49:55 +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="QlMKpjtW"; dkim-atps=neutral Received: by mail-lj1-x230.google.com with SMTP id f16so16272877ljq.10 for ; Tue, 14 Mar 2023 07:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805394; 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=LIMALetFO7wAVuqtZcDoxVbIpR8Q7JtG3uCyJPy1QWQ=; b=QlMKpjtWamjxgnE/9Njmk/dFO2HT3by3QsRXqGEldxDXg31wTbByB4JTN9rPbp9kg7 Snkg8wHMmKS/1/Lf3DdAN/jlFbPSupVj9RZAV9ZxgcFy2dG76kpcCyKFj+3i4tzZF8oF 8YPIyrodd+li3EI/DWJ0ctR+P3mzmXQpCi4uHxfw7pdfcjldWkVjvnWgLEoa7awSkNso 00IkWmBTckf+e4zKbq1CrbN0OJZ+oZS4/dsYwRUBijkrEgbBt+i1jcz3iYoCUOKaC9BU pM2epLGmSTufMEyrJtCddlexqkCHc8UvPvIXCETZMU0wVqpXPGbAgBcwK6jJxeZiH1Sm r0BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805394; 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=LIMALetFO7wAVuqtZcDoxVbIpR8Q7JtG3uCyJPy1QWQ=; b=AWwWU+vfH9Zb+r/T2W70PKi1Jma4wWEGGQVjv7BLkyTG1Hk3rsz9XSN674B8HO5Q5o cPXi1YMrnkImpaVLkmxjWlfVevu/64pgG5+FwNDouZYZL9dh3j2GyeQ0Q1jBbXYDFvpv HBghps81Zi47CCFfkTMvjCuxLkdF/egBa7HERrM4fu8saoPeetHLqHiXRPi0PVGky3Fb TBA8YQZPMEl59BRg/T+V23Qm5mWiH2XZd8jpSWBsFzmVIXdeNVWDnFnlw4KdBEapv/7X xs0lgJNHCLOFC2vo3bAQkaDYmJH5WOTvP2RYSQ7GAxZkJVbrVcyIBI95zh42YiaZIGC9 kMAg== X-Gm-Message-State: AO0yUKUPycC9uweQEotuQyVBiTpZhFYeCtnSRpBGqw4ywkJo8HHmWebU cwRuSXiCoQ5aQu62l6GUzhSqCYQ2pDbJEmwDNCE= X-Google-Smtp-Source: AK7set+YhA7EpitO3VtL65P7R58fNxZt0SuO9W39EysUlpoOU0Jv1LbglmxNagEt0PuYlSBwOnesRQ== X-Received: by 2002:a2e:7006:0:b0:294:6a83:fb28 with SMTP id l6-20020a2e7006000000b002946a83fb28mr12243828ljc.41.1678805394701; Tue, 14 Mar 2023 07:49:54 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:54 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:31 +0100 Message-Id: <20230314144834.85193-8-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 07/10] ipa: rkisp1: af: Add "Windows" Metering mode 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add platform related code for configuring auto focus window on the rkisp1. Connect to the windowUpdateRequested() signal exposed by the AfHillClimbing and configure the window on each signal emission. This enables support of AfMetering and AfWindows controls on the rkisp1 platform. 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 | 63 +++++++++++++++++++++++++++++++- src/ipa/rkisp1/algorithms/af.h | 11 ++++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp index abf5d91f..794fa59e 100644 --- a/src/ipa/rkisp1/algorithms/af.cpp +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -31,18 +31,48 @@ namespace libcamera::ipa::rkisp1::algorithms { * amount of time on each movement. This parameter should be set according * to the worst case - the number of frames it takes to move lens between * limit positions. + * - **isp-threshold:** Threshold used for minimizing the influence of noise. + * This affects the ISP sharpness calculation. + * - **isp-var-shift:** The number of bits for the shift operation at the end + * of the calculation chain. This affects the ISP sharpness calculation. + * + * \sa libcamera::ipa::common::algorithms::AfHillClimbing for additional tuning + * parameters. */ 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 */ + +Af::Af() +{ + af.windowUpdateRequested.connect(this, &Af::updateCurrentWindow); +} + /** * \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 af.init(tuningData); } @@ -77,6 +107,32 @@ void Af::queueRequest([[maybe_unused]] IPAContext &context, af.queueRequest(controls); } +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void Af::prepare([[maybe_unused]] IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + 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 */ + af.setFramesToSkip(1); + } +} + /** * \copydoc libcamera::ipa::Algorithm::process */ @@ -102,6 +158,11 @@ void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, } } +void Af::updateCurrentWindow(const Rectangle &window) +{ + updateWindow_ = window; +} + 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 index 85de0a64..df2ca31a 100644 --- a/src/ipa/rkisp1/algorithms/af.h +++ b/src/ipa/rkisp1/algorithms/af.h @@ -18,20 +18,31 @@ namespace libcamera::ipa::rkisp1::algorithms { class Af : public Algorithm { public: + Af(); + 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 updateCurrentWindow(const Rectangle &window); + ipa::common::algorithms::AfHillClimbing af; + std::optional updateWindow_; + uint32_t ispThreshold_; + uint32_t ispVarShift_; + /* Wait number of frames after changing lens position */ uint32_t waitFramesLens_; }; From patchwork Tue Mar 14 14:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18400 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 CA7E3C329F for ; Tue, 14 Mar 2023 14:50:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5664A6273D; Tue, 14 Mar 2023 15:50:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805407; bh=BjcrFEiQTZSm9P/GWdlS61dbmdphmJsI4G6x4WDNV8k=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=rZrX2t8JgCQYrq0dNud90arpH5n4O2gKnxj4IjfwXNnEA8jwgrtoAgCHULD5v+vnl zfuh9tMLzEf5saIF78lerpQaE0u55y3kQrKHvz5BXLpZZgbMMDFWhOWv7FjA+hJz04 AP+SJjaZ5rp7t3OJJXLzdHR2A9e+W/DDXm2IC7ksRl3RNXoXYReS2cMkpzDUQYmHUB 3Td6W2K+k/Ktdc8nt7NV065ba6FwpBY8t5VInH4slhsQyl/FG0d7E8iwz1mecpZzb8 nqkBb1qVaaMT8PCw5hGUjtZDmYXF950fxCZgPRz+gFkyXCpQmC0BYvV5pN1zU3RefF bt47IQoJpwvIA== Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC76362717 for ; Tue, 14 Mar 2023 15:49:56 +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="llo8xF8D"; dkim-atps=neutral Received: by mail-lj1-x230.google.com with SMTP id g18so16322041ljl.3 for ; Tue, 14 Mar 2023 07:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805395; 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=LRgW1NFPu4viMTf/MJ3llUErEThVQZNmL7f3XB7nmj0=; b=llo8xF8DBh4d4Nv3tE+yoEbzYTBRSdcVldWOiX7IbNrD5/GseRgbf7mc2qS2hunhdD 0xY7HBgWhpIPjzTNfFQ7ccefILJWbMEb2nITkMndIpT7/zvTTGeGLlbrccr2DsTByARu eXnTlZMXkeKIwP97Y0k7hmNiBy+gQzScrJyL3ifo0m9TuN7p0wQ/frkGseMldRooZaQT 5yqXB6x7MNTc0lbCMHgGVtyaoA6LI+8mRPHHYOS2Ki2FrJNmUK/pC8ePagmdLoGYF1g6 oBC/4JRbOy+HpDaCk3XliZr5rDl/SHCib64iOE3HtbQvv+boQ0gBZRDoYJ4yCNA2yWi7 tS5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805395; 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=LRgW1NFPu4viMTf/MJ3llUErEThVQZNmL7f3XB7nmj0=; b=70nX30buugHTriL+JHM+KlKcXtJ68MY+PCBGSrqtor5ctfjvvCngtuPTraNuJBns5p lwIA8W4uXze3rF34687jiXTEcxVMWTWWEJXS3DVuItl/0cj3ljgHv4TdBw8FksHsG3Qp eeRTnmoL6u+toyvvgRJdHYU/WV85B7A8P9RKsdXF6k3LiFMJTNmJqXgmspgrc+vaisnp M5Tigq7Tc2aahhyHdDZ64oQjDU+kUG2iegRKMP6jSgUUnyBoI4g6sHYNcE9VQT/JKBHq m8RayO62s/Nb6/MiM02lI1hUd61WmfSXBBZaZR/vXTz6Oza2lASV3ns7PIbXBQrVN/I6 lndQ== X-Gm-Message-State: AO0yUKUXeodpTky9qrMb1z202He5Co7YeSVrS2MvwQ7N6Y4IYid17fZO tRxi7OJw4Ax8wUe9P+eoAMIpRn4wGKiK3CS32r0= X-Google-Smtp-Source: AK7set8QzPqibHMyzRPO6KSDAtwfhwxeAVGpWcNkKsN+6U/vJpFXMnqViPhh2II6D4t7RBQ3RIOp5g== X-Received: by 2002:a05:651c:2125:b0:293:2cec:9ebc with SMTP id a37-20020a05651c212500b002932cec9ebcmr15823042ljq.14.1678805395260; Tue, 14 Mar 2023 07:49:55 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:32 +0100 Message-Id: <20230314144834.85193-9-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 08/10] ipa: rkisp1: Add AF controls to the RkISP1 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 Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add controls supported by the AF algorithm to the list of controls supported by the RkISP1 IPA. This exposes the AF controls to the user and allows controlling the AF algorithm using the top level API. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/rkisp1.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index cd1fbae3..4b30844f 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -101,10 +101,16 @@ 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) }, { &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 Tue Mar 14 14:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18401 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 B3F69C32A0 for ; Tue, 14 Mar 2023 14:50:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 301A16274E; Tue, 14 Mar 2023 15:50:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805409; bh=J62OTx3oB/aLsxLwgoirbptPdUBJpLLnjDolM8ZEjBI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=W0cok8L5BSbYxQkJ7P/pCA8kg+Zu0AVwzO9uRLBXj64bvxTxzYAX0eWzzVCKoZpJz TYS3vpwnfy7QlhPbkJT0C4xfBZhdj2q7JNSb5FCN0YPywN30Tfqq4O+2e47Grdkm9P wbPakH+J8l2eo59DOzuTfTUAzJD5rZ+eeMEhDjCdn9cS0f9y3v2EQb53p5K/rnW0tz dPqznwTijNmKhQcg5D66K8bHIAxI/VgOwq051qw4OFx4l/vDIciD+eePkimJ/3AJVa XHo44WCbnJdDidxZK/1Ivg2VhOs++4FXSBGZD9x9hzlLXmnXGBuKgxS2er4qdOBjZa u7dXLJykRFxgg== Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 10D016270D for ; Tue, 14 Mar 2023 15:49:57 +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="M5O2tbBf"; dkim-atps=neutral Received: by mail-lj1-x22b.google.com with SMTP id t14so16295683ljd.5 for ; Tue, 14 Mar 2023 07:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805395; 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=/VDexCp2IVtvlqpNyv5xS3Sww9RNPylcLJ5hCb13SxA=; b=M5O2tbBfgDYlkmIEuX9bvyKrkqp3jK00z1xG5d1qSJ/0d4K3abwSaCZYDagyjMQc8Q +wEqKcuRpWNyHCJPOVz5c+9KHEQw9j+PUpwdrVQupt/Z9ixBE8Lidqv1a7EnneMpkIVo Yfra1KTnG3cEPgGUOD5sgluaHw5Yep+kZhHA5wuPDPPmlDkpIyGl2LwTDxQ3p8wNsAEq WJPPZw9xoxJAFJltnKBaurm+jwqp3KNGVELS6lq3Eb14AUfcLvOdTMMAJu/xiOhVAv7z JK1Djw9YeskN+kNz77l3AMFrqDoOGRrAKGJOTbf0sgU7VJuZVYhSADYq7YZVh8HqHq80 lJYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805395; 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=/VDexCp2IVtvlqpNyv5xS3Sww9RNPylcLJ5hCb13SxA=; b=LOMWklzw20rrjOzKPa6r+HzRlaMopm/oPSsv7eZW2OtN23OMnwOvOQo2OYC3dFpi61 bDeFffSBjAX728q/oAFuib0jDcyYtwom9zPbrQxvvR/IWZbeK7tb4EwxOt4Q/gocxkOw YrN+f631SGdvkWMF/hhizoRRt3GaA+SJkldQnVkhHduRvvxgeP8t6kVayQh+N0AzhEZp J8D4o9SVahAUH8jEpsb2cJwOb/ljU/swu3KQS8WmeeV901aSjLIXdVvENGOMBCroBEfk b3+mxlCtS5aOklf4DW5bHyuH4poiLBZ0ULSrE8nUOB8yyxlNrtpZAKpSRlUCy2UvMCpL +W3w== X-Gm-Message-State: AO0yUKU0rxE0yJShXRFSk+L1ACAmFF68FtSKDEbe4tlAzatQfQnLZK4p 5JjOWU19tI08K7P+RujxYpM2ILSLs314tVPzXEs= X-Google-Smtp-Source: AK7set+/tsJqdz9jguoTotjh6vFFa7kVhK4eT8niQSnYG31yKuO1Qlgp0g/X4ReqrjVdGSdSCRs25Q== X-Received: by 2002:a2e:83d6:0:b0:293:2ca4:bbcb with SMTP id s22-20020a2e83d6000000b002932ca4bbcbmr10945456ljh.50.1678805395821; Tue, 14 Mar 2023 07:49:55 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:33 +0100 Message-Id: <20230314144834.85193-10-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 09/10] 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 Cc: jacopo.mondi@ideasonboard.com 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/rkisp1.cpp | 8 ++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 17 +++++++++++++++++ 3 files changed, 26 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/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 4b30844f..4aef2e30 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -469,6 +469,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, + 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 83fb6287..1dc3f957 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -114,6 +114,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); }; @@ -340,6 +341,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); @@ -403,6 +405,21 @@ 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 Tue Mar 14 14:48:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18399 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 33E12BD80A for ; Tue, 14 Mar 2023 14:50:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 204E262720; Tue, 14 Mar 2023 15:50:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805406; bh=U0zf70n67gmp4DQxMp/xgOytdA7qn3pFeerSB80BB5s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=P+7m78/mUiyLfrEZ1Mi+oxE45NOhxwCi4iDu0O0iLVC1cli737yVZ/Jm2wmrMYE0h 4rozrkI7kdVDIVC1oye8it4G1p5e5XG1n/LNQlKrxitH5hAvEVshDnmcXLZK8gugHw OmWLeTv88S7n7jPQKZbCUuYmH1kONOSU6kpqj4CBSWf1pCRyDLVyyl8HqZVwFrDy/Q ZUEMFR0SQ9ulglCEqQzX7pwXVacw5TskoDK2GNYPpKr4FY6hlQbu156ruakMR0nCkH ci3QAf8+OVS3crtmuAmqkmoFZWzFeD6f2VsMiNEOhq/XBQ+w2EbfAtqLDfZvIEuke7 4BmBii+V3DsJQ== Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9388F62716 for ; Tue, 14 Mar 2023 15:49:56 +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="hLs6UIhY"; dkim-atps=neutral Received: by mail-lj1-x22c.google.com with SMTP id b10so16321224ljr.0 for ; Tue, 14 Mar 2023 07:49:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805396; 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=enxLfi8KyvVnCKcjKKDlk6Z79Yzi2hsHgA7AOVpAjH4=; b=hLs6UIhYuGpz5kMFKMoYP3o9BYJWsuHdy2zoOITz0t1NsGuefLq82K+3RHpo5iqmAq nnBz4xtLg1lLPgNjcpPbe48l+rTrF+uHGy4IPzzA0HvPqN5sBBTe4nZVtT9Ebc80y1+h rZf8lA4iUpsfuc72n/LX3w6vZlLmi++ZWyqdUuDCqibt0sf5su4fZhsUxY0uqTcRKdV2 zsrqWWbApofHQitanPOm5/N387pOdvYgbm9xJTHVfM4hkz0DrEQnDViIkUhsWbrBZ/4t NxBnMmGQfmoLyJCRiDrp6KyADosSkrEQaYdpNrUAZLY6JQH2ARBjh5LKhoupskwijd26 zD9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805396; 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=enxLfi8KyvVnCKcjKKDlk6Z79Yzi2hsHgA7AOVpAjH4=; b=gjEtmSUZun4bBGEkxbc7kG11KVx0QJYZPzEKhMhdml3b9aw6SjMaUYEi5c8bCbLt8z niDLmZMamY1ofOhYAXkrhb13AO4nt+qb5aNk35PgAJ+FCE2/deiiVfG81ykKx3PlL+k/ SNZlLEGK/BFl11if8Ve2sPbea0QrRqKjBAgpsFdxrYyeykWYvBYiRIO5TWifnci01a9j 2+cqGDx7zTk7EobvUch+GzTEIMwX0rQ2Cns7QOxYE6h7YCMqX7rGA5ZvcGmAs2QMK4Ux QQBzjx2PiN8cqsSsa5f+cwl/KNYlRLOIffB74p2jZE+pVWTNFxn39xBX5gSrh8zQm6bM lhCA== X-Gm-Message-State: AO0yUKVyHxqZaRYQr0QewrKXYQ68NL0Z73c10upD4OPSBptEiIQH6zkb pIoG190FvNG0HKJrKNEAD+7szkgvcSsugIBGl3o= X-Google-Smtp-Source: AK7set/U6duceBL9zgvlFk2TNSMIXYiH6KTJKdNFVHNgxPj7TWXmyO1K5QkMRs63GA21Nma/3owyMw== X-Received: by 2002:a2e:9b93:0:b0:298:7018:e2e7 with SMTP id z19-20020a2e9b93000000b002987018e2e7mr4590357lji.22.1678805396378; Tue, 14 Mar 2023 07:49:56 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:56 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:34 +0100 Message-Id: <20230314144834.85193-11-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 10/10] 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 Cc: jacopo.mondi@ideasonboard.com 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 --- `min-vcm-position` and `max-vcm-position` was removed compared to v3. src/ipa/rkisp1/data/meson.build | 1 + src/ipa/rkisp1/data/ov5675.yaml | 18 ++++++++++++++++++ 2 files changed, 19 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 f5e9fa75..1fdce2c9 100644 --- a/src/ipa/rkisp1/data/meson.build +++ b/src/ipa/rkisp1/data/meson.build @@ -4,6 +4,7 @@ conf_files = files([ 'imx219.yaml', 'ov4689.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..6a31868c --- /dev/null +++ b/src/ipa/rkisp1/data/ov5675.yaml @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: CC0-1.0 +%YAML 1.1 +--- +version: 1 +algorithms: + - Af: + coarse-search-step: 30 + fine-search-step: 1 + fine-search-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: +...