From patchwork Fri Oct 29 11:59:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14418 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 E5C0DBDB1C for ; Fri, 29 Oct 2021 12:00:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A7403600BF; Fri, 29 Oct 2021 14:00:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mORXNa/D"; dkim-atps=neutral Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7A6FD600B8 for ; Fri, 29 Oct 2021 14:00:09 +0200 (CEST) Received: by mail-pg1-x52c.google.com with SMTP id j9so1543267pgh.1 for ; Fri, 29 Oct 2021 05:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tR9zsB15kCVtnpZ46suSVvmTtEQhG1D1AqAr7QKKInw=; b=mORXNa/DrBx60QPYtycNOWjs6W9c+t9QJayhB6FQgv109VAcp3RCjXXaq05IGkbIQC nCckyX/lREnWuZI+EUEBmawL+9NEHd/tSiyuHvZK7BzSCuShbHy3AedoQz0oKsgDHOp9 SbCsYdPuxQuwY5aXTa74oi/YCafPO9tl2NllY= 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:mime-version :content-transfer-encoding; bh=tR9zsB15kCVtnpZ46suSVvmTtEQhG1D1AqAr7QKKInw=; b=XQ33bYaVB2BmOFUr+CFG9x9VKE+1fmgwrzWJoNt1Y4jwbXth5zZcNJcA2ulSaICdvj kktihtBt8rKCJaIUmo0rXIDut6YHgnGRhjBv40sYnONtQxxPs83IN6tQH/kFIhSAvAhh RNEjbGMtDFM4loM0LP0JHQMgCOpToLqFWXPWRy89fdUxACBq+DcLcDE+aeg10m8YBUuu vPJAIGALESSbfe7YxtwuHbtnntWH3KNyLUIbDG1g05QAgtqWBpR3/t/0Kw1VI2CJj24d wbJp9FcR0E+3qCfYgNJ1ew6/U7GLbQW9PNu/vV4FS2FLFUyM2nfvndYx1G52YWOnQJrt PmBA== X-Gm-Message-State: AOAM530Q4bNAMPjKr1CcHglLBoIeDd9W6VUp6Vg2cixQqXJNKa9MhdK5 eJZLwP86DkgEHFHtNTGz5bQW5nDv+fV3vovz X-Google-Smtp-Source: ABdhPJwAtpqTFc/Pl7w6Ca+/i6M99yTY2JQRWdo11JggqePFODD5+qFQNfyA46vcOgtekXGF/tVSNA== X-Received: by 2002:a63:9554:: with SMTP id t20mr7760818pgn.255.1635508804735; Fri, 29 Oct 2021 05:00:04 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id n9sm11587805pjk.3.2021.10.29.05.00.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:04 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 19:59:56 +0800 Message-Id: <20211029120001.2469018-1-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/6] ipu3: Use ia_aiq_frame_use_preview as default mode for AIQ 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" The frame use mode is set according to Android Capture Intent in Intel HAL's implememtation. The current default mode ia_aiq_frame_use_still is only used with the single capture request. For preview use case, it has hard time converging AE and AF smoothly. Change the default mode to ia_aiq_frame_use_preview for better user experience. Signed-off-by: Han-Lin Chen Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- aiq/aiq_input_parameters.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp index 36e2b07..bc87b31 100644 --- a/aiq/aiq_input_parameters.cpp +++ b/aiq/aiq_input_parameters.cpp @@ -132,7 +132,7 @@ void AiqInputParameters::setAeAwbAfDefaults() { /*Ae Params */ aeInputParams.num_exposures = NUM_EXPOSURES; - aeInputParams.frame_use = ia_aiq_frame_use_still; + aeInputParams.frame_use = ia_aiq_frame_use_preview; aeInputParams.flash_mode = ia_aiq_flash_mode_off; aeInputParams.operation_mode = ia_aiq_ae_operation_mode_automatic; aeInputParams.metering_mode = ia_aiq_ae_metering_mode_evaluative; @@ -153,7 +153,7 @@ void AiqInputParameters::setAeAwbAfDefaults() aeInputParams.manual_convergence_time = -1; /* AWB Params */ - awbParams.frame_use = ia_aiq_frame_use_still; + awbParams.frame_use = ia_aiq_frame_use_preview; awbParams.scene_mode = ia_aiq_awb_operation_mode_auto; awbParams.manual_convergence_time = -1.0; awbParams.manual_cct_range = nullptr; @@ -161,7 +161,7 @@ void AiqInputParameters::setAeAwbAfDefaults() /* AF Params */ afParams = { - ia_aiq_frame_use_still, 0, 1500, + ia_aiq_frame_use_preview, 0, 1500, ia_aiq_af_operation_mode_auto, ia_aiq_af_range_normal, ia_aiq_af_metering_mode_auto, @@ -172,11 +172,11 @@ void AiqInputParameters::setAeAwbAfDefaults() /* GBCE Params */ gbceParams.gbce_level = ia_aiq_gbce_level_bypass; gbceParams.tone_map_level = ia_aiq_tone_map_level_default; - gbceParams.frame_use = ia_aiq_frame_use_still; + gbceParams.frame_use = ia_aiq_frame_use_preview; gbceParams.ev_shift = 0; /* SA Params */ - saParams.frame_use = ia_aiq_frame_use_still; + saParams.frame_use = ia_aiq_frame_use_preview; } } /* namespace ipa::ipu3::aiq */ From patchwork Fri Oct 29 11:59:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14419 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 71DDBC324E for ; Fri, 29 Oct 2021 12:00:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0DCC9600BC; Fri, 29 Oct 2021 14:00:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WD/YeaBq"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CCBBB600B8 for ; Fri, 29 Oct 2021 14:00:09 +0200 (CEST) Received: by mail-pf1-x442.google.com with SMTP id m14so9010430pfc.9 for ; Fri, 29 Oct 2021 05:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9JZPwUj7sK91HcP0MWC8uO8gM6PfU3AIrpnW7+5lbN0=; b=WD/YeaBqq8W1MN86NegkqHkgFhayZ5BcjfNZMeL9UuQASLBFBXa3SIIl79PaMfTipk 1OtKr8NpZSlAQdcUOKDe7llthva/6+Hx8ElZ7r4y2zhfMzB7W4laBQDzUBTL4pi/m1jY FuZv/eNISkQR75VELBdhXjdiylCK02deATHd8= 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=9JZPwUj7sK91HcP0MWC8uO8gM6PfU3AIrpnW7+5lbN0=; b=DZ1UMlFgkMgKm3EAB7zWlRD/ELtalv/Y+9wDRg8BzWZ91v8bTFzg1iWUgDjCkAc6d0 Oxxu9sT6f6NDESKUKO9z5D5YVqM1shtSXLqIPA+jSuCAteuCYjvc1ZymqkY4Ha/OVERr URKJm6XWLKPvDmjYl5sVRc/mDZQ+ZmMOw+RR1icz2OJrWDoL53kFROFMmIcyk4MOGKYq n3Pibmd5Ee5ZlrLvptifYUIJ5tsvITBQqwC8afKbz2Kq3JMEUWK6P/FJez2c2R7g5KzL n8VpIpDk5pqvZh3wzYsm/rD34V0kmv/vjqPcCTEOvYKMSAx0OkpUShp3WcsKirUkcpAN RGAA== X-Gm-Message-State: AOAM532D5YoJPqGi9idQxKojjQTO8Mn5yMuQIewEMwO7fykFP9Oap7xK 6/6lDguxHs9KYxtjApm1YhA/PRG82805S5BT X-Google-Smtp-Source: ABdhPJy6Q6BUQxSlOwXjB1dfQ85vbH16ATrBS59weJ7QgnqSpSRBNNWMMUKHxy80WRXPkyiAYdaXdA== X-Received: by 2002:a05:6a00:1906:b0:44c:b35d:71a8 with SMTP id y6-20020a056a00190600b0044cb35d71a8mr10586116pfi.51.1635508807145; Fri, 29 Oct 2021 05:00:07 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id l14sm10590902pjq.13.2021.10.29.05.00.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:06 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 19:59:57 +0800 Message-Id: <20211029120001.2469018-2-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211029120001.2469018-1-hanlinchen@chromium.org> References: <20211029120001.2469018-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/6] ipu3: Add a class AiqResultsRingBuffer to reserve AiqResults history 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" The AIQ algorithm expects the statstistics comes with the effective AiqResults applied on the sensor, which may not always be the latest AiqResults, since pipeline handler may delay setting the controls based on SOF. Add a class to reserve the history of the AiqResults generated for previous frames, so IPA can have a chance to look for the suitable one backwards. Signed-off-by: Han-Lin Chen --- aiq/aiq_results.cpp | 85 ++++++++++++++++++++++++++++++++++++++++----- aiq/aiq_results.h | 38 +++++++++++++++----- 2 files changed, 107 insertions(+), 16 deletions(-) diff --git a/aiq/aiq_results.cpp b/aiq/aiq_results.cpp index f727f36..deda4be 100644 --- a/aiq/aiq_results.cpp +++ b/aiq/aiq_results.cpp @@ -63,7 +63,34 @@ AiqResults::AiqResults() sa_.channel_b = channelB_.data(); } -void AiqResults::setAe(ia_aiq_ae_results *ae) +AiqResults::AiqResults(const AiqResults &other) + :AiqResults() +{ + setAe(&other.ae_); + setAf(&other.af_); + setAfBracket(&other.afBracket_); + setAwb(&other.awb_); + setGbce(&other.gbce_); + setDetectedSceneMode(other.detectedSceneMode_); + setPa(&other.pa_); + setSa(&other.sa_); +} + +AiqResults& AiqResults::operator=(const AiqResults &other) +{ + setAe(&other.ae_); + setAf(&other.af_); + setAfBracket(&other.afBracket_); + setAwb(&other.awb_); + setGbce(&other.gbce_); + setDetectedSceneMode(other.detectedSceneMode_); + setPa(&other.pa_); + setSa(&other.sa_); + + return *this; +} + +void AiqResults::setAe(const ia_aiq_ae_results *ae) { /* Todo: Potentially Requires copying * ia_aiq_aperture_control *aperture_control; @@ -121,7 +148,7 @@ void AiqResults::setAe(ia_aiq_ae_results *ae) } } -void AiqResults::setAf(ia_aiq_af_results *af) +void AiqResults::setAf(const ia_aiq_af_results *af) { ASSERT(af); @@ -133,7 +160,7 @@ void AiqResults::setAf(ia_aiq_af_results *af) af_.final_lens_position_reached = af->final_lens_position_reached; } -void AiqResults::setAfBracket(ia_aiq_af_bracket_results *afBracket) +void AiqResults::setAfBracket(const ia_aiq_af_bracket_results *afBracket) { ASSERT(afBracket); @@ -145,7 +172,7 @@ void AiqResults::setAfBracket(ia_aiq_af_bracket_results *afBracket) afBracket_.lens_positions_bracketing = afBracket->lens_positions_bracketing; } -void AiqResults::setAwb(ia_aiq_awb_results *awb) +void AiqResults::setAwb(const ia_aiq_awb_results *awb) { ASSERT(awb); @@ -157,7 +184,7 @@ void AiqResults::setAwb(ia_aiq_awb_results *awb) awb_.distance_from_convergence = awb->distance_from_convergence; } -void AiqResults::setGbce(ia_aiq_gbce_results *gbce) +void AiqResults::setGbce(const ia_aiq_gbce_results *gbce) { ASSERT(gbce); @@ -181,12 +208,12 @@ void AiqResults::setGbce(ia_aiq_gbce_results *gbce) } } -void AiqResults::setDetectedSceneMode(ia_aiq_scene_mode dsm) +void AiqResults::setDetectedSceneMode(const ia_aiq_scene_mode dsm) { detectedSceneMode_ = dsm; } -void AiqResults::setPa(ia_aiq_pa_results *pa) +void AiqResults::setPa(const ia_aiq_pa_results *pa) { ASSERT(pa); @@ -234,7 +261,7 @@ void AiqResults::setPa(ia_aiq_pa_results *pa) pa_.brightness_level = pa->brightness_level; } -void AiqResults::setSa(ia_aiq_sa_results *sa) +void AiqResults::setSa(const ia_aiq_sa_results *sa) { ASSERT(sa && sa->channel_r && sa->channel_gr && sa->channel_gb && sa->channel_b); @@ -275,6 +302,48 @@ void AiqResults::setSa(ia_aiq_sa_results *sa) sa_.frame_params = sa->frame_params; } +AiqResults& AiqResultsRingBuffer::operator[](unsigned int index) +{ + return std::array::operator[](index % bufferSize); +} + +const AiqResults& AiqResultsRingBuffer::operator[](unsigned int index) const +{ + return std::array::operator[](index % bufferSize); +} + +void AiqResultsRingBuffer::Reset() +{ + start_ = end_ = size_ = 0; +} + +void AiqResultsRingBuffer::Push(const AiqResults& result) +{ + operator[](end_) = result; + end_ = (end_ + 1) % bufferSize; + size_ = std::min(size_ + 1, bufferSize); + if (size_ == bufferSize) { + start_ = end_; + } +} + +AiqResults& AiqResultsRingBuffer::searchBackward( + const std::function pred, AiqResults& def) +{ + if (size_ == 0) + return def; + + unsigned int i = (end_ - 1) % bufferSize; + while (i != start_) { + if (pred(operator[](i))) { + return operator[](i); + } + i = --i % bufferSize; + } + + return def; +} + } /* namespace ipa::ipu3::aiq */ } /* namespace libcamera */ diff --git a/aiq/aiq_results.h b/aiq/aiq_results.h index ae19a6c..7005a47 100644 --- a/aiq/aiq_results.h +++ b/aiq/aiq_results.h @@ -8,6 +8,8 @@ * of the aiq result structures. */ +#include +#include #include #include @@ -37,6 +39,8 @@ class AiqResults { public: AiqResults(); + AiqResults(const AiqResults &other); + AiqResults &operator=(const AiqResults &other); const ia_aiq_ae_results *ae() { return &ae_; } ia_aiq_af_results *af() { return &af_; } @@ -46,14 +50,14 @@ public: const ia_aiq_pa_results *pa() { return &pa_; } const ia_aiq_sa_results *sa() { return &sa_; } - void setAe(ia_aiq_ae_results *ae); - void setAf(ia_aiq_af_results *af); - void setAfBracket(ia_aiq_af_bracket_results *afBracket); - void setAwb(ia_aiq_awb_results *awb); - void setGbce(ia_aiq_gbce_results *gbce); - void setDetectedSceneMode(ia_aiq_scene_mode dsm); - void setPa(ia_aiq_pa_results *pa); - void setSa(ia_aiq_sa_results *sa); + void setAe(const ia_aiq_ae_results *ae); + void setAf(const ia_aiq_af_results *af); + void setAfBracket(const ia_aiq_af_bracket_results *afBracket); + void setAwb(const ia_aiq_awb_results *awb); + void setGbce(const ia_aiq_gbce_results *gbce); + void setDetectedSceneMode(const ia_aiq_scene_mode dsm); + void setPa(const ia_aiq_pa_results *pa); + void setSa(const ia_aiq_sa_results *sa); private: ia_aiq_ae_results ae_; @@ -109,6 +113,24 @@ private: std::vector channelGb_; }; +static constexpr unsigned int bufferSize = 16; +class AiqResultsRingBuffer: public std::array +{ +public: + AiqResults &operator[](unsigned int index); + const AiqResults &operator[](unsigned int index) const; + void Reset(); + void Push(const AiqResults& result); + unsigned int size() { return size_; } + AiqResults& searchBackward(const std::function pred, + AiqResults& def); + +private: + unsigned int start_ = 0; + unsigned int end_ = 0; + unsigned int size_ = 0; +}; + } /* namespace libcamera::ipa::ipu3::aiq */ #endif /* IPA_IPU3_AIQ_RESULTS_H */ From patchwork Fri Oct 29 11:59:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14420 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 02277BDB1C for ; Fri, 29 Oct 2021 12:00:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF856600C1; Fri, 29 Oct 2021 14:00:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="FiU4uwTk"; dkim-atps=neutral Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 992D1600BD for ; Fri, 29 Oct 2021 14:00:11 +0200 (CEST) Received: by mail-pj1-x1044.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so7231239pjb.3 for ; Fri, 29 Oct 2021 05:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kOqdl60WvBSlqN+8QOZ7NkZ/E4N8GLwa6xp0qkQQXgE=; b=FiU4uwTkLQYDwwDloX1eYRhmdQ1zn1OHNtVthZdKG75OLipUFQA0gwWoigHvYtOLWY v2AbX+b3pAgXoVEGCouB/8l5KlnJi8RBgTkNZ4guCarou7WlyKhAv/DDyP28TvAo/5oS F/WvXG3EQLFSDQeUp3s1OSHBFnvSdGjBeQixs= 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=kOqdl60WvBSlqN+8QOZ7NkZ/E4N8GLwa6xp0qkQQXgE=; b=ddTtXRmV4gPqZyF7z3dessO55dlWx8OYri3japIOqk8kBeJmLs4lhRyYzviG4i57zY M+GqNnCZKYNrtGFiYodHemoEexdDYTPNVGM8ZecwuIJHhr51rt4KIkFwrhZ+PIQA+4Uq Qhbc+bSbIU0EOVREBJZR1F052yCM5PbNWShzJF1t5W13ThYHpHiN7dgoWhS7/YjXZZTC 4GuZSx+LDB4Kx09f2Cw/TW5gxfonbuiH3YFsuXs4jd3R0OaVuIwOptObBo/KJC3MqFV9 XZeungeS5Kr15wUAYgLEy1JwOo73gDzfEyuIQRmWIOipNUXOR4OHJpQzAZIsdQuLcniO ZGKA== X-Gm-Message-State: AOAM5331CQNOR2WBAJC50xINEtOMpGfLTrM/7waLQ0a0mP90erh7MBM5 K8W7p3sci78cV26YTFJzXuoRx5dQEf7vkZmO X-Google-Smtp-Source: ABdhPJy/TgFia5yNkuOwtJbNuABt+Jt19ajkrn20UgDEomHoKz/xMSZqbD9yS/kjWf9MJ34cQPIPiQ== X-Received: by 2002:a17:902:ecc5:b0:140:4db1:e74 with SMTP id a5-20020a170902ecc500b001404db10e74mr9275441plh.10.1635508809159; Fri, 29 Oct 2021 05:00:09 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id d15sm7399844pfu.12.2021.10.29.05.00.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:08 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 19:59:58 +0800 Message-Id: <20211029120001.2469018-3-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211029120001.2469018-1-hanlinchen@chromium.org> References: <20211029120001.2469018-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/6] ipu3: Set statistics with the effective AE AiqResults 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" Set the statistics with the latest AE AiqResults which has the same exposure time and analog gain. The patch reduces the AE haunting during the converging process. Signed-off-by: Han-Lin Chen --- aiq/aiq_input_parameters.cpp | 2 +- ipu3.cpp | 66 ++++++++++++++++++++++++++++++------ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp index bc87b31..46553a6 100644 --- a/aiq/aiq_input_parameters.cpp +++ b/aiq/aiq_input_parameters.cpp @@ -130,7 +130,7 @@ AiqInputParameters &AiqInputParameters::operator=(const AiqInputParameters &othe void AiqInputParameters::setAeAwbAfDefaults() { - /*Ae Params */ + /* Ae Params */ aeInputParams.num_exposures = NUM_EXPOSURES; aeInputParams.frame_use = ia_aiq_frame_use_preview; aeInputParams.flash_mode = ia_aiq_flash_mode_off; diff --git a/ipu3.cpp b/ipu3.cpp index 8126e9d..f463805 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -59,7 +59,8 @@ private: void fillParams(unsigned int frame, ipu3_uapi_params *params); void parseStatistics(unsigned int frame, int64_t frameTimestamp, - const ipu3_uapi_stats_3a *stats); + const ipu3_uapi_stats_3a *stats, + const ControlList& sensorCtrls); void setControls(unsigned int frame); @@ -84,6 +85,7 @@ private: /* Temporary storage until we have a FrameContext object / struct */ aiq::AiqInputParameters aiqInputParams_; aiq::AiqResults results_; + aiq::AiqResultsRingBuffer resultsHistory_; BinaryData aiqb_; BinaryData nvm_; @@ -282,6 +284,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, /* Upate the camera controls using the new sensor settings. */ updateControls(sensorInfo_, ctrls_, ipaControls); + resultsHistory_.Reset(); + return 0; } @@ -327,7 +331,10 @@ void IPAIPU3::processEvent(const IPU3Event &event) const ipu3_uapi_stats_3a *stats = reinterpret_cast(mem.data()); - parseStatistics(event.frame, event.frameTimestamp, stats); + parseStatistics(event.frame, + event.frameTimestamp, + stats, + event.sensorControls); break; } case EventFillParams: { @@ -374,14 +381,16 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) */ /* Run algorithms into/using this context structure */ - if (frame % 10 == 0) - aiq_.run2a(frame, aiqInputParams_, results_); + aiq_.run2a(frame, aiqInputParams_, results_); aic_.updateRuntimeParams(results_); aic_.run(params); exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global; + + resultsHistory_.Push(results_); + setControls(frame); IPU3Action op; @@ -392,7 +401,8 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) void IPAIPU3::parseStatistics(unsigned int frame, int64_t frameTimestamp, - const ipu3_uapi_stats_3a *stats) + const ipu3_uapi_stats_3a *stats, + const ControlList& sensorCtrls) { ControlList ctrls(controls::controls); @@ -403,10 +413,43 @@ void IPAIPU3::parseStatistics(unsigned int frame, */ ASSERT (frameTimestamp > 0); - aiq_.setStatistics(frame, frameTimestamp, results_, stats); + + /* Ae algorithm expects the statistics to be set with its corresponding + * Ae result, i.e., the Ae result should match the exposure time and + * analog gain with the the effective sensor controls of the statistics. + * Search the required Ae result in the result history and combine it + * with the latest result as the input to AIQ::setStatistics(). + */ + + int32_t effectiveExpo = 0; + int32_t effectiveGain = 0; + ControlValue ctrlValue; + + ctrlValue = sensorCtrls.get(V4L2_CID_EXPOSURE); + if (!ctrlValue.isNone()) + effectiveExpo = ctrlValue.get(); + + ctrlValue = sensorCtrls.get(V4L2_CID_ANALOGUE_GAIN); + if (!ctrlValue.isNone()) + effectiveGain = ctrlValue.get(); + + auto pred = [effectiveExpo, effectiveGain] (aiq::AiqResults& result) { + ia_aiq_exposure_sensor_parameters* sensorExposure = + result.ae()->exposures[0].sensor_exposure; + + return (effectiveExpo == sensorExposure->coarse_integration_time || + effectiveGain == sensorExposure->analog_gain_code_global); + }; + aiq::AiqResults& aeMatchedResults = resultsHistory_.searchBackward(pred, results_); + + aiq::AiqResults combinedResults = results_; + combinedResults.setAe(aeMatchedResults.ae()); + + /* Aiq library expects timestamp in microseconds */ + aiq_.setStatistics(frame, (frameTimestamp / 1000), combinedResults, stats); /* Set frame durations from exposure results */ - ia_aiq_exposure_sensor_parameters *sensorExposure = results_.ae()->exposures->sensor_exposure; + ia_aiq_exposure_sensor_parameters *sensorExposure = combinedResults.ae()->exposures->sensor_exposure; int64_t frameDuration = (sensorExposure->line_length_pixels * sensorExposure->frame_length_lines) / (sensorInfo_.pixelRate / 1e6); ctrls.set(controls::FrameDuration, frameDuration); @@ -423,10 +466,11 @@ void IPAIPU3::setControls(unsigned int frame) IPU3Action op; op.op = ActionSetSensorControls; - ControlList ctrls(ctrls_); - ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure_)); - ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain_)); - op.controls = ctrls; + ControlList sensorCtrls(ctrls_); + sensorCtrls.set(V4L2_CID_EXPOSURE, static_cast(exposure_)); + sensorCtrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain_)); + + op.sensorControls = sensorCtrls; queueFrameAction.emit(frame, op); } From patchwork Fri Oct 29 11:59:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14423 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 D4655BDB1C for ; Fri, 29 Oct 2021 12:00:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8E063600BD; Fri, 29 Oct 2021 14:00:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ScBQg3df"; dkim-atps=neutral Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 35DB1600B8 for ; Fri, 29 Oct 2021 14:00:18 +0200 (CEST) Received: by mail-pj1-x102e.google.com with SMTP id gn3so7095581pjb.0 for ; Fri, 29 Oct 2021 05:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=imlPZU3kTuDJRGvSnEYlWRRbrPPnlI4LZdlpVSqGL0I=; b=ScBQg3df1GtW6nvWBbwVvrjUI5qESaZd1Im3/MxhYCzMccZjEZ1FxiKRgUorx5uBVt JuciAnNPv6UvRAl5ytopQoVnN8vosT+zP6ym7C6JRuNJJ5zTAiRmZ3K0UGJtl3p8dFkD GT4QBBPqgZKHI1lZSiUswpjGXi8N4Pd8A7cmI= 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=imlPZU3kTuDJRGvSnEYlWRRbrPPnlI4LZdlpVSqGL0I=; b=4QOsnleylTyzdKzY53bW1urLu0k7ebOZt9b+6Xs1Tj8Tv0uts2Y9e28xmGOZ4P2Jo8 FFo2iCMEU9HfAc66H8PvMEseexoIbGpiNMXEdEpYBWUQMgJIejwCjsjMPCW+Y16NiM6e /9TSjgCF/5stVJHgOq9BiRuBrHn97VjMe3bzZsX17rWjXgr8UoyXBXM0ZWmCDZfFHNOp pkDvnVIGIAunrFKaMXkR8/uD3MRrdevBHL4EZXqwKJc3lUL8nPwe7aBXiPfq5GyTQ2pE dPHqvIWMhNcfERKkni2685aRUP/qi60R1Dsl87DR1hF7CR7IYOyXu7YA5wrCVig78hnY +Luw== X-Gm-Message-State: AOAM532zxODO0vZuf2ePziyEjrBDFhd65ypfG50VOoMmZEcGSwVY3+Nq RoC244jQCS3C5t/R60lnCW5mnDxfC/1C58Ve X-Google-Smtp-Source: ABdhPJzSv7T97Vpr0qcjZL/cIQ1XR3uOfQIf2Iy8csRAtcUcbGZuGZLuwzCO8A0gp37LgUazAQAi5g== X-Received: by 2002:a17:90a:5992:: with SMTP id l18mr19035730pji.127.1635508811314; Fri, 29 Oct 2021 05:00:11 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id k5sm5839262pjd.46.2021.10.29.05.00.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:11 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 19:59:59 +0800 Message-Id: <20211029120001.2469018-4-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211029120001.2469018-1-hanlinchen@chromium.org> References: <20211029120001.2469018-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/6] ipu3: Apply auto focus and send lens controls to pipeline handler 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" Apply auto focus and send lens controls to pipeline handler. Signed-off-by: Han-Lin Chen --- aiq/aiq.cpp | 5 ++++- aiq/aiq.h | 2 +- aiq/aiq_input_parameters.cpp | 2 +- ipu3.cpp | 27 ++++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/aiq/aiq.cpp b/aiq/aiq.cpp index 24c61cb..9c7f9d6 100644 --- a/aiq/aiq.cpp +++ b/aiq/aiq.cpp @@ -139,7 +139,7 @@ int AIQ::setStatistics(unsigned int frame, * of the parameter buffer being the only part handled when called for. */ int AIQ::run2a(unsigned int frame, AiqInputParameters ¶ms, - AiqResults &results) + AiqResults &results, int lensPosition, int64_t lensMovementStartTime) { (void)frame; @@ -157,6 +157,9 @@ int AIQ::run2a(unsigned int frame, AiqInputParameters ¶ms, params.saParams.awb_results = results.awb(); shadingAdapterRun(params.saParams, results); + params.afParams.lens_position = lensPosition; + params.afParams.lens_movement_start_timestamp = lensMovementStartTime; + afRun(params.afParams, results); return 0; diff --git a/aiq/aiq.h b/aiq/aiq.h index fcd02d2..4f5f868 100644 --- a/aiq/aiq.h +++ b/aiq/aiq.h @@ -41,7 +41,7 @@ public: const ipu3_uapi_stats_3a *stats); int run2a(unsigned int frame, AiqInputParameters ¶ms, - AiqResults &results); + AiqResults &results, int lensPosition, int64_t lensMovementStartTime); private: std::string decodeError(ia_err err); diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp index 46553a6..5dd2f6c 100644 --- a/aiq/aiq_input_parameters.cpp +++ b/aiq/aiq_input_parameters.cpp @@ -166,7 +166,7 @@ void AiqInputParameters::setAeAwbAfDefaults() ia_aiq_af_range_normal, ia_aiq_af_metering_mode_auto, ia_aiq_flash_mode_off, - NULL, NULL, false + &focusRect, &manualFocusParams, false }; /* GBCE Params */ diff --git a/ipu3.cpp b/ipu3.cpp index f463805..c2dc754 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -77,6 +77,10 @@ private: uint32_t gain_; uint32_t minGain_; uint32_t maxGain_; + int32_t lensPosition_; + + /* Intel AF library relies on timestamp to wait for lens movement */ + uint64_t lensMovementStartTime_; /* Intel Library Instances. */ aiq::AIQ aiq_; @@ -258,6 +262,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, maxGain_ = itGain->second.max().get(); gain_ = maxGain_; + lensMovementStartTime_ = 0; + lensPosition_ = 0; + int ret; ret = aiq_.configure(); @@ -381,7 +388,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) */ /* Run algorithms into/using this context structure */ - aiq_.run2a(frame, aiqInputParams_, results_); + aiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_); aic_.updateRuntimeParams(results_); aic_.run(params); @@ -389,6 +396,19 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global; + /* + * Af algorithm compares the timestamp of start of lens movement and the + * that of the statistics generated to estimate whether next lens + * positon should be produced. + * Todo: Use the lens movement start time reported by the pipeline handler. + */ + if (lensPosition_ != results_.af()->next_lens_position) { + utils::time_point time = utils::clock::now(); + uint64_t msecs = std::chrono::duration_cast(time.time_since_epoch()).count(); + lensMovementStartTime_ = msecs; + } + lensPosition_ = results_.af()->next_lens_position; + resultsHistory_.Push(results_); setControls(frame); @@ -472,6 +492,11 @@ void IPAIPU3::setControls(unsigned int frame) op.sensorControls = sensorCtrls; + ControlList lensCtrls; + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_); + + op.lensControls = lensCtrls; + queueFrameAction.emit(frame, op); } From patchwork Fri Oct 29 12:00:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14421 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 B5134BDB1C for ; Fri, 29 Oct 2021 12:00:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71368600C4; Fri, 29 Oct 2021 14:00:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="d9+o9rDf"; dkim-atps=neutral Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 384CA600B8 for ; Fri, 29 Oct 2021 14:00:15 +0200 (CEST) Received: by mail-pg1-x52b.google.com with SMTP id f5so9651646pgc.12 for ; Fri, 29 Oct 2021 05:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JIW54wwtEbmae2rJT2JySJLiLDfh8qO7VcEWNSqs6/M=; b=d9+o9rDfXPduJSFS+4RJsy16BxJxk2RjT9c48uTBBWYS1v2PHmf7tqlw0NT/hRJCkR t6GrzbQSguV5Z/OuflsyBX0N7gOBrmANF/iohpCW2tjqHF01M8WyaoLVQHXbAlwiKX3K rd5t9oaLh0iZXy7+mvDINx/mb6YEXqCH3Ll7Y= 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=JIW54wwtEbmae2rJT2JySJLiLDfh8qO7VcEWNSqs6/M=; b=Yq8SMjP3d6MIyBSGEIfOt1hRMZIICCsYJKXPLpGOMn4yQiJl2ItcQm12zqroTc94Yf J+4R041qR6Rd+V5VDrHHuox06kLm4dKMx1xQglk5OTi0mdwTzL1U8u8T97aQmWIQcH5x li6E0ca81eVJhCe8MssY6tjKflX5swV3W6lCa+8AiMjvR2n4sDc8hK8s66yWyr0/iLNc XsDaxTk+AjTgn9QXeAARjBN5Sokzvvn0qtZZGU3bElu8eB/eqdKEAox6525jhvPp6XB1 ZVEoaP8Je9eaXvqkrVXQg+GYoKuTIDjOJFhG6GvNibzjxoP8EoCnWbbNnsfSDl6MCN+b jLgQ== X-Gm-Message-State: AOAM533lt/QD8zn9NPuu6m50as1tF3fw5xSnhgXEH6fo9OV1Lu3ylxqL tV8hR4ncGMqYHkya7jw2PtNgEnU76nfow0La X-Google-Smtp-Source: ABdhPJy2QrjFQY3GcLHjq6Zl7E24fYjqNvo08F6ZrpAVq5zsK0zC8zGY01zV6GNKV527xts5iRBkfQ== X-Received: by 2002:a05:6a00:23d5:b0:47c:236d:65b4 with SMTP id g21-20020a056a0023d500b0047c236d65b4mr10297906pfc.52.1635508813340; Fri, 29 Oct 2021 05:00:13 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id v2sm5516063pga.57.2021.10.29.05.00.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:13 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 20:00:00 +0800 Message-Id: <20211029120001.2469018-5-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211029120001.2469018-1-hanlinchen@chromium.org> References: <20211029120001.2469018-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/6] ipu3: Run AIQ for the first frame to avoid blanking 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" The start() function set the first exposure time and analog gain to maximum. In result, the first frame might be over bright and the user may see a bright blank when changing the camera in application. Run AIQ to get an initial exposure time and analog gain in start() to smooth the AE process. Signed-off-by: Han-Lin Chen Reviewed-by: Kieran Bingham --- ipu3.cpp | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index c2dc754..2232e07 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -56,6 +56,7 @@ private: const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls); void processControls(unsigned int frame, const ControlList &metadata); + void runAiq(unsigned int frame); void fillParams(unsigned int frame, ipu3_uapi_params *params); void parseStatistics(unsigned int frame, int64_t frameTimestamp, @@ -221,6 +222,7 @@ int IPAIPU3::init(const IPASettings &settings, int IPAIPU3::start() { + runAiq(0); setControls(0); return 0; @@ -370,29 +372,11 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame, /* \todo Start processing for 'frame' based on 'controls'. */ } -void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) +void IPAIPU3::runAiq(unsigned int frame) { - /* Prepare parameters buffer. */ - memset(params, 0, sizeof(*params)); - - /* - * Call into the AIQ object, and set up the library with any requested - * controls or settings from the incoming request. - * - * (statistics are fed into the library as a separate event - * when available) - * - * - Run algorithms - * - * - Fill params buffer with the results of the algorithms. - */ - /* Run algorithms into/using this context structure */ aiq_.run2a(frame, aiqInputParams_, results_, lensPosition_, lensMovementStartTime_); - aic_.updateRuntimeParams(results_); - aic_.run(params); - exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global; @@ -410,6 +394,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) lensPosition_ = results_.af()->next_lens_position; resultsHistory_.Push(results_); +} + +void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) +{ + /* Prepare parameters buffer. */ + memset(params, 0, sizeof(*params)); + + /* + * Call into the AIQ object, and set up the library with any requested + * controls or settings from the incoming request. + * + * (statistics are fed into the library as a separate event + * when available) + * + * - Run algorithms + * + * - Fill params buffer with the results of the algorithms. + */ + + runAiq(frame); + + aic_.updateRuntimeParams(results_); + aic_.run(params); setControls(frame); From patchwork Fri Oct 29 12:00:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14422 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 51A26BDB1C for ; Fri, 29 Oct 2021 12:00:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 05624600C0; Fri, 29 Oct 2021 14:00:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KDtF1/X2"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E3F72600BD for ; Fri, 29 Oct 2021 14:00:17 +0200 (CEST) Received: by mail-pj1-x1029.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so7231503pjb.3 for ; Fri, 29 Oct 2021 05:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=++tKZTGfJU1x4+QwSMn15mcVaU3lDPfIxRASilIzLtI=; b=KDtF1/X2JvnOSCty9NkwOIjEyJS/eb/x7Z/VVinbUiiRB5MRvPnUFZ0/hivwgU6j3Z Ut6AVb3j4QV1gA+VTNGp18rOKqPoG0+r5imh2XVJptwVaLifxf1uzMnn+Rps9r8WPyxR HxjFdwRpoigodv1YD21w4wUG1S1Lto25SU+ps= 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=++tKZTGfJU1x4+QwSMn15mcVaU3lDPfIxRASilIzLtI=; b=N4qXq7gM7fiUkrkiFcc3PyyPsrPElIl9rmyXTMqscjwNhqJD9LIieirQfQWFO1Npqi v7Yw2ebouedMyC1XjyBMDrxXB/qXCwquoZihrBPHCEr//Lx+u4m0hHbZBT3cIjWyDuYF FEixbTYd2akJ5jF8tP+p9OIwdnLweb/pDFdYMqPBdnVG6EmN5ZvmBYIvJ52Z/n30bPYA Nrt8T904SxzxCvp8FkpdG8HUf7C0Vs0D0PSXWArGx18mupkSP/3GAnl0cAAJiTTVyGgG LEPG2P7lcrYd3euv/PO8zy9WsXcgpH6QxH/ouMurLTAdETj+O5DKLA7VtEtopTxirXYa DOyQ== X-Gm-Message-State: AOAM531F1rUBmrpNWNIGe45j1yTItoxAalYE8SGtJPA7shYQJ/ORcQNc 0TDAcY/Gyz5NU/DPmJZXZJfG4FqA3UZf3YWq X-Google-Smtp-Source: ABdhPJxJ1EEI91L7pvSWugCJTA+4r4hjQ5ZsnUShkvpYN0Vy04f4rUj71mbp/yllf9ujkKaEtft8AA== X-Received: by 2002:a17:902:c214:b0:13f:1b2a:8011 with SMTP id 20-20020a170902c21400b0013f1b2a8011mr9258324pll.3.1635508815896; Fri, 29 Oct 2021 05:00:15 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:35fe:d53b:684:b538]) by smtp.gmail.com with UTF8SMTPSA id m7sm5570191pgn.32.2021.10.29.05.00.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Oct 2021 05:00:15 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Fri, 29 Oct 2021 20:00:01 +0800 Message-Id: <20211029120001.2469018-6-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211029120001.2469018-1-hanlinchen@chromium.org> References: <20211029120001.2469018-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/6] ipu3: Use gbce and tone mapping from the tuning files 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" Change the flags to gbce algorithm to use the global brightness and tone mapping from the tunint files. Signed-off-by: Han-Lin Chen Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- aiq/aiq_input_parameters.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp index 5dd2f6c..7a6a1fa 100644 --- a/aiq/aiq_input_parameters.cpp +++ b/aiq/aiq_input_parameters.cpp @@ -170,8 +170,8 @@ void AiqInputParameters::setAeAwbAfDefaults() }; /* GBCE Params */ - gbceParams.gbce_level = ia_aiq_gbce_level_bypass; - gbceParams.tone_map_level = ia_aiq_tone_map_level_default; + gbceParams.gbce_level = ia_aiq_gbce_level_use_tuning; + gbceParams.tone_map_level = ia_aiq_tone_map_level_use_tuning; gbceParams.frame_use = ia_aiq_frame_use_preview; gbceParams.ev_shift = 0;