From patchwork Fri Mar 31 08:19:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18509 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 8144EC329D for ; Fri, 31 Mar 2023 08:19:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2E10262724; Fri, 31 Mar 2023 10:19:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1680250794; bh=VUG4UFjzIQCeqV4WxyY3nTBPu3yS2LvNEUV/9j13dF0=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Uz2oXma9PqJwMOLfViQZKcZb4Pxzon17U/oTiAeA760KX3uOKtxZbT+uJEqsSKndf lrruzckPQsPEpOgjiaxv558TQ+RTnrzpX2QmnNfdcayiGbbh+FWa5MrmN11tknD94I 5W2GYxZWbcy/3PqaisDLNV77XSxD5UM2kXUEwobLgErP26Redv8wc4WJ69OxbBFGZI BXqraFqUUyzEI6ugeS76wAASrMgoaFkZCGmFQ8NYM0p0v6PQHAKX9ZC79rQBrFV7l7 KhX/Px/q60aaXI0wyrxrw/MSZiiX+BlZnxFC+PlPGKZsd79LjL6trt85IcejnPGBeF 4cXZhJIMA3+YA== Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F0AD562724 for ; Fri, 31 Mar 2023 10:19:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="6gOvMZPr"; dkim-atps=neutral Received: by mail-lf1-x131.google.com with SMTP id q16so27863204lfe.10 for ; Fri, 31 Mar 2023 01:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1680250788; x=1682842788; 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=J1b/IOB9ADFX+04pgjf6PbC5dFg/NgQJ2Yx90sri+kU=; b=6gOvMZPre612Ot5Qk2NnnuUgVBt+kKWCoqZE+A372ISKJJRCBfmd2qTLIF91ejr7o9 ytmmjmQvK/F0n+dHX0iwp14VsO+Yt1rqnJV0QU38cf6DLamMAdop0bTx+obo3yB8u++f 8E3xGaR9qpHU6vL9MRtCPKbVxGZcdsmQXFW9QsAvmrDzcZhvBNcmw7ZDDTcL2nNh2BZg zFwX5YaYymQ666cj0aqv0Io5KU0mkKDcoFS8H+vy7pZbz6DskD+tdyROHsN5RBUbc8ol SbgTAx6ITPopiKrE0OwdzBR6ufH3vVsu95JlYC/o3I7xGfSIgtx+qLZtsy96sknpl61w f7Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680250788; x=1682842788; 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=J1b/IOB9ADFX+04pgjf6PbC5dFg/NgQJ2Yx90sri+kU=; b=K9H+mdFQ26Owl1McSCNWLdITHKdCjmVQAjRc9Z29hIU20DMY/vhiFHhfiiEvvBRpFW Drhu5DFRSt0nbGHTEqHmI8rU94IRHHs1mA6WmoBaeZHbR05WrdtE3278ke43wkjEH/x/ BYwHTt/mCuaZbtFQR2GNVl2xVpt/gfB8Anc7SggexOl3Ow4/a/jZuStwoymnZTjn8Fwc 9crwDXcfiaMUQW0ODP4FXCJ/3qLqOqcYO5k/rj0qhlCsRKi6U9JHQGix7XVKwOPL/PHh UvU5KIp5Gl2LnWKLpKjgh4N7kmh1PQWn/JRRhRMLqII/yPVAFvpUsuseJD+H4atLw97/ ud4A== X-Gm-Message-State: AAQBX9f0JVBOvwV3/bHYREpeT+FlPYvyrNNV/QxCHSgmtQv4Rv7aZpFT eHjbsBT4opR0RQiQN1Qpx44Q/37NtP+lONZSpHPIPQ== X-Google-Smtp-Source: AKy350YhfL62OPs61OKTiSesHBgpnH8rk5py+PO8xzKk+uUfd92q+EESdGoQhiKaQOLxS0Oz3OlssA== X-Received: by 2002:ac2:522e:0:b0:4ea:f6ad:2977 with SMTP id i14-20020ac2522e000000b004eaf6ad2977mr7626143lfl.38.1680250788099; Fri, 31 Mar 2023 01:19:48 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id t1-20020ac24c01000000b004e84a8c3d86sm281459lfq.42.2023.03.31.01.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 01:19:47 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 31 Mar 2023 10:19:22 +0200 Message-Id: <20230331081930.19289-3-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331081930.19289-1-dse@thaumatec.com> References: <20230331081930.19289-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add information about focus lens position limits to the IPA session configuration. These information can then be used by IPA algorithms to know which focus positions are valid. Signed-off-by: Daniel Semkowicz --- src/ipa/rkisp1/ipa_context.cpp | 17 +++++++++++++++++ src/ipa/rkisp1/ipa_context.h | 9 +++++++++ src/ipa/rkisp1/rkisp1.cpp | 23 ++++++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 9bbf3684..aea99299 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -14,6 +14,18 @@ namespace libcamera::ipa::rkisp1 { +/** + * \struct LensConfiguration + * \brief Lens-specific parameters + * + * \var LensConfiguration::minFocusPosition + * \brief Minimum position supported by the camera focus lens + * + * \var LensConfiguration::maxFocusPosition + * \brief Maximum position supported by the camera focus lens + * + */ + /** * \struct IPASessionConfiguration * \brief Session configuration for the IPA module @@ -89,6 +101,11 @@ namespace libcamera::ipa::rkisp1 { * \brief Sensor output resolution */ +/** + * \var IPASessionConfiguration::lens + * \brief Contains lens-specific parameters if lens was detected + */ + /** * \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..65b3fbfe 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -8,6 +8,8 @@ #pragma once +#include + #include #include @@ -20,6 +22,11 @@ namespace libcamera { namespace ipa::rkisp1 { +struct LensConfiguration { + int32_t minFocusPosition = 0; + int32_t maxFocusPosition = 0; +}; + struct IPASessionConfiguration { struct { struct rkisp1_cif_isp_window measureWindow; @@ -45,6 +52,8 @@ struct IPASessionConfiguration { Size size; } sensor; + std::optional lens; + struct { rkisp1_cif_isp_version revision; } hw; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index d338d374..292768cf 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -164,9 +164,21 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, context_.configuration.sensor.lineDuration = sensorInfo.minLineLength * 1.0s / sensorInfo.pixelRate; - if (!lensControls.empty()) + if (!lensControls.empty()) { lensControls_ = lensControls; + const ControlInfo &focusAbsolute = + lensControls_->at(V4L2_CID_FOCUS_ABSOLUTE); + + LOG(IPARkISP1, Debug) + << "Focus lens: " << focusAbsolute.toString(); + + context_.configuration.lens = { + .minFocusPosition = focusAbsolute.min().get(), + .maxFocusPosition = focusAbsolute.max().get() + }; + } + /* Load the tuning data file. */ File file(settings.configurationFile); if (!file.open(File::OpenModeFlag::ReadOnly)) { @@ -234,6 +246,13 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, << "Exposure: [" << minExposure << ", " << maxExposure << "], gain: [" << minGain << ", " << maxGain << "]"; + /* + * Save the existing lens configuration and restore it after context + * reset. It does not change since init(). + */ + const std::optional lensConfig = + context_.configuration.lens; + /* Clear the IPA context before the streaming session. */ context_.configuration = {}; context_.activeState = {}; @@ -272,6 +291,8 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + context_.configuration.lens = lensConfig; + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get());