From patchwork Mon May 3 09:26:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12162 X-Patchwork-Delegate: jacopo@jmondi.org 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 9B40FBDE78 for ; Mon, 3 May 2021 09:26:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 470FD6891F; Mon, 3 May 2021 11:26:26 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC4A5688E4 for ; Mon, 3 May 2021 11:26:24 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id B8A5CE0006 for ; Mon, 3 May 2021 09:26:24 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:26:59 +0200 Message-Id: <20210503092705.15562-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/7] libcamera: ipu3: imgu: Update BDS calculation process 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 the last three hunks of commit 243d134 ("Fix some bug for some resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git to the BDS calculation procedure. The BDS calculation is now perfomed by scaling both width and height, and repeated by scaling width first. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Signed-off-by: Jacopo Mondi Acked-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 34 ++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index d5cf05b0c421..8373dc165a61 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -394,19 +394,43 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) const Size &in = pipe->input; Size gdc = calculateGDC(pipe); - unsigned int ifWidth = utils::alignUp(in.width, IF_ALIGN_W); - unsigned int ifHeight = in.height; - unsigned int minIfWidth = in.width - IF_CROP_MAX_W; float bdsSF = static_cast(in.width) / gdc.width; float sf = findScaleFactor(bdsSF, bdsScalingFactors, true); + /* Populate the configurations vector by scaling width and height. */ + unsigned int ifWidth = utils::alignUp(in.width, IF_ALIGN_W); + unsigned int ifHeight = utils::alignUp(in.height, IF_ALIGN_H); + unsigned int minIfWidth = in.width - IF_CROP_MAX_W; + unsigned int minIfHeight = in.height - IF_CROP_MAX_H; while (ifWidth >= minIfWidth) { - Size iif{ ifWidth, ifHeight }; - calculateBDS(pipe, iif, gdc, sf); + while (ifHeight >= minIfHeight) { + Size iif{ ifWidth, ifHeight }; + calculateBDS(pipe, iif, gdc, sf); + ifHeight -= IF_ALIGN_H; + } ifWidth -= IF_ALIGN_W; } + /* Repeat search by scaling width first. */ + ifWidth = utils::alignUp(in.width, IF_ALIGN_W); + ifHeight = utils::alignUp(in.height, IF_ALIGN_H); + minIfWidth = in.width - IF_CROP_MAX_W; + minIfHeight = in.height - IF_CROP_MAX_H; + while (ifHeight >= minIfHeight) { + /* + * \todo This procedure is probably broken: + * https://github.com/intel/intel-ipu3-pipecfg/issues/2 + */ + while (ifWidth >= minIfWidth) { + Size iif{ ifWidth, ifHeight }; + calculateBDS(pipe, iif, gdc, sf); + ifWidth -= IF_ALIGN_W; + } + + ifHeight -= IF_ALIGN_H; + } + if (pipeConfigs.size() == 0) { LOG(IPU3, Error) << "Failed to calculate pipe configuration"; return {}; From patchwork Mon May 3 09:27:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12163 X-Patchwork-Delegate: jacopo@jmondi.org 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 0FF74BDE78 for ; Mon, 3 May 2021 09:26:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B7A6868927; Mon, 3 May 2021 11:26:26 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 570E7602C0 for ; Mon, 3 May 2021 11:26:25 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 22E64E0009 for ; Mon, 3 May 2021 09:26:24 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:27:00 +0200 Message-Id: <20210503092705.15562-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/7] libcamera: ipu3: imgu: Filter BDS by height 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 to calculateBDS() function the content of commit 243d134 ("Fix some bug for some resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git. The calculated BDS sizes are filtered by height and not only by width anymore. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Signed-off-by: Jacopo Mondi Acked-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index 8373dc165a61..36fee31c1962 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -33,6 +33,7 @@ namespace { * at revision: 61e83f2f7606 ("Add more information into README") */ +static constexpr unsigned int FILTER_W = 4; static constexpr unsigned int FILTER_H = 4; static constexpr unsigned int IF_ALIGN_W = 2; @@ -194,15 +195,20 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, float bdsSF) { - unsigned int minBDSWidth = gdc.width + FILTER_H * 2; + unsigned int minBDSWidth = gdc.width + FILTER_W * 2; + unsigned int minBDSHeight = gdc.height + FILTER_H * 2; float sf = bdsSF; while (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) { float bdsWidth = static_cast(iif.width) / sf; + float bdsHeight = static_cast(iif.height) / sf; - if (std::fmod(bdsWidth, 1.0) == 0) { + if (std::fmod(bdsWidth, 1.0) == 0 && + std::fmod(bdsHeight, 1.0) == 0) { unsigned int bdsIntWidth = static_cast(bdsWidth); - if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth) + unsigned int bdsIntHeight = static_cast(bdsHeight); + if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth && + !(bdsIntHeight % BDS_ALIGN_H) && bdsHeight >= minBDSHeight) calculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf); } @@ -212,10 +218,14 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa sf = bdsSF; while (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) { float bdsWidth = static_cast(iif.width) / sf; + float bdsHeight = static_cast(iif.height) / sf; - if (std::fmod(bdsWidth, 1.0) == 0) { + if (std::fmod(bdsWidth, 1.0) == 0 && + std::fmod(bdsHeight, 1.0) == 0) { unsigned int bdsIntWidth = static_cast(bdsWidth); - if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth) + unsigned int bdsIntHeight = static_cast(bdsHeight); + if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth && + !(bdsIntHeight % BDS_ALIGN_H) && bdsHeight >= minBDSHeight) calculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf); } From patchwork Mon May 3 09:27:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12164 X-Patchwork-Delegate: jacopo@jmondi.org 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 92A25BDE78 for ; Mon, 3 May 2021 09:26:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE86B6892B; Mon, 3 May 2021 11:26:26 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AB0EF602C0 for ; Mon, 3 May 2021 11:26:25 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 77ECCE0009 for ; Mon, 3 May 2021 09:26:25 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:27:01 +0200 Message-Id: <20210503092705.15562-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/7] libcamera: ipu3: imgu: Fix BDS height calculation 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 IF rectangle height is iteratively computed by first subtracting the scaling factor to the estimated height, then in a successive loop by adding the same scaling factor until the maximum IF size is not reached. As the computed IF height is not cached in any variable, the second loop over-writes the result of the first one, even if the BDS alignment condition is not satisfied. Fix this by caching the result of the two iterations, and use the one that produced any result, with a preference for the one produced by the second loop, as implemented in the reference python script. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index 36fee31c1962..ea654e57b0e7 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -129,10 +129,10 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc float bdsHeight; if (!isSameRatio(pipe->input, gdc)) { + unsigned int foundIfHeights[2] = { 0, 0 }; float estIFHeight = (iif.width * gdc.height) / static_cast(gdc.width); estIFHeight = std::clamp(estIFHeight, minIFHeight, iif.height); - bool found = false; ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H); while (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) { @@ -142,7 +142,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc unsigned int bdsIntHeight = static_cast(bdsHeight); if (!(bdsIntHeight % BDS_ALIGN_H)) { - found = true; + foundIfHeights[0] = ifHeight; break; } } @@ -158,7 +158,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc unsigned int bdsIntHeight = static_cast(bdsHeight); if (!(bdsIntHeight % BDS_ALIGN_H)) { - found = true; + foundIfHeights[1] = ifHeight; break; } } @@ -166,7 +166,12 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc ifHeight += IF_ALIGN_H; } - if (found) { + if (foundIfHeights[0]) + ifHeight = foundIfHeights[0]; + if (foundIfHeights[1]) + ifHeight = foundIfHeights[1]; + + if (foundIfHeights[0] || foundIfHeights[1]) { unsigned int bdsIntHeight = static_cast(bdsHeight); pipeConfigs.push_back({ bdsSF, { iif.width, ifHeight }, From patchwork Mon May 3 09:27:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12165 X-Patchwork-Delegate: jacopo@jmondi.org 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 099B8BDE78 for ; Mon, 3 May 2021 09:26:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 30D486892E; Mon, 3 May 2021 11:26:29 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0DCE268909 for ; Mon, 3 May 2021 11:26:26 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id CFA6EE0009 for ; Mon, 3 May 2021 09:26:25 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:27:02 +0200 Message-Id: <20210503092705.15562-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/7] libcamera: ipu3: imgu: Fix IF height selection 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 to calculateBDSHeight() function the first hunk of commit 243d134 ("Fix some bug for some resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git. The condition for the computed IF rectangle height to be matched against the desired alignment now makes sure that it is included in the minimum and maximum acceptable values. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Signed-off-by: Jacopo Mondi Acked-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index ea654e57b0e7..feee2cc55abd 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -135,7 +135,8 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc estIFHeight = std::clamp(estIFHeight, minIFHeight, iif.height); ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H); - while (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) { + while (ifHeight >= minIFHeight && ifHeight <= iif.height && + ifHeight / bdsSF >= minBDSHeight) { bdsHeight = ifHeight / bdsSF; if (std::fmod(bdsHeight, 1.0) == 0) { @@ -151,7 +152,8 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc } ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H); - while (ifHeight <= iif.height && ifHeight / bdsSF >= minBDSHeight) { + while (ifHeight >= minIFHeight && ifHeight <= iif.height && + ifHeight / bdsSF >= minBDSHeight) { bdsHeight = ifHeight / bdsSF; if (std::fmod(bdsHeight, 1.0) == 0) { From patchwork Mon May 3 09:27:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12166 X-Patchwork-Delegate: jacopo@jmondi.org 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 513E7BDE79 for ; Mon, 3 May 2021 09:26:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 81A2468922; Mon, 3 May 2021 11:26:29 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7133A68922 for ; Mon, 3 May 2021 11:26:26 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 3E710E0009 for ; Mon, 3 May 2021 09:26:26 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:27:03 +0200 Message-Id: <20210503092705.15562-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/7] libcamera: ipu3: imgu: Fix BSD height size comparison 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" Fix a size comparison when iterating on the BDS sizes to accepts values that are equal to the minimum accepted height. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index feee2cc55abd..fa8cf7eeef19 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -182,7 +182,7 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc } } else { ifHeight = utils::alignUp(iif.height, IF_ALIGN_H); - while (ifHeight > minIFHeight && ifHeight / bdsSF >= minBDSHeight) { + while (ifHeight >= minIFHeight && ifHeight / bdsSF >= minBDSHeight) { bdsHeight = ifHeight / bdsSF; if (std::fmod(ifHeight, 1.0) == 0 && std::fmod(bdsHeight, 1.0) == 0) { From patchwork Mon May 3 09:27:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12167 X-Patchwork-Delegate: jacopo@jmondi.org 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 7DC00BDE78 for ; Mon, 3 May 2021 09:26:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DAA2868925; Mon, 3 May 2021 11:26:29 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB2156892A for ; Mon, 3 May 2021 11:26:26 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 99BF1E0003 for ; Mon, 3 May 2021 09:26:26 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:27:04 +0200 Message-Id: <20210503092705.15562-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/7] libcamera: ipu3: imgu: Add pipe calculation debug 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" Add pipe calculation debug with a new associated log category. This helps compare the pipe calculation with the one performed by the python script. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 34 ++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index fa8cf7eeef19..c874a07e8da6 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -23,6 +23,7 @@ namespace libcamera { LOG_DECLARE_CATEGORY(IPU3) +LOG_DEFINE_CATEGORY(ImgUPipe) namespace { @@ -128,6 +129,8 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc unsigned int ifHeight; float bdsHeight; + LOG(ImgUPipe, Debug) << "BDS sf: " << bdsSF << ", BDS width: " << bdsWidth; + if (!isSameRatio(pipe->input, gdc)) { unsigned int foundIfHeights[2] = { 0, 0 }; float estIFHeight = (iif.width * gdc.height) / @@ -135,6 +138,9 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc estIFHeight = std::clamp(estIFHeight, minIFHeight, iif.height); ifHeight = utils::alignUp(estIFHeight, IF_ALIGN_H); + LOG(ImgUPipe, Debug) << "Estimated IF Height: " << estIFHeight + << ", IF Height: " << ifHeight; + while (ifHeight >= minIFHeight && ifHeight <= iif.height && ifHeight / bdsSF >= minBDSHeight) { @@ -175,9 +181,15 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc if (foundIfHeights[0] || foundIfHeights[1]) { unsigned int bdsIntHeight = static_cast(bdsHeight); + Size foundIf{ iif.width, ifHeight }; + Size foundBds{ bdsWidth, bdsIntHeight }; - pipeConfigs.push_back({ bdsSF, { iif.width, ifHeight }, - { bdsWidth, bdsIntHeight }, gdc }); + LOG(ImgUPipe, Debug) + << "IF: " << foundIf.toString() + << ", BDS: " << foundBds.toString() + << ", GDC: " << gdc.toString(); + + pipeConfigs.push_back({ bdsSF, foundIf, foundBds, gdc }); return; } } else { @@ -190,8 +202,15 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc if (!(ifHeight % IF_ALIGN_H) && !(bdsIntHeight % BDS_ALIGN_H)) { - pipeConfigs.push_back({ bdsSF, { iif.width, ifHeight }, - { bdsWidth, bdsIntHeight }, gdc }); + Size foundIf{ iif.width, ifHeight }; + Size foundBds{ bdsWidth, bdsIntHeight }; + + LOG(ImgUPipe, Debug) + << "IF: " << foundIf.toString() + << ", BDS: " << foundBds.toString() + << ", GDC: " << gdc.toString(); + + pipeConfigs.push_back({ bdsSF, foundIf, foundBds, gdc }); } } @@ -269,6 +288,8 @@ Size calculateGDC(ImgUDevice::Pipe *pipe) gdc.width = main.width * sf; gdc.height = main.height * sf; + LOG(ImgUPipe, Debug) << "GDC: " << gdc.toString(); + return gdc; } @@ -286,6 +307,11 @@ FOV calcFOV(const Size &in, const ImgUDevice::PipeConfig &pipe) fov.w = (inW - (ifCropW + gdcCropW)) / inW; fov.h = (inH - (ifCropH + gdcCropH)) / inH; + LOG(ImgUPipe, Debug) + << "IF (" << pipe.iif.toString() << ") - BDS (" + << pipe.bds.toString() << ") - GDC (" << pipe.gdc.toString() + << ") -> FOV: " << fov.w << "x" << fov.h; + return fov; } From patchwork Mon May 3 09:27:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12168 X-Patchwork-Delegate: jacopo@jmondi.org 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 9F7E4BDE7A for ; Mon, 3 May 2021 09:26:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 055576892A; Mon, 3 May 2021 11:26:30 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4063568926 for ; Mon, 3 May 2021 11:26:27 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 03E90E0003 for ; Mon, 3 May 2021 09:26:26 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:27:05 +0200 Message-Id: <20210503092705.15562-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 7/7] libcamera: ipu3: imgu: Bump script version 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" Update the revision of the ImgU Python configuration tool the libcamera implementation is based on to commit 243d134 ("Fix some bug for some resolutions"). Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index c874a07e8da6..b5143ef7ed8a 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -31,7 +31,7 @@ namespace { * The procedure to calculate the ImgU pipe configuration has been ported * from the pipe_config.py python script, available at: * https://github.com/intel/intel-ipu3-pipecfg - * at revision: 61e83f2f7606 ("Add more information into README") + * at revision: 243d134 ("Fix some bug for some resolutions") */ static constexpr unsigned int FILTER_W = 4;