From patchwork Tue May 18 11:12:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huzaifa Sidhpurwala X-Patchwork-Id: 100405 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4IBEEYI003266 for ; Tue, 18 May 2010 11:14:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756701Ab0ERLOM (ORCPT ); Tue, 18 May 2010 07:14:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2779 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756552Ab0ERLOL (ORCPT ); Tue, 18 May 2010 07:14:11 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4IBEBl4020418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 May 2010 07:14:11 -0400 Received: from huzaifas.csb (babylon.pnq.redhat.com [10.65.192.182]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4IBE8Ar017179; Tue, 18 May 2010 07:14:09 -0400 Message-ID: <4BF27601.8010207@redhat.com> Date: Tue, 18 May 2010 16:42:01 +0530 From: Huzaifa Sidhpurwala User-Agent: Thunderbird 2.0.0.24 (X11/20100311) MIME-Version: 1.0 To: Hans de Goede CC: linux-media@vger.kernel.org Subject: [Patch] Moving v4l1 ioctls from kernel to libv4l1 X-Enigmail-Version: 0.96.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 18 May 2010 11:14:14 +0000 (UTC) diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c index eae3b43..8571651 100644 --- a/lib/libv4l1/libv4l1.c +++ b/lib/libv4l1/libv4l1.c @@ -61,6 +61,10 @@ #define V4L1_PIX_FMT_TOUCHED 0x04 #define V4L1_PIX_SIZE_TOUCHED 0x08 +#ifndef min + #define min( a, b ) ( ((a) < (b)) ? (a) : (b) ) +#endif + static pthread_mutex_t v4l1_open_mutex = PTHREAD_MUTEX_INITIALIZER; static struct v4l1_dev_info devices[V4L1_MAX_DEVICES] = { { .fd = -1 }, @@ -130,6 +134,45 @@ static unsigned int pixelformat_to_palette(unsigned int pixelformat) return 0; } +static int count_inputs(int fd) +{ + struct v4l2_input input2; + int i; + for (i = 0;; i++) { + memset(&input2, 0, sizeof(input2)); + input2.index = i; + if (0 != SYS_IOCTL(fd, VIDIOC_ENUMINPUT, &input2)) + break; + } + return i; +} + +static int check_size(int fd,int *maxw,int *maxh) +{ + struct v4l2_fmtdesc desc2; + struct v4l2_format fmt2; + + memset(&desc2, 0, sizeof(desc2)); + memset(&fmt2, 0, sizeof(fmt2)); + + desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + if (0 != SYS_IOCTL(fd, VIDIOC_ENUM_FMT, &desc2)) + goto done; + + fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + fmt2.fmt.pix.width = 10000; + fmt2.fmt.pix.height = 10000; + fmt2.fmt.pix.pixelformat = desc2.pixelformat; + if (0 != SYS_IOCTL(fd, VIDIOC_TRY_FMT, &fmt2)) + goto done; + + *maxw = fmt2.fmt.pix.width; + *maxh = fmt2.fmt.pix.height; + + done: + return 0; +} + static int v4l1_set_format(int index, unsigned int width, unsigned int height, int v4l1_pal, int width_height_may_differ)