Commit 36e819db authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (10345): gspca - jpeg subdrivers: One quantization table per subdriver.

Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 96ff6514
......@@ -23,6 +23,7 @@
#include "gspca.h"
#define CONEX_CAM 1 /* special JPEG header */
#define QUANT_VAL 0 /* quantization table */
#include "jpeg.h"
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
......@@ -36,8 +37,6 @@ struct sd {
unsigned char brightness;
unsigned char contrast;
unsigned char colors;
unsigned char qindex;
};
/* V4L2 controls supported by the driver */
......@@ -818,7 +817,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = vga_mode;
cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
sd->qindex = 0; /* set the quantization */
sd->brightness = BRIGHTNESS_DEF;
sd->contrast = CONTRAST_DEF;
sd->colors = COLOR_DEF;
......@@ -882,9 +880,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
data, 0);
/* put the JPEG header in the new frame */
jpeg_put_header(gspca_dev, frame,
((struct sd *) gspca_dev)->qindex,
0x22);
jpeg_put_header(gspca_dev, frame, 0x22);
data += 2;
len -= 2;
}
......
This diff is collapsed.
......@@ -22,6 +22,7 @@
#define MODULE_NAME "mars"
#include "gspca.h"
#define QUANT_VAL 1 /* quantization table */
#include "jpeg.h"
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
......@@ -31,8 +32,6 @@ MODULE_LICENSE("GPL");
/* specific webcam descriptor */
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
char qindex;
};
/* V4L2 controls supported by the driver */
......@@ -117,13 +116,11 @@ static void bulk_w(struct gspca_dev *gspca_dev,
static int sd_config(struct gspca_dev *gspca_dev,
const struct usb_device_id *id)
{
struct sd *sd = (struct sd *) gspca_dev;
struct cam *cam;
cam = &gspca_dev->cam;
cam->cam_mode = vga_mode;
cam->nmodes = ARRAY_SIZE(vga_mode);
sd->qindex = 1; /* set the quantization table */
return 0;
}
......@@ -345,7 +342,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
__u8 *data, /* isoc packet */
int len) /* iso packet length */
{
struct sd *sd = (struct sd *) gspca_dev;
int p;
if (len < 6) {
......@@ -368,8 +364,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
frame, data, 0);
/* put the JPEG header */
jpeg_put_header(gspca_dev, frame,
sd->qindex, 0x21);
jpeg_put_header(gspca_dev, frame, 0x21);
data += 16;
len -= 16;
break;
......
......@@ -22,6 +22,7 @@
#define MODULE_NAME "sonixj"
#include "gspca.h"
#define QUANT_VAL 4 /* quantization table */
#include "jpeg.h"
#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
......@@ -49,7 +50,6 @@ struct sd {
__s8 ag_cnt;
#define AG_CNT_START 13
__u8 qindex;
__u8 bridge;
#define BRIDGE_SN9C102P 0
#define BRIDGE_SN9C105 1
......@@ -1025,7 +1025,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
sd->sensor = id->driver_info >> 8;
sd->i2c_base = id->driver_info;
sd->qindex = 4; /* set the quantization table */
sd->brightness = BRIGHTNESS_DEF;
sd->contrast = CONTRAST_DEF;
sd->colors = COLOR_DEF;
......@@ -1549,7 +1548,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
if (gspca_dev->last_packet_type == LAST_PACKET) {
/* put the JPEG 422 header */
jpeg_put_header(gspca_dev, frame, sd->qindex, 0x21);
jpeg_put_header(gspca_dev, frame, 0x21);
}
gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
}
......
......@@ -22,6 +22,7 @@
#define MODULE_NAME "spca500"
#include "gspca.h"
#define QUANT_VAL 5 /* quantization table */
#include "jpeg.h"
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
......@@ -39,7 +40,6 @@ struct sd {
unsigned char contrast;
unsigned char colors;
char qindex;
char subtype;
#define AgfaCl20 0
#define AiptekPocketDV 1
......@@ -637,7 +637,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = sif_mode;
cam->nmodes = ARRAY_SIZE(sif_mode);
}
sd->qindex = 5;
sd->brightness = BRIGHTNESS_DEF;
sd->contrast = CONTRAST_DEF;
sd->colors = COLOR_DEF;
......@@ -900,7 +899,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
ffd9, 2);
/* put the JPEG header in the new frame */
jpeg_put_header(gspca_dev, frame, sd->qindex, 0x22);
jpeg_put_header(gspca_dev, frame, 0x22);
data += SPCA500_OFFSET_DATA;
len -= SPCA500_OFFSET_DATA;
......
......@@ -21,6 +21,8 @@
#define MODULE_NAME "stk014"
#include "gspca.h"
#define QUANT_VAL 7 /* quantization table */
/* <= 4 KO - 7: good (enough!) */
#include "jpeg.h"
MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
......@@ -37,9 +39,6 @@ struct sd {
unsigned char lightfreq;
};
/* global parameters */
static int sd_quant = 7; /* <= 4 KO - 7: good (enough!) */
/* V4L2 controls supported by the driver */
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
......@@ -418,7 +417,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
ffd9, 2);
/* put the JPEG 411 header */
jpeg_put_header(gspca_dev, frame, sd_quant, 0x22);
jpeg_put_header(gspca_dev, frame, 0x22);
/* beginning of the frame */
#define STKHDRSZ 12
......@@ -575,6 +574,3 @@ static void __exit sd_mod_exit(void)
module_init(sd_mod_init);
module_exit(sd_mod_exit);
module_param_named(quant, sd_quant, int, 0644);
MODULE_PARM_DESC(quant, "Quantization index (0..8)");
......@@ -22,6 +22,7 @@
#define MODULE_NAME "sunplus"
#include "gspca.h"
#define QUANT_VAL 5 /* quantization table */
#include "jpeg.h"
MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
......@@ -40,7 +41,6 @@ struct sd {
unsigned char colors;
unsigned char autogain;
char qindex;
char bridge;
#define BRIDGE_SPCA504 0
#define BRIDGE_SPCA504B 1
......@@ -849,7 +849,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->nmodes = sizeof vga_mode2 / sizeof vga_mode2[0];
break;
}
sd->qindex = 5; /* set the quantization table */
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;
......@@ -1154,9 +1153,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
ffd9, 2);
/* put the JPEG header in the new frame */
jpeg_put_header(gspca_dev, frame,
((struct sd *) gspca_dev)->qindex,
0x22);
jpeg_put_header(gspca_dev, frame, 0x22);
}
/* add 0x00 after 0xff */
......
......@@ -31,6 +31,7 @@ MODULE_LICENSE("GPL");
static int force_sensor = -1;
#define QUANT_VAL 1 /* quantization table */
#include "jpeg.h"
#include "zc3xx-reg.h"
......@@ -45,7 +46,6 @@ struct sd {
__u8 lightfreq;
__u8 sharpness;
char qindex;
signed char sensor; /* Type of image sensor chip */
/* !! values used in different tables */
#define SENSOR_CS2102 0
......@@ -6536,7 +6536,6 @@ static void setquality(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
struct usb_device *dev = gspca_dev->dev;
__u8 quality;
__u8 frxt;
switch (sd->sensor) {
......@@ -6547,26 +6546,18 @@ static void setquality(struct gspca_dev *gspca_dev)
return;
}
/*fixme: is it really 0008 0007 0018 for all other sensors? */
quality = sd->qindex;
reg_w(dev, quality, 0x0008);
reg_w(dev, QUANT_VAL, 0x0008);
frxt = 0x30;
reg_w(dev, frxt, 0x0007);
switch (quality) {
case 0:
case 1:
case 2:
frxt = 0xff;
break;
case 3:
frxt = 0xf0;
break;
case 4:
frxt = 0xe0;
break;
case 5:
frxt = 0x20;
break;
}
#if QUANT_VAL == 0 || QUANT_VAL == 1 || QUANT_VAL == 2
frxt = 0xff;
#elif QUANT_VAL == 3
frxt = 0xf0;
#elif QUANT_VAL == 4
frxt = 0xe0;
#else
frxt = 0x20;
#endif
reg_w(dev, frxt, 0x0018);
}
......@@ -7156,7 +7147,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
cam->cam_mode = sif_mode;
cam->nmodes = ARRAY_SIZE(sif_mode);
}
sd->qindex = 1;
sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
sd->gamma = gamma[(int) sd->sensor];
......@@ -7358,9 +7348,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
data, 0);
/* put the JPEG header in the new frame */
jpeg_put_header(gspca_dev, frame,
((struct sd *) gspca_dev)->qindex,
0x21);
jpeg_put_header(gspca_dev, frame, 0x21);
/* remove the webcam's header:
* ff d8 ff fe 00 0e 00 00 ss ss 00 01 ww ww hh hh pp pp
* - 'ss ss' is the frame sequence number (BE)
......
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