huangcm
2025-07-03 c26084b3642f262f858535ab4e46c1e9b520d3a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 * Allwinner SoCs display driver.
 *
 * Copyright (C) 2016 Allwinner.
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */
 
/*******************************************************************************
 *  All Winner Tech, All Right Reserved. 2014-2015 Copyright (c)
 *
 *  File name   :   de_fce_type.h
 *
 *  Description :   display engine 2.0 fce struct declaration
 *
 *  History     :   2014/04/01  vito cheng  v0.1  Initial version
 *                  2014/04/29      vito cheng  v0.2  Add __fce_config_data
 ******************************************************************************/
 
#ifndef __DE_FCE_TYPE_H__
#define __DE_FCE_TYPE_H__
 
#include "de_rtmx.h"
 
/*
 * 0x0: do hist in even frame;
 * 0x1, do hist in odd frame;
 * 0x2, do hist in all frames
 */
#define HIST_FRAME_MASK  0x00000002
 
/*
 * 0x0: do CE in even frame;
 * 0x1, do CE in odd frame;
 * 0x2, do CE in all frames
 */
#define CE_FRAME_MASK    0x00000002
 
#define LCE_PARA_NUM  2
#define LCE_MODE_NUM  2
 
#define AUTOCE_PARA_NUM  5
#define AUTOCE_MODE_NUM  3
 
#define CE_PARA_NUM  2
#define CE_MODE_NUM  2
 
#define FTC_PARA_NUM  2
#define FTC_MODE_NUM  2
 
#define AVG_NUM 8
 
/* for hist */
extern unsigned int *g_hist[DE_NUM][CHN_NUM];
extern unsigned int *g_hist_p[DE_NUM][CHN_NUM];
extern unsigned int g_sum[DE_NUM][CHN_NUM];
 
extern unsigned int g_format[DE_NUM];
 
union FCE_GCTRL_REG {
   unsigned int dwval;
   struct {
       unsigned int en:1;
       unsigned int res0:15;
       unsigned int hist_en:1;
       unsigned int ce_en:1;
       unsigned int lce_en:1;
       unsigned int res1:1;
       unsigned int ftc_en:1;
       unsigned int res2:10;
       unsigned int win_en:1;
   } bits;
};
 
union FCE_SIZE_REG {
   unsigned int dwval;
   struct {
       unsigned int width:12;
       unsigned int res0:4;
       unsigned int height:12;
       unsigned int res1:4;
   } bits;
};
 
union FCE_WIN0_REG {
   unsigned int dwval;
   struct {
       unsigned int win_left:12;
       unsigned int res0:4;
       unsigned int win_top:12;
       unsigned int res1:4;
   } bits;
};
 
union FCE_WIN1_REG {
   unsigned int dwval;
   struct {
       unsigned int win_right:12;
       unsigned int res0:4;
       unsigned int win_bot:12;
       unsigned int res1:4;
   } bits;
};
 
union LCE_GAIN_REG {
   unsigned int dwval;
   struct {
       unsigned int lce_gain:6;
       unsigned int res0:2;
       unsigned int lce_blend:8;
       unsigned int res1:16;
   } bits;
};
 
union HIST_SUM_REG {
   unsigned int dwval;
   struct {
       unsigned int sum:32;
   } bits;
};
 
union HIST_STATUS_REG {
   unsigned int dwval;
   struct {
       unsigned int hist_valid:1;
       unsigned int res0:31;
   } bits;
};
 
union CE_STATUS_REG {
   unsigned int dwval;
   struct {
       unsigned int celut_access_switch:1;
       unsigned int res0:31;
   } bits;
};
 
union FTC_GAIN_REG {
   unsigned int dwval;
   struct {
       unsigned int ftc_gain1:8;
       unsigned int res0:8;
       unsigned int ftc_gain2:8;
       unsigned int res1:8;
   } bits;
};
 
union FTC_CSCBYPASS_REG {
   unsigned int dwval;
   struct {
       unsigned int csc_bypass:1;
       unsigned int res0:31;
   } bits;
};
 
union CE_LUT_REG {
   unsigned int dwval;
   struct {
       unsigned int lut0:8;
       unsigned int lut1:8;
       unsigned int lut2:8;
       unsigned int lut3:8;
   } bits;
};
 
union HIST_CNT_REG {
   unsigned int dwval;
   struct {
       unsigned int hist:22;
       unsigned int res0:10;
   } bits;
};
 
struct __fce_reg_t {
   union FCE_GCTRL_REG ctrl;                /* 0x0000        */
   union FCE_SIZE_REG size;                /* 0x0004        */
   union FCE_WIN0_REG win0;                /* 0x0008        */
   union FCE_WIN1_REG win1;                /* 0x000c        */
   union LCE_GAIN_REG lcegain;              /* 0x0010        */
   unsigned int res0[3];              /* 0x0014-0x001c */
   union HIST_SUM_REG histsum;              /* 0x0020        */
   union HIST_STATUS_REG histstauts;        /* 0x0024        */
   union CE_STATUS_REG cestatus;            /* 0x0028        */
   unsigned int res1;                /* 0x002c        */
   union FTC_GAIN_REG ftcgain;              /* 0x0030        */
   unsigned int res2[3];              /* 0x0034-0x003c */
   union FTC_CSCBYPASS_REG cscbypass;      /* 0x0040        */
   unsigned int res3[47];            /* 0x0044-0x00fc */
   union CE_LUT_REG celut[64];              /* 0x0100-0x01fc */
   union HIST_CNT_REG hist[256];            /* 0x0200-0x05fc */
};
 
struct __fce_config_data {
   /* global */
   unsigned int fce_en;
 
   /* ce */
   unsigned int ce_en;
   unsigned int up_precent_thr;
   unsigned int down_precent_thr;
   unsigned int b_automode;
   unsigned int update_diff_thr;
 
   /* bws */
   unsigned int present_black;
   unsigned int present_white;
   unsigned int slope_black_lmt;
   unsigned int slope_white_lmt;
   unsigned int black_prec;
   unsigned int white_prec;
   unsigned int lowest_black;
   unsigned int highest_white;
 
   /* lce */
   unsigned int lce_en;
   unsigned int lce_blend;
   unsigned int lce_gain;
 
   /* ftc */
   unsigned int ftc_en;
   unsigned int ftc_gain1;
   unsigned int ftc_gain2;
 
   unsigned int hist_en;
 
   unsigned int win_en;
   struct de_rect win;
};
 
struct __hist_status_t {
   /* Frame number of Histogram run */
   unsigned int runtime;
   /* Histogram enabled */
   unsigned int isenable;
   /* Already get histogram of two frames */
   unsigned int twohistready;
};
 
struct __ce_status_t {
   unsigned int isenable;      /* CE enabled */
   unsigned int b_automode;    /* 0: Constant CE ; 1: Auto CE */
   unsigned int width;
   unsigned int height;
   /* alg */
   unsigned int up_precent_thr;
   unsigned int down_precent_thr;
   unsigned int update_diff_thr;
   unsigned int slope_black_lmt;
   unsigned int slope_white_lmt;
 
};
 
struct hist_data {
   unsigned int hist_mean;
   unsigned int old_hist_mean;
   int hist_mean_diff;
   unsigned int avg_mean_saved[AVG_NUM];
   unsigned int avg_mean_idx;
   unsigned int avg_mean;
   unsigned int counter;
   unsigned int diff_coeff;
 
   unsigned int black_thr0;
   unsigned int black_thr1;
   unsigned int white_thr0;
   unsigned int white_thr1;
 
   unsigned int black_slp0;
   unsigned int black_slp1;
   unsigned int white_slp0;
   unsigned int white_slp1;
 
};
 
#endif