Camera Driver analysis in the platform of MTK
Preliminary Information
3、 添加 Camera 驱动(以 ov5647 为例):
创建 SensorFuncOV5647 这样一个数据结构 SENSOR_FUNCTION_STRUCT SensorFuncOV5647= { OV5647Open,
OV5647GetInfo, OV5647GetResolution, OV5647FeatureControl,
OV5647Control, OV5647Close};
- 19 -
Ghong Confidential
Revision 0.1-Feb.14 2012
?2012 Ghong inc.
Camera Driver analysis in the platform of MTK
a) OV5647Open
Preliminary Information
初始化操作就是对 SensorIC 中寄存器的操作,调试主要由 IC 原厂支持。Open 函数结
束后返回 ERROR_NONE 表示初始化成功,可以正常使用。
b) OV5647GetInfo
UINT32 OV5647GetInfo(MSDK_SCENARIO_ID_ENUM ScenarioId, MSDK_SENSOR_INFO_STRUCT *pSensorInfo,
MSDK_SENSOR_CONFIG_STRUCT *pSensorConfigData)
第一个参数 ScenarioId 来自于 MSDK_SCENARIO_ID_ENUM 这个数组,在
kd_imgsensor_define.h 中是这样定义的: #define MSDK_SCENARIO_ID_ENUM typedef enum {
ACDK_SCENARIO_ID_CAMERA_PREVIEW=0, ACDK_SCENARIO_ID_VIDEO_PREVIEW, ACDK_SCENARIO_ID_VIDEO_CAPTURE_MPEG4, ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG, ACDK_SCENARIO_ID_CAMERA_CAPTURE_MEM, ACDK_SCENARIO_ID_CAMERA_BURST_CAPTURE_JPEG, ACDK_SCENARIO_ID_VIDEO_DECODE_MPEG4, ACDK_SCENARIO_ID_VIDEO_DECODE_H263, ACDK_SCENARIO_ID_VIDEO_DECODE_H264, ACDK_SCENARIO_ID_VIDEO_DECODE_WMV78, ACDK_SCENARIO_ID_VIDEO_DECODE_WMV9, ACDK_SCENARIO_ID_VIDEO_DECODE_MPEG2, ACDK_SCENARIO_ID_IMAGE_YUV2RGB,
ACDK_SCENARIO_ID_ENUM
ACDK_SCENARIO_ID_IMAGE_RESIZE,
ACDK_SCENARIO_ID_IMAGE_ROTATE, Ghong Confidential Revision 0.1-Feb.14 2012
?2012 Ghong inc.
- 20 -
Camera Driver analysis in the platform of MTK
ACDK_SCENARIO_ID_IMAGE_POST_PROCESS, ACDK_SCENARIO_ID_JPEG_RESIZE, ACDK_SCENARIO_ID_JPEG_DECODE, ACDK_SCENARIO_ID_JPEG_PARSE, ACDK_SCENARIO_ID_JPEG_ENCODE,
ACDK_SCENARIO_ID_JPEG_ENCODE_THUMBNAIL, ACDK_SCENARIO_ID_DRIVER_IO_CONTROL, ACDK_SCENARIO_ID_DO_NOT_CARE,
ACDK_SCENARIO_ID_IMAGE_DSPL_BUFFER_ALLOC, ACDK_SCENARIO_ID_TV_OUT,
Preliminary Information
ACDK_SCENARIO_ID_MAX,
ACDK_SCENARIO_ID_VIDOE_ENCODE_WITHOUT_PREVIEW, ACDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG_BACK_PREVIEW, ACDK_SCENARIO_ID_VIDEO_DECODE_RV8, ACDK_SCENARIO_ID_VIDEO_DECODE_RV9,
} ACDK_SCENARIO_ID_ENUM;
ACDK_SCENARIO_ID_CAMERA_ZSD,
通过这个数组定义 Camera 的各种模式,并且给他们从 0 开始给一个模拟的 ID,通过这个
ScenarioID 来控制 Camera 的工作模式是在拍照、摄像等等。
想要了解*pSensorInfo 这个指针的内容就得看 MSDK_SENSOR_INFO_STRUCT 的定义
#define MSDK_SENSOR_INFO_STRUCT ACDK_SENSOR_INFO_STRUCT typedef struct {
MUINT16 SensorPreviewResolutionX; MUINT16 SensorPreviewResolutionY; MUINT16 SensorFullResolutionX; MUINT16 SensorFullResolutionY; MUINT8 SensorClockFreq;
/* MHz */
MUINT8 SensorCameraPreviewFrameRate; MUINT8 SensorVideoFrameRate; MUINT8 SensorStillCaptureFrameRate;
MUINT8 SensorWebCamCaptureFrameRate; MUINT8
SensorClockPolarity;
/*
SENSOR_CLOCK_POLARITY_HIGH/SENSOR_CLOCK_POLARITY_Low */
Ghong Confidential
Revision 0.1-Feb.14 2012
?2012 Ghong inc.
- 21 -
Camera Driver analysis in the platform of MTK
MUINT8 SensorClockFallingPolarity; MUINT8 SensorClockRisingCount; MUINT8 SensorClockFallingCount; MUINT8 SensorClockDividCount; MUINT8 SensorPixelClockCount; MUINT8 SensorDataLatchCount; MUINT8 SensorHsyncPolarity; MUINT8 SensorVsyncPolarity; MUINT8 SensorInterruptDelayLines; MINT32 SensorResetActiveHigh; MUINT32 SensorResetDelayCount;
ACDK_SENSOR_INTERFACE_TYPE_ENUM SensroInterfaceType;
/* 0..15 */
Preliminary Information
/* 0..15 */
/* 0..15 */
/* 0..15 */
/* 0..15 */
ACDK_SENSOR_OUTPUT_DATA_FORMAT_ENUM SensorOutputDataFormat; ACDK_SENSOR_MIPI_LANE_NUMBER_ENUM SensorMIPILaneNumber; CAMERA_ISO_BINNING_INFO_STRUCT SensorISOBinningInfo; MUINT32 CaptureDelayFrame; MUINT32 PreviewDelayFrame; MUINT32 VideoDelayFrame; MUINT16 SensorGrabStartX; MUINT16 SensorGrabStartY; MUINT16 SensorDrivingCurrent; MUINT8 MUINT8
/* The frame of setting shutter default 0 for TG
SensorMasterClockSwitch; AEShutDelayFrame;
int */ MUINT8 MUINT8 MUINT8 MUINT8 MUINT8 MUINT8 MUINT8 MUINT8
AESensorGainDelayFrame; AEISPGainDelayFrame;
/* The frame of setting sensor gain */
MIPIDataLowPwr2HighSpeedTermDelayCount; MIPIDataLowPwr2HighSpeedSettleDelayCount; MIPICLKLowPwr2HighSpeedTermDelayCount; SensorWidthSampling; SensorHightSampling; SensorPacketECCOrder;
MUINT8 SensorDriver3D;
} ACDK_SENSOR_INFO_STRUCT, *PACDK_SENSOR_INFO_STRUCT;
Ghong Confidential Revision 0.1-Feb.14 2012
?2012 Ghong inc.
- 22 -