summaryrefslogtreecommitdiff
path: root/drivers/media/video/s2255drv.c
diff options
context:
space:
mode:
authorDean Anderson <dean@sensoray.com>2008-08-29 22:33:19 +0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 15:36:55 +0400
commit22b88d48a08e334d36218ca166749c4e6d644f0c (patch)
treef57b3571d6ea16676ee306a7ba9a2a7f2da9140b /drivers/media/video/s2255drv.c
parentabc94fc8feb1488079dd7dd46bd61d37d91c5658 (diff)
downloadlinux-22b88d48a08e334d36218ca166749c4e6d644f0c.tar.xz
V4L/DVB (8845): s2255drv: adds JPEG compression quality control
adds VIDIOC_S_JPEGCOMP and VIDIOC_G_JPEGCOMP ioctls for controlling JPEG compression quality. Signed-off-by: Dean Anderson <dean@sensoray.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s2255drv.c')
-rw-r--r--drivers/media/video/s2255drv.c35
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 @@
+/* default JPEG quality */
+#define S2255_DEF_JPEG_QUAL 50
/* vendor request in */
#define S2255_VR_IN 0
/* vendor request out */
@@ -242,6 +244,8 @@ struct s2255_dev {
struct s2255_pipeinfo pipes[MAX_PIPE_BUFFERS];
struct s2255_bufferi buffer[MAX_CHANNELS];
struct s2255_mode mode[MAX_CHANNELS];
+ /* jpeg compression */
+ struct v4l2_jpegcompression jc[MAX_CHANNELS];
const struct s2255_fmt *cur_fmt[MAX_CHANNELS];
int cur_frame[MAX_CHANNELS];
int last_frame[MAX_CHANNELS];
@@ -1035,7 +1039,8 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
fh->mode.color = COLOR_Y8;
break;
case V4L2_PIX_FMT_JPEG:
- fh->mode.color = COLOR_JPG | (50 << 8);
+ fh->mode.color = COLOR_JPG |
+ (fh->dev->jc[fh->channel].quality << 8);
break;
case V4L2_PIX_FMT_YUV422P:
fh->mode.color = COLOR_YUVPL;
@@ -1208,6 +1213,10 @@ static int s2255_set_mode(struct s2255_dev *dev, unsigned long chn,
dev->mode[chn].scale);
dprintk(2, "mode contrast %x\n", mode->contrast);
+ /* if JPEG, set the quality */
+ if ((mode->color & MASK_COLOR) == COLOR_JPG)
+ mode->color = (dev->jc[chn].quality << 8) | COLOR_JPG;
+
/* save the mode */
dev->mode[chn] = *mode;
dev->req_image_size[chn] = get_transfer_size(mode);
@@ -1472,6 +1481,27 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
return -EINVAL;
}
+static int vidioc_g_jpegcomp(struct file *file, void *priv,
+ struct v4l2_jpegcompression *jc)
+{
+ struct s2255_fh *fh = priv;
+ struct s2255_dev *dev = fh->dev;
+ *jc = dev->jc[fh->channel];
+ dprintk(2, "getting jpegcompression, quality %d\n", jc->quality);
+ return 0;
+}
+
+static int vidioc_s_jpegcomp(struct file *file, void *priv,
+ struct v4l2_jpegcompression *jc)
+{
+ struct s2255_fh *fh = priv;
+ struct s2255_dev *dev = fh->dev;
+ if (jc->quality < 0 || jc->quality > 100)
+ return -EINVAL;
+ dev->jc[fh->channel].quality = jc->quality;
+ dprintk(2, "setting jpeg quality %d\n", jc->quality);
+ return 0;
+}
static int s2255_open(struct inode *inode, struct file *file)
{
int minor = iminor(inode);
@@ -1762,6 +1792,8 @@ static const struct v4l2_ioctl_ops s2255_ioctl_ops = {
#ifdef CONFIG_VIDEO_V4L1_COMPAT
.vidiocgmbuf = vidioc_cgmbuf,
#endif
+ .vidioc_s_jpegcomp = vidioc_s_jpegcomp,
+ .vidioc_g_jpegcomp = vidioc_g_jpegcomp,
};
static struct video_device template = {
@@ -2148,6 +2180,7 @@ static int s2255_board_init(struct s2255_dev *dev)
for (j = 0; j < MAX_CHANNELS; j++) {
dev->b_acquire[j] = 0;
dev->mode[j] = mode_def;
+ dev->jc[j].quality = S2255_DEF_JPEG_QUAL;
dev->cur_fmt[j] = &formats[0];
dev->mode[j].restart = 1;
dev->req_image_size[j] = get_transfer_size(&mode_def);