#include "asm/iic.h" #include "asm/isc.h" #include "asm/isp_dev.h" #include "gc2035.h" #include "gpio.h" #include "generic/jiffies.h" #include "device/iic.h" #include "device/device.h" #include "app_config.h" #ifdef CONFIG_VIDEO_ENABLE #define GC2035_DVP_WRCMD 0x78 #define GC2035_DVP_RDCMD 0x79 #define GC2035_DEVP_INPUT_MAX_W 1600 #define GC2035_DEVP_INPUT_MAX_H 1200 #if (CONFIG_VIDEO_IMAGE_W > GC2035_DEVP_INPUT_MAX_W) #define GC2035_DEVP_INPUT_W GC2035_DEVP_INPUT_MAX_W #define GC2035_DEVP_INPUT_H GC2035_DEVP_INPUT_MAX_H #else #define GC2035_DEVP_INPUT_W CONFIG_VIDEO_IMAGE_W #define GC2035_DEVP_INPUT_H CONFIG_VIDEO_IMAGE_H #endif #define CONFIG_INPUT_FPS 15 #define DELAY_TIME 10 static void *iic = NULL; static u8 gc2035_reset_io[2] = {-1, -1}; static u8 gc2035_power_io[2] = {-1, -1}; typedef struct { u8 addr; u8 value; } Sensor_reg_ini; const Sensor_reg_ini GC2035_INI_REG[] = { {0xfe, 0x80}, {0xfe, 0x80}, {0xfe, 0x80}, {0xfc, 0x06}, {0xf2, 0x00}, {0xf3, 0x00}, {0xf4, 0x00}, {0xf5, 0x00}, {0xf9, 0xfe}, //[0] pll enable {0xfa, 0x00}, {0xf6, 0x00}, {0xf7, 0x15}, //pll enable {0xf8, 0x85}, //85 {0xfe, 0x00}, {0x82, 0x00}, {0xb3, 0x60}, {0xb4, 0x40}, {0xb5, 0x60}, {0x03, 0x02}, {0x04, 0x80}, ////measure window /// {0xfe, 0x00}, {0xec, 0x06}, //04 2012.10.26 {0xed, 0x06}, //04 2012.10.26 {0xee, 0x62}, //60 2012.10.26 {0xef, 0x92}, //90 2012.10.26 ////analog/// {0x0a, 0x00}, //row start {0x0c, 0x00}, //col start {0x0d, 0x04}, {0x0e, 0xc0}, {0x0f, 0x06}, //Window setting {0x10, 0x58}, {0x17, 0x14}, //[0]mirror [1]flip {0x18, 0x0e}, // {0x19, 0x0c}, // {0x1a, 0x01}, // {0x1b, 0x8b}, {0x1c, 0x05}, // add by lanking 20130403 {0x1e, 0x88}, // {0x1f, 0x08}, //[3] tx-low en// {0x20, 0x05}, // {0x21, 0x0f}, // {0x22, 0xf0}, // f0 20130628 {0x23, 0xc3}, // {0x24, 0x17}, // 16 //AWB_gray {0xfe, 0x01}, {0x4f, 0x00}, {0x4d, 0x32}, // 30 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4d, 0x42}, // 40 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4d, 0x52}, // 50 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4d, 0x62}, // 60 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4d, 0x72}, // 70 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4d, 0x82}, // 80 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4d, 0x92}, // 90 {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4e, 0x04}, {0x4f, 0x01}, {0x50, 0x88}, {0xfe, 0x00}, {0x82, 0xfe}, ///////awb start //////////////// {0xfe, 0x01}, {0x50, 0x88}, //c0//[6]green mode {0x52, 0x40}, {0x54, 0x60}, {0x56, 0x06}, {0x57, 0x20}, //pre adjust {0x58, 0x01}, {0x5b, 0x02}, //AWB_gain_delta {0x61, 0xaa}, //R/G stand {0x62, 0xaa}, //R/G stand {0x71, 0x00}, {0x74, 0x10}, //AWB_C_max {0x77, 0x08}, //AWB_p2_x {0x78, 0xfd}, //AWB_p2_y {0x86, 0x30}, {0x87, 0x00}, {0x88, 0x04}, //[1]dark mode {0x8a, 0xc0}, //awb move mode {0x89, 0x75}, {0x84, 0x08}, //auto_window {0x8b, 0x00}, //awb compare luma {0x8d, 0x70}, //awb gain limit R {0x8e, 0x70}, //G {0x8f, 0xf4}, //B /////////awb end ///////////// //AEC {0xfe, 0x01}, {0x11, 0x20}, // {0x1f, 0xc0}, //max_post_gain {0x20, 0x60}, //max_pre_gain {0x47, 0x30}, //AEC_outdoor_th {0x0b, 0x10}, // {0x13, 0x75}, //y_target {0xfe, 0x00}, {0x05, 0x01}, //hb {0x06, 0x0d}, {0x07, 0x00}, //vb {0x08, 0x40}, {0xfe, 0x01}, {0x27, 0x00}, //step {0x28, 0xa0}, {0x29, 0x05}, //level1 {0x2a, 0x00}, {0x2b, 0x06}, //level2 {0x2c, 0x40}, {0x2d, 0x06}, //level3 {0x2e, 0x40}, {0x2f, 0x08}, //level4 {0x30, 0xc0}, {0xfe, 0x00}, {0xfe, 0x00}, //0x , 0x , 0x , 0x , 0x {0xb6, 0x03}, //AEC enable {0xfe, 0x00}, /////BLK////// {0x3f, 0x00}, //prc close {0x40, 0x77}, // {0x42, 0x7f}, {0x43, 0x30}, {0x5c, 0x08}, {0x5e, 0x20}, {0x5f, 0x20}, {0x60, 0x20}, {0x61, 0x20}, {0x62, 0x20}, {0x63, 0x20}, {0x64, 0x20}, {0x65, 0x20}, ///block//// {0x80, 0xff}, {0x81, 0x26}, // {0x87, 0x90}, // {0x84, 0x02}, //output put foramat//YUYV {0x86, 0x06}, ////sync plority 02 86 {0x8b, 0xbc}, {0xb0, 0x80}, //globle gain {0xc0, 0x40}, //Yuv bypass ////lsc/// {0xfe, 0x01}, {0xc2, 0x38}, {0xc3, 0x25}, {0xc4, 0x21}, {0xc8, 0x19}, {0xc9, 0x12}, {0xca, 0x0e}, {0xbc, 0x43}, {0xbd, 0x18}, {0xbe, 0x1b}, {0xb6, 0x40}, {0xb7, 0x2e}, {0xb8, 0x26}, {0xc5, 0x05}, {0xc6, 0x03}, {0xc7, 0x04}, {0xcb, 0x00}, {0xcc, 0x00}, {0xcd, 0x00}, {0xbf, 0x14}, {0xc0, 0x22}, {0xc1, 0x1b}, {0xb9, 0x00}, {0xba, 0x05}, {0xbb, 0x05}, {0xaa, 0x35}, {0xab, 0x33}, {0xac, 0x33}, {0xad, 0x25}, {0xae, 0x22}, {0xaf, 0x27}, {0xb0, 0x1d}, {0xb1, 0x20}, {0xb2, 0x22}, {0xb3, 0x14}, {0xb4, 0x15}, {0xb5, 0x16}, {0xd0, 0x00}, {0xd2, 0x07}, {0xd3, 0x08}, {0xd8, 0x00}, {0xda, 0x13}, {0xdb, 0x17}, {0xdc, 0x00}, {0xde, 0x0a}, {0xdf, 0x08}, {0xd4, 0x00}, {0xd6, 0x00}, {0xd7, 0x0c}, {0xa4, 0x00}, {0xa5, 0x00}, {0xa6, 0x00}, {0xa7, 0x00}, {0xa8, 0x00}, {0xa9, 0x00}, {0xa1, 0x80}, {0xa2, 0x80}, ///cc//// {0xfe, 0x02}, {0xc0, 0x01}, {0xc1, 0x40}, // {0xc2, 0xfc}, {0xc3, 0x05}, {0xc4, 0xec}, {0xc5, 0x42}, {0xc6, 0xf8}, {0xc7, 0x40}, //for cwf {0xc8, 0xf8}, {0xc9, 0x06}, {0xca, 0xfd}, {0xcb, 0x3e}, {0xcc, 0xf3}, {0xcd, 0x36}, //for A {0xce, 0xf6}, {0xcf, 0x04}, {0xe3, 0x0c}, {0xe4, 0x44}, {0xe5, 0xe5}, {0xfe, 0x00}, ///==========asde {0xfe, 0x01}, {0x21, 0xbf}, {0xfe, 0x02}, {0xa4, 0x00}, {0xa5, 0x40}, //lsc_th {0xa2, 0xa0}, //lsc_dec_slope {0xa6, 0x80}, //dd_th {0xa7, 0x80}, //ot_th {0xab, 0x31}, {0xa9, 0x6f}, {0xb0, 0x99}, //edge effect slope low {0xb1, 0x34}, //edge effect slope low {0xb3, 0x80}, //saturation dec slope {0xde, 0xb6}, {0x38, 0x0f}, {0x39, 0x60}, {0xfe, 0x00}, {0x81, 0x26}, {0xfe, 0x02}, {0x83, 0x00}, {0x84, 0x45}, ////////////YCP////////// {0xd1, 0x38}, //saturation_cb {0xd2, 0x38}, //saturation_Cr {0xd3, 0x40}, //contrast {0xd4, 0x80}, //contrast center {0xd5, 0x00}, //luma_offset {0xdc, 0x30}, {0xdd, 0xb8}, //edge_sa_g,b {0xfe, 0x00}, //////////dndd/////////// {0xfe, 0x02}, {0x88, 0x15}, //dn_b_base {0x8c, 0xf6}, //[2]b_in_dark_inc {0x89, 0x03}, //dn_c_weight //////////EE /////////// {0xfe, 0x02}, {0x90, 0x6c}, // EEINTP mode1 {0x97, 0x45}, // edge effect ////==============RGB Gamma //// {0xfe, 0x02}, {0x15, 0x0a}, {0x16, 0x12}, {0x17, 0x19}, {0x18, 0x1f}, {0x19, 0x2c}, {0x1a, 0x38}, {0x1b, 0x42}, {0x1c, 0x4e}, {0x1d, 0x63}, {0x1e, 0x76}, {0x1f, 0x87}, {0x20, 0x96}, {0x21, 0xa2}, {0x22, 0xb8}, {0x23, 0xca}, {0x24, 0xd8}, {0x25, 0xe3}, {0x26, 0xf0}, {0x27, 0xf8}, {0x28, 0xfd}, {0x29, 0xff}, //// small RGB gamma//// ///=================y gamma {0xfe, 0x02}, {0x2b, 0x00}, {0x2c, 0x04}, {0x2d, 0x09}, {0x2e, 0x18}, {0x2f, 0x27}, {0x30, 0x37}, {0x31, 0x49}, {0x32, 0x5c}, {0x33, 0x7e}, {0x34, 0xa0}, {0x35, 0xc0}, {0x36, 0xe0}, {0x37, 0xff}, // {SENSOR_WRITE_DELAY , 0xff}, //AWB clear {0xfe, 0x01}, {0x4f, 0x00}, {0x4d, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x10}, // 10 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x20}, // 20 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x30}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, // 30 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x40}, // 40 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x50}, // 50 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x60}, // 60 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x70}, // 70 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x80}, // 80 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0x90}, // 90 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0xa0}, // a0 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0xb0}, // b0 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0xc0}, // c0 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0xd0}, // d0 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0xe0}, /////////////////////////////////e0 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4d, 0xf0}, /////////////////////////////////f0 {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4e, 0x00}, {0x4f, 0x01}, // awb value// {0xfe, 0x01}, {0x4f, 0x00}, {0x4d, 0x30}, {0x4e, 0x00}, {0x4e, 0x80}, {0x4e, 0x80}, {0x4e, 0x02}, {0x4e, 0x02}, {0x4d, 0x40}, {0x4e, 0x00}, {0x4e, 0x80}, {0x4e, 0x80}, {0x4e, 0x02}, {0x4e, 0x02}, {0x4e, 0x02}, {0x4d, 0x53}, {0x4e, 0x08}, {0x4e, 0x04}, {0x4d, 0x62}, {0x4e, 0x10}, {0x4d, 0x72}, {0x4e, 0x20}, {0x4f, 0x01}, {0xfe, 0x00}, // {0x90, 0x01}, ////crop enablei {0x91, 0x01}, //y1-300 {0x92, 0x2c}, {0x93, 0x01}, //x1-350 {0x94, 0x5e}, #if 0 {0x95, 0x04}, ////1600x1200 {0x96, 0xb0}, {0x97, 0x06}, {0x98, 0x40}, #else /* {0x95 , 0x02}, ////1280x720 {0x96 , 0xd0}, {0x97 , 0x05}, {0x98 , 0x00}, */ {0x95, 0x02}, //800x600 {0x96, 0x58}, {0x97, 0x03}, {0x98, 0x20}, #endif {0xfe, 0x03}, {0x17, 0x00}, //widv {0x40, 0x40}, //00 {0x41, 0x02}, //Pclk_polarity {0x42, 0x40}, {0x43, 0x06}, //output buf width ////output DVP///// {0xfe, 0x00}, {0x82, 0xfe}, {0xf2, 0x70}, {0xf3, 0xff}, {0xf4, 0x00}, {0xf5, 0x30}, {0xff, 0xff}, }; unsigned char wrGC2035Reg(unsigned char regID, unsigned char regDat) { u8 ret = 1; dev_ioctl(iic, IIC_IOCTL_START, 0); if (dev_ioctl(iic, IIC_IOCTL_TX_WITH_START_BIT, GC2035_DVP_WRCMD)) { ret = 0; printf("iic write err!!! line : %d \n", __LINE__); goto exit; } delay(DELAY_TIME); if (dev_ioctl(iic, IIC_IOCTL_TX, regID)) { ret = 0; printf("iic write err!!! line : %d \n", __LINE__); goto exit; } delay(DELAY_TIME); if (dev_ioctl(iic, IIC_IOCTL_TX_WITH_STOP_BIT, regDat)) { ret = 0; printf("iic write err!!! line : %d \n", __LINE__); goto exit; } delay(DELAY_TIME); exit: dev_ioctl(iic, IIC_IOCTL_STOP, 0); return ret; } unsigned char rdGC2035Reg(unsigned char regID, unsigned char *regDat) { u8 ret = 1; dev_ioctl(iic, IIC_IOCTL_START, 0); if (dev_ioctl(iic, IIC_IOCTL_TX_WITH_START_BIT, GC2035_DVP_WRCMD)) { ret = 0; printf("iic write err!!! line : %d \n", __LINE__); goto exit; } delay(DELAY_TIME); if (dev_ioctl(iic, IIC_IOCTL_TX_WITH_STOP_BIT, regID)) { ret = 0; printf("iic write err!!! line : %d \n", __LINE__); goto exit; } delay(DELAY_TIME); if (dev_ioctl(iic, IIC_IOCTL_TX_WITH_START_BIT, GC2035_DVP_RDCMD)) { ret = 0; printf("iic write err!!! line : %d \n", __LINE__); goto exit; } delay(DELAY_TIME); dev_ioctl(iic, IIC_IOCTL_RX_WITH_STOP_BIT, (u32)regDat); exit: dev_ioctl(iic, IIC_IOCTL_STOP, 0); return ret; } void GC2035_config_SENSOR(u16 *width, u16 *height, u8 *format, u8 *frame_freq) { int i; for (i = 0; i < sizeof(GC2035_INI_REG) / sizeof(Sensor_reg_ini); i++) { wrGC2035Reg(GC2035_INI_REG[i].addr, GC2035_INI_REG[i].value); } *format = SEN_IN_FORMAT_YUYV; puts("\nGC2035 YUYV\n"); } s32 GC2035_set_output_size(u16 *width, u16 *height, u8 *freq) { u16 liv_width = *width; u16 liv_height = *height; return 0; } s32 GC2035_ID_check(void) { u8 pid = 0x00; u8 ver = 0x00; u8 i ; for (i = 0; i < 3; i++) { // rdGC2035Reg(0xf0, &pid); rdGC2035Reg(0xf1, &ver); } puts("Sensor PID \n"); puts("\n"); if (pid != 0x20 || ver != 0x35) { puts("\n----not GC2035_DVP-----\n"); return -1; } puts("\n----hello GC2035_DVP-----\n"); return 0; } static s32 GC2035_powerio_ctl(u8 _power_gpio, u8 on_off) { gpio_direction_output(_power_gpio, on_off); return 0; } void GC2035_reset(u8 isp_dev) { u8 res_io; u8 powd_io; u8 id = 0; puts("GC2035 reset\n"); if (isp_dev == ISP_DEV_0) { res_io = gc2035_reset_io[0]; powd_io = gc2035_power_io[0]; } else { res_io = gc2035_reset_io[1]; powd_io = gc2035_power_io[1]; } if (powd_io != (u8) - 1) { GC2035_powerio_ctl(powd_io, 0); } if (res_io != (u8) - 1) { gpio_direction_output(res_io, 1); gpio_direction_output(res_io, 0); os_time_dly(1); gpio_direction_output(res_io, 1); } } s32 GC2035_check(u8 isp_dev, u32 _reset_gpio, u32 _power_gpio) { if (!iic) { if (isp_dev == ISP_DEV_0) { iic = dev_open("iic0", 0); } else { iic = dev_open("iic1", 0); } gc2035_reset_io[isp_dev] = (u8)_reset_gpio; gc2035_power_io[isp_dev] = (u8)_power_gpio; } if (iic == NULL) { printf("GC2035 iic open err!!!\n\n"); return -1; } GC2035_reset(isp_dev); if (0 != GC2035_ID_check()) { dev_close(iic); iic = NULL; return -1; } return 0; } u16 GC2035_dvp_rd_reg(u16 addr) { u8 val; rdGC2035Reg((u8)addr, &val); return val; } void GC2035_dvp_wr_reg(u16 addr, u16 val) { wrGC2035Reg((u8)addr, (u8)val); } void set_rev_sensor_GC2035(u16 rev_flag) { if (!rev_flag) { wrGC2035Reg(0x17, 0x12); } else { wrGC2035Reg(0x17, 0x11); } } static s32 GC2035_init(u8 isp_dev, u16 *width, u16 *height, u8 *format, u8 *frame_freq) { puts("\n\n GC2035_init \n\n"); if (0 != GC2035_check(isp_dev, 0, 0)) { return -1; } GC2035_config_SENSOR(width, height, format, frame_freq); return 0; } // *INDENT-OFF* REGISTER_CAMERA(GC2035) = { .logo = "GC2035", .isp_dev = ISP_DEV_NONE, .in_format = SEN_IN_FORMAT_YUYV, .mbus_type = SEN_MBUS_PARALLEL, .mbus_config = SEN_MBUS_DATA_WIDTH_8B | SEN_MBUS_HSYNC_ACTIVE_HIGH | \ SEN_MBUS_PCLK_SAMPLE_FALLING | SEN_MBUS_VSYNC_ACTIVE_HIGH, #if CONFIG_CAMERA_H_V_EXCHANGE .sync_config = SEN_MBUS_SYNC0_VSYNC_SYNC1_HSYNC,//WL82/AC791才可以H-V SYNC互换,请留意 #endif .fps = CONFIG_INPUT_FPS, .sen_size = {GC2035_DEVP_INPUT_W, GC2035_DEVP_INPUT_H}, .cap_fps = CONFIG_INPUT_FPS, .sen_cap_size = {GC2035_DEVP_INPUT_W, GC2035_DEVP_INPUT_H}, .ops = { .avin_fps = NULL, .avin_valid_signal = NULL, .avin_mode_det = NULL, .sensor_check = GC2035_check, .init = GC2035_init, .set_size_fps = GC2035_set_output_size, .power_ctrl = GC2035_powerio_ctl, .sleep = NULL, .wakeup = NULL, .write_reg = GC2035_dvp_wr_reg, .read_reg = GC2035_dvp_rd_reg, .set_sensor_reverse = set_rev_sensor_GC2035, } }; #endif