From patchwork Tue Jun 28 09:06:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16401 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 74429BE173 for ; Tue, 28 Jun 2022 09:07:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F5BC65638; Tue, 28 Jun 2022 11:07:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656407232; bh=sbnH6DeiWmVmShudASLtOyHMJp9Y2I7iCrW1cASfX88=; 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=kVld9aYnvT9szJdb1eYL6vELkW2TF2CGpcdgNFIAZe+bxAXAS9hvg55dzKFKLsifB gVb5aOA61k99y3cDTVel78g30neGLXgUWJtJP9gDSr//I1MQB6RFwjgYVEv4eRXUgk hjqpX0FHf4nHheRIV8ItNXYQOWbAClY4OT0Tidl8Qjw5YZjIngx5/awlKc+Cpn60CR OxPBYt1j+O83Z9ADdRUl7pAQNURS7pZpk7YGQFeQoMG5vXYgcU93EoxQvGo93zbFmL tu+MifLNmoUHT+CDsu36TS1gDCCzSw7eP3EGxHVUJG51t/vb0nxPLZfyKaopvlGrBJ gFk/Jyp1snrkg== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F06836559A for ; Tue, 28 Jun 2022 11:07: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="6biJQSSJ"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id h14-20020a1ccc0e000000b0039eff745c53so7137974wmb.5 for ; Tue, 28 Jun 2022 02:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=isqQCtca+id/lggpU5IKMGvQbHwvkY2hggxC5WD7M+c=; b=6biJQSSJcieqRiTiOoyBvLOlPpmHvglVspHCXrcn2sopP840fzDrn1Jsi1Ny4rrM95 26RCjOPXb0KTHrWGZ8tWW0Fs/aIfANQZ3E6pTNDcZ6iSLogJfh/OTVKQT9YNJaNMw1Gb zoKy6Fc2TOaEjuQE1PtPvdvi8NBrKFHZg03Wjgpg4CRtAmzwLY68yhLIgDN5XpFy6oqA E+5LI/59D/TmFtufReGVtbT0B8mpEFipF6gFMOOtQhlo/tnAoL3VWJmlebYE+MeoNTHZ 1PzI8p16ofmEAAwozo3OKJlihMbw4wUsiOSkjHJxsRj7BBt1yCtN/GXQrrSfEG0upltp s1MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=isqQCtca+id/lggpU5IKMGvQbHwvkY2hggxC5WD7M+c=; b=OcBNtrGVkLvq2UUnKQ7qBXA9O33jt5tq0G6JQHuOatztjGBAObpG7FRzbqxMUNomjK aA+gGXcBuucfiIpoTVSSPyjZ88kg9YE9NQfb0oiG3lhNWdnPS17YAip7j/Vc7Ukx3C8Q 4okjaAhYcQ/JuRD77CML9PXJj6ohJNlLZnb1H0KZ00/PlS4yeHlBwqW7aeUVFEwvYzd7 t+EAXqhRlhyArcwjAwv+sVnTV0HeP0h6Pexn7elyxxbe+TSsIu4hbxpx70UXtm24lEuF U1GHLxeJjlli2kmK6Uz/r1bxHqQKNpU/cF/kZvjNx8a+DhpVMQq0CH2ZxO4ZyWNUSKfe QYYQ== X-Gm-Message-State: AJIora9sBgHEDMPLL5rOZAu/Gf4d+6kxExSMxTNQEjgIcFMctUcSsthA /gOjJKlf8yakzQjKt/TuTY91WvENEvcmOw== X-Google-Smtp-Source: AGRyM1sujJFUgqo8jOnHGJ2J4gzF2ECPYgYlBB5rXxdnV7nrZeaWeU/6yyPzXHrkrC4W9vVXm7rZaA== X-Received: by 2002:a1c:2b05:0:b0:3a0:2ae2:5277 with SMTP id r5-20020a1c2b05000000b003a02ae25277mr20826809wmr.30.1656407230661; Tue, 28 Jun 2022 02:07:10 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r68-20020a1c2b47000000b0039c4b518df4sm20126972wmr.5.2022.06.28.02.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 02:07:10 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 28 Jun 2022 11:06:54 +0200 Message-Id: <20220628090656.19572-2-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628090656.19572-1-dse@thaumatec.com> References: <20220628090656.19572-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] libcamera: rkisp1: Control the lens from pipeline 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" Control lens focus from rkisp1 pipeline, using CameraLens controller and expose lens controls to the IPA during configure(). Signed-off-by: Daniel Semkowicz --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 7cf36524..363273b2 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" @@ -107,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); }; @@ -353,6 +355,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); @@ -654,6 +670,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 Jun 28 09:06:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16402 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 34C71BE173 for ; Tue, 28 Jun 2022 09:07:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F0C0F6563B; Tue, 28 Jun 2022 11:07:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656407235; bh=K1Guve83AcE617R92eX/K8/fgyobek0+MOd8IhImbm8=; 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=Vumj7Hxz9RAmezoZyjhHmwxLeUfg2lSolSR39C25OAU6xjKRNGQ3qeavyK2Ho5U05 QCwCSmqI5TJf9ewzB0V1QtLFWsbcoHjppoJstymkJ0CuqYJdYDHS9xnHThx28g814H eCZQC4sSyA4QxpvtBuI8ICLpzDaPUQre9zjU+uwfAn6OAOdrSWNIrxbEskUWXFazdh StiJ5V6+IiMqm7o/W9JhBXLAkwcIAFwi/jyOl6FF5RnHTOO56uaoV1opRDiS8pCKmB UydqP9eg3VCRkj8/0yceaRUXDfxGUiVb1QNbL4Wg7ZzfnI45IsUyzM/HdLtVBxbWT2 /v5NhipwSZSNg== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B70165633 for ; Tue, 28 Jun 2022 11:07:13 +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="PW5jxuGc"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id m184so6924834wme.1 for ; Tue, 28 Jun 2022 02:07:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xI05EEK/C5foWNjuVX6e/4IavLiNSTV1YJfqa/cQXMw=; b=PW5jxuGcVtSfi5tV3uQ/aml6pJu4WT/AW/I6z46wTGmG7g9EHLLpsLz3UFA9I1Vk/O cjkwT+M2U7D++SVT6tn7JIwTSxMGOgtU2JxRKhYLqV0qugovdL76Cwth3hn/gSCBQQat W34tAfDFKMzp3z0fIvMEAzkFUxrKg22iRbkYsKiZIqzR770FqMTLF77xziabsRy003GW 6Ly1EAEZ4DvehKdCzRl15nlfXPZ8x+t1f+gh2HWEFsZSP30GjxJ+x1MvqiZzR2NkjtpU ak5v9Zkg0ogNjEPB4IwSU17PhN8zIMF3yguvoleyKNpHXKiE3b4+3utv0NkoG7+PWHa7 iXvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xI05EEK/C5foWNjuVX6e/4IavLiNSTV1YJfqa/cQXMw=; b=Zevn0ZxF3t3bgX07+55e85Ef6yUsLG7s/1kRezgUZ3oTB7b9sOsAZNzozMhR5lZchi iP/xkgmj/EzyMRCVMW3GYMjZv/EYPVf5odNKsLNlQsmXs7sXCFIBN8GwCKGT5E9FxQTk wron2/WVhRksI7KYTgtJol/2FY2O8pyLw4yLrTlB6jVrhYZAXr7ClZuYmMtuus4PzrCY Bxj3p5zPOGLc256c/rbRZ7R9dV+QDmPd4sc2VOLmQXY1lUlYYoy14kryaDtnacVX/2QC h8pq0OWSi/v0KSIr6s7omt0OATj6UY+zjczdS0N5GJe82/BnnSnLOV3zENmPm1nSrTR1 OBYQ== X-Gm-Message-State: AJIora8ukNVpDQVLMt7fV/6uveLwjAa/nM2WynpxQjj9+pxty44gc4D2 nScM5k4Ebv/dUOZC73PkehIh3gQIUoiFSg== X-Google-Smtp-Source: AGRyM1s7Jb6/Kx6U/R7hJ+HJ/JqzoYy1+SstX8USN2npEPlRGQfKwBf/glvTiM9P8/gv9nuy7vKByg== X-Received: by 2002:a7b:c20d:0:b0:3a0:39e4:19e8 with SMTP id x13-20020a7bc20d000000b003a039e419e8mr25552846wmi.166.1656407232878; Tue, 28 Jun 2022 02:07:12 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r68-20020a1c2b47000000b0039c4b518df4sm20126972wmr.5.2022.06.28.02.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 02:07:12 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 28 Jun 2022 11:06:55 +0200 Message-Id: <20220628090656.19572-3-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628090656.19572-1-dse@thaumatec.com> References: <20220628090656.19572-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/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 --- 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 7d6f0b39..3511a054 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -65,7 +65,7 @@ private: std::map buffers_; std::map mappedBuffers_; - ControlInfoMap ctrls_; + ControlInfoMap sensorCtrls_; /* Camera sensor controls. */ bool autoExposure_; @@ -148,16 +148,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; } @@ -284,7 +284,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 Jun 28 09:06:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Semkowicz X-Patchwork-Id: 16403 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 37B66BE173 for ; Tue, 28 Jun 2022 09:07:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB4B765636; Tue, 28 Jun 2022 11:07:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1656407237; bh=gfzwUG83+G0yymYmH0N1alx3bx8m4CacN2rgSnexuaM=; 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=Ps1/izySZocKPjuNolYWOq4G3/QSTY7rFwZj9sjOgj7RK15vwKzaQC+PwEDZyBZ/X V4G7wLAnzFCC1niO5iOxM8HRjkaRFk0Xp8utubQos0jXTJyqwv7p89vrMBV7Ay839t RwfIenUaQGUwCWODNxsvdnDT4M83YXrM67G8PNKiFdVpo0UDiPrp8UTnx+Z9VOMuEM lWEMjRFtR6MWlfjY0I00ce4ZucVODTRjH8HqS6BJ+pXrEeeWyPL2RdF82taBjP7SIP Gj7iQ88af6zLGpN660D9CZ7b+Y3v9aUAkwdWIAj/oqzR699qY6Hl/5g7SAX0ew8TAn gEEOQwwYS2L0g== Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 719986559A for ; Tue, 28 Jun 2022 11:07:15 +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="yHOiDYsQ"; dkim-atps=neutral Received: by mail-wr1-x431.google.com with SMTP id s1so16655078wra.9 for ; Tue, 28 Jun 2022 02:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thaumatec-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZYSh6TtUV6Id9lYrR/VR4whhLRNG6xChpZLV3FOUjj4=; b=yHOiDYsQ/YJF9PfdUKPVbA/N2Zsp405kpkBNFoCHhxDcz/qncX14londaGcbcUcpCC ail24whucfNovrfAbYlLyKeL9TQPpw2F4cWQo+RVduoAWuA5xvKZehZ+MI1b9JGzTqIE vR9huRZEkVmL97Tz2FLQNAnUmOUR74vNnTYanvgNhb3A/q1+HiwbxVgq1Tr3kYMJZDwP hbSlEp39TiUQMAgrmxhfy1msp+0vZnEcxAQGhmyDlgSrkxdDZIr2bsSbBPXgV79zQ7Lv hl5iGOjNaL2pcwwYEkggJFJXaGBCnehcTHOnLrWXqYgJ1k1zFWYf88S81G/2/Ayi+TXC UA9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZYSh6TtUV6Id9lYrR/VR4whhLRNG6xChpZLV3FOUjj4=; b=bQ57uJiQE0ASInCHtJJfXR0zBnTJZf6eKkitMKIZi5tLH/HGZ/gfH9qiwsDojmUF42 2Jbo3gDbK38fxH0dP1fI3AfhVKSGd7F81YB2QMujx5sfCyWQck8Rqe2sJXCpUCdO9jaN I+nbMqYcsa0HsP2bfIg3D7TYFFnhXUH2KiJoFJsmTEOQcgSoFAI4IPhBfrh12UQLZMsv 7Ka6VJo6R/4q1AZ543/M2d+PXMoyWIqr4vlM7xrMpLbmY0pg8h/MAF8D8I5c9jQnex5K ERIklWoKIqYYYXXbfSwvzPcy2/R9seDiqFsVZXXtpTrOIc06NVvx5GOqThMVL9/SipjU SDVw== X-Gm-Message-State: AJIora/VoxgtexoKXBcQV+wIO6IY/Bx/k8hYoT2B5h5bpLR+E+q2VKld DpbLzZw4BDjCQwVi+IQ4Dkg634cKA3mCvg== X-Google-Smtp-Source: AGRyM1tTC6UUkZIFqd7NZR6fpldiQQZwEaeDHDF1Z5r8e9TvsG49JVOS2DUPNoUskBTHH/FEBckYig== X-Received: by 2002:a5d:47aa:0:b0:21b:ad9a:d48c with SMTP id 10-20020a5d47aa000000b0021bad9ad48cmr17919069wrb.610.1656407235061; Tue, 28 Jun 2022 02:07:15 -0700 (PDT) Received: from localhost.localdomain (ip092042140082.rev.nessus.at. [92.42.140.82]) by smtp.gmail.com with ESMTPSA id r68-20020a1c2b47000000b0039c4b518df4sm20126972wmr.5.2022.06.28.02.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jun 2022 02:07:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 28 Jun 2022 11:06:56 +0200 Message-Id: <20220628090656.19572-4-dse@thaumatec.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628090656.19572-1-dse@thaumatec.com> References: <20220628090656.19572-1-dse@thaumatec.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] libcamera: rkisp1: Control the lens 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" Check if lens are available and have ability to control the focus. Connect IPA setLensControls() signal to the pipeline slot that controls the lens. If lens are valid, allow changing the focus from IPA by emitting signal to the pipeline. Signed-off-by: Daniel Semkowicz --- include/libcamera/ipa/rkisp1.mojom | 1 + src/ipa/rkisp1/ipa_context.h | 4 +++ src/ipa/rkisp1/rkisp1.cpp | 36 ++++++++++++++++++++++++ src/libcamera/pipeline/rkisp1/rkisp1.cpp | 1 + 4 files changed, 42 insertions(+) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index e3537385..ee06a6b0 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 f387cace..4b199048 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -41,6 +41,10 @@ struct IPASessionConfiguration { }; struct IPAFrameContext { + struct { + uint32_t focus; + } af; + struct { uint32_t exposure; double gain; diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 3511a054..2447f4f4 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -59,6 +60,8 @@ public: void processStatsBuffer(const uint32_t frame, const uint32_t bufferId, const ControlList &sensorControls) override; private: + bool validateLensControls(const ControlInfoMap &lensControls); + void setControls(unsigned int frame); void prepareMetadata(unsigned int frame, unsigned int aeState); @@ -66,6 +69,7 @@ private: std::map mappedBuffers_; ControlInfoMap sensorCtrls_; + std::optional lensCtrls_; /* Camera sensor controls. */ bool autoExposure_; @@ -162,6 +166,14 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, return -EINVAL; } + auto lensControls = entityControls.find(1); + if (lensControls != entityControls.end()) { + if (validateLensControls(lensControls->second)) + lensCtrls_ = lensControls->second; + else + LOG(IPARkISP1, Error) << "Lens control validation failed."; + } + autoExposure_ = true; int32_t minExposure = itExp->second.min().get(); @@ -205,6 +217,23 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info, return 0; } +bool IPARkISP1::validateLensControls(const ControlInfoMap &lensControls) +{ + static const uint32_t ctrls[] = { + V4L2_CID_FOCUS_ABSOLUTE, + }; + + for (auto c : ctrls) { + if (lensControls.find(c) == lensControls.end()) { + LOG(IPARkISP1, Error) << "Unable to find lens control " + << utils::hex(c); + return false; + } + } + + return true; +} + void IPARkISP1::mapBuffers(const std::vector &buffers) { for (const IPABuffer &buffer : buffers) { @@ -289,6 +318,13 @@ void IPARkISP1::setControls(unsigned int frame) ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); setSensorControls.emit(frame, ctrls); + + if (lensCtrls_) { + ControlList lensCtrls(*lensCtrls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, + static_cast(context_.frameContext.af.focus)); + 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 363273b2..55d3e3a9 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -320,6 +320,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);