xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/include/uAPI2/rk_aiq_user_api2_custom_ae.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  *  Copyright (c) 2021 Rockchip Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef _RK_AIQ_USER_API_CUSTOM_AE_H_
19 #define _RK_AIQ_USER_API_CUSTOM_AE_H_
20 
21 #include "rk_aiq_types.h" /* common structs */
22 #include "rk_aiq_user_api2_sysctl.h" /* rk_aiq_sys_ctx_t */
23 #include "ae/rk_aiq_types_ae_hw.h" /* include ae structs*/
24 
25 RKAIQ_BEGIN_DECLARE
26 
27 #ifndef RK_AIQ_MAX_HDR_FRAME
28 #define RK_AIQ_MAX_HDR_FRAME 3
29 #endif
30 
31 /* all ae stats */
32 typedef struct rk_aiq_customAe_stats_s
33 {
34     //hw stats
35     Aec_Stat_Res_t rawae_stat[RK_AIQ_MAX_HDR_FRAME]; // before awb gain
36     Aec_Stat_Res_t extra;      // after awb gain, lsc, TMO
37 
38     //exposure
39     RkAiqExpParamComb_t linear_exp;
40     RkAiqExpParamComb_t hdr_exp[RK_AIQ_MAX_HDR_FRAME];
41 
42     struct rk_aiq_customAe_stats_s* next; // for surround view(multiple cams)
43 } rk_aiq_customAe_stats_t;
44 
45 typedef struct rk_aiq_i2c_data_s {
46     bool            bValid;
47     unsigned int    nNumRegs;
48     unsigned int*   pRegAddr;
49     unsigned int*   pAddrByteNum;
50     unsigned int*   pRegValue;
51     unsigned int*   pValueByteNum;
52     unsigned int*   pDelayFrames;
53 } rk_aiq_i2c_data_t;
54 
55 /* ae results */
56 typedef struct rk_aiq_customeAe_results_singel_s
57 {
58     //exposure result (including:reg value & real value)
59     RkAiqExpParamComb_t linear_exp;
60     RkAiqExpParamComb_t hdr_exp[RK_AIQ_MAX_HDR_FRAME];
61     rk_aiq_i2c_data_t   exp_i2c_params;
62 
63     //hw result
64     struct window meas_win;
65     unsigned char meas_weight[15 * 15];
66 
67     struct rk_aiq_customeAe_results_singel_s* next; // for surround view(multiple cams)
68 } rk_aiq_customeAe_results_single_t;
69 
70 typedef struct rk_aiq_customeAe_results_s
71 {
72 
73     //exposure result (including:reg value & real value)
74     RkAiqExpParamComb_t linear_exp;
75     RkAiqExpParamComb_t hdr_exp[RK_AIQ_MAX_HDR_FRAME];
76     rk_aiq_i2c_data_t   exp_i2c_params;
77 
78     //hw result
79     struct window meas_win;
80     unsigned char meas_weight[15 * 15];
81 
82     RkAiqIrisParamComb_t Iris;
83     uint32_t frame_length_lines;
84     bool     is_longfrm_mode;
85 
86     struct rk_aiq_customeAe_results_singel_s* next; // for surround view(multiple cams)
87 } rk_aiq_customeAe_results_t;
88 
89 typedef struct rk_aiq_customeAe_cbs_s
90 {
91     /* ctx is the rk_aiq_sys_ctx_t/rk_aiq_camgroup_ctx_t
92      * which is corresponded to
93      * camera/camgroup, could be mapped to camera id.
94      */
95     int32_t (*pfn_ae_init)(void* ctx);
96     int32_t (*pfn_ae_run)(void* ctx, const rk_aiq_customAe_stats_t* pstAeInfo,
97                           rk_aiq_customeAe_results_t* pstAeResult);
98     /* not used now */
99     int32_t (*pfn_ae_ctrl)(void* ctx, uint32_t u32Cmd, void *pValue);
100     int32_t (*pfn_ae_exit)(void* ctx);
101 } rk_aiq_customeAe_cbs_t;
102 
103 /*!
104  * \brief register custom Ae algo
105  *
106  * \param[in] ctx             context
107  * \param[in] cbs             custom Ae callbacks
108  * \note should be called after rk_aiq_uapi_sysctl_init
109  */
110 XCamReturn
111 rk_aiq_uapi2_customAE_register(const rk_aiq_sys_ctx_t* ctx, rk_aiq_customeAe_cbs_t* cbs);
112 
113 /*!
114  * \brief enable/disable custom Ae algo
115  *
116  * \param[in] ctx             context
117  * \param[in] enable          enable/diable custom Ae
118  * \note should be called after rk_aiq_uapi_customAE_register. If custom Ae was enabled,
119  *       Rk ae will be stopped, vice versa.
120  */
121 XCamReturn
122 rk_aiq_uapi2_customAE_enable(const rk_aiq_sys_ctx_t* ctx, bool enable);
123 
124 /*!
125  * \brief unregister custom Ae algo
126  *
127  * \param[in] ctx             context
128  * \note should be called after rk_aiq_uapi_customAE_register.
129  */
130 XCamReturn
131 rk_aiq_uapi2_customAE_unRegister(const rk_aiq_sys_ctx_t* ctx);
132 
133 RKAIQ_END_DECLARE
134 
135 #endif
136