All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] capture-example: allow V4L2_PIX_FMT_GREY with USERPTR
@ 2011-06-28 14:23 Michael Jones
  2011-07-13 22:35 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Jones @ 2011-06-28 14:23 UTC (permalink / raw)
  To: linux-media

There is an assumption that the format coming from the device
needs 2 bytes per pixel, which is not the case when the device
delivers e.g. V4L2_PIX_FMT_GREY. This doesn't manifest itself with
IO_METHOD_MMAP because init_mmap() (the default) doesn't take
sizeimage as an argument.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
---

This same issue would apply to other formats which have 1 byte per pixel,
this patch only fixes it for GREY.  Is this OK for now, or does somebody
have a better suggestion for supporting other formats as well?

 contrib/test/capture-example.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/contrib/test/capture-example.c b/contrib/test/capture-example.c
index 3852c58..0eb5235 100644
--- a/contrib/test/capture-example.c
+++ b/contrib/test/capture-example.c
@@ -416,6 +416,7 @@ static void init_device(void)
 	struct v4l2_crop crop;
 	struct v4l2_format fmt;
 	unsigned int min;
+	unsigned int bytes_per_pixel;
 
 	if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) {
 		if (EINVAL == errno) {
@@ -519,7 +520,8 @@ static void init_device(void)
 	}
 
 	/* Buggy driver paranoia. */
-	min = fmt.fmt.pix.width * 2;
+	bytes_per_pixel = fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_GREY ? 1 : 2;
+	min = fmt.fmt.pix.width * bytes_per_pixel;
 	if (fmt.fmt.pix.bytesperline < min)
 		fmt.fmt.pix.bytesperline = min;
 	min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;
-- 
1.7.5.4


MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-18 10:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-28 14:23 [RFC PATCH] capture-example: allow V4L2_PIX_FMT_GREY with USERPTR Michael Jones
2011-07-13 22:35 ` Mauro Carvalho Chehab
2011-07-14  7:03   ` Michael Jones
2011-07-14 10:56     ` Mauro Carvalho Chehab
2011-07-18 10:00       ` [PATCH] capture-example: don't use bytesperline when allocating buffers Michael Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.