[libcamera-devel] [PATCH v3 10/22] v4l2: v4l2_camera_proxy: Use stream config in tryFormat

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Jul 4 21:01:42 CEST 2020


Hi Paul,

Thank you for the patch.

On Sat, Jul 04, 2020 at 10:31:28PM +0900, Paul Elder wrote:
> For handling try_fmt, the values should be filled in by validating the
> stream configuration, and not by recalculating them. Use
> V4L2Camera::validateConfiguration to obtain size, format, stride, and
> frameSize values.
> 
> Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>

Squashed with 07/22, and reordered appropriately to avoid using the
stride() and frameSize() functions (although that last part isn't really
mandatory, I thought it would be nice from a bisection point of view,
but the code is not working correctly today anyway, so there's no
regression),

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
> New in v3
> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 9121d3d..1a1753b 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -299,24 +299,19 @@ void V4L2CameraProxy::tryFormat(struct v4l2_format *arg)
>  {
>  	V4L2PixelFormat v4l2Format = V4L2PixelFormat(arg->fmt.pix.pixelformat);
>  	PixelFormat format = PixelFormatInfo::info(v4l2Format).format;
> -	const std::vector<PixelFormat> &formats =
> -		streamConfig_.formats().pixelformats();
> -	if (std::find(formats.begin(), formats.end(), format) == formats.end())
> -		format = streamConfig_.formats().pixelformats()[0];
> -
>  	Size size(arg->fmt.pix.width, arg->fmt.pix.height);
> -	const std::vector<Size> &sizes = streamConfig_.formats().sizes(format);
> -	if (std::find(sizes.begin(), sizes.end(), size) == sizes.end())
> -		size = streamConfig_.formats().sizes(format)[0];
>  
> -	const PixelFormatInfo &formatInfo = PixelFormatInfo::info(format);
> +	StreamConfiguration config;
> +	vcam_->validateConfiguration(&config, size, format);
> +
> +	const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);
>  
> -	arg->fmt.pix.width        = size.width;
> -	arg->fmt.pix.height       = size.height;
> -	arg->fmt.pix.pixelformat  = formatInfo.v4l2Format;
> +	arg->fmt.pix.width        = config.size.width;
> +	arg->fmt.pix.height       = config.size.height;
> +	arg->fmt.pix.pixelformat  = info.v4l2Format;
>  	arg->fmt.pix.field        = V4L2_FIELD_NONE;
> -	arg->fmt.pix.bytesperline = formatInfo.stride(size.width, 0);
> -	arg->fmt.pix.sizeimage    = formatInfo.frameSize(size);
> +	arg->fmt.pix.bytesperline = config.stride;
> +	arg->fmt.pix.sizeimage    = config.frameSize;
>  	arg->fmt.pix.colorspace   = V4L2_COLORSPACE_SRGB;
>  	arg->fmt.pix.priv         = V4L2_PIX_FMT_PRIV_MAGIC;
>  	arg->fmt.pix.ycbcr_enc    = V4L2_YCBCR_ENC_DEFAULT;

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list