From patchwork Mon May 31 08:03:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huzaifa Sidhpurwala X-Patchwork-Id: 103223 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 o4V85YlU031688 for ; Mon, 31 May 2010 08:05:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756222Ab0EaIFd (ORCPT ); Mon, 31 May 2010 04:05:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34785 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755877Ab0EaIFc (ORCPT ); Mon, 31 May 2010 04:05:32 -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 o4V85Vi3030303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 31 May 2010 04:05:32 -0400 Received: from localhost.localdomain (shazarik.pnq.redhat.com [10.65.192.171]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4V85TJs004281; Mon, 31 May 2010 04:05:30 -0400 From: huzaifas@redhat.com To: linux-media@vger.kernel.org Cc: hdegoede@redhat.com, Huzaifa Sidhpurwala Subject: [PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1 Date: Mon, 31 May 2010 13:33:28 +0530 Message-Id: <1275293008-3261-1-git-send-email-huzaifas@redhat.com> 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]); Mon, 31 May 2010 08:05:35 +0000 (UTC) diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c index e13feba..5b2dc29 100644 --- a/lib/libv4l1/libv4l1.c +++ b/lib/libv4l1/libv4l1.c @@ -804,6 +804,51 @@ int v4l1_ioctl(int fd, unsigned long int request, ...) break; } + case VIDIOCGFBUF: { + struct video_buffer *buffer = arg; + struct v4l2_framebuffer fbuf = { 0, }; + + result = v4l2_ioctl(fd, VIDIOC_G_FBUF, buffer); + if (result < 0) + break; + + buffer->base = fbuf.base; + buffer->height = fbuf.fmt.height; + buffer->width = fbuf.fmt.width; + + switch (fbuf.fmt.pixelformat) { + case V4L2_PIX_FMT_RGB332: + buffer->depth = 8; + break; + case V4L2_PIX_FMT_RGB555: + buffer->depth = 15; + break; + case V4L2_PIX_FMT_RGB565: + buffer->depth = 16; + break; + case V4L2_PIX_FMT_BGR24: + buffer->depth = 24; + break; + case V4L2_PIX_FMT_BGR32: + buffer->depth = 32; + break; + default: + buffer->depth = 0; + } + + if (fbuf.fmt.bytesperline) { + buffer->bytesperline = fbuf.fmt.bytesperline; + if (!buffer->depth && buffer->width) + buffer->depth = ((fbuf.fmt.bytesperline<<3) + + (buffer->width-1)) + / buffer->width; + } else { + buffer->bytesperline = + (buffer->width * buffer->depth + 7) & 7; + buffer->bytesperline >>= 3; + } + } + default: /* Pass through libv4l2 for applications which are using v4l2 through libv4l1 (this can happen with the v4l1compat.so wrapper preloaded */