vfd_portable.c
资源名称:8202s.rar [点击查看]
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:15k
源码类别:
DVD
开发平台:
C/C++
- /*
- ----->included by vfd_io_util.c
- ----->only for portable dvd use.
- ----->did it on 07/25
- */
- #ifdef EASTWIN
- extern UINT8 safe_on;
- #endif
- #ifdef EASTWIN
- void check_portable_gpio(void)
- {
- UINT16 temp=0;
- #ifdef TFT_VIDEO_INOUT
- static BYTE AVin_step = 0;
- INT_EXT_GPIO_INIT();
- switch (GPIO_I_GET(INT_EXT_VIDEO_GPIO))
- {
- case 0://8210 input video to TFT
- if((system_state == SYSTEM_OPEN) && (AVin_step == 1))
- {//just now system was interrupted in reading disc
- if(CDOpened())
- {
- call_ir_func(IRC_EJECT);
- AVin_step = 0;
- //printf("i am going to read disc.......n");
- }
- }
- else if((system_state == SYSTEM_STOP) && (AVin_step == 2))
- {//just now system was interrupted in normal playing state
- ircmd_play();
- AVin_step = 0;
- //printf("i am going to play disc.......n");
- }
- if(hold_state == 2)
- hold_state = 0;
- break;
- case 1://External AV input to TFT
- if(system_state == SYSTEM_READ_TITLE)
- {//in reading disc and
- if(!CDOpened())
- {
- AVin_step = 1;
- call_ir_func(IRC_EJECT);
- //printf("video in when reading disc,then i go into open staten");
- }
- }
- else if(system_state == SYSTEM_BROWSE)
- {
- if(play_state != VCD_STATE_STOP)
- {
- AVin_step = 2;
- ircmd_stop();
- #ifdef STOP_LOADER
- stop_loader();
- #endif
- //printf("video in when playing disc,then i go into stop staten");
- }
- }
- if(hold_state == 0)
- hold_state = 2;
- break;
- }
- if(!AVin_step)
- {
- #endif //end #ifdef TFT_VIDEO_INOUT
- #ifdef SUNPLUS_8202P_DEMOBOARD
- regs0->sft_cfg4 &= ~((0x03)<<2); //Enable GPIO2,3 For COVER & TFT SW
- #endif
- #ifdef TFT_VIDEO_INOUT
- }
- #endif //end #ifdef TFT_VIDEO_INOUT
- #ifdef TFT_VIDEO_INOUT
- if(!AVin_step)
- {
- #endif //end #ifdef TFT_VIDEO_INOUT
- #ifdef HOLD_KEY_DETECT
- temp=regs0->gpio_in[HOLD_GPIO / 16] & (1 << (HOLD_GPIO % 16)); //get gpio37(HOLD)
- if(temp)
- hold_state=1;
- else
- hold_state=0;
- #endif
- temp=regs0->gpio_in[TFT_SW_GPIO / 16] & (1 << (TFT_SW_GPIO % 16)); //get gpio44(TFT_SW)
- if(temp) // lcd panel open
- {
- if(!bINVERTER_POWER)
- {
- INVERTER_POWER_ON();
- bINVERTER_POWER = 1;
- bPOWER_LED_FLASH = 0;
- }
- }
- else // lcd panel close
- {
- if(bINVERTER_POWER)
- {
- INVERTER_POWER_OFF();
- bINVERTER_POWER = 0;
- bPOWER_LED_FLASH = 1;
- }
- }
- if(bINVERTER_POWER) // lcd panel open
- {
- if(!bAMP_IS_ON && bPOWER_ON_MUTE_EXE)
- {
- ENABLE_AMP();
- bAMP_IS_ON = 1;
- }
- }
- else // lcd panel close
- {
- if(EAR_DETECT()) // earphone no plug in
- {
- if(bAMP_IS_ON)
- {
- DISABLE_AMP();
- bAMP_IS_ON = 0;
- }
- }
- else // earphone plug in
- { if(!bAMP_IS_ON && bPOWER_ON_MUTE_EXE)
- {
- ENABLE_AMP();
- bAMP_IS_ON = 1;
- }
- }
- }
- #ifdef POWER_ON_MUTE
- if(!bPOWER_ON_MUTE_EXE)
- {
- if(power_on_mute_timer >100 ) // power on to mute off time around 4.5S
- {
- AUDIO_MUTE_OFF();
- bPOWER_ON_MUTE_EXE = 1;
- power_on_mute_timer = 0;
- }
- power_on_mute_timer++;
- }
- #endif
- #ifdef POWER_LED_FLASH
- if(bPOWER_LED_FLASH)
- {
- if( power_led_flash_timer < 100 )
- {
- power_led_flash_timer ++;
- POWER_LED_ON();
- }
- else
- {
- if((power_led_flash_timer>=100) & (power_led_flash_timer<=200))
- {
- power_led_flash_timer ++;
- POWER_LED_OFF();
- }
- else
- power_led_flash_timer = 0;
- }
- }
- else
- {
- power_led_flash_timer = 0;
- POWER_LED_OFF();
- }
- #endif // end of POWER_LED_FLASH
- #ifdef TFT_VIDEO_INOUT
- }
- #endif //end #ifdef TFT_VIDEO_INOUT
- // Eastwin change to GPIO 18
- temp = regs0->gpio_in[LOWBAT_DET_GPIO / 16] & (1 << (LOWBAT_DET_GPIO % 16));
- if(!temp)
- {
- bIS_LOWBAT = 0; // Kevin Sep 10,04
- if(bLOWBAT_DISP)
- {
- bLOWBAT_DISP = 0;
- ClearOsdMsg(2);
- lowbat_timer=0;
- }
- }
- else
- {
- bIS_LOWBAT = 1; // Kevin Sep 10,04
- if (safe_on==1) // Kevin Sep 10,04
- safe_srn_off();
- if(lowbat_timer<100)
- {
- PrintOsdMsg(STR_OS_LOWBAT,REGION2,0,0);
- lowbat_timer++;
- bLOWBAT_DISP = 1;
- }
- else
- {
- if((lowbat_timer>=100) & (lowbat_timer<150))
- {
- ClearOsdMsg(2);
- lowbat_timer++;
- bLOWBAT_DISP = 0;
- }
- else
- {
- lowbat_timer = 0;
- bLOWBAT_DISP = 1;
- }
- }
- }
- }
- #else
- void check_portable_gpio(void)
- {
- UINT16 temp=0;
- #ifdef TFT_VIDEO_INOUT
- static BYTE AVin_step = 0;
- INT_EXT_GPIO_INIT();
- switch (GPIO_I_GET(INT_EXT_VIDEO_GPIO))
- {
- case 0://8210 input video to TFT
- if((system_state == SYSTEM_OPEN) && (AVin_step == 1))
- {//just now system was interrupted in reading disc
- if(CDOpened())
- {
- call_ir_func(IRC_EJECT);
- AVin_step = 0;
- //printf("i am going to read disc.......n");
- }
- }
- else if((system_state == SYSTEM_STOP) && (AVin_step == 2))
- {//just now system was interrupted in normal playing state
- ircmd_play();
- AVin_step = 0;
- //printf("i am going to play disc.......n");
- }
- if(hold_state == 2)
- hold_state = 0;
- break;
- case 1://External AV input to TFT
- if(system_state == SYSTEM_READ_TITLE)
- {//in reading disc and
- if(!CDOpened())
- {
- AVin_step = 1;
- call_ir_func(IRC_EJECT);
- //printf("video in when reading disc,then i go into open staten");
- }
- }
- else if(system_state == SYSTEM_BROWSE)
- {
- if(play_state != VCD_STATE_STOP)
- {
- AVin_step = 2;
- ircmd_stop();
- #ifdef STOP_LOADER
- stop_loader();
- #endif
- //printf("video in when playing disc,then i go into stop staten");
- }
- }
- if(hold_state == 0)
- hold_state = 2;
- break;
- }
- if(!AVin_step)
- {
- #endif //end #ifdef TFT_VIDEO_INOUT
- #ifdef SUNPLUS_8202P_DEMOBOARD
- regs0->sft_cfg4 &= ~((0x03)<<2); //Enable GPIO2,3 For COVER & TFT SW
- #endif
- #ifdef CHECK_PORTABLE_OPCLSW
- temp=regs0->gpio_in[PDVD_OPCLSW_GPIO / 16] & (1 << (PDVD_OPCLSW_GPIO % 16)); //get gpio16(COVER_SW)
- if(temp)
- {
- if(!CDOpened())
- {
- #ifdef ARGUS_PDVD_MENU_PLUS
- if(full_scrn & SETUP_PLUS)
- ircmd_setup_plus();
- #endif //end #ifdef ARGUS_PDVD_MENU_PLUS
- call_ir_func(IRC_EJECT);
- PrintOsdMsg(STR_OS_OPEN,REGION1,0,0);
- }
- }
- else
- {
- if(CDOpened())
- call_ir_func(IRC_EJECT);
- }
- #endif
- #ifdef TFT_VIDEO_INOUT
- }
- #endif //end #ifdef TFT_VIDEO_INOUT
- #if defined(GBM_PORTABLE_DVD)||defined(SUNPLUS_8202P_DEMOBOARD) //rbhung for GBM Portable DVD
- #ifdef TFT_VIDEO_INOUT
- if(!AVin_step)
- #endif //end #ifdef TFT_VIDEO_INOUT
- {
- #ifdef HOLD_KEY_DETECT
- temp=regs0->gpio_in[HOLD_GPIO / 16] & (1 << (HOLD_GPIO % 16)); //get (HOLD)
- if(temp)
- hold_state=1;
- else
- hold_state=0;
- #endif
- temp=regs0->gpio_in[TFT_SW_GPIO / 16] & (1 << (TFT_SW_GPIO % 16)); //get (TFT_SW)
- if(temp)
- regs0->gpio_out[CTR_TFT_GPIO /16]|= (1 << (CTR_TFT_GPIO % 16));
- else
- regs0->gpio_out[CTR_TFT_GPIO /16]&= ~(1 << (CTR_TFT_GPIO % 16));
- }
- temp=regs0->gpio_in[MCU_POWER_DET_GPIO / 16] & (1 << (MCU_POWER_DET_GPIO % 16)); //get gpio41(MCU_POWER_DET)
- if(temp)
- {
- powerdown_timer=0;
- }
- else
- {
- powerdown_timer++;
- if(powerdown_timer>100)
- {
- regs0->gpio_out[CTR_GLED_GPIO/16]|= (1 << (CTR_GLED_GPIO % 16)); //CTR_GLED->H,GREEN LED OFF
- regs0->gpio_out[DSP_RLED_GPIO/16]&= ~(1 << (DSP_RLED_GPIO % 16)); //DSP_RLED->L,RED LED ON
- call_ir_func(IRC_POWER);
- }
- }
- temp=regs0->gpio_in[LOWBAT_DET_GPIO / 16] & (1 << (LOWBAT_DET_GPIO % 16)); //get gpio42(LOWBAT_DET)
- if(temp)
- {
- if(lowbat_timer==0)
- ClearOsdMsg(2);
- lowbat_timer=1;
- regs0->gpio_out[CTR_GLED_GPIO/16]&= ~(1 << (CTR_GLED_GPIO % 16)); //CTR_GLED->L,GREEN LED ON
- regs0->gpio_out[DSP_RLED_GPIO/16]|= (1 << (DSP_RLED_GPIO % 16)); //DSP_RLED->H,RED LED OFF
- }
- else
- {
- if(lowbat_timer<100)
- {
- PrintOsdMsg(STR_OS_LOWBAT,REGION2,0,0);
- lowbat_timer++;
- regs0->gpio_out[CTR_GLED_GPIO/16]|= (1 << (CTR_GLED_GPIO % 16)); //CTR_GLED->H,GREEN LED OFF
- regs0->gpio_out[DSP_RLED_GPIO/16]&= ~(1 << (DSP_RLED_GPIO % 16)); //DSP_RLED->L,RED LED GLITTER ON
- }
- else
- {
- if((lowbat_timer>=100) & (lowbat_timer<150))
- {
- ClearOsdMsg(2);
- lowbat_timer++;
- regs0->gpio_out[DSP_RLED_GPIO/16]|= (1 << (DSP_RLED_GPIO % 16)); //DSP_RLED->H,RED LED GLITTER OFF
- }
- else
- lowbat_timer=0;
- }
- }
- #endif //end #ifdef GBM_PORTABLE_DVD
- }
- #endif
- #ifdef PDVD_USE_IO_SCAN_KEY
- const BYTE gpio[8]={46,47,48,49,50,51,52,18};
- #ifdef USE_COMBINED_KEY
- #define LONG_PRESS_KEY_TIME 12
- #endif
- //#define PORTABLE_IOKEY_DEBUG
- void check_portable_key(void)
- {
- #ifdef USE_COMBINED_KEY
- BYTE i,j,keydata;
- static BYTE column_dot = 4;
- static BYTE row_dot = 0;
- static BYTE keyprev = 0;
- static BYTE key_press_times = 0 ;
- #ifdef HOLD_KEY_DETECT
- if(hold_state)
- return;
- #endif
- regs0->gpio_oe[3]&= 0xffcf; //jhuang org 011f
- for(i=0;i<4;i++)
- {
- for(j=0;j<4;j++)
- GPIO_O_SET(gpio[j],1);
- GPIO_O_SET(gpio[i],0);
- for(j=4;j<8;j++)
- {
- keydata=GPIO_I_GET(gpio[j]);
- if(keydata == 0)
- {//have key pressing
- keydata=i*4+(j-4)+1;
- column_dot = j;
- row_dot = i;
- if(keyprev != keydata)
- {//first press key!
- keyprev = keydata;
- #ifdef PORTABLE_IOKEY_DEBUG
- printf("%d key press at the first timen",keydata);
- #endif
- }
- else
- {//count the key press times
- #ifdef D02_9_10INCH
- if((keydata == 8) || (keydata == 10))
- #else
- if((keydata == 4) || (keydata == 6)
- #ifdef D02_A_10INCH
- ||(keydata == 10) || (keydata == 16)
- #endif
- )
- #endif
- {
- key_press_times++;
- #ifdef PORTABLE_IOKEY_DEBUG
- printf("key press times:---->%dn",key_press_times);
- #endif
- }
- }
- break;
- }
- else if((j == column_dot) && (i == row_dot) && (keyprev != 0))
- {//key is released
- if(key_press_times >= LONG_PRESS_KEY_TIME)
- {//long press key
- #ifdef PORTABLE_IOKEY_DEBUG
- printf("call long key:%d!press %d timesn",keyprev,key_press_times);
- #endif
- #ifdef D02_9_10INCH
- if(keyprev == 8)
- #else
- if(keyprev == 4)
- #endif
- {
- #ifdef D02_A_10INCH
- call_ir_func(IRC_LEFT);
- #else
- call_ir_func(IRC_PREV);
- #endif
- }
- else
- {
- #ifdef D02_A_10INCH
- if(keyprev == 10)
- call_ir_func(IRC_DOWN);
- else if (keyprev == 16)
- call_ir_func(IRC_UP);
- else
- call_ir_func(IRC_RIGHT);
- #else
- call_ir_func(IRC_NEXT);
- #endif
- }
- }
- else
- {//short key press
- call_ir_func(vfd_keycode[keyprev - 1]);
- #ifdef PORTABLE_IOKEY_DEBUG
- printf("call short key:%dn",keyprev);
- #endif
- }
- key_press_times = 0;
- keyprev = 0;
- column_dot = 4;
- row_dot = 0;
- }
- }
- }
- #else
- BYTE i,j,k,keydata,press_key=0;
- static BYTE keyprev=0;
- #ifdef HOLD_KEY_DETECT
- if(hold_state)
- return;
- #endif
- regs0->gpio_oe[3]&= 0xffcf; //jhuang org 011f
- for(i=0;i<4;i++)
- {
- for(j=0;j<4;j++)
- GPIO_O_SET(gpio[j],1);
- GPIO_O_SET(gpio[i],0);
- for(k=4;k<8;k++)
- {
- keydata=GPIO_I_GET(gpio[k]);
- if(keydata==0)
- {
- press_key=1;
- keydata=i*4+(k-4)+1;
- if(keyprev!=keydata)
- {
- keyprev=keydata;
- call_ir_func(vfd_keycode[keydata - 1]);
- printf("key %d SW %d,%d.n",keydata,i,k-4);
- }
- break;
- }
- }
- }
- if(press_key==0) keyprev=0;
- #endif //end #ifdef USE_COMBINED_KEY
- }
- #endif //#ifdef PDVD_USE_IO_SCAN_KEY