From patchwork Tue Mar 14 14:48:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18401 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B3F69C32A0 for ; Tue, 14 Mar 2023 14:50:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 301A16274E; Tue, 14 Mar 2023 15:50:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678805409; bh=J62OTx3oB/aLsxLwgoirbptPdUBJpLLnjDolM8ZEjBI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=W0cok8L5BSbYxQkJ7P/pCA8kg+Zu0AVwzO9uRLBXj64bvxTxzYAX0eWzzVCKoZpJz TYS3vpwnfy7QlhPbkJT0C4xfBZhdj2q7JNSb5FCN0YPywN30Tfqq4O+2e47Grdkm9P wbPakH+J8l2eo59DOzuTfTUAzJD5rZ+eeMEhDjCdn9cS0f9y3v2EQb53p5K/rnW0tz dPqznwTijNmKhQcg5D66K8bHIAxI/VgOwq051qw4OFx4l/vDIciD+eePkimJ/3AJVa XHo44WCbnJdDidxZK/1Ivg2VhOs++4FXSBGZD9x9hzlLXmnXGBuKgxS2er4qdOBjZa u7dXLJykRFxgg== Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 10D016270D for ; Tue, 14 Mar 2023 15:49:57 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=thaumatec-com.20210112.gappssmtp.com header.i=@thaumatec-com.20210112.gappssmtp.com header.b="M5O2tbBf"; dkim-atps=neutral Received: by mail-lj1-x22b.google.com with SMTP id t14so16295683ljd.5 for ; Tue, 14 Mar 2023 07:49:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1678805395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/VDexCp2IVtvlqpNyv5xS3Sww9RNPylcLJ5hCb13SxA=; b=M5O2tbBfgDYlkmIEuX9bvyKrkqp3jK00z1xG5d1qSJ/0d4K3abwSaCZYDagyjMQc8Q +wEqKcuRpWNyHCJPOVz5c+9KHEQw9j+PUpwdrVQupt/Z9ixBE8Lidqv1a7EnneMpkIVo Yfra1KTnG3cEPgGUOD5sgluaHw5Yep+kZhHA5wuPDPPmlDkpIyGl2LwTDxQ3p8wNsAEq WJPPZw9xoxJAFJltnKBaurm+jwqp3KNGVELS6lq3Eb14AUfcLvOdTMMAJu/xiOhVAv7z JK1Djw9YeskN+kNz77l3AMFrqDoOGRrAKGJOTbf0sgU7VJuZVYhSADYq7YZVh8HqHq80 lJYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678805395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/VDexCp2IVtvlqpNyv5xS3Sww9RNPylcLJ5hCb13SxA=; b=LOMWklzw20rrjOzKPa6r+HzRlaMopm/oPSsv7eZW2OtN23OMnwOvOQo2OYC3dFpi61 bDeFffSBjAX728q/oAFuib0jDcyYtwom9zPbrQxvvR/IWZbeK7tb4EwxOt4Q/gocxkOw YrN+f631SGdvkWMF/hhizoRRt3GaA+SJkldQnVkhHduRvvxgeP8t6kVayQh+N0AzhEZp J8D4o9SVahAUH8jEpsb2cJwOb/ljU/swu3KQS8WmeeV901aSjLIXdVvENGOMBCroBEfk b3+mxlCtS5aOklf4DW5bHyuH4poiLBZ0ULSrE8nUOB8yyxlNrtpZAKpSRlUCy2UvMCpL +W3w== X-Gm-Message-State: AO0yUKU0rxE0yJShXRFSk+L1ACAmFF68FtSKDEbe4tlAzatQfQnLZK4p 5JjOWU19tI08K7P+RujxYpM2ILSLs314tVPzXEs= X-Google-Smtp-Source: AK7set+/tsJqdz9jguoTotjh6vFFa7kVhK4eT8niQSnYG31yKuO1Qlgp0g/X4ReqrjVdGSdSCRs25Q== X-Received: by 2002:a2e:83d6:0:b0:293:2ca4:bbcb with SMTP id s22-20020a2e83d6000000b002932ca4bbcbmr10945456ljh.50.1678805395821; Tue, 14 Mar 2023 07:49:55 -0700 (PDT) Received: from localhost.localdomain ([91.90.166.178]) by smtp.gmail.com with ESMTPSA id q25-20020a2eb4b9000000b00295a35f30e1sm470961ljm.115.2023.03.14.07.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:49:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Mar 2023 15:48:33 +0100 Message-Id: <20230314144834.85193-10-dse@thaumatec.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314144834.85193-1-dse@thaumatec.com> References: <20230314144834.85193-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 09/10] rkisp1: Control camera lens position from IPA X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Daniel Semkowicz via libcamera-devel From: Daniel Semkowicz Reply-To: Daniel Semkowicz Cc: jacopo.mondi@ideasonboard.com Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow control of lens position from the IPA, by setting corresponding af fields in the IPAFrameContext structure. Controls are then passed to the pipeline handler, which sets the lens position in CameraLens. Signed-off-by: Daniel Semkowicz --- include/libcamera/ipa/rkisp1.mojom | 1 + src/ipa/rkisp1/rkisp1.cpp | 8 ++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index bf6e9141..c3ed87aa 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -39,5 +39,6 @@ interface IPARkISP1Interface { interface IPARkISP1EventInterface { paramsBufferReady(uint32 frame); setSensorControls(uint32 frame, libcamera.ControlList sensorControls); + setLensControls(libcamera.ControlList lensControls); metadataReady(uint32 frame, libcamera.ControlList metadata); }; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 4b30844f..4aef2e30 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -469,6 +469,14 @@ void IPARkISP1::setControls(unsigned int frame) ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); setSensorControls.emit(frame, ctrls); + + if (lensControls_ && context_.activeState.af.applyLensCtrls) { + context_.activeState.af.applyLensCtrls = false; + ControlList lensCtrls(*lensControls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + context_.activeState.af.lensPosition); + setLensControls.emit(lensCtrls); + } } } /* namespace ipa::rkisp1 */ diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 83fb6287..1dc3f957 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -114,6 +114,7 @@ private: void paramFilled(unsigned int frame); void setSensorControls(unsigned int frame, const ControlList &sensorControls); + void setLensControls(const ControlList &lensControls); void metadataReady(unsigned int frame, const ControlList &metadata); }; @@ -340,6 +341,7 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) return -ENOENT; ipa_->setSensorControls.connect(this, &RkISP1CameraData::setSensorControls); + ipa_->setLensControls.connect(this, &RkISP1CameraData::setLensControls); ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled); ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady); @@ -403,6 +405,21 @@ void RkISP1CameraData::setSensorControls([[maybe_unused]] unsigned int frame, delayedCtrls_->push(sensorControls); } +void RkISP1CameraData::setLensControls(const ControlList &lensControls) +{ + CameraLens *focusLens = sensor_->focusLens(); + if (!focusLens) + return; + + if (!lensControls.contains(V4L2_CID_FOCUS_ABSOLUTE)) + return; + + const ControlValue &focusValue = + lensControls.get(V4L2_CID_FOCUS_ABSOLUTE); + + focusLens->setFocusPosition(focusValue.get()); +} + void RkISP1CameraData::metadataReady(unsigned int frame, const ControlList &metadata) { RkISP1FrameInfo *info = frameInfo_.find(frame);