All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frank Schäfer" <fschaefer.oss@googlemail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Devin Heitmueller <dheitmueller@kernellabs.com>
Subject: Re: [RFC PATCH] em28xx: fix bytesperline calculation in TRY_FMT
Date: Tue, 29 Jan 2013 18:51:46 +0100	[thread overview]
Message-ID: <51080C32.40601@googlemail.com> (raw)
In-Reply-To: <201301291049.58085.hverkuil@xs4all.nl>

Am 29.01.2013 10:49, schrieb Hans Verkuil:
> This was part of my original em28xx patch series. That particular patch
> combined two things: this fix and the change where TRY_FMT would no
> longer return -EINVAL for unsupported pixelformats. The latter change was
> rejected (correctly), but we all forgot about the second part of the patch
> which fixed a real bug. I'm reposting just that fix.
>
> Regards,
>
> 	Hans
>
> The bytesperline calculation was incorrect: it used the old width instead
> of the provided width, and it miscalculated the bytesperline value for the
> depth == 12 case.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/em28xx/em28xx-video.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
> index 2eabf2a..070506d 100644
> --- a/drivers/media/usb/em28xx/em28xx-video.c
> +++ b/drivers/media/usb/em28xx/em28xx-video.c
> @@ -906,7 +906,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
>  	f->fmt.pix.width = width;
>  	f->fmt.pix.height = height;
>  	f->fmt.pix.pixelformat = fmt->fourcc;
> -	f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3;
> +	f->fmt.pix.bytesperline = width * ((fmt->depth + 7) >> 3);
>  	f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height;
>  	f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
>  	if (dev->progressive)

Hmm... how are 12 bit pixels stored ? Are padding bits used so that 2
bytes per pixel are needed ?
I wonder if V4L2_PIX_FMT_YUV411P has ever been tested (libv4lconvert
doesn't support it)...

While we are at it, we should check and fix the other size calculations,
too.
For example, in em28xx-video.c we have in

vidioc_g_fmt_vid_cap():
f->fmt.pix.bytesperline = (dev->width * dev->format->depth + 7) >> 3;

queue_setup():
size = (dev->width * dev->height * dev->format->depth + 7) >> 3;

buffer_prepare():
size = (dev->width * dev->height * dev->format->depth + 7) >> 3;

em28xx_copy_video():
int bytesperline = dev->width << 1;

and there are probably more places...


Regards,
Frank



  parent reply	other threads:[~2013-01-29 17:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29  9:49 [RFC PATCH] em28xx: fix bytesperline calculation in TRY_FMT Hans Verkuil
2013-01-29 13:52 ` Devin Heitmueller
2013-01-29 17:51 ` Frank Schäfer [this message]
2013-01-29 18:21   ` Hans Verkuil
2013-01-29 18:33     ` Mauro Carvalho Chehab

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=51080C32.40601@googlemail.com \
    --to=fschaefer.oss@googlemail.com \
    --cc=dheitmueller@kernellabs.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /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.