[libcamera-devel,v3,4/8] libcamera: v4l2_subdevice: Update crop/compose rectangle

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

Commit Message

Jacopo Mondi Feb. 26, 2019, 4:26 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.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/v4l2_subdevice.cpp | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kieran Bingham Feb. 26, 2019, 11:35 p.m. UTC | #1
Hi Jacopo,

On 26/02/2019 16:26, 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.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/v4l2_subdevice.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index f81a521f9e2a..a043a07ff156 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -385,6 +385,11 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
>  		return ret;
>  	}
>  
> +	rect->y = sel.r.left;
> +	rect->x = sel.r.top;

Hrm... am I crazy? or are the x/y coordinates swapped there.
X is horizontal, so it's the left value, right? (pun-intended).


Same comment applies to the sel being set earlier in the function?



> +	rect->w = sel.r.width;
> +	rect->h = sel.r.height;
> +
>  	return 0;
>  }
>  
>
Jacopo Mondi Feb. 27, 2019, 8:26 a.m. UTC | #2
Hi Kieran,

On Tue, Feb 26, 2019 at 11:35:16PM +0000, Kieran Bingham wrote:
> Hi Jacopo,
>
> On 26/02/2019 16:26, 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.
> >
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> > ---
> >  src/libcamera/v4l2_subdevice.cpp | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> > index f81a521f9e2a..a043a07ff156 100644
> > --- a/src/libcamera/v4l2_subdevice.cpp
> > +++ b/src/libcamera/v4l2_subdevice.cpp
> > @@ -385,6 +385,11 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,
> >  		return ret;
> >  	}
> >
> > +	rect->y = sel.r.left;
> > +	rect->x = sel.r.top;
>
> Hrm... am I crazy? or are the x/y coordinates swapped there.
> X is horizontal, so it's the left value, right? (pun-intended).

You're absolutely not, maybe I am, as I've gone through this sequence
quite some time and never noticed :(

>
>
> Same comment applies to the sel being set earlier in the function?

Good spot, thanks for the comment!

>
>
>
> > +	rect->w = sel.r.width;
> > +	rect->h = sel.r.height;
> > +
> >  	return 0;
> >  }
> >
> >
>
> --
> Regards
> --
> Kieran

Patch

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