1. 设备驱动加载及系统配置

关于sensor的开发环境、MPP的工作原理、ISP简介等可参考shugenyin的博客——海思Hi3518EV200。

cd ko
./load3516a -a -sensor sc3035 -osmem 64

在load脚本中添加sensor的相关配置,这里使用smartsens的SC3035-M的360万像素CMOS sensor。

insert_sns()
{
	case $SNS_TYPE in
		sc3035)
			himm 0x200f0050 0x2;                # i2c0_scl
			himm 0x200f0054 0x2;                # i2c0_sda

			himm 0x2003002c 0xB0007             # sensolsr unreset, clk 27MHz, VI 250MHz
			;;
		*)
			echo "xxxx Invalid sensor type $SNS_TYPE xxxx"
			report_error
			;;
	esac
}


2. sensor的库文件生成(.so)

sensor的库文件需要在Linux服务器中的SDK包中编译得到,将生成的.so文件放到SDK包中的stream软件包中的Hi3516A_Stream_xxx/libs目录下。

wKiom1fqDVnwo6s8AADLefhHtRE231.jpg

sc3035_sensor_ctl.c实现sensor的初始化。

void sensor_init()
{
   sensor_i2c_init();
   sensor_init_3M_1536p_4lan();     
}

void sensor_init_3M_1536p_4lan()
{
	sensor_write_register(0x0100,0x00);
	sensor_write_register(0x4500,0x31);// rnc sel
	sensor_write_register(0x3416,0x11);
	sensor_write_register(0x4501,0xa4);// bit ctrl 
	sensor_write_register(0x3e03,0x03);// aec
	sensor_write_register(0x3e08,0x00);
	sensor_write_register(0x3e09,0x10);
	sensor_write_register(0x3e01,0x30);
	sensor_write_register(0x322e,0x00);
	sensor_write_register(0x322f,0xaf);
	sensor_write_register(0x3306,0x56);
	sensor_write_register(0x3307,0x17);
	sensor_write_register(0x330b,0x54);
	sensor_write_register(0x3303,0x20);
	sensor_write_register(0x3309,0x20);
	sensor_write_register(0x3308,0x08);
	sensor_write_register(0x331e,0x16);
	sensor_write_register(0x331f,0x16);
	sensor_write_register(0x3320,0x18);
	sensor_write_register(0x3321,0x18);
	sensor_write_register(0x3322,0x18);
	sensor_write_register(0x332