[libcamera-devel] [PATCH 3/4] v4l2: camera_proxy: Rationalize arguments to format helpers

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue Jan 7 18:24:29 CET 2020


Hi Laurent,

Thanks for your patch.

On 2020-01-06 18:14:16 +0200, Laurent Pinchart wrote:
> To clarify code, adopt the following rules for format helpers:
> 
> - All variables representing V4L2 pixel formats shall use uint32_t
> - All variables representing DRM pixel formats shall use PixelFormat
> - Functions returning positive values only shall not have a signed
>   return type
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>

> ---
>  src/v4l2/v4l2_camera_proxy.cpp | 18 +++++++++---------
>  src/v4l2/v4l2_camera_proxy.h   | 10 +++++-----
>  2 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index dd3ee3e6c6ff..6a222d702e13 100644
> --- a/src/v4l2/v4l2_camera_proxy.cpp
> +++ b/src/v4l2/v4l2_camera_proxy.cpp
> @@ -510,7 +510,7 @@ int V4L2CameraProxy::ioctl(unsigned long request, void *arg)
>  }
>  
>  /* \todo make libcamera export these */
> -int V4L2CameraProxy::bplMultiplier(unsigned int format)
> +unsigned int V4L2CameraProxy::bplMultiplier(uint32_t format)
>  {
>  	switch (format) {
>  	case V4L2_PIX_FMT_NV12:
> @@ -535,8 +535,8 @@ int V4L2CameraProxy::bplMultiplier(unsigned int format)
>  	};
>  }
>  
> -int V4L2CameraProxy::imageSize(unsigned int format,
> -			       unsigned int width, unsigned int height)
> +unsigned int V4L2CameraProxy::imageSize(uint32_t format, unsigned int width,
> +					unsigned int height)
>  {
>  	switch (format) {
>  	case V4L2_PIX_FMT_NV12:
> @@ -563,9 +563,9 @@ int V4L2CameraProxy::imageSize(unsigned int format,
>  	};
>  }
>  
> -unsigned int V4L2CameraProxy::v4l2ToDrm(unsigned int pixelformat)
> +PixelFormat V4L2CameraProxy::v4l2ToDrm(uint32_t format)
>  {
> -	switch (pixelformat) {
> +	switch (format) {
>  	/* RGB formats. */
>  	case V4L2_PIX_FMT_RGB24:
>  		return DRM_FORMAT_BGR888;
> @@ -598,13 +598,13 @@ unsigned int V4L2CameraProxy::v4l2ToDrm(unsigned int pixelformat)
>  	case V4L2_PIX_FMT_NV42:
>  		return DRM_FORMAT_NV42;
>  	default:
> -		return pixelformat;
> +		return format;
>  	};
>  }
>  
> -unsigned int V4L2CameraProxy::drmToV4L2(unsigned int pixelformat)
> +uint32_t V4L2CameraProxy::drmToV4L2(PixelFormat format)
>  {
> -	switch (pixelformat) {
> +	switch (format) {
>  	/* RGB formats. */
>  	case DRM_FORMAT_BGR888:
>  		return V4L2_PIX_FMT_RGB24;
> @@ -637,6 +637,6 @@ unsigned int V4L2CameraProxy::drmToV4L2(unsigned int pixelformat)
>  	case DRM_FORMAT_NV42:
>  		return V4L2_PIX_FMT_NV42;
>  	default:
> -		return pixelformat;
> +		return format;
>  	}
>  }
> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h
> index bef0f0afab3b..3d702084f8ff 100644
> --- a/src/v4l2/v4l2_camera_proxy.h
> +++ b/src/v4l2/v4l2_camera_proxy.h
> @@ -54,12 +54,12 @@ private:
>  	int vidioc_streamon(int *arg);
>  	int vidioc_streamoff(int *arg);
>  
> -	static int bplMultiplier(unsigned int format);
> -	static int imageSize(unsigned int format, unsigned int width,
> -			     unsigned int height);
> +	static unsigned int bplMultiplier(uint32_t format);
> +	static unsigned int imageSize(uint32_t format, unsigned int width,
> +				      unsigned int height);
>  
> -	static unsigned int v4l2ToDrm(unsigned int pixelformat);
> -	static unsigned int drmToV4L2(unsigned int pixelformat);
> +	static PixelFormat v4l2ToDrm(uint32_t format);
> +	static uint32_t drmToV4L2(PixelFormat format);
>  
>  	unsigned int refcount_;
>  	unsigned int index_;
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list