--- linux-2.6.7/drivers/usb/media/ov511.c 2004-08-15 08:34:19.000000000 -0500 +++ linux-2.6.7-patched/drivers/usb/media/ov511.c 2004-08-18 10:10:18.000000000 -0500 @@ -118,6 +118,10 @@ static int remove_zeros; static int mirror; static int ov518_color; +static int rgb_raw; +static int black_lines; +static int rapid_adjust; +static int low_pass = 1; MODULE_PARM(autobright, "i"); MODULE_PARM_DESC(autobright, "Sensor automatically changes brightness"); @@ -192,6 +196,17 @@ MODULE_PARM_DESC(mirror, "Reverse image horizontally"); MODULE_PARM(ov518_color, "i"); MODULE_PARM_DESC(ov518_color, "Enable OV518 color (experimental)"); +MODULE_PARM(rgb_raw, "i"); +MODULE_PARM_DESC(rgb_raw, + "Use raw RGB data (OV7620). 0=off (default), 1=gamma-corrected, 2=linear"); +MODULE_PARM(rapid_adjust, "i"); +MODULE_PARM_DESC(rapid_adjust, + "Enable rapid adjustment of saturation, brightness, and white balance (OV7620)."); +MODULE_PARM(black_lines, "i"); +MODULE_PARM_DESC(black_lines, + "Write black level into the topmost horizontal lines (OV7620)."); +MODULE_PARM(low_pass, "i"); +MODULE_PARM_DESC(low_pass, "Enable Low Pass Filter."); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); @@ -1418,6 +1433,9 @@ 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff }; + if (rgb_raw) + return 0; + /* Use Y gamma control instead. Bit 0 enables it. */ rc = i2c_w(ov, 0x64, ctab[val>>12]); if (rc < 0) @@ -2167,10 +2185,17 @@ get_depth(int palette) { switch (palette) { - case VIDEO_PALETTE_GREY: return 8; - case VIDEO_PALETTE_YUV420: return 12; - case VIDEO_PALETTE_YUV420P: return 12; /* Planar */ - default: return 0; /* Invalid format */ + case VIDEO_PALETTE_GREY: + return 8; + case VIDEO_PALETTE_YUV420: + case VIDEO_PALETTE_YUV420P: /* Planar */ + if (rgb_raw) + return 0; + else + return 12; + default: + /* Invalid format */ + return 0; } } @@ -2251,7 +2276,30 @@ && ov518_color) { i2c_w_mask(ov, 0x12, 0x00, 0x10); i2c_w_mask(ov, 0x13, 0x00, 0x20); - } else { + } else if (ov->sensor == SEN_OV7620 && rgb_raw) { + /* Set one-line raw mode */ + i2c_w_mask(ov, 0x12, 0x08, 0x08); + i2c_w_mask(ov, 0x28, 0x80, 0x80); + i2c_w_mask(ov, 0x61, 0x00, 0x80); + /* Turn sharpening off (or down...) */ + i2c_w_mask(ov, 0x69, 0x00, 0x40); + i2c_w (ov, 0x07, 0xf0); + // i2c_w (ov, 0x6a, 0x70); + i2c_w (ov, 0x6a, 0x00); + i2c_w_mask(ov, 0x26, 0xc0, 0xf0); + /* Turn anti-aliasing off */ + i2c_w_mask(ov, 0x68, 0x00, 0x0c); + /* Disable aperture correction */ + i2c_w_mask(ov, 0x20, 0x00, 0x30); + /* If specified, disable gamma correction */ + if (rgb_raw == 2) { + i2c_w_mask(ov, 0x14, 0x00, 0x04); + i2c_w_mask(ov, 0x64, 0x00, 0x01); + } + /* Disable range extension, since it doesn't + * seem to work very well. */ + i2c_w_mask(ov, 0x27, 0x00, 0x02); + } else if (ov->sensor != SEN_OV7620) { i2c_w_mask(ov, 0x13, 0x20, 0x20); } } else { @@ -2334,6 +2382,17 @@ /* Enable auto white balance */ i2c_w_mask(ov, 0x12, 0x04, 0x04); + /* Rapid adjustment */ + if (rapid_adjust == 1 && ov->sensor == SEN_OV7620) { + i2c_w_mask(ov, 0x70, 0x0a, 0x0a); + i2c_w_mask(ov, 0x71, 0x00, 0x80); + } + + /* Black level lines */ + if (black_lines == 1 && ov->sensor == SEN_OV7620) { + i2c_w_mask(ov, 0x26, 0x01, 0x01); + } + // This will go away as soon as ov51x_mode_init_sensor_regs() // is fully tested. /* 7620/6620/6630? don't have register 0x35, so play it safe */ @@ -2503,13 +2562,19 @@ if (mode == VIDEO_PALETTE_GREY) { reg_w(ov, R511_CAM_UV_EN, 0x00); reg_w(ov, R511_SNAP_UV_EN, 0x00); - reg_w(ov, R511_SNAP_OPTS, 0x01); } else { reg_w(ov, R511_CAM_UV_EN, 0x01); reg_w(ov, R511_SNAP_UV_EN, 0x01); - reg_w(ov, R511_SNAP_OPTS, 0x03); + + /* YUV 420 */ + reg_w_mask(ov, R511_CAM_OPTS, 0x02, 0x02); + reg_w_mask(ov, R511_SNAP_OPTS, 0x02, 0x02); } + /* Low pass filter */ + reg_w_mask(ov, R511_CAM_OPTS, (low_pass&&!rgb_raw)?0x01:0x00, 0x01); + reg_w_mask(ov, R511_SNAP_OPTS, (low_pass&&!rgb_raw)?0x01:0x00, 0x01); + /* Here I'm assuming that snapshot size == image size. * I hope that's always true. --claudio */ @@ -2521,9 +2586,6 @@ reg_w(ov, R511_CAM_PXDIV, 0x00); reg_w(ov, R511_CAM_LNDIV, 0x00); - /* YUV420, low pass filter on */ - reg_w(ov, R511_CAM_OPTS, 0x03); - /* Snapshot additions */ reg_w(ov, R511_SNAP_PXCNT, hsegs); reg_w(ov, R511_SNAP_LNCNT, vsegs); @@ -5009,14 +5071,16 @@ return -1; } - if (ov->sensor == SEN_OV7620) { - PDEBUG(4, "Writing 7620 registers"); - if (write_regvals(ov, aRegvalsNorm7620)) - return -1; - } else { - PDEBUG(4, "Writing 7610 registers"); - if (write_regvals(ov, aRegvalsNorm7610)) - return -1; + if (!rgb_raw) { + if (ov->sensor == SEN_OV7620) { + PDEBUG(4, "Writing 7620 registers"); + if (write_regvals(ov, aRegvalsNorm7620)) + return -1; + } else { + PDEBUG(4, "Writing 7610 registers"); + if (write_regvals(ov, aRegvalsNorm7610)) + return -1; + } } /* Set sensor-specific vars */