int WifiCmd_GetData(char* path, char* argument, cyg_uint32 bufAddr, cyg_uint32* bufSize, char* mimeType, cyg_uint32 segmentCount) { UINT32 cmd=0,par=0; char* pch=0; UINT32 ret =0; UINT32 UserCB = 0; //char *parStr;//post event,data in stack would release DBG_IND("Data2 path = %s, argument -> %s, mimeType= %s, bufsize= %d, segmentCount= %d\r\n",path,argument, mimeType, *bufSize, segmentCount); if(strncmp(argument,CMD_STR,strlen(CMD_STR))==0) { if(segmentCount==0) WifiCmd_Lock(); sscanf(argument+strlen(CMD_STR),"%d",&cmd); pch=strchr(argument+strlen(CMD_STR),'&'); if(pch) { if(strncmp(pch,PAR_STR,strlen(PAR_STR))==0) { sscanf(pch+strlen(PAR_STR),"%d",&par); ret = WifiCmd_DispatchCmd(cmd,WIFICMD_PAR_NUM,par,&UserCB); } else if(strncmp(pch,PARS_STR,strlen(PARS_STR))==0) { //DBG_ERR("%s\r\n",pch+strlen(PARS_STR)); ret = WifiCmd_DispatchCmd(cmd,WIFICMD_PAR_STR,(UINT32)pch+strlen(PARS_STR),&UserCB); } } else { ret = WifiCmd_DispatchCmd(cmd,WIFICMD_PAR_NULL,0,&UserCB); } if(UserCB) { UINT32 hfs_result; hfs_result = ((cyg_hfs_getCustomData *)UserCB)(path,argument,bufAddr,bufSize,mimeType,segmentCount); if(hfs_result != CYG_HFS_CB_GETDATA_RETURN_CONTINUE) WifiCmd_Unlock(); return hfs_result; } else //default return value xml { if(gDefReturnFormat) { gDefReturnFormat(cmd,ret,bufAddr,bufSize,mimeType); WifiCmd_Unlock(); return CYG_HFS_CB_GETDATA_RETURN_OK; } else { DBG_ERR("no default CB\r\n"); WifiCmd_Unlock(); return CYG_HFS_CB_GETDATA_RETURN_ERROR; } } } else //for test,list url command { UINT32 len=0; char* buf = (char*)bufAddr; FST_FILE filehdl=0; char pFilePath[32]; UINT32 fileLen =*bufSize; sprintf(pFilePath,"%s",HTML_PATH); //html of all command list filehdl = FileSys_OpenFile(pFilePath,FST_OPEN_READ); if(filehdl) { // set the data mimetype strcpy(mimeType,"text/html"); FileSys_ReadFile(filehdl, (UINT8 *)buf, &fileLen, 0,0); FileSys_CloseFile(filehdl); *bufSize = fileLen; *(buf+fileLen) ='\0'; } else { strcpy(mimeType,"text/html"); len = sprintf(buf,"no %s file",HTML_PATH); buf+=len; *bufSize = (cyg_uint32)(buf)-bufAddr; } } return CYG_HFS_CB_GETDATA_RETURN_OK; }
static BOOL UI_WriteLogoFileName(UINT32 logoId) { FST_FILE pFile; UINT32 uiFileSize; UINT8 *BgBuf; char *fileName; IRECT Rect = {0, 0, 320, 240}; ER erReturn = E_OK; PSTORE_SECTION_HANDLE* pSecHdl; // to save the handle of PStore section char *psecnameId; if (logoId == UI_LOGO_POWERON) { fileName = "A:\\logo.jpg"; psecnameId = PS_POWERON_LOGO; } else //if (logoId == UI_LOGO_POWEROFF) { fileName = "A:\\logo2.jpg"; psecnameId = PS_POWEROFF_LOGO; } FileSys_WaitFinish(); pFile = FileSys_OpenFile(fileName, FST_OPEN_READ); if (pFile == NULL) { debug_err(("open file error\r\n")); return FALSE; } uiFileSize = FileSys_GetFileLen(fileName); // for small page nand USE_MSG(("file size = %d\r\n",uiFileSize)); if ((uiFileSize < 1024) || (uiFileSize > LOGO_MAX_FILESIZE)) { Cal_FillRect(&Rect, _OSD_INDEX_BLACK); Cal_ShowStringByColor("jpg size is too big or too small\n", &Rect, _OSD_INDEX_YELLOW, _OSD_INDEX_BLACK); Delay_DelayMs(3000); Cal_FillRect(&Rect, _OSD_INDEX_BLACK); debug_err(("Write logo error\n\r")); return FALSE; } BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP); if (FileSys_ReadFile(pFile,(UINT8 *)(BgBuf+4),&uiFileSize,FST_FLAG_NONE,NULL)!=FST_STA_OK) { USE_MSG(("file read failed\r\n")); return FALSE; } FileSys_CloseFile(pFile); *BgBuf = LO_BYTE(LO_WORD(uiFileSize)); *(BgBuf+1) = HI_BYTE(LO_WORD(uiFileSize)); *(BgBuf+2) = LO_BYTE(HI_WORD(uiFileSize)); *(BgBuf+3) = HI_BYTE(HI_WORD(uiFileSize)); pSecHdl = PStore_OpenSection(psecnameId, PS_RDWR | PS_CREATE); if (pSecHdl == E_PS_SECHDLER) { debug_err(("Section open fail\r\n")); goto err_ret; } erReturn = PStore_WriteSection(BgBuf, 0, SYSPARAM_LOGO_LEN, pSecHdl); if (erReturn != E_PS_OK) { debug_err(("PStore program error\r\n")); goto err_ret; } //#PIC#2010/07/23#Creator -begin PStore_CloseSection(pSecHdl); //#PIC#2010/07/23#Creator -end return TRUE; err_ret: PStore_CloseSection(pSecHdl); //PStore_DisablePS(); return FALSE; }
void UI_UpdateCfgFile(void) { #if 0 UINT32 uiKeyAct, uiKeyCode; FLGPTN uiFlag; #endif char* str; FST_FILE pFile; UINT32 uiFileSize; UINT8 *BgBuf; char *fileName; IRECT Rect = {0, 0, 320, 240}; BOOL Ret =TRUE ; ER erReturn; PSTORE_SECTION_HANDLE* pSecHdl; // to save the handle of PStore section fileName = "A:\\NTCONFIG.bin"; FileSys_WaitFinish(); pFile = FileSys_OpenFile(fileName, FST_OPEN_READ); if (pFile == NULL) { debug_err(("open file error\r\n")); Ret =FALSE; } uiFileSize = FileSys_GetFileLen(fileName); // for small page nand USE_MSG(("file size = %d\r\n",uiFileSize)); //if file is null if (uiFileSize == 0) { USE_MSG(("file size is 0\r\n")); Ret =FALSE; } if (uiFileSize > CFG_MAX_FILESIZE) { USE_MSG(("file size is bigger = %d\r\n",uiFileSize)); Ret =FALSE; } //get_blk((void *)&BgBuf, POOL_ID_SICD); //rel_blk(POOL_ID_SICD, BgBuf); //SysGetSICDAddr((UINT32*)&BgBuf); BgBuf = (UINT8 *)OS_GetMempoolAddr(POOL_ID_APP); if (FileSys_ReadFile(pFile,BgBuf,&uiFileSize,FST_FLAG_NONE,NULL)!=FST_STA_OK) { USE_MSG(("file read failed\r\n")); Ret =FALSE; } FileSys_CloseFile(pFile); *BgBuf = LO_BYTE(LO_WORD(uiFileSize)); *(BgBuf+1) = HI_BYTE(LO_WORD(uiFileSize)); *(BgBuf+2) = LO_BYTE(HI_WORD(uiFileSize)); *(BgBuf+3) = HI_BYTE(HI_WORD(uiFileSize)); //PStore_EnablePS(); pSecHdl = PStore_OpenSection(PS_BG_CFG, PS_RDWR | PS_CREATE); if (pSecHdl == E_PS_SECHDLER) { debug_err(("Section open fail\r\n")); PStore_CloseSection(pSecHdl); //PStore_DisablePS(); Ret =FALSE; } erReturn = PStore_WriteSection(BgBuf, 0, SYSPARAM_SYSFLAG_LEN, pSecHdl); PStore_CloseSection(pSecHdl); if (erReturn != E_PS_OK) { debug_err(("PStore program error\r\n")); Ret =FALSE; } Cal_FillRect(&Rect, _OSD_INDEX_BLACK); Rect.x = 56; Rect.y = 108; Rect.w = 212; Rect.h = 24; if (Ret == FALSE) { str = "Update Cfg file error"; Cal_ShowStringByColor(str, &Rect, _OSD_INDEX_YELLOW, _OSD_INDEX_BLACK); }else { str = "Update Cfg file ok"; Cal_ShowStringByColor(str, &Rect, _OSD_INDEX_YELLOW, _OSD_INDEX_BLACK); } Delay_DelayMs(1000); if (Ret) { System_PowerOff(SYS_POWEROFF_NORMAL); } #if 0 clr_flg(FLG_ID_CALIBRATION, 0xffffffff); while (1) { wai_flg(&uiFlag, FLG_ID_CALIBRATION, 0xffffffff, TWF_ORW | TWF_CLR); debug_msg("^GuiFlag:%x\r\n",uiFlag); if (uiFlag) break; } #else Delay_DelayMs(1500); #endif }
UINT32 System_OnStrg_UploadFW(UINT32 DevID) { UINT32 m_MemSrc=0; UINT32 uiMemSize=0; UINT32 m_SectSize = 0; //DX_HANDLE pStrgDev = (DX_HANDLE)GxStrg_GetDevice(DevID); DX_HANDLE pGxStrgDXH = (DX_HANDLE)GxStrg_GetDevice(DevID); //HNVT_STRG pStrg,pWhichObj; DX_HANDLE pFSStrgDXH; FST_FILE hFile=NULL; UINT32 uiSize=0; //FileSize INT32 fst_er; #if (FW_CHECK_METHOD != FW_CHECK_NOCHECK) UINT32 uiSizeExt; MEMCHECK_PSEUDOSTR Pesudo = {0}; #endif FWSRV_ER fws_er; //alloc mem uiMemSize = 0x1000000; // 16MB m_MemSrc = SxCmd_GetTempMem(uiMemSize); //if (pStrgDev == 0) if (pGxStrgDXH == 0) { debug_msg("Incorrect storage\r\n"); return UPDNAND_STS_FW_INVALID_STG; } //pStrg = (HNVT_STRG)Dx_Getcaps(pStrgDev, STORAGE_CAPS_HANDLE, 0); //if (pStrg == 0) //{ // debug_msg("Incorrect storage\r\n"); // return UPDNAND_STS_FW_INVALID_STG; //} //FileSys_GetStrgObj(&pWhichObj); FileSys_GetStrgObj(&pFSStrgDXH); //if(pWhichObj != pStrg) if(pFSStrgDXH != pGxStrgDXH) { debug_msg("Incorrect storage\r\n"); return UPDNAND_STS_FW_INVALID_STG; } memset(&Cmd,0,sizeof(Cmd)); Cmd.Idx = FWSRV_CMD_IDX_GET_BLK_SIZE; Cmd.Out.pData = &m_SectSize; Cmd.Out.uiNumByte = sizeof(m_SectSize); Cmd.Prop.bExitCmdFinish = TRUE; fws_er = FwSrv_Cmd(&Cmd); if(fws_er != FWSRV_ER_OK) { debug_msg("FW bin write failed\r\n"); return UPDNAND_STS_FW_WRITE_CHK_ERR; } uiSize = (UINT32)FileSys_GetFileLen(uiUpdateFWName); if((uiSize==0) || (uiSize>uiMemSize)) { debug_msg("FW bin read fail.\r\n"); return UPDNAND_STS_FW_READ_ERR; } hFile = FileSys_OpenFile(uiUpdateFWName, FST_OPEN_READ); if(hFile != 0) { fst_er = FileSys_ReadFile(hFile, (UINT8*)m_MemSrc, &uiSize, 0, NULL); FileSys_CloseFile(hFile); if(fst_er != FST_STA_OK) { debug_msg("FW bin read fail. 1\r\n"); return UPDNAND_STS_FW_READ2_ERR; } } else { debug_msg("FW bin read fail. 2\r\n"); return UPDNAND_STS_FW_READ2_ERR; } #if (FW_CHECK_METHOD != FW_CHECK_NOCHECK) //Pesudo string is appended to Crc & Checksum flow. //It is an additional protection key for project. //Both two pseudo strings setting must be match exactly // in "FW bin encryption prcoess" & "update FW process" of project. //In FW bin encryption process: (see config in MakeOption.txt) // this string is not written to file. //In update FW process: (FW update FW, or Loader update FW) // this string is not written to nand. Pesudo.uiAddr = m_MemSrc; Pesudo.uiLen = uiSize; Pesudo.uiMemSize = uiMemSize; Pesudo.pPseudoStr = FW_CHECK_PSEUDO_STR; uiSizeExt=MemCheck_AddPseudoStr(&Pesudo); #if (FW_CHECK_METHOD == FW_CHECK_CRC) if(MemCheck_CalcCrcCode(m_MemSrc,uiSizeExt)!=0) #else if(MemCheck_CalcCheckSum16Bit(m_MemSrc,uiSizeExt)!=0) #endif { debug_msg("FW bin check error\r\n"); return UPDNAND_STS_FW_READ_CHK_ERR; } #endif memset(&Cmd,0,sizeof(Cmd)); Buf.uiAddr = m_MemSrc; Buf.uiSize = (uiSize+(m_SectSize-1))&(~(m_SectSize-1)); Cmd.Idx = FWSRV_CMD_IDX_FW_WRITE; Cmd.In.pData = &Buf; Cmd.In.uiNumByte = sizeof(Buf); Cmd.Prop.bExitCmdFinish = TRUE; fws_er = FwSrv_Cmd(&Cmd); if(fws_er != FWSRV_ER_OK) { debug_msg("FW bin write failed\r\n"); return UPDNAND_STS_FW_WRITE_CHK_ERR; } return UPDNAND_STS_FW_OK; }
INT32 UIFlowWndPlay_OnKeyEnter(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { //#NT#2012/08/31#Calvin Chang#Porting Media Flow -begin //UINT32 uiCurindex; UINT32 uiPoolAddr; char pFilePath[FULL_FILE_PATH_LEN]; UINT32 fileType = DCF_FILE_TYPE_JPG; UINT32 uiPBFileFmt; switch(g_PlbData.State) { case PLB_ST_PLAY_MOV: case PLB_ST_FWD_MOV: case PLB_ST_BWD_MOV: Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PAUSE_PLAY_MOVIE, 0); FlowPB_IconDrawMovPlay(TRUE); g_PlbData.State = PLB_ST_PAUSE_MOV; //#NT#2012/10/23#Philex Lin - begin // enable auto power off/USB detect timer // enable sound key tone flag KeyScan_EnableMisc(TRUE); //#NT#2012/10/23#Philex Lin - end break; case PLB_ST_PAUSE_MOV: //#NT#2012/10/23#Philex Lin - begin // disable auto power off/USB detect timer // disable key tone flag KeyScan_EnableMisc(FALSE); //#NT#2012/10/23#Philex Lin - end // Start to Play Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PLAY_PLAY_MOVIE, 2, g_uiUIFlowWndPlayCurrenSpeed, g_uiUIFlowWndPlayCurrenDirection); FlowPB_IconDrawMovPlay(TRUE); g_PlbData.State = PLB_ST_PLAY_MOV; break; default: case PLB_ST_FULL: uiPBFileFmt = AppPlay_GetData(PLAY_FILEFMT); if (uiPBFileFmt & PBFMT_AVI || uiPBFileFmt & PBFMT_MOVMJPG || uiPBFileFmt & PBFMT_MP4) { // Open Video File if (gphUIFlowMovPlay_Filehdl) { FileSys_CloseFile(gphUIFlowMovPlay_Filehdl); gphUIFlowMovPlay_Filehdl = NULL; } if (uiPBFileFmt & PBFMT_AVI) fileType = DCF_FILE_TYPE_AVI; else if (uiPBFileFmt & PBFMT_MOVMJPG) fileType = DCF_FILE_TYPE_MOV; else if (uiPBFileFmt & PBFMT_MP4) fileType = DCF_FILE_TYPE_MOV; else { debug_msg("Wrong video file format!! \r\n"); break; } // Get Current index PB_GetParam(PBPRMID_CURR_FILEPATH, (UINT32 *)pFilePath); #if 0 uiCurindex = DCF_GetCurIndex(); DCF_GetObjPath(uiCurindex,fileType,pFilePath); #endif // Open Test Media File gphUIFlowMovPlay_Filehdl = FileSys_OpenFile(pFilePath, FST_OPEN_READ); if (!gphUIFlowMovPlay_Filehdl) { debug_msg("UIFlowWndPlay_OnKeyEnter: Can't open Video file!\r\n"); break; } //#NT#2012/10/23#Philex Lin - begin // disable auto power off/USB detect timer // disable key tone flag KeyScan_EnableMisc(FALSE); //#NT#2012/10/23#Philex Lin - end // Buffer Allocation get_blf((VP*)&(uiPoolAddr), POOL_ID_APP); rel_blf(POOL_ID_APP, (VP)uiPoolAddr); g_UIPlayMediaObj.hActMediafilehdl = gphUIFlowMovPlay_Filehdl; g_UIPlayMediaObj.CallBackFunc = Play_MovieCB; // g_UIPlayMediaObj.uiMemAddr = uiPoolAddr; g_UIPlayMediaObj.uiMemAddr = (UINT32)OS_GetMempoolAddr(POOL_ID_APP); g_UIPlayMediaObj.uiMemSize = POOL_SIZE_APP; //g_UIPlayMediaObj.iAudioType = AUDIO_OUTPUT_HP; g_UIPlayMediaObj.bDisableAudio = FALSE; UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed); g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD; //flush event first Ux_FlushEventByRange(NVTEVT_KEY_EVT_START,NVTEVT_KEY_EVT_END); //stop scan //SxTimer_SetFuncActive(SX_TIMER_DET_STRG_ID, FALSE); SxTimer_SetFuncActive(SX_TIMER_DET_SYSTEM_BUSY_ID, FALSE); Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_INIT_PLAY_MOVIE, 1, &g_UIPlayMediaObj); // Start to Play Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PLAY_PLAY_MOVIE, 2, g_uiUIFlowWndPlayCurrenSpeed, g_uiUIFlowWndPlayCurrenDirection); if (KeyScan_GetPlugDev()!=PLUG_HDMI) { //FlowPB_IconDrawMovPlayVolumn(g_uiUIFlowWndPlayCurrentVolume); } FlowPB_IconDrawMovPlay(TRUE); g_PlbData.State = PLB_ST_PLAY_MOV; } break; } //#NT#2012/08/31#Calvin Chang -end return NVTEVT_CONSUME; }
INT32 UIFlowWndPlay_OnKeyMenu(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) { switch(g_PlbData.State) { case PLB_ST_FULL: g_PlbData.State = PLB_ST_MENU; Input_SetKeyMask(KEY_RELEASE, FLGKEY_KEY_MASK_NULL); // Reset specific menu items SysSetFlag(FL_PROTECT, PROTECT_ONE); // Set Tab menu to Playback menu TM_SetMenu(&gPlaybackMenu); // Open common item menu Ux_OpenWindow(&MenuCommonItemCtrl, 0); break; #if(_MODEL_DSC_== _MODEL_DUAL_NAZHIDA_) case PLB_ST_PLAY_MOV: case PLB_ST_FWD_MOV: case PLB_ST_BWD_MOV: //#NT#2012/08/31#Calvin Chang#Porting Media Flow -begin g_PlbData.State = PLB_ST_FULL; g_PlbData.VideoPBSpeed = PLB_FWD_MOV_1x; UIFlowMoviePlay_SetSpeed(g_PlbData.VideoPBSpeed); g_uiUIFlowWndPlayCurrenDirection = MEDIAPLAY_DIR_FORWARD; Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_PAUSE_PLAY_MOVIE, 0); Ux_SendEvent(&UIMoviePlayObjCtrl, NVTEVT_CLOSE_PLAY_MOVIE, 0); //#NT#2012/10/23#Philex Lin - begin // enable auto power off/USB detect timer // enable key tone flag KeyScan_EnableMisc(TRUE); //#NT#2012/10/23#Philex Lin - end // stop scan //if (SxTimer_GetFuncActive(SX_TIMER_DET_STRG_ID)==0) // SxTimer_SetFuncActive(SX_TIMER_DET_STRG_ID, TRUE); if (SxTimer_GetFuncActive(SX_TIMER_DET_SYSTEM_BUSY_ID)==0) SxTimer_SetFuncActive(SX_TIMER_DET_SYSTEM_BUSY_ID, TRUE); if (gphUIFlowMovPlay_Filehdl) { FileSys_CloseFile(gphUIFlowMovPlay_Filehdl); gphUIFlowMovPlay_Filehdl = NULL; } // Play 1st video frame image Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_PLAYSINGLE, 1, PB_SINGLE_CURR); //#NT#2012/08/31#Calvin Chang -end g_PlbData.State = PLB_ST_MENU; Input_SetKeyMask(KEY_RELEASE, FLGKEY_KEY_MASK_NULL); // Reset specific menu items SysSetFlag(FL_PROTECT, PROTECT_ONE); // Set Tab menu to Playback menu TM_SetMenu(&gPlaybackMenu); // Open common item menu Ux_OpenWindow(&MenuCommonItemCtrl, 0); break; #endif } return NVTEVT_CONSUME; }