| 1 | #include "App_Main.h" |
|---|
| 2 | #include "App_Res_Resources.h" |
|---|
| 3 | #include "App_Proc.h" |
|---|
| 4 | #include "App_Fnc_Common.h" |
|---|
| 5 | #include "App_Fnc_Video.h" |
|---|
| 6 | #include "App_Fnc_ChTune.h" |
|---|
| 7 | #include "App_Fnc_Ucm.h" |
|---|
| 8 | #include "App_Fnc_SignalMonitor.h" |
|---|
| 9 | #include "App_Fnc_Sdds.h" |
|---|
| 10 | #include "App_Fnc_CC.h" |
|---|
| 11 | #include "App_Fnc_AutoScan.h" |
|---|
| 12 | #include "App_Fnc_Time.h" |
|---|
| 13 | #include "App_Fnc_Comm.h" |
|---|
| 14 | |
|---|
| 15 | #include "App_OSD_Banner.h" |
|---|
| 16 | #include "App_OSD_Common.h" |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #include "DHL_UIO.h" |
|---|
| 20 | |
|---|
| 21 | #define MS_AUTO_REBOOT (1000*60*60*3) //3½Ã°£ |
|---|
| 22 | |
|---|
| 23 | static BOOL p_is_first_boot=TRUE; |
|---|
| 24 | static int p_prev_uid; |
|---|
| 25 | static int p_prev_rf; |
|---|
| 26 | static int p_prev_program_num; |
|---|
| 27 | static BOOL p_is_from_ad_key=FALSE; |
|---|
| 28 | static int p_led_mode; |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | static void p_av_mute(BOOL bmute) |
|---|
| 32 | { |
|---|
| 33 | if(bmute) { |
|---|
| 34 | DHL_AV_DispSetFormat((tDHL_DispPort)0, eDHL_DISP_NO_OUTPUT, (tDHL_DispColorSpace)0); |
|---|
| 35 | |
|---|
| 36 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_DECODER, TRUE); |
|---|
| 37 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_HDMI, TRUE); |
|---|
| 38 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_SPDIF, TRUE); |
|---|
| 39 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_AMP, TRUE); |
|---|
| 40 | #if 0 |
|---|
| 41 | DHL_SYS_ResetGPIO(GPIO_5VDC_CTRL); |
|---|
| 42 | #endif |
|---|
| 43 | } |
|---|
| 44 | else { |
|---|
| 45 | #if 0 |
|---|
| 46 | DHL_SYS_SetGPIO(GPIO_5VDC_CTRL); |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | App_VideoSetOutputResolution(App_VideoGetOutputResolution()); |
|---|
| 50 | |
|---|
| 51 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_DECODER, FALSE); |
|---|
| 52 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_HDMI, FALSE); |
|---|
| 53 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_SPDIF, FALSE); |
|---|
| 54 | DHL_AV_AudioMuteControl(eDHL_AUDIO_MUTE_AMP, FALSE); |
|---|
| 55 | } |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | static void p_led_ctrl(int mode) |
|---|
| 59 | { |
|---|
| 60 | //mode 0 : standby, 1: normal |
|---|
| 61 | DHL_UIO_Control(eDHL_UIO_CT_LED, GPIO_LED_G, mode); |
|---|
| 62 | DHL_UIO_Control(eDHL_UIO_CT_LED, GPIO_LED_R, 1-mode); |
|---|
| 63 | |
|---|
| 64 | p_led_mode=mode; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | static void p_do_before_standby() |
|---|
| 68 | { |
|---|
| 69 | p_prev_uid=APP_CUR_CH.nUid; |
|---|
| 70 | p_prev_rf=APP_CUR_CH.nRF; |
|---|
| 71 | p_prev_program_num=APP_CUR_CH.nProgramNumber; |
|---|
| 72 | |
|---|
| 73 | App_ChTuneStopTVEx(TRUE); |
|---|
| 74 | App_Pause_SMTask(); |
|---|
| 75 | //sleep timer init |
|---|
| 76 | App_SetSleepTimer(0); |
|---|
| 77 | |
|---|
| 78 | // cafrii 101208 add |
|---|
| 79 | DMW_CDB_DeleteDisabledChannel(); |
|---|
| 80 | App_NVM_SaveUcm(); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | static void p_do_before_normal() |
|---|
| 85 | { |
|---|
| 86 | // App_Menu_SetAllVars(); |
|---|
| 87 | |
|---|
| 88 | // App_Menu_InitPos(); |
|---|
| 89 | |
|---|
| 90 | if(p_prev_uid==0) { //¸¸¾à ±âÁ¸¿¡ ÀúÀåµÈ °ÍÀÌ ¾ø´Ù¸é ù ¹øÂ° ä³ÎÀ» ¼±ÅÃÇÔ |
|---|
| 91 | tApp_UcmShortInfo info; |
|---|
| 92 | |
|---|
| 93 | if(statusOK==App_Ucm_GetShortInfobyIndex(0, &info)) { |
|---|
| 94 | APP_CUR_CH.nUid=info.uid; |
|---|
| 95 | APP_CUR_CH.nRF=info.rf; |
|---|
| 96 | APP_CUR_CH.nProgramNumber=info.prog_number; |
|---|
| 97 | } |
|---|
| 98 | else { |
|---|
| 99 | |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | else { |
|---|
| 103 | APP_CUR_CH.nUid=p_prev_uid; |
|---|
| 104 | APP_CUR_CH.nRF=p_prev_rf; |
|---|
| 105 | APP_CUR_CH.nProgramNumber=p_prev_program_num; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | if(p_is_from_ad_key) { |
|---|
| 109 | char *t; |
|---|
| 110 | |
|---|
| 111 | DMG_SetFontSize(22); |
|---|
| 112 | |
|---|
| 113 | GET_STR(t, POPUP_DIGITAL); |
|---|
| 114 | App_OSD_DrawPopupBG(t); |
|---|
| 115 | DMG_AutoRefresh(); |
|---|
| 116 | |
|---|
| 117 | DMG_SetFontSize(24); |
|---|
| 118 | |
|---|
| 119 | DHL_OS_Delay(1500); |
|---|
| 120 | App_OSD_ErasePopupBG(); |
|---|
| 121 | DMG_AutoRefresh(); |
|---|
| 122 | } |
|---|
| 123 | else { |
|---|
| 124 | //DHL_OS_Delay(2000); |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | App_VideoSetPreferedResolution(App_VideoGetPreferedResolution(), FALSE); |
|---|
| 128 | |
|---|
| 129 | /* ¸¸ÀÏ cable mode°¡ Á¸ÀçÇÏ´Ù°¡ ¾ø¾îÁö´Â °æ¿ì°¡ ÀÖÀ» ¼ö ÀÖÀ¸¹Ç·Î |
|---|
| 130 | ChangeChannelTypeÀ» È£ÃâÇØ¾ß ÇÔ |
|---|
| 131 | */ |
|---|
| 132 | |
|---|
| 133 | App_ChangeChannelType(APP_CUR_CH.nChannelType==0?ChannelType_Air:ChannelType_Cable); |
|---|
| 134 | |
|---|
| 135 | if (APP_CUR_CH.nUid > 0) |
|---|
| 136 | { |
|---|
| 137 | App_TuneChannelByUidEx(APP_CUR_CH.nUid, APP_UID_TUNE_NORMAL); |
|---|
| 138 | } |
|---|
| 139 | else |
|---|
| 140 | { |
|---|
| 141 | // cafrii 070426 |
|---|
| 142 | // program number ±îÁö ÁöÁ¤Çؼ Æ©´×Çϵµ·Ï ÇÏÀÚ. |
|---|
| 143 | App_ChTuneQuickScanAndTune(APP_CUR_CH.nRF, APP_CUR_CH.nProgramNumber, APP_QUICKSCAN_SIGMON); |
|---|
| 144 | } |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | void p_draw_dst_logo() |
|---|
| 148 | { |
|---|
| 149 | int i; |
|---|
| 150 | //neverdai 110120 ¹ö±×·Î ÀÎÇØ ¾ËÆÄ °ªÀÌ 0xc0ÀÌ»óÀÌ µÇ¸é |
|---|
| 151 | //ºñµð¿À ½ÌÅ©°¡ ²÷¾îÁ®¹ö¸®´Â ¹®Á¦°¡ ÀÖÀ½ : 0xff -> 0xc0 |
|---|
| 152 | App_SetLogoOpacity(0x0); |
|---|
| 153 | |
|---|
| 154 | App_DrawDstLogo(); |
|---|
| 155 | DMG_AutoRefresh(); |
|---|
| 156 | |
|---|
| 157 | for(i=0x0; i<=0xc0; i+=0x8) { |
|---|
| 158 | App_SetLogoOpacity(i); |
|---|
| 159 | DHL_OS_Delay(20); |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | DHL_OS_Delay(500); |
|---|
| 163 | |
|---|
| 164 | for(i=0xc0; i>=0x0; i-=0x8) { |
|---|
| 165 | App_SetLogoOpacity(i); |
|---|
| 166 | DHL_OS_Delay(20); |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | App_EraseDstLogo(); |
|---|
| 170 | DMG_AutoRefresh(); |
|---|
| 171 | App_SetLogoOpacity(-1); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | BOOL App_Proc_Standby(tDMG_CMD cmd, UINT32 opt, UINT32 param1, UINT32 param2) |
|---|
| 175 | { |
|---|
| 176 | tDMG_Menu *pmenu; |
|---|
| 177 | static UINT32 ms_standby_start=0; |
|---|
| 178 | |
|---|
| 179 | switch(cmd) { |
|---|
| 180 | |
|---|
| 181 | case eDMG_CMD_ON_MENU_ENTER : |
|---|
| 182 | |
|---|
| 183 | pmenu=(tDMG_Menu *)param1; |
|---|
| 184 | |
|---|
| 185 | DHL_OS_Printf("---------------------\n"); |
|---|
| 186 | DHL_OS_Printf("----standby mode-----\n"); |
|---|
| 187 | DHL_OS_Printf("---------------------\n"); |
|---|
| 188 | |
|---|
| 189 | if(p_is_first_boot) { |
|---|
| 190 | // 1. init task & av mute |
|---|
| 191 | //extern void App_InitializeTask(void); |
|---|
| 192 | //App_InitializeTask(); |
|---|
| 193 | p_av_mute(TRUE); |
|---|
| 194 | |
|---|
| 195 | //p_do_before_standby(); |
|---|
| 196 | |
|---|
| 197 | DMG_MenuExit(MID_STANDBY); // |
|---|
| 198 | break; |
|---|
| 199 | } |
|---|
| 200 | else if(pmenu->param1==1) { //by A/D key |
|---|
| 201 | |
|---|
| 202 | p_is_from_ad_key=TRUE; |
|---|
| 203 | |
|---|
| 204 | p_do_before_standby(); |
|---|
| 205 | |
|---|
| 206 | DMG_EraseRect(0, 0, 720, 480, 0x0); |
|---|
| 207 | { |
|---|
| 208 | char *t; |
|---|
| 209 | GET_STR(t, POPUP_ANALOG); |
|---|
| 210 | |
|---|
| 211 | DMG_SetFontSize(20); |
|---|
| 212 | |
|---|
| 213 | App_OSD_DrawPopupBG(t); |
|---|
| 214 | |
|---|
| 215 | DMG_SetFontSize(24); |
|---|
| 216 | } |
|---|
| 217 | DMG_AutoRefresh(); |
|---|
| 218 | DHL_OS_Delay(1500); /* display popup during 1 sec */ |
|---|
| 219 | App_OSD_ErasePopupBG(); |
|---|
| 220 | DMG_AutoRefresh(); |
|---|
| 221 | |
|---|
| 222 | p_av_mute(TRUE); |
|---|
| 223 | |
|---|
| 224 | ms_standby_start=DHL_OS_GetMsCount(); |
|---|
| 225 | |
|---|
| 226 | DMG_SetTimer(TIMER_ID_L1, 4000, eDMG_CMD_OPT_TIMER_LOCAL1 | eDMG_CMD_OPT_TIMER_ONESHOT); |
|---|
| 227 | } |
|---|
| 228 | else { //by power off |
|---|
| 229 | ms_standby_start=DHL_OS_GetMsCount(); |
|---|
| 230 | |
|---|
| 231 | p_is_from_ad_key=FALSE; |
|---|
| 232 | |
|---|
| 233 | p_do_before_standby(); |
|---|
| 234 | |
|---|
| 235 | p_av_mute(TRUE); |
|---|
| 236 | |
|---|
| 237 | DMG_SetTimer(TIMER_ID_L1, 4000, eDMG_CMD_OPT_TIMER_LOCAL1 | eDMG_CMD_OPT_TIMER_ONESHOT); |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | App_NVM_SaveNvParam(); |
|---|
| 241 | App_NVM_Sync(); |
|---|
| 242 | |
|---|
| 243 | do |
|---|
| 244 | { |
|---|
| 245 | APP_SDDS_SHORT_INFO info; |
|---|
| 246 | App_SddsGetInfo(&info); |
|---|
| 247 | |
|---|
| 248 | if (info.state == eSDDS_STATE_INIT || info.state ==eSDDS_STATE_COMPELTED) { |
|---|
| 249 | //if sdds update is not required, then go to standby |
|---|
| 250 | //DHL_OS_Delay(3000); //wait until ending flash writing. |
|---|
| 251 | DMW_CDB_WaitForNvRamSyncDone(); |
|---|
| 252 | App_Fnc_SendData2(eCMD_SET_STATUS, eMICOM_MODE_S1, 0, 0, 0); |
|---|
| 253 | |
|---|
| 254 | p_led_ctrl(0); |
|---|
| 255 | DHL_SYS_Reset(eDHL_RESET_Standby); |
|---|
| 256 | } |
|---|
| 257 | else { |
|---|
| 258 | //go to s2(update) |
|---|
| 259 | App_Fnc_SendData2(eCMD_SET_STATUS, eMICOM_MODE_S2, 0, 0, 0); |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | } while(0); |
|---|
| 263 | |
|---|
| 264 | // cafrii 101208 add TODO |
|---|
| 265 | // ¹æ±Ý Àü¿¡ disabled channelÀ» ¸ðµÎ »èÁ¦ÈÄ ÀúÀå ÇßÀ¸¹Ç·Î NVM worker task°¡ Á¾·áÇÒ ¶§ ±îÁö ´ë±âÇÒ ÇÊ¿ä ÀÖÀ½. |
|---|
| 266 | // ¿ÏÀüÈ÷ ´ë±âÇÑ ÈÄ¿¡ MICOM¿¡°Ô enter power stby ¸í·ÉÀ» º¸³»¾ß ÇÔ. |
|---|
| 267 | // ÀÌ °úÁ¤ Áß¿¡ »ç¿ëÀÚ°¡ AC off °¡ µÇÁö ¾Êµµ·Ï LED blinkingÀ» ÇØ ÁÖ´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÔ. |
|---|
| 268 | |
|---|
| 269 | p_led_ctrl(0); |
|---|
| 270 | |
|---|
| 271 | break; |
|---|
| 272 | |
|---|
| 273 | case eDMG_CMD_ON_MENU_EXIT : |
|---|
| 274 | DHL_OS_Printf("---------------------\n"); |
|---|
| 275 | DHL_OS_Printf("----normal mode-----\n"); |
|---|
| 276 | DHL_OS_Printf("---------------------\n"); |
|---|
| 277 | |
|---|
| 278 | if(!p_is_first_boot) { |
|---|
| 279 | //notify changing from s2(update) to s3(normal) |
|---|
| 280 | App_Fnc_SendData2(eCMD_SET_STATUS, eMICOM_MODE_S3, 0, 0, 0); |
|---|
| 281 | } |
|---|
| 282 | |
|---|
| 283 | p_led_ctrl(1); |
|---|
| 284 | p_av_mute(FALSE); |
|---|
| 285 | |
|---|
| 286 | #if SUPPORT_SDDS |
|---|
| 287 | App_SddsPowerModeChanged(TRUE); |
|---|
| 288 | |
|---|
| 289 | // ÀÏ´Ü ½ÃÀÛ ÇÒ ¶§ flashing ¸ðµå°¡ ¹ß°ßµÇ¸é ¿Ï·á ÈÄ ¸®ºÎÆÃ ÇÒ °ÍÀÓ. |
|---|
| 290 | do |
|---|
| 291 | { |
|---|
| 292 | APP_SDDS_SHORT_INFO info; |
|---|
| 293 | App_SddsGetInfo(&info); |
|---|
| 294 | |
|---|
| 295 | if (info.state != eSDDS_STATE_FLASHING) { |
|---|
| 296 | break; // Á¤»ó ºÎÆÃ ÀýÂ÷ °è¼Ó ÁøÇà. |
|---|
| 297 | } |
|---|
| 298 | |
|---|
| 299 | //now flashing...then wait until flashing is done |
|---|
| 300 | DHL_OS_Printf("flashing in progress..\n"); |
|---|
| 301 | |
|---|
| 302 | // ¹«ÇÑ ·çÇÁ. ¿Ï·á µÇ¸é fnc_sdds ¿¡¼ reboot±îÁö ÁøÇàÇÑ´Ù. |
|---|
| 303 | while (info.state == eSDDS_STATE_FLASHING) { |
|---|
| 304 | |
|---|
| 305 | App_SddsGetInfo(&info); |
|---|
| 306 | |
|---|
| 307 | APP_OSD_DrawWarningBanner(7, 1); |
|---|
| 308 | DMG_AutoRefresh(); |
|---|
| 309 | DHL_OS_Delay(500); |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | //flashing is done, |
|---|
| 313 | DMW_CDB_WaitForNvRamSyncDone(); |
|---|
| 314 | DHL_SYS_Reset(eDHL_RESET_Reboot); |
|---|
| 315 | |
|---|
| 316 | } while(0); |
|---|
| 317 | #endif |
|---|
| 318 | |
|---|
| 319 | if(!p_is_first_boot) { |
|---|
| 320 | p_do_before_normal(); |
|---|
| 321 | } |
|---|
| 322 | |
|---|
| 323 | p_is_first_boot=FALSE; |
|---|
| 324 | |
|---|
| 325 | //p_draw_dst_logo(); |
|---|
| 326 | |
|---|
| 327 | |
|---|
| 328 | DMG_EraseRect(0, 0, 720, 480, 0x0); |
|---|
| 329 | DMG_AutoRefresh(); |
|---|
| 330 | |
|---|
| 331 | if(App_NVM_GetShowSetupWizard()) { |
|---|
| 332 | DMG_SetFontSize(24); |
|---|
| 333 | |
|---|
| 334 | DMG_MenuStart(MID_SETUP_WIZARD); |
|---|
| 335 | } |
|---|
| 336 | else { |
|---|
| 337 | DMG_MenuStart(MID_IDLE); |
|---|
| 338 | |
|---|
| 339 | if(DCC_IsReady()) { //CC also must be started!! |
|---|
| 340 | DMG_MenuStart(MID_CC); |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | App_ChTuneRecoverLastChannel(); |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | break; |
|---|
| 347 | |
|---|
| 348 | case eDMG_CMD_ON_KEY : |
|---|
| 349 | |
|---|
| 350 | if(ms_standby_start!=0 && DHL_OS_GetMsCount()-ms_standby_start<4000) { |
|---|
| 351 | break; |
|---|
| 352 | } |
|---|
| 353 | |
|---|
| 354 | switch(param2) { |
|---|
| 355 | case APP_VK_AD : |
|---|
| 356 | case APP_VK_POWER_OFF : |
|---|
| 357 | DMG_MenuExit(MID_STANDBY); |
|---|
| 358 | break; |
|---|
| 359 | |
|---|
| 360 | default: |
|---|
| 361 | ; |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | case eDMG_CMD_ON_TIME : |
|---|
| 365 | |
|---|
| 366 | if(param1==TIMER_ID_L1) { |
|---|
| 367 | // notify "enter to standby mode" to sdds module |
|---|
| 368 | #if SUPPORT_SDDS |
|---|
| 369 | App_SddsPowerModeChanged(FALSE); |
|---|
| 370 | DHL_OS_Printf("########### sdds power mode changed #############\n"); |
|---|
| 371 | #endif |
|---|
| 372 | //DMG_SetTimer(TIMER_ID_L1, MS_AUTO_REBOOT-4000, eDMG_CMD_OPT_TIMER_LOCAL1); |
|---|
| 373 | |
|---|
| 374 | } |
|---|
| 375 | else if(param1==TIMER_ID_CHK_UART) { |
|---|
| 376 | App_Proc_Idle(cmd, opt, param1, param2); |
|---|
| 377 | } |
|---|
| 378 | else if(param1==TIMER_ID_BG_1SEC) { |
|---|
| 379 | //standby mode check.. |
|---|
| 380 | APP_SDDS_SHORT_INFO info; |
|---|
| 381 | App_SddsGetInfo(&info); |
|---|
| 382 | |
|---|
| 383 | if (info.state == eSDDS_STATE_INIT || info.state ==eSDDS_STATE_COMPELTED) { |
|---|
| 384 | //if sdds update is not required, then go to standby |
|---|
| 385 | DMW_CDB_WaitForNvRamSyncDone(); |
|---|
| 386 | App_Fnc_SendData2(eCMD_SET_STATUS, eMICOM_MODE_S1, 0, 0, 0); |
|---|
| 387 | |
|---|
| 388 | p_led_ctrl(0); |
|---|
| 389 | DHL_SYS_Reset(eDHL_RESET_Standby); |
|---|
| 390 | } |
|---|
| 391 | |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | break; |
|---|
| 395 | |
|---|
| 396 | default : |
|---|
| 397 | ; |
|---|
| 398 | } |
|---|
| 399 | return TRUE; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | |
|---|
| 403 | void App_Menu_CreateStandby() |
|---|
| 404 | { |
|---|
| 405 | if(DMG_GetMenu(MID_STANDBY)) { |
|---|
| 406 | return; |
|---|
| 407 | } |
|---|
| 408 | |
|---|
| 409 | DMG_CreateMenu(MID_STANDBY_CFG); |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | int App_Menu_GetLedMode() |
|---|
| 414 | { |
|---|
| 415 | return p_led_mode; |
|---|
| 416 | } |
|---|