From patchwork Fri Mar 31 08:19:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 18515 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 7E925C32A1 for ; Fri, 31 Mar 2023 08:20:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 205FC627AF; Fri, 31 Mar 2023 10:20:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1680250800; bh=bLqSmcHJss4tPX5K00bkSod/puYdxUrHTNdIMYC+T4g=; 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=sXhfkpM497wNlQGQbZY4bxxdTaVPfBA4Ox7wwTi6jMsJ7Dv1U8Mgk7yPQzxsooz73 wWQW+XBAM72DUNChEccaRiVDf8H++ljW8p2xOM8BnSWR9S8co7yTIzA/7Y4obo0YVJ LMpLMIWwJfVznW2Asmu6pWOZWd25RTI0VmQlK76SEneebK8Sq8BYJ6hFs2ALahAj6Z mODIbcbwRWAKpSua9y8jo+c30R+1s5K+IamKA+ITbBrQo8NbeyaUg6fUvIAnGvbuO9 8kt0rzwDLdJAJDJ1g4+HYbhPLpAS9gA29NiuERj4Fmu0YCL28JGK2DoYaarNare3i0 zdQmO9PJ+eAMA== Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DECD662768 for ; Fri, 31 Mar 2023 10:19:51 +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="znrHpllc"; dkim-atps=neutral Received: by mail-lf1-x12f.google.com with SMTP id g19so14771264lfr.9 for ; Fri, 31 Mar 2023 01:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; t=1680250791; x=1682842791; 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=bF+pQHcoCZEIwhlblfRqtcMkef8BVDr4E6eAf4PH+RY=; b=znrHpllc/gKHFg1K8WJR7uyIq4CeBOOdmjIpwWkQ/XVYF8FyhwuClI/KjMXOmUZMQF 2tBv6QeCRKo0xexKroLjxj5lbL5kb09deqFIBGRoNdevQD8egrCiUikeW8CyWZi1p4iW +hJD4qz2vB9URkr3qnlJePS9nYQuQb/RRnUsIIGf+H4yzu/vsE5ZM3188gO4fAB7N1dO OrGCrgF/sgSGQ5hNnRDV1oTbvuzdCZQ1Ew16yZ67kxznRfBG2V7O78GA39taV3gGp+TG RfwtDya2G3YVscWz/0fMdAGLeqERiwy32yvkxJHOtC4ZALFI7M1NOCft08kADB8pIWzF 2xIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680250791; x=1682842791; 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=bF+pQHcoCZEIwhlblfRqtcMkef8BVDr4E6eAf4PH+RY=; b=KIrcJ1s9hBLTgPA1mV105PM7Ps/9V9fexhad6rX9tGusaS+kZeUX9IAd1zw1CEPytp Ybp/sXFNciSMZwzBjx1c1kiGTDPMI1GhIgn3s6T9c+n/N69uBchgFWH22xLWayYkd8HQ enObf0Bhwa/teo7ZNPIm9pBpzxvhlimHreTHqV6UsRD5l13kWs3u+1FVwRuGFDYphjH+ ISjZ/hV1m3mG6bxxU4IOYnmX+mZQoaxVKyqDflKc4Z1cz8iDFcBkkv5h+n2ay28pZAV/ Yfweg1nmrEs0bEnQddB4CA2seXABcF11i+mrM4N5+sHyh2N4FE38xgYfuEuQ2H8cOEgO ce7A== X-Gm-Message-State: AAQBX9ebMmbFvIX46jkYym1t4pgjHs4OcZEwcRSxp9zx8/UqM+giF+M2 pZzWyotoOfUBCBekx/9IE2uQAEx0f29UOA8v5XwQfw== X-Google-Smtp-Source: AKy350Y+tZRguc0e8D/rHEZCEx/JwaHZshapC/da2YrZ7emqoyDIAmS+v9QF0H5KIvPzaXVUFyOF6A== X-Received: by 2002:a19:f519:0:b0:4eb:304f:66f3 with SMTP id j25-20020a19f519000000b004eb304f66f3mr232857lfb.22.1680250791671; Fri, 31 Mar 2023 01:19:51 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 01:19:51 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 31 Mar 2023 10:19:29 +0200 Message-Id: <20230331081930.19289-10-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 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 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 d4ff1230..dc6a8ffc 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 9c8b4a82..37b1e0a8 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -497,6 +497,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 f966254a..f42a8368 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); @@ -409,6 +412,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);