summaryrefslogtreecommitdiff
path: root/drivers/staging/media
diff options
context:
space:
mode:
authorCorentin Labbe <clabbe@baylibre.com>2020-09-25 20:30:53 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-10-01 10:02:56 +0200
commit11c9c16f7cb5b7d6fba2d6b7f1ec92a3be0c3df2 (patch)
tree932cca04db402944f1f059a0233facc6ebd33b5f /drivers/staging/media
parent64868edc96185acc9dfac37174b039bd6de7e29a (diff)
media: zoran: fix use of buffer_size and sizeimage
buffer_size was not set when it should be. Furthermore, use it instead of recalculate it. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/staging/media')
-rw-r--r--drivers/staging/media/zoran/zoran_card.c2
-rw-r--r--drivers/staging/media/zoran/zoran_driver.c9
2 files changed, 8 insertions, 3 deletions
diff --git a/drivers/staging/media/zoran/zoran_card.c b/drivers/staging/media/zoran/zoran_card.c
index 89fbc114c368..d7b3efa9e39f 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -857,6 +857,8 @@ void zoran_open_init_params(struct zoran *zr)
if (i)
pci_err(zr->pci_dev, "%s internal error\n", __func__);
+ zr->buffer_size = zr->v4l_settings.bytesperline * zr->v4l_settings.height;
+
clear_interrupt_counters(zr);
}
diff --git a/drivers/staging/media/zoran/zoran_driver.c b/drivers/staging/media/zoran/zoran_driver.c
index 5dacbeac790b..021073ba08e6 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -407,6 +407,8 @@ static int zoran_v4l_set_format(struct zoran *zr, int width, int height,
bpp = (format->depth + 7) / 8;
+ zr->buffer_size = height * width * bpp;
+
/* Check against available buffer size */
if (height * width * bpp > zr->buffer_size) {
pci_err(zr->pci_dev, "%s - video buffer size (%d kB) is too small\n",
@@ -1100,7 +1102,7 @@ static int zoran_g_fmt_vid_out(struct file *file, void *__fh,
fmt->fmt.pix.width = zr->jpg_settings.img_width / zr->jpg_settings.HorDcm;
fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 /
(zr->jpg_settings.VerDcm * zr->jpg_settings.TmpDcm);
- fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(&zr->jpg_settings);
+ fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
if (zr->jpg_settings.TmpDcm == 1)
fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
@@ -1125,7 +1127,7 @@ static int zoran_g_fmt_vid_cap(struct file *file, void *__fh,
fmt->fmt.pix.width = zr->v4l_settings.width;
fmt->fmt.pix.height = zr->v4l_settings.height;
- fmt->fmt.pix.sizeimage = zr->v4l_settings.bytesperline * zr->v4l_settings.height;
+ fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.pixelformat = zr->v4l_settings.format->fourcc;
fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
@@ -1194,6 +1196,7 @@ static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(&settings);
+ zr->buffer_size = fmt->fmt.pix.sizeimage;
fmt->fmt.pix.bytesperline = 0;
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
return res;
@@ -1352,7 +1355,7 @@ static int zoran_s_fmt_vid_cap(struct file *file, void *__fh,
/* tell the user the results/missing stuff */
fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline;
- fmt->fmt.pix.sizeimage = zr->v4l_settings.height * zr->v4l_settings.bytesperline;
+ fmt->fmt.pix.sizeimage = zr->buffer_size;
fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace;
if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
fmt->fmt.pix.field = V4L2_FIELD_INTERLACED;