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.

476 lines
9.8 KiB

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