1 /*
2 * Copyright (c) 2020 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 #include <stdio.h>
17 #include "asm/io.h"
18 #include "hi_module_param.h"
19 #include "stdlib.h"
20 #include "fcntl.h"
21 #include "string.h"
22
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif /* End of #ifdef __cplusplus */
28
29 #define SENSOR_LIST_CMDLINE_LEN 256
30 #define CHIP_NAME_LEN 64
31
32 static unsigned long long g_mmz_start = 0x88000000;
33 static unsigned int g_mmz_size = 384; /* M Byte */
34
35 static int g_online_flag = 1;
36 static int g_cmos_yuv_flag = 0; /* vi: 0--RAW, 1--BT1120, 2--BT656 */
37 /* imx335 */
38 static char g_sensor_list[SENSOR_LIST_CMDLINE_LEN] = "sns0=imx335,sns1=imx335";
39
40 /* hi3516dv300 */
41 static char g_chip_list[CHIP_NAME_LEN] = "hi3516dv300";
42
43
SYS_cfg(void)44 static void SYS_cfg(void)
45 {
46 extern int hi_sysconfig_init(int cmos_yuv_flag, int online_flag, char* chip_list, char* sensor_list);
47 hi_sysconfig_init(g_cmos_yuv_flag, g_online_flag, g_chip_list, g_sensor_list);
48 }
49
50
MMZ_init(void)51 static int MMZ_init(void)
52 {
53 extern int media_mem_init(void *pArgs);
54 MMZ_SETUP_MODULE_PARAMS_S stMMZ_Param = {0};
55 snprintf(stMMZ_Param.mmz, MMZ_SETUP_CMDLINE_LENGTH, "anonymous,0,0x%llx,%dM", g_mmz_start, g_mmz_size);
56 stMMZ_Param.anony = 1;
57
58 dprintf("g_mmz_start=0x%llx, g_mmz_size=0x%x\n", g_mmz_start, g_mmz_size);
59 dprintf("mmz param= %s\n", stMMZ_Param.mmz);
60
61 return media_mem_init(&stMMZ_Param);
62 }
63
BASE_init(void)64 static int BASE_init(void)
65 {
66 extern int base_mod_init(void);
67 return base_mod_init();
68 }
69
SYS_init(void)70 static int SYS_init(void)
71 {
72 extern int sys_mod_init(void);
73 return sys_mod_init();
74 }
75
RGN_init(void)76 static int RGN_init(void)
77 {
78 extern int rgn_mod_init(void);
79 return rgn_mod_init();
80 }
81
ISP_init(void)82 static int ISP_init(void)
83 {
84 extern int isp_mod_init(void);
85 return isp_mod_init();
86 }
87
VI_init(void)88 static int VI_init(void)
89 {
90 extern int vi_mod_init(void);
91 return vi_mod_init();
92 }
93
DIS_init(void)94 static int DIS_init(void)
95 {
96 extern int dis_mod_init(void);
97 return dis_mod_init();
98 }
99
GDC_init(void)100 static int GDC_init(void)
101 {
102 extern int gdc_mod_init(void* pArgs);
103 GDC_MODULE_PARAMS_S stGdcModuleParam;
104 stGdcModuleParam.u32MaxGdcJob = 32; /* 32 -- max job num */
105 stGdcModuleParam.u32MaxGdcTask = 64; /* 64 -- max task num */
106 stGdcModuleParam.u32MaxGdcNode = 64; /* 64 -- max node num */
107 stGdcModuleParam.au32GdcEn[0] = 1;
108
109 return gdc_mod_init(&stGdcModuleParam);
110 }
111
VGS_init(void)112 static int VGS_init(void)
113 {
114 extern void vgs_get_module_param(void *pArgs);
115 extern int vgs_mod_init(void *pArgs);
116
117 VGS_MODULE_PARAMS_S stVgsModuleParam;
118
119 vgs_get_module_param((void *)&stVgsModuleParam);
120 stVgsModuleParam.u32MaxVgsJob = 64; /* 64 -- max job num */
121 stVgsModuleParam.u32MaxVgsTask = 100; /* 100 -- max task num */
122 stVgsModuleParam.u32MaxVgsNode = 100; /* 100 -- max node num */
123
124 return vgs_mod_init(&stVgsModuleParam);
125 }
126
VPSS_init(void)127 static int VPSS_init(void)
128 {
129 extern int vpss_mod_init(void *args);
130 return vpss_mod_init(NULL);
131 }
132
VO_init(void)133 static int VO_init(void)
134 {
135 extern int vou_module_init(void);
136 return vou_module_init();
137 }
138
RC_init(void)139 static int RC_init(void)
140 {
141 extern int rc_mod_init(void);
142 return rc_mod_init();
143 }
144
VENC_init(void)145 static int VENC_init(void)
146 {
147 extern int venc_mod_init(void *pArgs);
148 return venc_mod_init(NULL);
149 }
150
CHNL_init(void)151 static int CHNL_init(void)
152 {
153 extern int chnl_mod_init(void);
154 return chnl_mod_init();
155 }
156
VEDU_init(void)157 static int VEDU_init(void)
158 {
159 extern int vedu_mod_init(void);
160 return vedu_mod_init();
161 }
162
H264e_init(void)163 static int H264e_init(void)
164 {
165 extern int h264e_mod_init(void);
166 return h264e_mod_init();
167 }
168
H265e_init(void)169 static int H265e_init(void)
170 {
171 extern int h265e_mod_init(void *pArgs);
172 return h265e_mod_init(NULL);
173 }
174
JPEGE_init(void)175 static int JPEGE_init(void)
176 {
177 extern int jpege_mod_init(void);
178 return jpege_mod_init();
179 }
180
JPEGD_init(void)181 static int JPEGD_init(void)
182 {
183 extern int jpegd_mod_init(void);
184 return jpegd_mod_init();
185 }
186
VFMW_init(void)187 static int VFMW_init(void)
188 {
189 extern int vfmw_mod_init(void);
190 return vfmw_mod_init();
191 }
192
VDEC_init(void)193 static int VDEC_init(void)
194 {
195 extern int vdec_mod_init(void);
196 return vdec_mod_init();
197 }
198
IVE_init(void)199 static int IVE_init(void)
200 {
201 extern int ive_mod_init(void *pvArg);
202 IVE_MODULE_PARAMS_S stIveModuleParam;
203 stIveModuleParam.bSavePowerEn = HI_TRUE;
204 stIveModuleParam.u16IveNodeNum = 512; /* 512 -- max node num */
205 return ive_mod_init(&stIveModuleParam);
206 }
207
NNIE_init(void)208 static int NNIE_init(void)
209 {
210 extern int svp_nnie_mod_init(void *pvArg);
211 SVP_NNIE_MODULE_PARAMS_S stNnieModuleParam;
212 stNnieModuleParam.bSavePowerEn = HI_TRUE;
213 stNnieModuleParam.u16NnieTskBufNum = 32; /* 32 -- max buf num */
214 return svp_nnie_mod_init(&stNnieModuleParam);
215 }
216
TDE_init(void)217 static int TDE_init(void)
218 {
219 extern int tde_mod_init(void);
220
221 return tde_mod_init();
222 }
223
HIFB_init(void)224 static int HIFB_init(void)
225 {
226 extern int hifb_init(void *pArgs);
227
228 HIFB_MODULE_PARAMS_S stHIFB_Param;
229 snprintf(stHIFB_Param.video, 64, "hifb:vram0_size:16200"); /* 64 -- str length */
230 stHIFB_Param.bUpdateRotateRect = HI_FALSE;
231 return hifb_init(&stHIFB_Param);
232 }
233
hi_sensor_spi_init(void)234 static int hi_sensor_spi_init(void)
235 {
236 extern int sensor_spi_dev_init(void *pArgs);
237 return sensor_spi_dev_init(NULL);
238 }
239
hi_sensor_i2c_init(void)240 static int hi_sensor_i2c_init(void)
241 {
242 extern int hi_dev_init(void);
243 return hi_dev_init();
244 }
245
PWM_init(void)246 static int PWM_init(void)
247 {
248 extern int pwm_init(void);
249 return pwm_init();
250 }
251
PIRIS_init(void)252 static int PIRIS_init(void)
253 {
254 extern int piris_init(void);
255
256 return piris_init();
257 }
258
HDMI_init(void)259 static int HDMI_init(void)
260 {
261 extern int hdmi_drv_mod_init(void);
262 return hdmi_drv_mod_init();
263 }
264
MIPI_RX_init(void)265 static int MIPI_RX_init(void)
266 {
267 extern int mipi_rx_mod_init(void);
268 return mipi_rx_mod_init();
269 }
270
271 #ifndef LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_DSI
MIPI_TX_init(int smooth)272 static int MIPI_TX_init(int smooth)
273 {
274 extern int mipi_tx_module_init(int smooth);
275 return mipi_tx_module_init(smooth);
276 }
277 #endif
278
HI_USER_init(void)279 static int HI_USER_init(void)
280 {
281 extern int hi_user_init(void);
282 return hi_user_init();
283 }
284
AcodecMod_init(void)285 static int AcodecMod_init(void)
286 {
287 extern int acodec_mod_init(void *pArgs);
288 return acodec_mod_init(NULL);
289 }
290
AiaoMod_init(void)291 static int AiaoMod_init(void)
292 {
293 extern int aiao_mod_init(void);
294 return aiao_mod_init();
295 }
296
AiMod_init(void)297 static int AiMod_init(void)
298 {
299 extern int ai_mod_init(void);
300 return ai_mod_init();
301 }
302
AoMod_init(void)303 static int AoMod_init(void)
304 {
305 extern int ao_mod_init(void *pArgs);
306 return ao_mod_init(NULL);
307 }
308
AencMod_init(void)309 static int AencMod_init(void)
310 {
311 extern int aenc_mod_init(void *pArgs);
312 return aenc_mod_init(NULL);
313 }
314
AdecMod_init(void)315 static int AdecMod_init(void)
316 {
317 extern int adec_mod_init(void *pArgs);
318 return adec_mod_init(NULL);
319 }
320
Cipher_init(void)321 static int Cipher_init(void)
322 {
323 extern int cipher_drv_mod_init(void);
324 return cipher_drv_mod_init();
325 }
326
insert_audio(void)327 static void insert_audio(void)
328 {
329 int ret;
330
331 ret = AiaoMod_init();
332 if (ret != 0) {
333 printf("aiao init error.\n");
334 }
335
336 ret = AiMod_init();
337 if (ret != 0) {
338 printf("ai init error.\n");
339 }
340
341 ret = AoMod_init();
342 if (ret != 0) {
343 printf("ao init error.\n");
344 }
345
346 ret = AencMod_init();
347 if (ret != 0) {
348 printf("aenc init error.\n");
349 }
350
351 ret = AdecMod_init();
352 if (ret != 0) {
353 printf("adec init error.\n");
354 }
355
356 ret = AcodecMod_init();
357 if (ret != 0) {
358 printf("acodec init error.\n");
359 }
360 }
361
362 extern void osal_proc_init(void);
363
SDK_init(void)364 void SDK_init(void)
365 {
366 int ret;
367
368 SYS_cfg();
369
370 osal_proc_init();
371
372 ret = MMZ_init();
373 if (ret != 0) {
374 printf("MMZ init error.\n");
375 }
376
377 ret = BASE_init();
378 if (ret != 0) {
379 printf("base init error.\n");
380 }
381
382 ret = SYS_init();
383 if (ret != 0) {
384 printf("sys init error.\n");
385 }
386
387 ret = RGN_init();
388 if (ret != 0) {
389 printf("rgn init error.\n");
390 }
391
392 ret = GDC_init();
393 if (ret != 0) {
394 printf("gdc init error.\n");
395 }
396
397 ret = VGS_init();
398 if (ret != 0) {
399 printf("vgs init error.\n");
400 }
401
402 ret = DIS_init();
403 if (ret != 0) {
404 printf("vgs init error.\n");
405 }
406
407 ret = VI_init();
408 if (ret != 0) {
409 printf("vi init error.\n");
410 }
411
412 ret = ISP_init();
413 if (ret != 0) {
414 printf("isp init error.\n");
415 }
416
417 ret = VPSS_init();
418 if (ret != 0) {
419 printf("vpss init error.\n");
420 }
421
422 ret = VO_init();
423 if (ret != 0) {
424 printf("vo init error.\n");
425 }
426
427 ret = CHNL_init();
428 if (ret != 0) {
429 printf("chnl init error.\n");
430 }
431
432 ret = VEDU_init();
433 if (ret != 0) {
434 printf("vedu init error.\n");
435 }
436
437 ret = RC_init();
438 if (ret != 0) {
439 printf("rc init error.\n");
440 }
441
442 ret = VENC_init();
443 if (ret != 0) {
444 printf("venc init error.\n");
445 }
446
447 ret = H264e_init();
448 if (ret != 0) {
449 printf("H264e init error.\n");
450 }
451
452 ret = H265e_init();
453 if (ret != 0) {
454 printf("H265e init error.\n");
455 }
456
457 ret = JPEGE_init();
458 if (ret != 0) {
459 printf("jpege init error.\n");
460 }
461
462 ret = JPEGD_init();
463 if (ret != 0) {
464 printf("jpegd init error.\n");
465 }
466
467 ret = VFMW_init();
468 if (ret != 0) {
469 printf("vfmw init error.\n");
470 }
471
472 ret = VDEC_init();
473 if (ret != 0) {
474 printf("vdec init error.\n");
475 }
476
477 ret = IVE_init();
478 if (ret != 0) {
479 printf("ive init error.\n");
480 }
481
482 ret = NNIE_init();
483 if (ret != 0) {
484 printf("nnie init error.\n");
485 }
486
487 ret = TDE_init();
488 if (ret != 0) {
489 printf("TDE init error.\n");
490 }
491
492 ret = HIFB_init();
493 if (ret != 0) {
494 printf("HIFB_init error.\n");
495 }
496
497 insert_audio();
498
499 ret = PWM_init();
500 if (ret != 0) {
501 printf("pwm init error.\n");
502 }
503
504 ret = PIRIS_init();
505 if (ret != 0) {
506 printf("piris init error.\n");
507 }
508 #ifndef LOSCFG_DRIVERS_HDF_PLATFORM_SPI
509 #ifdef LOSCFG_DRIVERS_SPI
510 dprintf("spi bus init ...\n");
511 extern int spi_dev_init(void);
512 spi_dev_init();
513 #endif
514 #endif
515
516 #ifndef LOSCFG_DRIVERS_HDF_PLATFORM_I2C
517 #ifdef LOSCFG_DRIVERS_I2C
518 dprintf("i2c bus init ...\n");
519 extern int i2c_dev_init(void);
520 i2c_dev_init();
521 #endif
522 #endif
523
524 ret = hi_sensor_i2c_init();
525 if (ret != 0) {
526 printf("sensor i2c init error.\n");
527 }
528
529 ret = hi_sensor_spi_init();
530 if (ret != 0) {
531 printf("sensor spi init error.\n");
532 }
533
534 ret = HDMI_init();
535 if (ret != 0) {
536 printf("hdmi init error.\n");
537 }
538
539 ret = MIPI_RX_init();
540 if (ret != 0) {
541 printf("mipi_rx init error.\n");
542 }
543
544 #ifndef LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_DSI
545 int smooth = 0;
546 ret = MIPI_TX_init(smooth);
547 if (ret != 0) {
548 printf("mipi_tx init error.\n");
549 }
550 #endif
551
552 ret = Cipher_init();
553 if (ret != 0) {
554 printf("cipher init error.\n");
555 }
556
557 ret = HI_USER_init();
558 if (ret != 0) {
559 printf("hi user init error.\n");
560 }
561
562 printf("SDK init ok...\n");
563 }
564
565 #ifdef __cplusplus
566 #if __cplusplus
567 }
568 #endif
569 #endif /* End of #ifdef __cplusplus */
570