[libcamera-devel] libcamera: pipeline: vimc: Fix configuration validation

Message ID 20200825170801.17513-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 3bce337fbe5caeab6064e1969fb2fd0c537d57db
Headers show
Series
  • [libcamera-devel] libcamera: pipeline: vimc: Fix configuration validation
Related show

Commit Message

Laurent Pinchart Aug. 25, 2020, 5:08 p.m. UTC
The sensor aligns the width and height to multiples of two pixels, and
the scaler has a x3 hardcoded factor. The output size must thus be
aligned to 6 pixels, not 3. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/vimc/vimc.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Paul Elder Aug. 25, 2020, 11:36 p.m. UTC | #1
Hi Laurent,

On Tue, Aug 25, 2020 at 08:08:01PM +0300, Laurent Pinchart wrote:
> The sensor aligns the width and height to multiples of two pixels, and
> the scaler has a x3 hardcoded factor. The output size must thus be
> aligned to 6 pixels, not 3. Fix it.
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/libcamera/pipeline/vimc/vimc.cpp | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> index 7e237650b448..d192670bbc8f 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -149,11 +149,15 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
>  	/* Clamp the size based on the device limits. */
>  	const Size size = cfg.size;
>  
> -	/* The scaler hardcodes a x3 scale-up ratio. */
> +	/*
> +	 * The scaler hardcodes a x3 scale-up ratio, and the sensor output size
> +	 * is aligned to two pixels in both directions. The output width and
> +	 * height thus have to be multiples of 6.
> +	 */
>  	cfg.size.width = std::max(48U, std::min(4096U, cfg.size.width));
>  	cfg.size.height = std::max(48U, std::min(2160U, cfg.size.height));
> -	cfg.size.width -= cfg.size.width % 3;
> -	cfg.size.height -= cfg.size.height % 3;
> +	cfg.size.width -= cfg.size.width % 6;
> +	cfg.size.height -= cfg.size.height % 6;
>  
>  	if (cfg.size != size) {
>  		LOG(VIMC, Debug)
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham Aug. 26, 2020, 8:13 a.m. UTC | #2
Hi Laurent,

On 25/08/2020 18:08, Laurent Pinchart wrote:
> The sensor aligns the width and height to multiples of two pixels, and
> the scaler has a x3 hardcoded factor. The output size must thus be
> aligned to 6 pixels, not 3. Fix it.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/pipeline/vimc/vimc.cpp | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
> index 7e237650b448..d192670bbc8f 100644
> --- a/src/libcamera/pipeline/vimc/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc/vimc.cpp
> @@ -149,11 +149,15 @@ CameraConfiguration::Status VimcCameraConfiguration::validate()
>  	/* Clamp the size based on the device limits. */
>  	const Size size = cfg.size;
>  
> -	/* The scaler hardcodes a x3 scale-up ratio. */
> +	/*
> +	 * The scaler hardcodes a x3 scale-up ratio, and the sensor output size
> +	 * is aligned to two pixels in both directions. The output width and
> +	 * height thus have to be multiples of 6.
> +	 */
>  	cfg.size.width = std::max(48U, std::min(4096U, cfg.size.width));
>  	cfg.size.height = std::max(48U, std::min(2160U, cfg.size.height));
> -	cfg.size.width -= cfg.size.width % 3;
> -	cfg.size.height -= cfg.size.height % 3;
> +	cfg.size.width -= cfg.size.width % 6;
> +	cfg.size.height -= cfg.size.height % 6;
>  
>  	if (cfg.size != size) {
>  		LOG(VIMC, Debug)
>

Patch

diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp
index 7e237650b448..d192670bbc8f 100644
--- a/src/libcamera/pipeline/vimc/vimc.cpp
+++ b/src/libcamera/pipeline/vimc/vimc.cpp
@@ -149,11 +149,15 @@  CameraConfiguration::Status VimcCameraConfiguration::validate()
 	/* Clamp the size based on the device limits. */
 	const Size size = cfg.size;
 
-	/* The scaler hardcodes a x3 scale-up ratio. */
+	/*
+	 * The scaler hardcodes a x3 scale-up ratio, and the sensor output size
+	 * is aligned to two pixels in both directions. The output width and
+	 * height thus have to be multiples of 6.
+	 */
 	cfg.size.width = std::max(48U, std::min(4096U, cfg.size.width));
 	cfg.size.height = std::max(48U, std::min(2160U, cfg.size.height));
-	cfg.size.width -= cfg.size.width % 3;
-	cfg.size.height -= cfg.size.height % 3;
+	cfg.size.width -= cfg.size.width % 6;
+	cfg.size.height -= cfg.size.height % 6;
 
 	if (cfg.size != size) {
 		LOG(VIMC, Debug)