From patchwork Thu Nov 11 10:49:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14546 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 4A998BDB1C for ; Thu, 11 Nov 2021 10:49:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0613B6034E; Thu, 11 Nov 2021 11:49:33 +0100 (CET) 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="I0/lVFwx"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE9A66032C for ; Thu, 11 Nov 2021 11:49:30 +0100 (CET) Received: by mail-pj1-x1032.google.com with SMTP id j6-20020a17090a588600b001a78a5ce46aso4264517pji.0 for ; Thu, 11 Nov 2021 02:49:30 -0800 (PST) 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=QzcjOG7A0t3KcNbyAQ/elM2/0txN25oL28rye8sRV2U=; b=I0/lVFwxP5zPlN59gObLHwOCtE8qYrzEyDV/91BldHzXNwEgNdaMXs2wJzG8WzivEr 4nML0UaQpl1pArshH0bM2O/0ZIks7qRTMyVHxw2D11nZl5FSRMvD/NBpjgmvGafjDX/D lF2X3IR0uhw4ts1cjriyNhcq/VrezfpWfqES4= 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=QzcjOG7A0t3KcNbyAQ/elM2/0txN25oL28rye8sRV2U=; b=yM73dMvW1Yc+jI366oIL8aYtMFCPKordqRz2wpo6ksGdXcZ/qWUSggQIEN8HypigwN JYFuRP03WrljoNw3jAmm6JmZhyTGlI99xZPrkIuO++LOIO7wFaB+Ot5DulqPkil4lHo+ XwEkhCRb/cNM5sDyS63mKf9SaQXlYwpgMRoFgbsGrbEqDdDGKQ/3TrIdlDudnjlKbzhX M1NJZYIkStl0eQEr0/SpqbppA5Yab0DXDAbIFiZ4CEzi3Ow6Iif1u3+p/6f3gcFqzYY5 2zhSaefBQ0V1mgq9WWbDzBQNiQfnvUJJmIDMID0SMsbUVkstFaTTCCJRp9mOityIBPAt uqfw== X-Gm-Message-State: AOAM531Ib2pZt2SfMcqIJv2K8AeWvmZeAmRxJ0tXtn0w16VfLUZEqe9o 3TUFdJyrLzJ0IBTth3h6Ji5Nx4IpcOh+dg== X-Google-Smtp-Source: ABdhPJwhWpR472qKJvW1ac+4zKyEql7u2IX7PbI+nFA9tQhSQ6/X5mMQXTebiCca/Q1W7Y06IwXcfA== X-Received: by 2002:a17:90a:ab17:: with SMTP id m23mr7265141pjq.194.1636627769342; Thu, 11 Nov 2021 02:49:29 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id md6sm2148665pjb.22.2021.11.11.02.49.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:28 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:03 +0800 Message-Id: <20211111104908.295992-2-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 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 a 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 Thu Nov 11 10:49:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14547 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 CE8C2BDB1C for ; Thu, 11 Nov 2021 10:49:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7CCB06035D; Thu, 11 Nov 2021 11:49:34 +0100 (CET) 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="KHjzFO1+"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A0DB60369 for ; Thu, 11 Nov 2021 11:49:33 +0100 (CET) Received: by mail-pj1-x1032.google.com with SMTP id x7so3832805pjn.0 for ; Thu, 11 Nov 2021 02:49:33 -0800 (PST) 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=79aUadBtYlR09ShcgbybPJ7j1L4UXmL3pC0j4+AsB4Y=; b=KHjzFO1+egAxmxcSOEtxT0fTrNxgi6FgwvH72GxZAenZVAp9GiUv/KCYmnOX7Cw2Eo VjiAeYSYM2uT7RWCsQJbqeLlNKDL6ziUXwOXNzRlo1Ejpdw0dJxUp3rO9K3Qo9X3DBGl dboZuyVttsqwFn/4vzCF/foF5OQIU3B4h1kiw= 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=79aUadBtYlR09ShcgbybPJ7j1L4UXmL3pC0j4+AsB4Y=; b=SjK9np4wbQJClDlwUpvgZM25W2w+tsGjIBV3ZRlXvygMlYgk1pjdBp0fQ7CVhEDzRB p0+v7F71FqZwQ9dWZOkaE2wMzt7r7keRAJI2V1RJlJrunW/yXrEgph34PaBFiQTaQpgJ yUzCxfkS+1dcxj8GakzU9+2/8w0NRyOLm28xL8Nra6T45uOmIlfeP+UE0k5ghgE0umrI dcxRpCCEq9mYJjrW2flW7mwFFx3dleGjJdpiDNMLBeGt3WYpVLQWTQktOTTetzy8QZlN pKFNDIknOZJ/9s1+PkGO+rDQszLXcWYbDpcNwPTJI4Nqx64IWGt0dy2jGLuA5JcOcbkh 2tbg== X-Gm-Message-State: AOAM5333O7iC07j1ThIpCt4iI50pikjsOKEesMvuhfLisFDjOPpgSguz 1Y+rQE0GVbI0G/5dVZn6afolpovQvjuZlg== X-Google-Smtp-Source: ABdhPJycg9H7J2aNpa7+OLnfSdMx8AgtACW+juCDqshGpCxyaAbE/WHYAV8nFNMDCVWV9OGfzWbQ7g== X-Received: by 2002:a17:90b:4f86:: with SMTP id qe6mr7225147pjb.198.1636627771348; Thu, 11 Nov 2021 02:49:31 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id x14sm2217514pjl.27.2021.11.11.02.49.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:31 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:04 +0800 Message-Id: <20211111104908.295992-3-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 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. In details, the patch adds following to AiqResult Class. - Make the parameters to setXXX() functions const. - Implement copy constructors - Implement a RingBuffer to maintain AiqResults History Signed-off-by: Han-Lin Chen Reviewed-by: Kieran Bingham --- aiq/aiq_results.cpp | 90 +++++++++++++++++++++++++++++++++++++++++---- aiq/aiq_results.h | 43 ++++++++++++++++++---- 2 files changed, 117 insertions(+), 16 deletions(-) diff --git a/aiq/aiq_results.cpp b/aiq/aiq_results.cpp index f727f36..befcf7a 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,53 @@ 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::extendOne() +{ + end_ = (end_ + 1) % bufferSize; + size_ = std::min(size_ + 1, bufferSize); + if (size_ == bufferSize) { + start_ = end_; + } +} + +AiqResults& AiqResultsRingBuffer::latest() +{ + unsigned int i = (end_ + bufferSize - 1) % bufferSize; + return operator[](i); +} + +AiqResults& AiqResultsRingBuffer::searchBackward( + const std::function pred, AiqResults& def) +{ + if (size_ == 0) + return def; + + unsigned int i = (end_ + bufferSize - 1) % bufferSize; + while (i != start_) { + if (pred(operator[](i))) { + return operator[](i); + } + i = (i + bufferSize - 1) % bufferSize; + } + + return def; +} + } /* namespace ipa::ipu3::aiq */ } /* namespace libcamera */ diff --git a/aiq/aiq_results.h b/aiq/aiq_results.h index ae19a6c..8c95852 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,10 @@ class AiqResults { public: AiqResults(); + AiqResults(const AiqResults &other); + AiqResults &operator=(const AiqResults &other); + AiqResults(const AiqResults &&other) = delete; + AiqResults &operator=(const AiqResults &&other) = delete; const ia_aiq_ae_results *ae() { return &ae_; } ia_aiq_af_results *af() { return &af_; } @@ -46,14 +52,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 +115,27 @@ 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 extendOne(); + AiqResults& latest(); + unsigned int size() { return size_; } + AiqResults& searchBackward(const std::function pred, + AiqResults& def); + +private: + void incrementSize(); + + 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 Nov 11 10:49:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14548 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 44E78BDB1C for ; Thu, 11 Nov 2021 10:49:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0072760361; Thu, 11 Nov 2021 11:49:37 +0100 (CET) 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="B3xDokDH"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7FF1E6032C for ; Thu, 11 Nov 2021 11:49:35 +0100 (CET) Received: by mail-pl1-x636.google.com with SMTP id u11so5491594plf.3 for ; Thu, 11 Nov 2021 02:49:35 -0800 (PST) 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=rdnEleC34M0zr+gS5rQKJvmxxwea1e6rZmRlToyr4Ik=; b=B3xDokDHVzh4frwnNBeZCl18NWgflfCFzA8jG0rlT0TI1kpcOwlkj+lJN/7qx/5X+/ KqfQGgg0mmglkjGqdFZcWLt3g4kuufpeffKt8SiR1xeUPiO0sU4tiDdnMFmPaec2FQi3 0ahIBJFK0VHFnUmmLMvlKEmhLaLYMo7UfZrxA= 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=rdnEleC34M0zr+gS5rQKJvmxxwea1e6rZmRlToyr4Ik=; b=qujM2e292yo/diOYHJ75HOp+UoODY5/h3lt8lhtnUWsNazpn1XW71R7/aDunpKtYWH p2UieOmDuCIGfUBkyZpLcNDstEQfS75L+qoiI5vU7oldlxHeKgpLNo8CIRWLak3QY7Ta 4H5SUKd7fqYkH8RM96SITgkpfCFiVOPf62dEPLdtdAljwDMrfbH80CapfP6Cl1/sFUGf v4H7M/mS+l4QnUuQkN1/oz1AgF2IPTG0FEQhmISyP6dj86AsEiZtMLK13T+9WqBgtlJc XffkfHmjGQEFlz7Ugcz8ioSZAhKfgCPjNlbjPAxOq6skCKGRFrhuFi2QvHa1zQkCYE0U Zyfg== X-Gm-Message-State: AOAM530TW++cuB1EDPho+/Um/7RcEOaMRliFXuuQaNH16ts4EGi1jcn7 Zk5yWJ1ewt8JcNEYId478ugvvzYMJrcbxg== X-Google-Smtp-Source: ABdhPJyabafKp9MqRFwvpPHkm5JnBuBxRKmJDY9V9jSI4HnWr2a2A7nRTTIdRpyD4JWgNOvU3cl8YA== X-Received: by 2002:a17:902:c7d5:b0:143:72b7:2ca5 with SMTP id r21-20020a170902c7d500b0014372b72ca5mr6602592pla.20.1636627773810; Thu, 11 Nov 2021 02:49:33 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id fs21sm7444307pjb.1.2021.11.11.02.49.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:33 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:05 +0800 Message-Id: <20211111104908.295992-4-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 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 hunting during the converging process. Signed-off-by: Han-Lin Chen Reviewed-by: Kieran Bingham --- aiq/aiq_input_parameters.cpp | 2 +- ipu3.cpp | 75 ++++++++++++++++++++++++++++-------- 2 files changed, 61 insertions(+), 16 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..9d07268 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); @@ -83,7 +84,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 +283,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 +330,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 +380,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_); + resultsHistory_.extendOne(); + aiq::AiqResults& latestResults = resultsHistory_.latest(); - aic_.updateRuntimeParams(results_); + aiq_.run2a(frame, aiqInputParams_, latestResults); + aic_.updateRuntimeParams(latestResults); aic_.run(params); - exposure_ = results_.ae()->exposures[0].sensor_exposure->coarse_integration_time; - gain_ = results_.ae()->exposures[0].sensor_exposure->analog_gain_code_global; + exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; + gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global; + setControls(frame); IPU3Action op; @@ -392,7 +400,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 +412,45 @@ 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& latestResults = resultsHistory_.latest(); + aiq::AiqResults& aeMatchedResults = resultsHistory_.searchBackward(pred, latestResults); + + aiq::AiqResults combinedResults = latestResults; + 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 +467,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 Nov 11 10:49:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14549 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 B50D4BDB1C for ; Thu, 11 Nov 2021 10:49:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6BC1D6036E; Thu, 11 Nov 2021 11:49:38 +0100 (CET) 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="KBwXN/cT"; dkim-atps=neutral Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9415C6035A for ; Thu, 11 Nov 2021 11:49:37 +0100 (CET) Received: by mail-pj1-x1032.google.com with SMTP id t5-20020a17090a4e4500b001a0a284fcc2so4305712pjl.2 for ; Thu, 11 Nov 2021 02:49:37 -0800 (PST) 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=wzmpKQs8eEkuk068oAnuEEo9voqG/Kew3C+UC0uQZpQ=; b=KBwXN/cTpoyYsOHIOkcTrX1I65JNVK0i+mZgRNZQPwMkX5g0kxsaQg/1JfMCkVsm32 nKDlJM1PSMq7et4mTqSGodl6pWftWant4mrXlR+ZjBgiKoCst8T3VumINi10K8IJyje6 dKJqZ+cvZSPmsTKMIDU0QhRhoME1L/hIn5o8Y= 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=wzmpKQs8eEkuk068oAnuEEo9voqG/Kew3C+UC0uQZpQ=; b=eICTRAJZ3spIK09x7LbJmjnm4kJr69UN5j2S0ERxnEhUmg2FAwqL/urcgRfYvh+tw8 ThhE+S+9yFAga0VPNsfnFr2c5wLpdROzmuuutGCIpplWnUmoTgiYK8MpaWmhwgEkZccm kAf8yhOpqAZ/3Ku12HFlKmA//AwQzgUM3rPxSLqUzWLxA5E69ULOoNUYxnu65rJloOWg 0922mXFuT2gw7fMBNvBkkgLBhU4lNs3c9YBLUkh8Q8JFek3fW96pPIre+2q7aaY/OWr8 Ty9JQhTjfkwt5U5w1lCvCqCwmwctvDLSGA8VZiZiVswgd8bCP5uMocPkqOxdYtf1H5pL U0mQ== X-Gm-Message-State: AOAM533ACAg5RdFjDx8RA/bjZksY5LZ7Qf9OeA+vhg3Ndof96BxRDNA/ pObpPW1pLwhXO1WprMwH4rcqeTAyXacZdw== X-Google-Smtp-Source: ABdhPJxqX5tGYOGr8pCL272EXzO9Zi99GecQdQzM1X/BPB8/FX6XRGcLEuq73XQPcgLspXT4kKqFvw== X-Received: by 2002:a17:90b:3848:: with SMTP id nl8mr24802999pjb.221.1636627775955; Thu, 11 Nov 2021 02:49:35 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id f3sm2689644pfg.167.2021.11.11.02.49.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:35 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:06 +0800 Message-Id: <20211111104908.295992-5-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 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 Reviewed-by: Kieran Bingham --- aiq/aiq.cpp | 3 +-- aiq/aiq.h | 4 +--- aiq/aiq_input_parameters.cpp | 2 +- ipu3.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/aiq/aiq.cpp b/aiq/aiq.cpp index 24c61cb..52a9c07 100644 --- a/aiq/aiq.cpp +++ b/aiq/aiq.cpp @@ -138,8 +138,7 @@ int AIQ::setStatistics(unsigned int frame, * might run asycnronously, or after receipt of statistics, with the filling * of the parameter buffer being the only part handled when called for. */ -int AIQ::run2a(unsigned int frame, AiqInputParameters ¶ms, - AiqResults &results) +int AIQ::run2a(unsigned int frame, AiqInputParameters ¶ms, AiqResults &results) { (void)frame; diff --git a/aiq/aiq.h b/aiq/aiq.h index fcd02d2..49eee2d 100644 --- a/aiq/aiq.h +++ b/aiq/aiq.h @@ -39,9 +39,7 @@ public: int setStatistics(unsigned int frame, int64_t timestamp, AiqResults &results, const ipu3_uapi_stats_3a *stats); - - int run2a(unsigned int frame, AiqInputParameters ¶ms, - AiqResults &results); + int run2a(unsigned int frame, AiqInputParameters ¶ms, AiqResults &results); 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 9d07268..f38440d 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_; @@ -257,6 +261,9 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, maxGain_ = itGain->second.max().get(); gain_ = maxGain_; + lensMovementStartTime_ = 0; + lensPosition_ = 0; + int ret; ret = aiq_.configure(); @@ -383,6 +390,10 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) resultsHistory_.extendOne(); aiq::AiqResults& latestResults = resultsHistory_.latest(); + /* Todo: Refactor AiqInputParameters interface to set following parameters. */ + aiqInputParams_.afParams.lens_position = lensPosition_; + aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_; + aiq_.run2a(frame, aiqInputParams_, latestResults); aic_.updateRuntimeParams(latestResults); aic_.run(params); @@ -390,6 +401,19 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = latestResults.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_ != latestResults.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_ = latestResults.af()->next_lens_position; + setControls(frame); IPU3Action op; @@ -473,6 +497,8 @@ void IPAIPU3::setControls(unsigned int frame) op.sensorControls = sensorCtrls; + op.lensControls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_); + queueFrameAction.emit(frame, op); } From patchwork Thu Nov 11 10:49:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14550 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 6210EBDB1C for ; Thu, 11 Nov 2021 10:49:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14CD760345; Thu, 11 Nov 2021 11:49:41 +0100 (CET) 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="Qcp/FlbC"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8E2760345 for ; Thu, 11 Nov 2021 11:49:39 +0100 (CET) Received: by mail-pj1-x102f.google.com with SMTP id p18-20020a17090ad31200b001a78bb52876so4109072pju.3 for ; Thu, 11 Nov 2021 02:49:39 -0800 (PST) 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=C3gXGHepNdq76R5E/Cgv2uleOXsTZATDjAvBWpSPQLE=; b=Qcp/FlbCbiaOLXm1XbFNSV7gvEa71pIuKl4DXIBJvGIMVd0Jfyeb89y7bSTXQteALT uKT2wTzKtBV4lIQ+NeYghz/j0OI7bG3VakoiNJpizV18pCPNMWla93Ae+dqlvhN2kNVG uApEZGrmMfsDz1N7aru5HwOLm0x4lhQH7FEKI= 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=C3gXGHepNdq76R5E/Cgv2uleOXsTZATDjAvBWpSPQLE=; b=g/RLeBakrAmFvzXPB/GlNqmGvh2zdTC5LyP2O/BJGa6kfjUI0Cq930yXV3aR+JStSN hrycml+1fMgJh8sI9CUbc4oSUKSgRxQ+abaENymOpz5gf/6EKopvvFX3D/erJZzNExEq 8jY1sZTAIvMz0S3f8USF234BvolLUNnE+lXeEChIaP6qP5JEpYpgKt7x7YuGBDk7+aeC DwyOqWNtDcA85SLnjVnHWgPAE792EZ9liFxXwBclDjPI7j2MDrtxqWDMrCQUpINMel/y Gl4yU0FtjcRpQJ+fuwLLAUFFsbjrb69gZpLX5kYAguMDGR9Qc+Po78BVWqRpKJ4JZO3W /zpw== X-Gm-Message-State: AOAM532V+/YCnbkqu55uSJnMc+npiKQ79ZAOyQ1RaiFZlMU+G0FKWKy9 qMzABDYIEXc3nzPWnRWeaQz8CI+I+SnS7w== X-Google-Smtp-Source: ABdhPJyDw2xrwudaiNBEt+Mwc9VKGhN7BmiLc6de1F01yEzhREUZ+PCqBBOWtovlDV1VYRXCgeDcyQ== X-Received: by 2002:a17:902:b08a:b0:142:51be:57e2 with SMTP id p10-20020a170902b08a00b0014251be57e2mr6514684plr.53.1636627778137; Thu, 11 Nov 2021 02:49:38 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id h18sm2868775pfh.172.2021.11.11.02.49.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:37 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:07 +0800 Message-Id: <20211111104908.295992-6-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 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 | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index f38440d..ffa78b3 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, @@ -220,6 +221,7 @@ int IPAIPU3::init(const IPASettings &settings, int IPAIPU3::start() { + runAiq(0); setControls(0); return 0; @@ -369,23 +371,8 @@ 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([[maybe_unused]] 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 */ resultsHistory_.extendOne(); aiq::AiqResults& latestResults = resultsHistory_.latest(); @@ -395,8 +382,6 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) aiqInputParams_.afParams.lens_movement_start_timestamp = lensMovementStartTime_; aiq_.run2a(frame, aiqInputParams_, latestResults); - aic_.updateRuntimeParams(latestResults); - aic_.run(params); exposure_ = latestResults.ae()->exposures[0].sensor_exposure->coarse_integration_time; gain_ = latestResults.ae()->exposures[0].sensor_exposure->analog_gain_code_global; @@ -413,6 +398,29 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) lensMovementStartTime_ = msecs; } lensPosition_ = latestResults.af()->next_lens_position; +} + +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); + + aiq::AiqResults& latestResults = resultsHistory_.latest(); + aic_.updateRuntimeParams(latestResults); + aic_.run(params); setControls(frame); From patchwork Thu Nov 11 10:49:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanlin Chen X-Patchwork-Id: 14551 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 C5937BDB1C for ; Thu, 11 Nov 2021 10:49:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A59160368; Thu, 11 Nov 2021 11:49:43 +0100 (CET) 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="IgjLw+dX"; dkim-atps=neutral Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 47F996032C for ; Thu, 11 Nov 2021 11:49:42 +0100 (CET) Received: by mail-pg1-x52a.google.com with SMTP id 200so4855132pga.1 for ; Thu, 11 Nov 2021 02:49:42 -0800 (PST) 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=9VdNDInwabkMtIQOIhMATye+WUU0NKXVhLjxlazEuZ8=; b=IgjLw+dXSlaJX3ylPvIPePzHJPwH88iq8paebqox57slofmHezqS7iApzdwmLoLxCP uht67uIdzjrB6yP8oDrt6GFAonh/n087QdX0BHHmBpHe1HPNBSl+7On+6VcqjnJelfy3 z+FL2V3tNIxP/VidX3C0lHFU4/0pHdJsASF+Q= 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=9VdNDInwabkMtIQOIhMATye+WUU0NKXVhLjxlazEuZ8=; b=wyg2jq5SRvZCyEKg6UHquCF5Ja4EpUFFZjVjILwMqa1LsfLt8ix0w4Ib/MFHNM/L71 vCZy62pI2Ap9nFYO3py8GrHeH7/+aDXuBeHfeGgQXrUz6bag/VbXCsu6rF/Hj2W3lhTS 3Z8sgM6nGSJUlksCCkpg7VFi/VkG4WwNLc5sohXo21OOOl6+xNfl77Wgh4Rm7kMpy2Yk kjFJBkKObBO6pYTm0Hm4EeR1pTMqZLJe65ZeOsQPEVKfTDMlr2hlHneb7zrxyGMCV0IU +BBFgAVx9/Zw3NNXCHLDcE0SjFajYdRI+N74HOgcuY9NIsOq0BDW1CSdhxDUoxty2/WJ t7jQ== X-Gm-Message-State: AOAM531yTd1g21pY3G2B7CFCPKVOOE8GouiUZWlJ7tao/B024+iMsrTI doGPiqrVd8KLojIxMnTq185P4gYPtBfySw== X-Google-Smtp-Source: ABdhPJx6mexjuzKEF0/2Sglgohxf7CjkoNwHO3gG3c7/TUmjt45qdWtu+P87ZMz+25UxtD3h9betDQ== X-Received: by 2002:a63:1d03:: with SMTP id d3mr4023595pgd.149.1636627780342; Thu, 11 Nov 2021 02:49:40 -0800 (PST) Received: from localhost ([2401:fa00:1:10:3925:da9c:3049:be7a]) by smtp.gmail.com with UTF8SMTPSA id b21sm2665836pff.179.2021.11.11.02.49.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 02:49:40 -0800 (PST) From: Han-Lin Chen To: libcamera-devel@lists.libcamera.org Date: Thu, 11 Nov 2021 18:49:08 +0800 Message-Id: <20211111104908.295992-7-hanlinchen@chromium.org> X-Mailer: git-send-email 2.34.0.rc1.387.gb447b232ab-goog In-Reply-To: <20211111104908.295992-1-hanlinchen@chromium.org> References: <20211111104908.295992-1-hanlinchen@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [IPU3-IPA PATCH v3 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 tuning 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;