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.

910 lines
23 KiB

  1. #include "common.h"
  2. #include "regs.h"
  3. #include "vdec.h"
  4. void VDecoder::init( const PDEVICE_INIT_INFO pDevInit )
  5. {
  6. ioBase = pDevInit->ioBase;
  7. }
  8. void VDecoder::VIDEO_RESET( void )
  9. {
  10. UCHAR val;
  11. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_RESET );
  12. for ( ; ; )
  13. {
  14. val = READ_PORT_UCHAR( ioBase + TC812_STT1 );
  15. if ( ( val & 0x01 ) != 0x01 )
  16. break;
  17. // wait !!
  18. }
  19. for ( ; ; )
  20. {
  21. val = READ_PORT_UCHAR( ioBase + TC812_STT1 );
  22. if ( ( val & 0x10 ) != 0x10 )
  23. break;
  24. // wait !!
  25. }
  26. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x05 );
  27. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  28. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  29. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, 0x00 );
  30. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x13 );
  31. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  32. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  33. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  34. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, 0x00 );
  35. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x14 );
  36. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x05 );
  37. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  38. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  39. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, 0x00 );
  40. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x13 );
  41. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x34 );
  42. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_RESET );
  43. for ( ; ; )
  44. {
  45. val = READ_PORT_UCHAR( ioBase + TC812_STT1 );
  46. if ( ( val & 0x01 ) != 0x01 )
  47. break;
  48. // wait !!
  49. }
  50. for ( ; ; )
  51. {
  52. val = READ_PORT_UCHAR( ioBase + TC812_STT1 );
  53. if ( ( val & 0x10 ) != 0x10 )
  54. break;
  55. // wait !!
  56. }
  57. }
  58. void VDecoder::VIDEO_MODE_DVD( void )
  59. {
  60. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  61. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DEC_MODE );
  62. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xe0 );
  63. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_INT_ID );
  64. VIDEO_PRSO_PS1();
  65. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xbf );
  66. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  67. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  68. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, 0x00 );
  69. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_USER_ID );
  70. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  71. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DMODE );
  72. WRITE_PORT_UCHAR( ioBase + TC812_DSPL, 0x1f );
  73. VIDEO_VIDEOCD_OFF();
  74. }
  75. void VDecoder::VDVD_VIDEO_MODE_PS( void )
  76. {
  77. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xbd );
  78. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  79. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_PRSO_ID );
  80. }
  81. void VDecoder::VIDEO_PRSO_PS1( void )
  82. {
  83. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xbd );
  84. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  85. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_PRSO_ID );
  86. }
  87. void VDecoder::VIDEO_PRSO_NON( void )
  88. {
  89. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  90. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  91. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_PRSO_ID );
  92. }
  93. void VDecoder::VIDEO_OUT_NTSC( void )
  94. {
  95. UCHAR val;
  96. // set video frame size mode to NTSC
  97. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  98. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_VFMODE );
  99. // set STD buffer size
  100. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x40 );
  101. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x11 );
  102. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_STD_SIZE );
  103. // set USER1/2 area size
  104. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xf7 );
  105. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x01 );
  106. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  107. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, 0x00 );
  108. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_USER_SIZE );
  109. // set ext. memory mapping
  110. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_MEM_MAP );
  111. for ( ; ; )
  112. {
  113. val = READ_PORT_UCHAR( ioBase + TC812_STT1 );
  114. if ( ( val & 0x10 ) != 0x10 )
  115. break;
  116. // wait !!! & timeout !!!
  117. }
  118. // set underflow/overflow size
  119. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x10 );
  120. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  121. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, 0x00 );
  122. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, 0x10 );
  123. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_UOF_SIZE );
  124. // default RHOS
  125. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  126. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  127. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_HOFFSET );
  128. // default RVOS
  129. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  130. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  131. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_VOFFSET );
  132. }
  133. void VDecoder::VIDEO_ALL_INT_OFF( void )
  134. {
  135. WRITE_PORT_UCHAR( ioBase + TC812_IRM, 0xff );
  136. WRITE_PORT_UCHAR( ioBase + TC812_DEM, 0xff );
  137. WRITE_PORT_UCHAR( ioBase + TC812_WEM, 0xff );
  138. WRITE_PORT_UCHAR( ioBase + TC812_ERM, 0xff );
  139. WRITE_PORT_UCHAR( ioBase + TC812_UOM, 0xff );
  140. }
  141. void VDecoder::VIDEO_SCR_INT_ON( void )
  142. {
  143. UCHAR val;
  144. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  145. val &= 0xfd;
  146. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  147. }
  148. void VDecoder::VIDEO_SCR_INT_OFF( void )
  149. {
  150. UCHAR val;
  151. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  152. val |= 0x02;
  153. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  154. }
  155. void VDecoder::VIDEO_VERR_INT_ON( void )
  156. {
  157. UCHAR val;
  158. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  159. val &= 0xef;
  160. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  161. WRITE_PORT_UCHAR( ioBase + TC812_ERM, 0x00 );
  162. }
  163. void VDecoder::VIDEO_VERR_INT_OFF( void )
  164. {
  165. UCHAR val;
  166. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  167. val |= 0x10;
  168. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  169. WRITE_PORT_UCHAR( ioBase + TC812_ERM, 0x7f );
  170. }
  171. void VDecoder::VIDEO_UFLOW_INT_ON( void )
  172. {
  173. UCHAR val;
  174. val = READ_PORT_UCHAR( ioBase + TC812_UOM );
  175. val &= 0xfe;
  176. WRITE_PORT_UCHAR( ioBase + TC812_UOM, val );
  177. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  178. val &= 0xbf;
  179. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  180. }
  181. void VDecoder::VIDEO_UFLOW_INT_OFF( void )
  182. {
  183. UCHAR val;
  184. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  185. val |= 0x40;
  186. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  187. val = READ_PORT_UCHAR( ioBase + TC812_UOM );
  188. val |= 0x01;
  189. WRITE_PORT_UCHAR( ioBase + TC812_UOM, val );
  190. }
  191. void VDecoder::VIDEO_DECODE_INT_ON( void )
  192. {
  193. UCHAR val;
  194. val = READ_PORT_UCHAR( ioBase + TC812_DEM );
  195. val &= 0xfb;
  196. WRITE_PORT_UCHAR( ioBase + TC812_DEM, val );
  197. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  198. val &= 0xfb;
  199. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  200. }
  201. void VDecoder::VIDEO_DECODE_INT_OFF( void )
  202. {
  203. UCHAR val;
  204. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  205. val |= 0x04;
  206. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  207. val = READ_PORT_UCHAR( ioBase + TC812_DEM );
  208. val |= 0x04;
  209. WRITE_PORT_UCHAR( ioBase + TC812_DEM, val );
  210. }
  211. void VDecoder::VIDEO_USER_INT_ON( void )
  212. {
  213. UCHAR val;
  214. val = READ_PORT_UCHAR( ioBase + TC812_WEM );
  215. val &= 0xfe;
  216. WRITE_PORT_UCHAR( ioBase + TC812_WEM, val );
  217. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  218. val &= 0xf7;
  219. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  220. }
  221. void VDecoder::VIDEO_USER_INT_OFF( void )
  222. {
  223. UCHAR val;
  224. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  225. val |= 0x08;
  226. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  227. val = READ_PORT_UCHAR( ioBase + TC812_WEM );
  228. val |= 0x01;
  229. WRITE_PORT_UCHAR( ioBase + TC812_WEM, val );
  230. }
  231. //--- 97.09.23 K.Chujo
  232. void VDecoder::VIDEO_UDSC_INT_ON( void )
  233. {
  234. // user data start code interrupt on
  235. UCHAR val;
  236. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  237. val &= 0xFE;
  238. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  239. }
  240. void VDecoder::VIDEO_UDSC_INT_OFF( void )
  241. {
  242. // user data start code interrput off
  243. UCHAR val;
  244. val = READ_PORT_UCHAR( ioBase + TC812_IRM );
  245. val |= 0x01;
  246. WRITE_PORT_UCHAR( ioBase + TC812_IRM, val );
  247. }
  248. //--- End.
  249. void VDecoder::VIDEO_ALL_IFLAG_CLEAR( void )
  250. {
  251. UCHAR val;
  252. val = READ_PORT_UCHAR( ioBase + TC812_UOF );
  253. val = READ_PORT_UCHAR( ioBase + TC812_ERF );
  254. val = READ_PORT_UCHAR( ioBase + TC812_WEF );
  255. val = READ_PORT_UCHAR( ioBase + TC812_DEF );
  256. val = READ_PORT_UCHAR( ioBase + TC812_IRF );
  257. }
  258. void VDecoder::VIDEO_SET_STCA( ULONG stca )
  259. {
  260. UCHAR val;
  261. val = (UCHAR)( stca & 0xff );
  262. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, val );
  263. val = (UCHAR)( ( stca >> 8 ) & 0xff );
  264. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, val );
  265. val = (UCHAR)( ( stca >> 16 ) & 0xff );
  266. WRITE_PORT_UCHAR( ioBase + TC812_DATA5, val );
  267. val = (UCHAR)( ( stca >> 24 ) & 0xff );
  268. WRITE_PORT_UCHAR( ioBase + TC812_DATA6, val );
  269. WRITE_PORT_UCHAR( ioBase + TC812_DATA7, 0x00 );
  270. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_STCA );
  271. }
  272. void VDecoder::VIDEO_SET_STCS( ULONG stcs )
  273. {
  274. UCHAR val;
  275. val = (UCHAR)( stcs & 0xff );
  276. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, val );
  277. val = (UCHAR)( ( stcs >> 8 ) & 0xff );
  278. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, val );
  279. val = (UCHAR)( ( stcs >> 16 ) & 0xff );
  280. WRITE_PORT_UCHAR( ioBase + TC812_DATA5, val );
  281. val = (UCHAR)( ( stcs >> 24 ) & 0xff );
  282. WRITE_PORT_UCHAR( ioBase + TC812_DATA6, val );
  283. WRITE_PORT_UCHAR( ioBase + TC812_DATA7, 0x00 );
  284. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_STCS );
  285. }
  286. ULONG VDecoder::VIDEO_GET_STCA( void )
  287. {
  288. ULONG rval = 0, val;
  289. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_STCA );
  290. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  291. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  292. val <<= 8;
  293. rval += val;
  294. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA5 );
  295. val <<= 16;
  296. rval += val;
  297. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA6 );
  298. val <<= 24;
  299. rval += val;
  300. return rval;
  301. }
  302. ULONG VDecoder::VIDEO_GET_STCS( void )
  303. {
  304. ULONG rval = 0, val;
  305. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_STCS );
  306. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  307. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  308. val <<= 8;
  309. rval += val;
  310. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA5 );
  311. val <<= 16;
  312. rval += val;
  313. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA6 );
  314. val <<= 24;
  315. rval += val;
  316. return rval;
  317. }
  318. void VDecoder::VIDEO_SYSTEM_START( void )
  319. {
  320. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x07 ); // video buffer flow control
  321. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_SYS );
  322. }
  323. void VDecoder::VIDEO_SYSTEM_STOP( void )
  324. {
  325. UCHAR val;
  326. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_SYS );
  327. val = READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  328. val &= 0xfe;
  329. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, val );
  330. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_SYS );
  331. }
  332. ULONG VDecoder::VIDEO_GET_STD_CODE( void )
  333. {
  334. ULONG rval, val;
  335. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_STD_CODE );
  336. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  337. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  338. val <<= 8;
  339. rval += val;
  340. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  341. val <<= 16;
  342. rval += val;
  343. rval <<= 2;
  344. return rval;
  345. }
  346. BOOL VDecoder::VIDEO_GET_DECODE_STATE( void )
  347. {
  348. UCHAR val;
  349. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_DECODE );
  350. val = READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  351. if ( ( val & 0x01 ) == 0x01 )
  352. return TRUE; // Decode
  353. else
  354. return FALSE; // Non Decode
  355. }
  356. void VDecoder::VIDEO_DECODE_START( void )
  357. {
  358. UCHAR val;
  359. for ( ; ; )
  360. {
  361. val = READ_PORT_UCHAR( ioBase + TC812_STT2 );
  362. if ( ( val & 0x01 ) != 0x01 )
  363. break;
  364. }
  365. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x05 );
  366. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DECODE );
  367. }
  368. NTSTATUS VDecoder::VIDEO_DECODE_STOP( void )
  369. {
  370. UCHAR val;
  371. val = READ_PORT_UCHAR( ioBase + TC812_STT2 );
  372. if ( ( val & 0x01 ) == 0x01 )
  373. return (NTSTATUS)-1;
  374. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_DECODE );
  375. val = READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  376. val &= 0x0e;
  377. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, val );
  378. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DECODE );
  379. return 0;
  380. }
  381. void VDecoder::VIDEO_STD_CLEAR( void )
  382. {
  383. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_STD_CLEAR );
  384. }
  385. void VDecoder::VIDEO_USER_CLEAR( void )
  386. {
  387. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_USER1_CLEAR );
  388. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_USER2_CLEAR );
  389. }
  390. void VDecoder::VIDEO_PVSIN_ON( void )
  391. {
  392. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x01 );
  393. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_PVSIN );
  394. }
  395. void VDecoder::VIDEO_PVSIN_OFF( void )
  396. {
  397. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  398. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_PVSIN );
  399. }
  400. void VDecoder::VIDEO_SET_DTS( ULONG dts )
  401. {
  402. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, (UCHAR)( dts & 0xff ) );
  403. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, (UCHAR)( ( dts >> 8 ) & 0xff ) );
  404. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, (UCHAR)( ( dts >> 16 ) & 0xff ) );
  405. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, (UCHAR)( ( dts >> 24 ) & 0xff ) );
  406. WRITE_PORT_UCHAR( ioBase + TC812_DATA5, 0 );
  407. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DTS );
  408. }
  409. ULONG VDecoder::VIDEO_GET_DTS( void )
  410. {
  411. ULONG rval, val;
  412. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_DTS );
  413. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  414. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  415. val <<= 8;
  416. rval += val;
  417. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  418. val <<= 16;
  419. rval += val;
  420. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  421. val <<= 24;
  422. rval += val;
  423. return rval;
  424. }
  425. void VDecoder::VIDEO_SET_PTS( ULONG pts )
  426. {
  427. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, (UCHAR)( pts & 0xff ) );
  428. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, (UCHAR)( ( pts >> 8 ) & 0xff ) );
  429. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, (UCHAR)( ( pts >> 16 ) & 0xff ) );
  430. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, (UCHAR)( ( pts >> 24 ) & 0xff ) );
  431. WRITE_PORT_UCHAR( ioBase + TC812_DATA5, 0x00 );
  432. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_PTS );
  433. }
  434. ULONG VDecoder::VIDEO_GET_PTS( void )
  435. {
  436. ULONG rval, val;
  437. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_PTS );
  438. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  439. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  440. val <<= 8;
  441. rval += val;
  442. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  443. val <<= 16;
  444. rval += val;
  445. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  446. val <<= 24;
  447. rval += val;
  448. return rval;
  449. }
  450. ULONG VDecoder::VIDEO_GET_SCR( void )
  451. {
  452. ULONG rval, val;
  453. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_SCR );
  454. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  455. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  456. val <<= 8;
  457. rval += val;
  458. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA5 );
  459. val <<= 16;
  460. rval += val;
  461. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA6 );
  462. val <<= 24;
  463. rval += val;
  464. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_STCR_END );
  465. return rval;
  466. }
  467. ULONG VDecoder::VIDEO_GET_STCC( void )
  468. {
  469. ULONG rval, val;
  470. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_STCC );
  471. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  472. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  473. val <<= 8;
  474. rval += val;
  475. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA5 );
  476. val <<= 16;
  477. rval += val;
  478. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA6 );
  479. val <<= 24;
  480. rval += val;
  481. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_STCR_END );
  482. return rval;
  483. }
  484. void VDecoder::VIDEO_SEEMLESS_ON( void )
  485. {
  486. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x01 );
  487. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_SEEMLES );
  488. }
  489. void VDecoder::VIDEO_SEEMLESS_OFF( void )
  490. {
  491. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  492. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_SEEMLES );
  493. }
  494. void VDecoder::VIDEO_VIDEOCD_OFF( void )
  495. {
  496. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  497. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_VCD );
  498. }
  499. NTSTATUS VDecoder::VIDEO_GET_UDATA( PUCHAR pudata )
  500. {
  501. if ( ( READ_PORT_UCHAR( ioBase + TC812_STT1 ) & 0x80 ) != 0x80 )
  502. return (NTSTATUS)-1; // no user data
  503. *pudata = READ_PORT_UCHAR( ioBase + TC812_UDAT );
  504. return 0;
  505. }
  506. void VDecoder::VIDEO_PLAY_NORMAL( void )
  507. {
  508. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_TRICK_NORMAL );
  509. }
  510. void VDecoder::VIDEO_PLAY_FAST( ULONG flag )
  511. {
  512. if ( flag == FAST_ONLYI )
  513. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  514. else if ( flag == FAST_IANDP )
  515. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x07 );
  516. else
  517. return;
  518. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_TRICK_FAST );
  519. }
  520. void VDecoder::VIDEO_PLAY_SLOW( ULONG speed )
  521. {
  522. if ( speed == 0 || speed > 31 )
  523. return;
  524. speed <<= 2;
  525. speed |= 3;
  526. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, (UCHAR)speed );
  527. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_TRICK_SLOW );
  528. }
  529. void VDecoder::VIDEO_PLAY_FREEZE( void )
  530. {
  531. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  532. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_TRICK_FREEZE );
  533. }
  534. void VDecoder::VIDEO_PLAY_STILL( void )
  535. {
  536. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  537. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_TRICK_STILL );
  538. }
  539. void VDecoder::VIDEO_LBOX_ON( void )
  540. {
  541. UCHAR val;
  542. val = READ_PORT_UCHAR( ioBase + TC812_DSPL );
  543. val &= 0xf7;
  544. val |= 0x10;
  545. WRITE_PORT_UCHAR( ioBase + TC812_DSPL, val );
  546. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x3e );
  547. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  548. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_VOFFSET );
  549. }
  550. void VDecoder::VIDEO_LBOX_OFF( void )
  551. {
  552. UCHAR val;
  553. val = READ_PORT_UCHAR( ioBase + TC812_DSPL );
  554. val |= 0x18;
  555. WRITE_PORT_UCHAR( ioBase + TC812_DSPL, val );
  556. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x04 );
  557. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  558. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_VOFFSET );
  559. }
  560. void VDecoder::VIDEO_PANSCAN_ON( void )
  561. {
  562. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  563. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DMODE );
  564. }
  565. void VDecoder::VIDEO_PANSCAN_OFF( void )
  566. {
  567. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x1b );
  568. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_DMODE );
  569. }
  570. void VDecoder::VIDEO_UFLOW_CURB_ON( void )
  571. {
  572. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  573. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x10 );
  574. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_UF_CURB );
  575. }
  576. void VDecoder::VIDEO_UFLOW_CURB_OFF( void )
  577. {
  578. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  579. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  580. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_UF_CURB );
  581. }
  582. ULONG VDecoder::VIDEO_USER_DWORD( ULONG offset )
  583. {
  584. ULONG rval, val;
  585. for ( ; ; )
  586. {
  587. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_STT2 );
  588. if ( ( val & 0x01 ) != 0x01 )
  589. break;
  590. }
  591. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  592. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, (UCHAR)( offset & 0xff ) );
  593. WRITE_PORT_UCHAR( ioBase + TC812_DATA3, (UCHAR)( ( offset >> 8 ) & 0xff ) );
  594. WRITE_PORT_UCHAR( ioBase + TC812_DATA4, (UCHAR)( ( offset >> 16 ) & 0x07 ) );
  595. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_SET_WRITE_MEM );
  596. for ( ; ; )
  597. {
  598. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_STT2 );
  599. if ( ( val & 0x01 ) != 0x01 )
  600. break;
  601. }
  602. rval = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  603. rval <<= 8;
  604. rval += (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  605. rval <<= 8;
  606. rval += (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  607. rval <<= 8;
  608. rval += (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  609. rval <<= 8;
  610. return rval;
  611. }
  612. void VDecoder::VIDEO_UDAT_CLEAR( void )
  613. {
  614. UCHAR val;
  615. for ( ; ; )
  616. {
  617. val = READ_PORT_UCHAR( ioBase + TC812_STT1 );
  618. if ( ( val & 0x08 ) != 0x08 )
  619. break;
  620. val = READ_PORT_UCHAR( ioBase + TC812_UDAT );
  621. }
  622. }
  623. ULONG VDecoder::VIDEO_GET_TRICK_MODE( void )
  624. {
  625. ULONG val;
  626. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, V_GET_TRICK );
  627. val = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  628. val &= 0x07;
  629. return val;
  630. }
  631. void VDecoder::VIDEO_BUG_PRE_SEARCH_01( void )
  632. {
  633. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x25 );
  634. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  635. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x52 );
  636. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x01 );
  637. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x11 );
  638. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x10 );
  639. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x02 );
  640. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  641. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x00 );
  642. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x5d );
  643. }
  644. void VDecoder::VIDEO_BUG_PRE_SEARCH_02( void )
  645. {
  646. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  647. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x02 );
  648. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x1b );
  649. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x8f );
  650. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  651. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x8f );
  652. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x42 );
  653. }
  654. void VDecoder::VIDEO_BUG_PRE_SEARCH_03( void )
  655. {
  656. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xc1 );
  657. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x01 );
  658. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x52 );
  659. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xb8 );
  660. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x01 );
  661. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x52 );
  662. }
  663. void VDecoder::VIDEO_BUG_PRE_SEARCH_04( void )
  664. {
  665. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x1b );
  666. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x8f );
  667. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x03 );
  668. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x8f );
  669. }
  670. void VDecoder::VIDEO_BUG_PRE_SEARCH_05( void )
  671. {
  672. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  673. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x01 );
  674. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x5d );
  675. }
  676. // NEEDED TO BE DEBUGGED !!!
  677. void VDecoder::VIDEO_BUG_SLIDE_01( void )
  678. {
  679. UCHAR val;
  680. ULONG ul;
  681. // check whether vdec hanged-up
  682. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x7d );
  683. val = READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  684. // if( UF_FLAG == TRUE ) {
  685. // DebugPrint(( DebugLevelTrace, "TOSDVD: DECODER STATUS = %x\r\n", val ));
  686. // }
  687. if ( ( val & 0x30 ) == 0x00 )
  688. {
  689. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x72 );
  690. ul = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  691. ul <<= 8;
  692. ul += (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  693. // if( UF_FLAG == TRUE ) {
  694. // DebugPrint(( DebugLevelTrace, "TOSDVD: DECODER PC(1) = %x\r\n", ul ));
  695. // }
  696. if ( ul == 0x1a5 )
  697. {
  698. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0xb8 );
  699. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x01 );
  700. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x52 );
  701. DebugPrint(( DebugLevelTrace, "TOSDVD: <<RE-ORDER(1)>>\r\n" ));
  702. // uf
  703. } else {
  704. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0xb0 );
  705. ul = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA4 );
  706. ul <<= 8;
  707. val = READ_PORT_UCHAR( ioBase + TC812_DATA3 );
  708. ul += (ULONG)val;
  709. ul <<= 8;
  710. val = READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  711. ul += (ULONG)val;
  712. ul <<= 8;
  713. val = READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  714. ul += (ULONG)val;
  715. // if( UF_FLAG == TRUE ) {
  716. // DebugPrint(( DebugLevelTrace, "TOSDVD: DECODER DTS = %x\r\n", ul ));
  717. // }
  718. if ( ( VIDEO_GET_STCA() - 2 ) > ul )
  719. {
  720. ul = VIDEO_GET_STD_CODE();
  721. // if( UF_FLAG == TRUE ) {
  722. // DebugPrint(( DebugLevelTrace, "TOSDVD: DECODER STD = %x\r\n", ul ));
  723. // }
  724. if ( ul >= 0x200 )
  725. {
  726. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x72 );
  727. ul = (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA2 );
  728. ul <<= 8;
  729. ul += (ULONG)READ_PORT_UCHAR( ioBase + TC812_DATA1 );
  730. // if( UF_FLAG == TRUE ) {
  731. // DebugPrint(( DebugLevelTrace, "TOSDVD: DECODER PC(2) = %x\r\n", ul ));
  732. // }
  733. if ( ul >= 0x404 && ul <= 0x409 )
  734. {
  735. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x18 );
  736. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x04 );
  737. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x52 );
  738. DebugPrint(( DebugLevelTrace, "TOSDVD: <<RE-ORDER(2)>>\r\n" ));
  739. // uf
  740. }
  741. }
  742. }
  743. }
  744. }
  745. WRITE_PORT_UCHAR( ioBase + TC812_DATA1, 0x00 );
  746. WRITE_PORT_UCHAR( ioBase + TC812_DATA2, 0x01 );
  747. WRITE_PORT_UCHAR( ioBase + TC812_CMDR1, 0x5d );
  748. }
  749. //
  750. //void VDecoder::VIDEO_DEBUG_SET_UF( void )
  751. //{
  752. // UF_FLAG = TRUE;
  753. //}
  754. //
  755. //void VDecoder::VIDEO_DEBUG_CLR_UF( void )
  756. //{
  757. // UF_FLAG = FALSE;
  758. //}