From patchwork Thu Jan 19 08:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18141 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id DB73FC3294 for ; Thu, 19 Jan 2023 08:42:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 70C01625EB; Thu, 19 Jan 2023 09:42:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674117730; bh=MHzwZkPrjFZzqFqY+IIHDDrrED15mLTFTjZlBdvTItc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OXOIgBoQBvFZPJG4aBNla6KfgIEDwB6+5RWoYE2Uc8QthAbzpDD8zttLuOY/Qvqra gNWAeoLPUg0XRlzqvP2KdT9hlTYWg3fUIsLI+n2/IfxVBE0b0GGPwQdCm0c7k/kQwT bzymZgyrarUBf8k3Y8znk33vFP5tYsA+RqWrKDmD7t5tsYBUglIyvA9zRhpTjJH0Om Icrr4+1ZxLTQJq97Dz4O8avFVt5tG+SIJbqEMjKpbFMDfbKa5wi93/7p17tIQp1Mi9 874KQ2BWYGg4Aa8QFgzSjKbG5clXKspVWxMLVNt8n5VWUDaz5JIA3EcKXLOUV1OYmM uIQJMoE1DZO4Q== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2542361EFC for ; Thu, 19 Jan 2023 09:42:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="QEx+T+Bs"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so3027904wml.3 for ; Thu, 19 Jan 2023 00:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ruQTIYdis1jrfTOZQl3cOInBkB3eyVJBswJS5xkktXk=; b=QEx+T+Bs5xexf697oj9h1b/guMUTM7yYtVbvizOmlJYhN5rgO79oZNq+gJnZdscC0/ +HYgc3xMj1ZzTkH//qPfQqWuOxqURYx3SZC1/u++GmW7KW/I5teFgbYMtwM2WMzN6GE7 wahxihZCZAqWCLbWWS8axDR0P32c3fC03F3gPARMs2Rb4IiC/9B5PFvYZhUGCxVaNACL U/MBcWHUbXN5q8CyvDqVGdw5TxoTGZcSQJeN3PN/zqbSInlB8RnBpY9H82zV/Ja66vTC v7V62Q7Hc1R/O8+EIVenisIvRL2lOfPPxNtDbDufGcLCcKMfB9ri4NaEKFmfFHmrQ1nN 8dEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ruQTIYdis1jrfTOZQl3cOInBkB3eyVJBswJS5xkktXk=; b=Z5+X1Zvh5Nwjdhfk08VzE0a33dBs7KUXtkAjnwZ7AI/4DEg7kGEMLLNRTgkETb+g6f j0ZJiknMXnjw1pZCwB04pKtM0p6Rr1hYh/g0ZvAY7Oy0v34MLVNR5LzeXNyoncmum7cD /NdebZxZH7mf8QMaR9O5qOdntHHCEW/WASiI6SMqqN1wYC4d+y8KjUChJA4wl46Tl6su ng6O1YkfMq7XQhsfZcMGLdHutnmcvH0+mh3I+03eG8766U1iPlecAx/UAhD20bwYmoIM 3686kNWxVhEjs6YQ6YYkyFwLLXqgCVyOj/2FMwWjasHLtIFZaCtVsnkqgxle+oRmxM7K uAKg== X-Gm-Message-State: AFqh2kooLG4uC5BY2igvDK+VfQHR+iYBr+X6ZsNX0E3u6XUCsnKQ87wu Mz2mLlbec71913IwJEdqPVBFPbUn01+N1R3efxg= X-Google-Smtp-Source: AMrXdXu/6QSSIZbHtHdJqZ6kP/Ig7yA2INmPsp/rbahcU7780NiXuxXCZpjE7VY6qgWBU0aayn0fuA== X-Received: by 2002:a05:600c:13c8:b0:3db:3e8:feca with SMTP id e8-20020a05600c13c800b003db03e8fecamr9923463wmg.15.1674117728880; Thu, 19 Jan 2023 00:42:08 -0800 (PST) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c074a00b003db0ee277b2sm3935754wmn.5.2023.01.19.00.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 00:42:08 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Thu, 19 Jan 2023 09:41:06 +0100 Message-Id: <20230119084112.20564-3-dse@thaumatec.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119084112.20564-1-dse@thaumatec.com> References: <20230119084112.20564-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/8] rkisp1: Control camera lens position from IPA X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow control of lens position from the IPA, by setting corresponding af fields in the IPAFrameContext structure. Controls are then passed to the pipeline handler, which sets the lens position in CameraLens. Signed-off-by: Daniel Semkowicz --- include/libcamera/ipa/rkisp1.mojom | 1 + src/ipa/rkisp1/ipa_context.h | 5 +++++ src/ipa/rkisp1/rkisp1.cpp | 12 ++++++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 16 ++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index bf6e9141..c3ed87aa 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -39,5 +39,6 @@ interface IPARkISP1Interface { interface IPARkISP1EventInterface { paramsBufferReady(uint32 frame); setSensorControls(uint32 frame, libcamera.ControlList sensorControls); + setLensControls(libcamera.ControlList lensControls); metadataReady(uint32 frame, libcamera.ControlList metadata); }; diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b9b20653..1fac6af9 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -53,6 +53,11 @@ struct IPASessionConfiguration { }; struct IPAActiveState { + struct { + uint32_t lensPosition; + bool applyLensCtrls; + } af; + struct { struct { uint32_t exposure; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e861fc0..297161b2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -270,6 +270,10 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return format.colourEncoding == PixelFormatInfo::ColourEncodingRAW; }); + /* Lens position is unknown at the startup, so initilize the variable + * that holds the current position to something out of the range. */ + context_.activeState.af.lensPosition = std::numeric_limits::max(); + for (auto const &a : algorithms()) { Algorithm *algo = static_cast(a.get()); @@ -452,6 +456,14 @@ void IPARkISP1::setControls(unsigned int frame) ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); setSensorControls.emit(frame, ctrls); + + if (lensControls_ && context_.activeState.af.applyLensCtrls) { + context_.activeState.af.applyLensCtrls = false; + ControlList lensCtrls(*lensControls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + static_cast(context_.activeState.af.lensPosition)); + setLensControls.emit(lensCtrls); + } } } /* namespace ipa::rkisp1 */ diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 0559d261..b2fedc5f 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -113,6 +113,7 @@ private: void paramFilled(unsigned int frame); void setSensorControls(unsigned int frame, const ControlList &sensorControls); + void setLensControls(const ControlList &lensControls); void metadataReady(unsigned int frame, const ControlList &metadata); }; @@ -337,6 +338,7 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return -ENOENT; ipa_->setSensorControls.connect(this, &RkISP1CameraData::setSensorControls); + ipa_->setLensControls.connect(this, &RkISP1CameraData::setLensControls); ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled); ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady); @@ -400,6 +402,20 @@ void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame, delayedCtrls_->push(sensorControls); } +void RkISP1CameraData::setLensControls(const ControlList &lensControls) +{ + CameraLens *focusLens = sensor_->focusLens(); + if (!focusLens) + return; + + if (!lensControls.contains(V4L2_CID_FOCUS_ABSOLUTE)) + return; + + const ControlValue &focusValue = lensControls.get(V4L2_CID_FOCUS_ABSOLUTE); + + focusLens->setFocusPosition(focusValue.get()); +} + void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) { RkISP1FrameInfo *info = frameInfo_.find(frame);