static int ov76be_mode_init(struct i2c_client *c, struct ovcamchip_window *win) { int qvga = win->quarter; ov_write(c, 0x14, qvga?0xa4:0x84); if (win->format == VIDEO_PALETTE_GREY) { ov_write_mask(c, 0x0e, 0x40, 0x40); ov_write_mask(c, 0x13, 0x20, 0x20); } else { ov_write_mask(c, 0x0e, 0x00, 0x40); ov_write_mask(c, 0x13, 0x00, 0x20); } ov_write(c, 0x11, win->clockdiv); if (win->width == 640 && win->height == 480) ov_write(c, 0x35, 0x9e); else ov_write(c, 0x35, 0x1e); return 0; }
static int ov76be_mode_init(struct i2c_client *c, struct ovcamchip_window *win) { int qvga = win->quarter; /******** QVGA-specific regs ********/ ov_write(c, 0x14, qvga?0xa4:0x84); /******** Palette-specific regs ********/ if (win->format == VIDEO_PALETTE_GREY) { ov_write_mask(c, 0x0e, 0x40, 0x40); ov_write_mask(c, 0x13, 0x20, 0x20); } else { ov_write_mask(c, 0x0e, 0x00, 0x40); ov_write_mask(c, 0x13, 0x00, 0x20); } /******** Clock programming ********/ ov_write(c, 0x11, win->clockdiv); /******** Resolution-specific ********/ if (win->width == 640 && win->height == 480) ov_write(c, 0x35, 0x9e); else ov_write(c, 0x35, 0x1e); return 0; }
static int ov6x20_mode_init(struct i2c_client *c, struct ovcamchip_window *win) { /******** QCIF-specific regs ********/ ov_write(c, 0x14, win->quarter?0x24:0x04); /******** Palette-specific regs ********/ /* OV518 needs 8 bit multiplexed in color mode, and 16 bit in B&W */ if (c->adapter->id == (I2C_ALGO_SMBUS | I2C_HW_SMBUS_OV518)) { if (win->format == VIDEO_PALETTE_GREY) ov_write_mask(c, 0x13, 0x00, 0x20); else ov_write_mask(c, 0x13, 0x20, 0x20); } else { if (win->format == VIDEO_PALETTE_GREY) ov_write_mask(c, 0x13, 0x20, 0x20); else ov_write_mask(c, 0x13, 0x00, 0x20); } /******** Clock programming ********/ /* The OV6620 needs special handling. This prevents the * severe banding that normally occurs */ /* Clock down */ ov_write(c, 0x2a, 0x04); ov_write(c, 0x11, win->clockdiv); ov_write(c, 0x2a, 0x84); /* This next setting is critical. It seems to improve * the gain or the contrast. The "reserved" bits seem * to have some effect in this case. */ ov_write(c, 0x2d, 0x85); /* FIXME: This messes up banding filter */ return 0; }
static int ov76be_set_control(struct i2c_client *c, struct ovcamchip_control *ctl) { struct ovcamchip *ov = i2c_get_clientdata(c); struct ov76be *s = ov->spriv; int rc; int v = ctl->value; switch (ctl->id) { case OVCAMCHIP_CID_BRIGHT: rc = ov_write(c, REG_BRT, v >> 8); break; case OVCAMCHIP_CID_SAT: rc = ov_write(c, REG_SAT, v >> 8); break; case OVCAMCHIP_CID_EXP: rc = ov_write(c, REG_EXP, v); break; case OVCAMCHIP_CID_FREQ: { int sixty = (v == 60); rc = ov_write_mask(c, 0x2a, sixty?0x00:0x80, 0x80); if (rc < 0) goto out; rc = ov_write(c, 0x2b, sixty?0x00:0xac); if (rc < 0) goto out; rc = ov_write_mask(c, 0x76, 0x01, 0x01); break; } case OVCAMCHIP_CID_BANDFILT: rc = ov_write_mask(c, 0x2d, v?0x04:0x00, 0x04); s->bandfilt = v; break; case OVCAMCHIP_CID_AUTOBRIGHT: rc = ov_write_mask(c, 0x2d, v?0x10:0x00, 0x10); s->auto_brt = v; break; case OVCAMCHIP_CID_AUTOEXP: rc = ov_write_mask(c, 0x13, v?0x01:0x00, 0x01); s->auto_exp = v; break; case OVCAMCHIP_CID_MIRROR: rc = ov_write_mask(c, 0x12, v?0x40:0x00, 0x40); s->mirror = v; break; default: DDEBUG(2, &c->dev, "control not supported: %d", ctl->id); return -EPERM; } out: DDEBUG(3, &c->dev, "id=%d, arg=%d, rc=%d", ctl->id, v, rc); return rc; }