Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

466 lines
9.6 KiB

  1. //***************************************************************************
  2. // Video Processor(V-PRO) process
  3. //
  4. //***************************************************************************
  5. #include "common.h"
  6. #include "regs.h"
  7. #include "cvpro.h"
  8. void VProcessor::init( const PDEVICE_INIT_INFO pDevInit )
  9. {
  10. ioBase = pDevInit->ioBase;
  11. //--- 97.09.04 K.Chujo
  12. // You should reset SUBPIC part to change the subpic stream ID safely,
  13. // because early VPRO has a bug.
  14. // But if you reset it, you must restore registers.
  15. //--- End.
  16. }
  17. void VProcessor::SetParam( ULONG aMode, BOOL bSubpicMute )
  18. {
  19. AudioMode = aMode;
  20. SubpicMute = bSubpicMute;
  21. if( SubpicMute )
  22. VproCOMMAND_REG = 0xA0; // see specifications (date 96.09.26 spec)
  23. else
  24. VproCOMMAND_REG = 0x20; // see specifications (date 96.09.26 spec)
  25. }
  26. void VProcessor::VPRO_RESET_FUNC()
  27. {
  28. WRITE_PORT_UCHAR( ioBase + VPRO_RESET, 0 );
  29. WRITE_PORT_UCHAR( ioBase + VPRO_RESET, 0x80 );
  30. VproRESET_REG = 0x80;
  31. VproVMODE_REG = 0; // ? ? ?
  32. VproAVM_REG = 0; // ? ? ?
  33. }
  34. void VProcessor::VPRO_VIDEO_MUTE_ON()
  35. {
  36. // debug
  37. // if ( !(VproRESET_REG & 0x80) )
  38. // Error;
  39. // debug
  40. VproRESET_REG |= 0x40;
  41. WRITE_PORT_UCHAR( ioBase + VPRO_RESET, VproRESET_REG );
  42. }
  43. void VProcessor::VPRO_VIDEO_MUTE_OFF()
  44. {
  45. // debug
  46. // if ( !(VproRESET_REG & 0x80) )
  47. // Error;
  48. // debug
  49. VproRESET_REG &= 0xbf;
  50. WRITE_PORT_UCHAR( ioBase + VPRO_RESET, VproRESET_REG );
  51. }
  52. void VProcessor::VPRO_INIT_NTSC()
  53. {
  54. VproVMODE_REG &= 0x7f;
  55. WRITE_PORT_UCHAR( ioBase + VPRO_VMODE, VproVMODE_REG );
  56. VproAVM_REG &= 0x5f;
  57. WRITE_PORT_UCHAR( ioBase + VPRO_AVM, VproAVM_REG );
  58. WRITE_PORT_UCHAR( ioBase + VPRO_DVEN, 0xc0 );
  59. }
  60. void VProcessor::VPRO_INIT_PAL()
  61. {
  62. VproVMODE_REG |= 0x80;
  63. WRITE_PORT_UCHAR( ioBase + VPRO_VMODE, VproVMODE_REG );
  64. VproAVM_REG &= 0x5f;
  65. WRITE_PORT_UCHAR( ioBase + VPRO_AVM, VproAVM_REG );
  66. WRITE_PORT_UCHAR( ioBase + VPRO_DVEN, 0x80 );
  67. }
  68. void VProcessor::VPRO_CC_ON()
  69. {
  70. // VproVMODE_REG &= 0xbf;
  71. VproVMODE_REG |= 0x40;
  72. WRITE_PORT_UCHAR( ioBase + VPRO_VMODE, VproVMODE_REG );
  73. }
  74. void VProcessor::VPRO_CC_OFF()
  75. {
  76. // VproVMODE_REG |= 0x40;
  77. VproVMODE_REG &= 0xbf;
  78. WRITE_PORT_UCHAR( ioBase + VPRO_VMODE, VproVMODE_REG );
  79. }
  80. void VProcessor::VPRO_SUBP_PALETTE( PUCHAR pPalData )
  81. {
  82. ULONG i;
  83. WRITE_PORT_UCHAR( ioBase + VPRO_CPSET, 0x80 );
  84. for( i = 0; i < 48; i++ )
  85. WRITE_PORT_UCHAR( ioBase + VPRO_CPSP, *pPalData++ );
  86. WRITE_PORT_UCHAR( ioBase + VPRO_CPSET, 0x40 );
  87. WRITE_PORT_UCHAR( ioBase + VPRO_CPSET, 0 );
  88. }
  89. void VProcessor::VPRO_OSD_PALETTE( PUCHAR pPalData )
  90. {
  91. int i;
  92. WRITE_PORT_UCHAR( ioBase + VPRO_CPSET, 0x20 );
  93. for( i = 0; i < 48; i++ )
  94. WRITE_PORT_UCHAR( ioBase + VPRO_CPSP, *pPalData++ );
  95. WRITE_PORT_UCHAR( ioBase + VPRO_CPSET, 0x10 );
  96. WRITE_PORT_UCHAR( ioBase + VPRO_CPSET, 0 );
  97. }
  98. void VProcessor::SUBP_RESET_INIT()
  99. {
  100. UCHAR ch;
  101. SUBP_RESET_FUNC();
  102. // Interrupt Mask.
  103. WRITE_PORT_UCHAR( ioBase + SUBP_STSINT, 0xf0 );
  104. // select Audio Stream.
  105. if( AudioMode == AUDIO_TYPE_AC3 || AudioMode == AUDIO_TYPE_PCM )
  106. SUBP_SELECT_AUDIO_SSID();
  107. else
  108. SUBP_SELECT_AUDIO_STID();
  109. SUBP_STC_OFF();
  110. // Audio channel
  111. if( AudioMode == AUDIO_TYPE_AC3 )
  112. ch = SUB_STRMID_AC3;
  113. else if( AudioMode == AUDIO_TYPE_MPEG_F1 )
  114. ch = STRMID_MPEG_AUDIO;
  115. else if( AudioMode == AUDIO_TYPE_MPEG_F2 )
  116. ch = STRMID_MPEG_AUDIO;
  117. else
  118. ch = SUB_STRMID_PCM;
  119. ch = (UCHAR)SUBP_GET_AUDIO_CH();
  120. SUBP_SET_AUDIO_CH( ch );
  121. // Sub-Pic Channel
  122. SUBP_SET_SUBP_CH( 0 );
  123. // Sub-Pic MUTE ON/OFF.
  124. if( SubpicMute )
  125. SUBP_MUTE_ON();
  126. else
  127. SUBP_MUTE_OFF();
  128. SUBP_BUFF_CLEAR();
  129. }
  130. void VProcessor::SUBP_RESET_FUNC()
  131. {
  132. WRITE_PORT_UCHAR( ioBase + SUBP_RESET, 0x80 );
  133. WRITE_PORT_UCHAR( ioBase + SUBP_RESET, 0 );
  134. // set or restore COMMAND REGISTER
  135. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG );
  136. }
  137. void VProcessor::SUBP_RESET_STC()
  138. {
  139. WRITE_PORT_UCHAR( ioBase + SUBP_RESET, 0x40 );
  140. WRITE_PORT_UCHAR( ioBase + SUBP_RESET, 0 );
  141. }
  142. void VProcessor::SUBP_BUFF_CLEAR()
  143. {
  144. //--- 97.09.04 K.Chujo
  145. // old below
  146. // UCHAR val;
  147. // val = READ_PORT_UCHAR( ioBase + SUBP_COMMAND );
  148. // val |= 0x10;
  149. // WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, val );
  150. // val &= 0xef;
  151. // WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, val );
  152. // new below
  153. VproCOMMAND_REG |= 0x10;
  154. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG);
  155. VproCOMMAND_REG &= 0xef;
  156. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG);
  157. //--- End.
  158. }
  159. void VProcessor::SUBP_MUTE_ON()
  160. {
  161. DebugPrint(( DebugLevelTrace, "TOSDVD:VProcessor::SUBP_MUTE_ON()\r\n" ));
  162. //--- 97.09.04 K.Chujo
  163. // old below
  164. // UCHAR val;
  165. // val = READ_PORT_UCHAR( ioBase + SUBP_COMMAND );
  166. // val |= 0x80;
  167. // WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, val );
  168. // new below
  169. VproCOMMAND_REG |= 0x80;
  170. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG );
  171. //--- End.
  172. SubpicMute = TRUE;
  173. }
  174. void VProcessor::SUBP_MUTE_OFF()
  175. {
  176. DebugPrint(( DebugLevelTrace, "TOSDVD:VProcessor::SUBP_MUTE_OFF()\r\n" ));
  177. //--- 97.09.04 K.Chujo
  178. // old below
  179. // UCHAR val;
  180. // val = READ_PORT_UCHAR( ioBase + SUBP_COMMAND );
  181. // val &= 0x7f;
  182. // WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, val );
  183. // new below
  184. VproCOMMAND_REG &= 0x7f;
  185. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG );
  186. //--- End.
  187. SubpicMute = FALSE;
  188. }
  189. void VProcessor::SUBP_HLITE_ON()
  190. {
  191. //--- 97.09.04 K.Chujo
  192. // old below
  193. // UCHAR val;
  194. // val = READ_PORT_UCHAR( ioBase + SUBP_COMMAND );
  195. // val |= 0x40;
  196. // WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, val );
  197. // new below
  198. VproCOMMAND_REG |= 0x40;
  199. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG );
  200. //--- End.
  201. }
  202. void VProcessor::SUBP_HLITE_OFF()
  203. {
  204. //--- 97.09.04 K.Chujo
  205. // old below
  206. // UCHAR val;
  207. // val = READ_PORT_UCHAR( ioBase + SUBP_COMMAND );
  208. // val &= 0xbf;
  209. // WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, val );
  210. // new below
  211. VproCOMMAND_REG &= 0xbf;
  212. WRITE_PORT_UCHAR( ioBase + SUBP_COMMAND, VproCOMMAND_REG );
  213. //--- End.
  214. }
  215. void VProcessor::SUBP_SET_STC( ULONG stc )
  216. {
  217. SUBP_STC_OFF();
  218. WRITE_PORT_UCHAR( ioBase + SUBP_STCLL, (UCHAR)( stc & 0xff ) );
  219. WRITE_PORT_UCHAR( ioBase + SUBP_STCLH, (UCHAR)( ( stc >> 8 ) & 0xff ) );
  220. WRITE_PORT_UCHAR( ioBase + SUBP_STCHL, (UCHAR)( ( stc >> 16 ) & 0xff ) );
  221. WRITE_PORT_UCHAR( ioBase + SUBP_STCHH, (UCHAR)( ( stc >> 24 ) & 0xff ) );
  222. // SUBP_STC_ON();
  223. }
  224. void VProcessor::SUBP_SET_LNCTLI( PUCHAR pData )
  225. {
  226. WRITE_PORT_UCHAR( ioBase + SUBP_LCINFLL, *pData++ );
  227. WRITE_PORT_UCHAR( ioBase + SUBP_LCINFLH, *pData++ );
  228. WRITE_PORT_UCHAR( ioBase + SUBP_LCINFHL, *pData++ );
  229. WRITE_PORT_UCHAR( ioBase + SUBP_LCINFHH, *pData++ );
  230. }
  231. void VProcessor::SUBP_SET_PXCTLIS( PUCHAR pData )
  232. {
  233. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFSLL, *pData++ );
  234. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFSLH, *pData++ );
  235. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFSML, *pData++ );
  236. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFSMH, *pData++ );
  237. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFSHL, *pData++ );
  238. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFSHH, *pData++ );
  239. }
  240. void VProcessor::SUBP_SET_PXCTLIE( PUCHAR pData )
  241. {
  242. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFELL, *pData++ );
  243. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFELH, *pData++ );
  244. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFEML, *pData++ );
  245. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFEMH, *pData++ );
  246. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFEHL, *pData++ );
  247. WRITE_PORT_UCHAR( ioBase + SUBP_PCINFEHH, *pData++ );
  248. }
  249. void VProcessor::SUBP_STC_ON()
  250. {
  251. UCHAR val;
  252. val = READ_PORT_UCHAR( ioBase + SUBP_STCCNT );
  253. val |= 0x80;
  254. WRITE_PORT_UCHAR( ioBase + SUBP_STCCNT, val );
  255. }
  256. void VProcessor::SUBP_STC_OFF()
  257. {
  258. UCHAR val;
  259. val = READ_PORT_UCHAR( ioBase + SUBP_STCCNT );
  260. val &= 0x7f;
  261. WRITE_PORT_UCHAR( ioBase + SUBP_STCCNT, val );
  262. }
  263. void VProcessor::SUBP_SET_SUBP_CH( ULONG ch )
  264. {
  265. UCHAR ucch;
  266. ucch = (UCHAR)( ch & 0x1f );
  267. ucch |= 0x20;
  268. //--- 97.09.14 K.Chujo
  269. SubpicID = ucch;
  270. #if 1
  271. // VPRO (early TC90A09F) has a bug. When change subpic ID, subpic disappears somtimes.
  272. // You should reset SUBPIC part to change subpic ID safely.
  273. // reset SUBPIC part
  274. SUBP_RESET_FUNC();
  275. // Interrupt Mask.
  276. WRITE_PORT_UCHAR( ioBase + SUBP_STSINT, 0xf0 );
  277. // select Audio Stream.
  278. if( AudioMode == AUDIO_TYPE_AC3 || AudioMode == AUDIO_TYPE_PCM )
  279. SUBP_SELECT_AUDIO_SSID();
  280. else
  281. SUBP_SELECT_AUDIO_STID();
  282. // SUBP_STC_OFF();
  283. // Audio channel
  284. SUBP_SET_AUDIO_CH( AudioID );
  285. DebugPrint(( DebugLevelTrace, "TOSDVD: <<< New Audio ID = %x >>>\r\n", AudioID ));
  286. // Sub-Pic Channel
  287. WRITE_PORT_UCHAR( ioBase + SUBP_SPID, SubpicID );
  288. DebugPrint(( DebugLevelTrace, "TOSDVD: <<< New Subpic ID = %x >>>\r\n", SubpicID ));
  289. // Sub-Pic MUTE ON/OFF.
  290. if( SubpicMute )
  291. SUBP_MUTE_ON();
  292. else
  293. SUBP_MUTE_OFF();
  294. // SUBP_BUFF_CLEAR();
  295. #else
  296. // Maybe VPRO works only next one code if later version (ex. Timpani).
  297. WRITE_PORT_UCHAR( ioBase + SUBP_SPID, SubpicID );
  298. #endif
  299. //--- End.
  300. }
  301. ULONG VProcessor::SUBP_GET_SUBP_CH()
  302. {
  303. UCHAR val;
  304. val = READ_PORT_UCHAR( ioBase + SUBP_SPID );
  305. return val;
  306. }
  307. void VProcessor::SUBP_SET_AUDIO_CH( ULONG ch )
  308. {
  309. UCHAR ucch;
  310. ucch = (UCHAR)( ch & 0x7 );
  311. if( AudioMode == AUDIO_TYPE_AC3 )
  312. ucch |= 0x80;
  313. else if( AudioMode == AUDIO_TYPE_PCM )
  314. ucch |= 0xa0;
  315. else if( AudioMode == AUDIO_TYPE_MPEG_F1 )
  316. ucch |= 0xc0;
  317. else
  318. ucch |= 0xd0;
  319. //--- 97.09.14 K.Chujo
  320. AudioID = ucch;
  321. //--- End.
  322. WRITE_PORT_UCHAR( ioBase + SUBP_AAID, ucch );
  323. WRITE_PORT_UCHAR( ioBase + SUBP_ABID, 0 );
  324. }
  325. void VProcessor::SUBP_SET_AUDIO_NON()
  326. {
  327. //--- 97.09.14 K.Chujo
  328. AudioID = 0;
  329. //--- End.
  330. WRITE_PORT_UCHAR( ioBase + SUBP_AAID, 0 );
  331. WRITE_PORT_UCHAR( ioBase + SUBP_ABID, 0 );
  332. }
  333. //--- 97.09.10 K.Chujo
  334. ULONG VProcessor::SUBP_GET_AUDIO_CH()
  335. {
  336. UCHAR val;
  337. val = READ_PORT_UCHAR( ioBase + SUBP_AAID );
  338. return (ULONG)val;
  339. }
  340. //--- End.
  341. void VProcessor::SUBP_SELECT_AUDIO_STID()
  342. {
  343. WRITE_PORT_UCHAR( ioBase + SUBP_ASEL, 0 );
  344. }
  345. void VProcessor::SUBP_SELECT_AUDIO_SSID()
  346. {
  347. WRITE_PORT_UCHAR( ioBase + SUBP_ASEL, 3 );
  348. }