[libcamera-devel,v6,04/10] libcamera: camera_sensor: Default analogue crop rectangle
diff mbox series

Message ID 20210107094735.11673-5-jacopo@jmondi.org
State Accepted
Delegated to: Jacopo Mondi
Headers show
Series
  • libcamera: camera_sensor: Make validation more strict
Related show

Commit Message

Jacopo Mondi Jan. 7, 2021, 9:47 a.m. UTC
As support for the V4L2_SEL_TGT_CROP selection target used to read the
sensor analogue crop rectangle is schedule to become mandatory but is
still optional, use the sensor's active area size as fallback value to
allow the creation of the CameraSensorInfo in the case the driver does
not support it.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/camera_sensor.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Niklas Söderlund Jan. 13, 2021, 12:29 p.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2021-01-07 10:47:29 +0100, Jacopo Mondi wrote:
> As support for the V4L2_SEL_TGT_CROP selection target used to read the
> sensor analogue crop rectangle is schedule to become mandatory but is
> still optional, use the sensor's active area size as fallback value to
> allow the creation of the CameraSensorInfo in the case the driver does
> not support it.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/camera_sensor.cpp | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
> index 0c9bd4f50cff..e8caa4467643 100644
> --- a/src/libcamera/camera_sensor.cpp
> +++ b/src/libcamera/camera_sensor.cpp
> @@ -643,13 +643,16 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const
>  	 */
>  	info->activeAreaSize = { activeArea_.width, activeArea_.height };
>  
> -	/* It's mandatory for the subdevice to report its crop rectangle. */
> +	/*
> +	 * \todo Support for retreiving the crop rectangle is scheduled to
> +	 * become mandatory. For the time being use the default value if it has
> +	 * been initialized at sensor driver validation time.
> +	 */
>  	int ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &info->analogCrop);
>  	if (ret) {
> +		info->analogCrop = activeArea_;
>  		LOG(CameraSensor, Error)
> -			<< "Failed to construct camera sensor info: "
> -			<< "the camera sensor does not report the crop rectangle";
> -		return ret;
> +			<< "The analogue crop rectangle has been defaulted to the active area size";
>  	}
>  
>  	/*
> -- 
> 2.29.2
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch
diff mbox series

diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp
index 0c9bd4f50cff..e8caa4467643 100644
--- a/src/libcamera/camera_sensor.cpp
+++ b/src/libcamera/camera_sensor.cpp
@@ -643,13 +643,16 @@  int CameraSensor::sensorInfo(CameraSensorInfo *info) const
 	 */
 	info->activeAreaSize = { activeArea_.width, activeArea_.height };
 
-	/* It's mandatory for the subdevice to report its crop rectangle. */
+	/*
+	 * \todo Support for retreiving the crop rectangle is scheduled to
+	 * become mandatory. For the time being use the default value if it has
+	 * been initialized at sensor driver validation time.
+	 */
 	int ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP, &info->analogCrop);
 	if (ret) {
+		info->analogCrop = activeArea_;
 		LOG(CameraSensor, Error)
-			<< "Failed to construct camera sensor info: "
-			<< "the camera sensor does not report the crop rectangle";
-		return ret;
+			<< "The analogue crop rectangle has been defaulted to the active area size";
 	}
 
 	/*