hi_comm_3a.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. /******************************************************************************
  2. Copyright (C), 2016, Hisilicon Tech. Co., Ltd.
  3. ******************************************************************************
  4. File Name : hi_comm_3a.h
  5. Version : Initial Draft
  6. Author : Hisilicon multimedia software group
  7. Created : 2012/12/18
  8. Description :
  9. History :
  10. 1.Date : 2012/12/18
  11. Author :
  12. Modification: Created file
  13. ******************************************************************************/
  14. #ifndef __HI_COMM_3A_H__
  15. #define __HI_COMM_3A_H__
  16. #include "hi_common.h"
  17. #include "hi_comm_isp.h"
  18. #include "hi_comm_sns.h"
  19. #ifdef __cplusplus
  20. #if __cplusplus
  21. extern "C" {
  22. #endif
  23. #endif /* End of #ifdef __cplusplus */
  24. #define IS_LINEAR_MODE(mode) (WDR_MODE_NONE == (mode))
  25. #define IS_WDR_MODE(mode) ((!IS_LINEAR_MODE(mode)) && ((mode) < WDR_MODE_BUTT))
  26. #define IS_HDR_MODE(mode) (((mode) > DYNAMIC_RANGE_SDR10) && ((mode) < DYNAMIC_RANGE_BUTT))
  27. #define IS_BUILT_IN_WDR_MODE(mode) (WDR_MODE_BUILT_IN == (mode))
  28. #define IS_FS_WDR_MODE(mode) ((!IS_LINEAR_MODE(mode))&& (!IS_BUILT_IN_WDR_MODE(mode)) && ((mode) < WDR_MODE_BUTT))
  29. #define IS_2to1_WDR_MODE(mode) ((WDR_MODE_2To1_FRAME == (mode)) || (WDR_MODE_2To1_FRAME_FULL_RATE == (mode)) || (WDR_MODE_2To1_LINE == (mode)) || (WDR_MODE_QUDRA == (mode)))
  30. #define IS_3to1_WDR_MODE(mode) ((WDR_MODE_3To1_FRAME == (mode)) || (WDR_MODE_3To1_FRAME_FULL_RATE == (mode)) || (WDR_MODE_3To1_LINE == (mode)))
  31. #define IS_4to1_WDR_MODE(mode) ((WDR_MODE_4To1_FRAME == (mode)) || (WDR_MODE_4To1_FRAME_FULL_RATE == (mode)) || (WDR_MODE_4To1_LINE == (mode)))
  32. #define IS_FULL_WDR_MODE(mode) ((WDR_MODE_2To1_FRAME_FULL_RATE == (mode)) || (WDR_MODE_3To1_FRAME_FULL_RATE == (mode)) || (WDR_MODE_4To1_FRAME_FULL_RATE == (mode)))
  33. #define IS_HALF_WDR_MODE(mode) ((WDR_MODE_2To1_FRAME == (mode)) || (WDR_MODE_3To1_FRAME == (mode)) || (WDR_MODE_4To1_FRAME == (mode)))
  34. #define IS_LINE_WDR_MODE(mode) ((WDR_MODE_2To1_LINE == (mode)) || (WDR_MODE_3To1_LINE == (mode)) || (WDR_MODE_4To1_LINE == (mode)) || (WDR_MODE_QUDRA == (mode)))
  35. #define IS_STITCH_MAIN_PIPE(ViPipe,MainPipe) ((ViPipe) == (MainPipe))
  36. #define IS_OFFLINE_MODE(mode) (ISP_MODE_RUNNING_OFFLINE == (mode))
  37. #define IS_ONLINE_MODE(mode) (ISP_MODE_RUNNING_ONLINE == (mode))
  38. #define IS_SIDEBYSIDE_MODE(mode) (ISP_MODE_RUNNING_SIDEBYSIDE == (mode))
  39. #define IS_STRIPING_MODE(mode) (ISP_MODE_RUNNING_STRIPING == (mode))
  40. #define MAX_REGISTER_ALG_LIB_NUM 2
  41. typedef enum hiISP_ALG_MOD_E
  42. {
  43. ISP_ALG_AE = 0,
  44. ISP_ALG_AF,
  45. ISP_ALG_AWB,
  46. //ISP_ALG_ANTIFOG,
  47. ISP_ALG_BLC,
  48. ISP_ALG_FELOGLUT,
  49. ISP_ALG_LOGLUT,
  50. ISP_ALG_DP,
  51. ISP_ALG_PREGAMMA,
  52. ISP_ALG_DRC,
  53. ISP_ALG_DEMOSAIC,
  54. ISP_ALG_ANTIFALSECOLOR,
  55. ISP_ALG_GAMMA,
  56. ISP_ALG_GE,
  57. //ISP_ALG_NEW_ANTIFOG,
  58. //ISP_ALG_NR,
  59. ISP_ALG_SHARPEN,
  60. ISP_ALG_EDGEAMRK,
  61. //ISP_ALG_SHADING,
  62. ISP_ALG_FrameWDR,
  63. ISP_ALG_FPN,
  64. ISP_ALG_DEHAZE,
  65. ISP_ALG_ACM,
  66. ISP_ALG_LCAC,
  67. ISP_ALG_GCAC,
  68. ISP_ALG_CSC,
  69. ISP_ALG_EXPANDER,
  70. ISP_ALG_MCDS,
  71. ISP_ALG_LSC,
  72. ISP_ALG_RLSC,
  73. ISP_ALG_FeLSC,
  74. ISP_ALG_RC,
  75. ISP_ALG_RGBIR,
  76. ISP_ALG_HRS,
  77. ISP_ALG_DG,
  78. //ISP_ALG_BAS,
  79. ISP_ALG_BAYERNR,
  80. ISP_ALG_COMM,
  81. ISP_ALG_FLICKER,
  82. ISP_ALG_SPLIT,
  83. ISP_ALG_DCI,
  84. ISP_ALG_LDCI,
  85. ISP_ALG_CA,
  86. ISP_ALG_NDDM,
  87. ISP_ALG_BUTT,
  88. ISP_ALG_CLUT,
  89. /*HDR_Related*/
  90. ISP_ALG_DEGAMMA,
  91. ISP_ALG_CUS,
  92. ISP_ALG_CC,
  93. ISP_ALG_CDS,
  94. ISP_ALG_OETF,
  95. ISP_ALG_OETF_HDR,
  96. ISP_ALG_TM,
  97. ISP_ALG_CLUTHDR,
  98. ISP_ALG_CC2,
  99. ISP_ALG_HDRCSC,
  100. /*HDR_Related_End*/
  101. ISP_ALG_DETAIL,
  102. } ISP_ALG_MOD_E;
  103. typedef enum hiISP_CTRL_CMD_E
  104. {
  105. ISP_WDR_MODE_SET = 8000,
  106. ISP_PROC_WRITE,
  107. ISP_AE_FPS_BASE_SET,
  108. ISP_AE_BLC_SET,
  109. ISP_AE_RC_SET,
  110. ISP_AE_BAYER_FORMAT_SET,
  111. ISP_AWB_ISO_SET, /* set iso, change saturation when iso change */
  112. ISP_CHANGE_IMAGE_MODE_SET,
  113. ISP_UPDATE_INFO_GET,
  114. ISP_FRAMEINFO_GET,
  115. ISP_ATTACHINFO_GET,
  116. ISP_COLORGAMUTINFO_GET,
  117. ISP_AWB_INTTIME_SET,
  118. ISP_BAS_MODE_SET,
  119. ISP_PROTRIGGER_SET,
  120. ISP_AWB_PIRIS_SET,
  121. ISP_AWB_SNAP_MODE_SET,
  122. ISP_CTRL_CMD_BUTT,
  123. } ISP_CTRL_CMD_E;
  124. typedef struct hiISP_CTRL_PROC_WRITE_S
  125. {
  126. HI_CHAR *pcProcBuff;
  127. HI_U32 u32BuffLen;
  128. HI_U32 u32WriteLen; /* The len count should contain '\0'. */
  129. } ISP_CTRL_PROC_WRITE_S;
  130. typedef struct hiISP_STITCH_ATTR_S
  131. {
  132. HI_BOOL bStitchEnable;
  133. HI_BOOL bMainPipe;
  134. HI_U8 u8StitchPipeNum;
  135. HI_S8 as8StitchBindId[VI_MAX_PIPE_NUM];
  136. } ISP_STITCH_ATTR_S;
  137. /******************************** AE *************************************/
  138. /* the init param of ae alg */
  139. typedef struct hiISP_AE_PARAM_S
  140. {
  141. SENSOR_ID SensorId;
  142. HI_U8 u8WDRMode;
  143. HI_U8 u8HDRMode;
  144. HI_U16 u16BlackLevel;
  145. HI_FLOAT f32Fps;
  146. ISP_BAYER_FORMAT_E enBayer;
  147. ISP_STITCH_ATTR_S stStitchAttr;
  148. HI_S32 s32Rsv;
  149. } ISP_AE_PARAM_S;
  150. /* the statistics of ae alg */
  151. typedef struct hiISP_FE_AE_STAT_1_S
  152. {
  153. HI_U32 u32PixelCount[ISP_CHN_MAX_NUM];
  154. HI_U32 u32PixelWeight[ISP_CHN_MAX_NUM];
  155. HI_U32 au32HistogramMemArray[ISP_CHN_MAX_NUM][1024];
  156. } ISP_FE_AE_STAT_1_S;
  157. typedef struct hiISP_FE_AE_STAT_2_S
  158. {
  159. HI_U16 u16GlobalAvgR[ISP_CHN_MAX_NUM];
  160. HI_U16 u16GlobalAvgGr[ISP_CHN_MAX_NUM];
  161. HI_U16 u16GlobalAvgGb[ISP_CHN_MAX_NUM];
  162. HI_U16 u16GlobalAvgB[ISP_CHN_MAX_NUM];
  163. } ISP_FE_AE_STAT_2_S;
  164. typedef struct hiISP_FE_AE_STAT_3_S
  165. {
  166. HI_U16 au16ZoneAvg[ISP_CHN_MAX_NUM][AE_ZONE_ROW][AE_ZONE_COLUMN][4];
  167. } ISP_FE_AE_STAT_3_S;
  168. typedef struct hiISP_FE_AE_STITCH_STAT_3_S
  169. {
  170. HI_U16 au16ZoneAvg[VI_MAX_PIPE_NUM][ISP_CHN_MAX_NUM][AE_ZONE_ROW][AE_ZONE_COLUMN][4];
  171. } ISP_FE_AE_STITCH_STAT_3_S;
  172. typedef struct hiISP_BE_AE_STAT_1_S
  173. {
  174. HI_U32 u32PixelCount;
  175. HI_U32 u32PixelWeight;
  176. HI_U32 au32HistogramMemArray[1024];
  177. } ISP_BE_AE_STAT_1_S;
  178. typedef struct hiISP_BE_AE_STAT_2_S
  179. {
  180. HI_U16 u16GlobalAvgR;
  181. HI_U16 u16GlobalAvgGr;
  182. HI_U16 u16GlobalAvgGb;
  183. HI_U16 u16GlobalAvgB;
  184. } ISP_BE_AE_STAT_2_S;
  185. typedef struct hiISP_BE_AE_STAT_3_S
  186. {
  187. HI_U16 au16ZoneAvg[AE_ZONE_ROW][AE_ZONE_COLUMN][4];
  188. } ISP_BE_AE_STAT_3_S;
  189. typedef struct hiISP_BE_AE_STITCH_STAT_3_S
  190. {
  191. HI_U16 au16ZoneAvg[VI_MAX_PIPE_NUM][AE_ZONE_ROW][AE_ZONE_COLUMN][4];
  192. } ISP_BE_AE_STITCH_STAT_3_S;
  193. typedef struct hiISP_AE_INFO_S
  194. {
  195. HI_U32 u32FrameCnt; /* the counting of frame */
  196. ISP_FE_AE_STAT_1_S *pstFEAeStat1;
  197. ISP_FE_AE_STAT_2_S *pstFEAeStat2;
  198. ISP_FE_AE_STAT_3_S *pstFEAeStat3;
  199. ISP_FE_AE_STITCH_STAT_3_S *pstFEAeStiStat;
  200. ISP_BE_AE_STAT_1_S *pstBEAeStat1;
  201. ISP_BE_AE_STAT_2_S *pstBEAeStat2;
  202. ISP_BE_AE_STAT_3_S *pstBEAeStat3;
  203. ISP_BE_AE_STITCH_STAT_3_S *pstBEAeStiStat;
  204. } ISP_AE_INFO_S;
  205. typedef struct hiISP_AE_STAT_ATTR_S
  206. {
  207. HI_BOOL bChange;
  208. HI_BOOL bHistAdjust;
  209. HI_U8 u8AEBESel;
  210. HI_U8 u8FourPlaneMode;
  211. HI_U8 u8HistOffsetX;
  212. HI_U8 u8HistOffsetY;
  213. HI_U8 u8HistSkipX;
  214. HI_U8 u8HistSkipY;
  215. HI_BOOL bModeUpdate;
  216. HI_U8 u8HistMode;
  217. HI_U8 u8AverMode;
  218. HI_U8 u8MaxGainMode;
  219. HI_BOOL bWightTableUpdate;
  220. HI_U8 au8WeightTable[VI_MAX_PIPE_NUM][AE_ZONE_ROW][AE_ZONE_COLUMN];
  221. } ISP_AE_STAT_ATTR_S;
  222. /* the final calculate of ae alg */
  223. #define AE_INT_TIME_NUM (4)
  224. typedef struct hiISP_AE_RESULT_S
  225. {
  226. HI_U32 u32IntTime[AE_INT_TIME_NUM];
  227. HI_U32 u32IspDgain;
  228. HI_U32 u32Again;
  229. HI_U32 u32Dgain;
  230. HI_U32 u32Iso;
  231. HI_U8 u8AERunInterval;
  232. HI_BOOL bPirisValid;
  233. HI_S32 s32PirisPos;
  234. HI_U32 u32PirisGain;
  235. ISP_FSWDR_MODE_E enFSWDRMode;
  236. HI_U32 au32WDRGain[4];
  237. HI_U32 u32HmaxTimes; /* unit is ns */
  238. ISP_AE_STAT_ATTR_S stStatAttr;
  239. ISP_DCF_UPDATE_INFO_S stUpdateInfo;
  240. } ISP_AE_RESULT_S;
  241. typedef struct hiISP_AE_EXP_FUNC_S
  242. {
  243. HI_S32 (*pfn_ae_init)(HI_S32 s32Handle, const ISP_AE_PARAM_S *pstAeParam);
  244. HI_S32 (*pfn_ae_run)(HI_S32 s32Handle,
  245. const ISP_AE_INFO_S *pstAeInfo,
  246. ISP_AE_RESULT_S *pstAeResult,
  247. HI_S32 s32Rsv
  248. );
  249. HI_S32 (*pfn_ae_ctrl)(HI_S32 s32Handle, HI_U32 u32Cmd, HI_VOID *pValue);
  250. HI_S32 (*pfn_ae_exit)(HI_S32 s32Handle);
  251. } ISP_AE_EXP_FUNC_S;
  252. typedef struct hiISP_AE_REGISTER_S
  253. {
  254. ISP_AE_EXP_FUNC_S stAeExpFunc;
  255. } ISP_AE_REGISTER_S;
  256. /******************************** AWB *************************************/
  257. typedef enum hiAWB_CTRL_CMD_E
  258. {
  259. AWB_CCM_CONFIG_SET,
  260. AWB_CCM_CONFIG_GET,
  261. AWB_DEBUG_ATTR_SET,
  262. AWB_DEBUG_ATTR_GET,
  263. AWB_CTRL_BUTT,
  264. } AWB_CTRL_CMD_E;
  265. typedef struct hiAWB_CCM_CONFIG_S
  266. {
  267. HI_BOOL bAWBBypassEn;
  268. HI_BOOL bManualSatEn;
  269. HI_BOOL bManualTempEn;
  270. HI_U32 u32ManualSatValue;
  271. HI_U32 u32ManualTempValue;
  272. HI_U16 u16CCMSpeed;
  273. HI_U16 au16HighCCM[9];
  274. HI_U16 au16LowCCM[9];
  275. HI_U16 u16HighColorTemp;
  276. HI_U16 u16LowColorTemp;
  277. } AWB_CCM_CONFIG_S;
  278. /* the init param of awb alg */
  279. typedef struct hiISP_AWB_PARAM_S
  280. {
  281. SENSOR_ID SensorId;
  282. HI_U8 u8WDRMode;
  283. HI_U8 u8AWBZoneRow;
  284. HI_U8 u8AWBZoneCol;
  285. HI_U8 u8AWBZoneBin;
  286. ISP_STITCH_ATTR_S stStitchAttr;
  287. HI_U16 u16AWBWidth;
  288. HI_U16 u16AWBHeight;
  289. HI_S8 s8Rsv;
  290. } ISP_AWB_PARAM_S;
  291. /* the statistics of awb alg */
  292. typedef struct hiISP_AWB_STAT_1_S
  293. {
  294. HI_U16 u16MeteringAwbAvgR;
  295. HI_U16 u16MeteringAwbAvgG;
  296. HI_U16 u16MeteringAwbAvgB;
  297. HI_U16 u16MeteringAwbCountAll;
  298. } ISP_AWB_STAT_1_S;
  299. typedef struct hiISP_AWB_STAT_2_S
  300. {
  301. HI_U16 au16MeteringMemArrayAvgR[AWB_ZONE_NUM];
  302. HI_U16 au16MeteringMemArrayAvgG[AWB_ZONE_NUM];
  303. HI_U16 au16MeteringMemArrayAvgB[AWB_ZONE_NUM];
  304. HI_U16 au16MeteringMemArrayCountAll[AWB_ZONE_NUM];
  305. } ISP_AWB_STAT_2_S;
  306. typedef struct hiISP_AWB_STAT_STITCH_S
  307. {
  308. HI_U16 u16ZoneCol;
  309. HI_U16 u16ZoneRow;
  310. HI_U16 u16ZoneBin;
  311. HI_U16 au16MeteringMemArrayAvgR[AWB_ZONE_STITCH_MAX];
  312. HI_U16 au16MeteringMemArrayAvgG[AWB_ZONE_STITCH_MAX];
  313. HI_U16 au16MeteringMemArrayAvgB[AWB_ZONE_STITCH_MAX];
  314. HI_U16 au16MeteringMemArrayCountAll[AWB_ZONE_STITCH_MAX];
  315. } ISP_AWB_STAT_STITCH_S;
  316. typedef struct hiISP_AWB_STAT_RESULT_S
  317. {
  318. HI_U16 *pau16ZoneAvgR;
  319. HI_U16 *pau16ZoneAvgG;
  320. HI_U16 *pau16ZoneAvgB;
  321. HI_U16 *pau16ZoneCount;
  322. } ISP_AWB_STAT_RESULT_S;
  323. typedef struct hiISP_AWB_INFO_S
  324. {
  325. HI_U32 u32FrameCnt;
  326. ISP_AWB_STAT_1_S *pstAwbStat1;
  327. ISP_AWB_STAT_RESULT_S stAwbStat2;
  328. } ISP_AWB_INFO_S;
  329. /* the statistics's attr of awb alg */
  330. typedef struct hiISP_AWB_RAW_STAT_ATTR_S
  331. {
  332. HI_BOOL bStatCfgUpdate;
  333. HI_U16 u16MeteringWhiteLevelAwb;
  334. HI_U16 u16MeteringBlackLevelAwb;
  335. HI_U16 u16MeteringCrRefMaxAwb;
  336. HI_U16 u16MeteringCbRefMaxAwb;
  337. HI_U16 u16MeteringCrRefMinAwb;
  338. HI_U16 u16MeteringCbRefMinAwb;
  339. } ISP_AWB_RAW_STAT_ATTR_S;
  340. /* the final calculate of awb alg */
  341. typedef struct hiISP_AWB_RESULT_S
  342. {
  343. HI_U32 au32WhiteBalanceGain[ISP_BAYER_CHN_NUM];
  344. HI_U16 au16ColorMatrix[CCM_MATRIX_SIZE];
  345. HI_U32 u32ColorTemp;
  346. HI_U8 u8Saturation;
  347. ISP_AWB_RAW_STAT_ATTR_S stRawStatAttr;
  348. } ISP_AWB_RESULT_S;
  349. typedef struct hiISP_AWB_EXP_FUNC_S
  350. {
  351. HI_S32 (*pfn_awb_init)(HI_S32 s32Handle, const ISP_AWB_PARAM_S *pstAwbParam);
  352. HI_S32 (*pfn_awb_run)(HI_S32 s32Handle,
  353. const ISP_AWB_INFO_S *pstAwbInfo,
  354. ISP_AWB_RESULT_S *pstAwbResult,
  355. HI_S32 s32Rsv
  356. );
  357. HI_S32 (*pfn_awb_ctrl)(HI_S32 s32Handle, HI_U32 u32Cmd, HI_VOID *pValue);
  358. HI_S32 (*pfn_awb_exit)(HI_S32 s32Handle);
  359. } ISP_AWB_EXP_FUNC_S;
  360. typedef struct hiISP_AWB_REGISTER_S
  361. {
  362. ISP_AWB_EXP_FUNC_S stAwbExpFunc;
  363. } ISP_AWB_REGISTER_S;
  364. /******************************** AF *************************************/
  365. /* the statistics of af alg */
  366. typedef struct hiISP_AF_ZONE_S
  367. {
  368. HI_U16 u16v1;
  369. HI_U16 u16h1;
  370. HI_U16 u16v2;
  371. HI_U16 u16h2;
  372. HI_U16 u16y;
  373. HI_U16 u16HlCnt;
  374. } ISP_AF_ZONE_S;
  375. typedef struct hiISP_AF_STAT_S
  376. {
  377. ISP_AF_ZONE_S stZoneMetrics[WDR_CHN_MAX][AF_ZONE_ROW][AF_ZONE_COLUMN]; /*R; The zoned measure of contrast*/
  378. } ISP_AF_STAT_S;
  379. #define ALG_LIB_NAME_SIZE_MAX (20)
  380. typedef struct hiALG_LIB_S
  381. {
  382. HI_S32 s32Id;
  383. HI_CHAR acLibName[ALG_LIB_NAME_SIZE_MAX];
  384. } ALG_LIB_S;
  385. typedef struct hiISP_BIND_ATTR_S
  386. {
  387. SENSOR_ID SensorId;
  388. ALG_LIB_S stAeLib;
  389. ALG_LIB_S stAfLib;
  390. ALG_LIB_S stAwbLib;
  391. } ISP_BIND_ATTR_S;
  392. #ifdef __cplusplus
  393. #if __cplusplus
  394. }
  395. #endif
  396. #endif /* End of #ifdef __cplusplus */
  397. #endif /*__HI_COMM_SNS_H__ */