From patchwork Thu Oct 28 10:03:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14390 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 935F5BF415 for ; Thu, 28 Oct 2021 10:03:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 50E5C600BB; Thu, 28 Oct 2021 12:03:54 +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="EfnqQy5Y"; dkim-atps=neutral Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7CBA0600B5 for ; Thu, 28 Oct 2021 12:03:53 +0200 (CEST) Received: by mail-pg1-x52f.google.com with SMTP id t7so5876713pgl.9 for ; Thu, 28 Oct 2021 03:03:53 -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=DgneWOyX29bUTgvuPCS53eREeOsak0Fruu65Vcrdp8M=; b=EfnqQy5YPCV0LJaZqy389jrq/UkhxSOsA1Bk2s6IapLphcVMbjryY2s0dWVzR+zY5m AJbhGxfqt2EuwTwT2Qryf42ebIuSY7jDH+TknGphWAGVIvKkkvMYPpwB/vn1DJFM67M+ /O45KTB9yss25HVZRk9Wf53N+vYGXxR2k2FCs= 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=DgneWOyX29bUTgvuPCS53eREeOsak0Fruu65Vcrdp8M=; b=qekInM5Pkrfk7zoccAhtNo6RWvrD9EWV1oQ1WfNmrd3xGE4ZMNcTf5M10w5v3X4Yca GixvSfQIT3zBfBOZfGIRsrHUFDfo2y+WKS9A1MlPzvVyjzv4SccID5//1oPE/KwIwG6m refRg1mrMy3pNNnGedgoj42o2fp3jKQmi64+LnXTSoMj3bFV59YNrL2KpFpqoEKW7/rP IjR4kx4G90bMdMgR7wEh4KwJ6NGR5uaAWdwqNIApKiCIvaP7II2SdlDyuPPULCZUPjwy 1Ye0QMv2CZJtBbiktX+LUBcYn7U5TPdCTIVhRpu/kIDEfjPYeQZZ7CqqXMtJhW1wyBT8 1M0A== X-Gm-Message-State: AOAM532D7g9m4zrwnBmls0VbwFtqSazItVg7CzWboV/3MwCdrjgeFPee Ac+9qwMevjvKJcgS6dywGtxMmK8oVV5LtNAt X-Google-Smtp-Source: ABdhPJz3+Sdcjc2mr+uocmynwLxEZb/Nxnh+AT7KjCWyp89G6QSRFS5BASQa5zaR896xiK23sdE8MA== X-Received: by 2002:a65:62c1:: with SMTP id m1mr2455093pgv.339.1635415431962; Thu, 28 Oct 2021 03:03:51 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id w21sm3122629pfu.68.2021.10.28.03.03.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:03:51 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:44 +0800 Message-Id: <20211028100349.1098545-1-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: , Cc: Han-Lin Chen 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 --- 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 Thu Oct 28 10:03:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14391 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 3B1E5BF415 for ; Thu, 28 Oct 2021 10:03:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DF1E7600C0; Thu, 28 Oct 2021 12:03:56 +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="CMnRzdNi"; dkim-atps=neutral Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 78BE1600B7 for ; Thu, 28 Oct 2021 12:03:55 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id gn3so4325947pjb.0 for ; Thu, 28 Oct 2021 03:03:55 -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=1SMrpSDlqic9LD5peqt2PFspq8nG97POBwGqQWYZUr8=; b=CMnRzdNiZiWZJXumxDzWtyflq9nK2sLaMigIIEhOQZ2R52gxi/RLpt2e3Phn3fklUI g4Q13kDkUK1MLLCbwU/dLi/3la9JkdsTgSJuXboiC0KRFEgMaAVpgYlxTM5ABjK2yz65 R6ihLN1SQuDs7LERtU9qc6dDkl0hOH5VHvklE= 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=1SMrpSDlqic9LD5peqt2PFspq8nG97POBwGqQWYZUr8=; b=su9YdP3p0PuTkeTjvu2oWF2ODDqQ8TprqQked7WCAli1GQGcgyKi8AG0IUdgNGwLvp GnUCYILws8opVpK+fDy1BaULBqSjwvurHU/pYv1JkrF4sfr2b8/7uE2z57sLyQvRdQs0 RHlKrMV2fr6MHaxg5O1K8UiIA++dC+Irm+agp3ObIT3u963lGDklMRZhx30mToYEvhyy UUGi71wIofO66tzxVCsNP2QyK2xMIbVa+hY9j53RLdQbHvW602GNsEMOcIym0JPiHULK MJ8PNcrGN5OuQ294FY4kCa20gstWQ6XrBUWHzfEXzB/QdcIQEj7ZVhrOPbotPNjsrMUi n91A== X-Gm-Message-State: AOAM532AuTyTU0WeFs/P3YAxV9wdcgLd1RL1yg20LfFvp67+m3JxOrW0 NDdUKxGTnDlhVjDmOorwA5+h5idLW9XgZiA7 X-Google-Smtp-Source: ABdhPJzJ4VLbeLoMF5Ov70rF1+dbAff8ANCLyAjbu35FEkIf5kroTks/ycPYXfezKt+QaaUvSlWupA== X-Received: by 2002:a17:902:c407:b0:13f:68f:6753 with SMTP id k7-20020a170902c40700b0013f068f6753mr2783522plk.39.1635415433891; Thu, 28 Oct 2021 03:03:53 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id g4sm674353pfv.195.2021.10.28.03.03.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:03:53 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:45 +0800 Message-Id: <20211028100349.1098545-2-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211028100349.1098545-1-hanlinchen@chromium.org> References: <20211028100349.1098545-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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. --- 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 Thu Oct 28 10:03:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14392 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 C57E6BF415 for ; Thu, 28 Oct 2021 10:03:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 79BED600C4; Thu, 28 Oct 2021 12:03:58 +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="T0CPjW0N"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 85099600B5 for ; Thu, 28 Oct 2021 12:03:57 +0200 (CEST) Received: by mail-pg1-x541.google.com with SMTP id h193so5930243pgc.1 for ; Thu, 28 Oct 2021 03:03:57 -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=lTSTK7FwG3T04+revACHrdm6IhgZuUILZhymSQGcEl8=; b=T0CPjW0Nfww4D7MpTbYCCUf5LVUnhIdCUJJFPHProfRHlAZ6+B7o1M6JR9HWBeeTTO LqXyVZLWq9SjeVjqD9VLsd1HMO1XC6ZYlwLHaxu6HRHoCgh5uY6GOZSWJHYitQ9W7X9d gNYfY3RczquvNOglgx8U3PQU/TllFGqJbtmFQ= 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=lTSTK7FwG3T04+revACHrdm6IhgZuUILZhymSQGcEl8=; b=bsl/cR9nznqcq3e/yDdfPjfbQ5qCwTDRA2mkfsJBX/nUHvL/Mwd4hat7/bYkThb9C8 Ou+m326bBpmrmfJr4E0uRXllN9GMyUrfejuTyQUBxg3dNP8yNUdGw1x8kvVth+sb+85T twSxKvi2Quj12XdImQR1HC9+J39iACm+/ZhlQLOhWNHJ0FMxX90ke+kCnjCRa+brN9f9 DNl40IAKUU8kegpaidP7QTjSP3x+3mGcazZhm8ipbLXTLTq9KTEbPfUUYRvXu9u2RUm6 P8Re5RANW+ZpzMCjMiGf2N9nhhylhjXm6okArqzUTWMCQ/7qJ4bqru3JaAlwi/a+cLWb wNOQ== X-Gm-Message-State: AOAM533K9u7UWsOg9mbt3B3uqjWgAz82mRzIm+y7b4y91doZkb6F9Qw9 +OXkoaz/y/Wzzm13n3LEK4hCHUxOXrOdquCu X-Google-Smtp-Source: ABdhPJwQ+T0RBy2+0iiwhcUCz7MxW53C4qiYj8pKgE7nGKQ8HVmUtpxBXNt7tVK4CDfyK251RCgLGQ== X-Received: by 2002:a63:8f5a:: with SMTP id r26mr2487035pgn.50.1635415435956; Thu, 28 Oct 2021 03:03:55 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id b10sm2780427pfi.122.2021.10.28.03.03.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:03:55 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:46 +0800 Message-Id: <20211028100349.1098545-3-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211028100349.1098545-1-hanlinchen@chromium.org> References: <20211028100349.1098545-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: , Cc: Han-Lin Chen 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 | 4 +-- ipu3.cpp | 66 ++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 13 deletions(-) diff --git a/aiq/aiq_input_parameters.cpp b/aiq/aiq_input_parameters.cpp index bc87b31..5dd2f6c 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; @@ -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 8126e9d..b7de901 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 it's corresponding Ae + * result, i.e., the Ae result should match the exposure time/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 Thu Oct 28 10:03:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14393 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 28197BF415 for ; Thu, 28 Oct 2021 10:04:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D32E3600F9; Thu, 28 Oct 2021 12:04:00 +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="DawF9SR1"; dkim-atps=neutral Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C60C600B5 for ; Thu, 28 Oct 2021 12:03:59 +0200 (CEST) Received: by mail-pf1-x42a.google.com with SMTP id b1so1952581pfm.6 for ; Thu, 28 Oct 2021 03:03:59 -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=fhWHJGT3GiHqLhE5ItshH8KqbE/k12uuErESYkJGWwE=; b=DawF9SR1Kv+BOseHJDO6haf90BJE/FdLX7dR9kBtcK3i1Oi2PSi9ouSbTI84yh1MQo mNtq5gPwluaTT2Z7bldvWrrZqMoedU/h06BaV6UVQXdDrcdoGdCAFEyqrizNmSnEVPVS xBpDC7VBmskPc+WbUZuiCxCQ4yopjTN8wNtX8= 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=fhWHJGT3GiHqLhE5ItshH8KqbE/k12uuErESYkJGWwE=; b=cqBKt0bMJ2uvKxi0R2QIIe+C3l3cpUVTqXg5J0Oik1m/I7ViTLESRWbGJBhLxkdvvj QyrQENvJqK9attkyYK4QYj7J2KEbpjL32CCmfEmal8AEX34aAis5SCJ7bUKORcI7I3U/ MZoOuFcaafyICnX5DXv12GR8r0wOpmNt2yqWdHRlwqpBf7DB2oe/tjwwYWj24fErvatW kQs1UomDg+dwwdYJBYFTHE6D0ZhD7icRzmzUNWMwKidwYSK86YErHenCNCqmyMfmOsOj /TmE5uHLf7s2j3IayWk80karbbg2GBnoJpE05zuLavd2M/wA2CeIozHUPqt6HZujrQDG nmtg== X-Gm-Message-State: AOAM533i6hUvchZE3E9tvXTgeILZE8vJFOYUqW5jyKQBWz8trvhQXbJD THtGR5bR678qkPQN0I/B068nfBZleDQCWleU X-Google-Smtp-Source: ABdhPJyp5qEJIh5nARascfiR0RaeU66nsXtfcKsywe2gtwI5pb7PpSJO0JuKxS5p/YMIy5FFxuFWCA== X-Received: by 2002:a05:6a00:2181:b0:44d:c18d:7af9 with SMTP id h1-20020a056a00218100b0044dc18d7af9mr3225357pfi.16.1635415437984; Thu, 28 Oct 2021 03:03:57 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id n29sm2828130pfv.77.2021.10.28.03.03.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:03:57 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:47 +0800 Message-Id: <20211028100349.1098545-4-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211028100349.1098545-1-hanlinchen@chromium.org> References: <20211028100349.1098545-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: , Cc: Han-Lin Chen 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 +- ipu3.cpp | 27 ++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 3 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/ipu3.cpp b/ipu3.cpp index b7de901..45330ca 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 start and the + * that of the statistics generated to estimate whether next lens positon + * should be produced. + * Todo: Uses 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 Thu Oct 28 10:03:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14394 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 27D18BF415 for ; Thu, 28 Oct 2021 10:04:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CEC4F600B7; Thu, 28 Oct 2021 12:04:02 +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="RCEyaZcJ"; 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 A223060103 for ; Thu, 28 Oct 2021 12:04:01 +0200 (CEST) Received: by mail-pj1-x102e.google.com with SMTP id ls14-20020a17090b350e00b001a00e2251c8so4262436pjb.4 for ; Thu, 28 Oct 2021 03:04:01 -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=P3cm+inl+EbpNn0pZqEsFguD4IKuCQYqm6q/3QvYvJM=; b=RCEyaZcJuxc2HJeD2iYL/xcrX4AoMuxxTSmseoskvhRhGhKDs5l/kOY8pvLBb9IZ7t lNwDm8Q9Njf3QfMl9sejBkLKMXJ/jU7r5uMbH15SN8ZBOqXgPKiLY9zJyywnXiXnT6VT Z541rfGCgbQeFhTRdi0J8xwKooK7xQF+QPOnc= 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=P3cm+inl+EbpNn0pZqEsFguD4IKuCQYqm6q/3QvYvJM=; b=NALDRLyLaiDv0ltghMeBUQJWQ7G2MEfl8+B/75w6dybKchNIDULU0xvsHtA7ECdkf7 Eprzn91EWo7CmDhCTYKbflB3helQ1uYz+mutMAjg/yYKo0tLwEKLYFQjolLVTDqRSYRW SB6qEk3i0KptUTe4PmZeVnG+2ipXdkDVQ+Sso5Pl+Pf5C6d5xqAduCWLx2vU33EmDpTr C37HQoapzq7yyVzUoqBSDVPIQg8uCowumNjb06Ywp50BALgw+GUoAqq57hNlDgiQH5ug QIJhHOLnkHqbdcngZEmjEBT/T/6gHgVAF3Q7V6uMj1Rg8CQeKXAI7K4XtElhg5aI5E4G z5sg== X-Gm-Message-State: AOAM533xNWmcjkUAWf+MPCmKc3WosePhz/HuEVNREWkFWBtCs7tyRV1q L+jVDACK0JEixcjuPl9Mk1iqoj0xYsutbFOr X-Google-Smtp-Source: ABdhPJw4rttndHgwG19pXE7nXiP5kg1yxoA4jUuO07+sXNXzFOdVTLpVf3z6cPInDJOxlsv0MHBW8A== X-Received: by 2002:a17:90a:6b0a:: with SMTP id v10mr11703821pjj.130.1635415440045; Thu, 28 Oct 2021 03:04:00 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id g25sm2815924pfh.216.2021.10.28.03.03.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:03:59 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:48 +0800 Message-Id: <20211028100349.1098545-5-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211028100349.1098545-1-hanlinchen@chromium.org> References: <20211028100349.1098545-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: , Cc: Han-Lin Chen 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 --- ipu3.cpp | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index 45330ca..b124301 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 Thu Oct 28 10:03:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14395 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 C8239BF415 for ; Thu, 28 Oct 2021 10:04:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8060D600C1; Thu, 28 Oct 2021 12:04:05 +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="ZD8CcsUd"; dkim-atps=neutral Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E8254600B5 for ; Thu, 28 Oct 2021 12:04:03 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id l203so5495385pfd.2 for ; Thu, 28 Oct 2021 03:04:03 -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=4rYXLtjA/5VTZ7mpq2/BlxHl2T8+W/evILXiYfKpWhQ=; b=ZD8CcsUdJ88aIXnb1p5QhCUTiSDImCXWm+PwgCmpsoFC87on5Repk3UJZX3neLNZyi SsWZ/LlHK7Bi/1iPjgWrwNmhzssHz+S34wf6YN0/EHjAy7ddTmyOQWmdqxl2hDriEjzm nhT2K5or7rYEgh+242kIchS8IUSYLNOixijzI= 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=4rYXLtjA/5VTZ7mpq2/BlxHl2T8+W/evILXiYfKpWhQ=; b=nsF2yqu9uxJBl62/KFgvHsZUc+Czi2tkUguEfVur3MspNdZG5hEpUl3LQgxDF5SV86 EKFiCbWXkgpkQ36fBtUw+uaXuLJF5p0350a/PnCb77oCjww7YSwKezS8WQcEdhUZcMyK xoT/CPxliMB+3J72bx6bmMThKN3xCPf+yRbhVyI4hmZR++ekTcbtc4pShsq62YdTsmo3 z51Gy1CieYYimtLKj3fU6tjziArYDxJMqWz4WNsTyWTLvvKwIMogr0lbaUfsdMBIRWbo 8kBwW+Bzhh3Q2SBytQ+ofGuy7tC0SZTBDDVb9bFd1Nl3ZQnjPsNgESILkxAHmK1vniM1 PboA== X-Gm-Message-State: AOAM533594v4NduSxFiBgiuNOGHgaKgZYLxhA33Q+z722TkO2CMQuVCc /WKXTUokOUFRAv5KVOeCswva1AkbxRrcLBFM X-Google-Smtp-Source: ABdhPJzCZnRnp2IWCzOdEt+qj8dLqQs1nIS1g6HFliwM3GH+MJLo17OGiS7MLfNGeBjuS9CgG9OjEA== X-Received: by 2002:aa7:9047:0:b0:44b:e142:8b0d with SMTP id n7-20020aa79047000000b0044be1428b0dmr3252201pfo.45.1635415442150; Thu, 28 Oct 2021 03:04:02 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:1bc:52e7:6df5:c7cf]) by smtp.gmail.com with UTF8SMTPSA id 141sm2349080pge.23.2021.10.28.03.04.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 03:04:01 -0700 (PDT) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 28 Oct 2021 18:03:49 +0800 Message-Id: <20211028100349.1098545-6-hanlinchen@chromium.org> X-Mailer: git-send-email 2.33.1.1089.g2158813163f-goog In-Reply-To: <20211028100349.1098545-1-hanlinchen@chromium.org> References: <20211028100349.1098545-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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: , Cc: Han-Lin Chen 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 --- 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;