[libcamera-devel,v2,4/7] libcamera: ipu3: imgu: Fix IF height selection
diff mbox series

Message ID 20210503092705.15562-5-jacopo@jmondi.org
State Accepted
Delegated to: Jacopo Mondi
Headers show
Series
  • ipu3: imgu: Improve ImgU calculation procedure
Related show

Commit Message

Jacopo Mondi May 3, 2021, 9:27 a.m. UTC
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 <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/ipu3/imgu.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Niklas Söderlund May 3, 2021, 10:56 a.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2021-05-03 11:27:02 +0200, Jacopo Mondi wrote:
> 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 <jeanmichel.hautbois@ideasonboard.com>
> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  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<float>(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) {
> -- 
> 2.31.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Hirokazu Honda May 6, 2021, 5:52 a.m. UTC | #2
Hi Jacopo, thank you for the patch.

On Mon, May 3, 2021 at 7:56 PM Niklas Söderlund <
niklas.soderlund@ragnatech.se> wrote:

> Hi Jacopo,
>
> Thanks for your work.
>
> On 2021-05-03 11:27:02 +0200, Jacopo Mondi wrote:
> > 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 <jeanmichel.hautbois@ideasonboard.com>
> > Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
>
> Acked-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
>
>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>


> > ---
> >  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<float>(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) {
> > --
> > 2.31.1
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
>
> --
> Regards,
> Niklas Söderlund
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
>

Patch
diff mbox series

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<float>(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) {