Commit 77ac0baf authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (11040): gspca - most jpeg subdrivers: Have the JPEG quality settable.

The JPEG quality of the images (quantization tables) is now settable by the
VIDIOC_S_JPEGCOMP ioctl.
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 71cb2764
...@@ -37,6 +37,9 @@ struct sd { ...@@ -37,6 +37,9 @@ struct sd {
unsigned char contrast; unsigned char contrast;
unsigned char colors; unsigned char colors;
u8 quality; u8 quality;
#define QUALITY_MIN 30
#define QUALITY_MAX 60
#define QUALITY_DEF 40
u8 *jpeg_hdr; u8 *jpeg_hdr;
}; };
...@@ -822,7 +825,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -822,7 +825,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->brightness = BRIGHTNESS_DEF; sd->brightness = BRIGHTNESS_DEF;
sd->contrast = CONTRAST_DEF; sd->contrast = CONTRAST_DEF;
sd->colors = COLOR_DEF; sd->colors = COLOR_DEF;
sd->quality = 40; sd->quality = QUALITY_DEF;
return 0; return 0;
} }
...@@ -1000,6 +1003,34 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) ...@@ -1000,6 +1003,34 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
return 0; return 0;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static struct sd_desc sd_desc = { static struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
...@@ -1010,6 +1041,8 @@ static struct sd_desc sd_desc = { ...@@ -1010,6 +1041,8 @@ static struct sd_desc sd_desc = {
.start = sd_start, .start = sd_start,
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
/* -- module initialisation -- */ /* -- module initialisation -- */
......
...@@ -37,6 +37,9 @@ struct sd { ...@@ -37,6 +37,9 @@ struct sd {
u8 gamma; u8 gamma;
u8 sharpness; u8 sharpness;
u8 quality; u8 quality;
#define QUALITY_MIN 40
#define QUALITY_MAX 70
#define QUALITY_DEF 50
u8 *jpeg_hdr; u8 *jpeg_hdr;
}; };
...@@ -178,7 +181,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -178,7 +181,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->colors = COLOR_DEF; sd->colors = COLOR_DEF;
sd->gamma = GAMMA_DEF; sd->gamma = GAMMA_DEF;
sd->sharpness = SHARPNESS_DEF; sd->sharpness = SHARPNESS_DEF;
sd->quality = 50; sd->quality = QUALITY_DEF;
gspca_dev->nbalt = 9; /* use the altsetting 08 */ gspca_dev->nbalt = 9; /* use the altsetting 08 */
return 0; return 0;
} }
...@@ -445,6 +448,34 @@ static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val) ...@@ -445,6 +448,34 @@ static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
return 0; return 0;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
...@@ -456,6 +487,8 @@ static const struct sd_desc sd_desc = { ...@@ -456,6 +487,8 @@ static const struct sd_desc sd_desc = {
.stopN = sd_stopN, .stopN = sd_stopN,
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
/* -- module initialisation -- */ /* -- module initialisation -- */
......
...@@ -47,6 +47,9 @@ struct sd { ...@@ -47,6 +47,9 @@ struct sd {
u8 vflip; /* ov7630/ov7648 only */ u8 vflip; /* ov7630/ov7648 only */
u8 infrared; /* mt9v111 only */ u8 infrared; /* mt9v111 only */
u8 quality; /* image quality */ u8 quality; /* image quality */
#define QUALITY_MIN 60
#define QUALITY_MAX 95
#define QUALITY_DEF 80
u8 jpegqual; /* webcam quality */ u8 jpegqual; /* webcam quality */
u8 reg18; u8 reg18;
...@@ -1295,7 +1298,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -1295,7 +1298,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
else else
sd->vflip = 1; sd->vflip = 1;
sd->infrared = INFRARED_DEF; sd->infrared = INFRARED_DEF;
sd->quality = 80; sd->quality = QUALITY_DEF;
sd->jpegqual = 80; sd->jpegqual = 80;
gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
...@@ -2130,6 +2133,34 @@ static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val) ...@@ -2130,6 +2133,34 @@ static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
return 0; return 0;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
...@@ -2142,6 +2173,8 @@ static const struct sd_desc sd_desc = { ...@@ -2142,6 +2173,8 @@ static const struct sd_desc sd_desc = {
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.dq_callback = do_autogain, .dq_callback = do_autogain,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
/* -- module initialisation -- */ /* -- module initialisation -- */
......
...@@ -39,6 +39,9 @@ struct sd { ...@@ -39,6 +39,9 @@ struct sd {
unsigned char contrast; unsigned char contrast;
unsigned char colors; unsigned char colors;
u8 quality; u8 quality;
#define QUALITY_MIN 70
#define QUALITY_MAX 95
#define QUALITY_DEF 85
char subtype; char subtype;
#define AgfaCl20 0 #define AgfaCl20 0
...@@ -642,7 +645,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -642,7 +645,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->brightness = BRIGHTNESS_DEF; sd->brightness = BRIGHTNESS_DEF;
sd->contrast = CONTRAST_DEF; sd->contrast = CONTRAST_DEF;
sd->colors = COLOR_DEF; sd->colors = COLOR_DEF;
sd->quality = 85; sd->quality = QUALITY_DEF;
return 0; return 0;
} }
...@@ -1021,6 +1024,34 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) ...@@ -1021,6 +1024,34 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
return 0; return 0;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static struct sd_desc sd_desc = { static struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
...@@ -1032,6 +1063,8 @@ static struct sd_desc sd_desc = { ...@@ -1032,6 +1063,8 @@ static struct sd_desc sd_desc = {
.stopN = sd_stopN, .stopN = sd_stopN,
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
/* -- module initialisation -- */ /* -- module initialisation -- */
......
...@@ -36,6 +36,9 @@ struct sd { ...@@ -36,6 +36,9 @@ struct sd {
unsigned char colors; unsigned char colors;
unsigned char lightfreq; unsigned char lightfreq;
u8 quality; u8 quality;
#define QUALITY_MIN 60
#define QUALITY_MAX 95
#define QUALITY_DEF 80
u8 *jpeg_hdr; u8 *jpeg_hdr;
}; };
...@@ -301,7 +304,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -301,7 +304,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->contrast = CONTRAST_DEF; sd->contrast = CONTRAST_DEF;
sd->colors = COLOR_DEF; sd->colors = COLOR_DEF;
sd->lightfreq = FREQ_DEF; sd->lightfreq = FREQ_DEF;
sd->quality = 80; sd->quality = QUALITY_DEF;
return 0; return 0;
} }
...@@ -535,6 +538,34 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, ...@@ -535,6 +538,34 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
return -EINVAL; return -EINVAL;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
...@@ -547,6 +578,8 @@ static const struct sd_desc sd_desc = { ...@@ -547,6 +578,8 @@ static const struct sd_desc sd_desc = {
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.querymenu = sd_querymenu, .querymenu = sd_querymenu,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
/* -- module initialisation -- */ /* -- module initialisation -- */
......
...@@ -40,6 +40,9 @@ struct sd { ...@@ -40,6 +40,9 @@ struct sd {
unsigned char colors; unsigned char colors;
unsigned char autogain; unsigned char autogain;
u8 quality; u8 quality;
#define QUALITY_MIN 70
#define QUALITY_MAX 95
#define QUALITY_DEF 85
char bridge; char bridge;
#define BRIDGE_SPCA504 0 #define BRIDGE_SPCA504 0
...@@ -854,7 +857,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -854,7 +857,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
sd->quality = 85; sd->quality = QUALITY_DEF;
return 0; return 0;
} }
...@@ -1319,6 +1322,34 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) ...@@ -1319,6 +1322,34 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
return 0; return 0;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
/* sub-driver description */ /* sub-driver description */
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
...@@ -1330,6 +1361,8 @@ static const struct sd_desc sd_desc = { ...@@ -1330,6 +1361,8 @@ static const struct sd_desc sd_desc = {
.stopN = sd_stopN, .stopN = sd_stopN,
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
/* -- module initialisation -- */ /* -- module initialisation -- */
......
...@@ -46,6 +46,9 @@ struct sd { ...@@ -46,6 +46,9 @@ struct sd {
__u8 lightfreq; __u8 lightfreq;
__u8 sharpness; __u8 sharpness;
u8 quality; /* image quality */ u8 quality; /* image quality */
#define QUALITY_MIN 40
#define QUALITY_MAX 60
#define QUALITY_DEF 50
signed char sensor; /* Type of image sensor chip */ signed char sensor; /* Type of image sensor chip */
/* !! values used in different tables */ /* !! values used in different tables */
...@@ -7180,7 +7183,7 @@ static int sd_config(struct gspca_dev *gspca_dev, ...@@ -7180,7 +7183,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->gamma = gamma[(int) sd->sensor]; sd->gamma = gamma[(int) sd->sensor];
sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value; sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value;
sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value; sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value;
sd->quality = 50; sd->quality = QUALITY_DEF;
switch (sd->sensor) { switch (sd->sensor) {
case SENSOR_GC0305: case SENSOR_GC0305:
...@@ -7536,6 +7539,34 @@ static int sd_querymenu(struct gspca_dev *gspca_dev, ...@@ -7536,6 +7539,34 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
return -EINVAL; return -EINVAL;
} }
static int sd_set_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
if (jcomp->quality < QUALITY_MIN)
sd->quality = QUALITY_MIN;
else if (jcomp->quality > QUALITY_MAX)
sd->quality = QUALITY_MAX;
else
sd->quality = jcomp->quality;
if (gspca_dev->streaming)
jpeg_set_qual(sd->jpeg_hdr, sd->quality);
return 0;
}
static int sd_get_jcomp(struct gspca_dev *gspca_dev,
struct v4l2_jpegcompression *jcomp)
{
struct sd *sd = (struct sd *) gspca_dev;
memset(jcomp, 0, sizeof *jcomp);
jcomp->quality = sd->quality;
jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT
| V4L2_JPEG_MARKER_DQT;
return 0;
}
static const struct sd_desc sd_desc = { static const struct sd_desc sd_desc = {
.name = MODULE_NAME, .name = MODULE_NAME,
.ctrls = sd_ctrls, .ctrls = sd_ctrls,
...@@ -7546,6 +7577,8 @@ static const struct sd_desc sd_desc = { ...@@ -7546,6 +7577,8 @@ static const struct sd_desc sd_desc = {
.stop0 = sd_stop0, .stop0 = sd_stop0,
.pkt_scan = sd_pkt_scan, .pkt_scan = sd_pkt_scan,
.querymenu = sd_querymenu, .querymenu = sd_querymenu,
.get_jcomp = sd_get_jcomp,
.set_jcomp = sd_set_jcomp,
}; };
static const __devinitdata struct usb_device_id device_table[] = { static const __devinitdata struct usb_device_id device_table[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment