diff options
author | Hans de Goede <j.w.r.degoede@hhs.nl> | 2008-07-04 16:55:18 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:16:58 -0400 |
commit | 24c530b4abb979f9e79298f0b4c4e83781a0e4c3 (patch) | |
tree | 8f96e78399b688efb7eb63024e4ffcca837bf48d /drivers | |
parent | a5ae2062252e697d38e53dbbeb91460252208914 (diff) |
V4L/DVB (8196): gspca: Correct sizeimage in vidioc_s/try/g_fmt_cap
Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/gspca/gspca.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index ad4721b06920..f6d216316b11 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c | |||
@@ -43,8 +43,8 @@ MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); | |||
43 | MODULE_DESCRIPTION("GSPCA USB Camera Driver"); | 43 | MODULE_DESCRIPTION("GSPCA USB Camera Driver"); |
44 | MODULE_LICENSE("GPL"); | 44 | MODULE_LICENSE("GPL"); |
45 | 45 | ||
46 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 2) | 46 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 4) |
47 | static const char version[] = "2.1.2"; | 47 | static const char version[] = "2.1.4"; |
48 | 48 | ||
49 | static int video_nr = -1; | 49 | static int video_nr = -1; |
50 | 50 | ||
@@ -391,14 +391,20 @@ static __u32 get_v4l2_depth(__u32 pixfmt) | |||
391 | return 24; | 391 | return 24; |
392 | } | 392 | } |
393 | 393 | ||
394 | static int gspca_get_buff_size(struct gspca_dev *gspca_dev) | 394 | static int gspca_get_buff_size(struct gspca_dev *gspca_dev, int mode) |
395 | { | 395 | { |
396 | unsigned int size; | 396 | unsigned int size; |
397 | 397 | ||
398 | size = gspca_dev->width * gspca_dev->height | 398 | size = gspca_dev->cam.cam_mode[mode].width * |
399 | * get_v4l2_depth(gspca_dev->pixfmt) / 8; | 399 | gspca_dev->cam.cam_mode[mode].height * |
400 | get_v4l2_depth(gspca_dev->cam.cam_mode[mode].pixfmt) / 8; | ||
400 | if (!size) | 401 | if (!size) |
401 | return -ENOMEM; | 402 | return -ENOMEM; |
403 | |||
404 | /* if compressed (JPEG), reduce the buffer size */ | ||
405 | if (gspca_is_compressed(gspca_dev->cam.cam_mode[mode].pixfmt)) | ||
406 | size = (size * comp_fac) / 100 + 600; /* (+ JPEG header sz) */ | ||
407 | |||
402 | return size; | 408 | return size; |
403 | } | 409 | } |
404 | 410 | ||
@@ -409,15 +415,12 @@ static int frame_alloc(struct gspca_dev *gspca_dev, | |||
409 | unsigned int frsz; | 415 | unsigned int frsz; |
410 | int i; | 416 | int i; |
411 | 417 | ||
412 | frsz = gspca_get_buff_size(gspca_dev); | 418 | frsz = gspca_get_buff_size(gspca_dev, gspca_dev->curr_mode); |
413 | if (frsz < 0) | 419 | if (frsz < 0) |
414 | return frsz; | 420 | return frsz; |
415 | PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); | 421 | PDEBUG(D_STREAM, "frame alloc frsz: %d", frsz); |
416 | if (count > GSPCA_MAX_FRAMES) | 422 | if (count > GSPCA_MAX_FRAMES) |
417 | count = GSPCA_MAX_FRAMES; | 423 | count = GSPCA_MAX_FRAMES; |
418 | /* if compressed (JPEG), reduce the buffer size */ | ||
419 | if (gspca_is_compressed(gspca_dev->pixfmt)) | ||
420 | frsz = (frsz * comp_fac) / 100 + 600; /* (+ JPEG header sz) */ | ||
421 | frsz = PAGE_ALIGN(frsz); | 424 | frsz = PAGE_ALIGN(frsz); |
422 | PDEBUG(D_STREAM, "new fr_sz: %d", frsz); | 425 | PDEBUG(D_STREAM, "new fr_sz: %d", frsz); |
423 | gspca_dev->frsz = frsz; | 426 | gspca_dev->frsz = frsz; |
@@ -796,8 +799,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
796 | fmt->fmt.pix.field = V4L2_FIELD_NONE; | 799 | fmt->fmt.pix.field = V4L2_FIELD_NONE; |
797 | fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat) | 800 | fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat) |
798 | * fmt->fmt.pix.width / 8; | 801 | * fmt->fmt.pix.width / 8; |
799 | fmt->fmt.pix.sizeimage = fmt->fmt.pix.bytesperline | 802 | fmt->fmt.pix.sizeimage = gspca_get_buff_size(gspca_dev, |
800 | * fmt->fmt.pix.height; | 803 | gspca_dev->curr_mode); |
801 | /* (should be in the subdriver) */ | 804 | /* (should be in the subdriver) */ |
802 | fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; | 805 | fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB; |
803 | fmt->fmt.pix.priv = 0; | 806 | fmt->fmt.pix.priv = 0; |
@@ -807,7 +810,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
807 | static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, | 810 | static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, |
808 | struct v4l2_format *fmt) | 811 | struct v4l2_format *fmt) |
809 | { | 812 | { |
810 | int w, h, mode, mode2, frsz; | 813 | int w, h, mode, mode2; |
811 | 814 | ||
812 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 815 | if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
813 | return -EINVAL; | 816 | return -EINVAL; |
@@ -849,12 +852,10 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev, | |||
849 | } | 852 | } |
850 | fmt->fmt.pix.width = gspca_dev->cam.cam_mode[mode].width; | 853 | fmt->fmt.pix.width = gspca_dev->cam.cam_mode[mode].width; |
851 | fmt->fmt.pix.height = gspca_dev->cam.cam_mode[mode].height; | 854 | fmt->fmt.pix.height = gspca_dev->cam.cam_mode[mode].height; |
855 | fmt->fmt.pix.field = V4L2_FIELD_NONE; | ||
852 | fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat) | 856 | fmt->fmt.pix.bytesperline = get_v4l2_depth(fmt->fmt.pix.pixelformat) |
853 | * fmt->fmt.pix.width / 8; | 857 | * fmt->fmt.pix.width / 8; |
854 | frsz = fmt->fmt.pix.bytesperline * fmt->fmt.pix.height; | 858 | fmt->fmt.pix.sizeimage = gspca_get_buff_size(gspca_dev, mode); |
855 | if (gspca_is_compressed(fmt->fmt.pix.pixelformat)) | ||
856 | frsz = (frsz * comp_fac) / 100; | ||
857 | fmt->fmt.pix.sizeimage = frsz; | ||
858 | return mode; /* used when s_fmt */ | 859 | return mode; /* used when s_fmt */ |
859 | } | 860 | } |
860 | 861 | ||