From patchwork Thu May 13 15:21:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12272 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 75380C31F1 for ; Thu, 13 May 2021 15:20:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F62568923; Thu, 13 May 2021 17:20:40 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B97D688E4 for ; Thu, 13 May 2021 17:20:38 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B77F5C0005; Thu, 13 May 2021 15:20:36 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:09 +0200 Message-Id: <20210513152116.17666-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/8] 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. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Acked-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 36 ++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index d5cf05b0c421..acc625ab0fac 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -394,19 +394,45 @@ 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 = std::min(IF_ALIGN_W, + in.width - IF_CROP_MAX_W); + unsigned int minIfHeight = std::min(IF_ALIGN_H, + 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 = std::min(IF_ALIGN_W, in.width - IF_CROP_MAX_W); + minIfHeight = std::min(IF_ALIGN_H, 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 Thu May 13 15:21:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12273 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 4E6F8C31F1 for ; Thu, 13 May 2021 15:20:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8557C68926; Thu, 13 May 2021 17:20:40 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D5243688E4 for ; Thu, 13 May 2021 17:20:38 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 41868C0006; Thu, 13 May 2021 15:20:38 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:10 +0200 Message-Id: <20210513152116.17666-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/8] libcamera: ipu3: imgu: Filter resolutions < IF_CROP_MAX 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" As reported in https://bugs.libcamera.org/show_bug.cgi?id=32 allowing resolutions < IF_CROP_MAX leads to a not manageable number configurations to be tested, slowing down the ImgU pipe configuration to a point which is not acceptable for production devices. Filter all resolutions < IF_CROP_MAX to maintain the run-time complexity acceptable and remove the safety check that was meant to avoid overflows when computing the IF rectangle sizes. Bug: https://bugs.libcamera.org/show_bug.cgi?id=32 Signed-off-by: Jacopo Mondi Reviewed-by: Hirokazu Honda Reviewed-by: Jean-Michel Hautbois --- src/libcamera/pipeline/ipu3/imgu.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index acc625ab0fac..f25f14a71e9e 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -392,6 +392,17 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) LOG(IPU3, Debug) << "vf: " << pipe->viewfinder.toString(); const Size &in = pipe->input; + + /* + * \todo Filter out all resolutions < IF_CROP_MAX. + * See https://bugs.libcamera.org/show_bug.cgi?id=32 + */ + if (in.width < IF_CROP_MAX_W || in.height < IF_CROP_MAX_H) { + LOG(IPU3, Error) << "Input resolution " << in.toString() + << " not supported"; + return {}; + } + Size gdc = calculateGDC(pipe); float bdsSF = static_cast(in.width) / gdc.width; @@ -400,10 +411,8 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) /* 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 = std::min(IF_ALIGN_W, - in.width - IF_CROP_MAX_W); - unsigned int minIfHeight = std::min(IF_ALIGN_H, - in.height - IF_CROP_MAX_H); + unsigned int minIfWidth = in.width - IF_CROP_MAX_W; + unsigned int minIfHeight = in.height - IF_CROP_MAX_H; while (ifWidth >= minIfWidth) { while (ifHeight >= minIfHeight) { Size iif{ ifWidth, ifHeight }; @@ -417,8 +426,8 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) /* Repeat search by scaling width first. */ ifWidth = utils::alignUp(in.width, IF_ALIGN_W); ifHeight = utils::alignUp(in.height, IF_ALIGN_H); - minIfWidth = std::min(IF_ALIGN_W, in.width - IF_CROP_MAX_W); - minIfHeight = std::min(IF_ALIGN_H, in.height - IF_CROP_MAX_H); + minIfWidth = in.width - IF_CROP_MAX_W; + minIfHeight = in.height - IF_CROP_MAX_H; while (ifHeight >= minIfHeight) { /* * \todo This procedure is probably broken: From patchwork Thu May 13 15:21:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12274 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 51021C31F1 for ; Thu, 13 May 2021 15:20:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1BB5068922; Thu, 13 May 2021 17:20:43 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9925D688E4 for ; Thu, 13 May 2021 17:20:40 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 1B708C0006; Thu, 13 May 2021 15:20:38 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:11 +0200 Message-Id: <20210513152116.17666-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/8] 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. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois 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 f25f14a71e9e..d878a029ad84 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 Thu May 13 15:21:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12275 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 8AB70C31F1 for ; Thu, 13 May 2021 15:20:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 59E1868925; Thu, 13 May 2021 17:20:44 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5818068909 for ; Thu, 13 May 2021 17:20:42 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id CEEAAC0002; Thu, 13 May 2021 15:20:40 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:12 +0200 Message-Id: <20210513152116.17666-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/8] 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. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index d878a029ad84..a325b787d916 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 foundIfHeight = 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; + foundIfHeight = 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; + foundIfHeight = ifHeight; break; } } @@ -166,10 +166,10 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc ifHeight += IF_ALIGN_H; } - if (found) { + if (foundIfHeight) { unsigned int bdsIntHeight = static_cast(bdsHeight); - pipeConfigs.push_back({ bdsSF, { iif.width, ifHeight }, + pipeConfigs.push_back({ bdsSF, { iif.width, foundIfHeight }, { bdsWidth, bdsIntHeight }, gdc }); return; } From patchwork Thu May 13 15:21:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12276 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 B77DFC31F1 for ; Thu, 13 May 2021 15:20:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 862636892F; Thu, 13 May 2021 17:20:48 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 005B4688E4 for ; Thu, 13 May 2021 17:20:43 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 926E4C0004; Thu, 13 May 2021 15:20:42 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:13 +0200 Message-Id: <20210513152116.17666-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/8] 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. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois 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 a325b787d916..5912ae4dfc87 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 Thu May 13 15:21:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12277 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 735CEC31F1 for ; Thu, 13 May 2021 15:20:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0E1CB68923; Thu, 13 May 2021 17:20:49 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BDD0A688E4 for ; Thu, 13 May 2021 17:20:45 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 3BB75C000C; Thu, 13 May 2021 15:20:44 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:14 +0200 Message-Id: <20210513152116.17666-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/8] 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. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart 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 5912ae4dfc87..df5a1b5b0826 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -177,7 +177,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 Thu May 13 15:21:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12278 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 901C7C31F1 for ; Thu, 13 May 2021 15:20:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 229CC68926; Thu, 13 May 2021 17:20:50 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B3F24688E4 for ; Thu, 13 May 2021 17:20:47 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id E8E90C0013; Thu, 13 May 2021 15:20:45 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:15 +0200 Message-Id: <20210513152116.17666-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 7/8] 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. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart 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 df5a1b5b0826..07e64e957999 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 foundIfHeight = 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) { @@ -170,9 +176,15 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc if (foundIfHeight) { unsigned int bdsIntHeight = static_cast(bdsHeight); + Size foundIf{ iif.width, foundIfHeight }; + Size foundBds{ bdsWidth, bdsIntHeight }; - pipeConfigs.push_back({ bdsSF, { iif.width, foundIfHeight }, - { bdsWidth, bdsIntHeight }, gdc }); + LOG(ImgUPipe, Debug) + << "IF: " << foundIf.toString() + << ", BDS: " << foundBds.toString() + << ", GDC: " << gdc.toString(); + + pipeConfigs.push_back({ bdsSF, foundIf, foundBds, gdc }); return; } } else { @@ -185,8 +197,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 }); } } @@ -264,6 +283,8 @@ Size calculateGDC(ImgUDevice::Pipe *pipe) gdc.width = main.width * sf; gdc.height = main.height * sf; + LOG(ImgUPipe, Debug) << "GDC: " << gdc.toString(); + return gdc; } @@ -281,6 +302,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 Thu May 13 15:21:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12279 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 949A0C31F1 for ; Thu, 13 May 2021 15:20:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 49BC368925; Thu, 13 May 2021 17:20:52 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C774D68920 for ; Thu, 13 May 2021 17:20:48 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id E88E5C000F; Thu, 13 May 2021 15:20:47 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:16 +0200 Message-Id: <20210513152116.17666-9-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 8/8] 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