// read and store the data for use by the writer thread. // this runs in the main loop. void updateSlowDL() { int i_ch; static int first_time = 1; int i_w; if (first_time) { int size = 0; for (i_ch = 0; slowDLList[i_ch].name[0]!='\0'; i_ch++) { slowDLList[i_ch].bi0s = GetBiPhaseAddr(slowDLList[i_ch].name); switch (slowDLList[i_ch].type) { case 'c': size++; break; case 's': case 'u': size += 2; break; case 'S': case 'U': size += 4; break; default: blast_fatal("%c: unknown var type in slow dl field %s", slowDLList[i_ch].type, slowDLList[i_ch].name); break; } if (size>255) { blast_fatal("slow downlink structure too large (%d > 255)", size); } } blast_info("slow downlink packet %d/255", size); first_time = 0; } i_w = slow_dl_read_index+1; if (i_w==3) i_w = 0; for (i_ch = 0; slowDLList[i_ch].name[0]!='\0'; i_ch++) { if (slowDLList[i_ch].encode == SDL_RAW) { slowDLList[i_ch].iX[i_w] = ReadData(slowDLList[i_ch].bi0s); } else if (slowDLList[i_ch].encode == SDL_SCALE) { slowDLList[i_ch].X[i_w] = ReadCalData(slowDLList[i_ch].bi0s); } else if (slowDLList[i_ch].encode == SDL_LOG) { slowDLList[i_ch].X[i_w] = ReadCalData(slowDLList[i_ch].bi0s); } } slow_dl_read_index = i_w; }
/** BurnIn main loop BurnIn main loop [CalBurnIn internal API] @param UINT32 uiOperation: Which operation you want to run BURNIN_OP_BURNIN (Burn In) BURNIN_OP_ZOOMAF (ZoomAF Lasting) BURNIN_OP_FLASH (Flash Lasting) BURNIN_OP_168H (168H) @return void */ static void Cal_BurnIn(UINT32 uiOperation) { UINT32 uiTimerID, uiFlag; UINT32 uiKeyFlagID, uiKeyEvent; // UINT32 uiOldPressConfig, uiOldReleaseConfig; UINT32 uiTotalIteration; UINT32 uiInterval; UINT32 uiEventCnt; PSIM_EVENT pSimEvent, pStartEvent; UINT8 uiKeyStatus, uiRepeatCnt; if(i2c_getLockStatus()) i2c_unlock(); // Open timer if (TIMEROpen((UINT *)&uiTimerID, Cal_BurnInTimerISR) != E_OK) { /* set_scankey_press_config(uiOldPressConfig); set_scankey_release_config(uiOldReleaseConfig); */ return; } switch (uiOperation) { case BURNIN_OP_BURNIN: //read cal status for check finish item ReadCalData(); FilesysFormat(Primary_GetStorageObj(PRIMARY_STGTYPE_NAND), TRUE); FilesysWaitCmdFinish(FST_TIME_INFINITE); FilesysFormat(Primary_GetStorageObj(PRIMARY_STGTYPE_NAND), TRUE); //if(Cal_CheckStatus()!= 0) // return ; uiTotalIteration = 40; //2hour //10 ; // 10*3 min = 30 mins pStartEvent = (PSIM_EVENT)&BurnInEvent; Primary_ChangeMode(PRIMARY_MODE_PHOTO); break; case BURNIN_OP_ZOOMAF: uiTotalIteration = 1000; pStartEvent = (PSIM_EVENT)&ZoomAFEvent; Primary_ChangeMode(PRIMARY_MODE_PHOTO); break; case BURNIN_OP_FLASH: FilesysWaitCmdFinish(FST_TIME_INFINITE); FilesysFormat(Primary_GetStorageObj(PRIMARY_STGTYPE_NAND), TRUE); uiTotalIteration = 8; //15 min * 8 = 2 hr pStartEvent = (PSIM_EVENT)&FlashEvent; Primary_ChangeMode(PRIMARY_MODE_PHOTO); SysSetFlag(FL_FLASH, FLASH_ON); break; case BURNIN_OP_168H: //read cal status for check finish item ReadCalData(); FilesysWaitCmdFinish(FST_TIME_INFINITE); FilesysFormat(Primary_GetStorageObj(PRIMARY_STGTYPE_NAND), TRUE); //if(Cal_CheckStatus()!= 0) // return ; uiTotalIteration = 0xFFFFFFFF; pStartEvent = (PSIM_EVENT)&BurnInEvent; Primary_ChangeMode(PRIMARY_MODE_PHOTO); break; case BURNIN_OP_10MIN: //read cal status for check finish item ReadCalData(); FilesysWaitCmdFinish(FST_TIME_INFINITE); FilesysFormat(Primary_GetStorageObj(PRIMARY_STGTYPE_NAND), TRUE); //if(Cal_CheckStatus()!= 0) // return ; uiTotalIteration = 10; // 3 min * 10 =30 mins pStartEvent = (PSIM_EVENT)&BurnInEvent; Primary_ChangeMode(PRIMARY_MODE_PHOTO); break; } // Init variable uiTimeoutValue = 0; // Enable timer and clear all flags clr_flg(FLG_ID_BURNIN, FLGBURNIN_ALL); TIMERSet(uiTimerID, TIMER_INTERVAL, _TIMER_CTRL_FREE_RUN | _TIMER_CTRL_INT_ENABLE, _TIMER_PLAY); for (uiIteration=1; uiIteration<=uiTotalIteration; uiIteration++) { debug_ind(("\n\r ***Loop = %ld,Event= %ld ***\r\n", uiIteration, uiEventCnt)); pSimEvent = pStartEvent; uiRepeatCnt = 0; uiInterval = 0; uiEventCnt = 0; if(uiOperation == BURNIN_OP_FLASH) { Ux_SendEvent(&UIPlayObjCtrl,NVTEVT_EXE_SLIDE,1,SLIDE_5SEC); ImageInfoTable = FlashImageInfoTable; } else ImageInfoTable = BurnInImageInfoTable; Delay_DelayMs(2000); Cal_SetImageInfor_Value(uiRepeatCnt); while (1) { wai_flg((UINT *)&uiFlag, FLG_ID_BURNIN, FLGBURNIN_TIMER, TWF_ORW | TWF_CLR); uiInterval += TIMER_INTERVAL; //avoid display msg too much if(uiInterval%2000 == 0) Cal_BurnInShowLoop(uiIteration, uiEventCnt,uiRepeatCnt); //accumlate time until to interval;the post event if (uiInterval >= pSimEvent->uiInterval) { uiInterval = 0; #if 0 if((uiOperation == BURNIN_OP_BURNIN || uiOperation == BURNIN_OP_10MIN ) && (uiIteration == 4)) //about 10 min,run dark dp { Cal_BurnInLog(uiIteration,uiEventCnt,999); if(uiOperation == BURNIN_OP_10MIN) Cal_DPinBurnIn(FALSE); //not check dp status else Cal_DPinBurnIn(TRUE); // check dp status break; } #endif // End of event if (pSimEvent->uiKeyFlagID == SIM_END) { break; } // Wait for specific flag, or change mode else if (pSimEvent->uiKeyFlagID == FLG_ID_BURNIN) { if (pSimEvent->uiKeyEvent == FLGBURNIN_WAITING) { // Enable timeout uiTimeoutValue = pSimEvent->uiInterval; uiTimerCnt = 0; clr_flg(FLG_ID_BURNIN, FLGBURNIN_TIMEOUT); Cal_BurnInLog(uiIteration,uiEventCnt,uiRepeatCnt); wai_flg((UINT *)&uiFlag, FLG_ID_BURNIN, pSimEvent->uiKeyEvent | FLGBURNIN_TIMEOUT, TWF_ORW | TWF_CLR); if (uiFlag & FLGBURNIN_TIMEOUT) { debug_err(("Wait for specific flag timeout %d\r\n",pSimEvent->uiInterval)); } // Disable timeout uiTimeoutValue = 0; // Clear timer flag clr_flg(FLG_ID_BURNIN, FLGBURNIN_TIMER); uiRepeatCnt = 0; pSimEvent++; uiEventCnt++; debug_ind(("\n\rFLGBURNIN_WAITING ***Loop = %ld,Event= %ld ***\r\n", uiIteration, uiEventCnt)); continue; } } else // FLG_ID_KEY { //log current event Cal_BurnInLog(uiIteration,uiEventCnt,uiRepeatCnt); uiKeyFlagID = pSimEvent->uiKeyFlagID; uiKeyEvent = pSimEvent->uiKeyEvent; uiKeyStatus = pSimEvent->uiKeyStatus; // Set key event if (uiKeyFlagID != NULL && uiKeyEvent != NULL) { //change key event to post message if(uiKeyFlagID == FLG_ID_KEY) { /* NVTMSG msg; if(uiKeyStatus == KEY_STATUS_PRESS) SET_COMMAND(&msg, NVTEVT_KEY_PRESS); else SET_COMMAND(&msg, NVTEVT_KEY_RELEASE); debug_ind(("uiKeyEvent %x nvtcmd %x \r\n",uiKeyEvent ,Get_NVTCMD(uiKeyEvent))); SET_KEY_EVENT(&msg,Get_NVTCMD(uiKeyEvent)); PostMessage(&msg); */ if(uiKeyEvent & (Input_GetKeyMask(KEY_PRESS))) { debug_err(("Ux_PostEvent %d \r\n",uiKeyEvent)); Ux_PostEvent(Get_NVTCMD(uiKeyEvent), 1, Get_NVTCMD(uiKeyEvent)); } } else { set_flg(uiKeyFlagID, uiKeyEvent); } } } uiRepeatCnt++; // Move to next event if (uiRepeatCnt == pSimEvent->uiRepeatCnt) { uiRepeatCnt = 0; pSimEvent++; uiEventCnt++; debug_ind(("*****next event*Loop = %ld,Event= %ld ***************\r\n", uiIteration, uiEventCnt)); } if ((pSimEvent == pStartEvent)&&((uiOperation==BURNIN_OP_10MIN)||(uiOperation==BURNIN_OP_BURNIN) || (uiOperation==BURNIN_OP_168H) || (uiOperation==BURNIN_OP_FLASH)) ) { Delay_DelayMs(2000); //for set flash charg,so set capture index first Cal_SetImageInfor_Value(uiRepeatCnt); } } } } TIMERClose(uiTimerID); //tmp write to AAA for read cal data AAA_Adjust.ISO_Status = _ISO_Status; WriteCalData(); if(uiOperation == BURNIN_OP_FLASH) sprintf(LogStringBuf,"Flash O\r\n"); else sprintf(LogStringBuf,"BurnIn O\r\n"); Cal_ShowStringWithColor((INT8 *)LogStringBuf, 64,170, _OSD_INDEX_GREEN); #if 0 Menu_PowerOff(POWER_OFF); #endif while(1) ;; /* set_scankey_press_config(uiOldPressConfig); set_scankey_release_config(uiOldReleaseConfig); */ // Power off DSC after burn in done // Premier don't want to power off now (2005.10.16) /* if (uiOperation == BURNIN_OP_BURNIN) { PowerOffFlow(TRUE, FALSE); } */ }
int main(int argc, const char *argv[]) { int fd = -1; int ret = -1; unsigned int pos; unsigned int zp; unsigned short reg_value; MOTOR_DIR_E dir; if (argc < 2) { usage(); return 0; } fd = open(dev_name, O_RDWR); if (fd < 0) { printf("open %s failed!\n", dev_name); return -1; } if (!strcmp(argv[1], "-i")) { ret = WriteCalData(); ret = ReadCalData(); if (ret < 0 ) { printf("read cal data failed!\n"); return -1; } sleep(1); //ret = write(fd, (unsigned char *)foc_cal_tbl, sizeof(foc_cal_tbl)); //if (ret != sizeof(foc_cal_tbl)) //{ // printf("write cal data failed!\n"); // return -1; //} ret = ioctl(fd, LENS_IOC_INIT); if (ret < 0) { printf("ioctl: LENS_IOC_INIT failed.\n"); goto err; } } else if (!strcmp(argv[1], "-fp")) { if (argc < 3) { usage(); goto err; } pos = atoi(argv[2]); ret = ioctl(fd, LENS_IOC_FOCPLUS, &pos); if (ret < 0) { printf("ioctl: LENS_IOC_FOCPLUS failed.\n"); goto err; } } else if (!strcmp(argv[1], "-fm")) { if (argc < 3) { usage(); goto err; } pos = atoi(argv[2]); ret = ioctl(fd, LENS_IOC_FOCMINUS, &pos); if (ret < 0) { printf("ioctl: LENS_IOC_FOCMINUS failed.\n"); goto err; } } else if (!strcmp(argv[1], "-zp")) { ret = ioctl(fd, LENS_IOC_ZOOMPLUS); if (ret < 0) { printf("ioctl: LENS_IOC_ZOOMPLUS failed.\n"); goto err; } } else if(!strcmp(argv[1], "-zm")) { ret = ioctl(fd, LENS_IOC_ZOOMMINUS); if (ret < 0) { printf("ioctl: LENS_IOC_ZOOMMINUS failed.\n"); goto err; } } else if(!strcmp(argv[1], "-fd")) { if (argc < 3) { usage(); goto err; } dir = atoi(argv[2]); ret = ioctl(fd, LENS_IOC_SETFOCDIR, &dir); if (ret < 0) { printf("ioctl: LENS_IOC_SETFOCDIR failed.\n"); goto err; } } else if(!strcmp(argv[1], "-gd")) { ret = ioctl(fd, LENS_IOC_GETFOCDIR, &dir); if (ret < 0) { printf("ioctl: LENS_IOC_GETFOCDIR failed.\n"); goto err; } printf("Get focus dir is: %d\n", dir); } else if(!strcmp(argv[1], "-sf")) { if (argc < 3) { usage(); goto err; } pos = atoi(argv[2]); ret = ioctl(fd, LENS_IOC_SETFOCPOS, &pos); if (ret < 0) { printf("ioctl: LENS_IOC_SETFOCPOS failed.\n"); goto err; } } else if(!strcmp(argv[1], "-gf")) { ret = ioctl(fd, LENS_IOC_GETFOCPOS, &pos); if (ret < 0) { printf("ioctl: LENS_IOC_GETFOCPOS failed.\n"); goto err; } printf("Get focus pos is: %d\n", pos); } else if(!strcmp(argv[1], "-sz")) { if (argc < 3) { usage(); goto err; } zp = atoi(argv[2]); ret = ioctl(fd, LENS_IOC_SETZOOMPOINT, &zp); if (ret < 0) { printf("ioctl: LENS_IOC_SETZOOMPOINT failed.\n"); goto err; } } else if(!strcmp(argv[1], "-gz")) { ret = ioctl(fd, LENS_IOC_GETZOOMPOINT, &zp); if (ret < 0) { printf("ioctl: LENS_IOC_GETZOOMPOINT failed.\n"); goto err; } printf("Get zoom point is: %d\n", zp); } else if(!strcmp(argv[1], "-fr")) { ret = ioctl(fd, LENS_IOC_GETFOCREG, ®_value); if (ret < 0) { printf("ioctl: LENS_IOC_GETFOCREG failed.\n"); goto err; } printf("Get focus reg value is:%#x\n", reg_value); } else { usage(); goto err; } err: close(fd); return 0; }