diff options
-rw-r--r-- | drivers/media/video/s2255drv.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/media/video/s2255drv.c b/drivers/media/video/s2255drv.c index ea40f4c8b33e..b8e104552206 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c | |||
@@ -58,6 +58,8 @@ | |||
58 | 58 | ||
59 | 59 | ||
60 | 60 | ||
61 | /* default JPEG quality */ | ||
62 | #define S2255_DEF_JPEG_QUAL 50 | ||
61 | /* vendor request in */ | 63 | /* vendor request in */ |
62 | #define S2255_VR_IN 0 | 64 | #define S2255_VR_IN 0 |
63 | /* vendor request out */ | 65 | /* vendor request out */ |
@@ -242,6 +244,8 @@ struct s2255_dev { | |||
242 | struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS]; | 244 | struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS]; |
243 | struct s2255_bufferi buffer[MAX_CHANNELS]; | 245 | struct s2255_bufferi buffer[MAX_CHANNELS]; |
244 | struct s2255_mode mode[MAX_CHANNELS]; | 246 | struct s2255_mode mode[MAX_CHANNELS]; |
247 | /* jpeg compression */ | ||
248 | struct v4l2_jpegcompression jc[MAX_CHANNELS]; | ||
245 | const struct s2255_fmt *cur_fmt[MAX_CHANNELS]; | 249 | const struct s2255_fmt *cur_fmt[MAX_CHANNELS]; |
246 | int cur_frame[MAX_CHANNELS]; | 250 | int cur_frame[MAX_CHANNELS]; |
247 | int last_frame[MAX_CHANNELS]; | 251 | int last_frame[MAX_CHANNELS]; |
@@ -1035,7 +1039,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1035 | fh->mode.color = COLOR_Y8; | 1039 | fh->mode.color = COLOR_Y8; |
1036 | break; | 1040 | break; |
1037 | case V4L2_PIX_FMT_JPEG: | 1041 | case V4L2_PIX_FMT_JPEG: |
1038 | fh->mode.color = COLOR_JPG | (50 << 8); | 1042 | fh->mode.color = COLOR_JPG | |
1043 | (fh->dev->jc[fh->channel].quality << 8); | ||
1039 | break; | 1044 | break; |
1040 | case V4L2_PIX_FMT_YUV422P: | 1045 | case V4L2_PIX_FMT_YUV422P: |
1041 | fh->mode.color = COLOR_YUVPL; | 1046 | fh->mode.color = COLOR_YUVPL; |
@@ -1208,6 +1213,10 @@ static int s2255_set_mode(struct s2255_dev *dev, unsigned long chn, | |||
1208 | dev->mode[chn].scale); | 1213 | dev->mode[chn].scale); |
1209 | dprintk(2, "mode contrast %x\n", mode->contrast); | 1214 | dprintk(2, "mode contrast %x\n", mode->contrast); |
1210 | 1215 | ||
1216 | /* if JPEG, set the quality */ | ||
1217 | if ((mode->color & MASK_COLOR) == COLOR_JPG) | ||
1218 | mode->color = (dev->jc[chn].quality << 8) | COLOR_JPG; | ||
1219 | |||
1211 | /* save the mode */ | 1220 | /* save the mode */ |
1212 | dev->mode[chn] = *mode; | 1221 | dev->mode[chn] = *mode; |
1213 | dev->req_image_size[chn] = get_transfer_size(mode); | 1222 | dev->req_image_size[chn] = get_transfer_size(mode); |
@@ -1472,6 +1481,27 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
1472 | return -EINVAL; | 1481 | return -EINVAL; |
1473 | } | 1482 | } |
1474 | 1483 | ||
1484 | static int vidioc_g_jpegcomp(struct file *file, void *priv, | ||
1485 | struct v4l2_jpegcompression *jc) | ||
1486 | { | ||
1487 | struct s2255_fh *fh = priv; | ||
1488 | struct s2255_dev *dev = fh->dev; | ||
1489 | *jc = dev->jc[fh->channel]; | ||
1490 | dprintk(2, "getting jpegcompression, quality %d\n", jc->quality); | ||
1491 | return 0; | ||
1492 | } | ||
1493 | |||
1494 | static int vidioc_s_jpegcomp(struct file *file, void *priv, | ||
1495 | struct v4l2_jpegcompression *jc) | ||
1496 | { | ||
1497 | struct s2255_fh *fh = priv; | ||
1498 | struct s2255_dev *dev = fh->dev; | ||
1499 | if (jc->quality < 0 || jc->quality > 100) | ||
1500 | return -EINVAL; | ||
1501 | dev->jc[fh->channel].quality = jc->quality; | ||
1502 | dprintk(2, "setting jpeg quality %d\n", jc->quality); | ||
1503 | return 0; | ||
1504 | } | ||
1475 | static int s2255_open(struct inode *inode, struct file *file) | 1505 | static int s2255_open(struct inode *inode, struct file *file) |
1476 | { | 1506 | { |
1477 | int minor = iminor(inode); | 1507 | int minor = iminor(inode); |
@@ -1762,6 +1792,8 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = { | |||
1762 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 1792 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
1763 | .vidiocgmbuf = vidioc_cgmbuf, | 1793 | .vidiocgmbuf = vidioc_cgmbuf, |
1764 | #endif | 1794 | #endif |
1795 | .vidioc_s_jpegcomp = vidioc_s_jpegcomp, | ||
1796 | .vidioc_g_jpegcomp = vidioc_g_jpegcomp, | ||
1765 | }; | 1797 | }; |
1766 | 1798 | ||
1767 | static struct video_device template = { | 1799 | static struct video_device template = { |
@@ -2148,6 +2180,7 @@ static int s2255_board_init(struct s2255_dev *dev) | |||
2148 | for (j = 0; j < MAX_CHANNELS; j++) { | 2180 | for (j = 0; j < MAX_CHANNELS; j++) { |
2149 | dev->b_acquire[j] = 0; | 2181 | dev->b_acquire[j] = 0; |
2150 | dev->mode[j] = mode_def; | 2182 | dev->mode[j] = mode_def; |
2183 | dev->jc[j].quality = S2255_DEF_JPEG_QUAL; | ||
2151 | dev->cur_fmt[j] = &formats[0]; | 2184 | dev->cur_fmt[j] = &formats[0]; |
2152 | dev->mode[j].restart = 1; | 2185 | dev->mode[j].restart = 1; |
2153 | dev->req_image_size[j] = get_transfer_size(&mode_def); | 2186 | dev->req_image_size[j] = get_transfer_size(&mode_def); |