From patchwork Sun Mar 29 22:28:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Baker X-Patchwork-Id: 15060 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2TMT8Yq029087 for ; Sun, 29 Mar 2009 22:29:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752251AbZC2W3H (ORCPT ); Sun, 29 Mar 2009 18:29:07 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753432AbZC2W3H (ORCPT ); Sun, 29 Mar 2009 18:29:07 -0400 Received: from mk-outboundfilter-1.mail.uk.tiscali.com ([212.74.114.37]:3996 "EHLO mk-outboundfilter-1.mail.uk.tiscali.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752251AbZC2W3G (ORCPT ); Sun, 29 Mar 2009 18:29:06 -0400 X-Trace: 233208524/mk-outboundfilter-1.mail.uk.tiscali.com/PIPEX/$PIPEX-ACCEPTED/pipex-customers/62.190.239.28/None/linux@baker-net.org.uk X-SBRS: None X-RemoteIP: 62.190.239.28 X-IP-MAIL-FROM: linux@baker-net.org.uk X-MUA: KMail/1.11.1 (Linux/2.6.28-11-generic; KDE/4.2.1; i686; ; ) X-IP-BHB: Once X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjEFAM+Sz0k+vu8c/2dsb2JhbACBUMUEg3oG X-IronPort-AV: E=Sophos;i="4.38,442,1233532800"; d="scan'208";a="233208524" X-IP-Direction: IN Received: from userch028.dsl.pipex.com (HELO gromit.localnet) ([62.190.239.28]) by smtp.pipex.tiscali.co.uk with ESMTP; 29 Mar 2009 23:28:13 +0100 From: Adam Baker To: linux-media@vger.kernel.org, Hans de Goede Subject: [PATCH v2 4/4] Add support to libv4l to use orientation from VIDIOC_ENUMINPUT Date: Sun, 29 Mar 2009 23:28:09 +0100 User-Agent: KMail/1.11.1 (Linux/2.6.28-11-generic; KDE/4.2.1; i686; ; ) Cc: Mauro Carvalho Chehab , "Jean-Francois Moine" , kilgota@banach.math.auburn.edu, Hans Verkuil References: <200903292309.31267.linux@baker-net.org.uk> <200903292322.08660.linux@baker-net.org.uk> <200903292325.16499.linux@baker-net.org.uk> In-Reply-To: <200903292325.16499.linux@baker-net.org.uk> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200903292328.09957.linux@baker-net.org.uk> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add check to libv4l of the sensor orientation as reported by VIDIOC_ENUMINPUT Signed-off-by: Adam Baker --- -- 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 -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;