From patchwork Thu Oct 17 12:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21651 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 CB0EFC32FC for ; Thu, 17 Oct 2024 12:46:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC85265387; Thu, 17 Oct 2024 14:46:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PLtcRFdd"; dkim-atps=neutral Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B867A6353B for ; Thu, 17 Oct 2024 14:46:22 +0200 (CEST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2fb4fa17044so10188681fa.3 for ; Thu, 17 Oct 2024 05:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729169181; x=1729773981; darn=lists.libcamera.org; 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=gf//YmGItTJZqmMJGI0RLt5WZowlPXW4ukhDfXgr89M=; b=PLtcRFddVXzhQMbFRuOKLwt0OGFcJB9ZMMGP6pBncvVqGyKlXpBdgBuZ39vbnVzA7Z K16QQeT+Y4k+SrI3C7S6zhfnXdsyg2M5r8X8BjEYw+tpF67dGQaDJsEwALxcqZB7ZDFP oM7Df0mj4ysa8I6u4o+26oQSYawFgh1YQyXlaz5Oq3EwjCjg+osTLGe/j5S33nMIz/pQ dpQC1eQMQvw1v7exRAEIHPH+bAxMm28/AFmz7ISoEc9PDVw0Rha5jw2Ncyxs0m26wuwg I4hXr2rbQZvK8y00CyC8gf+NJRqnDQjx4c4mTf24b4p43AzHM8isCkfNodAyujrTRhJb sQGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729169181; x=1729773981; 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=gf//YmGItTJZqmMJGI0RLt5WZowlPXW4ukhDfXgr89M=; b=HXjTnTWI8x2dovHLwKJ7nxJvr/PtpzM9dwi8mkLZcRLfkv5dmhnrPU4sL4MwKLd26z Xm2VNY017Q1iCS7pmST7sEVv/7ew1X0lGoqdGMgCsk2c4XvkFetw2UOS6NvgcT7c6ouq FsGfwcKRtpkAdIKFDmFUIZNlM47m/aB3XCbig8PbS/7qflBVWAt1qzIzkSEvOQaPIEmw HiPoTvlzrWPvhyNWGrZl2SnqWHA+Vm7n08NZaRgoFS81tLC7osJPFRvj5SNObGNPnQdE 8WPnguZy8pUQYH8Wsz+l+/o3xSncUYTxAY9NRkvvbbuuGJh3jGvXxJBKj9whcUlztum0 9ATw== X-Gm-Message-State: AOJu0YyZOJhRWdSFxNb6RS1f97kkg4vgG9UB2sk9ow8QeCgHWnW0z19Q bjFklOHHKR/H3Dg2FDki7t8XS84qhGMDdzJUjV2kY/8aKJ4CNQdDA8mxJQ== X-Google-Smtp-Source: AGHT+IEOGj9OnSDq497BhqP4ufqC7mYZI70EH7SkQvVrdOsxkqjHbYpAyGpPjCqM6yrFAaO9J16ShA== X-Received: by 2002:a2e:bea7:0:b0:2fb:5ebe:ed40 with SMTP id 38308e7fff4ca-2fb5ebef039mr57788551fa.15.1729169181057; Thu, 17 Oct 2024 05:46:21 -0700 (PDT) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fb5d0fb634sm7374221fa.11.2024.10.17.05.46.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 05:46:20 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Mikhail Rudenko Subject: [PATCH 1/3] ipa: rkisp1: agc: Use better default value for analogue gain Date: Thu, 17 Oct 2024 15:46:11 +0300 Message-ID: <20241017124613.3853273-2-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241017124613.3853273-1-mike.rudenko@gmail.com> References: <20241017124613.3853273-1-mike.rudenko@gmail.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" At present, analogue gain in IPA context is initialized to the minimum sensor gain in configure(). Many sensors report minimum analogue gain of 0, which is by no means a sane default. Use a reasonable default of 1.0 instead. Also move the default exposure to a named constant. Signed-off-by: Mikhail Rudenko --- src/ipa/rkisp1/algorithms/agc.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 17d074d9..339cddef 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -30,9 +30,13 @@ namespace libcamera { using namespace std::literals::chrono_literals; +using utils::Duration; namespace ipa::rkisp1::algorithms { +constexpr double defaultAnalogueGain = 1.0; +constexpr Duration defaultExposureTime = 10.0ms; + /** * \class Agc * \brief A mean-based auto-exposure algorithm @@ -164,9 +168,9 @@ int Agc::init(IPAContext &context, const YamlObject &tuningData) int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) { /* Configure the default exposure and gain. */ - context.activeState.agc.automatic.gain = context.configuration.sensor.minAnalogueGain; + context.activeState.agc.automatic.gain = defaultAnalogueGain; context.activeState.agc.automatic.exposure = - 10ms / context.configuration.sensor.lineDuration; + defaultExposureTime / context.configuration.sensor.lineDuration; context.activeState.agc.manual.gain = context.activeState.agc.automatic.gain; context.activeState.agc.manual.exposure = context.activeState.agc.automatic.exposure; context.activeState.agc.autoEnabled = !context.configuration.raw; From patchwork Thu Oct 17 12:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21652 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 08B74C32FD for ; Thu, 17 Oct 2024 12:46:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4ADD66538B; Thu, 17 Oct 2024 14:46:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JrgaYjmA"; dkim-atps=neutral Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1FC8E6353B for ; Thu, 17 Oct 2024 14:46:24 +0200 (CEST) Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2fb587d0436so10037341fa.2 for ; Thu, 17 Oct 2024 05:46:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729169183; x=1729773983; darn=lists.libcamera.org; 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=mBo7mhFEAoREmEgOkqNk+zC0d3g9ZeqMWWN8cDklThM=; b=JrgaYjmAOMyONe78+DMrcnXnagstuvsCxB+CV0H4LoWQulZMJ+Ple4Ly4znPgaB2l3 u3oOmdrOCgB5MWP2tQh5AGv1GSaf6ePxOXL+aORgQH+yeRmt8X9yau/+svirr4/DBqHJ zkEbQvsK+AjrVU1DXHLkfGakLi17JJAwDBSLldQZAl7mZCC7iJahZ1Qd3jt+Cp90UNF6 +Q3ZO4dTahhAPT6WHcgTNlqnKOELBJjp5HT5c8k34l4XdBnzshUCM/fJZBqRDPO3poCq KNvx6nMnegIyeeEMZ/M5DfbbNujRRa0viqq5V6al8aP1la31FP4qx3rNdzbAAj0/hp8X Em4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729169183; x=1729773983; 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=mBo7mhFEAoREmEgOkqNk+zC0d3g9ZeqMWWN8cDklThM=; b=UwXPl/QcEiqphqVJ1PhimOE4wXwYLh7eMNCpdl6N0zOJjZdALoJPGgxAfNMDCHTV4b U6GnWox3hLchD0KvsA3WxSWCCUOhUgQNyUdFvYz1NP+fh+6qwXmoS1sN5qnbz+mm613h 5E406jaNrtz+/3EfZeOT/iIi/clpFhV/rBq7D35+FuyQC9n0QciOeYpMzlg3Eim2k8JF 5hJzwlwxFva1W/9owH7XN3X8WF2be/9kR7wofSLIhyHNOZf8q+Ug796AfCx+7pKHcu1P zUtUTFxCXOZj7k7aNHYHyWpn0YJ98lWAxoPbu0UCSY1XB2NVQIN4uvGDhqL98NmfFcOY aJ/A== X-Gm-Message-State: AOJu0YwYHzSH73BVOxv5C1+iJvI6jybAjlf8ehPPiWPrc+08uKIZMUhh iusnrq+2nD4VIrT9mFY9/fd02ccxKnCwXWwWAgTrSAs9UpYZC9k/nRrGRw== X-Google-Smtp-Source: AGHT+IGj8zzuNnD7lSLbU0PSJcez3rYW1i7t26X2GliS7RBmiAEPWwUxW5oraYqJxeG/+ReLGduKLA== X-Received: by 2002:a2e:719:0:b0:2fb:3d1d:dd96 with SMTP id 38308e7fff4ca-2fb3f1b477dmr80151941fa.20.1729169182589; Thu, 17 Oct 2024 05:46:22 -0700 (PDT) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2fb5d0fdd34sm7173311fa.12.2024.10.17.05.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 05:46:22 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Mikhail Rudenko Subject: [PATCH 2/3] utils: ipc: Allow start method with output parameters in IPA proxies Date: Thu, 17 Oct 2024 15:46:12 +0300 Message-ID: <20241017124613.3853273-3-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241017124613.3853273-1-mike.rudenko@gmail.com> References: <20241017124613.3853273-1-mike.rudenko@gmail.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" At present IPA proxy and IPA proxy worker templates generate incorrect code when IPA start method has multiple output parameters and no input parameters. Fix that. Also merge repetitive cases of start function returning void/non-void in IPA proxy template. Signed-off-by: Mikhail Rudenko --- .../libcamera_templates/module_ipa_proxy.h.tmpl | 11 ++++------- .../module_ipa_proxy_worker.cpp.tmpl | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl index e213b18a..138832b5 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy.h.tmpl @@ -95,13 +95,10 @@ private: {%- elif method.mojom_name == "start" %} {{proxy_funcs.func_sig(proxy_name, method, "", false)|indent(16)}} { -{%- if method|method_return_value != "void" %} - return ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}}); -{%- else %} - ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}} - {{- ", " if method|method_param_outputs|params_comma_sep -}} - {{- method|method_param_outputs|params_comma_sep}}); -{%- endif %} + {{ "return" if method|method_return_value != "void" }} ipa_-> + {{- method.mojom_name}}({{method.parameters|params_comma_sep}} + {{- ", " if method|method_param_outputs|params_comma_sep and method.parameters|params_comma_sep -}} + {{- method|method_param_outputs|params_comma_sep}}); } {%- endif %} {%- endfor %} diff --git a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl index 1f990d3f..6bc11a09 100644 --- a/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl +++ b/utils/codegen/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl @@ -93,7 +93,7 @@ public: {{method|method_return_value}} _callRet = {%- endif -%} ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}} -{{- ", " if method|method_param_outputs|params_comma_sep -}} +{{- ", " if method|method_param_outputs|params_comma_sep and method.parameters|params_comma_sep -}} {%- for param in method|method_param_outputs -%} &{{param.mojom_name}}{{", " if not loop.last}} {%- endfor -%} From patchwork Thu Oct 17 12:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 21653 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 92F8FC32FE for ; Thu, 17 Oct 2024 12:46:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 53D156538A; Thu, 17 Oct 2024 14:46:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ncyCWVrS"; dkim-atps=neutral Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 21A2365388 for ; Thu, 17 Oct 2024 14:46:26 +0200 (CEST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-539f0f9ee49so1086963e87.1 for ; Thu, 17 Oct 2024 05:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729169185; x=1729773985; darn=lists.libcamera.org; 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=RZA4Fbi06ANAkJZDjKo3YmQxc3CPBlt20nPCs8P4ek8=; b=ncyCWVrSd3wQ6vDbfg/WWmQI0fb5UeHku2jNap9NHrz3JWXa5SiWvFdtGkvbNhqlil 57m03Nchzc/RcBCMA/oF6O2ZOfA+KyDGuTMVWxWXDWQDS+VqTDYxqbc/ax3LPmF/nWea 1pEOwf0E6tRSIKwR0LaSZFRYMnncs7WHzJ7cTDQUzQ2SKwkF6h8+LTXTpUlJfrhXJddQ BTFWdgP+B8qDBOIj0UxWFu5/Rs1Bqsn7gP5Bqx1feK3Ir3y50WL6N8raNlt73xaXvfU2 cuZU1F8Jr78CDWBA6QwyvPz57sSka74Ap7o/lsrKTlFs63ziiyg5NydgyyzoAUHkXoFK dBSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729169185; x=1729773985; 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=RZA4Fbi06ANAkJZDjKo3YmQxc3CPBlt20nPCs8P4ek8=; b=nW4SpHvjxKYLs3jgUMipsTp3b2GJhQsk0HOOlzMq4SFQf28fz9a63UcqYzVLixRAkk mZ064h4d+X2JMJ8XyqlAHvqPTBsDbUREucCI/CFOkQK3H4RO5xyzSsRQqEhpA5JfJ0RT wnWh9H7BR5vFbNtMi+pejPqLsXI9Jfw4bjln+Xlmh8TsV5sogGcskxLXEbRzVY/VFuxf N1pDCvhQ41wEZxnKJyN2Ce7B6hzG+L3Q1YKxy1BNXQmvJGCmkVKM8oVuy2O3oFy+bWZY C0tP9/6pkcMIoHWMH+6jb7f+tkCXCQYiLbJIwmu79F4VT9/0htWrvFTqrYxgPbod5smc 1CCw== X-Gm-Message-State: AOJu0YyxlzHhkABWfLz1hp/a5+uUs3f3jau6XsXw19ENKsO24n9shOa3 wxHI3Cc1inZ/Gic44bbHyfxO5n+BZtvKd0+glNgTxsScp13plDYxBBm1AA== X-Google-Smtp-Source: AGHT+IHzyWKq2jdOP9vbS1gsFA3MZC1oRTqlJYIvfj7J3tTcuaXjigtrQRTs5Z/EK8gRzAdvwSCjcg== X-Received: by 2002:a05:6512:3b97:b0:539:e333:1822 with SMTP id 2adb3069b0e04-53a03f070eamr4838648e87.4.1729169184239; Thu, 17 Oct 2024 05:46:24 -0700 (PDT) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-539ffff391fsm771436e87.125.2024.10.17.05.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 05:46:23 -0700 (PDT) From: Mikhail Rudenko To: libcamera-devel@lists.libcamera.org Cc: Mikhail Rudenko Subject: [PATCH 3/3] rkisp1: synchronize sensor controls with IPA Date: Thu, 17 Oct 2024 15:46:13 +0300 Message-ID: <20241017124613.3853273-4-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241017124613.3853273-1-mike.rudenko@gmail.com> References: <20241017124613.3853273-1-mike.rudenko@gmail.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When IPA AGC active state is initialized in configure() method, it may fall out of sync with actual sensor controls and initial values in the delayed controls. Fix this by sending updated controls to the pipeline handler on first start() after configure(). Also reset delayedCtrls_ on start to make it capture the updated control values. Signed-off-by: Mikhail Rudenko --- include/libcamera/ipa/rkisp1.mojom | 2 +- src/ipa/rkisp1/ipa_context.h | 2 ++ src/ipa/rkisp1/rkisp1.cpp | 19 +++++++++++++++---- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 6 +++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 80d54a03..09900742 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -20,7 +20,7 @@ interface IPARkISP1Interface { libcamera.IPACameraSensorInfo sensorInfo, libcamera.ControlInfoMap sensorControls) => (int32 ret, libcamera.ControlInfoMap ipaControls); - start() => (int32 ret); + start() => (int32 ret, libcamera.ControlList sensorControls); stop(); configure(IPAConfigInfo configInfo, diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index e274d9b0..e07a5cdb 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -191,6 +191,8 @@ struct IPAContext { /* Interface to the Camera Helper */ std::unique_ptr camHelper; + + bool sensorControlsNeedSync; }; } /* namespace ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 9e161cab..680a7eee 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -55,7 +55,7 @@ public: const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls) override; - int start() override; + int start(ControlList *sensorControls) override; void stop() override; int configure(const IPAConfigInfo &ipaConfig, @@ -124,7 +124,7 @@ const ControlInfoMap::Map rkisp1Controls{ } /* namespace */ IPARkISP1::IPARkISP1() - : context_({ {}, {}, {}, {}, { kMaxFrameContexts }, {}, {} }) + : context_({ {}, {}, {}, {}, { kMaxFrameContexts }, {}, {}, false }) { } @@ -208,10 +208,19 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision, return 0; } -int IPARkISP1::start() +int IPARkISP1::start(ControlList *sensorControls) { - setControls(0); + if (context_.sensorControlsNeedSync) { + const auto &agc = context_.activeState.agc; + uint32_t exposure = agc.automatic.exposure; + uint32_t gain = context_.camHelper->gainCode(agc.automatic.gain); + *sensorControls = ControlList{ sensorControls_ }; + sensorControls->set(V4L2_CID_EXPOSURE, static_cast(exposure)); + sensorControls->set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain)); + + context_.sensorControlsNeedSync = false; + } return 0; } @@ -290,6 +299,8 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig, return ret; } + context_.sensorControlsNeedSync = true; + return 0; } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 42961c12..18d98547 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -943,6 +943,7 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL { RkISP1CameraData *data = cameraData(camera); utils::ScopeExitActions actions; + ControlList sensorControls; int ret; /* Allocate buffers for internal pipeline usage. */ @@ -951,7 +952,7 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL return ret; actions += [&]() { freeBuffers(camera); }; - ret = data->ipa_->start(); + ret = data->ipa_->start(&sensorControls); if (ret) { LOG(RkISP1, Error) << "Failed to start IPA " << camera->id(); @@ -961,6 +962,9 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] const ControlL data->frame_ = 0; + data->sensor_->setControls(&sensorControls); + data->delayedCtrls_->reset(); + if (!isRaw_) { ret = param_->streamOn(); if (ret) {