All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Michael Jones <michael.jones@matrix-vision.de>
Cc: linux-media@vger.kernel.org
Subject: Re: [RFC PATCH] capture-example: allow V4L2_PIX_FMT_GREY with USERPTR
Date: Wed, 13 Jul 2011 19:35:46 -0300	[thread overview]
Message-ID: <4E1E1DC2.1070505@redhat.com> (raw)
In-Reply-To: <1309270998-5070-1-git-send-email-michael.jones@matrix-vision.de>

Em 28-06-2011 11:23, Michael Jones escreveu:
> 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?

Well, just rely on the bytesperline provided by the driver should be enough.
Devices should be returning it on a consistent way.

Regards,
Mauro

> 
>  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;


  reply	other threads:[~2011-07-13 22:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E1E1DC2.1070505@redhat.com \
    --to=mchehab@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=michael.jones@matrix-vision.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.