diff options
author | Jean-François Moine <moinejf@free.fr> | 2012-03-16 05:47:23 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-19 21:26:45 -0400 |
commit | cd7f98fcd8573bb29f768f70c58e3d1f8057f7e3 (patch) | |
tree | da9886cd5ecf17b76b8fc5539278f192e87f8bac /drivers/media | |
parent | 9ab2393fc3e460cd2040de1483918eb17abb822f (diff) |
[media] gspca - zc3xx: Add V4L2_CID_JPEG_COMPRESSION_QUALITY control support
This patch is adapted from Sylwester's patch proposed on 2012/02/22.
The JPEG compression control does not work with the autoquality done for the
sensors hv7131r and pas202b.
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/zc3xx.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c index c10bdb422271..7bbdf8331a91 100644 --- a/drivers/media/video/gspca/zc3xx.c +++ b/drivers/media/video/gspca/zc3xx.c | |||
@@ -44,6 +44,7 @@ enum e_ctrl { | |||
44 | AUTOGAIN, | 44 | AUTOGAIN, |
45 | LIGHTFREQ, | 45 | LIGHTFREQ, |
46 | SHARPNESS, | 46 | SHARPNESS, |
47 | QUALITY, | ||
47 | NCTRLS /* number of controls */ | 48 | NCTRLS /* number of controls */ |
48 | }; | 49 | }; |
49 | 50 | ||
@@ -99,6 +100,7 @@ static void setexposure(struct gspca_dev *gspca_dev); | |||
99 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 100 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
100 | static void setlightfreq(struct gspca_dev *gspca_dev); | 101 | static void setlightfreq(struct gspca_dev *gspca_dev); |
101 | static void setsharpness(struct gspca_dev *gspca_dev); | 102 | static void setsharpness(struct gspca_dev *gspca_dev); |
103 | static int sd_setquality(struct gspca_dev *gspca_dev, __s32 val); | ||
102 | 104 | ||
103 | static const struct ctrl sd_ctrls[NCTRLS] = { | 105 | static const struct ctrl sd_ctrls[NCTRLS] = { |
104 | [BRIGHTNESS] = { | 106 | [BRIGHTNESS] = { |
@@ -186,6 +188,18 @@ static const struct ctrl sd_ctrls[NCTRLS] = { | |||
186 | }, | 188 | }, |
187 | .set_control = setsharpness | 189 | .set_control = setsharpness |
188 | }, | 190 | }, |
191 | [QUALITY] = { | ||
192 | { | ||
193 | .id = V4L2_CID_JPEG_COMPRESSION_QUALITY, | ||
194 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
195 | .name = "Compression Quality", | ||
196 | .minimum = 40, | ||
197 | .maximum = 70, | ||
198 | .step = 1, | ||
199 | .default_value = 70 /* updated in sd_init() */ | ||
200 | }, | ||
201 | .set = sd_setquality | ||
202 | }, | ||
189 | }; | 203 | }; |
190 | 204 | ||
191 | static const struct v4l2_pix_format vga_mode[] = { | 205 | static const struct v4l2_pix_format vga_mode[] = { |
@@ -6151,6 +6165,7 @@ static void transfer_update(struct work_struct *work) | |||
6151 | || !gspca_dev->present | 6165 | || !gspca_dev->present |
6152 | || !gspca_dev->streaming) | 6166 | || !gspca_dev->streaming) |
6153 | goto err; | 6167 | goto err; |
6168 | sd->ctrls[QUALITY].val = jpeg_qual[sd->reg08]; | ||
6154 | jpeg_set_qual(sd->jpeg_hdr, | 6169 | jpeg_set_qual(sd->jpeg_hdr, |
6155 | jpeg_qual[sd->reg08]); | 6170 | jpeg_qual[sd->reg08]); |
6156 | } | 6171 | } |
@@ -6717,13 +6732,20 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
6717 | 6732 | ||
6718 | sd->ctrls[GAMMA].def = gamma[sd->sensor]; | 6733 | sd->ctrls[GAMMA].def = gamma[sd->sensor]; |
6719 | sd->reg08 = reg08_tb[sd->sensor]; | 6734 | sd->reg08 = reg08_tb[sd->sensor]; |
6735 | sd->ctrls[QUALITY].def = jpeg_qual[sd->reg08]; | ||
6736 | sd->ctrls[QUALITY].min = jpeg_qual[0]; | ||
6737 | sd->ctrls[QUALITY].max = jpeg_qual[ARRAY_SIZE(jpeg_qual) - 1]; | ||
6720 | 6738 | ||
6721 | switch (sd->sensor) { | 6739 | switch (sd->sensor) { |
6722 | case SENSOR_HV7131R: | 6740 | case SENSOR_HV7131R: |
6741 | gspca_dev->ctrl_dis = (1 << QUALITY); | ||
6723 | break; | 6742 | break; |
6724 | case SENSOR_OV7630C: | 6743 | case SENSOR_OV7630C: |
6725 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ) | (1 << EXPOSURE); | 6744 | gspca_dev->ctrl_dis = (1 << LIGHTFREQ) | (1 << EXPOSURE); |
6726 | break; | 6745 | break; |
6746 | case SENSOR_PAS202B: | ||
6747 | gspca_dev->ctrl_dis = (1 << QUALITY) | (1 << EXPOSURE); | ||
6748 | break; | ||
6727 | default: | 6749 | default: |
6728 | gspca_dev->ctrl_dis = (1 << EXPOSURE); | 6750 | gspca_dev->ctrl_dis = (1 << EXPOSURE); |
6729 | break; | 6751 | break; |
@@ -7003,24 +7025,33 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, | |||
7003 | return -EINVAL; | 7025 | return -EINVAL; |
7004 | } | 7026 | } |
7005 | 7027 | ||
7006 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | 7028 | static int sd_setquality(struct gspca_dev *gspca_dev, __s32 val) |
7007 | struct v4l2_jpegcompression *jcomp) | ||
7008 | { | 7029 | { |
7009 | struct sd *sd = (struct sd *) gspca_dev; | 7030 | struct sd *sd = (struct sd *) gspca_dev; |
7010 | int i; | 7031 | int i; |
7011 | 7032 | ||
7012 | for (i = 0; i < ARRAY_SIZE(jpeg_qual) - 1; i++) { | 7033 | for (i = 0; i < ARRAY_SIZE(jpeg_qual) - 1; i++) { |
7013 | if (jcomp->quality <= jpeg_qual[i]) | 7034 | if (val <= jpeg_qual[i]) |
7014 | break; | 7035 | break; |
7015 | } | 7036 | } |
7016 | if (i > 0 | 7037 | if (i > 0 |
7017 | && i == sd->reg08 | 7038 | && i == sd->reg08 |
7018 | && jcomp->quality < jpeg_qual[sd->reg08]) | 7039 | && val < jpeg_qual[sd->reg08]) |
7019 | i--; | 7040 | i--; |
7020 | sd->reg08 = i; | 7041 | sd->reg08 = i; |
7021 | jcomp->quality = jpeg_qual[i]; | 7042 | sd->ctrls[QUALITY].val = jpeg_qual[i]; |
7022 | if (gspca_dev->streaming) | 7043 | if (gspca_dev->streaming) |
7023 | jpeg_set_qual(sd->jpeg_hdr, jcomp->quality); | 7044 | jpeg_set_qual(sd->jpeg_hdr, sd->ctrls[QUALITY].val); |
7045 | return gspca_dev->usb_err; | ||
7046 | } | ||
7047 | |||
7048 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | ||
7049 | struct v4l2_jpegcompression *jcomp) | ||
7050 | { | ||
7051 | struct sd *sd = (struct sd *) gspca_dev; | ||
7052 | |||
7053 | sd_setquality(gspca_dev, jcomp->quality); | ||
7054 | jcomp->quality = sd->ctrls[QUALITY].val; | ||
7024 | return gspca_dev->usb_err; | 7055 | return gspca_dev->usb_err; |
7025 | } | 7056 | } |
7026 | 7057 | ||
@@ -7030,7 +7061,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev, | |||
7030 | struct sd *sd = (struct sd *) gspca_dev; | 7061 | struct sd *sd = (struct sd *) gspca_dev; |
7031 | 7062 | ||
7032 | memset(jcomp, 0, sizeof *jcomp); | 7063 | memset(jcomp, 0, sizeof *jcomp); |
7033 | jcomp->quality = jpeg_qual[sd->reg08]; | 7064 | jcomp->quality = sd->ctrls[QUALITY].val; |
7034 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT | 7065 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT |
7035 | | V4L2_JPEG_MARKER_DQT; | 7066 | | V4L2_JPEG_MARKER_DQT; |
7036 | return 0; | 7067 | return 0; |