• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef __HI_SNS_CTRL_H__
17 #define __HI_SNS_CTRL_H__
18 
19 #include "hi_type.h"
20 #include "hi_comm_3a.h"
21 #include "hi_debug.h"
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif /* End of #ifdef __cplusplus */
28 
29 #define ISP_SNS_SAVE_INFO_MAX 2
30 typedef struct hiISP_SNS_STATE_S {
31     HI_BOOL     bInit;                  /* HI_TRUE: Sensor init */
32     HI_BOOL     bSyncInit;              /* HI_TRUE: Sync Reg init */
33     HI_U8       u8ImgMode;
34     HI_U8       u8Hdr;               /* HI_TRUE: HDR enbale */
35     WDR_MODE_E  enWDRMode;
36 
37     ISP_SNS_REGS_INFO_S astRegsInfo[ISP_SNS_SAVE_INFO_MAX]; /* [0]: Sensor reg info of cur-frame;
38                                                                [1]: Sensor reg info of pre-frame */
39 
40     HI_U32      au32FL[ISP_SNS_SAVE_INFO_MAX];     /* [0]: FullLines of cur-frame;
41                                                       [1]: Pre FullLines of pre-frame */
42     HI_U32      u32FLStd;               /* FullLines std */
43     HI_U32      au32WDRIntTime[WDR_MAX_FRAME_NUM];
44     HI_U32      au32SensorWBGain[ISP_BAYER_CHN_NUM];
45 } ISP_SNS_STATE_S;
46 
47 typedef enum hiISP_SNS_MIRRORFLIP_TYPE_E {
48     ISP_SNS_NORMAL      = 0,
49     ISP_SNS_MIRROR      = 1,
50     ISP_SNS_FLIP        = 2,
51     ISP_SNS_MIRROR_FLIP = 3,
52     ISP_SNS_BUTT
53 } ISP_SNS_MIRRORFLIP_TYPE_E;
54 
55 typedef struct hiISP_SNS_BUS_EX_S {
56     char bus_addr;
57 } ISP_SNS_BUS_EX_S;
58 
59 typedef struct hiISP_SNS_OBJ_S {
60     HI_S32 (*pfnRegisterCallback)(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib);
61     HI_S32 (*pfnUnRegisterCallback)(VI_PIPE ViPipe, ALG_LIB_S *pstAeLib, ALG_LIB_S *pstAwbLib);
62     HI_S32 (*pfnSetBusInfo)(VI_PIPE ViPipe, ISP_SNS_COMMBUS_U unSNSBusInfo);
63     HI_S32 (*pfnSetBusExInfo)(VI_PIPE ViPipe, ISP_SNS_BUS_EX_S *pstSerdesInfo);
64     HI_VOID (*pfnStandby)(VI_PIPE ViPipe);
65     HI_VOID (*pfnRestart)(VI_PIPE ViPipe);
66     HI_VOID (*pfnMirrorFlip)(VI_PIPE ViPipe, ISP_SNS_MIRRORFLIP_TYPE_E eSnsMirrorFlip);
67     HI_S32 (*pfnWriteReg)(VI_PIPE ViPipe, HI_U32 s32Addr, HI_U32 s32Data);
68     HI_S32 (*pfnReadReg)(VI_PIPE ViPipe, HI_U32 s32Addr);
69     HI_S32 (*pfnSetInit)(VI_PIPE ViPipe, ISP_INIT_ATTR_S *pstInitAttr);
70 } ISP_SNS_OBJ_S;
71 
72 extern ISP_SNS_OBJ_S stSnsMn34220Obj;
73 extern ISP_SNS_OBJ_S stSnsImx377Obj;
74 extern ISP_SNS_OBJ_S stSnsImx299Obj;
75 extern ISP_SNS_OBJ_S stSnsImx477Obj;
76 extern ISP_SNS_OBJ_S stSnsImx299SlvsObj;
77 extern ISP_SNS_OBJ_S stSnsImx290Obj;
78 extern ISP_SNS_OBJ_S stSnsImx327Obj;
79 extern ISP_SNS_OBJ_S stSnsImx327_2l_Obj;
80 extern ISP_SNS_OBJ_S stSnsImx334Obj;
81 extern ISP_SNS_OBJ_S stSnsOV2718Obj;
82 extern ISP_SNS_OBJ_S stSnsOV2775Obj;
83 extern ISP_SNS_OBJ_S stSnsAr0237Obj;
84 
85 extern ISP_SNS_OBJ_S stSnsCmv50000Obj;
86 extern ISP_SNS_OBJ_S stSnsImx277SlvsObj;
87 extern ISP_SNS_OBJ_S stSnsImx117Obj;
88 extern ISP_SNS_OBJ_S stSnsImx290SlaveObj;
89 extern ISP_SNS_OBJ_S stSnsImx334SlaveObj;
90 extern ISP_SNS_OBJ_S stSnsImx226Obj;
91 extern ISP_SNS_OBJ_S stSnsImx390Obj;
92 extern ISP_SNS_OBJ_S stSnsImx335Obj;
93 extern ISP_SNS_OBJ_S stSnsImx307Obj;
94 extern ISP_SNS_OBJ_S stSnsImx307_2l_Obj;
95 extern ISP_SNS_OBJ_S g_sns_imx307_2l_obj;
96 extern ISP_SNS_OBJ_S g_stSnsImx307_2l_Slave_Obj;
97 extern ISP_SNS_OBJ_S stSnsImx458Obj;
98 extern ISP_SNS_OBJ_S stSnsSc4236Obj;
99 extern ISP_SNS_OBJ_S stSnsSc4210Obj;
100 extern ISP_SNS_OBJ_S stSnsSc2231Obj;
101 extern ISP_SNS_OBJ_S stSnsSc2235Obj;
102 extern ISP_SNS_OBJ_S stSnsSc3235Obj;
103 extern ISP_SNS_OBJ_S stSnsOs04b10_2lObj;
104 extern ISP_SNS_OBJ_S stSnsSoiF37Obj;
105 extern ISP_SNS_OBJ_S stSnsOs05aObj;
106 extern ISP_SNS_OBJ_S stSnsOS08A10Obj;
107 extern ISP_SNS_OBJ_S stSnsOs05a_2lObj;
108 extern ISP_SNS_OBJ_S stSnsGc2053Obj;
109 extern ISP_SNS_OBJ_S stSnsSharp8kObj;
110 extern ISP_SNS_OBJ_S stSnsOv12870Obj;
111 extern ISP_SNS_OBJ_S stSnsGc2053ForCarObj;
112 extern ISP_SNS_OBJ_S stSnsImx415Obj;
113 extern ISP_SNS_OBJ_S stSnsSp2305Obj;
114 extern ISP_SNS_OBJ_S stSnsOv9284Obj;
115 extern ISP_SNS_OBJ_S g_stSnsPs5260_2l_Obj;
116 extern ISP_SNS_OBJ_S g_sns_imx390_obj;
117 extern ISP_SNS_OBJ_S g_sns_q03_obj;
118 extern ISP_SNS_OBJ_S g_sns_sc500ai_obj;
119 extern ISP_SNS_OBJ_S stSnsK17Obj;
120 
121 #define CMOS_SLAVE_CHECK_DEV(dev) \
122     do { \
123         if (((dev) < 0) || ((dev) >= CAP_SLAVE_MAX_NUM)) {     \
124             HI_ERR_TRACE(HI_ID_ISP, "Err slave dev %d!\n", dev); \
125             return HI_ERR_ISP_ILLEGAL_PARAM; \
126         } \
127     } while (0)
128 
129 #define CMOS_CHECK_POINTER(ptr) \
130     do { \
131         if ((ptr) == HI_NULL) { \
132             HI_ERR_TRACE(HI_ID_ISP, "Null Pointer!\n");  \
133             return HI_ERR_ISP_NULL_PTR; \
134         } \
135     } while (0)
136 
137 #define CMOS_CHECK_POINTER_VOID(ptr) \
138     do { \
139         if ((ptr) == HI_NULL) { \
140             HI_ERR_TRACE(HI_ID_ISP, "Null Pointer!\n"); \
141             return; \
142         } \
143     } while (0)
144 
145 #define SENSOR_FREE(ptr) \
146     do { \
147         if ((ptr) != HI_NULL) { \
148             free(ptr); \
149             (ptr) = HI_NULL; \
150         } \
151     } while (0)
152 
153 #define SNS_ERR_TRACE(fmt, ...)                                                                            \
154     do {                                                                                                    \
155         HI_ERR_TRACE(HI_ID_ISP, "[Func]:%s [Line]:%d [Info]:" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
156     } while (0)
157 
158 #define SNS_DIV_0_TO_1(a)   (((a) == 0) ? 1 : (a))
159 #define SNS_DIV_0_TO_1_FLOAT(a) ((((a) < 1E-10) && ((a) > (-1E-10))) ? 1 : (a))
160 #ifdef __cplusplus
161 #if __cplusplus
162 }
163 #endif
164 #endif /* End of #ifdef __cplusplus */
165 
166 #endif /* __HI_SNS_CTRL_H__ */
167