diff options
Diffstat (limited to 'linux/drivers/media/common/saa7146_video.c')
-rw-r--r-- | linux/drivers/media/common/saa7146_video.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/linux/drivers/media/common/saa7146_video.c b/linux/drivers/media/common/saa7146_video.c index af13891b9..e0bf38f16 100644 --- a/linux/drivers/media/common/saa7146_video.c +++ b/linux/drivers/media/common/saa7146_video.c @@ -169,7 +169,8 @@ static int try_fmt(struct saa7146_fh *fh, struct v4l2_format *f) struct saa7146_format *fmt; enum v4l2_field field; int maxw, maxh; - + int calc_bpl; + DEB_EE(("V4L2_BUF_TYPE_VIDEO_CAPTURE: dev:%p, fh:%p\n",dev,fh)); fmt = format_by_fourcc(dev,f->fmt.pix.pixelformat); @@ -212,19 +213,16 @@ static int try_fmt(struct saa7146_fh *fh, struct v4l2_format *f) if (f->fmt.pix.height > maxh) f->fmt.pix.height = maxh; - if (f->fmt.pix.bytesperline == 0) { - f->fmt.pix.sizeimage = (f->fmt.pix.width * f->fmt.pix.height * fmt->depth)/8; - } else { - DEB_D(("bytesperline: %d\n",f->fmt.pix.bytesperline)); - if (f->fmt.pix.bytesperline < (f->fmt.pix.width * fmt->depth)/8) - f->fmt.pix.bytesperline = f->fmt.pix.width; - DEB_D(("bytesperline: %d\n",f->fmt.pix.bytesperline)); - if (f->fmt.pix.bytesperline > (2*PAGE_SIZE* fmt->depth)/8) - f->fmt.pix.bytesperline = f->fmt.pix.width; - f->fmt.pix.sizeimage = (f->fmt.pix.width * f->fmt.pix.bytesperline); - } - - DEB_D(("bytesperline: %d\n",f->fmt.pix.bytesperline)); + calc_bpl = (f->fmt.pix.width * fmt->depth)/8; + + if (f->fmt.pix.bytesperline < calc_bpl) + f->fmt.pix.bytesperline = calc_bpl; + + if (f->fmt.pix.bytesperline > (2*PAGE_SIZE * fmt->depth)/8) /* arbitrary constraint */ + f->fmt.pix.bytesperline = calc_bpl; + + f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * f->fmt.pix.height; + DEB_D(("w:%d, h:%d, bytesperline:%d, sizeimage:%d\n",f->fmt.pix.width,f->fmt.pix.height,f->fmt.pix.bytesperline,f->fmt.pix.sizeimage)); return 0; } |