源码平台:rk3399
RK支持了很多个摄像头,在驱动目录hardware/rockchip/camera/SiliconImage/isi/drv可以看到源码,已经支持的摄像头在cam_board.xml 配置一般就可以了,包括硬件的引脚等等,
我们先看看配置文件/etc/cam_board.xml 的内容
<?xml version="1.0" ?>
<BoardFile>
<BoardXmlVersion version="v0.0xf.0">
</BoardXmlVersion>
<CamDevie>
<HardWareInfo>
<Sensor>
<SensorName name="OV13850" ></SensorName>
<SensorLens name="50013A1"></SensorLens>
<SensorDevID IDname="CAMSYS_DEVID_SENSOR_1A"></SensorDevID>
<SensorHostDevID busnum="CAMSYS_DEVID_MARVIN" ></SensorHostDevID>
<SensorI2cBusNum busnum="1"></SensorI2cBusNum>
<SensorI2cAddrByte byte="2"></SensorI2cAddrByte>
<SensorI2cRate rate="100000"></SensorI2cRate>
<SensorAvdd name="NC" min="28000000" max="28000000" delay="0"></SensorAvdd>
<SensorDvdd name="NC" min="12000000" max="12000000" delay="0"></SensorDvdd>
<SensorDovdd name="NC" min="18000000" max="18000000" delay="5000"></SensorDovdd>
<SensorMclk mclk="24000000" delay="1000"></SensorMclk>
<SensorGpioPwen ioname="RK30_PIN1_PC7" active="1" delay="1000"></SensorGpioPwen>
<SensorGpioRst ioname="RK30_PIN0_PB0" active="0" delay="1000"></SensorGpioRst>
<SensorGpioPwdn ioname="NC" active="0" delay="0"></SensorGpioPwdn>
<SensorFacing facing="back"></SensorFacing>
<SensorInterface interface="MIPI"></SensorInterface>
<SensorMirrorFlip mirror="0"></SensorMirrorFlip>
<SensorOrientation orientation="180"></SensorOrientation>
<SensorPowerupSequence seq="1234"></SensorPowerupSequence>
<SensorFovParemeter h="60.0" v="60.0"></SensorFovParemeter>
<SensorAWB_Frame_Skip fps="15"></SensorAWB_Frame_Skip>
<SensorPhy phyMode="CamSys_Phy_Mipi" lane="2" phyIndex="0" sensorFmt="CamSys_Fmt_Raw_10b"></SensorPhy>
</Sensor>
<VCM>
<VCMDrvName name="DW9714"></VCMDrvName>
<VCMName name="HuaYong6505"></VCMName>
<VCMI2cBusNum busnum="1"></VCMI2cBusNum>
<VCMI2cAddrByte byte="0"></VCMI2cAddrByte>
<VCMI2cRate rate="0"></VCMI2cRate>
<VCMVdd name="NC" min="0" max="0" delay="0"></VCMVdd>
<VCMGpioPower ioname="NC" active="0" delay="1000"></VCMGpioPower>
<VCMGpioPwdn ioname="NC" active="0" delay="0"></VCMGpioPwdn>
<VCMCurrent start="20" rated="80" vcmmax="100" stepmode="13" drivermax="100"></VCMCurrent>
</VCM>
<Flash>
<FlashName name="Internal"></FlashName>
<FlashI2cBusNum busnum="0"></FlashI2cBusNum>
<FlashI2cAddrByte byte="0"></FlashI2cAddrByte>
<FlashI2cRate rate="0"></FlashI2cRate>
<FlashTrigger ioname="NC" active="0"></FlashTrigger>
<FlashEn ioname="NC" active="0"></FlashEn>
<FlashModeType mode="1"></FlashModeType>
<FlashLuminance luminance="0"></FlashLuminance>
<FlashColorTemp colortemp="0"></FlashColorTemp>
</Flash>
</HardWareInfo>
<SoftWareInfo>
<AWB>
<AWB_Auto support="1"></AWB_Auto>
<AWB_Incandescent support="1"></AWB_Incandescent>
<AWB_Fluorescent support="1"></AWB_Fluorescent>
<AWB_Warm_Fluorescent support="1"></AWB_Warm_Fluorescent>
<AWB_Daylight support="1"></AWB_Daylight>
<AWB_Cloudy_Daylight support="1"></AWB_Cloudy_Daylight>
<AWB_Twilight support="1"></AWB_Twilight>
<AWB_Shade support="1"></AWB_Shade>
</AWB>
<Sence>
<Sence_Mode_Auto support="1"></Sence_Mode_Auto>
<Sence_Mode_Action support="1"></Sence_Mode_Action>
<Sence_Mode_Portrait support="1"></Sence_Mode_Portrait>
<Sence_Mode_Landscape support="1"></Sence_Mode_Landscape>
<Sence_Mode_Night support="1"></Sence_Mode_Night>
<Sence_Mode_Night_Portrait support="1"></Sence_Mode_Night_Portrait>
<Sence_Mode_Theatre support="1"></Sence_Mode_Theatre>
<Sence_Mode_Beach support="1"></Sence_Mode_Beach>
<Sence_Mode_Snow support="1"></Sence_Mode_Snow>
<Sence_Mode_Sunset support="1"></Sence_Mode_Sunset>
<Sence_Mode_Steayphoto support="1"></Sence_Mode_Steayphoto>
<Sence_Mode_Pireworks support="1"></Sence_Mode_Pireworks>
<Sence_Mode_Sports support="1"></Sence_Mode_Sports>
<Sence_Mode_Party support="1"></Sence_Mode_Party>
<Sence_Mode_Candlelight support="1"></Sence_Mode_Candlelight>
<Sence_Mode_Barcode support="1"></Sence_Mode_Barcode>
<Sence_Mode_HDR support="1"></Sence_Mode_HDR>
</Sence>
<Effect>
<Effect_None support="1"></Effect_None>
<Effect_Mono support="1"></Effect_Mono>
<Effect_Solarize support="1"></Effect_Solarize>
<Effect_Negative support="1"></Effect_Negative>
<Effect_Sepia support="1"></Effect_Sepia>
<Effect_Posterize support="1"></Effect_Posterize>
<Effect_Whiteboard support="1"></Effect_Whiteboard>
<Effect_Blackboard support="1"></Effect_Blackboard>
<Effect_Aqua support="1"></Effect_Aqua>
</Effect>
<FocusMode>
<Focus_Mode_Auto support="1"></Focus_Mode_Auto>
<Focus_Mode_Infinity support="1"></Focus_Mode_Infinity>
<Focus_Mode_Marco support="1"></Focus_Mode_Marco>
<Focus_Mode_Fixed support="1"></Focus_Mode_Fixed>
<Focus_Mode_Edof support="1"></Focus_Mode_Edof>
<Focus_Mode_Continuous_Video support="0"></Focus_Mode_Continuous_Video>
<Focus_Mode_Continuous_Picture support="1"></Focus_Mode_Continuous_Picture>
</FocusMode>
<FlashMode>
<Flash_Mode_Off support="1"></Flash_Mode_Off>
<Flash_Mode_On support="1"></Flash_Mode_On>
<Flash_Mode_Torch support="1"></Flash_Mode_Torch>
<Flash_Mode_Auto support="1"></Flash_Mode_Auto>
<Flash_Mode_Red_Eye support="1"></Flash_Mode_Red_Eye>
</FlashMode>
<AntiBanding>
<Anti_Banding_Auto support="1"></Anti_Banding_Auto>
<Anti_Banding_50HZ support="1"></Anti_Banding_50HZ>
<Anti_Banding_60HZ support="1"></Anti_Banding_60HZ>
<Anti_Banding_Off support="1"></Anti_Banding_Off>
</AntiBanding>
<HDR support="1"></HDR>
<ZSL support="1"></ZSL>
<DigitalZoom support="1"></DigitalZoom>
<Continue_SnapShot support="1"></Continue_SnapShot>
<InterpolationRes resolution="0"></InterpolationRes>
<PreviewSize width="1920" height="1080"></PreviewSize>
<FaceDetect support="0" MaxNum="1"></FaceDetect>
<DV>
<DV_QCIF name="qcif" width="176" height="144" fps="10" support="1"></DV_QCIF>
<DV_QVGA name="qvga" width="320" height="240" fps="10" support="1"></DV_QVGA>
<DV_CIF name="cif" width="352" height="288" fps="10" support="1"></DV_CIF>
<DV_VGA name="480p" width="640" height="480" fps="10" support="0"></DV_VGA>
<DV_480P name="480p" width="720" height="480" fps="10" support="0"></DV_480P>
<DV_720P name="720p" width="1280" height="720" fps="10" support="1"></DV_720P>
<DV_1080P name="1080p" width="1920" height="1080" fps="10" support="1"></DV_1080P>
</DV>
</SoftWareInfo>
</CamDevie>
</BoardFile>
每一个摄像设备包含硬件和软件两部分的配置信息,
硬件信息:Sensor,VCM,Flash
软件信息:AWB(白平衡),Sence(场景),Effect(效果),FocusMode(对焦模式),FlashMode(闪光模式),AntiBanding(),HDR支持,ZSL(零秒延迟),DigitalZoom(缩放),Continue_SnapShot(连拍),InterpolationRes,PreviewSize(预览大小),FaceDetect(脸部检测),DV(数码格式?)
这个文件在HAL层解析,解析后将xml的配置信息保存到下面两个结构体
rk_cam_hardware_info
rk_camera_softinfo_config
我们看看这两个结构体的具体定义:hardware/rockchip/camera/CameraHal/CameraHal_board_xml_parse.h
struct rk_cam_hardware_info{
rk_cam_hardware_info():mIsOTP(false){};
~rk_cam_hardware_info(){};
rk_sensor_info mSensorInfo;
rk_vcm_info mVcmInfo;
rk_flash_info mFlashInfo;
bool mIsOTP;
};
struct rk_camera_softinfo_config{
rk_camera_softinfo_config()
:mZSLConfig(0),
mZoomConfig(0),
mContinue_snapshot_config(0),
mPreviewWidth(800),
mPreviewHeight(600),
mHDRConfig(0),
mInterpolationRes(0),
mFrameRate(0),
touchAE(0){};
~rk_camera_softinfo_config(){};
rk_white_balance_config mAwbConfig;
rk_sence_config mSenceConfig;
rk_effect_config mEffectConfig;
rk_anti_banding_config mAntiBandingConfig;
rk_focus_config mFocusConfig;
rk_flash_config mFlashConfig;
rk_face_detect_info mFaceDetctConfig;
rk_cproc_config mPreCprocConfig;
rk_cproc_config mCapCprocConfig;
rk_gamma_out_config mGammaOutConfig;
int mZSLConfig;
int mZoomConfig;
int mContinue_snapshot_config;
int mPreviewWidth;
int mPreviewHeight;
int mHDRConfig;
int mInterpolationRes;
int mFrameRate;
int touchAE;
Vector<rk_DV_info*> mDV_vector;
};
这些配置选项都对应到cam_board.xml文件的对应的选项.
xml配置选项到代码的配置中,有一些配置是用bit表示支持该功能,比如白平衡的配置
struct rk_white_balance_config{
rk_white_balance_config():mAwbSupport(0),mDefault(0){};
~rk_white_balance_config(){};
unsigned int mAwbSupport;
unsigned int mDefault;
};
我们在白平衡的配置标签中有很多选项,但这里都看不到,为什么?这里其中mAwbSupport这个无符号的整型变量,0到7bit 分别表示了功能,代码解析的时候会将xml支持变成对应的bit选项支持.
#define AWB_AUTO_BITPOS (0)
#define AWB_INCANDESCENT_BITPOS (1)
#define AWB_FLUORESCENT_BITPOS (2)
#define AWB_WARM_FLUORESCENT_BITPOS (3)
#define AWB_DAYLIGHT_BITPOS (4)
#define AWB_CLOUDY_BITPOS (5)
#define AWB_TWILIGHT_BITPOS (6)
#define AWB_SHADE_BITPOS (7)