运行命令make ARCH = menuconfig进入device drivers--->Multimedia support--->配置如下
把GC2145的驱动文件gc2145.c放在lichee\linux-3.3\drivers\media\video\sunxi-vfe\device\下并在其目录下的Makefike文件添加
obj-$(CONFIG_CSI_VFE) += cci.o
......
obj-m += gc2145.o
修改lichee\tools\pack\chips\sun6i\configs\android\mars-ml220\sys_config.fex文件中内容如下
[vip1_para]
vip_used = 1
vip_dev0_mname = "gc2145"
vip_dev0_twi_id = 0
vip_dev0_twi_addr = 0x78
vip_dev0_isp_used = 0
vip_dev0_fmt = 0
vip_dev0_stby_mode = 0
vip_dev0_vflip = 0
vip_dev0_hflip = 0
vip_dev0_iovdd = "axp22_dldo2"
vip_dev0_iovdd_vol = 2800000
vip_dev0_avdd = "axp22_ldoio0"
vip_dev0_avdd_vol = 2800000
vip_dev0_dvdd = "axp22_eldo2"
vip_dev0_dvdd_vol = 1800000
vip_dev0_afvdd = "axp22_dldo2"
vip_dev0_afvdd_vol = 2800000
vip_dev0_power_en =
vip_dev0_reset = port:PH26<1><default><default><0>
vip_dev0_pwdn = port:PH27<1><default><default><1>
vip_dev0_flash_en =
vip_dev0_flash_mode =
vip_dev0_af_pwdn =
vip_dev0_act_used = 0
vip_dev0_act_name = "ad5820_act"
vip_dev0_act_slave = 0x18
[camera_list_para]
camera_list_para_used = 1
......
gc2145 = 1
修改android\device\softwinner\mars-ml220\init.sun6i.rc文件中如下内容
#csi module
insmod /system/vendor/modules/videobuf-core.ko
insmod /system/vendor/modules/videobuf-dma-contig.ko
#insmod /system/vendor/modules/uvcvideo.ko
insmod /system/vendor/modules/cam_detect.ko
#insmod /system/vendor/modules/actuator.ko
#insmod /system/vendor/modules/ad5820_act.ko
insmod /system/vendor/modules/cci.ko
insmod /system/vendor/modules/vfe_os.ko
insmod /system/vendor/modules/vfe_subdev.ko
#insmod /system/vendor/modules/ov5647.ko
insmod /system/vendor/modules/gc2145.ko #注意:gc2145.ko一定要在vfe_v4l2.ko前注册,不然会提示连接不到相机
insmod /system/vendor/modules/vfe_v4l2.ko
修改android\device\softwinner\mars-ml220\configs文件中内容如下
number_of_camera = 1
camera_id = 0
camera_facing = 0
use_builtin_isp = 0
camera_orientation = 0
device_id = 0
在lichee\linux-3.3\drivers\media\video\sunxi-vfe\config.c文件中添加
struct camera_info camera_info_list[] =
{
{"gc2145",0,0,0,0},
{"gc2235",0,0,1,1},
{"ov5647",0,0,1,1},
{"gc2035",0,0,0,0},
{"gc0308",0,0,0,0},
{"gc0307",0,0,0,0},
{"hi257",0,0,0,0},
};
在lichee\linux-3.3\drivers\media\video\sunxi-vfe\camera_detector\camera_list.c文件中添加
#define __GC2145__
static void camera_pwr_on_gc2145(__u32 list_index, __camera_info_t *camera_info)
{
camera_gpio_set_status(camera_info->stby_pin, 1);
camera_gpio_set_status(camera_info->reset_pin, 1);
//power supply
camera_gpio_write(camera_info->stby_pin, camera_list[list_index].CSI_STBY_ON);
camera_gpio_write(camera_info->reset_pin, camera_list[list_index].CSI_RST_ON);
msleep(1);
clk_enable(camera_info->module_clk);
msleep(10);
camera_gpio_write(camera_info->pwr_pin, camera_list[list_index].CSI_PWR_ON);
msleep(10);
if(camera_info->dvdd)
{
if(camera_info->dvdd_vol > 0)
{
regulator_set_voltage(camera_info->dvdd,camera_info->dvdd_vol,camera_info->dvdd_vol);
}
else
{
list_print("dvdd_vol is NULL!! \n");
}
regulator_enable(camera_info->dvdd);
msleep(10);
}
if(camera_info->avdd)
{
if(camera_info->dvdd_vol > 0)
{
regulator_set_voltage(camera_info->avdd,camera_info->avdd_vol,camera_info->avdd_vol);
}
else
{
list_print("dvdd_vol is NULL!! \n");
}
regulator_enable(camera_info->avdd);
msleep(10);
}
if(camera_info->iovdd)
{
if(camera_info->dvdd_vol > 0)
{
regulator_set_voltage(camera_info->iovdd,camera_info->iovdd_vol,camera_info->iovdd_vol);
}
else
{
list_print("dvdd_vol is NULL!! \n");
}
regulator_enable(camera_info->iovdd);
msleep(10);
}
//standby off io
camera_gpio_write(camera_info->stby_pin, camera_list[list_index].CSI_STBY_OFF);
msleep(10);
camera_gpio_write(camera_info->reset_pin, camera_list[list_index].CSI_RST_OFF);
msleep(10);
camera_gpio_write(camera_info->reset_pin, camera_list[list_index].CSI_RST_ON);
msleep(10);
camera_gpio_write(camera_info->reset_pin, camera_list[list_index].CSI_RST_OFF);
msleep(10);
}
static void camera_pwr_off_gc2145(__u32 list_index, __camera_info_t *camera_info)
{
camera_gpio_write(camera_info->stby_pin, camera_list[list_index].CSI_STBY_ON);
msleep(10);
//reset on io
camera_gpio_write(camera_info->reset_pin, camera_list[list_index].CSI_RST_ON);
msleep(10);
//inactive mclk after power off
//power supply off
if(camera_info->iovdd) {
regulator_disable(camera_info->iovdd);
}
if(camera_info->avdd) {
regulator_disable(camera_info->avdd);
}
if(camera_info->dvdd) {
regulator_disable(camera_info->dvdd);
}
camera_gpio_write(camera_info->pwr_pin, camera_list[list_index].CSI_PWR_OFF);
msleep(10);
//standby of io
clk_disable(camera_info->module_clk);
//set the io to hi-z
camera_gpio_set_status(camera_info->reset_pin, 0);//set the gpio to input
// camera_gpio_set_status(camera_info->stby_pin, 0);//set the gpio to input
}
static __s32 camera_detect_gc2145(__u32 list_index, struct i2c_adapter *i2c_adap)
{
char reg_num[1], value[1];
__s32 ret = 0;
__u32 i2c_addr = camera_list[list_index].i2c_addr;
__u32 addr_step = camera_list[list_index].REG_ADDR_STEP;
__u32 data_step = camera_list[list_index].REG_DATA_STEP;
list_print("try to detect gc2145 ... \n");
reg_num[0] = 0xf0;
ret = camera_i2c_read(i2c_adap, reg_num, value, i2c_addr, addr_step, data_step);
if (ret < 0) {
return ret;
}
if(value[0] !=0x21)
return -ENODEV;
reg_num[0] = 0xf1;
ret = camera_i2c_read(i2c_adap, reg_num, value, i2c_addr, addr_step, data_step);
if (ret < 0) {
return ret;
}
if(value[0] !=0x55)
return -ENODEV;
list_print("detect gc2145 success!!\n");
return 0;
}
__camera_list_t camera_list[MAX_CAMERA_LIST_ITEM] = {
... ...
CAMERA_LIST_ITEM_INIT(gc2145, 1, 1, 0x78, 1, 0, 0, 1, 1, 0),
};
修改lichee\linux-3.3\drivers\media\video\sunxi-vfe\camera_detector\camera_list.h文件中内容如下
#define MAX_CAMERA_LIST_ITEM 26 //在原来的基础上加一