[libcamera-devel,v5,14/23] libcamera: raspberrypi: Set default configuration size at validation

Message ID 20200709132835.112593-15-paul.elder@ideasonboard.com
State Not Applicable
Headers show
Series
  • Clean up formats in v4l2-compat and pipeline handlers
Related show

Commit Message

Paul Elder July 9, 2020, 1:28 p.m. UTC
If a native format is not found, a default NV12 format is set. However,
this does not set a default configuration size, sometimes resulting in a
0x0 size. Fix this by setting a default configuration size.

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

---
New in v5, split from "libcamera: raspberrypi: Fill stride and frameSize
at config validation"
---
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart July 9, 2020, 7:17 p.m. UTC | #1
Hi Paul,

(CC'ing Naush)

Thank you for the patch.

On Thu, Jul 09, 2020 at 10:28:26PM +0900, Paul Elder wrote:
> If a native format is not found, a default NV12 format is set. However,
> this does not set a default configuration size, sometimes resulting in a
> 0x0 size. Fix this by setting a default configuration size.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> 
> ---
> New in v5, split from "libcamera: raspberrypi: Fill stride and frameSize
> at config validation"
> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index a08ad6a..5f00500 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -500,6 +500,9 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
>  		if (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {
>  			/* If we cannot find a native format, use a default one. */
>  			cfgPixFmt = formats::NV12;
> +			cfg.size.width = 1920;
> +			cfg.size.height = 1080;
> +

Is this the right fix ? Someone could pass an unsupported pixel format
with a valid size, or the other way around, a valid pixel format with a
null size. It seems to me that you should clamp the size based on the
sensor resolution and the scaler capabilities.

>  			status = Adjusted;
>  		}
>

Patch

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index a08ad6a..5f00500 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -500,6 +500,9 @@  CameraConfiguration::Status RPiCameraConfiguration::validate()
 		if (fmts.find(V4L2PixelFormat::fromPixelFormat(cfgPixFmt, false)) == fmts.end()) {
 			/* If we cannot find a native format, use a default one. */
 			cfgPixFmt = formats::NV12;
+			cfg.size.width = 1920;
+			cfg.size.height = 1080;
+
 			status = Adjusted;
 		}