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: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Родитель
71cb2764fc
Коммит
77ac0baf24
|
@ -37,6 +37,9 @@ struct sd {
|
|||
unsigned char contrast;
|
||||
unsigned char colors;
|
||||
u8 quality;
|
||||
#define QUALITY_MIN 30
|
||||
#define QUALITY_MAX 60
|
||||
#define QUALITY_DEF 40
|
||||
|
||||
u8 *jpeg_hdr;
|
||||
};
|
||||
|
@ -822,7 +825,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
sd->brightness = BRIGHTNESS_DEF;
|
||||
sd->contrast = CONTRAST_DEF;
|
||||
sd->colors = COLOR_DEF;
|
||||
sd->quality = 40;
|
||||
sd->quality = QUALITY_DEF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1000,6 +1003,34 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
|
|||
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 */
|
||||
static struct sd_desc sd_desc = {
|
||||
.name = MODULE_NAME,
|
||||
|
@ -1010,6 +1041,8 @@ static struct sd_desc sd_desc = {
|
|||
.start = sd_start,
|
||||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
/* -- module initialisation -- */
|
||||
|
|
|
@ -37,6 +37,9 @@ struct sd {
|
|||
u8 gamma;
|
||||
u8 sharpness;
|
||||
u8 quality;
|
||||
#define QUALITY_MIN 40
|
||||
#define QUALITY_MAX 70
|
||||
#define QUALITY_DEF 50
|
||||
|
||||
u8 *jpeg_hdr;
|
||||
};
|
||||
|
@ -178,7 +181,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
sd->colors = COLOR_DEF;
|
||||
sd->gamma = GAMMA_DEF;
|
||||
sd->sharpness = SHARPNESS_DEF;
|
||||
sd->quality = 50;
|
||||
sd->quality = QUALITY_DEF;
|
||||
gspca_dev->nbalt = 9; /* use the altsetting 08 */
|
||||
return 0;
|
||||
}
|
||||
|
@ -445,6 +448,34 @@ static int sd_getsharpness(struct gspca_dev *gspca_dev, __s32 *val)
|
|||
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 */
|
||||
static const struct sd_desc sd_desc = {
|
||||
.name = MODULE_NAME,
|
||||
|
@ -456,6 +487,8 @@ static const struct sd_desc sd_desc = {
|
|||
.stopN = sd_stopN,
|
||||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
/* -- module initialisation -- */
|
||||
|
|
|
@ -47,6 +47,9 @@ struct sd {
|
|||
u8 vflip; /* ov7630/ov7648 only */
|
||||
u8 infrared; /* mt9v111 only */
|
||||
u8 quality; /* image quality */
|
||||
#define QUALITY_MIN 60
|
||||
#define QUALITY_MAX 95
|
||||
#define QUALITY_DEF 80
|
||||
u8 jpegqual; /* webcam quality */
|
||||
|
||||
u8 reg18;
|
||||
|
@ -1295,7 +1298,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
else
|
||||
sd->vflip = 1;
|
||||
sd->infrared = INFRARED_DEF;
|
||||
sd->quality = 80;
|
||||
sd->quality = QUALITY_DEF;
|
||||
sd->jpegqual = 80;
|
||||
|
||||
gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
|
||||
|
@ -2130,6 +2133,34 @@ static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val)
|
|||
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 */
|
||||
static const struct sd_desc sd_desc = {
|
||||
.name = MODULE_NAME,
|
||||
|
@ -2142,6 +2173,8 @@ static const struct sd_desc sd_desc = {
|
|||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.dq_callback = do_autogain,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
/* -- module initialisation -- */
|
||||
|
|
|
@ -39,6 +39,9 @@ struct sd {
|
|||
unsigned char contrast;
|
||||
unsigned char colors;
|
||||
u8 quality;
|
||||
#define QUALITY_MIN 70
|
||||
#define QUALITY_MAX 95
|
||||
#define QUALITY_DEF 85
|
||||
|
||||
char subtype;
|
||||
#define AgfaCl20 0
|
||||
|
@ -642,7 +645,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
sd->brightness = BRIGHTNESS_DEF;
|
||||
sd->contrast = CONTRAST_DEF;
|
||||
sd->colors = COLOR_DEF;
|
||||
sd->quality = 85;
|
||||
sd->quality = QUALITY_DEF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1021,6 +1024,34 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
|
|||
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 */
|
||||
static struct sd_desc sd_desc = {
|
||||
.name = MODULE_NAME,
|
||||
|
@ -1032,6 +1063,8 @@ static struct sd_desc sd_desc = {
|
|||
.stopN = sd_stopN,
|
||||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
/* -- module initialisation -- */
|
||||
|
|
|
@ -36,6 +36,9 @@ struct sd {
|
|||
unsigned char colors;
|
||||
unsigned char lightfreq;
|
||||
u8 quality;
|
||||
#define QUALITY_MIN 60
|
||||
#define QUALITY_MAX 95
|
||||
#define QUALITY_DEF 80
|
||||
|
||||
u8 *jpeg_hdr;
|
||||
};
|
||||
|
@ -301,7 +304,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
sd->contrast = CONTRAST_DEF;
|
||||
sd->colors = COLOR_DEF;
|
||||
sd->lightfreq = FREQ_DEF;
|
||||
sd->quality = 80;
|
||||
sd->quality = QUALITY_DEF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -535,6 +538,34 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
|
|||
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 */
|
||||
static const struct sd_desc sd_desc = {
|
||||
.name = MODULE_NAME,
|
||||
|
@ -547,6 +578,8 @@ static const struct sd_desc sd_desc = {
|
|||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.querymenu = sd_querymenu,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
/* -- module initialisation -- */
|
||||
|
|
|
@ -40,6 +40,9 @@ struct sd {
|
|||
unsigned char colors;
|
||||
unsigned char autogain;
|
||||
u8 quality;
|
||||
#define QUALITY_MIN 70
|
||||
#define QUALITY_MAX 95
|
||||
#define QUALITY_DEF 85
|
||||
|
||||
char bridge;
|
||||
#define BRIDGE_SPCA504 0
|
||||
|
@ -854,7 +857,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
|
||||
sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
|
||||
sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
|
||||
sd->quality = 85;
|
||||
sd->quality = QUALITY_DEF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1319,6 +1322,34 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val)
|
|||
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 */
|
||||
static const struct sd_desc sd_desc = {
|
||||
.name = MODULE_NAME,
|
||||
|
@ -1330,6 +1361,8 @@ static const struct sd_desc sd_desc = {
|
|||
.stopN = sd_stopN,
|
||||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
/* -- module initialisation -- */
|
||||
|
|
|
@ -46,6 +46,9 @@ struct sd {
|
|||
__u8 lightfreq;
|
||||
__u8 sharpness;
|
||||
u8 quality; /* image quality */
|
||||
#define QUALITY_MIN 40
|
||||
#define QUALITY_MAX 60
|
||||
#define QUALITY_DEF 50
|
||||
|
||||
signed char sensor; /* Type of image sensor chip */
|
||||
/* !! values used in different tables */
|
||||
|
@ -7180,7 +7183,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
|
|||
sd->gamma = gamma[(int) sd->sensor];
|
||||
sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value;
|
||||
sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value;
|
||||
sd->quality = 50;
|
||||
sd->quality = QUALITY_DEF;
|
||||
|
||||
switch (sd->sensor) {
|
||||
case SENSOR_GC0305:
|
||||
|
@ -7536,6 +7539,34 @@ static int sd_querymenu(struct gspca_dev *gspca_dev,
|
|||
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 = {
|
||||
.name = MODULE_NAME,
|
||||
.ctrls = sd_ctrls,
|
||||
|
@ -7546,6 +7577,8 @@ static const struct sd_desc sd_desc = {
|
|||
.stop0 = sd_stop0,
|
||||
.pkt_scan = sd_pkt_scan,
|
||||
.querymenu = sd_querymenu,
|
||||
.get_jcomp = sd_get_jcomp,
|
||||
.set_jcomp = sd_set_jcomp,
|
||||
};
|
||||
|
||||
static const __devinitdata struct usb_device_id device_table[] = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче