* [PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1
@ 2010-05-31 8:03 huzaifas
2010-06-01 8:41 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: huzaifas @ 2010-05-31 8:03 UTC (permalink / raw)
To: linux-media; +Cc: hdegoede, Huzaifa Sidhpurwala
From: Huzaifa Sidhpurwala <huzaifas@fedora-12.(none)>
Move VIDIOCGFBUF into libv4l1
Signed-off-by: Huzaifa Sidhpurwala <huzaifas@redhat.com>
---
lib/libv4l1/libv4l1.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
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 */
--
1.6.6.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1
2010-05-31 8:03 [PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1 huzaifas
@ 2010-06-01 8:41 ` Hans de Goede
2010-06-01 8:42 ` Huzaifa Sidhpurwala
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2010-06-01 8:41 UTC (permalink / raw)
To: huzaifas; +Cc: linux-media
Hi,
Thanks, I've applied your patch with one small fix,
The else block at the end of was wrongly indented
(one indent level too much) It is the else for the first if, not the second.
Note the first if has a { at the end of the line, and the second does not,
and the else starts with a }.
Regards,
Hans
On 05/31/2010 10:03 AM, huzaifas@redhat.com wrote:
> From: Huzaifa Sidhpurwala<huzaifas@fedora-12.(none)>
>
> Move VIDIOCGFBUF into libv4l1
>
> Signed-off-by: Huzaifa Sidhpurwala<huzaifas@redhat.com>
> ---
> lib/libv4l1/libv4l1.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 45 insertions(+), 0 deletions(-)
>
> 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 */
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1
2010-06-01 8:41 ` Hans de Goede
@ 2010-06-01 8:42 ` Huzaifa Sidhpurwala
0 siblings, 0 replies; 3+ messages in thread
From: Huzaifa Sidhpurwala @ 2010-06-01 8:42 UTC (permalink / raw)
To: Hans de Goede; +Cc: linux-media
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hans de Goede wrote:
> Hi,
>
> Thanks, I've applied your patch with one small fix,
> The else block at the end of was wrongly indented
> (one indent level too much) It is the else for the first if, not the
> second.
> Note the first if has a { at the end of the line, and the second does not,
> and the else starts with a }.
>
Cool , i wonder why checkpatch.pl did not catch it :)
> Regards,
>
> Hans
>
>
> On 05/31/2010 10:03 AM, huzaifas@redhat.com wrote:
>> From: Huzaifa Sidhpurwala<huzaifas@fedora-12.(none)>
>>
>> Move VIDIOCGFBUF into libv4l1
>>
>> Signed-off-by: Huzaifa Sidhpurwala<huzaifas@redhat.com>
>> ---
>> lib/libv4l1/libv4l1.c | 45
>> +++++++++++++++++++++++++++++++++++++++++++++
>> 1 files changed, 45 insertions(+), 0 deletions(-)
>>
>> 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 */
- --
Regards,
Huzaifa Sidhpurwala, RHCE, CCNA (IRC: huzaifas)
IT Desktop R&D Lead.
Global Help Desk, Pune (India)
Phone: +91 20 4005 7322 (UTC +5.5)
GnuPG Fingerprint:
3A0F DAFB 9279 02ED 273B FFE9 CC70 DCF2 DA5B DAE5
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org/
iD8DBQFMBMfbzHDc8tpb2uURAtJ0AKCPnWfPn3UEdPTxz2n9AJJw4+YzwACgmcvp
TH5SM8YvgsiO66KOwspLk5k=
=yvT4
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-01 8:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-31 8:03 [PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1 huzaifas
2010-06-01 8:41 ` Hans de Goede
2010-06-01 8:42 ` Huzaifa Sidhpurwala
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox