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
20 #include "stdlib.h"
21 #include "fcntl.h"
22 #include "string.h"
23 #include "board.h"
24
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif /* End of #ifdef __cplusplus */
30
31 #define SENSOR_NAME_LEN 64
32 #define CHIP_NAME_LEN 64
33 #define BOARD_NAME_LEN 64
34
35 static unsigned long long g_mmz_start = 0x42000000;
36 static unsigned int g_mmz_size = 32; /* M Byte */
37 static char g_chip_name[CHIP_NAME_LEN] = "hi3518ev300"; /* hi3518ev300 */
38 static char g_sensor_name[SENSOR_NAME_LEN] = "f23"; /* f23 */
39 static char g_board_name[BOARD_NAME_LEN] = "demo"; /* demo sck */
40
CHIP_init(void)41 static void CHIP_init(void)
42 {
43 return;
44 }
45
SYSCONFIG_init(void)46 static int SYSCONFIG_init(void)
47 {
48 extern int hi_sysconfig_init(void);
49 extern int g_quick_start_flag;
50 extern int g_online_flag;
51 extern int g_cmos_yuv_flag;
52 extern char g_sensor_list[SENSOR_NAME_LEN];
53 extern char g_chip_list[CHIP_NAME_LEN];
54 extern char g_board_list[BOARD_NAME_LEN];
55
56 g_quick_start_flag = 0;
57 g_online_flag = 0;
58 g_cmos_yuv_flag = 0;
59 strncpy(g_chip_list, g_chip_name, CHIP_NAME_LEN);
60 strncpy(g_sensor_list, g_sensor_name, SENSOR_NAME_LEN);
61 strncpy(g_board_list, g_board_name, BOARD_NAME_LEN);
62
63 return hi_sysconfig_init();
64 }
65
66
MMZ_init(void)67 static int MMZ_init(void)
68 {
69 extern int media_mem_init(void *pArgs);
70 MMZ_SETUP_MODULE_PARAMS_S stMMZ_Param = {0};
71
72 snprintf(stMMZ_Param.mmz, MMZ_SETUP_CMDLINE_LENGTH, "anonymous,0,0x%llx,%dM", g_mmz_start, g_mmz_size);
73
74 stMMZ_Param.anony = 1;
75
76 dprintf("g_mmz_start=0x%llx, g_mmz_size=0x%x\n", g_mmz_start, g_mmz_size);
77 dprintf("mmz param= %s\n", stMMZ_Param.mmz);
78
79 return media_mem_init(&stMMZ_Param);
80 }
81
BASE_init(void)82 static int BASE_init(void)
83 {
84 extern void base_get_module_param(void *pArgs);
85 extern int base_mod_init(void *pArgs);
86
87 BASE_MODULE_PARAMS_S stBaseModuleParam;
88 base_get_module_param(&stBaseModuleParam);
89
90 return base_mod_init(&stBaseModuleParam);
91 }
92
SYS_init(void)93 static int SYS_init(void)
94 {
95 extern int sys_mod_init(void);
96
97 return sys_mod_init();
98 }
99
RGN_init(void)100 static int RGN_init(void)
101 {
102 extern int rgn_mod_init(void);
103
104 return rgn_mod_init();
105 }
106
ISP_init(void)107 static int ISP_init(void)
108 {
109 extern int isp_mod_init(void);
110
111 return isp_mod_init();
112 }
113
VI_init(void)114 static int VI_init(void)
115 {
116 extern int vi_mod_init(void);
117
118 return vi_mod_init();
119 }
120
VGS_init(void)121 static int VGS_init(void)
122 {
123 extern void vgs_get_module_param(void *pArgs);
124 extern int vgs_mod_init(void *pArgs);
125
126 VGS_MODULE_PARAMS_S stVgsModuleParam;
127
128 vgs_get_module_param((void*)&stVgsModuleParam);
129 stVgsModuleParam.u32MaxVgsJob = 64; /* 64 -- max job num */
130 stVgsModuleParam.u32MaxVgsTask = 100; /* 100 -- max task num */
131 stVgsModuleParam.u32MaxVgsNode = 100; /* 100 -- max node num */
132
133 return vgs_mod_init(&stVgsModuleParam);
134 }
135
IVE_init(void)136 static int IVE_init(void)
137 {
138 extern int ive_mod_init(void *pArgs);
139 extern void ive_get_module_param(void *pArgs);
140
141 IVE_MODULE_PARAMS_S stIveModuleParam;
142 ive_get_module_param((void*)&stIveModuleParam);
143 stIveModuleParam.bSavePowerEn = HI_TRUE;
144 stIveModuleParam.u16IveNodeNum = 512; /* 512 -- node num */
145 return ive_mod_init(&stIveModuleParam);
146 }
147
VPSS_init(void)148 static int VPSS_init(void)
149 {
150 extern void vpss_get_module_param(void *pArgs);
151 extern int vpss_mod_init(void *pArgs);
152
153 VPSS_MODULE_PARAMS_S stVpssModuleParam;
154 vpss_get_module_param((void*)&stVpssModuleParam);
155
156 return vpss_mod_init(&stVpssModuleParam);
157 }
158
VO_init(void)159 static int VO_init(void)
160 {
161 extern int vou_module_init(void);
162
163 return vou_module_init();
164 }
165
RC_init(void)166 static int RC_init(void)
167 {
168 extern int rc_mod_init(void);
169 return rc_mod_init();
170 }
171
VENC_init(void)172 static int VENC_init(void)
173 {
174 extern void venc_get_module_param(void *pArgs);
175 extern int venc_mod_init(void *pArgs);
176
177 VENC_MODULE_PARAMS_S stVencModuleParam;
178 venc_get_module_param((void*)&stVencModuleParam);
179 return venc_mod_init(&stVencModuleParam);
180 }
181
CHNL_init(void)182 static int CHNL_init(void)
183 {
184 extern int chnl_mod_init(void);
185 return chnl_mod_init();
186 }
187
VEDU_init(void)188 static int VEDU_init(void)
189 {
190 extern int vedu_mod_init(void);
191 return vedu_mod_init();
192 }
193
H264e_init(void)194 static int H264e_init(void)
195 {
196 extern int h264e_mod_init(void);
197 return h264e_mod_init();
198 }
199
H265e_init(void)200 static int H265e_init(void)
201 {
202 extern int h265e_mod_init(void *pArgs);
203 return h265e_mod_init(NULL);
204 }
205
JPEGE_init(void)206 static int JPEGE_init(void)
207 {
208 extern int jpege_mod_init(void);
209 return jpege_mod_init();
210 }
211
hi_sensor_spi_init(void)212 static int hi_sensor_spi_init(void)
213 {
214 extern int sensor_spi_dev_init(void *pArgs);
215 return sensor_spi_dev_init(NULL);
216 }
217
hi_sensor_i2c_init(void)218 static int hi_sensor_i2c_init(void)
219 {
220 extern int hi_dev_init(void);
221 return hi_dev_init();
222 }
223
PWM_init(void)224 static int PWM_init(void)
225 {
226 return 0;
227 }
228
MIPI_RX_init(void)229 static int MIPI_RX_init(void)
230 {
231 extern int mipi_rx_mod_init(void);
232 return mipi_rx_mod_init();
233 }
234
235
AcodecMod_init(void)236 static int AcodecMod_init(void)
237 {
238 extern int acodec_mod_init(void *pArgs);
239 return acodec_mod_init(NULL);
240 }
241
AiaoMod_init(void)242 static int AiaoMod_init(void)
243 {
244 extern int aiao_mod_init(void);
245 return aiao_mod_init();
246 }
247
AiMod_init(void)248 static int AiMod_init(void)
249 {
250 extern int ai_mod_init(void);
251 return ai_mod_init();
252 }
253
AoMod_init(void)254 static int AoMod_init(void)
255 {
256 extern int ao_mod_init(void *pArgs);
257 return ao_mod_init(NULL);
258 }
259
AencMod_init(void)260 static int AencMod_init(void)
261 {
262 extern int aenc_mod_init(void *pArgs);
263 return aenc_mod_init(NULL);
264 }
265
AdecMod_init(void)266 static int AdecMod_init(void)
267 {
268 extern int adec_mod_init(void *pArgs);
269 return adec_mod_init(NULL);
270 }
271
Cipher_init(void)272 static int Cipher_init(void)
273 {
274 extern int cipher_drv_mod_init(void);
275 return cipher_drv_mod_init();
276 }
277
TDE_init(void)278 static int TDE_init(void)
279 {
280 extern int tde_mod_init(void);
281 return tde_mod_init();
282 }
283
insert_audio(void)284 static void insert_audio(void)
285 {
286 int ret;
287
288 ret = AiaoMod_init();
289 if (ret != 0) {
290 printf("aiao init error.\n");
291 }
292
293 ret = AiMod_init();
294 if (ret != 0) {
295 printf("ai init error.\n");
296 }
297
298 ret = AoMod_init();
299 if (ret != 0) {
300 printf("ao init error.\n");
301 }
302
303 ret = AencMod_init();
304 if (ret != 0) {
305 printf("aenc init error.\n");
306 }
307
308 ret = AdecMod_init();
309 if (ret != 0) {
310 printf("adec init error.\n");
311 }
312
313 ret = AcodecMod_init();
314 if (ret != 0) {
315 printf("acodec init error.\n");
316 }
317
318 printf("insert audio\n");
319 }
320 extern void osal_proc_init(void);
321 extern int hifb_init(void* pArgs);
322
323
HIFB_init(void)324 static int HIFB_init(void)
325 {
326 HIFB_MODULE_PARAMS_S stHIFB_Param;
327 snprintf(stHIFB_Param.video, 64, "hifb:vram0_size:1620"); /* 64 -- str length */
328 stHIFB_Param.bUpdateRotateRect = HI_FALSE;
329 return hifb_init(&stHIFB_Param);
330 }
331
PM_init(void)332 static int PM_init(void)
333 {
334 return 0;
335 }
336
337
SDK_init(void)338 void SDK_init(void)
339 {
340 int ret;
341
342 CHIP_init();
343 SYSCONFIG_init();
344 osal_proc_init();
345
346 ret = MMZ_init();
347 if (ret != 0) {
348 printf("MMZ init error.\n");
349 }
350
351 ret = BASE_init();
352 if (ret != 0) {
353 printf("base init error.\n");
354 }
355
356 ret = SYS_init();
357 if (ret != 0) {
358 printf("sys init error.\n");
359 }
360
361 ret = RGN_init();
362 if (ret != 0) {
363 printf("rgn init error.\n");
364 }
365
366 ret = VGS_init();
367 if (ret != 0) {
368 printf("vgs init error.\n");
369 }
370
371 ret = ISP_init();
372 if (ret != 0) {
373 printf("isp init error.\n");
374 }
375
376 ret = VI_init();
377 if (ret != 0) {
378 printf("vi init error.\n");
379 }
380
381 ret = VPSS_init();
382 if (ret != 0) {
383 printf("vpss init error.\n");
384 }
385
386 ret = VO_init();
387 if (ret != 0) {
388 printf("vo init error.\n");
389 }
390
391 ret = CHNL_init();
392 if (ret != 0) {
393 printf("chnl init error.\n");
394 }
395
396 ret = VEDU_init();
397 if (ret != 0) {
398 printf("vedu init error.\n");
399 }
400
401 ret = RC_init();
402 if (ret != 0) {
403 printf("rc init error.\n");
404 }
405
406 ret = VENC_init();
407 if (ret != 0) {
408 printf("venc init error.\n");
409 }
410
411 ret = H264e_init();
412 if (ret != 0) {
413 printf("H264e init error.\n");
414 }
415
416 ret = H265e_init();
417 if (ret != 0) {
418 printf("H265e init error.\n");
419 }
420
421 ret = JPEGE_init();
422 if (ret != 0) {
423 printf("jpege init error.\n");
424 }
425
426 ret = IVE_init();
427 if (ret != 0) {
428 printf("ive init error.\n");
429 }
430 insert_audio();
431
432 ret = PWM_init();
433 if (ret != 0) {
434 printf("pwm init error.\n");
435 }
436
437 #ifndef LOSCFG_DRIVERS_HDF_PLATFORM_SPI
438 #ifdef LOSCFG_DRIVERS_SPI
439 dprintf("spi bus init ...\n");
440 extern int spi_dev_init(void);
441 spi_dev_init();
442 #endif
443 #endif
444
445 #ifndef LOSCFG_DRIVERS_HDF_PLATFORM_I2C
446 #ifdef LOSCFG_DRIVERS_I2C
447 dprintf("i2c bus init ...\n");
448 extern int i2c_dev_init(void);
449 i2c_dev_init();
450 #endif
451 #endif
452
453 ret = hi_sensor_spi_init();
454 if (ret != 0) {
455 printf("sensor spi init error.\n");
456 }
457
458 ret = Cipher_init();
459 if (ret != 0) {
460 printf("cipher init error.\n");
461 }
462
463 ret = MIPI_RX_init();
464 if (ret != 0) {
465 printf("mipi_rx init error.\n");
466 }
467
468 ret = hi_sensor_i2c_init();
469 if (ret != 0) {
470 printf("sensor i2c init error.\n");
471 } else {
472 printf("sensor i2c init OK.\n");
473 }
474
475 ret = TDE_init();
476 if (ret != 0) {
477 printf("TDE init error.\n");
478 }
479
480 ret = HIFB_init();
481 if (ret != 0) {
482 printf("HIFB_init error.\n");
483 }
484
485 ret = PM_init();
486 if (ret != 0) {
487 printf("PM_init error.\n");
488 }
489
490 printf("SDK init ok...\n");
491 }
492
493
494 #ifdef __cplusplus
495 #if __cplusplus
496 }
497 #endif
498 #endif /* End of #ifdef __cplusplus */
499