• Home
  • Raw
  • Download

Lines Matching refs:sd

50 struct sd {  struct
1989 static void reg_w(struct sd *sd, u16 index, u16 value) in reg_w() argument
1991 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in reg_w()
1994 if (sd->gspca_dev.usb_err < 0) in reg_w()
2000 switch (sd->bridge) { in reg_w()
2011 ret = usb_control_msg(sd->gspca_dev.dev, in reg_w()
2012 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in reg_w()
2023 sd->gspca_dev.usb_buf[0] = value; in reg_w()
2024 ret = usb_control_msg(sd->gspca_dev.dev, in reg_w()
2025 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in reg_w()
2029 sd->gspca_dev.usb_buf, 1, 500); in reg_w()
2033 sd->gspca_dev.usb_err = ret; in reg_w()
2040 static int reg_r(struct sd *sd, u16 index) in reg_r() argument
2042 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in reg_r()
2046 if (sd->gspca_dev.usb_err < 0) in reg_r()
2049 switch (sd->bridge) { in reg_r()
2063 ret = usb_control_msg(sd->gspca_dev.dev, in reg_r()
2064 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), in reg_r()
2067 0, index, sd->gspca_dev.usb_buf, 1, 500); in reg_r()
2070 ret = sd->gspca_dev.usb_buf[0]; in reg_r()
2075 sd->gspca_dev.usb_err = ret; in reg_r()
2087 static int reg_r8(struct sd *sd, in reg_r8() argument
2090 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in reg_r8()
2093 if (sd->gspca_dev.usb_err < 0) in reg_r8()
2098 ret = usb_control_msg(sd->gspca_dev.dev, in reg_r8()
2099 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), in reg_r8()
2102 0, index, sd->gspca_dev.usb_buf, 8, 500); in reg_r8()
2105 ret = sd->gspca_dev.usb_buf[0]; in reg_r8()
2108 sd->gspca_dev.usb_err = ret; in reg_r8()
2125 static void reg_w_mask(struct sd *sd, in reg_w_mask() argument
2135 ret = reg_r(sd, index); in reg_w_mask()
2142 reg_w(sd, index, value); in reg_w_mask()
2149 static void ov518_reg_w32(struct sd *sd, u16 index, u32 value, int n) in ov518_reg_w32() argument
2151 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov518_reg_w32()
2154 if (sd->gspca_dev.usb_err < 0) in ov518_reg_w32()
2157 *((__le32 *) sd->gspca_dev.usb_buf) = __cpu_to_le32(value); in ov518_reg_w32()
2161 ret = usb_control_msg(sd->gspca_dev.dev, in ov518_reg_w32()
2162 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in ov518_reg_w32()
2166 sd->gspca_dev.usb_buf, n, 500); in ov518_reg_w32()
2169 sd->gspca_dev.usb_err = ret; in ov518_reg_w32()
2173 static void ov511_i2c_w(struct sd *sd, u8 reg, u8 value) in ov511_i2c_w() argument
2175 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov511_i2c_w()
2183 reg_w(sd, R51x_I2C_SADDR_3, reg); in ov511_i2c_w()
2186 reg_w(sd, R51x_I2C_DATA, value); in ov511_i2c_w()
2189 reg_w(sd, R511_I2C_CTL, 0x01); in ov511_i2c_w()
2192 rc = reg_r(sd, R511_I2C_CTL); in ov511_i2c_w()
2207 static int ov511_i2c_r(struct sd *sd, u8 reg) in ov511_i2c_r() argument
2209 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov511_i2c_r()
2215 reg_w(sd, R51x_I2C_SADDR_2, reg); in ov511_i2c_r()
2218 reg_w(sd, R511_I2C_CTL, 0x03); in ov511_i2c_r()
2221 rc = reg_r(sd, R511_I2C_CTL); in ov511_i2c_r()
2231 reg_w(sd, R511_I2C_CTL, 0x10); in ov511_i2c_r()
2242 reg_w(sd, R511_I2C_CTL, 0x05); in ov511_i2c_r()
2245 rc = reg_r(sd, R511_I2C_CTL); in ov511_i2c_r()
2255 reg_w(sd, R511_I2C_CTL, 0x10); in ov511_i2c_r()
2263 value = reg_r(sd, R51x_I2C_DATA); in ov511_i2c_r()
2268 reg_w(sd, R511_I2C_CTL, 0x05); in ov511_i2c_r()
2278 static void ov518_i2c_w(struct sd *sd, in ov518_i2c_w() argument
2282 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov518_i2c_w()
2287 reg_w(sd, R51x_I2C_SADDR_3, reg); in ov518_i2c_w()
2290 reg_w(sd, R51x_I2C_DATA, value); in ov518_i2c_w()
2293 reg_w(sd, R518_I2C_CTL, 0x01); in ov518_i2c_w()
2297 reg_r8(sd, R518_I2C_CTL); in ov518_i2c_w()
2307 static int ov518_i2c_r(struct sd *sd, u8 reg) in ov518_i2c_r() argument
2309 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov518_i2c_r()
2313 reg_w(sd, R51x_I2C_SADDR_2, reg); in ov518_i2c_r()
2316 reg_w(sd, R518_I2C_CTL, 0x03); in ov518_i2c_r()
2317 reg_r8(sd, R518_I2C_CTL); in ov518_i2c_r()
2320 reg_w(sd, R518_I2C_CTL, 0x05); in ov518_i2c_r()
2321 reg_r8(sd, R518_I2C_CTL); in ov518_i2c_r()
2323 value = reg_r(sd, R51x_I2C_DATA); in ov518_i2c_r()
2328 static void ovfx2_i2c_w(struct sd *sd, u8 reg, u8 value) in ovfx2_i2c_w() argument
2330 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ovfx2_i2c_w()
2333 if (sd->gspca_dev.usb_err < 0) in ovfx2_i2c_w()
2336 ret = usb_control_msg(sd->gspca_dev.dev, in ovfx2_i2c_w()
2337 usb_sndctrlpipe(sd->gspca_dev.dev, 0), in ovfx2_i2c_w()
2344 sd->gspca_dev.usb_err = ret; in ovfx2_i2c_w()
2350 static int ovfx2_i2c_r(struct sd *sd, u8 reg) in ovfx2_i2c_r() argument
2352 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ovfx2_i2c_r()
2355 if (sd->gspca_dev.usb_err < 0) in ovfx2_i2c_r()
2358 ret = usb_control_msg(sd->gspca_dev.dev, in ovfx2_i2c_r()
2359 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), in ovfx2_i2c_r()
2362 0, (u16) reg, sd->gspca_dev.usb_buf, 1, 500); in ovfx2_i2c_r()
2365 ret = sd->gspca_dev.usb_buf[0]; in ovfx2_i2c_r()
2370 sd->gspca_dev.usb_err = ret; in ovfx2_i2c_r()
2376 static void i2c_w(struct sd *sd, u8 reg, u8 value) in i2c_w() argument
2378 if (sd->sensor_reg_cache[reg] == value) in i2c_w()
2381 switch (sd->bridge) { in i2c_w()
2384 ov511_i2c_w(sd, reg, value); in i2c_w()
2389 ov518_i2c_w(sd, reg, value); in i2c_w()
2392 ovfx2_i2c_w(sd, reg, value); in i2c_w()
2395 w9968cf_i2c_w(sd, reg, value); in i2c_w()
2399 if (sd->gspca_dev.usb_err >= 0) { in i2c_w()
2402 memset(sd->sensor_reg_cache, -1, in i2c_w()
2403 sizeof(sd->sensor_reg_cache)); in i2c_w()
2405 sd->sensor_reg_cache[reg] = value; in i2c_w()
2409 static int i2c_r(struct sd *sd, u8 reg) in i2c_r() argument
2413 if (sd->sensor_reg_cache[reg] != -1) in i2c_r()
2414 return sd->sensor_reg_cache[reg]; in i2c_r()
2416 switch (sd->bridge) { in i2c_r()
2419 ret = ov511_i2c_r(sd, reg); in i2c_r()
2424 ret = ov518_i2c_r(sd, reg); in i2c_r()
2427 ret = ovfx2_i2c_r(sd, reg); in i2c_r()
2430 ret = w9968cf_i2c_r(sd, reg); in i2c_r()
2435 sd->sensor_reg_cache[reg] = ret; in i2c_r()
2445 static void i2c_w_mask(struct sd *sd, in i2c_w_mask() argument
2454 rc = i2c_r(sd, reg); in i2c_w_mask()
2459 i2c_w(sd, reg, value); in i2c_w_mask()
2464 static inline void ov51x_stop(struct sd *sd) in ov51x_stop() argument
2466 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov51x_stop()
2469 sd->stopped = 1; in ov51x_stop()
2470 switch (sd->bridge) { in ov51x_stop()
2473 reg_w(sd, R51x_SYS_RESET, 0x3d); in ov51x_stop()
2477 reg_w_mask(sd, R51x_SYS_RESET, 0x3a, 0x3a); in ov51x_stop()
2480 reg_w(sd, OV519_R51_RESET1, 0x0f); in ov51x_stop()
2481 reg_w(sd, OV519_R51_RESET1, 0x00); in ov51x_stop()
2482 reg_w(sd, 0x22, 0x00); /* FRAR */ in ov51x_stop()
2485 reg_w_mask(sd, 0x0f, 0x00, 0x02); in ov51x_stop()
2488 reg_w(sd, 0x3c, 0x0a05); /* stop USB transfer */ in ov51x_stop()
2495 static inline void ov51x_restart(struct sd *sd) in ov51x_restart() argument
2497 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov51x_restart()
2500 if (!sd->stopped) in ov51x_restart()
2502 sd->stopped = 0; in ov51x_restart()
2505 switch (sd->bridge) { in ov51x_restart()
2508 reg_w(sd, R51x_SYS_RESET, 0x00); in ov51x_restart()
2512 reg_w(sd, 0x2f, 0x80); in ov51x_restart()
2513 reg_w(sd, R51x_SYS_RESET, 0x00); in ov51x_restart()
2516 reg_w(sd, OV519_R51_RESET1, 0x0f); in ov51x_restart()
2517 reg_w(sd, OV519_R51_RESET1, 0x00); in ov51x_restart()
2518 reg_w(sd, 0x22, 0x1d); /* FRAR */ in ov51x_restart()
2521 reg_w_mask(sd, 0x0f, 0x02, 0x02); in ov51x_restart()
2524 reg_w(sd, 0x3c, 0x8a05); /* USB FIFO enable */ in ov51x_restart()
2529 static void ov51x_set_slave_ids(struct sd *sd, u8 slave);
2534 static int init_ov_sensor(struct sd *sd, u8 slave) in init_ov_sensor() argument
2537 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in init_ov_sensor()
2539 ov51x_set_slave_ids(sd, slave); in init_ov_sensor()
2542 i2c_w(sd, 0x12, 0x80); in init_ov_sensor()
2548 if (i2c_r(sd, OV7610_REG_ID_HIGH) == 0x7f && in init_ov_sensor()
2549 i2c_r(sd, OV7610_REG_ID_LOW) == 0xa2) { in init_ov_sensor()
2556 i2c_w(sd, 0x12, 0x80); in init_ov_sensor()
2562 if (i2c_r(sd, 0x00) < 0) in init_ov_sensor()
2573 static void ov51x_set_slave_ids(struct sd *sd, in ov51x_set_slave_ids() argument
2576 switch (sd->bridge) { in ov51x_set_slave_ids()
2578 reg_w(sd, OVFX2_I2C_ADDR, slave); in ov51x_set_slave_ids()
2581 sd->sensor_addr = slave; in ov51x_set_slave_ids()
2585 reg_w(sd, R51x_I2C_W_SID, slave); in ov51x_set_slave_ids()
2586 reg_w(sd, R51x_I2C_R_SID, slave + 1); in ov51x_set_slave_ids()
2589 static void write_regvals(struct sd *sd, in write_regvals() argument
2594 reg_w(sd, regvals->reg, regvals->val); in write_regvals()
2599 static void write_i2c_regvals(struct sd *sd, in write_i2c_regvals() argument
2604 i2c_w(sd, regvals->reg, regvals->val); in write_i2c_regvals()
2616 static void ov_hires_configure(struct sd *sd) in ov_hires_configure() argument
2618 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov_hires_configure()
2621 if (sd->bridge != BRIDGE_OVFX2) { in ov_hires_configure()
2629 high = i2c_r(sd, 0x0a); in ov_hires_configure()
2630 low = i2c_r(sd, 0x0b); in ov_hires_configure()
2637 sd->sensor = SEN_OV2610; in ov_hires_configure()
2641 sd->sensor = SEN_OV2610AE; in ov_hires_configure()
2645 sd->sensor = SEN_OV9600; in ov_hires_configure()
2652 sd->sensor = SEN_OV3610; in ov_hires_configure()
2664 static void ov8xx0_configure(struct sd *sd) in ov8xx0_configure() argument
2666 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov8xx0_configure()
2672 rc = i2c_r(sd, OV7610_REG_COM_I); in ov8xx0_configure()
2678 sd->sensor = SEN_OV8610; in ov8xx0_configure()
2687 static void ov7xx0_configure(struct sd *sd) in ov7xx0_configure() argument
2689 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov7xx0_configure()
2695 rc = i2c_r(sd, OV7610_REG_COM_I); in ov7xx0_configure()
2705 high = i2c_r(sd, 0x0a); in ov7xx0_configure()
2706 low = i2c_r(sd, 0x0b); in ov7xx0_configure()
2711 sd->sensor = SEN_OV7670; in ov7xx0_configure()
2714 sd->sensor = SEN_OV7610; in ov7xx0_configure()
2718 if (i2c_r(sd, 0x15) & 1) { in ov7xx0_configure()
2720 sd->sensor = SEN_OV7620AE; in ov7xx0_configure()
2723 sd->sensor = SEN_OV76BE; in ov7xx0_configure()
2727 high = i2c_r(sd, 0x0a); in ov7xx0_configure()
2732 low = i2c_r(sd, 0x0b); in ov7xx0_configure()
2745 sd->sensor = SEN_OV7640; /* FIXME */ in ov7xx0_configure()
2749 sd->sensor = SEN_OV7640; /* FIXME */ in ov7xx0_configure()
2753 sd->sensor = SEN_OV7648; in ov7xx0_configure()
2757 sd->sensor = SEN_OV7660; in ov7xx0_configure()
2766 sd->sensor = SEN_OV7620; in ov7xx0_configure()
2775 static void ov6xx0_configure(struct sd *sd) in ov6xx0_configure() argument
2777 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov6xx0_configure()
2783 rc = i2c_r(sd, OV7610_REG_COM_I); in ov6xx0_configure()
2794 sd->sensor = SEN_OV6630; in ov6xx0_configure()
2798 sd->sensor = SEN_OV6620; in ov6xx0_configure()
2802 sd->sensor = SEN_OV6630; in ov6xx0_configure()
2806 sd->sensor = SEN_OV66308AF; in ov6xx0_configure()
2810 sd->sensor = SEN_OV6630; in ov6xx0_configure()
2820 sd->sif = 1; in ov6xx0_configure()
2824 static void ov51x_led_control(struct sd *sd, int on) in ov51x_led_control() argument
2826 if (sd->invert_led) in ov51x_led_control()
2829 switch (sd->bridge) { in ov51x_led_control()
2832 reg_w(sd, R511_SYS_LED_CTL, on); in ov51x_led_control()
2836 reg_w_mask(sd, R518_GPIO_OUT, 0x02 * on, 0x02); in ov51x_led_control()
2839 reg_w_mask(sd, OV519_GPIO_DATA_OUT0, on, 1); in ov51x_led_control()
2846 struct sd *sd = (struct sd *) gspca_dev; in sd_reset_snapshot() local
2848 if (!sd->snapshot_needs_reset) in sd_reset_snapshot()
2854 sd->snapshot_needs_reset = 0; in sd_reset_snapshot()
2856 switch (sd->bridge) { in sd_reset_snapshot()
2859 reg_w(sd, R51x_SYS_SNAP, 0x02); in sd_reset_snapshot()
2860 reg_w(sd, R51x_SYS_SNAP, 0x00); in sd_reset_snapshot()
2864 reg_w(sd, R51x_SYS_SNAP, 0x02); /* Reset */ in sd_reset_snapshot()
2865 reg_w(sd, R51x_SYS_SNAP, 0x01); /* Enable */ in sd_reset_snapshot()
2868 reg_w(sd, R51x_SYS_RESET, 0x40); in sd_reset_snapshot()
2869 reg_w(sd, R51x_SYS_RESET, 0x00); in sd_reset_snapshot()
2874 static void ov51x_upload_quan_tables(struct sd *sd) in ov51x_upload_quan_tables() argument
2912 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov51x_upload_quan_tables()
2919 if (sd->bridge == BRIDGE_OV511 || sd->bridge == BRIDGE_OV511PLUS) { in ov51x_upload_quan_tables()
2935 reg_w(sd, reg, val0); in ov51x_upload_quan_tables()
2942 reg_w(sd, reg + size, val0); in ov51x_upload_quan_tables()
2951 struct sd *sd = (struct sd *) gspca_dev; in ov511_configure() local
2996 reg_r(sd, R51x_SYS_CUST_ID)); in ov511_configure()
2998 write_regvals(sd, init_511, ARRAY_SIZE(init_511)); in ov511_configure()
3000 switch (sd->bridge) { in ov511_configure()
3002 write_regvals(sd, norm_511, ARRAY_SIZE(norm_511)); in ov511_configure()
3005 write_regvals(sd, norm_511_p, ARRAY_SIZE(norm_511_p)); in ov511_configure()
3010 write_regvals(sd, compress_511, ARRAY_SIZE(compress_511)); in ov511_configure()
3012 ov51x_upload_quan_tables(sd); in ov511_configure()
3018 struct sd *sd = (struct sd *) gspca_dev; in ov518_configure() local
3065 sd->revision = reg_r(sd, R51x_SYS_CUST_ID) & 0x1f; in ov518_configure()
3066 gspca_dbg(gspca_dev, D_PROBE, "Device revision %d\n", sd->revision); in ov518_configure()
3068 write_regvals(sd, init_518, ARRAY_SIZE(init_518)); in ov518_configure()
3071 reg_w_mask(sd, R518_GPIO_CTL, 0x00, 0x02); in ov518_configure()
3073 switch (sd->bridge) { in ov518_configure()
3075 write_regvals(sd, norm_518, ARRAY_SIZE(norm_518)); in ov518_configure()
3078 write_regvals(sd, norm_518_p, ARRAY_SIZE(norm_518_p)); in ov518_configure()
3082 ov51x_upload_quan_tables(sd); in ov518_configure()
3084 reg_w(sd, 0x2f, 0x80); in ov518_configure()
3087 static void ov519_configure(struct sd *sd) in ov519_configure() argument
3105 write_regvals(sd, init_519, ARRAY_SIZE(init_519)); in ov519_configure()
3108 static void ovfx2_configure(struct sd *sd) in ovfx2_configure() argument
3120 sd->stopped = 1; in ovfx2_configure()
3122 write_regvals(sd, init_fx2, ARRAY_SIZE(init_fx2)); in ovfx2_configure()
3127 static void ov519_set_mode(struct sd *sd) in ov519_set_mode() argument
3154 write_regvals(sd, bridge_ov7660[sd->gspca_dev.curr_mode], in ov519_set_mode()
3156 write_i2c_regvals(sd, sensor_ov7660[sd->gspca_dev.curr_mode], in ov519_set_mode()
3158 write_i2c_regvals(sd, sensor_ov7660_2, in ov519_set_mode()
3164 static void ov519_set_fr(struct sd *sd) in ov519_set_fr() argument
3189 sd->frame_rate = frame_rate; in ov519_set_fr()
3190 if (sd->frame_rate >= 30) in ov519_set_fr()
3192 else if (sd->frame_rate >= 25) in ov519_set_fr()
3194 else if (sd->frame_rate >= 20) in ov519_set_fr()
3196 else if (sd->frame_rate >= 15) in ov519_set_fr()
3198 else if (sd->frame_rate >= 10) in ov519_set_fr()
3202 reg_w(sd, 0xa4, fr_tb[sd->gspca_dev.curr_mode][fr][0]); in ov519_set_fr()
3203 reg_w(sd, 0x23, fr_tb[sd->gspca_dev.curr_mode][fr][1]); in ov519_set_fr()
3204 clock = fr_tb[sd->gspca_dev.curr_mode][fr][2]; in ov519_set_fr()
3205 if (sd->sensor == SEN_OV7660) in ov519_set_fr()
3207 ov518_i2c_w(sd, OV7670_R11_CLKRC, clock); in ov519_set_fr()
3212 struct sd *sd = (struct sd *) gspca_dev; in setautogain() local
3214 i2c_w_mask(sd, 0x13, val ? 0x05 : 0x00, 0x05); in setautogain()
3221 struct sd *sd = (struct sd *) gspca_dev; in sd_config() local
3224 sd->bridge = id->driver_info & BRIDGE_MASK; in sd_config()
3225 sd->invert_led = (id->driver_info & BRIDGE_INVERT_LED) != 0; in sd_config()
3227 switch (sd->bridge) { in sd_config()
3255 sd->frame_rate = 15; in sd_config()
3263 struct sd *sd = (struct sd *) gspca_dev; in sd_init() local
3266 switch (sd->bridge) { in sd_init()
3276 ov519_configure(sd); in sd_init()
3279 ovfx2_configure(sd); in sd_init()
3282 w9968cf_configure(sd); in sd_init()
3289 sd->sensor = -1; in sd_init()
3292 if (init_ov_sensor(sd, OV7xx0_SID) >= 0) { in sd_init()
3293 ov7xx0_configure(sd); in sd_init()
3296 } else if (init_ov_sensor(sd, OV6xx0_SID) >= 0) { in sd_init()
3297 ov6xx0_configure(sd); in sd_init()
3300 } else if (init_ov_sensor(sd, OV8xx0_SID) >= 0) { in sd_init()
3301 ov8xx0_configure(sd); in sd_init()
3304 } else if (init_ov_sensor(sd, OV_HIRES_SID) >= 0) { in sd_init()
3305 ov_hires_configure(sd); in sd_init()
3311 if (sd->sensor < 0) in sd_init()
3314 ov51x_led_control(sd, 0); /* turn LED off */ in sd_init()
3316 switch (sd->bridge) { in sd_init()
3319 if (sd->sif) { in sd_init()
3326 if (sd->sif) { in sd_init()
3332 if (sd->sif) { in sd_init()
3338 switch (sd->sensor) { in sd_init()
3353 if (sd->sif) { in sd_init()
3361 if (sd->sif) in sd_init()
3365 w9968cf_init(sd); in sd_init()
3370 switch (sd->sensor) { in sd_init()
3372 write_i2c_regvals(sd, norm_2610, ARRAY_SIZE(norm_2610)); in sd_init()
3375 i2c_w_mask(sd, 0x13, 0x27, 0x27); in sd_init()
3378 write_i2c_regvals(sd, norm_2610ae, ARRAY_SIZE(norm_2610ae)); in sd_init()
3381 i2c_w_mask(sd, 0x13, 0x05, 0x05); in sd_init()
3384 write_i2c_regvals(sd, norm_3620b, ARRAY_SIZE(norm_3620b)); in sd_init()
3387 i2c_w_mask(sd, 0x13, 0x27, 0x27); in sd_init()
3390 write_i2c_regvals(sd, norm_6x20, ARRAY_SIZE(norm_6x20)); in sd_init()
3394 write_i2c_regvals(sd, norm_6x30, ARRAY_SIZE(norm_6x30)); in sd_init()
3399 write_i2c_regvals(sd, norm_7610, ARRAY_SIZE(norm_7610)); in sd_init()
3400 i2c_w_mask(sd, 0x0e, 0x00, 0x40); in sd_init()
3404 write_i2c_regvals(sd, norm_7620, ARRAY_SIZE(norm_7620)); in sd_init()
3408 write_i2c_regvals(sd, norm_7640, ARRAY_SIZE(norm_7640)); in sd_init()
3411 i2c_w(sd, OV7670_R12_COM7, OV7670_COM7_RESET); in sd_init()
3413 reg_w(sd, OV519_R57_SNAPSHOT, 0x23); in sd_init()
3414 write_regvals(sd, init_519_ov7660, in sd_init()
3416 write_i2c_regvals(sd, norm_7660, ARRAY_SIZE(norm_7660)); in sd_init()
3417 sd->gspca_dev.curr_mode = 1; /* 640x480 */ in sd_init()
3418 ov519_set_mode(sd); in sd_init()
3419 ov519_set_fr(sd); in sd_init()
3421 ov51x_restart(sd); in sd_init()
3422 ov51x_stop(sd); /* not in win traces */ in sd_init()
3423 ov51x_led_control(sd, 0); in sd_init()
3426 write_i2c_regvals(sd, norm_7670, ARRAY_SIZE(norm_7670)); in sd_init()
3429 write_i2c_regvals(sd, norm_8610, ARRAY_SIZE(norm_8610)); in sd_init()
3432 write_i2c_regvals(sd, norm_9600, ARRAY_SIZE(norm_9600)); in sd_init()
3447 struct sd *sd = (struct sd *) gspca_dev; in sd_isoc_init() local
3449 switch (sd->bridge) { in sd_isoc_init()
3464 static void ov511_mode_init_regs(struct sd *sd) in ov511_mode_init_regs() argument
3466 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov511_mode_init_regs()
3472 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); in ov511_mode_init_regs()
3473 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); in ov511_mode_init_regs()
3476 sd->gspca_dev.usb_err = -EIO; in ov511_mode_init_regs()
3481 sd->gspca_dev.usb_err = -ENODEV; in ov511_mode_init_regs()
3486 reg_w(sd, R51x_FIFO_PSIZE, packet_size >> 5); in ov511_mode_init_regs()
3488 reg_w(sd, R511_CAM_UV_EN, 0x01); in ov511_mode_init_regs()
3489 reg_w(sd, R511_SNAP_UV_EN, 0x01); in ov511_mode_init_regs()
3490 reg_w(sd, R511_SNAP_OPTS, 0x03); in ov511_mode_init_regs()
3495 hsegs = (sd->gspca_dev.pixfmt.width >> 3) - 1; in ov511_mode_init_regs()
3496 vsegs = (sd->gspca_dev.pixfmt.height >> 3) - 1; in ov511_mode_init_regs()
3498 reg_w(sd, R511_CAM_PXCNT, hsegs); in ov511_mode_init_regs()
3499 reg_w(sd, R511_CAM_LNCNT, vsegs); in ov511_mode_init_regs()
3500 reg_w(sd, R511_CAM_PXDIV, 0x00); in ov511_mode_init_regs()
3501 reg_w(sd, R511_CAM_LNDIV, 0x00); in ov511_mode_init_regs()
3504 reg_w(sd, R511_CAM_OPTS, 0x03); in ov511_mode_init_regs()
3507 reg_w(sd, R511_SNAP_PXCNT, hsegs); in ov511_mode_init_regs()
3508 reg_w(sd, R511_SNAP_LNCNT, vsegs); in ov511_mode_init_regs()
3509 reg_w(sd, R511_SNAP_PXDIV, 0x00); in ov511_mode_init_regs()
3510 reg_w(sd, R511_SNAP_LNDIV, 0x00); in ov511_mode_init_regs()
3514 sd->frame_rate = frame_rate; in ov511_mode_init_regs()
3516 switch (sd->sensor) { in ov511_mode_init_regs()
3519 sd->clockdiv = 3; in ov511_mode_init_regs()
3529 if (sd->gspca_dev.pixfmt.width == 320) in ov511_mode_init_regs()
3535 switch (sd->frame_rate) { in ov511_mode_init_regs()
3539 if (sd->gspca_dev.pixfmt.width != 640) { in ov511_mode_init_regs()
3540 sd->clockdiv = 0; in ov511_mode_init_regs()
3548 sd->clockdiv = 1; in ov511_mode_init_regs()
3551 sd->clockdiv = 2; in ov511_mode_init_regs()
3554 sd->clockdiv = 5; in ov511_mode_init_regs()
3558 sd->clockdiv = (sd->clockdiv + 1) * 2 - 1; in ov511_mode_init_regs()
3560 if (sd->clockdiv > 10) in ov511_mode_init_regs()
3561 sd->clockdiv = 10; in ov511_mode_init_regs()
3567 sd->clockdiv = 0; in ov511_mode_init_regs()
3572 fps = (interlaced ? 60 : 30) / (sd->clockdiv + 1) + 1; in ov511_mode_init_regs()
3573 needed = fps * sd->gspca_dev.pixfmt.width * in ov511_mode_init_regs()
3574 sd->gspca_dev.pixfmt.height * 3 / 2; in ov511_mode_init_regs()
3578 reg_w(sd, R511_COMP_EN, 0x07); in ov511_mode_init_regs()
3579 reg_w(sd, R511_COMP_LUT_EN, 0x03); in ov511_mode_init_regs()
3581 reg_w(sd, R511_COMP_EN, 0x06); in ov511_mode_init_regs()
3582 reg_w(sd, R511_COMP_LUT_EN, 0x00); in ov511_mode_init_regs()
3585 reg_w(sd, R51x_SYS_RESET, OV511_RESET_OMNICE); in ov511_mode_init_regs()
3586 reg_w(sd, R51x_SYS_RESET, 0); in ov511_mode_init_regs()
3596 static void ov518_mode_init_regs(struct sd *sd) in ov518_mode_init_regs() argument
3598 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov518_mode_init_regs()
3603 intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface); in ov518_mode_init_regs()
3604 alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); in ov518_mode_init_regs()
3607 sd->gspca_dev.usb_err = -EIO; in ov518_mode_init_regs()
3612 sd->gspca_dev.usb_err = -ENODEV; in ov518_mode_init_regs()
3617 ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2); in ov518_mode_init_regs()
3620 reg_w(sd, 0x2b, 0); in ov518_mode_init_regs()
3621 reg_w(sd, 0x2c, 0); in ov518_mode_init_regs()
3622 reg_w(sd, 0x2d, 0); in ov518_mode_init_regs()
3623 reg_w(sd, 0x2e, 0); in ov518_mode_init_regs()
3624 reg_w(sd, 0x3b, 0); in ov518_mode_init_regs()
3625 reg_w(sd, 0x3c, 0); in ov518_mode_init_regs()
3626 reg_w(sd, 0x3d, 0); in ov518_mode_init_regs()
3627 reg_w(sd, 0x3e, 0); in ov518_mode_init_regs()
3629 if (sd->bridge == BRIDGE_OV518) { in ov518_mode_init_regs()
3631 reg_w_mask(sd, 0x20, 0x08, 0x08); in ov518_mode_init_regs()
3634 reg_w_mask(sd, 0x28, 0x80, 0xf0); in ov518_mode_init_regs()
3635 reg_w_mask(sd, 0x38, 0x80, 0xf0); in ov518_mode_init_regs()
3637 reg_w(sd, 0x28, 0x80); in ov518_mode_init_regs()
3638 reg_w(sd, 0x38, 0x80); in ov518_mode_init_regs()
3641 hsegs = sd->gspca_dev.pixfmt.width / 16; in ov518_mode_init_regs()
3642 vsegs = sd->gspca_dev.pixfmt.height / 4; in ov518_mode_init_regs()
3644 reg_w(sd, 0x29, hsegs); in ov518_mode_init_regs()
3645 reg_w(sd, 0x2a, vsegs); in ov518_mode_init_regs()
3647 reg_w(sd, 0x39, hsegs); in ov518_mode_init_regs()
3648 reg_w(sd, 0x3a, vsegs); in ov518_mode_init_regs()
3651 reg_w(sd, 0x2f, 0x80); in ov518_mode_init_regs()
3654 if (sd->bridge == BRIDGE_OV518PLUS && sd->revision == 0 && in ov518_mode_init_regs()
3655 sd->sensor == SEN_OV7620AE) in ov518_mode_init_regs()
3656 sd->clockdiv = 0; in ov518_mode_init_regs()
3658 sd->clockdiv = 1; in ov518_mode_init_regs()
3662 reg_w(sd, 0x51, 0x04); in ov518_mode_init_regs()
3663 reg_w(sd, 0x22, 0x18); in ov518_mode_init_regs()
3664 reg_w(sd, 0x23, 0xff); in ov518_mode_init_regs()
3666 if (sd->bridge == BRIDGE_OV518PLUS) { in ov518_mode_init_regs()
3667 switch (sd->sensor) { in ov518_mode_init_regs()
3681 if (sd->revision > 0 && in ov518_mode_init_regs()
3682 sd->gspca_dev.pixfmt.width == 640) { in ov518_mode_init_regs()
3683 reg_w(sd, 0x20, 0x60); in ov518_mode_init_regs()
3684 reg_w(sd, 0x21, 0x1f); in ov518_mode_init_regs()
3686 reg_w(sd, 0x20, 0x00); in ov518_mode_init_regs()
3687 reg_w(sd, 0x21, 0x19); in ov518_mode_init_regs()
3691 reg_w(sd, 0x20, 0x00); in ov518_mode_init_regs()
3692 reg_w(sd, 0x21, 0x19); in ov518_mode_init_regs()
3695 reg_w(sd, 0x21, 0x19); in ov518_mode_init_regs()
3698 reg_w(sd, 0x71, 0x17); /* Compression-related? */ in ov518_mode_init_regs()
3702 i2c_w(sd, 0x54, 0x23); in ov518_mode_init_regs()
3704 reg_w(sd, 0x2f, 0x80); in ov518_mode_init_regs()
3706 if (sd->bridge == BRIDGE_OV518PLUS) { in ov518_mode_init_regs()
3707 reg_w(sd, 0x24, 0x94); in ov518_mode_init_regs()
3708 reg_w(sd, 0x25, 0x90); in ov518_mode_init_regs()
3709 ov518_reg_w32(sd, 0xc4, 400, 2); /* 190h */ in ov518_mode_init_regs()
3710 ov518_reg_w32(sd, 0xc6, 540, 2); /* 21ch */ in ov518_mode_init_regs()
3711 ov518_reg_w32(sd, 0xc7, 540, 2); /* 21ch */ in ov518_mode_init_regs()
3712 ov518_reg_w32(sd, 0xc8, 108, 2); /* 6ch */ in ov518_mode_init_regs()
3713 ov518_reg_w32(sd, 0xca, 131098, 3); /* 2001ah */ in ov518_mode_init_regs()
3714 ov518_reg_w32(sd, 0xcb, 532, 2); /* 214h */ in ov518_mode_init_regs()
3715 ov518_reg_w32(sd, 0xcc, 2400, 2); /* 960h */ in ov518_mode_init_regs()
3716 ov518_reg_w32(sd, 0xcd, 32, 2); /* 20h */ in ov518_mode_init_regs()
3717 ov518_reg_w32(sd, 0xce, 608, 2); /* 260h */ in ov518_mode_init_regs()
3719 reg_w(sd, 0x24, 0x9f); in ov518_mode_init_regs()
3720 reg_w(sd, 0x25, 0x90); in ov518_mode_init_regs()
3721 ov518_reg_w32(sd, 0xc4, 400, 2); /* 190h */ in ov518_mode_init_regs()
3722 ov518_reg_w32(sd, 0xc6, 381, 2); /* 17dh */ in ov518_mode_init_regs()
3723 ov518_reg_w32(sd, 0xc7, 381, 2); /* 17dh */ in ov518_mode_init_regs()
3724 ov518_reg_w32(sd, 0xc8, 128, 2); /* 80h */ in ov518_mode_init_regs()
3725 ov518_reg_w32(sd, 0xca, 183331, 3); /* 2cc23h */ in ov518_mode_init_regs()
3726 ov518_reg_w32(sd, 0xcb, 746, 2); /* 2eah */ in ov518_mode_init_regs()
3727 ov518_reg_w32(sd, 0xcc, 1750, 2); /* 6d6h */ in ov518_mode_init_regs()
3728 ov518_reg_w32(sd, 0xcd, 45, 2); /* 2dh */ in ov518_mode_init_regs()
3729 ov518_reg_w32(sd, 0xce, 851, 2); /* 353h */ in ov518_mode_init_regs()
3732 reg_w(sd, 0x2f, 0x80); in ov518_mode_init_regs()
3742 static void ov519_mode_init_regs(struct sd *sd) in ov519_mode_init_regs() argument
3788 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in ov519_mode_init_regs()
3791 switch (sd->sensor) { in ov519_mode_init_regs()
3793 write_regvals(sd, mode_init_519, ARRAY_SIZE(mode_init_519)); in ov519_mode_init_regs()
3794 if (sd->sensor == SEN_OV7640 || in ov519_mode_init_regs()
3795 sd->sensor == SEN_OV7648) { in ov519_mode_init_regs()
3797 reg_w_mask(sd, OV519_R20_DFR, 0x10, 0x10); in ov519_mode_init_regs()
3803 write_regvals(sd, mode_init_519_ov7670, in ov519_mode_init_regs()
3808 reg_w(sd, OV519_R10_H_SIZE, sd->gspca_dev.pixfmt.width >> 4); in ov519_mode_init_regs()
3809 reg_w(sd, OV519_R11_V_SIZE, sd->gspca_dev.pixfmt.height >> 3); in ov519_mode_init_regs()
3810 if (sd->sensor == SEN_OV7670 && in ov519_mode_init_regs()
3811 sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv) in ov519_mode_init_regs()
3812 reg_w(sd, OV519_R12_X_OFFSETL, 0x04); in ov519_mode_init_regs()
3813 else if (sd->sensor == SEN_OV7648 && in ov519_mode_init_regs()
3814 sd->gspca_dev.cam.cam_mode[sd->gspca_dev.curr_mode].priv) in ov519_mode_init_regs()
3815 reg_w(sd, OV519_R12_X_OFFSETL, 0x01); in ov519_mode_init_regs()
3817 reg_w(sd, OV519_R12_X_OFFSETL, 0x00); in ov519_mode_init_regs()
3818 reg_w(sd, OV519_R13_X_OFFSETH, 0x00); in ov519_mode_init_regs()
3819 reg_w(sd, OV519_R14_Y_OFFSETL, 0x00); in ov519_mode_init_regs()
3820 reg_w(sd, OV519_R15_Y_OFFSETH, 0x00); in ov519_mode_init_regs()
3821 reg_w(sd, OV519_R16_DIVIDER, 0x00); in ov519_mode_init_regs()
3822 reg_w(sd, OV519_R25_FORMAT, 0x03); /* YUV422 */ in ov519_mode_init_regs()
3823 reg_w(sd, 0x26, 0x00); /* Undocumented */ in ov519_mode_init_regs()
3827 sd->frame_rate = frame_rate; in ov519_mode_init_regs()
3830 sd->clockdiv = 0; in ov519_mode_init_regs()
3831 switch (sd->sensor) { in ov519_mode_init_regs()
3834 switch (sd->frame_rate) { in ov519_mode_init_regs()
3837 reg_w(sd, 0xa4, 0x0c); in ov519_mode_init_regs()
3838 reg_w(sd, 0x23, 0xff); in ov519_mode_init_regs()
3841 reg_w(sd, 0xa4, 0x0c); in ov519_mode_init_regs()
3842 reg_w(sd, 0x23, 0x1f); in ov519_mode_init_regs()
3845 reg_w(sd, 0xa4, 0x0c); in ov519_mode_init_regs()
3846 reg_w(sd, 0x23, 0x1b); in ov519_mode_init_regs()
3849 reg_w(sd, 0xa4, 0x04); in ov519_mode_init_regs()
3850 reg_w(sd, 0x23, 0xff); in ov519_mode_init_regs()
3851 sd->clockdiv = 1; in ov519_mode_init_regs()
3854 reg_w(sd, 0xa4, 0x04); in ov519_mode_init_regs()
3855 reg_w(sd, 0x23, 0x1f); in ov519_mode_init_regs()
3856 sd->clockdiv = 1; in ov519_mode_init_regs()
3859 reg_w(sd, 0xa4, 0x04); in ov519_mode_init_regs()
3860 reg_w(sd, 0x23, 0x1b); in ov519_mode_init_regs()
3861 sd->clockdiv = 1; in ov519_mode_init_regs()
3866 switch (sd->frame_rate) { in ov519_mode_init_regs()
3869 reg_w(sd, 0xa4, 0x06); in ov519_mode_init_regs()
3870 reg_w(sd, 0x23, 0xff); in ov519_mode_init_regs()
3873 reg_w(sd, 0xa4, 0x06); in ov519_mode_init_regs()
3874 reg_w(sd, 0x23, 0x1f); in ov519_mode_init_regs()
3877 reg_w(sd, 0xa4, 0x06); in ov519_mode_init_regs()
3878 reg_w(sd, 0x23, 0x1b); in ov519_mode_init_regs()
3884 (sd->frame_rate == 0) ? 15 : sd->frame_rate); in ov519_mode_init_regs()
3885 reg_w(sd, 0xa4, 0x10); in ov519_mode_init_regs()
3886 switch (sd->frame_rate) { in ov519_mode_init_regs()
3888 reg_w(sd, 0x23, 0xff); in ov519_mode_init_regs()
3891 reg_w(sd, 0x23, 0x1b); in ov519_mode_init_regs()
3895 reg_w(sd, 0x23, 0xff); in ov519_mode_init_regs()
3896 sd->clockdiv = 1; in ov519_mode_init_regs()
3903 static void mode_init_ov_sensor_regs(struct sd *sd) in mode_init_ov_sensor_regs() argument
3905 struct gspca_dev *gspca_dev = (struct gspca_dev *)sd; in mode_init_ov_sensor_regs()
3912 switch (sd->sensor) { in mode_init_ov_sensor_regs()
3914 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
3915 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); in mode_init_ov_sensor_regs()
3916 i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); in mode_init_ov_sensor_regs()
3917 i2c_w(sd, 0x25, qvga ? 0x30 : 0x60); in mode_init_ov_sensor_regs()
3918 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); in mode_init_ov_sensor_regs()
3919 i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); in mode_init_ov_sensor_regs()
3920 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
3931 if (sd->frame_rate < 25) in mode_init_ov_sensor_regs()
3934 if (sd->frame_rate < 10) in mode_init_ov_sensor_regs()
3937 i2c_w(sd, 0x11, v); in mode_init_ov_sensor_regs()
3938 i2c_w(sd, 0x12, qvga ? 0x60 : 0x20); in mode_init_ov_sensor_regs()
3955 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0xf0); in mode_init_ov_sensor_regs()
3956 i2c_w_mask(sd, 0x32, in mode_init_ov_sensor_regs()
3959 i2c_w_mask(sd, 0x03, in mode_init_ov_sensor_regs()
3962 i2c_w(sd, 0x17, xstart >> 4); in mode_init_ov_sensor_regs()
3963 i2c_w(sd, 0x18, xend >> 4); in mode_init_ov_sensor_regs()
3964 i2c_w(sd, 0x19, ystart >> 3); in mode_init_ov_sensor_regs()
3965 i2c_w(sd, 0x1a, yend >> 3); in mode_init_ov_sensor_regs()
3969 i2c_w_mask(sd, OV7610_REG_COM_C, qvga ? (1 << 5) : 0, 1 << 5); in mode_init_ov_sensor_regs()
3970 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ in mode_init_ov_sensor_regs()
3971 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ in mode_init_ov_sensor_regs()
3972 i2c_w_mask(sd, 0x2d, 0x00, 0x40); /* from windrv 090403 */ in mode_init_ov_sensor_regs()
3973 i2c_w_mask(sd, 0x28, 0x20, 0x20); /* progressive mode on */ in mode_init_ov_sensor_regs()
3976 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
3977 i2c_w(sd, 0x35, qvga ? 0x1e : 0x9e); in mode_init_ov_sensor_regs()
3978 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ in mode_init_ov_sensor_regs()
3979 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ in mode_init_ov_sensor_regs()
3984 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
3985 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); in mode_init_ov_sensor_regs()
3986 i2c_w(sd, 0x24, qvga ? 0x20 : 0x3a); in mode_init_ov_sensor_regs()
3987 i2c_w(sd, 0x25, qvga ? 0x30 : 0x60); in mode_init_ov_sensor_regs()
3988 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); in mode_init_ov_sensor_regs()
3989 i2c_w_mask(sd, 0x67, qvga ? 0xb0 : 0x90, 0xf0); in mode_init_ov_sensor_regs()
3990 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
3991 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ in mode_init_ov_sensor_regs()
3992 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ in mode_init_ov_sensor_regs()
3993 if (sd->sensor == SEN_OV76BE) in mode_init_ov_sensor_regs()
3994 i2c_w(sd, 0x35, qvga ? 0x1e : 0x9e); in mode_init_ov_sensor_regs()
3998 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
3999 i2c_w_mask(sd, 0x28, qvga ? 0x00 : 0x20, 0x20); in mode_init_ov_sensor_regs()
4002 i2c_w_mask(sd, 0x2d, qvga ? 0x40 : 0x00, 0x40); in mode_init_ov_sensor_regs()
4004 i2c_w_mask(sd, 0x67, qvga ? 0xf0 : 0x90, 0xf0); in mode_init_ov_sensor_regs()
4006 i2c_w_mask(sd, 0x74, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
4007 i2c_w_mask(sd, 0x12, 0x04, 0x04); /* AWB: 1 */ in mode_init_ov_sensor_regs()
4013 i2c_w_mask(sd, OV7670_R12_COM7, in mode_init_ov_sensor_regs()
4016 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ in mode_init_ov_sensor_regs()
4017 i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_AWB, in mode_init_ov_sensor_regs()
4033 i2c_w(sd, OV7670_R17_HSTART, xstart >> 3); in mode_init_ov_sensor_regs()
4034 i2c_w(sd, OV7670_R18_HSTOP, xend >> 3); in mode_init_ov_sensor_regs()
4035 v = i2c_r(sd, OV7670_R32_HREF); in mode_init_ov_sensor_regs()
4039 i2c_w(sd, OV7670_R32_HREF, v); in mode_init_ov_sensor_regs()
4041 i2c_w(sd, OV7670_R19_VSTART, ystart >> 2); in mode_init_ov_sensor_regs()
4042 i2c_w(sd, OV7670_R1A_VSTOP, yend >> 2); in mode_init_ov_sensor_regs()
4043 v = i2c_r(sd, OV7670_R03_VREF); in mode_init_ov_sensor_regs()
4047 i2c_w(sd, OV7670_R03_VREF, v); in mode_init_ov_sensor_regs()
4050 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
4051 i2c_w_mask(sd, 0x13, 0x00, 0x20); /* Select 16 bit data bus */ in mode_init_ov_sensor_regs()
4052 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ in mode_init_ov_sensor_regs()
4056 i2c_w_mask(sd, 0x14, qvga ? 0x20 : 0x00, 0x20); in mode_init_ov_sensor_regs()
4057 i2c_w_mask(sd, 0x12, 0x04, 0x06); /* AWB: 1 Test pattern: 0 */ in mode_init_ov_sensor_regs()
4078 i2c_w_mask(sd, 0x12, qvga ? 0x40 : 0x00, 0x40); in mode_init_ov_sensor_regs()
4080 vals = sd->frame_rate < 30 ? vga_15 : vga_30; in mode_init_ov_sensor_regs()
4082 vals = sd->frame_rate < 15 ? sxga_7_5 : sxga_15; in mode_init_ov_sensor_regs()
4083 write_i2c_regvals(sd, vals, ARRAY_SIZE(sxga_15)); in mode_init_ov_sensor_regs()
4091 i2c_w(sd, 0x11, sd->clockdiv); in mode_init_ov_sensor_regs()
4097 struct sd *sd = (struct sd *) gspca_dev; in sethvflip() local
4099 if (sd->gspca_dev.streaming) in sethvflip()
4100 reg_w(sd, OV519_R51_RESET1, 0x0f); /* block stream */ in sethvflip()
4101 i2c_w_mask(sd, OV7670_R1E_MVFP, in sethvflip()
4104 if (sd->gspca_dev.streaming) in sethvflip()
4105 reg_w(sd, OV519_R51_RESET1, 0x00); /* restart stream */ in sethvflip()
4108 static void set_ov_sensor_window(struct sd *sd) in set_ov_sensor_window() argument
4115 switch (sd->sensor) { in set_ov_sensor_window()
4121 mode_init_ov_sensor_regs(sd); in set_ov_sensor_window()
4124 ov519_set_mode(sd); in set_ov_sensor_window()
4125 ov519_set_fr(sd); in set_ov_sensor_window()
4129 gspca_dev = &sd->gspca_dev; in set_ov_sensor_window()
4135 switch (sd->sensor) { in set_ov_sensor_window()
4155 if (sd->sensor == SEN_OV66308AF && qvga) in set_ov_sensor_window()
4181 switch (sd->sensor) { in set_ov_sensor_window()
4213 mode_init_ov_sensor_regs(sd); in set_ov_sensor_window()
4215 i2c_w(sd, 0x17, hwsbase); in set_ov_sensor_window()
4216 i2c_w(sd, 0x18, hwebase + (sd->sensor_width >> hwscale)); in set_ov_sensor_window()
4217 i2c_w(sd, 0x19, vwsbase); in set_ov_sensor_window()
4218 i2c_w(sd, 0x1a, vwebase + (sd->sensor_height >> vwscale)); in set_ov_sensor_window()
4224 struct sd *sd = (struct sd *) gspca_dev; in sd_start() local
4227 sd->sensor_width = sd->gspca_dev.pixfmt.width; in sd_start()
4228 sd->sensor_height = sd->gspca_dev.pixfmt.height; in sd_start()
4230 switch (sd->bridge) { in sd_start()
4233 ov511_mode_init_regs(sd); in sd_start()
4237 ov518_mode_init_regs(sd); in sd_start()
4240 ov519_mode_init_regs(sd); in sd_start()
4244 w9968cf_mode_init_regs(sd); in sd_start()
4248 set_ov_sensor_window(sd); in sd_start()
4252 sd->snapshot_needs_reset = 1; in sd_start()
4255 sd->first_frame = 3; in sd_start()
4257 ov51x_restart(sd); in sd_start()
4258 ov51x_led_control(sd, 1); in sd_start()
4264 struct sd *sd = (struct sd *) gspca_dev; in sd_stopN() local
4266 ov51x_stop(sd); in sd_stopN()
4267 ov51x_led_control(sd, 0); in sd_stopN()
4272 struct sd *sd = (struct sd *) gspca_dev; in sd_stop0() local
4274 if (!sd->gspca_dev.present) in sd_stop0()
4276 if (sd->bridge == BRIDGE_W9968CF) in sd_stop0()
4277 w9968cf_stop0(sd); in sd_stop0()
4281 if (sd->snapshot_pressed) { in sd_stop0()
4284 sd->snapshot_pressed = 0; in sd_stop0()
4287 if (sd->bridge == BRIDGE_OV519) in sd_stop0()
4288 reg_w(sd, OV519_R57_SNAPSHOT, 0x23); in sd_stop0()
4293 struct sd *sd = (struct sd *) gspca_dev; in ov51x_handle_button() local
4295 if (sd->snapshot_pressed != state) { in ov51x_handle_button()
4301 sd->snapshot_needs_reset = 1; in ov51x_handle_button()
4303 sd->snapshot_pressed = state; in ov51x_handle_button()
4308 switch (sd->bridge) { in ov51x_handle_button()
4313 sd->snapshot_needs_reset = 1; in ov51x_handle_button()
4323 struct sd *sd = (struct sd *) gspca_dev; in ov511_pkt_scan() local
4358 sd->packet_nr = 0; in ov511_pkt_scan()
4373 struct sd *sd = (struct sd *) gspca_dev; in ov518_pkt_scan() local
4381 sd->packet_nr = 0; in ov518_pkt_scan()
4390 if (sd->packet_nr == data[len]) in ov518_pkt_scan()
4391 sd->packet_nr++; in ov518_pkt_scan()
4395 else if (sd->packet_nr == 0 || data[len]) { in ov518_pkt_scan()
4397 (int)data[len], (int)sd->packet_nr); in ov518_pkt_scan()
4457 struct sd *sd = (struct sd *) gspca_dev; in ovfx2_pkt_scan() local
4465 if (sd->first_frame) { in ovfx2_pkt_scan()
4466 sd->first_frame--; in ovfx2_pkt_scan()
4468 sd->gspca_dev.pixfmt.width * in ovfx2_pkt_scan()
4469 sd->gspca_dev.pixfmt.height) in ovfx2_pkt_scan()
4481 struct sd *sd = (struct sd *) gspca_dev; in sd_pkt_scan() local
4483 switch (sd->bridge) { in sd_pkt_scan()
4508 struct sd *sd = (struct sd *) gspca_dev; in setbrightness() local
4526 switch (sd->sensor) { in setbrightness()
4535 i2c_w(sd, OV7610_REG_BRT, val); in setbrightness()
4539 i2c_w(sd, OV7610_REG_BRT, val); in setbrightness()
4542 write_i2c_regvals(sd, brit_7660[val], in setbrightness()
4548 i2c_w(sd, OV7670_R55_BRIGHT, ov7670_abs_to_sm(val)); in setbrightness()
4555 struct sd *sd = (struct sd *) gspca_dev; in setcontrast() local
4615 switch (sd->sensor) { in setcontrast()
4618 i2c_w(sd, OV7610_REG_CNT, val); in setcontrast()
4622 i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f); in setcontrast()
4630 i2c_w(sd, 0x64, ctab[val >> 5]); in setcontrast()
4641 i2c_w(sd, 0x64, ctab[val >> 4]); in setcontrast()
4645 write_i2c_regvals(sd, contrast_7660[val], in setcontrast()
4650 i2c_w(sd, OV7670_R56_CONTRAS, val >> 1); in setcontrast()
4657 struct sd *sd = (struct sd *) gspca_dev; in setexposure() local
4659 i2c_w(sd, 0x10, val); in setexposure()
4664 struct sd *sd = (struct sd *) gspca_dev; in setcolors() local
4678 switch (sd->sensor) { in setcolors()
4685 i2c_w(sd, OV7610_REG_SAT, val); in setcolors()
4693 i2c_w(sd, OV7610_REG_SAT, val); in setcolors()
4697 i2c_w(sd, OV7610_REG_SAT, val & 0xf0); in setcolors()
4700 write_i2c_regvals(sd, colors_7660[val], in setcolors()
4713 struct sd *sd = (struct sd *) gspca_dev; in setautobright() local
4715 i2c_w_mask(sd, 0x2d, val ? 0x10 : 0x00, 0x10); in setautobright()
4718 static void setfreq_i(struct sd *sd, s32 val) in setfreq_i() argument
4720 if (sd->sensor == SEN_OV7660 in setfreq_i()
4721 || sd->sensor == SEN_OV7670) { in setfreq_i()
4724 i2c_w_mask(sd, OV7670_R13_COM8, 0, OV7670_COM8_BFILT); in setfreq_i()
4727 i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_BFILT, in setfreq_i()
4729 i2c_w_mask(sd, OV7670_R3B_COM11, 0x08, 0x18); in setfreq_i()
4732 i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_BFILT, in setfreq_i()
4734 i2c_w_mask(sd, OV7670_R3B_COM11, 0x00, 0x18); in setfreq_i()
4737 i2c_w_mask(sd, OV7670_R13_COM8, OV7670_COM8_BFILT, in setfreq_i()
4739 i2c_w_mask(sd, OV7670_R3B_COM11, OV7670_COM11_HZAUTO, in setfreq_i()
4746 i2c_w_mask(sd, 0x2d, 0x00, 0x04); in setfreq_i()
4747 i2c_w_mask(sd, 0x2a, 0x00, 0x80); in setfreq_i()
4750 i2c_w_mask(sd, 0x2d, 0x04, 0x04); in setfreq_i()
4751 i2c_w_mask(sd, 0x2a, 0x80, 0x80); in setfreq_i()
4753 if (sd->sensor == SEN_OV6620 || in setfreq_i()
4754 sd->sensor == SEN_OV6630 || in setfreq_i()
4755 sd->sensor == SEN_OV66308AF) in setfreq_i()
4756 i2c_w(sd, 0x2b, 0x5e); in setfreq_i()
4758 i2c_w(sd, 0x2b, 0xac); in setfreq_i()
4761 i2c_w_mask(sd, 0x2d, 0x04, 0x04); in setfreq_i()
4762 if (sd->sensor == SEN_OV6620 || in setfreq_i()
4763 sd->sensor == SEN_OV6630 || in setfreq_i()
4764 sd->sensor == SEN_OV66308AF) { in setfreq_i()
4766 i2c_w_mask(sd, 0x2a, 0x80, 0x80); in setfreq_i()
4767 i2c_w(sd, 0x2b, 0xa8); in setfreq_i()
4770 i2c_w_mask(sd, 0x2a, 0x00, 0x80); in setfreq_i()
4779 struct sd *sd = (struct sd *) gspca_dev; in setfreq() local
4781 setfreq_i(sd, val); in setfreq()
4784 if (sd->bridge == BRIDGE_W9968CF) in setfreq()
4785 w9968cf_set_crop_window(sd); in setfreq()
4791 struct sd *sd = (struct sd *) gspca_dev; in sd_get_jcomp() local
4793 if (sd->bridge != BRIDGE_W9968CF) in sd_get_jcomp()
4797 jcomp->quality = v4l2_ctrl_g_ctrl(sd->jpegqual); in sd_get_jcomp()
4806 struct sd *sd = (struct sd *) gspca_dev; in sd_set_jcomp() local
4808 if (sd->bridge != BRIDGE_W9968CF) in sd_set_jcomp()
4811 v4l2_ctrl_s_ctrl(sd->jpegqual, jcomp->quality); in sd_set_jcomp()
4819 struct sd *sd = (struct sd *)gspca_dev; in sd_g_volatile_ctrl() local
4825 gspca_dev->exposure->val = i2c_r(sd, 0x10); in sd_g_volatile_ctrl()
4835 struct sd *sd = (struct sd *)gspca_dev; in sd_s_ctrl() local
4855 if (!ctrl->val && sd->brightness->is_new) in sd_s_ctrl()
4856 setbrightness(gspca_dev, sd->brightness->val); in sd_s_ctrl()
4862 sethvflip(gspca_dev, ctrl->val, sd->vflip->val); in sd_s_ctrl()
4883 struct sd *sd = (struct sd *)gspca_dev; in sd_init_controls() local
4888 if (valid_controls[sd->sensor].has_brightness) in sd_init_controls()
4889 sd->brightness = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4891 sd->sensor == SEN_OV7660 ? 6 : 255, 1, in sd_init_controls()
4892 sd->sensor == SEN_OV7660 ? 3 : 127); in sd_init_controls()
4893 if (valid_controls[sd->sensor].has_contrast) { in sd_init_controls()
4894 if (sd->sensor == SEN_OV7660) in sd_init_controls()
4900 (sd->sensor == SEN_OV6630 || in sd_init_controls()
4901 sd->sensor == SEN_OV66308AF) ? 200 : 127); in sd_init_controls()
4903 if (valid_controls[sd->sensor].has_sat) in sd_init_controls()
4906 sd->sensor == SEN_OV7660 ? 4 : 255, 1, in sd_init_controls()
4907 sd->sensor == SEN_OV7660 ? 2 : 127); in sd_init_controls()
4908 if (valid_controls[sd->sensor].has_exposure) in sd_init_controls()
4911 if (valid_controls[sd->sensor].has_hvflip) { in sd_init_controls()
4912 sd->hflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4914 sd->vflip = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4917 if (valid_controls[sd->sensor].has_autobright) in sd_init_controls()
4918 sd->autobright = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4920 if (valid_controls[sd->sensor].has_autogain) in sd_init_controls()
4923 if (valid_controls[sd->sensor].has_freq) { in sd_init_controls()
4924 if (sd->sensor == SEN_OV7670) in sd_init_controls()
4925 sd->freq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops, in sd_init_controls()
4930 sd->freq = v4l2_ctrl_new_std_menu(hdl, &sd_ctrl_ops, in sd_init_controls()
4934 if (sd->bridge == BRIDGE_W9968CF) in sd_init_controls()
4935 sd->jpegqual = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, in sd_init_controls()
4945 if (sd->autobright) in sd_init_controls()
4946 v4l2_ctrl_auto_cluster(2, &sd->autobright, 0, false); in sd_init_controls()
4947 if (sd->hflip) in sd_init_controls()
4948 v4l2_ctrl_cluster(2, &sd->hflip); in sd_init_controls()
5011 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd), in sd_probe()