[libcamera-devel] [PATCH] libcamera: camera_sensor: Match V4L2 specification

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Aug 5 23:41:07 CEST 2020


Hi Jacopo,

Thank you for the patch.

On Wed, Aug 05, 2020 at 02:30:04PM +0200, Jacopo Mondi wrote:
> Adjust the top-left corner coordinates of the analogCrop rectangle
> to match the libcamera and V4L2 specification.
> 
> As per the V4L2 selection API specification, all rectangles accessed
> using V4L2_SEL_TGT_* are defined relatively to the full pixel array,
> which is retrieved using the V4L2_SEL_TGT_NATIVE target. Libcamera
> defines the analogCrop rectangle to be defined relatively
> to the active pixel matrix rectangle.
> 
> To compensate the difference in the reference rectangle between the two
> specification, subtract from the TGT_CROP rectangle top-left corner the
> offset of the active pixel array previously obtained with
> TGT_CROP_DEFAULT.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> ---
> 
> This patch depends on the inclusion of the following patch in the
> Linux kernel:
> [PATCH 4/4] media: i2c: imx219: Selection compliance fixes

Let's postpone this until the review discussions related to the above
patch are complete.

> ---
>  src/libcamera/camera_sensor.cpp | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index 350f49accad9..8f09206ff635 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -508,6 +508,18 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
>  		return ret;
>  	}
> 
> +	/*
> +	 * The top-left corner position of the selection rectangle returned by
> +	 * the V4L2_SEL_TGT_CROP target is defined relatively to the full pixel
> +	 * array, while libcamera's analogCrop is defined relatively to the
> +	 * active portion of the pixel matrix.
> +	 *
> +	 * Subtract from the top-left coordinates the offsets of the
> +	 * CROP_DEFAULT target rectangle to align the two.
> +	 */
> +	info->analogCrop.x -= rect.x;
> +	info->analogCrop.y -= rect.y;
> +
>  	/* The bit depth and image size depend on the currently applied format. */
>  	V4L2SubdeviceFormat format{};
>  	ret = subdev_->getFormat(pad_, &format);

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list