From patchwork Tue Aug 9 14:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 17048 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 B85B6C3272 for ; Tue, 9 Aug 2022 14:47:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 701BF6332B; Tue, 9 Aug 2022 16:47:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056433; bh=WQkdgTVG3hetfoDKXcDN22AlAySAJ+/ln+M90qR+WjM=; 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=TTtxaePDB2JclrbiyY6xpRryCDu1o4I5uLSFIKWPTQktwS0VZ0/e9WRvsqoR41ZNW BX6mX5CIU9eovq0aX32VCE41jtgBtmEu1rZHnOiwxPk/6l+BPtHk6uzU5jM5wUcuUJ 2k7mjpBZmaM0wm0k38d1OyGLuc+lxfw8+9irGf1Q1E9rLp8It3iD+pZi3pccf8ofef Pt1UT/M/trMew8PGvOil1+dNcGy3VPmcHZfgVlkt7cC8iz5QpdCthHeR+F0pntqMd2 s8VSY+AKnAfrcr6JjjtuYbWNhwou2ZtubRWN+ojpIXZgpZiX4MuzloKS47G956dE5V 2YCwNV5wzldUw== Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 041D363326 for ; Tue, 9 Aug 2022 16:47:10 +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="D4EXp1kA"; dkim-atps=neutral Received: by mail-ed1-x535.google.com with SMTP id r4so15385314edi.8 for ; Tue, 09 Aug 2022 07:47:10 -0700 (PDT) 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; bh=i7m85d36XekqKOHcB/TG7CCkjvmb2lQA7sbkC1OlJZw=; b=D4EXp1kAUgGyIfdNBNQKilVPJTNc0bcoM2XrMWcx0NUBvFWbd8PmyFvvNAYxHUg1Xb 7EbUSEO/MpBoQeYddrHjL0Y/Q3FNnvC33/nKbppw4Jsqph/2EFEKRfCfhJASoKPTpYQ0 4U/8vz7NcWH4vQEQ+fLqIkZWR+zuF07KZhrqE2AfWl7SkUJ+RKbKpnuJhL7Xsqbwk9BX iVfaditCsGOtfdUAAnil8/PGfJMDyVVnpkUgmdduH5SfBTBGw663EdAxOcRXjLWaGNQj p+ACc+qyLUJvI8+CN6nwZMrkGcgWQ2lxsBAyMZub3rCDsDEjDjIADfEuwpqGqWzmzKS5 RZdQ== 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; bh=i7m85d36XekqKOHcB/TG7CCkjvmb2lQA7sbkC1OlJZw=; b=qQWx1k9MlVHIqOkWr/SNluBz/YLR/t+tMsf1St2G/Z5x/fSS9L4uLSfk3pYZR2ax3v R9hh65O9Ot5JGoi0ZX+FcILjEHkvFM/nQCqxb6c2QTQ+/d9G3QkqQospcquwTXG3Yphj NWx+DPHJE+E6kea96Q+aslqNC43FoZtQvq/i+G0BmGE2yPYMPDLLqKtvlEuNpRAgsrGm 5o7pBsUTofL/6o+lUea3HdDbVHxRGJYzExBCKRYq/DIUKtw1yKuunhfl02KHGMtbB4Xo yI2wfQDL9p4gj5mnkh7UCbRnoJN99X7FT7LMH4Ag5OFko5aFBOqtRDHVqE//mHhoJvSK Gctg== X-Gm-Message-State: ACgBeo3XgwTGn9WPO5x2yhFVwXc5Q0Dt0CriwHV2YY3lFaUevkLBE8Mq CqHgtcHPL19TB+MdDTsxmeVzqK0u1vB7NA== X-Google-Smtp-Source: AA6agR4GJ7DOHJDfNZMqReKQiUsj+1K2cmXr6roDApxeN8TOvyMAZ+jTO8JmvvSGIeNBPaAYOpBHoA== X-Received: by 2002:a05:6402:1e8c:b0:43d:db52:78a8 with SMTP id f12-20020a0564021e8c00b0043ddb5278a8mr21432378edf.324.1660056429680; Tue, 09 Aug 2022 07:47:09 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id cn15-20020a0564020caf00b0043ba0cf5dbasm6058486edb.2.2022.08.09.07.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 07:47:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 16:47:02 +0200 Message-Id: <20220809144704.61682-2-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809144704.61682-1-dse@thaumatec.com> References: <20220809144704.61682-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] libcamera: rkisp1: ipa: Rename ctrls_ to sensorCtrls_ 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" As additional controls will be added to the IPA (like lens), we want to have more specific names for each ControlInfoMap. Signed-off-by: Daniel Semkowicz Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/rkisp1.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 17d42d38..ee484845 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -69,7 +69,7 @@ private: std::map buffers_; std::map mappedBuffers_; - ControlInfoMap ctrls_; + ControlInfoMap sensorCtrls_; /* Camera sensor controls. */ bool autoExposure_; @@ -199,16 +199,16 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, if (entityControls.empty()) return -EINVAL; - ctrls_ = entityControls.at(0); + sensorCtrls_ = entityControls.at(0); - const auto itExp = ctrls_.find(V4L2_CID_EXPOSURE); - if (itExp == ctrls_.end()) { + const auto itExp = sensorCtrls_.find(V4L2_CID_EXPOSURE); + if (itExp == sensorCtrls_.end()) { LOG(IPARkISP1, Error) << "Can't find exposure control"; return -EINVAL; } - const auto itGain = ctrls_.find(V4L2_CID_ANALOGUE_GAIN); - if (itGain == ctrls_.end()) { + const auto itGain = sensorCtrls_.find(V4L2_CID_ANALOGUE_GAIN); + if (itGain == sensorCtrls_.end()) { LOG(IPARkISP1, Error) << "Can't find gain control"; return -EINVAL; } @@ -336,7 +336,7 @@ void IPARkISP1::setControls(unsigned int frame) uint32_t exposure = context_.frameContext.agc.exposure; uint32_t gain = camHelper_->gainCode(context_.frameContext.agc.gain); - ControlList ctrls(ctrls_); + ControlList ctrls(sensorCtrls_); ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure)); ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); From patchwork Tue Aug 9 14:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 17049 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 7895EC3272 for ; Tue, 9 Aug 2022 14:47:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2560863330; Tue, 9 Aug 2022 16:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056434; bh=mOCCKhMkLACzG+Qm14Ztu6VV6uEYpBKJBBmkQEn/lqw=; 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=XLNJois0kUbqjgyG4N7tyZgzliEAbl0CaLILwhYPz/acuYIcEoLbhN1tSeXaF1f6h DxxmwuuV5+a7f3xPFpIVhFpVSEIm8WxF+r3bsZ6YzJAF7htqT8VC3RnuyLyyyRUjk8 jXR6lHB2ejWQxOMpFm2XptEZrPeUgJtS2nZcABZzvt3oF9mZ5KhpoZGD1z1bdAN4OQ dZXt33f6Wxe35/7vVL1Bdz/tL1n17B3Ff6/d2BtSvuW/PXKYZCau7ZiTTUgGXwg0tY dv5kxcXLZBVIJHAHuAVvk0CopA2TzUmuT4WZhXYilNvGJ3s3l39yAVIJbfsoggtWmj n6bSd6nHbeqng== Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2131D63326 for ; Tue, 9 Aug 2022 16:47:11 +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="2uKvOnLS"; dkim-atps=neutral Received: by mail-ej1-x62e.google.com with SMTP id kb8so22655819ejc.4 for ; Tue, 09 Aug 2022 07:47:11 -0700 (PDT) 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; bh=LqXoxDZDBQ41e/9ovPZw7Mb2q+SlI9QHIG7vwlMPzTo=; b=2uKvOnLSw6hSDi3S+G/4UqVPM8OWI9aJIp8Lz2/++6Z468EFYV71s8KVUAsaWmlcrD 5A4LpmEed2BlfVDcn0OWjmUg8+GazPjPzRlUu1dfcNOLGnrUI+TVHYZLtFo9o18A/kqY QqYUnnfbFHzBwnfZOPNU1ssO0MjAStzkbuUQgzxmrdX/jUxImPpBDo+73KbcKn9yLivY IOoGRc8OA6pG+/xUA9Nj89u3gbg+RkpbUAOxfU0xjkX4mxMP+nWoh+pjbV8LqT/sF6rc CeUW5RokPOzmLsukf0SPG5Dm473pKeFWlSWYTSvkFHEPfDXP+z/RbYrt8Cwt/dxlUxzl BdaQ== 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; bh=LqXoxDZDBQ41e/9ovPZw7Mb2q+SlI9QHIG7vwlMPzTo=; b=Jy7YpimlrxYVZvp8UCr+xzrCaHQuC+Mr9pYEFhuUFQE5TFSqM+Pf1vDmcizOIDMV1a uNuue531R3qqZCxJfbtd1NnOoRK2W8vtvrdTB31XrQ3rvX2Y5XJfkE8sqdcKkZnqgEQf wXY2o9GXW8MHJ1huea7i484Sie7NB4tkLHKpcFXZfPQt6ZvcmHtWpoM9xXrfS9d9Ykoe +u5teV3J7XdVh1+X257DLr00zoXQgqUdXFF5hmJtY6uRg+FP1HJTMiDuOzdEfWw2tPYX CBsi5YtKq9ffacivP4Mzsf8AEeJ2yTAih/cUX/SCCnrBgrHYSkj34RpmI+QIk2S7JpE9 dKCw== X-Gm-Message-State: ACgBeo3r5S0DOigrxkWgalkfh+UxbM5F4XsrkHeZtP8DSBQFUpgHHxUJ tKXrI7oi8pNBb6aAZquN3tEMLKXy5GITow== X-Google-Smtp-Source: AA6agR4tbls6q384gtkBdUKfd1lUi305IEE/82MpYU2lrHPi+NvgVXSq8t31Aq0ssToY6kaQBarQ9A== X-Received: by 2002:a17:906:29d:b0:6f0:18d8:7be0 with SMTP id 29-20020a170906029d00b006f018d87be0mr16983672ejf.561.1660056430632; Tue, 09 Aug 2022 07:47:10 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id cn15-20020a0564020caf00b0043ba0cf5dbasm6058486edb.2.2022.08.09.07.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 07:47:10 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 16:47:03 +0200 Message-Id: <20220809144704.61682-3-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809144704.61682-1-dse@thaumatec.com> References: <20220809144704.61682-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] 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 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Check in pipeline handler if camera lens exists, add expose its controls to the IPA. Signed-off-by: Daniel Semkowicz Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/rkisp1.cpp | 7 +++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index ee484845..9e4c48a2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -70,6 +71,7 @@ private: std::map mappedBuffers_; ControlInfoMap sensorCtrls_; + std::optional lensCtrls_; /* Camera sensor controls. */ bool autoExposure_; @@ -201,6 +203,11 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, sensorCtrls_ = entityControls.at(0); + auto lensControls = entityControls.find(1); + if (lensControls != entityControls.end()) { + lensCtrls_ = lensControls->second; + } + const auto itExp = sensorCtrls_.find(V4L2_CID_EXPOSURE); if (itExp == sensorCtrls_.end()) { LOG(IPARkISP1, Error) << "Can't find exposure control"; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 93287332..5f10c26b 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -28,6 +28,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" @@ -694,6 +695,10 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) std::map entityControls; entityControls.emplace(0, data->sensor_->controls()); + CameraLens *lens = data->sensor_->focusLens(); + if (lens) + entityControls.emplace(1, lens->controls()); + ret = data->ipa_->configure(sensorInfo, streamConfig, entityControls); if (ret) { LOG(RkISP1, Error) << "failed configuring IPA (" << ret << ")"; From patchwork Tue Aug 9 14:47:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 17050 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 D643AC3272 for ; Tue, 9 Aug 2022 14:47:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 989B963332; Tue, 9 Aug 2022 16:47:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056435; bh=qU5aw/Jw76GpL2WQXt84DR+OO6C6wzVTR7vjAtoNTGs=; 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=nCSh7kmGArn7Q61mXDx6Z+RfgASWKw2WB4CkOGrF65AOpceua997Dl2EqMFp3lU5s H2KacojmkTU3usG/ksjd01DJYxos6GkNMrsjZrRv96qiZdC5/oEuRtbB6CfXCs2u/3 HU6RiAf8LGWz96i2uL/5rLTlOwfJg3t7ii90Q3UKPreAgHFXDUb1aquId6qWS/fyFV +kr17fLTQGb1p4Kpb1vTa9jg2k7hULnjtZ95U5EJPvMc2gK8P9V3/lD7UFBYSnTfD7 TiOBtFvPj1ar+ewe2pxAna0OsVLBZp9fEn+j5wx7YbcIWHzsBCl3QG5CXkJfr2jLgq XhRaQt7t6op2w== Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ED08363326 for ; Tue, 9 Aug 2022 16:47:11 +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="kkv0aXVB"; dkim-atps=neutral Received: by mail-ed1-x52f.google.com with SMTP id x21so15430864edd.3 for ; Tue, 09 Aug 2022 07:47:11 -0700 (PDT) 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; bh=lIX7iN6BFHYMg1C5EJH+xkJnpsY8ZgYE6Zav8pi9O7s=; b=kkv0aXVBk4CjNkw+b/nkZTi/8dzLJ1HaLrq5nU44/TCduZTrCG0am/me/IxyhQL5vq 96ji8yY0PTkvU6ZbsXyhdgHf7w8BW5OpcP9ia7l3Q0BIOQZ2kmcHwgv++j8cuRMv4Yk6 5gioKuurb91wytEO2PDNKGkbtacxuuaVTfaoU3fCmbqhlU9LG/DQFDC/2KoVhAnWlbKJ 8UUkJcA99bU1/LIWR0kQutjIDJRurKj+rhcxHCFSuhX1eyddplJoVT0Wx/VTJknKrJxx m8UE9IsDGhmDHdbBNd/PdO5XOBGLFEbFF0/hxdsUjuQ+IXHTg2UJM+mfKKlg7iG81vNN yGzQ== 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; bh=lIX7iN6BFHYMg1C5EJH+xkJnpsY8ZgYE6Zav8pi9O7s=; b=p+l0KHh5jUjQq+KAJZFs/pbN1Y5OSv882AYcMpvxdvioQ7Ysg7NsBEgqxueD8Hbr5f 856E12b31nnB9K+DhpYEt3JKN8buL/q05SieWjkZWarAd6eGsYJaJ1eEVRApDDmAWlEp Fq1Y9RVWZWfLELjWf9OcZF+sWdSuf2ohj/4ksdAU1BCkm8tMoYp2wFYcLg5TdJ8AK+aq QTneDGJQlQHcBKrDd92US6gj5ETgGXMf57mUCyVYGIi1JyUVM48k+nG7IaDbpdZ6VZio ZrZz3G0HBHZrtbLN/3nvOMvKabaLfzPSDqyOowJRTMIMUy/hf5eWiWOsylm7RlUQw0hh PX/w== X-Gm-Message-State: ACgBeo3K/5iJr/cZfANsg6d2bW8qDp7xvv8+mEZ5BkFr/PkrNQnj30HH mDnKCnmhAgJUyLsd5RNMafUnLVDfTTcxJw== X-Google-Smtp-Source: AA6agR4NoivrNZIOzSNTJ0okc8VwKFrcjXbXMMZjkUbeo62AQ3//dVFZKu36Qtk/ahf2sBHHnM4NDQ== X-Received: by 2002:a05:6402:40c2:b0:440:4ecd:f75f with SMTP id z2-20020a05640240c200b004404ecdf75fmr14722348edb.405.1660056431581; Tue, 09 Aug 2022 07:47:11 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id cn15-20020a0564020caf00b0043ba0cf5dbasm6058486edb.2.2022.08.09.07.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Aug 2022 07:47:11 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 16:47:04 +0200 Message-Id: <20220809144704.61682-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220809144704.61682-1-dse@thaumatec.com> References: <20220809144704.61682-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] rkisp1: Add camera lens position control 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 eaf3955e..caa1121a 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -32,5 +32,6 @@ interface IPARkISP1Interface { interface IPARkISP1EventInterface { paramsBufferReady(uint32 frame); setSensorControls(uint32 frame, libcamera.ControlList sensorControls); + setLensControls(libcamera.ControlList sensorControls); metadataReady(uint32 frame, libcamera.ControlList metadata); }; diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 2bdb6a81..d6d46b57 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -42,6 +42,11 @@ struct IPASessionConfiguration { }; struct IPAFrameContext { + struct { + uint32_t lensPosition; + bool applyLensCtrls; + } af; + struct { uint32_t exposure; double gain; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e4c48a2..39e1ab2f 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -253,6 +253,10 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, context_.configuration.agc.minAnalogueGain = camHelper_->gain(minGain); context_.configuration.agc.maxAnalogueGain = camHelper_->gain(maxGain); + /* Lens position is unknown at the startup, so initilize the variable + * that holds the current position to something out of the range. */ + context_.frameContext.af.lensPosition = std::numeric_limits::max(); + context_.frameContext.frameCount = 0; for (auto const &algo : algorithms()) { @@ -348,6 +352,14 @@ void IPARkISP1::setControls(unsigned int frame) ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); setSensorControls.emit(frame, ctrls); + + if (lensCtrls_ && context_.frameContext.af.applyLensCtrls) { + context_.frameContext.af.applyLensCtrls = false; + ControlList lensCtrls(*lensCtrls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + static_cast(context_.frameContext.af.lensPosition)); + setLensControls.emit(lensCtrls); + } } void IPARkISP1::prepareMetadata(unsigned int frame, unsigned int aeState) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 5f10c26b..de0d37da 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -108,6 +108,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); }; @@ -324,6 +325,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); @@ -378,6 +380,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);