赞
踩
展锐平台的camera sensor驱动代码设计解析(1)
展锐平台的camera sensor驱动代码设计解析(2)
展锐平台的camera sensor驱动代码设计解析(3)
#define VENDOR_NUM 1
#define SENSOR_NAME "ov8856"
#define I2C_SLAVE_ADDR 0x6c /* 8bit slave address*/
#define ov8856_PID_ADDR 0x300B
#define ov8856_PID_VALUE 0x88
#define ov8856_VER_ADDR 0x300C
#define ov8856_VER_VALUE 0x5A
VENDOR_NUM :表示一个模组厂的配置
SENSOR_NAME :表示打印语句的配置
I2C_SLAVE_ADDR :表示sensor的i2c地址,一般是8bit地址。
/* effective sensor output image size */ /* effective sensor output image size */ #define VIDEO_WIDTH 1280 #define VIDEO_HEIGHT 720 #define PREVIEW_WIDTH 1632 #define PREVIEW_HEIGHT 1224 #define SNAPSHOT_WIDTH 3264 #define SNAPSHOT_HEIGHT 2448 /*Raw Trim parameters*/ #define VIDEO_TRIM_X 0 #define VIDEO_TRIM_Y 0 #define VIDEO_TRIM_W 1280 #define VIDEO_TRIM_H 720 #define PREVIEW_TRIM_X 0 #define PREVIEW_TRIM_Y 0 #define PREVIEW_TRIM_W 1632 #define PREVIEW_TRIM_H 1224 #define SNAPSHOT_TRIM_X 0 #define SNAPSHOT_TRIM_Y 0 #define SNAPSHOT_TRIM_W 3264 #define SNAPSHOT_TRIM_H 2448
这个是sensor的配置的尺寸,最大的是full size,preview使用的是binning size,1280X720是给slow motion使用
/*Mipi output*/ #define LANE_NUM 2 #define RAW_BITS 10 #define VIDEO_MIPI_PER_LANE_BPS 776 /* 2*Mipi clk */ #define PREVIEW_MIPI_PER_LANE_BPS 776 /* 2*Mipi clk */ #define SNAPSHOT_MIPI_PER_LANE_BPS 1272 /* 2*Mipi clk */ /*line time unit: ns*/ #define VIDEO_LINE_TIME 13416 #define PREVIEW_LINE_TIME 26833 #define SNAPSHOT_LINE_TIME 13416 /* frame length*/ #define VIDEO_FRAME_LENGTH 963 #define PREVIEW_FRAME_LENGTH 1246 #define SNAPSHOT_FRAME_LENGTH 2496 /* please ref your spec */ #define FRAME_OFFSET 6 #define SENSOR_MAX_GAIN 0x7c0 // x15.5 A gain #define SENSOR_BASE_GAIN 0x80 #define SENSOR_MIN_SHUTTER 6
如上配置对sensor厂提供的regsetting非常重要,一定要确认正确,
LANE_NUM: 表示4组data lane,
RAW_BITS:表示sensor输出10bit的raw数据。
*LANE_BPS:表示三个尺寸的bps,单位是M,
LINE_TIME:表示三个尺寸的linetime,这个需要sensor厂给出,要确保正确,单位是ns。
FRAME_LENGTH: 表示三个尺寸的frame length,这三个帧长也需要确认正确,正常情况下帧长乘linetime应该是那个尺寸regsetting的最大帧率的一帧的时间。
FRAME_OFFSET: 表示帧偏,这个表示帧长和shutter的最小差值,属于sensor的特性,需要原厂给出。
BASE_GAIN和MAX_GAIN:表示sensor的gain可放大倍数,这个需要sensor厂确认,后面进行写gain的函数需要用到。
MIN_SHUTTER:表示最小曝光行,也是需要sensor原厂提供。
/* please ref your spec * 1 : average binning * 2 : sum-average binning * 4 : sum binning */ #define BINNING_FACTOR 1 /* please ref spec * 1: sensor auto caculate * 0: driver caculate */ /* sensor parameters end */ /* isp parameters, please don't change it*/ #define ISP_BASE_GAIN 0x80 /* please don't change it */ #define EX_MCLK 24
BINNING_FACTOR是为了shutter值的计算,主要是为了full size和binning size的曝光时间计算,如果是真实的binning,此值配置为1.另外,ispbase gain为平台的128,EX_MCLK为mclk的配置,24的单位为M,但有个问题是,这里只有24是准的,其他的配置可能不准确,必须的使用示波器测试。
/*============================================================================== * Description: * register setting *============================================================================*/ static const SENSOR_REG_T ov8856_init_setting[] = { /*2lan init setting clk_in = 24MHz mipi_clk =388MHz resolution =1632*1224 fps = 30 line_time = 3864/144000000 s min_line = 6 ob_value = 64 ob_value @ max_gain = 64 @ 15.5 bayer pattern=BGGR*/ { 0x0103, 0x01}, { 0x0100, 0x00}, { 0x0300, 0x04}, { 0x0302, 0x61}, { 0x0303, 0x00}, { 0x031e, 0x0c}, { 0x3000, 0x00}, { 0x300e, 0x00}, { 0x3010, 0x00}, { 0x3015, 0x84}, { 0x3018, 0x32}, { 0x3021, 0x23}, { 0x3033, 0x24}, { 0x3500, 0x00}, { 0x3501, 0x4c}, { 0x3502, 0xe0}, { 0x3503, 0x78}, { 0x3505, 0x83}, { 0x3508, 0x01}, { 0x3509, 0x80}, { 0x350c, 0x00}, { 0x350d, 0x80}, { 0x350e, 0x04}, { 0x350f, 0x00}, { 0x3510, 0x00}, { 0x3511, 0x02}, { 0x3512, 0x00}, { 0x3600, 0x72}, { 0x3601, 0x40}, { 0x3602, 0x30}, { 0x3610, 0xc5}, { 0x3611, 0x58}, { 0x3612, 0x5c}, { 0x3613, 0xca}, { 0x3614, 0x60}, { 0x3628, 0xff}, { 0x3629, 0xff}, { 0x362a, 0xff}, { 0x3633, 0x10}, { 0x3634, 0x10}, { 0x3635, 0x10}, { 0x3636, 0x10}, { 0x364a, 0x0f}, { 0x3663, 0x08}, { 0x3669, 0x34}, { 0x366e, 0x08}, { 0x3706, 0x86}, { 0x370b, 0x7e}, { 0x3714, 0x27}, { 0x3730, 0x12}, { 0x3733, 0x10}, { 0x3764, 0x00}, { 0x3765, 0x00}, { 0x3769, 0x62}, { 0x376a, 0x2a}, { 0x376b, 0x30}, { 0x3780, 0x00}, { 0x3781, 0x24}, { 0x3782, 0x00}, { 0x3783, 0x23}, { 0x3798, 0x2f}, { 0x37a1, 0x60}, { 0x37a8, 0x6a}, { 0x37ab, 0x3f}, { 0x37c2, 0x14}, { 0x37c3, 0xf1}, { 0x37c9, 0x80}, { 0x37cb, 0x16}, { 0x37cc, 0x16}, { 0x37cd, 0x16}, { 0x37ce, 0x16}, {
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。