[libcamera-devel,v5,5/9] libcamera: v4l2_subdevice: Update crop/compose rectangle

Message ID 20190228200151.2948-6-jacopo@jmondi.org
State Superseded
Headers show
Series
  • v4l2_(sub)dev: improvements and tests
Related show

Commit Message

Jacopo Mondi Feb. 28, 2019, 8:01 p.m. UTC
Update the crop/compose rectangle provided to setCrop()/setCompose()
methods with the rectangle sizes set by the device driver after a
S_SELECTION ioctl operation.

While at there, fix the use of 'top' and 'left' field of the selection
rectangle, which where wrongly used.

Fixes: 468176fa07d9 ("libcamera: Add V4L2Subdevice")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/v4l2_subdevice.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Laurent Pinchart Feb. 28, 2019, 10:05 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Thu, Feb 28, 2019 at 09:01:47PM +0100, Jacopo Mondi wrote:
> Update the crop/compose rectangle provided to setCrop()/setCompose()
> methods with the rectangle sizes set by the device driver after a
> S_SELECTION ioctl operation.
> 
> While at there, fix the use of 'top' and 'left' field of the selection
> rectangle, which where wrongly used.

I would have split this in two patches, as it's not really a "while at
it". For both patches you would have received my

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

> Fixes: 468176fa07d9 ("libcamera: Add V4L2Subdevice")
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/v4l2_subdevice.cpp | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index 7f191e072c61..d2f9365a9537 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -342,8 +342,8 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
>  	sel.target = target;
>  	sel.flags = 0;
>  
> -	sel.r.left = rect->y;
> -	sel.r.top = rect->x;
> +	sel.r.left = rect->x;
> +	sel.r.top = rect->y;
>  	sel.r.width = rect->w;
>  	sel.r.height = rect->h;
>  
> @@ -356,6 +356,11 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
>  		return ret;
>  	}
>  
> +	rect->x = sel.r.left;
> +	rect->y = sel.r.top;
> +	rect->w = sel.r.width;
> +	rect->h = sel.r.height;
> +
>  	return 0;
>  }
>

Patch

diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 7f191e072c61..d2f9365a9537 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -342,8 +342,8 @@  int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
 	sel.target = target;
 	sel.flags = 0;
 
-	sel.r.left = rect->y;
-	sel.r.top = rect->x;
+	sel.r.left = rect->x;
+	sel.r.top = rect->y;
 	sel.r.width = rect->w;
 	sel.r.height = rect->h;
 
@@ -356,6 +356,11 @@  int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
 		return ret;
 	}
 
+	rect->x = sel.r.left;
+	rect->y = sel.r.top;
+	rect->w = sel.r.width;
+	rect->h = sel.r.height;
+
 	return 0;
 }