LOCAL uint32_t SP0A19_Power_On(uint32_t power_on) { SENSOR_AVDD_VAL_E dvdd_val=g_SP0A19_yuv_info.dvdd_val; SENSOR_AVDD_VAL_E avdd_val=g_SP0A19_yuv_info.avdd_val; SENSOR_AVDD_VAL_E iovdd_val=g_SP0A19_yuv_info.iovdd_val; BOOLEAN power_down=g_SP0A19_yuv_info.power_down_level; BOOLEAN reset_level=g_SP0A19_yuv_info.reset_pulse_level; uint32_t reset_width=g_SP0A19_yuv_info.reset_pulse_width; if(SENSOR_TRUE==power_on) { Sensor_PowerDown(power_down); // Open power Sensor_SetVoltage(dvdd_val, avdd_val, iovdd_val); //Sensor_SetMonitorVoltage(SENSOR_AVDD_2800MV); SENSOR_Sleep(50); Sensor_SetMCLK(SENSOR_DEFALUT_MCLK); SENSOR_Sleep(20); Sensor_PowerDown(!power_down); // Reset sensor Sensor_Reset(reset_level); } else { Sensor_SetVoltage(dvdd_val, avdd_val, iovdd_val); SENSOR_Sleep(20); Sensor_PowerDown(power_down); SENSOR_Sleep(20); Sensor_SetMCLK(SENSOR_DISABLE_MCLK); Sensor_SetVoltage(SENSOR_AVDD_CLOSED, SENSOR_AVDD_CLOSED, SENSOR_AVDD_CLOSED); //Sensor_SetMonitorVoltage(SENSOR_AVDD_CLOSED); } return SENSOR_SUCCESS; }
LOCAL uint32_t GC0328_BeforeSnapshot(uint32_t param) { uint16_t shutter = 0x00; uint16_t temp_reg = 0x00; uint16_t temp_r =0x00; uint16_t temp_g =0x00; uint16_t temp_b =0x00; BOOLEAN b_AEC_on; SENSOR_TRACE("GC0328_BeforeSnapshot "); printk("SENSOR: set flash on beforeSnapShot, g_flash_mode = %d \n", g_flash_mode_en); if (g_flash_mode_en) { //Sensor_SetFlash(0x11); // high light Sensor_SetFlash(1); } #if 0 if(GC0328_ReadReg(0X41) & 0x08 == 0x08) //AEC on b_AEC_on = SENSOR_TRUE; else b_AEC_on = SENSOR_FALSE; temp_reg = GC0328_ReadReg(0xdb); temp_r = GC0328_ReadReg(0xcd); temp_g = GC0328_ReadReg(0xce); temp_b = GC0328_ReadReg(0xcf); shutter = (GC0328_ReadReg(0x03)<<8) | (GC0328_ReadReg(0x04)&0x00ff) ; shutter = shutter /2; if(b_AEC_on) GC0328_WriteReg(0x41,GC0328_ReadReg(0x41) & 0xc5); //0x01); SENSOR_Sleep(300); ///12m Sensor_SetMCLK(12); GC0328_WriteReg(0x03,shutter/256); GC0328_WriteReg(0x04,shutter & 0x00ff); //SENSOR_TRACE("GC0328_BeforeSnapshot, temp_r=%x,temp_reg=%x, final = %x ",temp_r,temp_reg, temp_r*temp_reg/ 0x80); temp_r = (temp_r*temp_reg) / 0x80; temp_g = (temp_g*temp_reg) / 0x80; temp_b = (temp_b*temp_reg) / 0x80; if(b_AEC_on) { GC0328_WriteReg(0xcd, temp_r); GC0328_WriteReg(0xce, temp_g); GC0328_WriteReg(0xcf , temp_b); } //SENSOR_TRACE("GC0328_BeforeSnapshot, temp_r=%x,temp_g=%x, temp_b = %x ",temp_r,temp_g,temp_b); SENSOR_Sleep(300); #endif return 0; }
LOCAL uint32_t _BF3905_PowerOn(uint32_t power_on) { SENSOR_AVDD_VAL_E dvdd_val=g_BF3905_mipi_yuv_info.dvdd_val; SENSOR_AVDD_VAL_E avdd_val=g_BF3905_mipi_yuv_info.avdd_val; SENSOR_AVDD_VAL_E iovdd_val=g_BF3905_mipi_yuv_info.iovdd_val; BOOLEAN power_down=g_BF3905_mipi_yuv_info.power_down_level; BOOLEAN reset_level=g_BF3905_mipi_yuv_info.reset_pulse_level; //uint32_t reset_width=g_BF3905_mipi_yuv_info.reset_pulse_width; if(SENSOR_TRUE==power_on) { Sensor_PowerDown(power_down); // Open power Sensor_SetVoltage(dvdd_val, avdd_val, iovdd_val); SENSOR_Sleep(20); Sensor_SetMCLK(SENSOR_DEFALUT_MCLK); SENSOR_Sleep(10); Sensor_PowerDown(!power_down); // Reset sensor Sensor_Reset(reset_level); CMR_LOGE("qzhu BF3905 power_on is true\n"); } else { Sensor_PowerDown(power_down); SENSOR_Sleep(10); Sensor_SetMCLK(SENSOR_DISABLE_MCLK); Sensor_SetVoltage(SENSOR_AVDD_CLOSED, SENSOR_AVDD_CLOSED, SENSOR_AVDD_CLOSED); CMR_LOGE("qzhu BF3905 power_on is false\n"); } return SENSOR_SUCCESS; }
LOCAL uint32_t _BF3905_StreamOff(uint32_t param) { SENSOR_PRINT("SENSOR: _BF3905_StreamOff"); int ret = 0; ret = Sensor_WriteReg(0x09, 0x01); //81 SENSOR_Sleep(20); return ret; }
LOCAL uint32_t _BF3905_StreamOn(uint32_t param) { SENSOR_PRINT("SENSOR: _BF3905_StreamOn"); int ret = 0; uint16_t read_val = 0; ret = Sensor_WriteReg(0x09, 0x01); SENSOR_Sleep(20); //SENSOR_PRINT("SENSOR: read_BF3905, reg:0x3012 val: 0x%x.\n", read_val); return ret; }
LOCAL uint32_t _BF3905_After_Snapshot(uint32_t param) { SENSOR_PRINT("SENSOR: _BF3905_After_Snapshot =%d \n",param); // BF3905_WriteReg(0x1b,0x2e); BF3905_WriteReg(0x13,0x07); SENSOR_Sleep(100); Sensor_SetMode(param); return SENSOR_SUCCESS; }
LOCAL uint32_t _ov7675_Power_On(uint32_t power_on) { SENSOR_AVDD_VAL_E dvdd_val=g_OV7675_yuv_info.dvdd_val; SENSOR_AVDD_VAL_E avdd_val=g_OV7675_yuv_info.avdd_val; SENSOR_AVDD_VAL_E iovdd_val=g_OV7675_yuv_info.iovdd_val; // BOOLEAN power_down=g_OV7675_yuv_info.power_down_level; BOOLEAN reset_level=g_OV7675_yuv_info.reset_pulse_level; uint32_t reset_width=g_OV7675_yuv_info.reset_pulse_width; if(1==power_on) { Sensor_SetVoltage(dvdd_val, avdd_val, iovdd_val); // GPIO_SetSensorPower(TRUE); // GPIO_SetFrontSensorPwdn((BOOLEAN)!power_down); // Open Mclk in default frequency Sensor_SetMCLK(SENSOR_DEFALUT_MCLK); SENSOR_Sleep(20); Sensor_SetResetLevel(reset_level); SENSOR_Sleep(reset_width); Sensor_SetResetLevel((BOOLEAN)!reset_level); SENSOR_Sleep(100); } else { // GPIO_SetFrontSensorPwdn(power_down); Sensor_SetMCLK(SENSOR_DISABLE_MCLK); // GPIO_SetSensorPower(FALSE); Sensor_SetVoltage(SENSOR_AVDD_CLOSED, SENSOR_AVDD_CLOSED, SENSOR_AVDD_CLOSED); } SENSOR_TRACE("SENSOR: _ov7675_Power_On(1:on, 0:off): %d", power_on); return 0; }
LOCAL uint32_t _BF3905_BeforeSnapshot(uint32_t sensor_snapshot_mode) { sensor_snapshot_mode &= 0xffff; Sensor_SetMode(sensor_snapshot_mode); Sensor_SetMode_WaitDone(); switch (sensor_snapshot_mode) { case SENSOR_MODE_PREVIEW_ONE: //VGA SENSOR_PRINT("Capture VGA Size"); BF3905_WriteReg(0x13,0x02); SENSOR_Sleep(200); break; case SENSOR_MODE_SNAPSHOT_ONE_FIRST: // 1.3 M { // BF3905_set_shutter(); BF3905_WriteReg(0x13,0x02); SENSOR_Sleep(450); ///300 // SENSOR_PRINT("Capture 1.3M&2M Size"); break; } case SENSOR_MODE_SNAPSHOT_ONE_SECOND: // 2 M { // BF3905_set_shutter(); BF3905_WriteReg(0x13,0x02); SENSOR_Sleep(450); ///300 // SENSOR_PRINT("Capture 1.3M&2M Size"); break; } default: break; } return 0; }
LOCAL uint32_t set_preview_mode(uint32_t preview_mode) { SENSOR_TRACE("set_preview_mode: preview_mode = %d\n", preview_mode); set_gc0309_anti_flicker(0); switch (preview_mode) { case DCAMERA_ENVIRONMENT_NORMAL: GC0309_WriteReg(0xec,0x20); break; case DCAMERA_ENVIRONMENT_NIGHT: GC0309_WriteReg(0xec,0x30); break; case DCAMERA_ENVIRONMENT_SUNNY: GC0309_WriteReg(0xec,0x10); break; default: break; } SENSOR_Sleep(10); return 0; }
LOCAL uint32_t SP0A19_set_preview_mode(uint32_t preview_mode) { switch (preview_mode) { case DCAMERA_ENVIRONMENT_NORMAL: case DCAMERA_ENVIRONMENT_SUNNY: { SP0A19_WriteReg(0xfd,0x0 ); SP0A19_WriteReg(0xb2,0x20); SP0A19_WriteReg(0xb3,0x1f); if(Antiflicker== DCAMERA_FLICKER_50HZ) { SENSOR_PRINTK("normal mode 50hz\r\n"); //capture preview daylight 24M 50hz 20-8FPS maxgain:0x70 SP0A19_WriteReg(0xfd,0x00); SP0A19_WriteReg(0x03,0x01); SP0A19_WriteReg(0x04,0x32); SP0A19_WriteReg(0x06,0x00); SP0A19_WriteReg(0x09,0x01); SP0A19_WriteReg(0x0a,0x46); SP0A19_WriteReg(0xf0,0x66); SP0A19_WriteReg(0xf1,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0x90,0x0c); SP0A19_WriteReg(0x92,0x01); SP0A19_WriteReg(0x98,0x66); SP0A19_WriteReg(0x99,0x00); SP0A19_WriteReg(0x9a,0x01); SP0A19_WriteReg(0x9b,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0xce,0xc8); SP0A19_WriteReg(0xcf,0x04); SP0A19_WriteReg(0xd0,0xc8); SP0A19_WriteReg(0xd1,0x04); SP0A19_WriteReg(0xfd,0x00); } else { SENSOR_PRINTK("normal mode 60hz\r\n"); //capture preview daylight 24M 60hz 20-8FPS maxgain:0x70 SP0A19_WriteReg(0xfd,0x00); SP0A19_WriteReg(0x03,0x00); SP0A19_WriteReg(0x04,0xff); SP0A19_WriteReg(0x06,0x00); SP0A19_WriteReg(0x09,0x01); SP0A19_WriteReg(0x0a,0x46); SP0A19_WriteReg(0xf0,0x55); SP0A19_WriteReg(0xf1,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0x90,0x0f); SP0A19_WriteReg(0x92,0x01); SP0A19_WriteReg(0x98,0x55); SP0A19_WriteReg(0x99,0x00); SP0A19_WriteReg(0x9a,0x01); SP0A19_WriteReg(0x9b,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0xce,0xfb); SP0A19_WriteReg(0xcf,0x04); SP0A19_WriteReg(0xd0,0xfb); SP0A19_WriteReg(0xd1,0x04); SP0A19_WriteReg(0xfd,0x00); } break; } case DCAMERA_ENVIRONMENT_NIGHT: { SP0A19_WriteReg(0xfd,0x0 ); SP0A19_WriteReg(0xb2,0x25); SP0A19_WriteReg(0xb3,0x1f); if(Antiflicker== DCAMERA_FLICKER_50HZ) { SENSOR_PRINTK("night mode 50hz\r\n"); //capture preview night 24M 50hz 20-6FPS maxgain:0x78 SP0A19_WriteReg(0xfd,0x00); SP0A19_WriteReg(0x03,0x01); SP0A19_WriteReg(0x04,0x32); SP0A19_WriteReg(0x06,0x00); SP0A19_WriteReg(0x09,0x01); SP0A19_WriteReg(0x0a,0x46); SP0A19_WriteReg(0xf0,0x66); SP0A19_WriteReg(0xf1,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0x90,0x10); SP0A19_WriteReg(0x92,0x01); SP0A19_WriteReg(0x98,0x66); SP0A19_WriteReg(0x99,0x00); SP0A19_WriteReg(0x9a,0x01); SP0A19_WriteReg(0x9b,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0xce,0x60); SP0A19_WriteReg(0xcf,0x06); SP0A19_WriteReg(0xd0,0x60); SP0A19_WriteReg(0xd1,0x06); SP0A19_WriteReg(0xfd,0x00); } else { SENSOR_PRINTK("night mode 60hz\r\n"); //capture preview night 24M 60hz 20-6FPS maxgain:0x78 SP0A19_WriteReg(0xfd,0x00); SP0A19_WriteReg(0x03,0x00); SP0A19_WriteReg(0x04,0xff); SP0A19_WriteReg(0x06,0x00); SP0A19_WriteReg(0x09,0x01); SP0A19_WriteReg(0x0a,0x46); SP0A19_WriteReg(0xf0,0x55); SP0A19_WriteReg(0xf1,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0x90,0x14); SP0A19_WriteReg(0x92,0x01); SP0A19_WriteReg(0x98,0x55); SP0A19_WriteReg(0x99,0x00); SP0A19_WriteReg(0x9a,0x01); SP0A19_WriteReg(0x9b,0x00); SP0A19_WriteReg(0xfd,0x01); SP0A19_WriteReg(0xce,0xa4); SP0A19_WriteReg(0xcf,0x06); SP0A19_WriteReg(0xd0,0xa4); SP0A19_WriteReg(0xd1,0x06); SP0A19_WriteReg(0xfd,0x00); } break; } default: { break; } SENSOR_Sleep(100); } return 0; }
LOCAL uint32_t _BF3905_set_preview_mode(uint32_t preview_mode) { SENSOR_PRINT("set_preview_mode: preview_mode = %d\n", preview_mode); //_BF3A20_set_anti_flicker(0); switch (preview_mode) { case DCAMERA_ENVIRONMENT_NORMAL: { //YCP_saturation BF3905_WriteReg(0x89 , 0x65); //7d BF3905_WriteReg(0x86 , 0x80); SENSOR_PRINT("set_preview_mode: DCAMERA_ENVIRONMENT_NORMAL\n"); break; } case 1://DCAMERA_ENVIRONMENT_NIGHT://1 { //YCP_saturation BF3905_WriteReg(0x89 , 0x65); //7d BF3905_WriteReg(0x86 , 0x80); SENSOR_PRINT("set_preview_mode: DCAMERA_ENVIRONMENT_NIGHT\n"); break; } case 3://SENSOR_ENVIROMENT_PORTRAIT://3 { //YCP_saturation BF3905_WriteReg(0x89 , 0x65); //7d BF3905_WriteReg(0x86 , 0x80); SENSOR_PRINT("set_preview_mode: SENSOR_ENVIROMENT_PORTRAIT\n"); break; } case 4://SENSOR_ENVIROMENT_LANDSCAPE://4 { //nightmode disable BF3905_WriteReg(0x89 , 0x65); //7d BF3905_WriteReg(0x86 , 0x80); SENSOR_PRINT("set_preview_mode: SENSOR_ENVIROMENT_LANDSCAPE\n"); break; } case 2://SENSOR_ENVIROMENT_SPORTS://2 { //nightmode disable //YCP_saturation BF3905_WriteReg(0x89 , 0x65); //7d BF3905_WriteReg(0x86 , 0x80); SENSOR_PRINT("set_preview_mode: SENSOR_ENVIROMENT_SPORTS\n"); break; } default: { break; } } SENSOR_Sleep(20); return 0; }