aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/s2255drv.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/s2255drv.c')
-rw-r--r--drivers/media/video/s2255drv.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c
index 561909b65ce6..5b9dce85645c 100644
--- a/drivers/media/video/s2255drv.c
+++ b/drivers/media/video/s2255drv.c
@@ -394,12 +394,17 @@ static unsigned int vid_limit = 16; /* Video memory limit, in Mb */
394/* start video number */ 394/* start video number */
395static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ 395static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
396 396
397/* Enable jpeg capture. */
398static int jpeg_enable = 1;
399
397module_param(debug, int, 0644); 400module_param(debug, int, 0644);
398MODULE_PARM_DESC(debug, "Debug level(0-100) default 0"); 401MODULE_PARM_DESC(debug, "Debug level(0-100) default 0");
399module_param(vid_limit, int, 0644); 402module_param(vid_limit, int, 0644);
400MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)"); 403MODULE_PARM_DESC(vid_limit, "video memory limit(Mb)");
401module_param(video_nr, int, 0644); 404module_param(video_nr, int, 0644);
402MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)"); 405MODULE_PARM_DESC(video_nr, "start video minor(-1 default autodetect)");
406module_param(jpeg_enable, int, 0644);
407MODULE_PARM_DESC(jpeg_enable, "Jpeg enable(1-on 0-off) default 1");
403 408
404/* USB device table */ 409/* USB device table */
405#define USB_SENSORAY_VID 0x1943 410#define USB_SENSORAY_VID 0x1943
@@ -413,6 +418,7 @@ MODULE_DEVICE_TABLE(usb, s2255_table);
413#define BUFFER_TIMEOUT msecs_to_jiffies(400) 418#define BUFFER_TIMEOUT msecs_to_jiffies(400)
414 419
415/* image formats. */ 420/* image formats. */
421/* JPEG formats must be defined last to support jpeg_enable parameter */
416static const struct s2255_fmt formats[] = { 422static const struct s2255_fmt formats[] = {
417 { 423 {
418 .name = "4:2:2, planar, YUV422P", 424 .name = "4:2:2, planar, YUV422P",
@@ -429,13 +435,17 @@ static const struct s2255_fmt formats[] = {
429 .fourcc = V4L2_PIX_FMT_UYVY, 435 .fourcc = V4L2_PIX_FMT_UYVY,
430 .depth = 16 436 .depth = 16
431 }, { 437 }, {
438 .name = "8bpp GREY",
439 .fourcc = V4L2_PIX_FMT_GREY,
440 .depth = 8
441 }, {
432 .name = "JPG", 442 .name = "JPG",
433 .fourcc = V4L2_PIX_FMT_JPEG, 443 .fourcc = V4L2_PIX_FMT_JPEG,
434 .depth = 24 444 .depth = 24
435 }, { 445 }, {
436 .name = "8bpp GREY", 446 .name = "MJPG",
437 .fourcc = V4L2_PIX_FMT_GREY, 447 .fourcc = V4L2_PIX_FMT_MJPEG,
438 .depth = 8 448 .depth = 24
439 } 449 }
440}; 450};
441 451
@@ -610,6 +620,9 @@ static const struct s2255_fmt *format_by_fourcc(int fourcc)
610 for (i = 0; i < ARRAY_SIZE(formats); i++) { 620 for (i = 0; i < ARRAY_SIZE(formats); i++) {
611 if (-1 == formats[i].fourcc) 621 if (-1 == formats[i].fourcc)
612 continue; 622 continue;
623 if (!jpeg_enable && ((formats[i].fourcc == V4L2_PIX_FMT_JPEG) ||
624 (formats[i].fourcc == V4L2_PIX_FMT_MJPEG)))
625 continue;
613 if (formats[i].fourcc == fourcc) 626 if (formats[i].fourcc == fourcc)
614 return formats + i; 627 return formats + i;
615 } 628 }
@@ -653,6 +666,7 @@ static void s2255_fillbuff(struct s2255_channel *channel,
653 memcpy(vbuf, tmpbuf, buf->vb.width * buf->vb.height); 666 memcpy(vbuf, tmpbuf, buf->vb.width * buf->vb.height);
654 break; 667 break;
655 case V4L2_PIX_FMT_JPEG: 668 case V4L2_PIX_FMT_JPEG:
669 case V4L2_PIX_FMT_MJPEG:
656 buf->vb.size = jpgsize; 670 buf->vb.size = jpgsize;
657 memcpy(vbuf, tmpbuf, buf->vb.size); 671 memcpy(vbuf, tmpbuf, buf->vb.size);
658 break; 672 break;
@@ -856,7 +870,9 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
856 870
857 if (index >= ARRAY_SIZE(formats)) 871 if (index >= ARRAY_SIZE(formats))
858 return -EINVAL; 872 return -EINVAL;
859 873 if (!jpeg_enable && ((formats[index].fourcc == V4L2_PIX_FMT_JPEG) ||
874 (formats[index].fourcc == V4L2_PIX_FMT_MJPEG)))
875 return -EINVAL;
860 dprintk(4, "name %s\n", formats[index].name); 876 dprintk(4, "name %s\n", formats[index].name);
861 strlcpy(f->description, formats[index].name, sizeof(f->description)); 877 strlcpy(f->description, formats[index].name, sizeof(f->description));
862 f->pixelformat = formats[index].fourcc; 878 f->pixelformat = formats[index].fourcc;
@@ -1037,6 +1053,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1037 mode.color |= COLOR_Y8; 1053 mode.color |= COLOR_Y8;
1038 break; 1054 break;
1039 case V4L2_PIX_FMT_JPEG: 1055 case V4L2_PIX_FMT_JPEG:
1056 case V4L2_PIX_FMT_MJPEG:
1040 mode.color &= ~MASK_COLOR; 1057 mode.color &= ~MASK_COLOR;
1041 mode.color |= COLOR_JPG; 1058 mode.color |= COLOR_JPG;
1042 mode.color |= (channel->jc.quality << 8); 1059 mode.color |= (channel->jc.quality << 8);
@@ -2382,7 +2399,7 @@ static void read_pipe_completion(struct urb *purb)
2382 read_pipe_completion, pipe_info); 2399 read_pipe_completion, pipe_info);
2383 2400
2384 if (pipe_info->state != 0) { 2401 if (pipe_info->state != 0) {
2385 if (usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL)) { 2402 if (usb_submit_urb(pipe_info->stream_urb, GFP_ATOMIC)) {
2386 dev_err(&dev->udev->dev, "error submitting urb\n"); 2403 dev_err(&dev->udev->dev, "error submitting urb\n");
2387 } 2404 }
2388 } else { 2405 } else {