1007 lines
29 KiB
C
Executable File
1007 lines
29 KiB
C
Executable File
// libc
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
// vos
|
|
#include <kwrap/cmdsys.h>
|
|
#include <kwrap/examsys.h>
|
|
#include <kwrap/perf.h>
|
|
#include <kwrap/util.h>
|
|
// kdrv
|
|
#include <comm/log.h>
|
|
#include <comm/timer.h>
|
|
#include <comm/hwclock.h>
|
|
#include <comm/ddr_arb.h>
|
|
#include <plat/drtc.h>
|
|
#include <plat/sdio.h>
|
|
#include <plat/grph_plat.h>
|
|
#include <plat/top.h>
|
|
#include <plat/rtc.h>
|
|
#include <plat/sdp.h>
|
|
#include <plat/spi.h>
|
|
#include <plat/usb2dev.h>
|
|
#include <plat/clock.h>
|
|
#include <kdrv_videocapture/kdrv_sie.h>
|
|
#include <kdrv_videoprocess/kdrv_ipp.h>
|
|
#include <kdrv_gfx2d/kdrv_ise.h>
|
|
#include "kdrv_audioio/audlib_aac.h"
|
|
#include "kdrv_audioio/audlib_g711.h"
|
|
#include "kdrv_audioio/audlib_anr.h"
|
|
#include "kdrv_audioio/kdrv_audioio.h"
|
|
#include "kdrv_builtin/kdrv_builtin.h"
|
|
|
|
// kflow
|
|
#include <kflow.h>
|
|
#include <kflow_videocapture/ctl_sie.h>
|
|
#include <gximage/hd_gximage.h>
|
|
#include <videosprite/videosprite.h>
|
|
|
|
// PQ
|
|
#include "isp_rtos_inc.h"
|
|
#include "isp_api.h"
|
|
// ext_devices
|
|
#include <dispdev_panlcomn.h>
|
|
#include <sen_inc.h>
|
|
#include <ad_inc.h>
|
|
// driver
|
|
#include <serial.h>
|
|
#include <console.h>
|
|
// lib
|
|
#include <lwip/tcpip.h>
|
|
#include <lwip/sockets.h>
|
|
#include <netif/nvt_eth.h>
|
|
#include <DbgUtApi.h>
|
|
// locals
|
|
#include "PrjCfg.h"
|
|
#include "startup.h"
|
|
#include "sys_mempool.h"
|
|
#include "sys_nvtmpp.h"
|
|
#include "sys_filesys.h"
|
|
#include "sys_card.h"
|
|
#include "sys_fwload.h"
|
|
#include "sys_fastboot.h"
|
|
#include "sys_storage_partition.h"
|
|
#include "sys_fdt.h"
|
|
#include "Utility/SwTimer.h"
|
|
#include "SxTimer/SxTimer.h"
|
|
#include "GxTimer.h"
|
|
#include "SysSensor.h"
|
|
#include "flow_system.h"
|
|
#include "flow_preview.h"
|
|
#include "flow_movie.h"
|
|
#include "flow_encode.h"
|
|
#include "flow_boot_linux.h"
|
|
#include "flow_load_flash.h"
|
|
#include <FreeRTOS_POSIX.h>
|
|
#include <FreeRTOS_POSIX/pthread.h>
|
|
#include "PhotoFast.h"
|
|
#include "MovieFast.h"
|
|
#include "UsbCamFast.h"
|
|
#include "UsbDiskFast.h"
|
|
#include "hdal.h"
|
|
#include "DxHunting.h"
|
|
|
|
|
|
#if HUNTING_CAMERA_MCU == ENABLE
|
|
#include <sf_mcu.h>
|
|
#include "sf_led.h"
|
|
#endif
|
|
|
|
//dis
|
|
#if (MOVIE_DIS == ENABLE)
|
|
#include "dis_alg_lib.h"
|
|
#endif
|
|
#include "ai_ioctl.h"
|
|
#if (defined(_NVT_ETHREARCAM_TX_)) && (ETHCAM_EIS == ENABLE)
|
|
#include "eis_ioctl.h"
|
|
#endif
|
|
|
|
#define DEFAULT_STASK_SIZE 4096
|
|
|
|
/*******************************************************************
|
|
* Debug Flag
|
|
*******************************************************************/
|
|
#define DBG_PART_LOAD 0 /* debug partial load, set 1 to predload fw to DBG_PART_LOAD_PL_SECTION */
|
|
#define DBG_PART_LOAD_PL_SECTION CODE_SECTION_10 /* partial load preload section */
|
|
extern void DrvGOIO_Turn_Onoff_IRCUT(UINT8 onoff);
|
|
|
|
extern int NvtMain(void);
|
|
extern void System_OnVideoFastbootInit(void);
|
|
#if (defined(_NVT_ETHREARCAM_TX_)) && (ETHCAM_EIS == ENABLE)
|
|
extern int gyro_init(void);
|
|
#endif
|
|
static void insmod_system(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) { //Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
/* system */
|
|
#if defined(_FW_TYPE_PARTIAL_) || defined(_FW_TYPE_PARTIAL_COMPRESS_)
|
|
fwload_init();
|
|
fwload_wait_done(CODE_SECTION_01);
|
|
#endif
|
|
nvt_pinmux_init(); // pinmux
|
|
arb_init(); // arb
|
|
nvt_cmdsys_init(); // command system
|
|
nvt_examsys_init(); // exam system
|
|
pll_init(); // pll
|
|
clock_platform_init(); // clock (ckgen)
|
|
nvt_timer_drv_init(); // timer
|
|
drtc_platform_init(); // drtc
|
|
rtc_platform_init(); // rtc
|
|
hwclock_init(); // hardware clock
|
|
log_init(NULL); // kdrv_log
|
|
fastboot_init(); // fast boot
|
|
#if defined(_EMBMEM_EMMC_)
|
|
sdio_platform_init(); // sdio for emmc storage object
|
|
#endif
|
|
storage_partition_init(); // storage partition for partial load
|
|
#if (HUNTING_CAMERA_MODEL == DISABLE)
|
|
usb2dev_power_on_init(TRUE);//USB
|
|
#endif
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
|
|
} else {
|
|
vos_perf_list_mark("b_sys", __LINE__, 0);
|
|
|
|
/* system */
|
|
fwload_init();
|
|
fwload_wait_done(CODE_SECTION_01);
|
|
nvt_pinmux_init(); // pinmux
|
|
arb_init(); // arb
|
|
nvt_cmdsys_init(); // command system
|
|
nvt_examsys_init(); // exam system
|
|
pll_init(); // pll
|
|
clock_platform_init(); // clock (ckgen)
|
|
nvt_timer_drv_init(); // timer
|
|
drtc_platform_init(); // drtc
|
|
rtc_platform_init(); // rtc
|
|
hwclock_init(); // hardware clock
|
|
log_init(NULL); // kdrv_log
|
|
fastboot_init(); // fast boot
|
|
#if defined(_EMBMEM_EMMC_) || defined(_EMBMEM_COMBO_)
|
|
sdio_platform_init(); // sdio for emmc storage object
|
|
#endif
|
|
storage_partition_init(); // storage partition for partial load
|
|
|
|
if(hwclock_open(HWCLOCK_MODE_DRTC) != E_OK){
|
|
DBG_ERR("open hwclock failed!\n");
|
|
}
|
|
else{
|
|
#if HUNTING_CAMERA_MCU != ENABLE// The time is controlled by the MCU. sf_get_mcu_rtc_set_sys
|
|
struct tm current_time = {0};
|
|
struct tm current_time2 = {0};
|
|
|
|
current_time.tm_year = 2001;
|
|
current_time.tm_mon = 12;
|
|
current_time.tm_mday = 30;
|
|
current_time.tm_hour = 6;
|
|
current_time.tm_min = 0;
|
|
current_time.tm_sec = 0;
|
|
|
|
DBG_DUMP("hwclock_set_time TIME_ID_CURRENT\n");
|
|
|
|
hwclock_set_time(TIME_ID_CURRENT, current_time, 0);
|
|
current_time2 = hwclock_get_time(TIME_ID_CURRENT);
|
|
|
|
DBG_DUMP("hwclock_get_time TIME_ID_CURRENT y%lu m%lu\n", current_time2.tm_year, current_time2.tm_mon);
|
|
#endif
|
|
|
|
}
|
|
|
|
vos_perf_list_mark("b_sys", __LINE__, 1);
|
|
}
|
|
|
|
fastboot_set_done(BOOT_INIT_SYSTEM);
|
|
|
|
}
|
|
|
|
#if defined (_NVT_ETHERNET_RTOS_)
|
|
#include "netif/ethernet.h"
|
|
|
|
static struct netif nvt_netif;
|
|
#if (defined(_NVT_ETHREARCAM_TX_))
|
|
#include "UIApp/Network/EthCamAppNetwork.h"
|
|
#include "UIApp/Network/UIAppNetwork.h"
|
|
#include "nvt_eth.h"
|
|
#include "UIApp/EthCamCmdParser/EthCamCmdParser.h"
|
|
static char Tx_mac_addr[6]={0x00,0xff,0x3e,0x26,0x0a,0x6b};
|
|
UINT32 gEthCamDhcpCliOpened = false;
|
|
UINT32 gEthCamDhcpCliIP = 0;
|
|
char g_chEthCamDhcpCliIP[FIX_IP_MAX_LEN] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
static UINT32 gbEthCamEthLinkStatus=NVTETH_LINK_DOWN;
|
|
bool gEthCamDhcpCliFailIP = false;
|
|
extern void init_eth0(void);
|
|
unsigned int ethlinkstatusget(void)
|
|
{
|
|
return gbEthCamEthLinkStatus;
|
|
}
|
|
void ethlinkstatusset(unsigned int LinkStatus)
|
|
{
|
|
gbEthCamEthLinkStatus=LinkStatus;
|
|
}
|
|
void ethlinkstatusnofity(unsigned int sts)
|
|
{
|
|
//DBG_DUMP("ethlinkstatusnofity=================================sts=%d\n",sts);
|
|
|
|
unsigned int ethcam_tx_ipaddr=0xc00a8c0;//192.168.0.12
|
|
char ipccmd[40];
|
|
ethlinkstatusset(sts);
|
|
if(sts==NVTETH_LINK_UP){
|
|
if(gEthCamDhcpCliOpened && gEthCamDhcpCliIP==0){//DHCP
|
|
DBG_DUMP("Dhcp start but NO IP Get!\r\n"); //wait ethcamsettxip cmd
|
|
return;
|
|
}else if(gEthCamDhcpCliOpened==0 && gEthCamDhcpCliIP==0){//static
|
|
if(gEthCamDhcpCliFailIP==true){
|
|
init_eth0();//retry
|
|
}else{
|
|
DBG_DUMP("NO IP Get!\r\n"); //wait ethcamsettxip cmd
|
|
}
|
|
return;
|
|
}else{
|
|
if(gEthCamDhcpCliOpened==0){
|
|
}
|
|
}
|
|
}else{
|
|
if(gEthCamDhcpCliOpened){
|
|
}
|
|
}
|
|
ethcam_tx_ipaddr=gEthCamDhcpCliIP;
|
|
snprintf(ipccmd, sizeof(ipccmd) - 1, "ethlinknotify %d %d",ethcam_tx_ipaddr, sts);
|
|
//EthCamNet_EthLinkStatusNotify("ethlinknotify 201369792 2");
|
|
//DBG_DUMP("ipccmd=%s\n",ipccmd);
|
|
EthCamNet_EthLinkStatusNotify(ipccmd);
|
|
}
|
|
#endif
|
|
static void eth_init(void)
|
|
{
|
|
#if (defined(_NVT_ETHREARCAM_TX_))
|
|
ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
|
|
UINT32 bDhcpIP=0;
|
|
|
|
EthCamCmd_InstallID(ETH_REARCAM_CAPS_COUNT);
|
|
EthsockIpc_InstallID();
|
|
|
|
eth_set_bypass_phy_rst(1);//loader MUST init ethernet
|
|
ethcam_get_chipid();
|
|
eth_gen_mac_address(Tx_mac_addr);
|
|
eth_set_mac_address("eth0", Tx_mac_addr);
|
|
|
|
nvteth_register_link_cb(ethlinkstatusnofity);
|
|
if(gEthCamDhcpCliIP) {
|
|
DBG_DUMP("static ip=%d.%d.%d.%d\r\n", (gEthCamDhcpCliIP & 0xFF), (gEthCamDhcpCliIP >> 8) & 0xFF, (gEthCamDhcpCliIP >> 16) & 0xFF, (gEthCamDhcpCliIP >> 24) & 0xFF);
|
|
|
|
IP4_ADDR(&loop_gw, 192, 168, 0, 3);
|
|
IP4_ADDR(&loop_ipaddr, (gEthCamDhcpCliIP & 0xFF), (gEthCamDhcpCliIP >> 8) & 0xFF, (gEthCamDhcpCliIP >> 16) & 0xFF, (gEthCamDhcpCliIP >> 24) & 0xFF);
|
|
IP4_ADDR(&loop_netmask, 255, 255, 255, 0);
|
|
|
|
/* add the network interface */
|
|
netif_add(&nvt_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, ethernetif_init, tcpip_input);
|
|
|
|
/* Registers the default network interface */
|
|
netif_set_default(&nvt_netif);
|
|
|
|
if (netif_is_link_up(&nvt_netif)) {
|
|
/* When the netif is fully configured this function must be called */
|
|
netif_set_up(&nvt_netif);
|
|
} else {
|
|
/* When the netif link is down this function must be called */
|
|
netif_set_down(&nvt_netif);
|
|
}
|
|
}else{
|
|
//gEthCamDhcpCliIP=0xc00a8c0;
|
|
DBG_DUMP("DHCP\r\n");
|
|
gEthCamDhcpCliOpened=1;
|
|
IP4_ADDR(&loop_gw, 192, 168, 0, 3);
|
|
//IP4_ADDR(&loop_ipaddr, 192, 168, 0, 3);
|
|
IP4_ADDR(&loop_ipaddr, 0, 0, 0, 0);
|
|
IP4_ADDR(&loop_netmask, 255, 255, 255, 0);
|
|
|
|
/* add the network interface */
|
|
netif_add(&nvt_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, ethernetif_init, tcpip_input);
|
|
|
|
/* Registers the default network interface */
|
|
netif_set_default(&nvt_netif);
|
|
|
|
if (netif_is_link_up(&nvt_netif)) {
|
|
/* When the netif is fully configured this function must be called */
|
|
netif_set_up(&nvt_netif);
|
|
} else {
|
|
/* When the netif link is down this function must be called */
|
|
netif_set_down(&nvt_netif);
|
|
}
|
|
//if(ethlinkstatusget() == NVTETH_LINK_UP){
|
|
EthCamNet_LwIP_DHCP(&nvt_netif, DHCP_START);
|
|
UINT8* ip=EthCamNet_LwIP_GetIP(&nvt_netif);
|
|
DBG_DUMP("DHCP ip[0]=%d.%d.%d.%d\r\n",ip[0],ip[1],ip[2],ip[3]);
|
|
gEthCamDhcpCliIP=(ip[3]<<24)|(ip[2]<<16)|(ip[1]<<8)|ip[0];
|
|
//}
|
|
bDhcpIP= 1;
|
|
}
|
|
|
|
EthCam_UdpCheckConn(bDhcpIP);
|
|
if(gEthCamDhcpCliIP){
|
|
snprintf(g_chEthCamDhcpCliIP, FIX_IP_MAX_LEN, "%d.%d.%d.%d", (gEthCamDhcpCliIP & 0xFF), (gEthCamDhcpCliIP >> 8) & 0xFF, (gEthCamDhcpCliIP >> 16) & 0xFF, (gEthCamDhcpCliIP >> 24) & 0xFF);
|
|
DBG_DUMP("gDhcpCliIP=0x%x, %s\r\n",gEthCamDhcpCliIP,g_chEthCamDhcpCliIP);
|
|
if(ethlinkstatusget()==NVTETH_LINK_UP){
|
|
//ethlinkstatusnofity(NVTIMETH_LINK_UP);
|
|
char ipccmd[40]={0};
|
|
snprintf(ipccmd, sizeof(ipccmd) - 1, "ethlinknotify %d %d",gEthCamDhcpCliIP, NVTETH_LINK_UP);
|
|
EthCamNet_EthLinkStatusNotify(ipccmd);
|
|
}
|
|
}
|
|
|
|
#else
|
|
ip4_addr_t loop_ipaddr, loop_netmask, loop_gw;
|
|
IP4_ADDR(&loop_gw, 192, 168, 0, 3);
|
|
IP4_ADDR(&loop_ipaddr, 192, 168, 0, 12);
|
|
IP4_ADDR(&loop_netmask, 255, 255, 255, 0);
|
|
|
|
/* add the network interface */
|
|
netif_add(&nvt_netif, &loop_ipaddr, &loop_netmask, &loop_gw, NULL, ethernetif_init, tcpip_input);
|
|
|
|
/* Registers the default network interface */
|
|
netif_set_default(&nvt_netif);
|
|
|
|
if (netif_is_link_up(&nvt_netif)) {
|
|
/* When the netif is fully configured this function must be called */
|
|
netif_set_up(&nvt_netif);
|
|
} else {
|
|
/* When the netif link is down this function must be called */
|
|
netif_set_down(&nvt_netif);
|
|
}
|
|
#endif
|
|
}
|
|
#if (defined(_NVT_ETHREARCAM_TX_))
|
|
void init_eth0(void)
|
|
{
|
|
EthCamNet_RegInitEthCB(eth_init);
|
|
EthCamNet_InitEth_Open();
|
|
EthCamNet_TrigInitEth();
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
static void * get_fdt_by_sensor_type(char *name)
|
|
{
|
|
if (strstr(name, "nvt_sen_ad")) {
|
|
return (void *)fdt_get_base();
|
|
}
|
|
return fdt_get_sensor();
|
|
}
|
|
|
|
static void insmod_sensor(void)
|
|
{
|
|
SENSOR_DTSI_INFO dtsi_info;
|
|
|
|
fwload_wait_done(CODE_SECTION_02);
|
|
vos_perf_list_mark("b_sen", __LINE__, 0);
|
|
|
|
dtsi_info.addr = fdt_get_sensor();
|
|
SEN_INIT(_SEN1_, &dtsi_info); //sensor (macro expression like invoking sen_init_imx290(), sen_init_os02k10()
|
|
|
|
vos_perf_list_mark("b_sen", __LINE__, 1);
|
|
fastboot_set_done(BOOT_INIT_SENSOR);
|
|
}
|
|
|
|
static void sie_vd_cb(const UINT32 vd_cnt)
|
|
{
|
|
if(vd_cnt == (PHOTOFAST_CAP_FRAME_CNT-1)){
|
|
vos_perf_list_mark("sie_vd", __LINE__, vd_cnt);
|
|
}
|
|
//if(vd_cnt == 3)
|
|
// sf_trigger_time_led_cb(vd_cnt);
|
|
}
|
|
|
|
static void insmod_capture(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) {//Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
SENSOR_DTSI_INFO dtsi_info;
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
nvtmpp_init(); // nvtmpp_init is in part-3
|
|
mempool_init();
|
|
#endif
|
|
|
|
/* capture */
|
|
kdrv_ife_rtos_init(); // ife engine
|
|
kdrv_dce_rtos_init(); // dce engine
|
|
kdrv_ipe_rtos_init(); // ipe engine
|
|
ime_builtin_rtos_init(); // ime engine
|
|
//kdrv_ife2_init(); // ife2 engine
|
|
kdrv_sie_init(); // sie engine
|
|
grph_platform_init(); // graphic engine
|
|
kdrv_ise_drv_init(); // ise engine
|
|
kflow_ctl_ipp_init(); // control ipp
|
|
kflow_ctl_sie_init(); // control sensor
|
|
kflow_videocap_init(); // video capture
|
|
kflow_videoproc_init(); // video process
|
|
isp_api_reg_if(0x1B); // isp
|
|
ae_init_module(0x1B); // ae
|
|
awb_init_module(0x1B); // awb
|
|
iq_init_module(0x1B, 1, 1, 1); // iq, dpc_en=1, ecs_en=1, 2dlut_en=1
|
|
nvt_gfx_init(); // gfx
|
|
nvt_vds_init(); // video srpite
|
|
|
|
#if defined (_NVT_ETHERNET_RTOS_)
|
|
eth_lwip_init();
|
|
#endif
|
|
lwip_socket_init(); // lwip netowrk stack
|
|
tcpip_init(NULL, NULL); // tcp ip udp
|
|
#if defined (_NVT_ETHERNET_RTOS_)
|
|
#if !(defined(_NVT_ETHREARCAM_TX_))
|
|
eth_init();
|
|
#endif
|
|
#endif
|
|
|
|
dtsi_info.addr = get_fdt_by_sensor_type(SEN_DRV_NAME(_SEN1_));
|
|
SEN_INIT(_SEN1_, &dtsi_info);
|
|
dtsi_info.addr = get_fdt_by_sensor_type(SEN_DRV_NAME(_SEN2_));
|
|
SEN_INIT(_SEN2_, &dtsi_info);
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
} else { //fastboot boot for hunting camera
|
|
fwload_wait_done(CODE_SECTION_03);
|
|
vos_perf_list_mark("b_cap", __LINE__, 0);
|
|
|
|
// allocate fixed memory (nvtmpp is required for mempool_init)
|
|
nvtmpp_init(); // nvtmpp_init is in part-3
|
|
mempool_init();
|
|
|
|
/* capture */
|
|
kdrv_sie_init(); // sie engine
|
|
kdrv_ife_rtos_init(); // ife engine
|
|
kdrv_dce_rtos_init(); // dce engine
|
|
kdrv_ipe_rtos_init(); // ipe engine
|
|
ime_builtin_rtos_init();// ime engine
|
|
//kdrv_ife2_rtos_init(); // ife2 engine
|
|
grph_platform_init(); // graphic engine
|
|
kdrv_ise_drv_init(); // ise engine
|
|
kflow_ctl_ipp_init(); // control ipp
|
|
kflow_ctl_sie_init(); // control sensor
|
|
kflow_videocap_init(); // video capture
|
|
kflow_videoproc_init(); // video process
|
|
isp_api_reg_if(0x1B); // isp
|
|
ae_init_module(0x1B); // ae
|
|
awb_init_module(0x1B); // awb
|
|
iq_init_module(0x1B, 1, 1, 1); // iq, dpc_en=1, ecs_en=1, 2dlut_en=1
|
|
nvt_gfx_init(); // gfx
|
|
nvt_vds_init(); // video srpite
|
|
|
|
kdrv_builtin_set_sie_vd_cb(sie_vd_cb);
|
|
|
|
vos_perf_list_mark("b_cap", __LINE__, 1);
|
|
}
|
|
|
|
fastboot_set_done(BOOT_INIT_CAPTURE);
|
|
}
|
|
|
|
static void insmod_display(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) {//Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
/* display */
|
|
kflow_videoout_init(); // video output
|
|
panel_init(); // panel
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
} else { //fastboot boot for hunting camera
|
|
fwload_wait_done(CODE_SECTION_04);
|
|
|
|
/* display */
|
|
#if (_PACKAGE_DISPLAY_)
|
|
kflow_videoout_init(); // video output
|
|
panel_init(); // panel
|
|
#endif
|
|
}
|
|
|
|
fastboot_set_done(BOOT_INIT_DISPLAY);
|
|
}
|
|
|
|
static void insmod_storage(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) { //Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
/* storage */
|
|
#if !defined(_EMBMEM_EMMC_)
|
|
sdio_platform_init(); // sdio
|
|
#endif
|
|
// card_init(); // sd card
|
|
filesys_init(); // file system
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
} else { //fastboot boot for hunting camera
|
|
fwload_wait_done(CODE_SECTION_04);
|
|
vos_perf_list_mark("b_strg", __LINE__, 0);
|
|
|
|
/* storage */
|
|
#if (_PACKAGE_SDCARD_)
|
|
#if !defined(_EMBMEM_EMMC_) && !defined(_EMBMEM_COMBO_)
|
|
sdio_platform_init(); // sdio
|
|
#endif
|
|
card_init(); // sd card
|
|
#endif
|
|
|
|
#if (_PACKAGE_FILESYS_)
|
|
filesys_init(); // file syste
|
|
#endif
|
|
|
|
vos_perf_list_mark("b_strg", __LINE__, 1);
|
|
}
|
|
|
|
fastboot_set_done(BOOT_INIT_STORAGE);
|
|
}
|
|
|
|
static void insmod_encoder(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) { //Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
/* media encoder */
|
|
kflow_videoenc_init(); // video encoder
|
|
isp_api_reg_enc_if(); // after vdoenc inited, notify isp can use vdoenc's api
|
|
kflow_audiocap_init(); // audio capture
|
|
kflow_audioenc_init(); // audio encoder
|
|
kdrv_audio_init();
|
|
kdrv_audlib_aac_init();
|
|
//kdrv_audlib_g711_init();
|
|
#if (ANR_FUNC == ENABLE)
|
|
kdrv_audlib_anr_init(); // anr
|
|
#endif
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
} else { //fastboot
|
|
fwload_wait_done(CODE_SECTION_05);
|
|
|
|
/* media encoder */
|
|
#if (_PACKAGE_VIDEO_)
|
|
kflow_videoenc_init(); // video encoder
|
|
isp_api_reg_enc_if(); // after vdoenc inited, notify isp can use vdoenc's api
|
|
#endif
|
|
|
|
#if (_PACKAGE_AUDIO_)
|
|
kflow_audiocap_init(); // audio capture
|
|
kflow_audioenc_init(); // audio encoder
|
|
kdrv_audio_init();
|
|
kdrv_audlib_aac_init();
|
|
#endif
|
|
}
|
|
|
|
fastboot_set_done(BOOT_INIT_MEIDA_ENCODER);
|
|
}
|
|
|
|
static void insmod_others(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) { //Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
/* others */
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
usb2dev_power_on_init(TRUE);//USB
|
|
#endif
|
|
#if (ALG_FUNC_AI2 == ENABLE)
|
|
nvt_ai_drv_init_rtos();
|
|
#endif
|
|
SwTimer_Init(); // sw timer
|
|
SxTimer_Init(); // detect system
|
|
GxTimer_Init(); // UI timer
|
|
kflow_videodec_init(); // video decoder
|
|
kflow_audiodec_init(); // audio decoder
|
|
kflow_audioout_init(); // audio output
|
|
|
|
#if (MOVIE_DIS == ENABLE)
|
|
dis_init_module(0x1B); // kflow_dis
|
|
#endif
|
|
|
|
sdp_platform_init(); // SDP (spi slave like)
|
|
spi_platform_init(); // SPI (SPI master)
|
|
gpio_platform_init(); // gpio interrupt
|
|
DbgUt_Init(); // Init DbgUt to measure usage of CPU/DMA
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
} else { //fastboot
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
|
|
#if defined(_FW_TYPE_PARTIAL_) || defined(_FW_TYPE_PARTIAL_COMPRESS_)
|
|
// !!!!! global c++'s constructors will be out of control on partial load tech. !!!!
|
|
// !!!!! so we only allow to use c++ after section_10 loaded. !!!!
|
|
// c++'s constructors init
|
|
constructors_init();
|
|
#endif
|
|
/* others */
|
|
SwTimer_Init(); // sw timer
|
|
DbgUt_Init(); // init DbgUt to measure usage of CPU/DMA
|
|
#if (_PACKAGE_VIDEO_)
|
|
kflow_videodec_init(); // video decoder
|
|
#endif
|
|
#if (_PACKAGE_AUDIO_)
|
|
kflow_audiodec_init(); // audio decoder
|
|
kflow_audioout_init(); // audio output
|
|
#endif
|
|
#if (POWERON_MODE != POWERON_MODE_BOOT_LINUX)
|
|
sdp_platform_init(); // SDP (spi slave like)
|
|
spi_platform_init(); // SPI (SPI master)
|
|
#endif
|
|
storage_partition_init2(); // init others storage partition after fastboot
|
|
}
|
|
|
|
fastboot_set_done(BOOT_INIT_OTHERS);
|
|
|
|
}
|
|
|
|
void insmod(void)
|
|
{
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) { //Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
insmod_system();
|
|
#if defined(_FW_TYPE_PARTIAL_) || defined(_FW_TYPE_PARTIAL_COMPRESS_)
|
|
//start partial load
|
|
VK_TASK_HANDLE vkt_partload = vos_task_create(fastboot_thread, fwload_partload, "init_partload", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_partload);
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
#endif
|
|
insmod_capture();
|
|
insmod_display();
|
|
insmod_storage();
|
|
insmod_encoder();
|
|
insmod_others();
|
|
} else {
|
|
|
|
// all insmod depend on insmod_system, so call it first
|
|
insmod_system();
|
|
|
|
#if DBG_PART_LOAD /* debug partial load, preload fw to section 10 */
|
|
//start partial load
|
|
VK_TASK_HANDLE vkt_partload = vos_task_create(fastboot_thread, fwload_partload, "init_partload", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_partload);
|
|
DBG_DUMP("********* debug partial load, preload section %u *********\n", DBG_PART_LOAD_PL_SECTION + 1);
|
|
fwload_wait_done(DBG_PART_LOAD_PL_SECTION);
|
|
#endif
|
|
|
|
if(DrvGPIO_GetPhotoMovieModeFromMonitor() != DX_HUNTING_MODE_OTHER){
|
|
// create task for multi-init after startinsmod_system();
|
|
VK_TASK_HANDLE vkt_sensor = vos_task_create(fastboot_thread, insmod_sensor, "init_sensor", 5, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_sensor);
|
|
VK_TASK_HANDLE vkt_capture = vos_task_create(fastboot_thread, insmod_capture, "init_capture", 5, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_capture);
|
|
VK_TASK_HANDLE vkt_display = vos_task_create(fastboot_thread, insmod_display, "init_display", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_display);
|
|
VK_TASK_HANDLE vkt_storage = vos_task_create(fastboot_thread, insmod_storage, "init_storage", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_storage);
|
|
VK_TASK_HANDLE vkt_encoder = vos_task_create(fastboot_thread, insmod_encoder, "init_encoder", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_encoder);
|
|
VK_TASK_HANDLE vkt_others = vos_task_create(fastboot_thread, insmod_others, "init_others", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_others);
|
|
}
|
|
|
|
#if !DBG_PART_LOAD /* normal partial load */
|
|
//start partial load
|
|
VK_TASK_HANDLE vkt_partload = vos_task_create(fastboot_thread, fwload_partload, "init_partload", 10, DEFAULT_STASK_SIZE);
|
|
vos_task_resume(vkt_partload);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
extern void System_OnTimerInit(void);
|
|
|
|
#if ((defined(_MODEL_565_CARDV_HS880C_)||defined(_MODEL_565_CARDV_HS880CC_))&&LOGFILE_FUNC==ENABLE)
|
|
inline static void serial_open_GPS(void) {
|
|
UART_INIT_PARA UartParaBasic;
|
|
|
|
uart_open();
|
|
|
|
UartParaBasic.BaudRate = UART_BAUDRATE_9600;
|
|
UartParaBasic.BaudRate = 9600 ;
|
|
UartParaBasic.Length = UART_LEN_L8_S1;
|
|
UartParaBasic.Parity = UART_PARITY_NONE;
|
|
UartParaBasic.FlowCtrlMode = UART_FC_MODE_NONE;
|
|
UartParaBasic.DataTransMode = UART_DATA_TRANS_PIO;
|
|
|
|
uart_initHW(&UartParaBasic);
|
|
}
|
|
#endif
|
|
|
|
#define I2C_SW_RESET DISABLE
|
|
|
|
#if (I2C_SW_RESET == ENABLE)
|
|
#define I2C_SCL P_GPIO(22)
|
|
#define I2C_SDA P_GPIO(21)
|
|
void Nvti2c_DevPowerOnReset(UINT32 GpioI2cCLK, UINT32 GpioI2cDAT)
|
|
{
|
|
UINT32 UnitTimeUs = 6;// H/L unit time use 6us
|
|
UINT32 i;
|
|
|
|
gpio_setDir(GpioI2cCLK, GPIO_DIR_INPUT);
|
|
gpio_setDir(GpioI2cDAT, GPIO_DIR_INPUT);
|
|
|
|
if (gpio_getPin(GpioI2cCLK)) {
|
|
if (gpio_getPin(GpioI2cDAT)) {
|
|
// Both the CLK&DAT are high.
|
|
// We issue START & STOP to reset ext device
|
|
gpio_setDir(GpioI2cDAT, GPIO_DIR_OUTPUT);
|
|
gpio_clearPin(GpioI2cDAT);
|
|
vos_util_delay_us(UnitTimeUs << 1);
|
|
gpio_setDir(GpioI2cDAT, GPIO_DIR_INPUT);
|
|
} else {
|
|
// CLK is High But Data is Low.
|
|
// We Toggle clock pin and wait device release DATA pin.
|
|
// And then issue START & STOP to reset ext device
|
|
for (i = 0; i < 8; i++) {
|
|
gpio_setDir(GpioI2cCLK, GPIO_DIR_OUTPUT);
|
|
gpio_clearPin(GpioI2cCLK);
|
|
vos_util_delay_us(UnitTimeUs);
|
|
gpio_setDir(GpioI2cCLK, GPIO_DIR_INPUT);
|
|
vos_util_delay_us(UnitTimeUs);
|
|
|
|
if (gpio_getPin(GpioI2cDAT)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (gpio_getPin(GpioI2cDAT)) {
|
|
gpio_setDir(GpioI2cDAT, GPIO_DIR_OUTPUT);
|
|
gpio_clearPin(GpioI2cDAT);
|
|
vos_util_delay_us(UnitTimeUs << 1);
|
|
gpio_setDir(GpioI2cDAT, GPIO_DIR_INPUT);
|
|
} else {
|
|
debug_err(("i2c Dev no relase DAT pin\r\n"));
|
|
}
|
|
|
|
}
|
|
} else {
|
|
debug_err(("i2c clk pin is keeping low!\r\n"));
|
|
}
|
|
|
|
gpio_setDir(GpioI2cCLK, GPIO_DIR_INPUT);
|
|
gpio_setDir(GpioI2cDAT, GPIO_DIR_INPUT);
|
|
}
|
|
#endif
|
|
|
|
#define FASTBOOT_KEYSCAN_FUNC DISABLE
|
|
#define FASTBOOT_USB_FUNC DISABLE
|
|
|
|
static void fastboot(void)
|
|
{
|
|
VK_TASK_HANDLE handle_photo_filenaming = 0;
|
|
VK_TASK_HANDLE handle_movie_filenaming = 0;
|
|
VK_TASK_HANDLE handle_movie_moviemode = 0;
|
|
#if (FASTBOOT_USB_FUNC == ENABLE)
|
|
VK_TASK_HANDLE handle_usb_msdcmode = 0;
|
|
VK_TASK_HANDLE handle_usb_uvacmode = 0;
|
|
#endif
|
|
|
|
vos_perf_list_reset();
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
// show the first message
|
|
serial_open(); // uart init first for debug message
|
|
printf("\nHello RTOS World! (%s)\n\n", __DATE__ " - " __TIME__);
|
|
|
|
// insmod for modules initialzation
|
|
insmod();
|
|
|
|
#if (FASTBOOT_USB_FUNC == ENABLE)
|
|
flow_system_get_usb_status();
|
|
#endif
|
|
|
|
#if (POWERON_MODE == POWERON_MODE_PREVIEW)
|
|
|
|
UINT32 photo_movie_mode = DrvGPIO_GetPhotoMovieModeFromMonitor();
|
|
// wait all text-code loaded
|
|
//printf("********* FL_BOOT_WORK_MODE_MENU = %d *********\n",SysGetFlag(FL_BOOT_WORK_MODE_MENU));
|
|
//printf("********* photo_movie_mode = %d *********\n",photo_movie_mode);
|
|
|
|
//#NT#2023/01/11#Eric - begin
|
|
/*next code just for rtos test.
|
|
*FL_BOOT_WORK_MODE_MENU add in linux SDK, then delete this.
|
|
*use Cmd_movie_set_boot_mode for test
|
|
**/
|
|
SysGetFlag(CamMode);
|
|
//Save_MenuInfo();
|
|
//#NT#2023/01/11#Eric - end
|
|
|
|
// start preview
|
|
switch (photo_movie_mode) {
|
|
case DX_HUNTING_MODE_PHOTO:
|
|
case DX_HUNTING_MODE_PHOTO_MOVIE:
|
|
case DX_HUNTING_MODE_CAMERA_PHOTO:
|
|
case DX_HUNTING_MODE_CAMERA_PHOTO_MOVIE:
|
|
|
|
flow_preview();
|
|
|
|
#if (HUNTING_CAMERA_BOOT_LINUX == ENABLE)
|
|
fwload_wait_done(CODE_SECTION_03);
|
|
flow_boot_linux();
|
|
#endif
|
|
|
|
// wait all text-code loaded
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
|
|
handle_photo_filenaming = vos_task_create(PhotoFast_InitFileNamingThread, "init_fn", NULL, 10, DEFAULT_STASK_SIZE);
|
|
if(!handle_photo_filenaming){
|
|
DBG_ERR("create PhotoFast_InitFileNamingThread failed\n");
|
|
}
|
|
else
|
|
vos_task_resume(handle_photo_filenaming);
|
|
|
|
break;
|
|
|
|
case DX_HUNTING_MODE_MOVIE:
|
|
case DX_HUNTING_MODE_CAMERA_MOVIE:
|
|
|
|
#if (HUNTING_CAMERA_BOOT_LINUX == ENABLE)
|
|
fwload_wait_done(CODE_SECTION_03);
|
|
flow_boot_linux();
|
|
#endif
|
|
|
|
flow_movie();
|
|
|
|
// wait all text-code loaded
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
|
|
System_OnPowerPreInit();
|
|
System_OnVideoFastbootInit();
|
|
|
|
handle_movie_filenaming = vos_task_create(MovieFast_InitFileNamingThread, "init_fn", NULL, 10, DEFAULT_STASK_SIZE);
|
|
if (!handle_movie_filenaming) {
|
|
DBG_ERR("create MovieFast_InitFileNamingThread failed\r\n");
|
|
}
|
|
else
|
|
vos_task_resume(handle_movie_filenaming);
|
|
|
|
fastboot_wait_done(BOOT_INIT_FILENAMINGOK);
|
|
|
|
handle_movie_moviemode = vos_task_create(MovieFast_InitMovieModeThread, "init_movie", NULL, 10, DEFAULT_STASK_SIZE);
|
|
if (!handle_movie_moviemode) {
|
|
DBG_ERR("create MovieFast_InitMovieModeThread failed\r\n");
|
|
}
|
|
else
|
|
vos_task_resume(handle_movie_moviemode);
|
|
|
|
break;
|
|
|
|
case DX_HUNTING_MODE_OTHER: /* boot linux only*/
|
|
DBG_DUMP("****** DX_HUNTING_MODE_OTHER ******\n");
|
|
DrvGOIO_Turn_Onoff_IRCUT(1);
|
|
|
|
#if (HUNTING_CAMERA_BOOT_LINUX == ENABLE)
|
|
fwload_wait_done(CODE_SECTION_03);
|
|
flow_boot_linux();
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
fastboot_set_done(BOOT_FLOW_BOOT);
|
|
flow_wait_linux();
|
|
#endif
|
|
break;
|
|
|
|
#if (FASTBOOT_USB_FUNC == ENABLE)
|
|
case DX_HUNTING_MODE_CAMERA_MSDC:
|
|
flow_movie();
|
|
// wait all text-code loaded
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
|
|
handle_usb_msdcmode = vos_task_create(UsbDiskFast_InitMsdcModeThread, "init_usb_msdc", NULL, 10, DEFAULT_STASK_SIZE);
|
|
if (!handle_usb_msdcmode) {
|
|
DBG_ERR("create UsbCamFast_InitMsdcModeThread failed\r\n", );
|
|
}
|
|
else
|
|
vos_task_resume(handle_usb_msdcmode);
|
|
break;
|
|
|
|
case DX_HUNTING_MODE_CAMERA_UVAC:
|
|
flow_movie();
|
|
// wait all text-code loaded
|
|
fwload_wait_done(CODE_SECTION_10);
|
|
|
|
handle_usb_uvacmode = vos_task_create(UsbCamFast_InitUvacModeThread, "init_usb_uvac", NULL, 10, DEFAULT_STASK_SIZE);
|
|
if (!handle_usb_uvacmode) {
|
|
DBG_ERR("create UsbCamFast_InitUvacModeThread failed\r\n");
|
|
}
|
|
else
|
|
vos_task_resume(handle_usb_uvacmode);
|
|
break;
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
vos_perf_list_mark(__func__, __LINE__, 1);
|
|
}
|
|
|
|
void rtos_main(void)
|
|
{
|
|
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if (DrvGPIO_GetHuntingWorkMode() == HUNTING_NORMAL_MODE) { //Normal boot for hunting camera
|
|
#else
|
|
if (1) { //cardv model
|
|
#endif
|
|
#if ((defined(_MODEL_565_CARDV_HS880C_)||defined(_MODEL_565_CARDV_HS880CC_))&&LOGFILE_FUNC==ENABLE)
|
|
CONSOLE console = {0};
|
|
|
|
console_get_none(&console);
|
|
console_set_curr(&console);
|
|
#endif
|
|
vos_perf_list_reset();
|
|
vos_perf_list_mark(__func__, __LINE__, 0);
|
|
|
|
// show the first message
|
|
#if ((defined(_MODEL_565_CARDV_HS880C_)||defined(_MODEL_565_CARDV_HS880CC_))&&LOGFILE_FUNC==ENABLE)
|
|
serial_open_GPS();
|
|
#else
|
|
serial_open(); // uart init first for debug message
|
|
#endif
|
|
printf("\nHello RTOS World! (%s)\n\n", __DATE__ " - " __TIME__);
|
|
|
|
#if (HUNTING_CAMERA_MODEL == DISABLE)
|
|
// nvtmpp init for continuous memory allocate
|
|
nvtmpp_init();
|
|
|
|
// allocate fixed memory for module initialzation
|
|
mempool_init();
|
|
#endif
|
|
|
|
#if (I2C_SW_RESET == ENABLE)
|
|
Nvti2c_DevPowerOnReset(I2C_SCL, I2C_SDA);
|
|
#endif
|
|
|
|
// insmod for modules initialzation
|
|
insmod();
|
|
|
|
#if (defined(_NVT_ETHREARCAM_TX_)) && (ETHCAM_EIS == ENABLE)
|
|
eis_init_module();
|
|
gyro_init();
|
|
#endif
|
|
|
|
NvtMain();
|
|
} else { //fastboot for hunting camera
|
|
#if (POWERON_FAST_BOOT_MSG == DISABLE)
|
|
fastboot_msg_en(DISABLE);
|
|
#endif
|
|
VK_TASK_HANDLE vkt_boot = vos_task_create(fastboot_thread, fastboot, "boot", 9, 10240);
|
|
vos_task_resume(vkt_boot);
|
|
fastboot_wait_done(BOOT_FLOW_BOOT);
|
|
// show report after filesys initialtion,
|
|
// because filesys is the last place
|
|
// fastboot_wait_done(BOOT_INIT_STORAGE);
|
|
#if (POWERON_FAST_BOOT_MSG == DISABLE)
|
|
fastboot_msg_en(ENABLE);
|
|
#endif
|
|
|
|
#if (FASTBOOT_KEYSCAN_FUNC == ENABLE) // enable for keyscan / usb function, but need modify lds file
|
|
flow_system_init();
|
|
#endif
|
|
}
|
|
}
|
|
|
|
|