diff mbox

[v2,4/4] Add support to libv4l to use orientation from VIDIOC_ENUMINPUT

Message ID 200903292328.09957.linux@baker-net.org.uk (mailing list archive)
State RFC
Headers show

Commit Message

Adam Baker March 29, 2009, 10:28 p.m. UTC
Add check to libv4l of the sensor orientation as reported by
VIDIOC_ENUMINPUT

Signed-off-by: Adam Baker <linux@baker-net.org.uk>

---

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Hans de Goede March 30, 2009, 8:30 a.m. UTC | #1
On 03/30/2009 12:28 AM, Adam Baker wrote:
> Add check to libv4l of the sensor orientation as reported by
> VIDIOC_ENUMINPUT
>
> Signed-off-by: Adam Baker<linux@baker-net.org.uk>
>

Looks good, thanks. I'll apply this to my libv4l tree, as soon
as its certain that the matching kernel changes will go in to
the kernel without any API changes.

Thanks & Regards,

Hans

> ---
> diff -r a647c2dfa989 v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c
> --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	Tue Jan 20 11:25:54 2009 +0100
> +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	Sun Mar 29 22:59:56 2009 +0100
> @@ -29,6 +29,11 @@
>   #define MIN(a,b) (((a)<(b))?(a):(b))
>   #define ARRAY_SIZE(x) ((int)sizeof(x)/(int)sizeof((x)[0]))
>
> +/* Workaround this potentially being missing from videodev2.h */
> +#ifndef V4L2_IN_ST_VFLIP
> +#define V4L2_IN_ST_VFLIP       0x00000020 /* Output is flipped vertically */
> +#endif
> +
>   /* Note for proper functioning of v4lconvert_enum_fmt the first entries in
>     supported_src_pixfmts must match with the entries in supported_dst_pixfmts */
>   #define SUPPORTED_DST_PIXFMTS \
> @@ -134,6 +139,7 @@
>     int i, j;
>     struct v4lconvert_data *data = calloc(1, sizeof(struct v4lconvert_data));
>     struct v4l2_capability cap;
> +  struct v4l2_input input;
>
>     if (!data)
>       return NULL;
> @@ -161,6 +167,13 @@
>
>     /* Check if this cam has any special flags */
>     data->flags = v4lconvert_get_flags(data->fd);
> +  if ((syscall(SYS_ioctl, fd, VIDIOC_G_INPUT,&input.index) == 0)&&
> +      (syscall(SYS_ioctl, fd, VIDIOC_ENUMINPUT,&input) == 0)) {
> +    /* Don't yet support independent HFLIP and VFLIP so getting
> +     * image the right way up is highest priority. */
> +    if (input.status&  V4L2_IN_ST_VFLIP)
> +      data->flags |= V4LCONVERT_ROTATE_180;
> +  }
>     if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP,&cap) == 0) {
>       if (!strcmp((char *)cap.driver, "uvcvideo"))
>         data->flags |= V4LCONVERT_IS_UVC;
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mauro Carvalho Chehab April 5, 2009, 12:12 p.m. UTC | #2
On Mon, 30 Mar 2009 10:30:22 +0200
Hans de Goede <j.w.r.degoede@hhs.nl> wrote:

> On 03/30/2009 12:28 AM, Adam Baker wrote:
> > Add check to libv4l of the sensor orientation as reported by
> > VIDIOC_ENUMINPUT
> >
> > Signed-off-by: Adam Baker<linux@baker-net.org.uk>
> >
> 
> Looks good, thanks. I'll apply this to my libv4l tree, as soon
> as its certain that the matching kernel changes will go in to
> the kernel without any API changes.

kernel patches merged. As per your request, I'm letting the libv4l one for you to take care.


Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hans de Goede April 10, 2009, 11:34 a.m. UTC | #3
Thanks,

I've applied this to my tree, it will be part of the next libv4l
release.

Regards,

Hans

On 03/30/2009 12:28 AM, Adam Baker wrote:
> Add check to libv4l of the sensor orientation as reported by
> VIDIOC_ENUMINPUT
>
> Signed-off-by: Adam Baker<linux@baker-net.org.uk>
>
> ---
> diff -r a647c2dfa989 v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c
> --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	Tue Jan 20 11:25:54 2009 +0100
> +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	Sun Mar 29 22:59:56 2009 +0100
> @@ -29,6 +29,11 @@
>   #define MIN(a,b) (((a)<(b))?(a):(b))
>   #define ARRAY_SIZE(x) ((int)sizeof(x)/(int)sizeof((x)[0]))
>
> +/* Workaround this potentially being missing from videodev2.h */
> +#ifndef V4L2_IN_ST_VFLIP
> +#define V4L2_IN_ST_VFLIP       0x00000020 /* Output is flipped vertically */
> +#endif
> +
>   /* Note for proper functioning of v4lconvert_enum_fmt the first entries in
>     supported_src_pixfmts must match with the entries in supported_dst_pixfmts */
>   #define SUPPORTED_DST_PIXFMTS \
> @@ -134,6 +139,7 @@
>     int i, j;
>     struct v4lconvert_data *data = calloc(1, sizeof(struct v4lconvert_data));
>     struct v4l2_capability cap;
> +  struct v4l2_input input;
>
>     if (!data)
>       return NULL;
> @@ -161,6 +167,13 @@
>
>     /* Check if this cam has any special flags */
>     data->flags = v4lconvert_get_flags(data->fd);
> +  if ((syscall(SYS_ioctl, fd, VIDIOC_G_INPUT,&input.index) == 0)&&
> +      (syscall(SYS_ioctl, fd, VIDIOC_ENUMINPUT,&input) == 0)) {
> +    /* Don't yet support independent HFLIP and VFLIP so getting
> +     * image the right way up is highest priority. */
> +    if (input.status&  V4L2_IN_ST_VFLIP)
> +      data->flags |= V4LCONVERT_ROTATE_180;
> +  }
>     if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP,&cap) == 0) {
>       if (!strcmp((char *)cap.driver, "uvcvideo"))
>         data->flags |= V4LCONVERT_IS_UVC;
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff -r a647c2dfa989 v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c
--- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	Tue Jan 20 11:25:54 2009 +0100
+++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	Sun Mar 29 22:59:56 2009 +0100
@@ -29,6 +29,11 @@ 
 #define MIN(a,b) (((a)<(b))?(a):(b))
 #define ARRAY_SIZE(x) ((int)sizeof(x)/(int)sizeof((x)[0]))
 
+/* Workaround this potentially being missing from videodev2.h */
+#ifndef V4L2_IN_ST_VFLIP
+#define V4L2_IN_ST_VFLIP       0x00000020 /* Output is flipped vertically */
+#endif
+
 /* Note for proper functioning of v4lconvert_enum_fmt the first entries in
   supported_src_pixfmts must match with the entries in supported_dst_pixfmts */
 #define SUPPORTED_DST_PIXFMTS \
@@ -134,6 +139,7 @@ 
   int i, j;
   struct v4lconvert_data *data = calloc(1, sizeof(struct v4lconvert_data));
   struct v4l2_capability cap;
+  struct v4l2_input input;
 
   if (!data)
     return NULL;
@@ -161,6 +167,13 @@ 
 
   /* Check if this cam has any special flags */
   data->flags = v4lconvert_get_flags(data->fd);
+  if ((syscall(SYS_ioctl, fd, VIDIOC_G_INPUT, &input.index) == 0) &&
+      (syscall(SYS_ioctl, fd, VIDIOC_ENUMINPUT, &input) == 0)) {
+    /* Don't yet support independent HFLIP and VFLIP so getting
+     * image the right way up is highest priority. */
+    if (input.status & V4L2_IN_ST_VFLIP)
+      data->flags |= V4LCONVERT_ROTATE_180;
+  }
   if (syscall(SYS_ioctl, fd, VIDIOC_QUERYCAP, &cap) == 0) {
     if (!strcmp((char *)cap.driver, "uvcvideo"))
       data->flags |= V4LCONVERT_IS_UVC;