sleep.c
上传用户:caisangzi8
上传日期:2013-10-25
资源大小:15756k
文件大小:19k
源码类别:

DVD

开发平台:

C/C++

  1. //
  2. // FILE
  3. // sleep.c
  4. //
  5. // DESCRIPTION
  6. // provide sleep functionality
  7. //
  8. //terry,2004/9/21 10:16PM , add risc can work when standby mode
  9. //
  10. #include "config.h"
  11. #include "global.h"
  12. #include "regmap.h"
  13. #include "pu8560.h"
  14. #include "cpu.h"
  15. #include "func.h"
  16. #include "gpio.h"
  17. #include "hwif.h"
  18. #include "tvif.h"
  19. #ifdef PMP_MCU810
  20. #include "vfd.h"
  21. #endif
  22. #ifdef TP6317_PANNEL   //yaowh add 04-10-25
  23.   extern BYTE TP6317_Power ;
  24. #endif
  25. #ifdef RISC_ALIVE_STANDBY  // 2004/10/01 yltseng
  26. #include "iop.h"
  27. #include "uartsup.h"
  28. #include "ircode.h"
  29. #endif
  30. //#include "auddac.h"
  31. //#include "ircode.h"    /* alan 02-05-21 added for IRC_POWER */
  32. #ifndef DVDRELEASE
  33. #include "sio.h"
  34. #include "emuio.h"
  35. #endif
  36. #ifdef DVD_SERVO_REAL_TURN_OFF//nono rename 4-12-30 11:18//NO_DVD_SERVO //ycwen 2004/08/10
  37. extern void servo_turn_off(void);
  38. #endif
  39. #define SAFE_AUTO_POWEROFF//nono set it. 4-7-22 23:46 Because servo need longer time to finish when trayout.
  40. #define ROM_ISA_ENABLE (1<<15)
  41. #define HW_RESET_GLOBAL (1<<0) // 1-shot global reset
  42. #define HW_RESET_AGDC_MMU (1<<1) // will/may hang up system
  43. #define HW_RESET_STC (1<<2)
  44. #define HW_RESET_IOP (1<<3)
  45. #define HW_RESET_HOST (1<<4) // ATAPI/UDE/CSS/CDDSP
  46. #define HW_RESET_AUD (1<<5) // DSP/DSP3IF/DVDAUD
  47. #define HW_RESET_VDEC (1<<6) // VLD/INVQ/IDCT/MC/OGT(?)
  48. #define HW_RESET_DISPLAY (1<<7) // VPP/OSD
  49. #define HW_RESET_SIO0 (1<<8)
  50. #define HW_RESET_UART0 (1<<9)
  51. #define HW_RESET_UART1 (1<<10)
  52. #ifdef SCART_TV
  53.     #define SET_SCART_RGB(d) ((d) ? (regs0->gpio_out[39 / 16] |= (0x1 << (39 % 16))) : (regs0->gpio_out[39 / 16] &= ~(0x1 << (39 % 16))))
  54.     #define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[38 / 16] |= (0x1 << (38 % 16))) : (regs0->gpio_out[38 / 16] &= ~(0x1 << (38 % 16))))
  55.     #define SET_SCART_TV(d) ((d) ? (regs0->gpio_out[37 / 16] |= (0x1 << (37 % 16))) : (regs0->gpio_out[37 / 16] &= ~(0x1 << (37 % 16))))
  56. #elif defined(KSD_SCART_TV)
  57.     #define SET_SCART_RGB(d) ((d) ? (regs0->gpio_out[57 / 16] |= (0x1 << (57 % 16))) : (regs0->gpio_out[57 / 16] &= ~(0x1 << (57 % 16))))
  58.     //#define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[18 / 16] |= (0x1 << (18 % 16))) : (regs0->gpio_out[18 / 16] &= ~(0x1 << (18 % 16))))
  59. #elif defined(SCART_TV_2)    //wanghaoying 2003-8-13 15:11 added 
  60.     #define SET_SCART_RGB(d) ((d) ? (regs0->gpio_out[57 / 16] |= (0x1 << (57 % 16))) : (regs0->gpio_out[57 / 16] &= ~(0x1 << (57 % 16))))
  61.     #define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[18 / 16] |= (0x1 << (18 % 16))) : (regs0->gpio_out[18 / 16] &= ~(0x1 << (18 % 16))))
  62.     #ifdef NIN_SCART_TV    //fangang added 4-2-11 17:02
  63.            #define SET_SCART_TV(d) ((d) ? (regs0->gpio_out[2 / 16] |= (0x1 << (2 % 16))) : (regs0->gpio_out[2 / 16] &= ~(0x1 << (2 % 16))))
  64.     #endif
  65.     #ifdef YILI_SCART_TV  //hq add, use 31 pin control  TV-AV switch, 4-2-17 9:40 
  66.            #define SET_SCART_TV(d) ((d) ? (regs0->gpio_out[4 / 16] |= (0x1 << (4 % 16))) : (regs0->gpio_out[4 / 16] &= ~(0x1 << (4 % 16))))
  67.     #endif    
  68. #elif defined(SCART_TV_3)   //wanghaoying 2003-9-12 11:28 added
  69.     #define SET_SCART_RGB(d)    ((d) ? (regs0->gpio_out[57 / 16] |= (0x1 << (57 % 16))) : (regs0->gpio_out[57 / 16] &= ~(0x1 << (57 % 16))))
  70.     #define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[18 / 16] |= (0x1 << (18 % 16))) : (regs0->gpio_out[18 / 16] &= ~(0x1 << (18 % 16))))
  71.     #define SET_SCART_SW1(d) ((d) ? (regs0->gpio_out[14 / 16] |= (0x1 << (14 % 16))) : (regs0->gpio_out[14 / 16] &= ~(0x1 << (14 % 16))))
  72. #elif defined(SCART_TV_4)   //nono 2003-9-26 1:44 for himage HJ-018
  73.     #define SET_SCART_RGB(d)    ((d) ? (regs0->gpio_out[3 / 16] |= (0x1 << (3 % 16))) : (regs0->gpio_out[3 / 16] &= ~(0x1 << (3 % 16))))
  74.     #ifdef HJ_021_SCART
  75.     #define SET_SCART_SW1(d) ((d) ? (regs0->gpio_out[4 / 16] |= (0x1 << (4 % 16))) : (regs0->gpio_out[4 / 16] &= ~(0x1 << (4 % 16))))
  76.     #define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[2 / 16] |= (0x1 << (2 % 16))) : (regs0->gpio_out[2 / 16] &= ~(0x1 << (2 % 16))))
  77.     #else//#ifdef HJ_021_SCART
  78.     #define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[4 / 16] |= (0x1 << (4 % 16))) : (regs0->gpio_out[4 / 16] &= ~(0x1 << (4 % 16))))
  79.     #define SET_SCART_SW1(d) ((d) ? (regs0->gpio_out[2 / 16] |= (0x1 << (2 % 16))) : (regs0->gpio_out[2 / 16] &= ~(0x1 << (2 % 16))))
  80.     #endif//#ifdef HJ_021_SCART
  81. #elif defined(SCART_TV_5)//wangfeng 2003-12-2 11:43 for himage HJ-023
  82.     #define SET_SCART_RGB(d)    ((d) ? (regs0->gpio_out[63 / 16] |= (0x1 << (63 % 16))) : (regs0->gpio_out[63 / 16] &= ~(0x1 << (63 % 16))))
  83.     #define SET_SCART_SW(d) ((d) ? (regs0->gpio_out[62 / 16] |= (0x1 << (62 % 16))) : (regs0->gpio_out[62 / 16] &= ~(0x1 << (62 % 16))))
  84.     #define SET_SCART_SW1(d) //((d) ? (regs0->gpio_out[2 / 16] |= (0x1 << (2 % 16))) : (regs0->gpio_out[2 / 16] &= ~(0x1 << (2 % 16))))
  85. #endif
  86. extern int atapi_standby_mode(void);
  87. extern void run_close_tray(UINT8);
  88. extern int atapi_p_mechanism_status(void);
  89. extern void ircmd_trayin(void);
  90. extern void reset_iop();
  91. extern int standby_cnt;
  92. extern const BYTE vfd_keycode[40];
  93. #if 0 //terry,2004/7/23 10:23PM, it's seem no use.
  94. void __system_stop(void)
  95. {
  96. //init_vfd_clear();
  97. run_close_tray(1);              // loader
  98. #if !defined(SUPPORT_TUNER_MV114) && !defined(SUPPORT_TUNER_ALPS) //xyy 2003-9-22 10:50
  99. regs0->reset = 
  100. HW_RESET_HOST |             // atapi
  101. HW_RESET_AUD |              // audio DSP
  102. HW_RESET_VDEC |             // video decoder
  103. HW_RESET_SIO0 |
  104. //HW_RESET_DISPLAY |          // video 
  105. HW_RESET_UART0;
  106. //HW_RESET_UART1             // debug port
  107. #endif
  108. }
  109. #endif
  110. static inline void system_tuner_sleep(void)
  111. {
  112.     tv_sleep();
  113. #if 0
  114.     regs0->rom_config = (1 << 15)   // rom run slow
  115.                         | (15 << 0)
  116.                         | (15 << 4)
  117.                         | (15 << 8);
  118. #endif    
  119.     delay_srv_10ms(10);
  120.     cpu_intr_disable();
  121.     regs0->intr_mask = 0;
  122.     regs0->intr_flag = -1;    
  123. }
  124. static inline void disable_tv(void)
  125. {
  126.     // disable tv-encoder
  127.     tv_sleep();
  128. #ifdef  YILI_SCART_TV  //hq added, use 31 pin control  TV-AV switch, 4-2-11 16:59
  129.     SET_SCART_TV(1);
  130. #endif   
  131. #ifdef  NIN_SCART_TV  //fangang added 4-2-11 16:59
  132.     SET_SCART_TV(1);
  133. #endif
  134. #ifdef SUPPORT_SCART_TV//SPHE8202//nono 4-3-27 21:35
  135.     SET_SCART_GPIO_SFT_CFG_CTRL();
  136.     SET_SCART_TO_TV();
  137. #endif//SPHE8202
  138. }
  139. static inline void close_tray_func(void)
  140. {
  141. #ifdef GBM_DVD
  142.     run_close_tray(0); // gerry for gbm use old servo code,if we update servo,maybe we need not this. 2004-2-7 15:42
  143. #elif !defined(TOP_DOOR_FOR_NGAILIK)     //hq add for ngailik, in order to wake up the system after power off-on quickly switch. 2004-3-3 17:38
  144. #ifdef SAFE_AUTO_POWEROFF//nono 20040327
  145.     if (atapi_p_mechanism_status()==0/*ATAPI_DOOR_OPEN*/)
  146.       ircmd_trayin();//nono 2004-3-27 16:27 for auto_poweroff.
  147.     else
  148.       run_close_tray(1); // Robert 2003/12/16        
  149. #else//SAFE_AUTO_POWEROFF
  150.     run_close_tray(1); // Robert 2003/12/16
  151. #endif//SAFE_AUTO_POWEROFF
  152. #endif    
  153. }
  154. static inline void led_light(void)
  155. {
  156. #ifdef USE_VFD_LED_AS_IO //xyy add for Oritron
  157. write_vfd_led(0x01);
  158. #endif
  159. #ifdef KENLOON_PANEL3
  160.     write_vfd_led(0xff);  //wangap add 2004/6/29
  161. #endif
  162. #ifdef USE_VFD_LED_POWER
  163. #ifdef USE_VFD_LED_POWER_LOW
  164.     write_vfd_led(0);
  165. #else
  166.     #ifdef  PROVIEW_DV_509
  167.         write_vfd_led(0x8);
  168.     #elif defined(VTREK_DVD)
  169.         write_vfd_led(0x7);
  170.     #else    
  171.         write_vfd_led(0xf);
  172.     #endif 
  173. #endif 
  174. #endif
  175. #ifdef KSD_SCART_TV
  176. GPIO_O_SET(18,1);
  177. #endif
  178. #ifdef USE_CD_SENSE_PIN_AS_LED_GPIO //gerry,2004-2-10 18:33
  179. GPIO_O_SET(4,1);
  180. #endif//USE_CD_SENSE_PIN_AS_LED_GPIO    
  181. #ifdef NINTAUS_612      //linrc add for nintaus 2004-7-6 13:57 when standby,the LED must light
  182.     GPIO_O_SET(4,1);
  183.     GPIO_O_SET(3,0);
  184. #endif
  185. #if defined(USE_VFDPORT_TO_KEYLIGHT_GBM)
  186. regs0->gpio_master[56 / 16] |= (0x1 << (56 % 16));//pin156
  187.     regs0->gpio_oe[56 / 16] |= (0x7 << (56 % 16));
  188.     regs0->gpio_out[56 / 16] |= (0x7 << (56 % 16));      
  189. #elif defined(GPIO14_STANDBY_LED)    //hq, 2004-3-20 15:52
  190.     GPIO_O_SET(14,1);//turn on the Standby LED.
  191. #elif defined(USE_VFDPORT_TO_KEYLIGHT_MINTON)
  192. GPIO_O_SET(14,0);//off
  193. regs0->gpio_oe[54 / 16] |= (0x7 << (54 % 16));//nono 2003-9-1 23:50
  194. GPIO_O_SET(54,1);//off
  195. GPIO_O_SET(55,1);//off
  196. GPIO_O_SET(56,1);//off         
  197. #elif defined(USE_VFD_GAME_PORT_TO_KEYBOARD_HJ_2290)
  198. GPIO_O_SET(54,1);//off
  199. GPIO_O_SET(55,1);//off
  200. GPIO_O_SET(56,1);//off
  201. #elif defined(USE_VFD_GAME_PORT_TO_KEYBOARD_HJ_DP313)
  202. GPIO_O_SET(3,1);
  203. GPIO_O_SET(62,1);
  204. GPIO_O_SET(63,1);          
  205. #endif
  206. #ifdef GBM_SET_VFD_PIN_LOW_WHEN_STANDBY //set vfd pin low when standby for GBM TOP_DOOR_LOADER,gerry,2004/2/11 08:48