static int s5k6aafx_set_frame_rate(struct v4l2_subdev *sd, struct v4l2_control *ctrl) { int err = 0; struct i2c_client *client = v4l2_get_subdevdata(sd); FUNC_ENTR(); switch(ctrl->value) { case 7: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_7fps, sizeof(s5k6aafx_vt_7fps) / sizeof(s5k6aafx_vt_7fps[0])); break; case 10: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_10fps, sizeof(s5k6aafx_vt_10fps) / sizeof(s5k6aafx_vt_10fps[0])); break; case 12: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_12fps, sizeof(s5k6aafx_vt_12fps) / sizeof(s5k6aafx_vt_12fps[0])); break; case 15: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_13fps, sizeof(s5k6aafx_vt_13fps) / sizeof(s5k6aafx_vt_13fps[0])); break; case 30: printk("frame rate is 30\n"); break; default: dev_err(&client->dev, "%s: no such framerate\n", __func__); break; } return 0; }
static int s5k6aafx_set_frame_rate(int value) { int err = 0; switch(value) { case 7: err = s5k6aafx_write_regs(s5k6aafx_vt_7fps, sizeof(s5k6aafx_vt_7fps) / sizeof(s5k6aafx_vt_7fps[0])); break; case 10: err = s5k6aafx_write_regs(s5k6aafx_vt_10fps, sizeof(s5k6aafx_vt_10fps) / sizeof(s5k6aafx_vt_10fps[0])); break; case 12: err = s5k6aafx_write_regs(s5k6aafx_vt_12fps, sizeof(s5k6aafx_vt_12fps) / sizeof(s5k6aafx_vt_12fps[0])); break; case 15: err = s5k6aafx_write_regs(s5k6aafx_vt_13fps, sizeof(s5k6aafx_vt_13fps) / sizeof(s5k6aafx_vt_13fps[0])); break; case 30: printk("frame rate is 30\n"); break; default: printk("%s: no such framerate\n", __func__); break; } return 0; }
static int s5k6aafx_set_flip(struct v4l2_subdev *sd, struct v4l2_control *ctrl) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct s5k6aafx_state *state = to_state(sd); int err = 0; FUNC_ENTR(); if(state->runmode != S5K6AAFX_RUNMODE_RUNNING) { return 0; } if(state->set_vhflip == 1) { err = s5k6aafx_write_regs(sd, s5k6aafx_vhflip_on, sizeof(s5k6aafx_vhflip_on) / sizeof(s5k6aafx_vhflip_on[0])); } else { err = s5k6aafx_write_regs(sd, s5k6aafx_vhflip_off, sizeof(s5k6aafx_vhflip_off) / sizeof(s5k6aafx_vhflip_off[0])); } return err; }
static int s5k6aafx_check_dataline_stop(struct v4l2_subdev *sd) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct s5k6aafx_state *state = to_state(sd); int err = -EINVAL; extern int s5k6aafx_power_reset(void); printk( "pattern off setting~~~~~~~~~~~~~~\n"); s5k6aafx_write(client, 0xFCFCD000); s5k6aafx_write(client, 0x0028D000); s5k6aafx_write(client, 0x002A3100); s5k6aafx_write(client, 0x0F120000); // err = s5k6aafx_write_regs(sd, s5k6aafx_pattern_off, sizeof(s5k6aafx_pattern_off) / sizeof(s5k6aafx_pattern_off[0])); printk("%s: sensor reset\n", __func__); #if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_EUR) || defined(CONFIG_TARGET_LOCALE_HKTW) || defined(CONFIG_TARGET_LOCALE_HKTW_FET) || defined(CONFIG_TARGET_LOCALE_USAGSM) // s5k6aafx_power_reset(); #endif printk("%s: load camera init setting \n", __func__); #ifdef CONFIG_VIDEO_S5K6AAFX_MIPI if (system_rev == 4) err = s5k6aafx_write_regs(sd, s5k6aafx_common_for_rev05, sizeof(s5k6aafx_common_for_rev05) / sizeof(s5k6aafx_common_for_rev05[0])); else #endif err = s5k6aafx_write_regs(sd, s5k6aafx_common, sizeof(s5k6aafx_common) / sizeof(s5k6aafx_common[0])); state->check_dataline = 0; // mdelay(100); return err; }
static int s5k6aafx_set_flip(int value) { int err = 0; if((value) == 1) { err = s5k6aafx_write_regs(s5k6aafx_vhflip_on, sizeof(s5k6aafx_vhflip_on) / sizeof(s5k6aafx_vhflip_on[0])); } else { err = s5k6aafx_write_regs(s5k6aafx_vhflip_off, sizeof(s5k6aafx_vhflip_off) / sizeof(s5k6aafx_vhflip_off[0])); } return err; }
static int s5k6aafx_check_dataline_stop() { struct i2c_client *client = s5k6aafx_client; int err = -EINVAL; extern int s5k6aafx_power_reset(void); printk( "pattern off setting~~~~~~~~~~~~~~\n"); s5k6aafx_write(client, 0xFCFCD000); s5k6aafx_write(client, 0x0028D000); s5k6aafx_write(client, 0x002A3100); s5k6aafx_write(client, 0x0F120000); // err = s5k6aafx_write_regs(sd, s5k6aafx_pattern_off, sizeof(s5k6aafx_pattern_off) / sizeof(s5k6aafx_pattern_off[0])); printk("%s: sensor reset\n", __func__); #if defined(CONFIG_TARGET_LOCALE_KOR) || defined(CONFIG_TARGET_LOCALE_EUR) || defined(CONFIG_TARGET_LOCALE_HKTW) || defined(CONFIG_TARGET_LOCALE_HKTW_FET) || defined(CONFIG_TARGET_LOCALE_USAGSM) s5k6aafx_power_reset(); #endif printk("%s: load camera init setting \n", __func__); err = s5k6aafx_write_regs(s5k6aafx_common, sizeof(s5k6aafx_common) / sizeof(s5k6aafx_common[0])); // mdelay(100); return err; }
//latin_cam VT CAM Antibanding static int s5k6aafx_set_60hz_antibanding() { // struct i2c_client *client = s5k6aafx_client; int err = -EINVAL; unsigned long s5k6aafx_antibanding60hz[] = { 0xFCFCD000, 0x00287000, // Anti-Flicker // // End user init script 0x002A0400, 0x0F12005F, //REG_TC_DBG_AutoAlgEnBits //Auto Anti-Flicker is enabled bit[5] = 1. 0x002A03DC, 0x0F120002, //02 REG_SF_USER_FlickerQuant //Set flicker quantization(0: no AFC, 1: 50Hz, 2: 60 Hz) 0x0F120001, }; err = s5k6aafx_write_regs(s5k6aafx_antibanding60hz, sizeof(s5k6aafx_antibanding60hz) / sizeof(s5k6aafx_antibanding60hz[0])); printk("%s: setting 60hz antibanding \n", __func__); if (unlikely(err)) { printk("%s: failed to set 60hz antibanding \n", __func__); return err; } return 0; }
int s5k6aafx_sensor_init_probe(const struct msm_camera_sensor_info *data) { // struct i2c_client *client = s5k6aafx_client; int err = 0; //int err = -EINVAL; /* set initial regster value */ if (s5k6aafx_ctrl->app_mode == CAMERA_MODE) { printk("%s: load camera common setting \n", __func__); err = s5k6aafx_write_regs(s5k6aafx_common, sizeof(s5k6aafx_common) / sizeof(s5k6aafx_common[0])); } else { printk("%s: load camera VT call setting \n", __func__); err = s5k6aafx_write_regs(s5k6aafx_vt_common, sizeof(s5k6aafx_vt_common) / sizeof(s5k6aafx_vt_common[0])); } if (unlikely(err)) { printk("%s: failed to init\n", __func__); return err; } /* #if defined(CONFIG_TARGET_LOCALE_LTN) //latin_cam VT Cam Antibanding if (state->anti_banding == ANTI_BANDING_60HZ) { err = s5k6aafx_set_60hz_antibanding(sd); if (unlikely(err)) { printk("%s: failed to s5k6aafx_set_60hz_antibanding \n", __func__); return err; } } //hmin84.park -10.07.06 #endif */ cam_gpio_print(4); return err; }
static int s5k6aafx_set_blur(int value) { // struct i2c_client *client = s5k6aafx_client; int err = -EINVAL; switch (value) { // case BLUR_LEVEL_0: case 0 : err = s5k6aafx_write_regs(s5k6aafx_vt_pretty_default, \ sizeof(s5k6aafx_vt_pretty_default) / sizeof(s5k6aafx_vt_pretty_default[0])); break; // case BLUR_LEVEL_1: case 1 : err = s5k6aafx_write_regs(s5k6aafx_vt_pretty_1, \ sizeof(s5k6aafx_vt_pretty_1) / sizeof(s5k6aafx_vt_pretty_1[0])); break; // case BLUR_LEVEL_2: case 2 : err = s5k6aafx_write_regs(s5k6aafx_vt_pretty_2, \ sizeof(s5k6aafx_vt_pretty_2) / sizeof(s5k6aafx_vt_pretty_2[0])); break; // case BLUR_LEVEL_3: // case BLUR_LEVEL_MAX: case 4 : err = s5k6aafx_write_regs(s5k6aafx_vt_pretty_3, \ sizeof(s5k6aafx_vt_pretty_3) / sizeof(s5k6aafx_vt_pretty_3[0])); break; default: printk("%s : there's no blur value with [%d]\n", __func__,value); return err; break; } if (err < 0) { printk("%s : i2c_write for set blur\n", __func__); return -EIO; } return err; }
static int s5k6aafx_set_brightness(int value) { // struct i2c_client *client = s5k6aafx_client; int err = -EINVAL; switch (value) { //case EV_MINUS_4: case 0 : err = s5k6aafx_write_regs(s5k6aafx_bright_m4, \ sizeof(s5k6aafx_bright_m4) / sizeof(s5k6aafx_bright_m4[0])); break; // case EV_MINUS_3: case 1 : err = s5k6aafx_write_regs(s5k6aafx_bright_m3, \ sizeof(s5k6aafx_bright_m3) / sizeof(s5k6aafx_bright_m3[0])); break; // case EV_MINUS_2: case 2 : err = s5k6aafx_write_regs(s5k6aafx_bright_m2, \ sizeof(s5k6aafx_bright_m2) / sizeof(s5k6aafx_bright_m2[0])); break; // case EV_MINUS_1: case 3 : err = s5k6aafx_write_regs(s5k6aafx_bright_m1, \ sizeof(s5k6aafx_bright_m1) / sizeof(s5k6aafx_bright_m1[0])); break; // case EV_DEFAULT: case 4 : err = s5k6aafx_write_regs(s5k6aafx_bright_default, \ sizeof(s5k6aafx_bright_default) / sizeof(s5k6aafx_bright_default[0])); break; // case EV_PLUS_1: case 5: err = s5k6aafx_write_regs(s5k6aafx_bright_p1, \ sizeof(s5k6aafx_bright_p1) / sizeof(s5k6aafx_bright_p1[0])); break; // case EV_PLUS_2: case 6 : err = s5k6aafx_write_regs(s5k6aafx_bright_p2, \ sizeof(s5k6aafx_bright_p2) / sizeof(s5k6aafx_bright_p2[0])); break; // case EV_PLUS_3: case 7: err = s5k6aafx_write_regs(s5k6aafx_bright_p3, \ sizeof(s5k6aafx_bright_p3) / sizeof(s5k6aafx_bright_p3[0])); break; // case EV_PLUS_4: case 8 : err = s5k6aafx_write_regs(s5k6aafx_bright_p4, \ sizeof(s5k6aafx_bright_p4) / sizeof(s5k6aafx_bright_p4[0])); break; default: printk("%s : there's no brightness value with [%d]\n", __func__,value); return err; break; } if (err < 0) { printk("%s : i2c_write for set brightness\n", __func__); return -EIO; } return err; }
static inline int s5k6aafx_write(struct i2c_client *client, unsigned long packet) { unsigned char buf[4]; int err = 0; int retry_count = 5; struct i2c_msg msg = { .addr = client->addr, .flags = 0, .buf = buf, .len = 4, }; // printk("%s: %d Start 1 \n", __func__, __LINE__); if (!client->adapter) { dev_err(&client->dev, "%s: can't search i2c client adapter\n", __func__); return -EIO; } while(retry_count--) { *(unsigned long *)buf = cpu_to_be32(packet); err = i2c_transfer(client->adapter, &msg, 1); if (likely(err == 1)) { // printk("%s: %d Start 2 \n", __func__, __LINE__); break; } mdelay(10); // printk("%s: %d Start 3 \n", __func__, __LINE__); } if (unlikely(err < 0)) { dev_err(&client->dev, "%s: 0x%08x write failed\n", __func__, (unsigned int)packet); return err; } // printk("%s: %d Start 4 %d \n", __func__, __LINE__,err); return (err != 1) ? -1 : 0; } /* program multiple registers */ static int s5k6aafx_write_regs( unsigned long *packet, unsigned int num) { struct i2c_client *client = s5k6aafx_client; int ret = -EAGAIN; /* FIXME */ unsigned long temp; char delay = 0; while (num--) { temp = *packet++; /* if ((temp & S5K6AAFX_DELAY) == S5K6AAFX_DELAY) { if (temp & 0x1) { dev_info(&client->dev, "delay for 100msec\n"); msleep(100); continue; } else { dev_info(&client->dev, "delay for 10msec\n"); msleep(10); continue; } } */ #if 1 if ((temp & S5K6AAFX_DELAY) == S5K6AAFX_DELAY) { delay = temp & 0xFFFF; //printk("func(%s):line(%d):delay(0x%x):delay(%d)\n",__func__,__LINE__,delay,delay); msleep(delay); continue; } #endif ret = s5k6aafx_write(client, temp); /* In error circumstances */ /* Give second shot */ if (unlikely(ret)) { dev_info(&client->dev, "s5k6aafx i2c retry one more time\n"); ret = s5k6aafx_write(client, temp); /* Give it one more shot */ if (unlikely(ret)) { dev_info(&client->dev, "s5k6aafx i2c retry twice\n"); ret = s5k6aafx_write(client, temp); break; } } } dev_info(&client->dev, "S5K6AAFX register programming ends up\n"); if( ret < 0) return -EIO; return ret; /* FIXME */ } static int s5k6aafx_set_capture_start() { struct i2c_client *client = s5k6aafx_client; int err = -EINVAL; unsigned short lvalue = 0; s5k6aafx_write(client, 0x002C7000); s5k6aafx_write(client, 0x002E1AAA); //read light value s5k6aafx_read(client, 0x0F12, &lvalue); printk("%s : light value is %x\n", __func__, lvalue); /* set initial regster value */ err = s5k6aafx_write_regs(s5k6aafx_capture, sizeof(s5k6aafx_capture) / sizeof(s5k6aafx_capture[0])); if (lvalue < 0x40) { printk("\n----- low light -----\n\n"); mdelay(100);//add 100 ms delay for capture sequence } else { printk("\n----- normal light -----\n\n"); mdelay(50); } if (unlikely(err)) { printk("%s: failed to make capture\n", __func__); return err; } return err; } static int s5k6aafx_set_preview_start() { // struct i2c_client *client = s5k6aafx_client; int err = -EINVAL; printk("%s: set_Preview_start\n", __func__); #if 0 if(state->check_dataline) // Output Test Pattern from VGA sensor { printk(" pattern on setting~~~~~~~~~~~\n"); err = s5k6aafx_write_regs(sd, s5k6aafx_pattern_on, sizeof(s5k6aafx_pattern_on) / sizeof(s5k6aafx_pattern_on[0])); // mdelay(200); } else { #endif /* set initial regster value */ err = s5k6aafx_write_regs(s5k6aafx_preview, sizeof(s5k6aafx_preview) / sizeof(s5k6aafx_preview[0])); if (unlikely(err)) { printk("%s: failed to make preview\n", __func__); return err; } // } // mdelay(200); // add 200 ms for displaying preview return err; } static int s5k6aafx_set_preview_stop() { int err = 0; return err; }
static int s5k6aafx_set_blur(struct v4l2_subdev *sd, struct v4l2_control *ctrl) { struct i2c_client *client = v4l2_get_subdevdata(sd); int err = -EINVAL; FUNC_ENTR(); #ifdef CONFIG_LOAD_FILE switch (ctrl->value) { case BLUR_LEVEL_0: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_pretty_default"); break; case BLUR_LEVEL_1: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_pretty_1"); break; case BLUR_LEVEL_2: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_pretty_2"); break; case BLUR_LEVEL_3: case BLUR_LEVEL_MAX: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_pretty_3"); break; default: dev_err(&client->dev, "%s : there's no blur value with [%d]\n", __func__,ctrl->value); return err; break; } #else switch (ctrl->value) { case BLUR_LEVEL_0: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_pretty_default, \ sizeof(s5k6aafx_vt_pretty_default) / sizeof(s5k6aafx_vt_pretty_default[0])); break; case BLUR_LEVEL_1: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_pretty_1, \ sizeof(s5k6aafx_vt_pretty_1) / sizeof(s5k6aafx_vt_pretty_1[0])); break; case BLUR_LEVEL_2: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_pretty_2, \ sizeof(s5k6aafx_vt_pretty_2) / sizeof(s5k6aafx_vt_pretty_2[0])); break; case BLUR_LEVEL_3: case BLUR_LEVEL_MAX: err = s5k6aafx_write_regs(sd, s5k6aafx_vt_pretty_3, \ sizeof(s5k6aafx_vt_pretty_3) / sizeof(s5k6aafx_vt_pretty_3[0])); break; default: dev_err(&client->dev, "%s : there's no blur value with [%d]\n", __func__,ctrl->value); return err; break; } #endif if (err < 0) { dev_err(&client->dev, "%s : i2c_write for set blur\n", __func__); return -EIO; } return err; }
static int s5k6aafx_set_brightness(struct v4l2_subdev *sd, struct v4l2_control *ctrl) { struct i2c_client *client = v4l2_get_subdevdata(sd); int err = -EINVAL; FUNC_ENTR(); #ifdef CONFIG_LOAD_FILE switch (ctrl->value) { case EV_MINUS_4: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_m4"); break; case EV_MINUS_3: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_m3"); break; case EV_MINUS_2: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_m2"); break; case EV_MINUS_1: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_m1"); break; case EV_DEFAULT: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_default"); break; case EV_PLUS_1: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_p1"); break; case EV_PLUS_2: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_p2"); break; case EV_PLUS_3: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_p3"); break; case EV_PLUS_4: err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_bright_p4"); break; default: dev_err(&client->dev, "%s : there's no brightness value with [%d]\n", __func__,ctrl->value); return err; break; } #else switch (ctrl->value) { case EV_MINUS_4: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_m4, \ sizeof(s5k6aafx_bright_m4) / sizeof(s5k6aafx_bright_m4[0])); break; case EV_MINUS_3: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_m3, \ sizeof(s5k6aafx_bright_m3) / sizeof(s5k6aafx_bright_m3[0])); break; case EV_MINUS_2: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_m2, \ sizeof(s5k6aafx_bright_m2) / sizeof(s5k6aafx_bright_m2[0])); break; case EV_MINUS_1: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_m1, \ sizeof(s5k6aafx_bright_m1) / sizeof(s5k6aafx_bright_m1[0])); break; case EV_DEFAULT: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_default, \ sizeof(s5k6aafx_bright_default) / sizeof(s5k6aafx_bright_default[0])); break; case EV_PLUS_1: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_p1, \ sizeof(s5k6aafx_bright_p1) / sizeof(s5k6aafx_bright_p1[0])); break; case EV_PLUS_2: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_p2, \ sizeof(s5k6aafx_bright_p2) / sizeof(s5k6aafx_bright_p2[0])); break; case EV_PLUS_3: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_p3, \ sizeof(s5k6aafx_bright_p3) / sizeof(s5k6aafx_bright_p3[0])); break; case EV_PLUS_4: err = s5k6aafx_write_regs(sd, s5k6aafx_bright_p4, \ sizeof(s5k6aafx_bright_p4) / sizeof(s5k6aafx_bright_p4[0])); break; default: dev_err(&client->dev, "%s : there's no brightness value with [%d]\n", __func__,ctrl->value); return err; break; } #endif if (err < 0) { dev_err(&client->dev, "%s : i2c_write for set brightness\n", __func__); return -EIO; } return err; }
static int s5k6aafx_init(struct v4l2_subdev *sd, u32 val) { //struct i2c_client *client = v4l2_get_subdevdata(sd); struct s5k6aafx_state *state = to_state(sd); int err = -EINVAL; FUNC_ENTR(); #ifdef CONFIG_LOAD_FILE err = loadFile(); if (unlikely(err)) { printk("%s: failed to init\n", __func__); return err; } #endif /* set initial regster value */ if (state->vt_mode == 0) { printk("%s: load camera common setting \n", __func__); #ifdef CONFIG_LOAD_FILE err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_common"); #else err = s5k6aafx_write_regs(sd, s5k6aafx_common, sizeof(s5k6aafx_common) / sizeof(s5k6aafx_common[0])); #endif } else { printk("%s: load camera VT call setting \n", __func__); #ifdef CONFIG_LOAD_FILE err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_common"); #else err = s5k6aafx_write_regs(sd, s5k6aafx_vt_common, sizeof(s5k6aafx_vt_common) / sizeof(s5k6aafx_vt_common[0])); #endif } if (unlikely(err)) { printk("%s: failed to init\n", __func__); return err; } #if defined(CONFIG_TARGET_LOCALE_LTN) //latin_cam VT Cam Antibanding if (state->anti_banding == ANTI_BANDING_60HZ) { err = s5k6aafx_set_60hz_antibanding(sd); if (unlikely(err)) { printk("%s: failed to s5k6aafx_set_60hz_antibanding \n", __func__); return err; } } //hmin84.park -10.07.06 #endif state->set_fmt.width = DEFAULT_WIDTH; state->set_fmt.height = DEFAULT_HEIGHT; return 0; }
static inline int s5k6aafx_write(struct i2c_client *client, unsigned long packet) { unsigned char buf[4]; int err = 0; int retry_count = 5; struct i2c_msg msg = { .addr = client->addr, .flags = 0, .buf = buf, .len = 4, }; if (!client->adapter) { dev_err(&client->dev, "%s: can't search i2c client adapter\n", __func__); return -EIO; } while(retry_count--) { *(unsigned long *)buf = cpu_to_be32(packet); err = i2c_transfer(client->adapter, &msg, 1); if (likely(err == 1)) break; mdelay(10); } if (unlikely(err < 0)) { dev_err(&client->dev, "%s: 0x%08x write failed\n", __func__, (unsigned int)packet); return err; } return (err != 1) ? -1 : 0; } #ifdef CONFIG_LOAD_FILE static int s5k6aafx_write_regs_from_sd(struct v4l2_subdev *sd, char s_name[]) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct test *tempData; int ret = -EAGAIN; unsigned long temp; char delay = 0; char data[11]; int searched = 0; int size = strlen(s_name); int i; FUNC_ENTR(); printk("size = %d, string = %s\n", size, s_name); tempData = &testBuf[0]; while(!searched) { searched = 1; for (i = 0; i < size; i++) { if (tempData->data != s_name[i]) { searched = 0; break; } tempData = tempData->nextBuf; } tempData = tempData->nextBuf; } //structure is get.. while(1) { if (tempData->data == '{') { break; } else { tempData = tempData->nextBuf; } } while (1) { searched = 0; while (1) { if (tempData->data == 'x') { //get 10 strings data[0] = '0'; for (i = 1; i < 11; i++) { data[i] = tempData->data; tempData = tempData->nextBuf; } //printk("%s\n", data); temp = simple_strtoul(data, NULL, 16); break; } else if (tempData->data == '}') { searched = 1; break; } else { tempData = tempData->nextBuf; } if (tempData->nextBuf == NULL) { return -1; } } if (searched) { break; } //let search... if ((temp & S5K6AAFX_DELAY) == S5K6AAFX_DELAY) { delay = temp & 0xFFFF; //printk("func(%s):line(%d):delay(0x%x):delay(%d)\n",__func__,__LINE__,delay,delay); msleep(delay); continue; } ret = s5k6aafx_write(client, temp); /* In error circumstances */ /* Give second shot */ if (unlikely(ret)) { dev_info(&client->dev, "s5k6aafx i2c retry one more time\n"); ret = s5k6aafx_write(client, temp); /* Give it one more shot */ if (unlikely(ret)) { dev_info(&client->dev, "s5k6aafx i2c retry twice\n"); ret = s5k6aafx_write(client, temp); } } } return ret; } #endif /* program multiple registers */ static int s5k6aafx_write_regs(struct v4l2_subdev *sd, unsigned long *packet, unsigned int num) { struct i2c_client *client = v4l2_get_subdevdata(sd); int ret = -EAGAIN; /* FIXME */ unsigned long temp; char delay = 0; while (num--) { temp = *packet++; /* if ((temp & S5K6AAFX_DELAY) == S5K6AAFX_DELAY) { if (temp & 0x1) { dev_info(&client->dev, "delay for 100msec\n"); msleep(100); continue; } else { dev_info(&client->dev, "delay for 10msec\n"); msleep(10); continue; } } */ #if 1 if ((temp & S5K6AAFX_DELAY) == S5K6AAFX_DELAY) { delay = temp & 0xFFFF; //printk("func(%s):line(%d):delay(0x%x):delay(%d)\n",__func__,__LINE__,delay,delay); msleep(delay); continue; } #endif ret = s5k6aafx_write(client, temp); /* In error circumstances */ /* Give second shot */ if (unlikely(ret)) { dev_info(&client->dev, "s5k6aafx i2c retry one more time\n"); ret = s5k6aafx_write(client, temp); /* Give it one more shot */ if (unlikely(ret)) { dev_info(&client->dev, "s5k6aafx i2c retry twice\n"); ret = s5k6aafx_write(client, temp); break; } } } dev_info(&client->dev, "S5K6AAFX register programming ends up\n"); if( ret < 0) return -EIO; return ret; /* FIXME */ } static int s5k6aafx_set_capture_start(struct v4l2_subdev *sd, struct v4l2_control *ctrl) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct s5k6aafx_state *state = to_state(sd); int err = -EINVAL; unsigned short lvalue = 0; FUNC_ENTR(); s5k6aafx_write(client, 0x002C7000); s5k6aafx_write(client, 0x002E1AAA); //read light value s5k6aafx_read(client, 0x0F12, &lvalue); printk("%s : light value is %x\n", __func__, lvalue); /* set initial regster value */ #ifdef CONFIG_LOAD_FILE err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_capture"); #else err = s5k6aafx_write_regs(sd, s5k6aafx_capture, sizeof(s5k6aafx_capture) / sizeof(s5k6aafx_capture[0])); #endif if (lvalue < 0x40) { printk("\n----- low light -----\n\n"); mdelay(100);//add 100 ms delay for capture sequence } else { printk("\n----- normal light -----\n\n"); mdelay(50); } if (unlikely(err)) { printk("%s: failed to make capture\n", __func__); return err; } state->runmode = S5K6AAFX_RUNMODE_IDLE; return err; } static int s5k6aafx_set_preview_start(struct v4l2_subdev *sd) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct s5k6aafx_state *state = to_state(sd); int err = -EINVAL; FUNC_ENTR(); dev_info(&client->dev, "%s: set_Preview_start\n", __func__); if(state->check_dataline) // Output Test Pattern from VGA sensor { printk(" pattern on setting~~~~~~~~~~~\n"); err = s5k6aafx_write_regs(sd, s5k6aafx_pattern_on, sizeof(s5k6aafx_pattern_on) / sizeof(s5k6aafx_pattern_on[0])); // mdelay(200); } else { /* set initial regster value */ #ifdef CONFIG_LOAD_FILE err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_preview"); #else err = s5k6aafx_write_regs(sd, s5k6aafx_preview, sizeof(s5k6aafx_preview) / sizeof(s5k6aafx_preview[0])); #endif if (unlikely(err)) { printk("%s: failed to make preview\n", __func__); return err; } } if(state->set_vhflip == 1) { err = s5k6aafx_write_regs(sd, s5k6aafx_vhflip_on, sizeof(s5k6aafx_vhflip_on) / sizeof(s5k6aafx_vhflip_on[0])); } state->runmode = S5K6AAFX_RUNMODE_RUNNING; // mdelay(200); // add 200 ms for displaying preview return err; } static int s5k6aafx_set_preview_stop(struct v4l2_subdev *sd) { struct s5k6aafx_state *state = to_state(sd); int err = 0; state->runmode = S5K6AAFX_RUNMODE_IDLE; return err; } #if 0 static int s5k6aafx_s_crystal_freq(struct v4l2_subdev *sd, u32 freq, u32 flags) { int err = -EINVAL; FUNC_ENTR(); return err; }
static int s5k6aafx_init(struct v4l2_subdev *sd, u32 val) { //struct i2c_client *client = v4l2_get_subdevdata(sd); struct s5k6aafx_state *state = to_state(sd); int err = -EINVAL; static int lock_level = -1; FUNC_ENTR(); #ifdef CONFIG_LOAD_FILE err = loadFile(); if (unlikely(err)) { printk("%s: failed to init\n", __func__); return err; } #endif #if defined(CONFIG_CPU_FREQ) if (lock_level < 0) lock_level = s5pv310_cpufreq_round_idx(CPUFREQ_1200MHZ); if (s5pv310_cpufreq_lock(DVFS_LOCK_ID_CAM, lock_level)) printk(KERN_ERR "%s: error : failed lock DVFS\n", __func__); #endif /* set initial regster value */ if (state->vt_mode == 0) { printk("%s: load camera common setting \n", __func__); #ifdef CONFIG_LOAD_FILE err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_common"); #else err = s5k6aafx_write_regs(sd, s5k6aafx_common, sizeof(s5k6aafx_common) / sizeof(s5k6aafx_common[0])); #endif } else { printk("%s: load camera VT call setting \n", __func__); #ifdef CONFIG_LOAD_FILE err = s5k6aafx_write_regs_from_sd(sd, "s5k6aafx_vt_common"); #else err = s5k6aafx_write_regs(sd, s5k6aafx_vt_common, sizeof(s5k6aafx_vt_common) / sizeof(s5k6aafx_vt_common[0])); #endif } #if defined(CONFIG_CPU_FREQ) s5pv310_cpufreq_lock_free(DVFS_LOCK_ID_CAM); #endif if (unlikely(err)) { printk("%s: failed to init\n", __func__); return err; } #if defined(CONFIG_TARGET_LOCALE_LTN) //latin_cam VT Cam Antibanding if (state->anti_banding == ANTI_BANDING_60HZ) { err = s5k6aafx_set_60hz_antibanding(sd); if (unlikely(err)) { printk("%s: failed to s5k6aafx_set_60hz_antibanding \n", __func__); return err; } } //hmin84.park -10.07.06 #endif state->set_fmt.width = DEFAULT_WIDTH; state->set_fmt.height = DEFAULT_HEIGHT; return 0; }