From patchwork Fri Mar 24 14:28:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18444 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 2AEFDC0F2A for ; Fri, 24 Mar 2023 14:29:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 542A9626D7; Fri, 24 Mar 2023 15:29:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668167; bh=5zj1ZK6RZTdGDyrBsCSug+3xNfV1FsZrVJVaDPc75go=; 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=qXUQIjWG5AsZxEt51JntFVPWOZ3Ga9Ib07PdCiGnt0wvmytpixUDkeecnyS3hI+4g byq3tW1z/K77etrmiZknYjKjCZoTr/ouzdfOAHKul8mlYcJjiL8xEdY9MPXBen0kHf xv+UBY7I4poBptpF/k2QBdbFuWD1p3Cg6tXGHIk9esW1yYlT2SPwLTcPrDbkEelnk1 1HQf1hyl9WXOxhFVYTjCmmJM0+IQngF3OafPTUrQGl0sCpSsVOxTLeFBmNNf45dvO8 fInZJIN8sYOieCoV4IEHakJqazcRIqfVFszMFNbFTPxPnznkgA74iyFql5E0OJTkKf Uzi97ix9eJxug== Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A5051626D7 for ; Fri, 24 Mar 2023 15:29:25 +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="csCrVjvl"; dkim-atps=neutral Received: by mail-lf1-x134.google.com with SMTP id g17so2474176lfv.4 for ; Fri, 24 Mar 2023 07:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668165; 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=+b1RxHmY2A94x2fOL2v5UZLA9FzXYBcNr7XlKQGwweA=; b=csCrVjvllNOFCyb+IzRdQVc1UVmGSgxsaVQC/IIbwfcxPMpg19EqHspw7fiC1NH2sE qOPOjBl1YWeEoaRCNeMWLew4yaEkkD04s3kxHQEFfLLfD6Wpn4pdVae52o++mz9fOeYN l8f5POfjbp07KENin/LsqmJYJ4x9C+A5tfBUBJc9tVQgWpd0nmEo5g4WvR9sZpsKwXlY 6OLjsHA4DTgHRCA0VTCy1TlK2CxqAfQ1jhqIci3qLlkLnugmd4Ixdd9mx9Dec3frnvdN aZTR4Cxp99j7V7Mf7mwhmxaGY6bfqeyWpKOFWafVkH7+7hb15lH6Hj/KM1DuBQaXJ01I J4WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668165; 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=+b1RxHmY2A94x2fOL2v5UZLA9FzXYBcNr7XlKQGwweA=; b=twoNn957yRjm2pqnyYxa3OkqKC1DI62akojdvfEi7+OTRirR8HBcWnT+np5zOa5Sep hq8tDPRISscCdv67eYeSLqOcakUDnhoYgqbyoACdVTs4ohBcPCzEsFWOachtgh06NY1E kItNmRulRYx73vw/fW9mM5U/keT/yglBEuekByYq0abkw8NJktNt1CnaINO0J6WzOJ/e Lg0t0dSsxj4Cb+cRzEYPw5I+Ua5lydLMH6MSQbNjP60L8fRQmlYNid+W/ytEWjCCGGj3 9I1/8/bPF1s7KeGtJQpYcKkr4eYCMWrqJtQAlY2IxtZadz1eg5l6KLGkM/7qWE9DtmTi XnCQ== X-Gm-Message-State: AAQBX9dcm61/5/js1VLGQlfZztvxrLoDT4qJ/7UBmRaTSQ8wSXaVuA1J RPO0PH9likWfOid1t1PJAc6fo7aVQky0JGfeltE= X-Google-Smtp-Source: AKy350ZO8VM12pPssOnBFcoQdCANLXO9TsZ8MLjMmnTuCFPyr2YBxW3tvKHQi2we5xxM8CI46miTyg== X-Received: by 2002:ac2:515b:0:b0:4e8:3b51:e7eb with SMTP id q27-20020ac2515b000000b004e83b51e7ebmr785866lfd.7.1679668164766; Fri, 24 Mar 2023 07:29:24 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:24 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:28:59 +0100 Message-Id: <20230324142908.64224-2-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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 Fri Mar 24 14:29:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18445 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 17A89C3260 for ; Fri, 24 Mar 2023 14:29:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9695C62718; Fri, 24 Mar 2023 15:29:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668168; 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=hl1xoDjdHc6KWyLWYSUrfRFlTUfdFBEivQfxaaN4N+7cu52S2JXjiFLnT6Cd8waZE NnQRYn5MREWDKI+gX7waQUOD1wDSpmndetixlPVWD68Fai1LEgp2wu7r+k2DwGqcqo KyAn61ju29EyQRqXzHhbhHU/UDMJiJSsLXiBSRz2Ah45fIM2+zBTkM4TDom4m7sEHr SNTaemz7DbpWSCpUAZI6Kr0l+mNuGlRp707Xt+aqWDPt+3x4OrTFoQxCGswXtnwOWU 1Hd7V3DyHtuCOg5UncG56lyYzu6AbXXGV8BpevKpmKbz8RNxxkR0lpB5LFOKbY3TSv uzTjtegUJ2Qdw== 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 E7E5A61ECF for ; Fri, 24 Mar 2023 15:29:25 +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="cgVGFXgy"; dkim-atps=neutral Received: by mail-lj1-x236.google.com with SMTP id f16so1896575ljq.10 for ; Fri, 24 Mar 2023 07:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668165; 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=cgVGFXgy1eGQ71qzy5NkubQESUttyiML1nkR9DwMpM6WPYF1Xjoi25+6ogQ/8N1Ujq 8fRqRDYwjCKBvZ/wXp2/nfLGWVhjRl5/rHT8erSegd/Wfg0XTM8dTb7Xx3B7oG5lJY6g 3UlQpjwQrzlaxSJhZJLwwKNAxWLKehx46VtJIccu1Kl101fBn/q37oF/kIRGZ1KzDgaO IzksOJp6mMcvShtRVCyOZdy2aZ8WLpuQDZ0Af5zW9mLgHoC6SAZNe3HNKgynBVVOD41T uoGupIQjN99gN6q1p+IJ34hNfxGSYGD/5ihkMFQSwshzrjsOdWKcIAyfoikRkCXJxtnu GyFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668165; 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=SUC5xuLMmmeyqXBqtumsee7lDCNH2d+wnUciuIQtYTYsfbRQNBnw+tMeeDMPv1X3yn xRL7xwoY8KDfWBW8LmUCti2DYBdsn82ttP0IsV2YS72MCwStFlF7ld3q3EtB0Ux8jtp2 G3Gcc1V+V/Buz0Pn1dUHWGddDE7GEU1MvivAKwi4Dhnaf48EwqvPADKM9ASzXOJmIWSq Hh3VRBdqtcqn7ywq9y1lufM/n1Sjd9vQKMwAwmJYjcmuLgEgB1zx2SQNAKuOmSBrQcpc SA7tqngth7mhWxhaJyTGFxf/Sav8G9ubqv8Blu0QCJWk1JcQZo/NwGR9LK9GKPdKg+Rl oE9A== X-Gm-Message-State: AAQBX9eoEU9omuxyZm6Vd5CHerosWH22C9lfsECPurOZkpHA6rwsG73e 0EcmBZ79niLKraSxs1xoYsiWhEZjtHfmDL2ZGjI= X-Google-Smtp-Source: AKy350bYQiA9mHFitxVRLanw8dmjb30gvJu1p94qjoKYdQ5KTNfyPVOzSivvSwT471uUE31th1ST1A== X-Received: by 2002:a2e:b046:0:b0:2a2:86de:667a with SMTP id d6-20020a2eb046000000b002a286de667amr932749ljl.40.1679668165285; Fri, 24 Mar 2023 07:29:25 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:00 +0100 Message-Id: <20230324142908.64224-3-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Jacopo Mondi --- 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 Fri Mar 24 14:29:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18446 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 11E83C0F2A for ; Fri, 24 Mar 2023 14:29:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E882B62710; Fri, 24 Mar 2023 15:29:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668171; bh=VvBr+2AA6dPAeiFBn7TRelJf2b2z8dbF/ClemE/ynww=; 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=ajYGHm/W4MiMHrLc6EQtOtFf1qqpQBsQxeln+KL9sfVzsn6Y+XdqtLgnrtGLUb3w3 uOxt/as7YPULvszN2ynYesutZspjN/YVyy2R5Fi7WA1/Vis+9koqmGpWnGO2tNKF28 AX0GmcLvpcYiIsO3rqSo4DOEvP4T2RPoXrkcmIbzvpb23oIYU8QeD0hnyA0+NmHgHw bjdVz1+/rzqBGEeRWbMP06i6+hr9uhfRZmkypJaJ1yA1jBk67JvrYr5kqXKp0Y1ulj qQdHz72Ai8VHcr5d/hL57kudMvYUp5OUPWzc+k9HAyxH7jINDtBELdpePl/OeTjA3m IW5cnhlAjRWvQ== Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F0E061ECF for ; Fri, 24 Mar 2023 15:29:26 +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="0wLdG1u1"; dkim-atps=neutral Received: by mail-lj1-x235.google.com with SMTP id a11so1912949lji.6 for ; Fri, 24 Mar 2023 07:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668166; 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=p3ktg7MZDXz8/FGb1gjNfXnLADZbV4jL8TI3FRHHtyk=; b=0wLdG1u1gTAQYhkQyOwaltTyFMF9MFpAJsDWLYIwHaxYGKTwaXLiLSOEsdq7MhEroD 4UJTUt6ybmqWJJsDkdXRzyKJ7+Kza2dYkgMkw7nnOa/54MMqkSWbk3r9ewrfle3s22er dIjAEqkauajShbb8cDQVnaDIbSLTwDHCBZ67O8ETzfL98tJgwmsopScwLWErcPRtIkNQ 39GGiparp7bMYA5bJVX+JGY7JJ9KGCxS3DjKUsTLTFaSjuFXnMUnHmQhgYQmt4ygzE5M s13at2d7twU1NBmHaBHEJf10F5dvUEVvp9+tKKRaije9WR4gIWTsy89vGChKh7yhRdDN F49Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668166; 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=p3ktg7MZDXz8/FGb1gjNfXnLADZbV4jL8TI3FRHHtyk=; b=E67cTqy9zeVAthTjcoyH9pmXtNlsoPPpQTxzwzoDs2XJeEqm63iPDdabEiP4KAJefw Du3/2cqoXNlzB5O2LdVyvj2HfTofepHYEMfcvMBbuF3NpIOe3qepo1jJThEUoahn6pWa kHwoGXsSvqHBAH6JGvAIrpdLaAGzj2L/2wXNVN2x9HcQqa4FAThDNSNeR4fK0yQZq98W p2JKjwCtriRP0W8kdNTPPblkH7o5STj0JkAuL8ECbRUQPtGng8kwbla6E8QKS+Xxxiuh f2pzNXI9qx8ce3CsDmhz3bIOCHgS1EcfsrDXj6P2FKJq0R5iCALqi7c7FUYKtO+hy//S cPiA== X-Gm-Message-State: AAQBX9cDQ+vpVMktc+yw0MdGk0C4dOyrEdz8/SYd0encFRSyoSMBCpip Y0879a7wRl17BZ09TC8TRE/Lc1xn2vUvsl5TadY= X-Google-Smtp-Source: AKy350YHxv2Uc5CxDB65tD42VSneyoi48539GgdeEoo1yKbdJlZqQrgnCTU1D7xDGNsmWvvsovjF2Q== X-Received: by 2002:a2e:988c:0:b0:298:9fb6:77a with SMTP id b12-20020a2e988c000000b002989fb6077amr940020ljj.32.1679668165802; Fri, 24 Mar 2023 07:29:25 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:01 +0100 Message-Id: <20230324142908.64224-4-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 pure virtual methods that should be implemented by the Auto Focus algorithm implementations. 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 | 159 ++++++++++++++++++++++++++ src/ipa/libipa/algorithms/af.h | 45 ++++++++ src/ipa/libipa/algorithms/meson.build | 9 ++ src/ipa/libipa/meson.build | 6 + 4 files changed, 219 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..0808aa3f --- /dev/null +++ b/src/ipa/libipa/algorithms/af.cpp @@ -0,0 +1,159 @@ +/* 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 { + +namespace ipa::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() + * \brief Set auto focus mode + * \param[in] mode AF mode + * + * \sa libcamera::controls::AfMode + */ + +/** + * \fn Af::setRange() + * \brief Set the range of focus distances that is scanned + * \param[in] range AF range + * + * \sa libcamera::controls::AfRange + */ + +/** + * \fn Af::setSpeed() + * \brief Set how fast algorithm should move the lens + * \param[in] speed Lens move speed + * +* \sa libcamera::controls::AfSpeed + */ + +/** + * \fn Af::setMeteringMode() + * \brief Set AF metering mode + * \param[in] metering AF metering mode + * + * \sa libcamera::controls::AfMetering + */ + +/** + * \fn Af::setWindows() + * \brief Set AF windows + * \param[in] windows AF windows + * + * \sa libcamera::controls::AfWindows + */ + +/** + * \fn Af::setTrigger() + * \brief Starts or cancels the autofocus scan + * \param[in] trigger Trigger mode + * + * \sa libcamera::controls::AfTrigger + */ + +/** + * \fn Af::setPause() + * \brief Pause the autofocus while in AfModeContinuous mode + * \param[in] pause Pause mode + * + * \sa libcamera::controls::AfPause + */ + +/** + * \fn Af::setLensPosition() + * \brief Set the lens position while in AfModeManual + * \param[in] lensPosition Lens position + * + * \sa libcamera::controls::LensPosition + */ + +/** + * \fn Af::state() + * \brief Get the current state of the AF algorithm + * \return AF state + * + * \sa libcamera::controls::AfState + */ + +/** + * \fn Af::pauseState() + * \brief Get the current pause state of the AF algorithm + * \return AF pause state + * + * \sa libcamera::controls::AfPauseState + */ + +} /* namespace ipa::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/algorithms/af.h b/src/ipa/libipa/algorithms/af.h new file mode 100644 index 00000000..4fd16ac2 --- /dev/null +++ b/src/ipa/libipa/algorithms/af.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Theobroma Systems + * + * af.h - Autofocus control algorithm interface + */ +#pragma once + +#include + +namespace libcamera { + +namespace ipa::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 ipa::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/algorithms/meson.build b/src/ipa/libipa/algorithms/meson.build new file mode 100644 index 00000000..3df4798f --- /dev/null +++ b/src/ipa/libipa/algorithms/meson.build @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: CC0-1.0 + +libipa_algorithms_headers = files([ + 'af.h', +]) + +libipa_algorithms_sources = files([ + 'af.cpp', +]) diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build index 016b8e0e..134c2dba 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 += libipa_algorithms_headers + libipa_sources = files([ 'algorithm.cpp', 'camera_sensor_helper.cpp', @@ -16,6 +20,8 @@ libipa_sources = files([ 'module.cpp', ]) +libipa_sources += libipa_algorithms_sources + libipa_includes = include_directories('..') libipa = static_library('ipa', [libipa_sources, libipa_headers], From patchwork Fri Mar 24 14:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18447 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 500F3C329C for ; Fri, 24 Mar 2023 14:29:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E58736273D; Fri, 24 Mar 2023 15:29:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668174; bh=71gherLPKH0KVRevos7fn6CtT5f5q1Lq0vDofBzbnSs=; 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=dIQx955IRStyrIA3fp1kdV91iNaRUw/ekdPNaBC2S0KTbe4Q/3wCajDFz5cIK60DU yrd6LxcMm/Oi5CbnSH7fswyKyWCq+v3AZR4HecWYfVbRoTpxn7hICAvJX9DR6IvTUz 4mKlpgnvAfXcD/fipZ9oVZLs2rXM5ZOlpNq2TBJ8p2J2yJRO6kcCdsxKluOHhmaBcl OLzXXbvfl5Aw+BUDCkqeNl85n//B0OCWZvctL400mWE1/E+wgedadgaOhLX+juBLbP e2r5YUtHWYHwIZuAEogTCX8TUsfX1KSbNjOmGKpFhRX1iMBhd0cTHuRoFlw6ygGRsq 8WFGgkM8nSZCQ== Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2733A62715 for ; Fri, 24 Mar 2023 15:29:27 +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="UPOVy/zS"; dkim-atps=neutral Received: by mail-lf1-x12b.google.com with SMTP id y20so2497437lfj.2 for ; Fri, 24 Mar 2023 07:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668166; 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=aAPkIGXrDpXgztSRfv8F1aKgcAkKp15YtqP6MCql3D8=; b=UPOVy/zScj27iG6qExLy0bMfsvMoEIa/i2WfcSYYh40Srl9ahuMruHHdZ3KYfWB51g d408uincP0JrEjW9MbnpGqPRxgs4SH/gGISqHBzHq32Cemda9CfmH5xKg705q7kjibbM oxCobMApswA5mRjTNZOUPBeTqB8lrf0omidrrYmfrM0EscgzFCrqQ0GXtpaislnWzX+m C8yoZ0hMOG4ueafBNOCw2OJ5w/bXnmyoUmJvg9ziAghyCuxDZpuLIEO2G82Q2Pxi83SU jxmjP3n9YmdLFeXNEj0HtA6Esdf3NB9jb5rYjCQi5Ng4eSlTvpiASCm0aJnvB3UVpyMs YSkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668166; 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=aAPkIGXrDpXgztSRfv8F1aKgcAkKp15YtqP6MCql3D8=; b=EZZPl8IREVgty4dWV+VU22NopTYJRlsp/MHFC9Te613PgsIvuXpdQyp32SDXuoj/58 yFGzDcTBy+9y0UH98iO7sqoXLtCzAx/NIZB4mKgQvI0mJbgv3jzO4VqRHIQaT4VReLnr j3ICXfTCvIxm8mxNatIgD5tSRQkP3TiiZQxH8aMOInTJoIFPXZ20/dkyR+3HiuaoFPiz P+YkXsbTbbP7YAM7T4fudLLaFrJtwtuEtelItz7KhZRNUep1aEvL9Mkl2oSQxXNxiPi1 H8Spp6dYxpMyLTyGWyK/Uh73vQvHr7SyiyciTX1sV9bynOymMEUJbkBhribD0f6iiOzm c7MQ== X-Gm-Message-State: AAQBX9dzTtcr1bwWqQM/5vzRLUjXVUUOp7rrofU57HOElQS4Ej7Q4xFv 1AJpQqf7V12ykCu7Vg8tCCPYLqR3A30o7s2THWw= X-Google-Smtp-Source: AKy350b0Nc8GFl/2hLxzUKFPMlhu0/zAefTQPyw9K5IpOpIRGXQIyJ9k17uxfxjcx4FETCRl1njmng== X-Received: by 2002:ac2:442a:0:b0:4ea:e68c:91bc with SMTP id w10-20020ac2442a000000b004eae68c91bcmr820049lfl.18.1679668166323; Fri, 24 Mar 2023 07:29:26 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:26 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:02 +0100 Message-Id: <20230324142908.64224-5-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 | 379 ++++++++++++++++++ src/ipa/libipa/algorithms/af_hill_climbing.h | 91 +++++ src/ipa/libipa/algorithms/meson.build | 2 + 3 files changed, 472 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..6ee090eb --- /dev/null +++ b/src/ipa/libipa/algorithms/af_hill_climbing.cpp @@ -0,0 +1,379 @@ +/* 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 { + +namespace ipa::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 + * based on the contrast measure supplied by the platform-specific + * implementation. This way it is independent from the platform. + * + * Platform layer that use this algorithm should call process() function + * for each each frame 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, the lens is moved with bigger steps to quickly find + * a rough position for the best focus. Then, based on the outcome of coarse + * search, the second phase is executed. Lens is 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 lens position will change + * in one step in the *coarse search* phase. Unit is lens specific. + * - **fine-search-step:** The value by which the lens position will change + * in one step in the *fine search* phase. Unit is lens specific. + * - **fine-search-range:** Search range in the *fine search* phase, expressed + * as a percentage of the coarse search result. Valid values are + * in the [0, 100] interval. Value 5 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. + * . + * + * \todo Search range in the *fine search* phase should depend on the lens + * movement range rather than coarse search result. + * \todo Implement setRange. + * \todo Implement setSpeed. + * \todo Implement setMeteringMode. + * \todo Implement setWindows. + * \todo Implement the AfPauseDeferred mode. + */ + +/** + * \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(5); + fineRange_ /= 100; + 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 frame. + * + * Contrast value supplied in the \p currentContrast parameter can be platform + * specific. The only requirement is the contrast value must increase with + * the increasing image focus. Contrast value must be highest when image is in + * focus. + * + * \return New lens position calculated by the 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: + processContinuousMode(); + break; + } + + return lensPosition_; +} + +void AfHillClimbing::processAutoMode() +{ + if (state_ == controls::AfStateScanning) { + afCoarseScan(); + afFineScan(); + } +} + +void AfHillClimbing::processContinuousMode() +{ + /* 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; + } + + /* + * AF scan can be started at any moment in AfModeContinuous, + * except when the state is already AfStateScanning. + */ + if (afIsOutOfFocus()) + afReset(); +} + +/** + * \brief Request AF to skip n frames + * \param[in] n Number of frames to be skipped + * + * For the requested number of frames, the AF calculation will be skipped + * and lens position will not change. The platform layer still needs to + * call process() function for each frame during this time. + * This function can be used by the platform layer if the hardware needs more + * time for some operations. + * + * The number of the requested frames (\p n) will be applied only if \p n has + * higher value than the number of frames already requested to be skipped. + * For example, if *setFramesToSkip(5)* was already called for the current + * frame, then calling *setFramesToSkip(3)* will not override the previous + * request and 5 frames will be skipped. + */ +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 valid 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 valid in mode " << mode_; + return; + } + + switch (pause) { + case controls::AfPauseImmediate: + pauseState_ = controls::AfPauseStatePaused; + break; + case controls::AfPauseDeferred: + LOG(Af, Warning) << "AfPauseDeferred is not supported!"; + break; + case controls::AfPauseResume: + pauseState_ = controls::AfPauseStateRunning; + break; + } +} + +void AfHillClimbing::setLensPosition(float lensPosition) +{ + if (mode_ != controls::AfModeManual) { + LOG(Af, Warning) + << __FUNCTION__ << " not valid in mode " << mode_; + return; + } + + lensPosition_ = static_cast(lensPosition); + + LOG(Af, Debug) << "Requesting lens position " << lensPosition_; +} + +void AfHillClimbing::afCoarseScan() +{ + if (coarseCompleted_) + return; + + if (afScan(coarseSearchStep_)) { + coarseCompleted_ = true; + maxContrast_ = 0; + const auto diff = static_cast( + std::abs(lensPosition_) * fineRange_); + lensPosition_ = std::max(lensPosition_ - diff, minLensPosition_); + maxStep_ = std::min(lensPosition_ + diff, maxLensPosition_); + } +} + +void AfHillClimbing::afFineScan() +{ + if (!coarseCompleted_) + return; + + if (afScan(fineSearchStep_)) { + LOG(Af, Debug) << "AF found the best focus position!"; + state_ = controls::AfStateFocused; + } +} + +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_ += static_cast(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; + } + } + + 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; + coarseCompleted_ = false; + maxContrast_ = 0.0; + setFramesToSkip(1); +} + +bool AfHillClimbing::afIsOutOfFocus() const +{ + const double 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_; + return var_ratio > maxChange_; +} + +bool AfHillClimbing::shouldSkipFrame() +{ + if (framesToSkip_ > 0) { + framesToSkip_--; + return true; + } + + return false; +} + +} /* namespace ipa::algorithms */ + +} /* namespace libcamera */ 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..47d2bbec --- /dev/null +++ b/src/ipa/libipa/algorithms/af_hill_climbing.h @@ -0,0 +1,91 @@ +/* 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::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 processContinuousMode(); + void afCoarseScan(); + void afFineScan(); + bool afScan(uint32_t steps); + void afReset(); + [[nodiscard]] bool afIsOutOfFocus() const; + bool shouldSkipFrame(); + + controls::AfModeEnum mode_ = controls::AfModeManual; + controls::AfStateEnum state_ = controls::AfStateIdle; + controls::AfPauseStateEnum pauseState_ = controls::AfPauseStateRunning; + + /* Current focus lens position. */ + int32_t lensPosition_ = 0; + /* Local optimum focus lens position during scanning. */ + int32_t bestPosition_ = 0; + + /* Current AF statistic contrast. */ + double currentContrast_ = 0; + /* It is used to determine the derivative during scanning */ + 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; + + uint32_t framesToSkip_ = 0; + + /* Position limits of the focus lens. */ + int32_t minLensPosition_; + int32_t maxLensPosition_; + + /* Minimum position 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::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/libipa/algorithms/meson.build b/src/ipa/libipa/algorithms/meson.build index 3df4798f..20e437fc 100644 --- a/src/ipa/libipa/algorithms/meson.build +++ b/src/ipa/libipa/algorithms/meson.build @@ -2,8 +2,10 @@ libipa_algorithms_headers = files([ 'af.h', + 'af_hill_climbing.h', ]) libipa_algorithms_sources = files([ 'af.cpp', + 'af_hill_climbing.cpp', ]) From patchwork Fri Mar 24 14:29:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18448 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 BB0A9C329D for ; Fri, 24 Mar 2023 14:29:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 31B5062726; Fri, 24 Mar 2023 15:29:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668175; bh=FODGdPtQZZhgvjqOGU8oExhjvYtsMWjVyG+lNSK7Frw=; 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=oaiAphdeaAjvyR74lVHlx7wSN5427GdNS7Ms57sq3n7NC3MAXSdn4dSNBnDT2QUvP MqZBN0id2P78meW4HMVM9OyoMUZ7HnkPN0eguSpsBR0wU/6sJotOXg4wYMKQRU7L4F ExN24RrfWCr25JYAL6gIpKHz20dgt3GjQn35AgxV6rijPkW3jYRtOu3TD85xwqiVCn LUSVLHpHMjEVHu0DmvPIhvXS5iG/RaEBUInm7IAa5DB1s6iTHBNJE6BAZRjPUKyLAz Szrt1vkAHZjk8G2gEOUiDtqPbhNwYeeXiQlawNWzgHuWPrx3us3YQJR/OgZIBr9sCE r2vGUmlgVcR/A== 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 87EB662717 for ; Fri, 24 Mar 2023 15:29:27 +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="Zexbqc7T"; dkim-atps=neutral Received: by mail-lj1-x22c.google.com with SMTP id g18so1918554ljl.3 for ; Fri, 24 Mar 2023 07:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668167; 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=7EsqPwgI0oXnlJ+z0E4iqsZzdQVGBOc459CaOA0zDf4=; b=Zexbqc7TM6Bg4nj9ugXqxAkFuuZa3IOWo1BAiBUOa4SEoG8cZ2ntUkr2gsjmRBJM3z bDGjpCAd62BBQStHst4JCAKR/OCGBeglqloNqTWlvbIiwfDq2h55Ccfrx9XrMz+ehY1R sxobdUGdZO0tg7thVEKbjGwhtZ0GPfxTbWKHW25Jk/1rIPd1CQBds2r/MpDP7rY8t3xs 7VagMc7ew6Eai1O11reB4OleN/YEbYoOZf3p+YLpqqAnI5M+OZGh/CTd+bpnk/pzKDfv h4xcyEMa5nz/PpbB1drAQfCL4Ca2cCnblXxtWX43dHdr/JussGD6cgz55u8BOLu0ZNtv ZFiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668167; 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=7EsqPwgI0oXnlJ+z0E4iqsZzdQVGBOc459CaOA0zDf4=; b=Y7wF5cMWFufK0tbtuT3GwW+KJfW5owcsN09iS8G3OwU6ltBAf6nFwj6Ed1Nvq4pwAM u1riUPA2Zy8HnTsaFOjwKdwUUZBalcYzm6lKvZdgeMlHeLTSRCdUUXVeNa6VBnE78wMM CHjy1Wc/MTbnKdKupwoplGddoBzErWtEy0WNkjJihsFogC5Rgfg845Wtg0a3M7c1IL52 jWQtPbh/Ztwgx3Ei5NEWaqFa232yqUzct+0EPEQA+ElrWrz0RUfEKbkEKFTiuJoLIt7l zIJo1oLSY85tGqW9FDPdQsVtmJTXxUxl+xlXmVQqH/FBOCtzQ+Apgu4aLMPYIjpSDuJ8 I5+w== X-Gm-Message-State: AAQBX9eZqN9qUFHkwjWTdx15ysfXmfpcQU/EsNBFd8NRK9DcB1g7NZA4 PHdXtL/awDKUQDOWywwyBRtiOwn/7UXRcwHv5Sw= X-Google-Smtp-Source: AKy350ZkYs4cwLki5ju7CEaCrAoJPCSV0feza1p4BBF1ZExiO/F8IohswAqvqPfRi1rNSvLYWyv5nQ== X-Received: by 2002:a2e:b016:0:b0:29b:4f87:c7cf with SMTP id y22-20020a2eb016000000b0029b4f87c7cfmr937292ljk.26.1679668166860; Fri, 24 Mar 2023 07:29:26 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:26 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:03 +0100 Message-Id: <20230324142908.64224-6-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 | 53 ++++++++++++++++--- src/ipa/libipa/algorithms/af_hill_climbing.h | 12 ++++- 2 files changed, 57 insertions(+), 8 deletions(-) diff --git a/src/ipa/libipa/algorithms/af_hill_climbing.cpp b/src/ipa/libipa/algorithms/af_hill_climbing.cpp index 6ee090eb..636a8674 100644 --- a/src/ipa/libipa/algorithms/af_hill_climbing.cpp +++ b/src/ipa/libipa/algorithms/af_hill_climbing.cpp @@ -63,9 +63,8 @@ LOG_DEFINE_CATEGORY(Af) * movement range rather than coarse search result. * \todo Implement setRange. * \todo Implement setSpeed. - * \todo Implement setMeteringMode. - * \todo Implement setWindows. * \todo Implement the AfPauseDeferred mode. + * \todo Implement support for multiple AF windows. */ /** @@ -97,15 +96,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(static_cast(outputSize.width / 8), + static_cast(outputSize.height / 8), + 3 * outputSize.width / 4, + 3 * outputSize.height / 4); + + windowUpdateRequested.emit(defaultWindow_); } /** @@ -194,6 +206,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_) @@ -219,14 +239,33 @@ 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; + } + + 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 47d2bbec..dee91f23 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; /* Current focus lens position. */ int32_t lensPosition_ = 0; @@ -84,6 +89,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::algorithms */ From patchwork Fri Mar 24 14:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18449 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 A7F49C329E for ; Fri, 24 Mar 2023 14:29:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 020E762717; Fri, 24 Mar 2023 15:29:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668176; bh=lWQp7FDFUsf+brUcDAs21WmvGm8oBGyyT7hhIY12fkc=; 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=qq4pWW0NhR3d4mVq3KPK6Fj1/T1LBxeBv/gMJ+y5L0ZTmMvXbH2gW326XbZn7X/Il 1oak6MEjdlpGAu5Y3PI8/czt39Vk3ufpkfgiGHdyL41sHWbnmfBMdGcocZpWzhckDp DhyG2V7w9xrPCQYlYozyEmlreRmhqkTSJ86PA7p5C4kpzVzL4HPAZmqpQaFlBRLMns ZUWCbbIlhrh8z94Kenl5P03ga5JrcLhXuXbwk3T/Klhi4sJlc9M4uRjkRbfqDT6MtS S3crarkIaZFWP2Oo/76zrxHWz2MxGjlgioGAXYPmuOGhuoBNRAwIBTz448voU6RNDf Oj5dMwzkC5qjg== 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 460A36270F for ; Fri, 24 Mar 2023 15:29:28 +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="q2AMk/Pi"; dkim-atps=neutral Received: by mail-lj1-x230.google.com with SMTP id t14so1917993ljd.5 for ; Fri, 24 Mar 2023 07:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668167; 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=jYWPwpLuVPnMkUQZsWBwirOzn6cygNfvhONXpwEd+Tk=; b=q2AMk/PiBhmlS702p6xLBs+qohqhwWcVsdPBn+tR3YVQGVrdD5Myl72fnmmdc9/71I AHN6oKaODa+l6zfQj6jh8EeCMWzbpnslYxivBcxbe/ARUqkbkOUJNX9cJsRgtBkWHcxG ANfZif8GOhaIP+tVCDIUhcov1Zsrtd28mAWm3LQyKaECI5vbpt2BL3450TMZBmniQhh7 fYrAaqMBL9MJUu0XeP24yBG/Q3E5pPTGMECQLfiOfrVV9ixbFZDi0+i0UU3Vs1MNUCI/ Z7CqIwAsnQA0P9IDyQSzqjNnCDbNk5+pPgaU0ymqkzbeUgKehLiL8IxOO86jNMNAwNVO xw6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668167; 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=jYWPwpLuVPnMkUQZsWBwirOzn6cygNfvhONXpwEd+Tk=; b=cZ6jgDRCOZIV35yPmdrJHhIRbUaCiO5r5vMpsfhvywJwVuC+NG1fiYyUxaF9pq4s8U geqYw6UyjuupO9WlqTdG0hTWEpRKR7LQZnejdubeQzAVOgR3rNW/6sbANC+zxoxzJ3MT KIhszX6TIhkcMxVT9ca3fH8Uvl1dpbwOnEHysd3/Y5/E5+eQZYFivSoTJNrwm7BsrfHk OfCknWrOmxpAi57B/bJZG2WA1DiZ/s1LlGe8bPHNxWx1v17rZPu5VpdpK7VlK6UvXT6+ FJmi2Ehjj1+6CnokL7ppHIrFGpqxvbMEKMGjxkM4AI198fa9xeC1Yt5t04MbyQru5YjQ P1sw== X-Gm-Message-State: AAQBX9f+nT0/RTMfzRs/H5rylD7KQCkjggdoPDUNKcTSb69LCHFY1OCQ xI63kxE/Y9RvsjbGy9E+8pFG4SFXJfVNEgv4H5A= X-Google-Smtp-Source: AKy350a4gFQN4gDFxZhZPNkEPdHmS3tjxp6wMlLA/feCkrPaGp+uKyA2Pi/Ewo/1SN+r2pMUZ4/MUg== X-Received: by 2002:a2e:97c1:0:b0:29e:e7ad:c8e1 with SMTP id m1-20020a2e97c1000000b0029ee7adc8e1mr1026041ljj.28.1679668167380; Fri, 24 Mar 2023 07:29:27 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:04 +0100 Message-Id: <20230324142908.64224-7-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 06/10] ipa: rkisp1: Add AF algorithm based 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 Reviewed-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/af.cpp | 117 ++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/af.h | 43 ++++++++++ src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/ipa_context.cpp | 13 +++ src/ipa/rkisp1/ipa_context.h | 5 ++ 5 files changed, 179 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..aca127d2 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -0,0 +1,117 @@ +/* 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 { + +namespace ipa::rkisp1::algorithms { + +/** + * \class Af + * \brief AF contrast based hill climbing control algorithm for RkISP platforms + * + * Auto focus algorithm for RkISP platforms, based on the common hill climbing + * auto focus implementation + * (libcamera::ipa::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. + * . + * \sa libcamera::ipa::algorithms::AfHillClimbing for additional tuning + * parameters. + * + * \todo Model the lens delay as number of frames required for the lens position + * to stabilize in the CameraLens class. + */ + +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 ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h new file mode 100644 index 00000000..3ba66d38 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/af.h @@ -0,0 +1,43 @@ +/* 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 { + +namespace 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, uint32_t frame, + IPAFrameContext &frameContext, + const ControlList &controls) override; + void process(IPAContext &context, uint32_t frame, + IPAFrameContext &frameContext, + const rkisp1_stat_buffer *stats, + ControlList &metadata) override; + +private: + ipa::algorithms::AfHillClimbing af; + + /* Wait number of frames after changing lens position */ + uint32_t waitFramesLens_ = 0; +}; + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ 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 Fri Mar 24 14:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18450 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 2ED08C3260 for ; Fri, 24 Mar 2023 14:29:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 95A4862712; Fri, 24 Mar 2023 15:29:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668176; bh=ItCp53EbrXJqVrpIw8CXw09ZfGPOxLlLBQIa6SktU/4=; 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=2meKGVau7itneF2Qt9Q1KJ3IyioiJOgfBpIjWuWuR9ZDBU263QnIVQEv49LGku+jW 1pkfc6O7Gec8vDBJ9nen6de1JERlvJnyu6xHc7WjRtTty7tacK+84OAjKAxL5DHoSg FLZxN9qWu3qWOJzsX3dyanh3ohE4iozJiEsiVwCpvT1BA8GTxevdaR63fULd/D/s/M 2JJPQR/TBJVgn87/t4hdKJWc6ErV9vywt3uzpYWomwDBpIlvW0hS1m8x0Dug2KSLs6 dt5O4ol/S6eoEadbfX5I21tPDyUNFL3fU/sVz5BytivCBrV3JUbby55SeGho4ioVGm nM5kKTci4yovA== 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 8E7B6626E5 for ; Fri, 24 Mar 2023 15:29:28 +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="4ZNCZXI8"; dkim-atps=neutral Received: by mail-lj1-x236.google.com with SMTP id by8so1891267ljb.12 for ; Fri, 24 Mar 2023 07:29:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668168; 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=RW3UZh1I69vi3Jxsfk5UYduKKMBKc8FCToCkGLOtrdE=; b=4ZNCZXI8cRixZzs+EI5cKK25f9ReTVMBYHCmMy1o3zU42Jxy6HgD45FMrglJGQ0S1O foeRmP16OhglVj+iM7lWGL3ZxSVt7uiShs1LxwIayRhrpshAelL3yEUOu2fB9Lr76bIR 9JYL9gMpMUZskpvUsRXTkBcLFJTAm94BFcgGFrbq75tfNUeJVJ2HQr/YbcKXEbRUdAIn D7N66ic68hwPKrahUhhwcFGwM/YVGEwgQV5cK9Af3dNHh4/+FohgVWWqPc//A0vWYSBC p2fVr0kcahZmUSpqH+7HUVewVkkQDxxTt6jYe2q1qECFufW7FiK1MD9VdsYPzARFUqS4 eeUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668168; 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=RW3UZh1I69vi3Jxsfk5UYduKKMBKc8FCToCkGLOtrdE=; b=BUT5QVhK2gKeLs6qDGlHRwMCUBUqbFCQA55UqeqdAd5tJbXYaEKEL5ddB8EOcI6wI4 o1GSSzgBOMMIRhxB9QXttsLB9BB7Q9B/VJn/+9AfNFz+TTAXJW7ubi1cEvaRR+IzqTaN pr5MXte+DZaIFzyfWZ+ygpE8ZNhQIKcaxTeWHaAbUdRGpE3DwrzREwW4OikpMYFb4Eja Ey0rPYEiK0QRjGEBWNFx+wX71QhU8sUoDMeJkLOkn8FYZ0egzc0uFvwHYqKftpllQQoS 2ZPgGNGnRvmPKET/hb0+JO0D8rglnKh6EcIQ+HLhOl724n8YCplo70FuyIuji/4PdyOy hH4w== X-Gm-Message-State: AAQBX9e7I+Q8L01LCGf6tqZ07K+pBfGoSaL7jAvEa05RCzOlUkzSvvmq CoX69d57eRj+aKM0Hhpz3MwF8NnCIHvrpQn0LBY= X-Google-Smtp-Source: AKy350bvbsC2Zc5XP0ne4qsfM49DtDGCvCdoxoPOiYuI79KoZOdXnxljhbb2lBEvz9Cb4QUn7wucCQ== X-Received: by 2002:a2e:988b:0:b0:295:a2d0:57ed with SMTP id b11-20020a2e988b000000b00295a2d057edmr1168320ljj.4.1679668167897; Fri, 24 Mar 2023 07:29:27 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:27 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:05 +0100 Message-Id: <20230324142908.64224-8-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 | 64 +++++++++++++++++++++++++++++++- src/ipa/rkisp1/algorithms/af.h | 13 ++++++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/af.cpp b/src/ipa/rkisp1/algorithms/af.cpp index aca127d2..9f7ba72e 100644 --- a/src/ipa/rkisp1/algorithms/af.cpp +++ b/src/ipa/rkisp1/algorithms/af.cpp @@ -33,24 +33,55 @@ namespace 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::algorithms::AfHillClimbing for additional tuning * parameters. * * \todo Model the lens delay as number of frames required for the lens position * to stabilize in the CameraLens class. + * \todo Check if requested window size is valid. RkISP supports AF window size + * few pixels smaller than sensor output size. + * \todo Implement support for all available AF windows. RkISP supports up to 3 + * AF windows. */ 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); } @@ -85,6 +116,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 */ @@ -110,6 +167,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 ipa::rkisp1::algorithms */ diff --git a/src/ipa/rkisp1/algorithms/af.h b/src/ipa/rkisp1/algorithms/af.h index 3ba66d38..6f5adb19 100644 --- a/src/ipa/rkisp1/algorithms/af.h +++ b/src/ipa/rkisp1/algorithms/af.h @@ -20,21 +20,32 @@ namespace 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, uint32_t frame, IPAFrameContext &frameContext, const ControlList &controls) override; + void prepare(IPAContext &context, uint32_t frame, + IPAFrameContext &frameContext, + rkisp1_params_cfg *params) override; void process(IPAContext &context, uint32_t frame, IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats, ControlList &metadata) override; private: + void updateCurrentWindow(const Rectangle &window); + ipa::algorithms::AfHillClimbing af; - /* Wait number of frames after changing lens position */ + std::optional updateWindow_; + uint32_t ispThreshold_ = 0; + uint32_t ispVarShift_ = 0; + + /* Wait number of frames after changing lens position. */ uint32_t waitFramesLens_ = 0; }; From patchwork Fri Mar 24 14:29:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18451 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 56C4BC329F for ; Fri, 24 Mar 2023 14:29:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D1FCC6272A; Fri, 24 Mar 2023 15:29:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668178; 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=oMYRwhlCeOWcTiPRvoXgLup9/0V7JyCPVXK+9IKEwkE+CE/48RCsUxyNL6wiYdSQm lUOqZDZ4RwOt7j1UBmNdS1qV7zm27781SgodriNc9kDhWI+hiotNlRVngW/q/pVBhw Hg6tOavVnMxeAxAE1S8gUb1+BvAWDFs0wjlDMjI29dPOHiiWFT6YWu9kOOu2IOpvnM dK8tosupouOF05LegEyIdAp6nmPT1Vjzil1dEvPuu6RbDl2TUxpQXbvA9R8h0ebuon JF5iCj+9MLmvNfUM/q9n3A8oQE4zM8A54BuKEvhkGwWjW6nKuUnSwAXu6bfTohPwQK hWxK7xQfHdmng== Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 490996271B for ; Fri, 24 Mar 2023 15:29:29 +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="Z1xMZxJv"; dkim-atps=neutral Received: by mail-lj1-x232.google.com with SMTP id z42so1889661ljq.13 for ; Fri, 24 Mar 2023 07:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668168; 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=Z1xMZxJvBCHqUBKHJIZeSA5iRdi8dBv62IN+wQuyQf6ci0StDuc/A7Wfmkt58XeJIp dP6rPN1R+YieHFbwXFE5O3htba7jiXhWrfl0+EBaNefzw/fY2dLNEJ/UnxDGNlznWT32 6UtbwcaTmxqQBPp/sUf+fDO+zjr6uZZVO6ehxPG2uA3tTZhxuBPjuWuuQmwX04qxJ0GY fstXq2mp8yqFnHVlP6j9XzL5ICagqGbtLgp2pkQOb6RM/OtI1JWg2wgtToCH4MGdfUoU WD5aIKdRxl8bMPifhz4bFm3ruG7+/J43Qb4usHwc6/Sgx2wNmqGS2F2WlhS/+kStsxnU p4Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668168; 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=2lGqogAEJBDg1FCofPzXzPq0Ngk+Ny+cJDOm+toYmRk82dhEfotMSSm7yY0VNv4Ihr d3uzGE7XccAwE3KcQetilUQPqSedLGpUhKd9PNKKKoM9ZVCpHNMQ8gw9SVaKXBFml0K8 s3jO6N5EboOAKE3/LJ3e4uiSgwFQTHxjTU0jWTcs79duuj7DlNWyQaNFHpvQdqGy63fo swHIYnnfmLrJcDaFgFjPq1Ec5tDuad+qtZN+9mHRzweN2OVsf2vhDE7EnmWd81hQVqMu BTeUOJqivpKFjh+OD2d+MjFvSd4+XL0anBTduWvocvke54mF4noBYzIP4gIMY9L7jljw CI8g== X-Gm-Message-State: AAQBX9e11PYsL/6XbL7a0eGK+jJZ3KihuF9MbavXIpVei8Isu/kKdAEO zQgJxQSfXwvdsKa1gu02aGYFngceeDIl18nAnF4= X-Google-Smtp-Source: AKy350ZAqpO2Xy9dJ71gg5O7EWBnCA6mrrwWGYu+V994vUpCsE3cAUGQ/4JJ49sNOOcQIUeu/8unvQ== X-Received: by 2002:a2e:a0c2:0:b0:29d:ce75:5d06 with SMTP id f2-20020a2ea0c2000000b0029dce755d06mr821459ljm.32.1679668168425; Fri, 24 Mar 2023 07:29:28 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:28 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:06 +0100 Message-Id: <20230324142908.64224-9-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Jacopo Mondi --- 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 Fri Mar 24 14:29:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18452 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 06385C32A0 for ; Fri, 24 Mar 2023 14:29:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9563162750; Fri, 24 Mar 2023 15:29:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668178; bh=ep3Vg6jIAMY8T9rW1GuAOePig6yWoEtEUB3rcWDKES0=; 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=BQw+gCbwBzRFc8JU3nkHhe2jTyZR5BtzJhaUBSGAxIq/gx/GcsSzCNYZybqs9YRJM 3mRKZpxmROT3hltOPkfubmWL2DIsOtNQMCxVIE1g7m0zqHLIlsP/500eUhoBenkvLX qB69XipdsvKNkhPdJdIzls5Cvp82cP9SSBibfZRIuMenx7bZiX4s/nNL12aGAED0Fo HkgKiMRU2dGLiqjTzIr9kO2i3DlJ78BRvr0VCESZYVkvRYjmS+Fm5LkFo/SX7bkQzf VS9yV19TgBv3sEKwwEDrcgPZRVotelEQtNwifLBRWQ9fwDGOUYdnuNQC58VAorMhlN FANOPeA1WQ+/Q== Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A41F36270E for ; Fri, 24 Mar 2023 15:29:29 +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="tj91w3S6"; dkim-atps=neutral Received: by mail-lj1-x231.google.com with SMTP id q14so1895965ljm.11 for ; Fri, 24 Mar 2023 07:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668169; 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=pCKH6OcTTdDeYB8O+3cUHp8U7UiJ/Ef5VKZA4e1pH+Y=; b=tj91w3S6LTlldMfy41yvl7qEFVmSvmqNu9s4gkheCqVQ8aZRGTDlKfkZd3NOtUQiqZ NRHz+T7Vqp5jjakAaeXnGclHMxjBMT5+An5hGo+wMm4wiiYsfDIR16WJprA00PM+gus7 l+dMbj5W9ODUDa4J4q3lJB0bgocuiplEir8xGDbBpEljVvoHxyTRCKnXZtaTs0Wxn10i Bzwe+nSmxOF+HuwxGTWBQfJMpY4GVG+2CMTSyLSB+exYgPouc+8h8gOIVjY3a1KJvmKS WiidWRQcxCK0e6eNjdCVb18CoRByJxzEcvXcJwWAT5kQcLrPYP3p0tm+9HJ308N0AMlX rdYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668169; 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=pCKH6OcTTdDeYB8O+3cUHp8U7UiJ/Ef5VKZA4e1pH+Y=; b=0yDd3vLs5KF8+80ODEIRviKyZ2/Y9KnMbET0KTxyryptOlF1joU9pKbKJmLhCWg4sM xvN4MnQeT57JOT2bvsVAswjF+hidHz0Bb43XUOJcuWx4XfyQ+VrOiZo8QImERJDrP+ii +0SZbrDBEKqxpPKGsnhdvF3qHZltHArfXuMtKSakKw5qdj7OPKciNwNP1mqy9NJcIbzI /EsplLdIIDOj6fc4eqXtVVoK/YTyBWbu5uVGCKpAAImD4uAatzYvJtVIihwxIXXoReOm tYn21P1oJ8zmWsa///M3GncaXY2vMNpZ/WkYvHUr1Z7krXjEP2xilbDHACxVnVLo8kuI hnHg== X-Gm-Message-State: AAQBX9ekaq+opjPeCaSf+UH0A4Vx3RRpZDGeN16bcjlM6B9cw4TIgV7N xMVEJkib8qEyZ5FzCNSpyvBRR1VzOjz1Ry3xtOs= X-Google-Smtp-Source: AKy350blIjx8nlvcw1L4pw2tawbyH0/N45S+taDTjhb98KTrFzxmnzFTL3Nn1iHqq/2QOiSoupZ0hw== X-Received: by 2002:a2e:9402:0:b0:29a:6325:6412 with SMTP id i2-20020a2e9402000000b0029a63256412mr886962ljh.47.1679668168940; Fri, 24 Mar 2023 07:29:28 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:28 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:07 +0100 Message-Id: <20230324142908.64224-10-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Jacopo Mondi --- include/libcamera/ipa/rkisp1.mojom | 1 + src/ipa/rkisp1/rkisp1.cpp | 8 ++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 +++++++++++++ 3 files changed, 22 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..b6eef541 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,8 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return -ENOENT; ipa_->setSensorControls.connect(this, &RkISP1CameraData::setSensorControls); + if (sensor_->focusLens()) + ipa_->setLensControls.connect(this, &RkISP1CameraData::setLensControls); ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled); ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady); @@ -403,6 +406,16 @@ void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame, delayedCtrls_->push(sensorControls); } +void RkISP1CameraData::setLensControls(const ControlList &lensControls) +{ + CameraLens *focusLens = sensor_->focusLens(); + + for (auto const &[id, value] : lensControls) { + if (id == V4L2_CID_FOCUS_ABSOLUTE) + focusLens->setFocusPosition(value.get()); + } +} + void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) { RkISP1FrameInfo *info = frameInfo_.find(frame); From patchwork Fri Mar 24 14:29:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18453 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 1CDF5C0F2A for ; Fri, 24 Mar 2023 14:29:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8BB6362711; Fri, 24 Mar 2023 15:29:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679668180; bh=x0R9Qqic00qgo35ORUHPibHmiHSvzEH9VdtJbsiB1p4=; 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=McmKE/NFjsTvPaGR/ERP7mcURXkMKxb493NTaP+9wLiZbV4KJkjiUgdyvHDJ2yJ89 MwA/FjbDS0P8drFQ8kc+6W1pW8JmxakormOvZN7WMfQzm4semC4f6i26HNszMlI58P FZT1Bji4qQo1IKSs4tu8YaCt/42edkZcVGQ++82KiP80kvUcbpinXtQ1rY0MxvXoF3 GGmIOBpSDGvSpoafygcGteH+8/uqwjdRNS5Q1rxOkoVA/kY4Zd6AN28i6nooxisKlm JLEHejv5OHmzKTBC9ryb28fy/Gj1ASPJPaE1Sv0LraJQhbt1Fe7eLS3CJ55YNA6FgJ g2N04V7/seXtw== Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 085956271E for ; Fri, 24 Mar 2023 15:29:30 +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="wdVEAVo+"; dkim-atps=neutral Received: by mail-lj1-x232.google.com with SMTP id q14so1895978ljm.11 for ; Fri, 24 Mar 2023 07:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1679668169; 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=mLZm2INCozHNI1ySEb1DUhlrc5wmxjKjFeWdt7Y767s=; b=wdVEAVo+cztgty4dtTeEo+b0NnAFkoNvIj46aj0hViqWa0kgr3BK3XIIu4JuJm+uy2 gxKfzuG7940ebE7hLw4FftJlUOm/HKKwA/686W64xhbedLtmqfffiotQAxKrLivNWy1+ tZpbPc9TqVysn3UhqIYsp0XbXFfqTHWwslDOCoMNaThLUAdWlIaY+r9Akl4/LT2/c+DW z5htgMdilx7HxOtv+EsUdWEbd4zsfPu8sxKqEs9tStIeN9son8jgvY7+cfLawSVBbYQV KKibRLGjH7nJn4mkTKjK2kuk+VzKLdEg+roiZQ/jDlM0tF1+TKnUCgI82ma5O/Rs/4dQ Hx7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679668169; 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=mLZm2INCozHNI1ySEb1DUhlrc5wmxjKjFeWdt7Y767s=; b=7Lmv802qZXTzRDZetB2O89hlcftfdoqv4O8M06UmmZKdsPjKTWrSCGVxCmXVSzSl5d leh88vf++wtpHqnQO0V1OHKKY0ZMzP79deqFWMydt1NU/c6EiXsQJlua/jFQLGB+smRe D6O8BYMw737M3b/lkgn12tiRUYKSG2x6VkFeM/F+u6X/CKvfWQTOrrEBMDMp5B6R9yqk 43fNbAShGH4LX/4MyNLhE9488yQp0vcevkfb2187MwbO/IiMxe5jcbHpXnyd8l/xxOtL 6TWkrdU5Oamh/xh1AEz90LIOcot/JJylE8N7ClmNVM6zAfcq1jf3Z6Pg8M6aqz42G5Kk 573Q== X-Gm-Message-State: AAQBX9cSjk+wKxiBSGXUZGzsfLNfEcuZbyXRswVK5BEPF5yy9Htne4D9 j5MKURKSd2qJAL7olwu1tHJC4II2Gdd3XeO7aH4= X-Google-Smtp-Source: AKy350awm22/yAVob52IjRSSMFj8SOvnhTWzKLhkftJo1gdXk1jcRW8JKqvIQIbmdl5ohPGEHGPAGA== X-Received: by 2002:a2e:94c5:0:b0:29c:9223:2f6b with SMTP id r5-20020a2e94c5000000b0029c92232f6bmr910984ljh.30.1679668169441; Fri, 24 Mar 2023 07:29:29 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id j21-20020a2e8515000000b002a10b2ea089sm981714lji.16.2023.03.24.07.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 07:29:29 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 24 Mar 2023 15:29:08 +0100 Message-Id: <20230324142908.64224-11-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230324142908.64224-1-dse@thaumatec.com> References: <20230324142908.64224-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 --- 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..4f3da897 --- /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: 5 + max-variance-change: 0.5 + wait-frames-lens: 2 # tuned for 30fps stream + isp-threshold: 128 + isp-var-shift: 4 + - Agc: + - Awb: + - BlackLevelCorrection: + - ColorProcessing: +...