aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/pac207.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/pac207.c')
-rw-r--r--drivers/media/video/gspca/pac207.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index 95a97ab684cd..96659433d248 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -35,25 +35,17 @@ MODULE_LICENSE("GPL");
35 35
36#define PAC207_BRIGHTNESS_MIN 0 36#define PAC207_BRIGHTNESS_MIN 0
37#define PAC207_BRIGHTNESS_MAX 255 37#define PAC207_BRIGHTNESS_MAX 255
38#define PAC207_BRIGHTNESS_DEFAULT 4 /* power on default: 4 */ 38#define PAC207_BRIGHTNESS_DEFAULT 46
39 39
40/* An exposure value of 4 also works (3 does not) but then we need to lower 40#define PAC207_EXPOSURE_MIN 3
41 the compression balance setting when in 352x288 mode, otherwise the usb
42 bandwidth is not enough and packets get dropped resulting in corrupt
43 frames. The problem with this is that when the compression balance gets
44 lowered below 0x80, the pac207 starts using a different compression
45 algorithm for some lines, these lines get prefixed with a 0x2dd2 prefix
46 and currently we do not know how to decompress these lines, so for now
47 we use a minimum exposure value of 5 */
48#define PAC207_EXPOSURE_MIN 5
49#define PAC207_EXPOSURE_MAX 26 41#define PAC207_EXPOSURE_MAX 26
50#define PAC207_EXPOSURE_DEFAULT 5 /* power on default: 3 ?? */ 42#define PAC207_EXPOSURE_DEFAULT 5 /* power on default: 3 */
51#define PAC207_EXPOSURE_KNEE 11 /* 4 = 30 fps, 11 = 8, 15 = 6 */ 43#define PAC207_EXPOSURE_KNEE 8 /* 4 = 30 fps, 11 = 8, 15 = 6 */
52 44
53#define PAC207_GAIN_MIN 0 45#define PAC207_GAIN_MIN 0
54#define PAC207_GAIN_MAX 31 46#define PAC207_GAIN_MAX 31
55#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */ 47#define PAC207_GAIN_DEFAULT 9 /* power on default: 9 */
56#define PAC207_GAIN_KNEE 20 48#define PAC207_GAIN_KNEE 31
57 49
58#define PAC207_AUTOGAIN_DEADZONE 30 50#define PAC207_AUTOGAIN_DEADZONE 30
59 51
@@ -166,16 +158,12 @@ static const struct v4l2_pix_format sif_mode[] = {
166}; 158};
167 159
168static const __u8 pac207_sensor_init[][8] = { 160static const __u8 pac207_sensor_init[][8] = {
169 {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0xf0}, 161 {0x10, 0x12, 0x0d, 0x12, 0x0c, 0x01, 0x29, 0x84},
170 {0x00, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30}, 162 {0x49, 0x64, 0x64, 0x64, 0x04, 0x10, 0xf0, 0x30},
171 {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00}, 163 {0x00, 0x00, 0x00, 0x70, 0xa0, 0xf8, 0x00, 0x00},
172 {0x00, 0x00, 0x32, 0x00, 0x96, 0x00, 0xa2, 0x02},
173 {0x32, 0x00, 0x96, 0x00, 0xA2, 0x02, 0xaf, 0x00}, 164 {0x32, 0x00, 0x96, 0x00, 0xA2, 0x02, 0xaf, 0x00},
174}; 165};
175 166
176 /* 48 reg_72 Rate Control end BalSize_4a =0x36 */
177static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 };
178
179static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, 167static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
180 const u8 *buffer, u16 length) 168 const u8 *buffer, u16 length)
181{ 169{
@@ -274,7 +262,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
274 * Bit_1=LED, 262 * Bit_1=LED,
275 * Bit_2=Compression test mode enable */ 263 * Bit_2=Compression test mode enable */
276 pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */ 264 pac207_write_reg(gspca_dev, 0x0f, 0x00); /* Power Control */
277 pac207_write_reg(gspca_dev, 0x11, 0x30); /* Analog Bias */
278 265
279 return 0; 266 return 0;
280} 267}
@@ -289,15 +276,13 @@ static int sd_start(struct gspca_dev *gspca_dev)
289 pac207_write_regs(gspca_dev, 0x0002, pac207_sensor_init[0], 8); 276 pac207_write_regs(gspca_dev, 0x0002, pac207_sensor_init[0], 8);
290 pac207_write_regs(gspca_dev, 0x000a, pac207_sensor_init[1], 8); 277 pac207_write_regs(gspca_dev, 0x000a, pac207_sensor_init[1], 8);
291 pac207_write_regs(gspca_dev, 0x0012, pac207_sensor_init[2], 8); 278 pac207_write_regs(gspca_dev, 0x0012, pac207_sensor_init[2], 8);
292 pac207_write_regs(gspca_dev, 0x0040, pac207_sensor_init[3], 8); 279 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[3], 8);
293 pac207_write_regs(gspca_dev, 0x0042, pac207_sensor_init[4], 8);
294 pac207_write_regs(gspca_dev, 0x0048, PacReg72, 4);
295 280
296 /* Compression Balance */ 281 /* Compression Balance */
297 if (gspca_dev->width == 176) 282 if (gspca_dev->width == 176)
298 pac207_write_reg(gspca_dev, 0x4a, 0xff); 283 pac207_write_reg(gspca_dev, 0x4a, 0xff);
299 else 284 else
300 pac207_write_reg(gspca_dev, 0x4a, 0x88); 285 pac207_write_reg(gspca_dev, 0x4a, 0x30);
301 pac207_write_reg(gspca_dev, 0x4b, 0x00); /* Sram test value */ 286 pac207_write_reg(gspca_dev, 0x4b, 0x00); /* Sram test value */
302 pac207_write_reg(gspca_dev, 0x08, sd->brightness); 287 pac207_write_reg(gspca_dev, 0x08, sd->brightness);
303 288
@@ -346,7 +331,7 @@ static void pac207_do_auto_gain(struct gspca_dev *gspca_dev)
346 if (sd->autogain_ignore_frames > 0) 331 if (sd->autogain_ignore_frames > 0)
347 sd->autogain_ignore_frames--; 332 sd->autogain_ignore_frames--;
348 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, 333 else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum,
349 100 + sd->brightness / 2, PAC207_AUTOGAIN_DEADZONE, 334 100, PAC207_AUTOGAIN_DEADZONE,
350 PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE)) 335 PAC207_GAIN_KNEE, PAC207_EXPOSURE_KNEE))
351 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; 336 sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES;
352} 337}