Commit 24c530b4 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

V4L/DVB (8196): gspca: Correct sizeimage in vidioc_s/try/g_fmt_cap

Signed-off-by: default avatarHans de Goede <j.w.r.degoede@hhs.nl>
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent a5ae2062
...@@ -43,8 +43,8 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); ...@@ -43,8 +43,8 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
MODULE_DESCRIPTION("GSPCA USB Camera Driver"); MODULE_DESCRIPTION("GSPCA USB Camera Driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 2) #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 4)
static const char version[] = "2.1.2"; static const char version[] = "2.1.4";
static int video_nr = -1; static int video_nr = -1;
...@@ -391,14 +391,20 @@ static __u32 get_v4l2_depth(__u32 pixfmt) ...@@ -391,14 +391,20 @@ static __u32 get_v4l2_depth(__u32 pixfmt)
return 24; return 24;
} }
static int gspca_get_buff_size(struct gspca_dev *gspca_dev) static int gspca_get_buff_size(struct gspca_dev *gspca_dev, int mode)
{ {
unsigned int size; unsigned int size;
size = gspca_dev->width * gspca_dev->height size = gspca_dev->cam.cam_mode[mode].width *
* get_v4l2_depth(gspca_dev->pixfmt) / 8; gspca_dev->cam.cam_mode[mode].height *
get_v4l2_depth(gspca_dev->cam.cam_mode[mode].pixfmt) / 8;
if (!size) if (!size)
return -ENOMEM; return -ENOMEM;
/* if compressed (JPEG), reduce the buffer size */
if (gspca_is_compressed(gspca_dev->cam.cam_mode[mode].pixfmt))
size = (size * comp_fac) / 100 + 600; /* (+ JPEG header sz) */
return size; return size;
} }
...@@ -409,15 +415,12 @@ static int frame_alloc(struct gspca_dev *gspca_dev, ...@@ -409,15 +415,12 @@ static int frame_alloc(struct gspca_dev *gspca_dev,
unsigned int frsz; unsigned int frsz;
int i; int i;
frsz = gspca_get_buff_size(gspca_dev); frsz = gspca_get_buff_size(gspca_dev, gspca_dev->curr_mode);
if (frsz < 0) if (frsz < 0)
return frsz; return frsz;
PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz);
if (count > GSPCA_MAX_FRAMES) if (count > GSPCA_MAX_FRAMES)
count = GSPCA_MAX_FRAMES; count = GSPCA_MAX_FRAMES;
/* if compressed (JPEG), reduce the buffer size */
if (gspca_is_compressed(gspca_dev->pixfmt))
frsz = (frsz * comp_fac) / 100 + 600; /* (+ JPEG header sz) */
frsz = PAGE_ALIGN(frsz); frsz = PAGE_ALIGN(frsz);
PDEBUG(D_STREAM, "new fr_sz: %d", frsz); PDEBUG(D_STREAM, "new fr_sz: %d", frsz);
gspca_dev->frsz = frsz; gspca_dev->frsz = frsz;
...@@ -796,8 +799,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -796,8 +799,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
fmt->fmt.pix.field = V4L2_FIELD_NONE; fmt->fmt.pix.field = V4L2_FIELD_NONE;
fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat) fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat)
* fmt->fmt.pix.width / 8; * fmt->fmt.pix.width / 8;
fmt->fmt.pix.sizeimage = fmt->fmt.pix.bytesperline fmt->fmt.pix.sizeimage = gspca_get_buff_size(gspca_dev,
* fmt->fmt.pix.height; gspca_dev->curr_mode);
/* (should be in the subdriver) */ /* (should be in the subdriver) */
fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
fmt->fmt.pix.priv = 0; fmt->fmt.pix.priv = 0;
...@@ -807,7 +810,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -807,7 +810,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
struct v4l2_format *fmt) struct v4l2_format *fmt)
{ {
int w, h, mode, mode2, frsz; int w, h, mode, mode2;
if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL; return -EINVAL;
...@@ -849,12 +852,10 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, ...@@ -849,12 +852,10 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
} }
fmt->fmt.pix.width = gspca_dev->cam.cam_mode[mode].width; fmt->fmt.pix.width = gspca_dev->cam.cam_mode[mode].width;
fmt->fmt.pix.height = gspca_dev->cam.cam_mode[mode].height; fmt->fmt.pix.height = gspca_dev->cam.cam_mode[mode].height;
fmt->fmt.pix.field = V4L2_FIELD_NONE;
fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat) fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat)
* fmt->fmt.pix.width / 8; * fmt->fmt.pix.width / 8;
frsz = fmt->fmt.pix.bytesperline * fmt->fmt.pix.height; fmt->fmt.pix.sizeimage = gspca_get_buff_size(gspca_dev, mode);
if (gspca_is_compressed(fmt->fmt.pix.pixelformat))
frsz = (frsz * comp_fac) / 100;
fmt->fmt.pix.sizeimage = frsz;
return mode; /* used when s_fmt */ return mode; /* used when s_fmt */
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment