xref: /OK3568_Linux_fs/external/camera_engine_rkaiq/rkaiq/algos/adebayer/rk_aiq_uapi_adebayer_int.cpp (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 #include "rk_aiq_uapi_adebayer_int.h"
2 #if RKAIQ_HAVE_DEBAYER_V1
3 #include "adebayer/rk_aiq_adebayer_algo_v1.h"
4 #endif
5 #if RKAIQ_HAVE_DEBAYER_V2 || RKAIQ_HAVE_DEBAYER_V2_LITE
6 #include "adebayer/rk_aiq_adebayer_algo_v2.h"
7 #endif
8 
9 #if RKAIQ_HAVE_DEBAYER_V1
10 XCamReturn
rk_aiq_uapi_adebayer_SetAttrib(RkAiqAlgoContext * ctx,adebayer_attrib_t attr,bool need_sync)11 rk_aiq_uapi_adebayer_SetAttrib
12 (
13     RkAiqAlgoContext* ctx,
14     adebayer_attrib_t attr,
15     bool need_sync
16 )
17 {
18     if(ctx == NULL) {
19         LOGE_ADEBAYER("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
20         return XCAM_RETURN_ERROR_PARAM;
21     }
22 
23     AdebayerContext_t* pAdebayerCtx = (AdebayerContext_t*)&ctx->adebayerCtx;
24     pAdebayerCtx->full_param.enable = attr.enable;
25     pAdebayerCtx->mode = attr.mode;
26     if (attr.mode == RK_AIQ_DEBAYER_MODE_AUTO) {
27         pAdebayerCtx->full_param.thed0 = attr.stAuto.high_freq_thresh;
28         pAdebayerCtx->full_param.thed1 = attr.stAuto.low_freq_thresh;
29         memcpy(pAdebayerCtx->full_param.sharp_strength, attr.stAuto.sharp_strength,
30                sizeof(attr.stAuto.sharp_strength));
31     } else if (attr.mode == RK_AIQ_DEBAYER_MODE_MANUAL) {
32         memcpy(&pAdebayerCtx->manualAttrib, &attr.stManual, sizeof(attr.stManual));
33     } else {
34         LOGE_ADEBAYER("Invalid mode: %s\n", attr.mode == RK_AIQ_DEBAYER_MODE_AUTO ? "auto" : "manual");
35         return XCAM_RETURN_ERROR_PARAM;
36     }
37 
38     pAdebayerCtx->is_reconfig = true;
39 
40     return XCAM_RETURN_NO_ERROR;
41 }
42 
43 XCamReturn
rk_aiq_uapi_adebayer_GetAttrib(RkAiqAlgoContext * ctx,adebayer_attrib_t * attr)44 rk_aiq_uapi_adebayer_GetAttrib
45 (
46     RkAiqAlgoContext*  ctx,
47     adebayer_attrib_t* attr
48 )
49 {
50     if(ctx == NULL || attr == NULL) {
51         LOGE_ADEBAYER("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
52         return XCAM_RETURN_ERROR_PARAM;
53     }
54 
55 
56     AdebayerContext_t* pAdebayerCtx = (AdebayerContext_t*)&ctx->adebayerCtx;
57     attr->enable = pAdebayerCtx->full_param.enable;
58     attr->mode = pAdebayerCtx->mode;
59     attr->stAuto.high_freq_thresh = pAdebayerCtx->full_param.thed0;
60     attr->stAuto.low_freq_thresh = pAdebayerCtx->full_param.thed1;
61     memcpy(attr->stAuto.sharp_strength, pAdebayerCtx->full_param.sharp_strength,
62            sizeof(attr->stAuto.sharp_strength));
63 
64     memcpy(&attr->stManual, &pAdebayerCtx->manualAttrib, sizeof(pAdebayerCtx->manualAttrib));
65 
66     return XCAM_RETURN_NO_ERROR;
67 }
68 #endif
69 
70 #if RKAIQ_HAVE_DEBAYER_V2
71 XCamReturn
rk_aiq_uapi_adebayer_v2_SetAttrib(RkAiqAlgoContext * ctx,adebayer_v2_attrib_t attr,bool need_sync)72 rk_aiq_uapi_adebayer_v2_SetAttrib
73 (
74     RkAiqAlgoContext* ctx,
75     adebayer_v2_attrib_t attr,
76     bool need_sync
77 ) {
78     if(ctx == NULL) {
79         LOGE_ADEBAYER("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
80         return XCAM_RETURN_ERROR_PARAM;
81     }
82 
83     AdebayerContext_t* pAdebayerCtx = (AdebayerContext_t*)&ctx->adebayerCtx;
84 
85     pAdebayerCtx->mode = attr.mode;
86 
87     if (attr.mode == RK_AIQ_DEBAYER_MODE_AUTO) {
88         pAdebayerCtx->full_param_v2 = attr.stAuto;
89 
90     } else if (attr.mode == RK_AIQ_DEBAYER_MODE_MANUAL) {
91         pAdebayerCtx->select_param_v2 = attr.stManual;
92     } else {
93         LOGE_ADEBAYER("Invalid mode: %d\n", attr.mode);
94         return XCAM_RETURN_ERROR_PARAM;
95     }
96 
97     pAdebayerCtx->is_reconfig = true;
98 
99     return XCAM_RETURN_NO_ERROR;
100 }
101 XCamReturn
rk_aiq_uapi_adebayer_v2_GetAttrib(RkAiqAlgoContext * ctx,adebayer_v2_attrib_t * attr)102 rk_aiq_uapi_adebayer_v2_GetAttrib
103 (
104     RkAiqAlgoContext*  ctx,
105     adebayer_v2_attrib_t* attr
106 )
107 {
108     if(ctx == NULL || attr == NULL) {
109         LOGE_ADEBAYER("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
110         return XCAM_RETURN_ERROR_PARAM;
111     }
112 
113     AdebayerContext_t* pAdebayerCtx = (AdebayerContext_t*)&ctx->adebayerCtx;
114 
115     attr->mode = pAdebayerCtx->mode;
116     attr->stAuto = pAdebayerCtx->full_param_v2;
117     attr->stManual = pAdebayerCtx->select_param_v2;
118 
119     return XCAM_RETURN_NO_ERROR;
120 }
121 
122 #endif
123 
124 #if RKAIQ_HAVE_DEBAYER_V2_LITE
125 XCamReturn
rk_aiq_uapi_adebayer_v2lite_SetAttrib(RkAiqAlgoContext * ctx,adebayer_v2lite_attrib_t attr,bool need_sync)126 rk_aiq_uapi_adebayer_v2lite_SetAttrib
127 (
128     RkAiqAlgoContext* ctx,
129     adebayer_v2lite_attrib_t attr,
130     bool need_sync
131 ) {
132     if(ctx == NULL) {
133         LOGE_ADEBAYER("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
134         return XCAM_RETURN_ERROR_PARAM;
135     }
136 
137     AdebayerContext_t* pAdebayerCtx = (AdebayerContext_t*)&ctx->adebayerCtx;
138 
139     pAdebayerCtx->mode = attr.mode;
140 
141     if (attr.mode == RK_AIQ_DEBAYER_MODE_AUTO) {
142         pAdebayerCtx->full_param_v2_lite = attr.stAuto;
143 
144     } else if (attr.mode == RK_AIQ_DEBAYER_MODE_MANUAL) {
145         pAdebayerCtx->select_param_v2_lite = attr.stManual;
146     } else {
147         LOGE_ADEBAYER("Invalid mode: %d\n", attr.mode);
148         return XCAM_RETURN_ERROR_PARAM;
149     }
150 
151     pAdebayerCtx->is_reconfig = true;
152 
153     return XCAM_RETURN_NO_ERROR;
154 }
155 
156 XCamReturn
rk_aiq_uapi_adebayer_v2lite_GetAttrib(RkAiqAlgoContext * ctx,adebayer_v2lite_attrib_t * attr)157 rk_aiq_uapi_adebayer_v2lite_GetAttrib
158 (
159     RkAiqAlgoContext*  ctx,
160     adebayer_v2lite_attrib_t* attr
161 )
162 {
163     if(ctx == NULL || attr == NULL) {
164         LOGE_ADEBAYER("%s(%d): null pointer\n", __FUNCTION__, __LINE__);
165         return XCAM_RETURN_ERROR_PARAM;
166     }
167 
168     AdebayerContext_t* pAdebayerCtx = (AdebayerContext_t*)&ctx->adebayerCtx;
169 
170     attr->mode = pAdebayerCtx->mode;
171     attr->stAuto = pAdebayerCtx->full_param_v2_lite;
172     attr->stManual = pAdebayerCtx->select_param_v2_lite;
173 
174     return XCAM_RETURN_NO_ERROR;
175 }
176 #endif
177