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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/*
 * 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.
 */
 
#ifndef _DE_FEAT_H_
#define _DE_FEAT_H_
 
#define DE_OUTPUT_TYPE_LCD   1
#define DE_OUTPUT_TYPE_TV    2
#define DE_OUTPUT_TYPE_HDMI  4
#define DE_OUTPUT_TYPE_VGA   8
#define DE_OUTPUT_TYPE_VDPO  16
#define WB_HAS_CSC
 
#define CVBS_PAL_WIDTH 720
#define CVBS_PAL_HEIGHT 576
#define CVBS_NTSC_WIDTH 720
#define CVBS_NTSC_HEIGHT 480
 
#define P2P_FB_MIN_WIDTH 704
#define P2P_FB_MAX_WIDTH 736
 
#if defined(CONFIG_ARCH_SUN50IW2)
 
/* features for sun50iw2 */
 
#define DEVICE_NUM    2
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    1
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
/* #define SUPPORT_DSI */
/* #define SUPPORT_SMBL */
#define SUPPORT_HDMI
/* #define DSI_VERSION_40 */
/* #define HAVE_DEVICE_COMMON_MODULE */
#define SUPPORT_TV
#define TV_UGLY_CLK_RATE 216000000
/* #define SUPPORT_VGA */
/* #define SUPPORT_LVDS */
/* #define LVDS_REVERT */
 
#if defined(CONFIG_FPGA_V4_PLATFORM) \
   || defined(CONFIG_FPGA_V7_PLATFORM)
/*
 * TCON1_DRIVE_PANEL - General for fpga verify
 * On some platform there is no tcon0
 * At fpga period, we can use tcon1 to drive lcd pnael
 * we need to config & enable tcon1.
 * So enable this config.
 */
#define TCON1_DRIVE_PANEL
#endif
 
#elif defined(CONFIG_ARCH_SUN8IW11)
 
/* features for sun8iw11 */
 
#define DEVICE_NUM    4
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    1
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_DSI
#define SUPPORT_SMBL
#define SUPPORT_HDMI
#define DSI_VERSION_40
#define HAVE_DEVICE_COMMON_MODULE
#define SUPPORT_TV
#define TV_UGLY_CLK_RATE 216000000
#define SUPPORT_VGA
#define SUPPORT_LVDS
#define DE_WB_RESET_SHARE
/* #define LVDS_REVERT */
#elif defined(CONFIG_ARCH_SUN8IW15)
 
/* features for sun8iw15 */
 
#define DEVICE_NUM    1
#define DE_NUM    1
#define CHN_NUM        4
#define VI_CHN_NUM    1
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_DSI
#define DSI_VERSION_28
#define CLK_NUM_PER_DSI 2
#define DEVICE_DSI_NUM 1
#define SUPPORT_SMBL
#define HAVE_DEVICE_COMMON_MODULE
#define SUPPORT_LVDS
/*#define DE_WB_RESET_SHARE*/
 
/* #define SUPPORT_EINK */
/* #define EINK_PANEL_USED */
/* #define SUPPORT_WB */
/* #define EINK_DMABUF_USED */
 
/* #define LVDS_REVERT */
 
#elif defined(CONFIG_ARCH_SUN50IW10)
/* features for sun50iw10 */
 
#define CONFIG_INDEPENDENT_DE
#define DEVICE_NUM    2
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    2
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_DSI
#define SUPPORT_COMBO_DPHY
#define DSI_VERSION_40
#define CLK_NUM_PER_DSI 1
#define DEVICE_DSI_NUM 1
#define SUPPORT_SMBL
#define HAVE_DEVICE_COMMON_MODULE
#define SUPPORT_LVDS
#define DEVICE_LVDS_NUM 2
#define SUNXI_DSI_PASSIVE_BUG
#define IOMMU_DE0_MASTOR_ID 0
#define IOMMU_DE1_MASTOR_ID 1
/*#define DE_WB_RESET_SHARE*/
 
/* #define SUPPORT_EINK */
/* #define EINK_PANEL_USED */
/* #define SUPPORT_WB */
/* #define EINK_DMABUF_USED */
 
/* #define LVDS_REVERT */
 
#elif defined(CONFIG_ARCH_SUN50IW1)
 
/* features for sun50iw1 */
 
#define DEVICE_NUM    4
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    1
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_DSI
#define SUPPORT_SMBL
#define SUPPORT_HDMI
#define DSI_VERSION_40
#define HAVE_DEVICE_COMMON_MODULE
#define SUPPORT_TV
#define SUPPORT_VGA
#define SUPPORT_LVDS
/* #define LVDS_REVERT */
 
#elif defined(CONFIG_ARCH_SUN50IW8)
 
/* features for sun50iw8 */
 
#define DEVICE_NUM      1
#define DE_NUM  1
#define CHN_NUM         2
#define VI_CHN_NUM      0
#define UI_CHN_NUM      (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
//#define SUPPORT_DSI
#define SUPPORT_SMBL
/*#define SUPPORT_HDMI  */
//#define DSI_VERSION_40
#define HAVE_DEVICE_COMMON_MODULE
//#define SUPPORT_TV
//#define SUPPORT_VGA
//#define SUPPORT_LVDS
/* #define LVDS_REVERT */
 
 
#elif defined(CONFIG_ARCH_SUN8IW12)
 
/* features for sun8iw12 */
 
#define DEVICE_NUM    2
#define DE_NUM    1
#define CHN_NUM        4
#define VI_CHN_NUM    2
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_SMBL
 
#define SUPPORT_DSI
#define DSI_VERSION_28
#define CLK_NUM_PER_DSI 2
#define DEVICE_DSI_NUM 1
#define SUPPORT_HDMI
/* #define DSI_VERSION_40 */
#define HAVE_DEVICE_COMMON_MODULE
#define SUPPORT_TV
#define TV_UGLY_CLK_RATE 216000000
/* #define SUPPORT_VGA */
#define SUPPORT_LVDS
#define DE_WB_RESET_SHARE
/* #define LVDS_REVERT */
#define SUPPORT_VDPO
#define DEVICE_VDPO_NUM 1
 
#elif defined(CONFIG_ARCH_SUN8IW6)
/* features for sun8iw6 */
 
#define DEVICE_NUM      2
#define DE_NUM          2
#define CHN_NUM         4
#define VI_CHN_NUM      1
#define UI_CHN_NUM      (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
#define SUPPORT_LVDS
#define SUPPORT_DSI
#define SUPPORT_SMBL
#define SUPPORT_HDMI
#define SUPPORT_TV
#define DSI_VERSION_28
#define CLK_NUM_PER_DSI 2
#define DE_WB_RESET_SHARE
#define LVDS_REVERT
 
#elif defined(CONFIG_ARCH_SUN8IW7)
 
#define DEVICE_NUM    2
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    1
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
#define VEP_NUM  1
#define DE_WB_RESET_SHARE
 
#define SUPPORT_HDMI
#define SUPPORT_TV
#define TV_UGLY_CLK_RATE 216000000
 
#elif defined(CONFIG_ARCH_SUN8IW17)
 
/* features for sun8iw17 */
 
#define DEVICE_NUM    3
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    2
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_MAX_VI_NUM_PER_CHN 4
#define LAYER_MAX_UI_NUM_PER_CHN 4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_DSI
#define DEVICE_DSI_NUM 2
#define SUPPORT_SMBL
/* #define SUPPORT_HDMI */
#define DSI_VERSION_40
#define HAVE_DEVICE_COMMON_MODULE
#define SUPPORT_TV
#define TV_UGLY_CLK_RATE 216000000
/* #define SUPPORT_VGA */
#define SUPPORT_LVDS
/* #define LVDS_REVERT */
 
#else
 
/* default features */
#error "undefined platform!!!"
 
#define DEVICE_NUM    2
#define DE_NUM    2
#define CHN_NUM        4
#define VI_CHN_NUM    1
#define UI_CHN_NUM    (CHN_NUM - VI_CHN_NUM)
#define LAYER_NUM_PER_CHN_PER_VI_CHN    4
#define LAYER_NUM_PER_CHN_PER_UI_CHN    4
#define LAYER_MAX_NUM_PER_CHN 4
 
#define SUPPORT_DSI
#define SUPPORT_SMBL
#define SUPPORT_HDMI
#define DSI_VERSION_40
/* #define HAVE_DEVICE_COMMON_MODULE */
#define SUPPORT_TV
/* #define SUPPORT_VGA */
#define SUPPORT_LVDS
/* #define LVDS_REVERT */
#endif
 
#if defined(TV_UGLY_CLK_RATE)
#define TV_COMPOSITE_CLK_RATE 27000000
#endif
 
#ifndef CLK_NUM_PER_DSI
#define CLK_NUM_PER_DSI 1
#endif
 
#ifndef DEVICE_DSI_NUM
#define DEVICE_DSI_NUM 1
#endif /*endif DEVICE_DSI_NUM */
 
#ifndef DEVICE_LVDS_NUM
#define DEVICE_LVDS_NUM 1
#endif
/* total number of DSI clk */
#define CLK_DSI_NUM  (CLK_NUM_PER_DSI * DEVICE_DSI_NUM)
 
#ifndef SUPPORT_VDPO
#define DEVICE_VDPO_NUM 0
#endif
 
#ifndef IOMMU_DE0_MASTOR_ID
#define IOMMU_DE0_MASTOR_ID 0
#define IOMMU_DE1_MASTOR_ID 0
#endif
 
struct de_feat {
   const int num_screens;
   /* indicate layer manager number */
   const int num_devices;
   /*indicate timing controller number */
   const int *num_chns;
   const int *num_vi_chns;
   const int *num_layers;
   const int *is_support_vep;
   const int *is_support_smbl;
   const int *is_support_wb;
   const int *supported_output_types;
   const int *is_support_scale;
   const int *scale_line_buffer;
   const int num_vdpo; /*number of vdpo device*/
};
 
int de_feat_init(void);
int de_feat_exit(void);
int de_feat_get_num_screens(void);
int de_feat_get_num_devices(void);
int de_feat_get_num_chns(unsigned int disp);
int de_feat_get_num_vi_chns(unsigned int disp);
unsigned int de_feat_get_number_of_vdpo(void);
int de_feat_get_num_ui_chns(unsigned int disp);
int de_feat_get_num_layers(unsigned int disp);
int de_feat_get_num_layers_by_chn(unsigned int disp, unsigned int chn);
int de_feat_is_support_vep(unsigned int disp);
int de_feat_is_support_vep_by_chn(unsigned int disp, unsigned int chn);
int de_feat_is_support_smbl(unsigned int disp);
int de_feat_is_supported_output_types(unsigned int disp,
                     unsigned int output_type);
int de_feat_is_support_wb(unsigned int disp);
int de_feat_is_support_scale(unsigned int disp);
int de_feat_is_support_scale_by_chn(unsigned int disp, unsigned int chn);
int de_feat_get_scale_linebuf(unsigned int disp);
int de_feat_get_tcon_index(unsigned int tcon_index);
unsigned int de_feat_get_tcon_type(unsigned int tcon_index);
 
#endif