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.

851 lines
18 KiB

  1. //***************************************************************************
  2. // Audio decoder process
  3. //
  4. //***************************************************************************
  5. #include "common.h"
  6. #include "regs.h"
  7. #include "cadec.h"
  8. #include "zrnpch6.h"
  9. #include "cdack.h"
  10. void ADecoder::init( const PDEVICE_INIT_INFO pDevInit )
  11. {
  12. ioBase = pDevInit->ioBase;
  13. // shoud be remove when release
  14. // ASSERT( sizeof(ZRN_AC3_DEC) == 3891 );
  15. // ASSERT( sizeof(ZRN_AC3_SPD) == 410 );
  16. // ASSERT( sizeof(ZRN_PCM) == 6965 );
  17. }
  18. void ADecoder::SetParam( ULONG aMode, ULONG aFreq, ULONG aType, BOOL aCgms, Dack *pDak )
  19. {
  20. AudioMode = aMode;
  21. AudioFreq = aFreq;
  22. AudioType = aType;
  23. AudioCgms = ( 0<=aCgms && aCgms<=3 ) ? aCgms : 3;
  24. pDack = pDak;
  25. }
  26. // ***************************************************************************
  27. // T C 6 8 0 0 A F
  28. // ***************************************************************************
  29. void ADecoder::AUDIO_TC6800_INIT_PCM()
  30. {
  31. pDack->PCIF_CHECK_SERIAL();
  32. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  33. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0xa0 );
  34. pDack->PCIF_CHECK_SERIAL();
  35. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  36. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x80 );
  37. }
  38. void ADecoder::AUDIO_TC6800_INIT_AC3()
  39. {
  40. pDack->PCIF_CHECK_SERIAL();
  41. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  42. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x20 );
  43. pDack->PCIF_CHECK_SERIAL();
  44. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  45. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  46. }
  47. void ADecoder::AUDIO_TC6800_INIT_MPEG()
  48. {
  49. pDack->PCIF_CHECK_SERIAL();
  50. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  51. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x20 );
  52. pDack->PCIF_CHECK_SERIAL();
  53. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  54. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  55. }
  56. void ADecoder::AUDIO_TC6800_DATA_OFF()
  57. {
  58. pDack->PCIF_CHECK_SERIAL();
  59. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x66 );
  60. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x60 );
  61. }
  62. // ***************************************************************************
  63. // Z R 3 8 5 2 1
  64. // ***************************************************************************
  65. void ADecoder::AUDIO_ZR385_OUT( UCHAR val )
  66. {
  67. pDack->PCIF_CHECK_SERIAL();
  68. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x08 );
  69. WRITE_PORT_UCHAR( ioBase + PCIF_SW, val );
  70. // necessary?
  71. pDack->PCIF_CHECK_SERIAL();
  72. }
  73. void ADecoder::AUDIO_ZR385_DOWNLOAD( PUCHAR pData, ULONG size )
  74. {
  75. ULONG i;
  76. for( i = 0; i < size; i++ )
  77. AUDIO_ZR385_OUT( *pData++ );
  78. }
  79. void ADecoder::AUDIO_ZR38521_BOOT_AC3()
  80. {
  81. AUDIO_ZR385_DOWNLOAD( ZRN_AC3_DEC, sizeof(ZRN_AC3_DEC) );
  82. if( AudioType == AUDIO_OUT_DIGITAL )
  83. AUDIO_ZR385_DOWNLOAD( ZRN_AC3_SPD, sizeof(ZRN_AC3_SPD) );
  84. }
  85. void ADecoder::AUDIO_ZR38521_BOOT_MPEG()
  86. {
  87. // not support!
  88. }
  89. void ADecoder::AUDIO_ZR38521_BOOT_PCM()
  90. {
  91. AUDIO_ZR385_DOWNLOAD( ZRN_PCM, sizeof(ZRN_PCM) );
  92. }
  93. NTSTATUS ADecoder::AUDIO_ZR38521_CFG()
  94. {
  95. UCHAR val;
  96. pDack->PCIF_CHECK_SERIAL();
  97. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  98. if( val != 0x80 )
  99. return STATUS_UNSUCCESSFUL;
  100. AUDIO_ZR385_OUT( 0x82 );
  101. AUDIO_ZR385_OUT( 0x50 );
  102. AUDIO_ZR385_OUT( 0x40 );
  103. AUDIO_ZR385_OUT( 0x09 );
  104. AUDIO_ZR385_OUT( 0x09 );
  105. if( AudioType == AUDIO_OUT_DIGITAL )
  106. AUDIO_ZR385_OUT( 0x70 );
  107. else
  108. AUDIO_ZR385_OUT( 0x50 );
  109. AUDIO_ZR385_OUT( 0x02 );
  110. AUDIO_ZR385_OUT( 0x02 );
  111. AUDIO_ZR385_OUT( 0x04 );
  112. AUDIO_ZR385_OUT( 0x00 );
  113. AUDIO_ZR385_OUT( 0x00 );
  114. AUDIO_ZR385_OUT( 0x00 );
  115. return STATUS_SUCCESS;
  116. }
  117. NTSTATUS ADecoder::AUDIO_ZR38521_PCMX()
  118. {
  119. UCHAR val;
  120. pDack->PCIF_CHECK_SERIAL();
  121. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  122. if( val != 0x80 )
  123. return STATUS_UNSUCCESSFUL;
  124. AUDIO_ZR385_OUT( 0x88 );
  125. AUDIO_ZR385_OUT( 0x81 );
  126. AUDIO_ZR385_OUT( 0x82 );
  127. AUDIO_ZR385_OUT( 0x7f );
  128. AUDIO_ZR385_OUT( 0xff );
  129. AUDIO_ZR385_OUT( 0x01 );
  130. AUDIO_ZR385_OUT( 0x00 );
  131. AUDIO_ZR385_OUT( 0x00 );
  132. AUDIO_ZR385_OUT( 0x00 );
  133. AUDIO_ZR385_OUT( 0x00 );
  134. AUDIO_ZR385_OUT( 0x00 );
  135. AUDIO_ZR385_OUT( 0x00 );
  136. return STATUS_SUCCESS;
  137. }
  138. NTSTATUS ADecoder::AUDIO_ZR38521_AC3()
  139. {
  140. UCHAR val;
  141. pDack->PCIF_CHECK_SERIAL();
  142. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  143. if( val != 0x80 )
  144. return STATUS_UNSUCCESSFUL;
  145. AUDIO_ZR385_OUT( 0x85 );
  146. AUDIO_ZR385_OUT( 0x08 );
  147. AUDIO_ZR385_OUT( 0x00 );
  148. AUDIO_ZR385_OUT( 0x00 );
  149. AUDIO_ZR385_OUT( 0x7f );
  150. AUDIO_ZR385_OUT( 0x7f );
  151. AUDIO_ZR385_OUT( 0x11 );
  152. AUDIO_ZR385_OUT( 0x7f );
  153. AUDIO_ZR385_OUT( 0xff );
  154. AUDIO_ZR385_OUT( 0x00 );
  155. AUDIO_ZR385_OUT( 0x00 );
  156. AUDIO_ZR385_OUT( 0x00 );
  157. return STATUS_SUCCESS;
  158. }
  159. NTSTATUS ADecoder::AUDIO_ZR38521_MPEG1()
  160. {
  161. UCHAR val;
  162. pDack->PCIF_CHECK_SERIAL();
  163. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  164. if( val != 0x80 )
  165. return STATUS_UNSUCCESSFUL;
  166. AUDIO_ZR385_OUT( 0x87 );
  167. AUDIO_ZR385_OUT( 0x00 );
  168. AUDIO_ZR385_OUT( 0x7f );
  169. AUDIO_ZR385_OUT( 0xff );
  170. AUDIO_ZR385_OUT( 0x00 );
  171. AUDIO_ZR385_OUT( 0x00 );
  172. AUDIO_ZR385_OUT( 0x00 );
  173. return STATUS_SUCCESS;
  174. }
  175. NTSTATUS ADecoder::AUDIO_ZR38521_PLAY()
  176. {
  177. UCHAR val;
  178. pDack->PCIF_CHECK_SERIAL();
  179. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  180. if( val != 0x80 )
  181. return STATUS_UNSUCCESSFUL;
  182. AUDIO_ZR385_OUT( 0x8a );
  183. AUDIO_ZR385_OUT( 0x00 );
  184. AUDIO_ZR385_OUT( 0x00 );
  185. AUDIO_ZR385_OUT( 0x00 );
  186. return STATUS_SUCCESS;
  187. }
  188. NTSTATUS ADecoder::AUDIO_ZR38521_MUTE_OFF()
  189. {
  190. UCHAR val;
  191. pDack->PCIF_CHECK_SERIAL();
  192. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  193. if( val != 0x80 )
  194. return STATUS_UNSUCCESSFUL;
  195. AUDIO_ZR385_OUT( 0x89 );
  196. AUDIO_ZR385_OUT( 0x00 );
  197. AUDIO_ZR385_OUT( 0x00 );
  198. AUDIO_ZR385_OUT( 0x00 );
  199. return STATUS_SUCCESS;
  200. }
  201. NTSTATUS ADecoder::AUDIO_ZR38521_MUTE_ON()
  202. {
  203. UCHAR val;
  204. pDack->PCIF_CHECK_SERIAL();
  205. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  206. if( val != 0x80 )
  207. return STATUS_UNSUCCESSFUL;
  208. AUDIO_ZR385_OUT( 0x8b );
  209. AUDIO_ZR385_OUT( 0x00 );
  210. AUDIO_ZR385_OUT( 0x00 );
  211. AUDIO_ZR385_OUT( 0x00 );
  212. return STATUS_SUCCESS;
  213. }
  214. NTSTATUS ADecoder::AUDIO_ZR38521_STOP()
  215. {
  216. UCHAR val;
  217. pDack->PCIF_CHECK_SERIAL();
  218. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  219. if( val != 0x80 )
  220. return STATUS_UNSUCCESSFUL;
  221. AUDIO_ZR385_OUT( 0x8c );
  222. AUDIO_ZR385_OUT( 0x00 );
  223. AUDIO_ZR385_OUT( 0x00 );
  224. AUDIO_ZR385_OUT( 0x00 );
  225. return STATUS_SUCCESS;
  226. }
  227. NTSTATUS ADecoder::AUDIO_ZR38521_STOPF()
  228. {
  229. UCHAR val;
  230. pDack->PCIF_CHECK_SERIAL();
  231. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  232. if( val != 0x80 )
  233. return STATUS_UNSUCCESSFUL;
  234. AUDIO_ZR385_OUT( 0x8d );
  235. AUDIO_ZR385_OUT( 0x00 );
  236. AUDIO_ZR385_OUT( 0x00 );
  237. AUDIO_ZR385_OUT( 0x00 );
  238. return STATUS_SUCCESS;
  239. }
  240. NTSTATUS ADecoder::AUDIO_ZR38521_STCR()
  241. {
  242. UCHAR val;
  243. pDack->PCIF_CHECK_SERIAL();
  244. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  245. if( val != 0x80 )
  246. return STATUS_UNSUCCESSFUL;
  247. AUDIO_ZR385_OUT( 0x94 );
  248. AUDIO_ZR385_OUT( 0x0d );
  249. AUDIO_ZR385_OUT( 0x03 );
  250. AUDIO_ZR385_OUT( 0xf6 );
  251. AUDIO_ZR385_OUT( 0x00 );
  252. AUDIO_ZR385_OUT( 0x00 );
  253. AUDIO_ZR385_OUT( 0x00 );
  254. AUDIO_ZR385_OUT( 0x01 );
  255. AUDIO_ZR385_OUT( 0x00 );
  256. AUDIO_ZR385_OUT( 0x00 );
  257. AUDIO_ZR385_OUT( 0x00 );
  258. AUDIO_ZR385_OUT( 0x00 );
  259. AUDIO_ZR385_OUT( 0x00 );
  260. AUDIO_ZR385_OUT( 0x00 );
  261. AUDIO_ZR385_OUT( 0x00 );
  262. return STATUS_SUCCESS;
  263. }
  264. NTSTATUS ADecoder::AUDIO_ZR38521_VDSCR_ON( ULONG stc )
  265. {
  266. UCHAR val;
  267. pDack->PCIF_CHECK_SERIAL();
  268. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  269. if( val != 0x80 )
  270. return STATUS_UNSUCCESSFUL;
  271. AUDIO_ZR385_OUT( 0x93 );
  272. AUDIO_ZR385_OUT( 0x0d );
  273. AUDIO_ZR385_OUT( 0x03 );
  274. AUDIO_ZR385_OUT( 0xf4 );
  275. AUDIO_ZR385_OUT( 0x00 );
  276. AUDIO_ZR385_OUT( 0x00 );
  277. AUDIO_ZR385_OUT( 0x00 );
  278. AUDIO_ZR385_OUT( 0x02 );
  279. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 25 ) & 0xff ) );
  280. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 17 ) & 0xff ) );
  281. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 9 ) & 0xff ) );
  282. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 1 ) & 0xff ) );
  283. AUDIO_ZR385_OUT( 0x00 );
  284. AUDIO_ZR385_OUT( 0xfb );
  285. AUDIO_ZR385_OUT( 0xc8 );
  286. AUDIO_ZR385_OUT( 0x00 );
  287. AUDIO_ZR385_OUT( 0x00 );
  288. AUDIO_ZR385_OUT( 0x00 );
  289. AUDIO_ZR385_OUT( 0x00 );
  290. return STATUS_SUCCESS;
  291. }
  292. NTSTATUS ADecoder::AUDIO_ZR38521_VDSCR_OFF( ULONG stc )
  293. {
  294. UCHAR val;
  295. pDack->PCIF_CHECK_SERIAL();
  296. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  297. if( val != 0x80 )
  298. return STATUS_UNSUCCESSFUL;
  299. AUDIO_ZR385_OUT( 0x93 );
  300. AUDIO_ZR385_OUT( 0x0d );
  301. AUDIO_ZR385_OUT( 0x03 );
  302. AUDIO_ZR385_OUT( 0xf4 );
  303. AUDIO_ZR385_OUT( 0x00 );
  304. AUDIO_ZR385_OUT( 0x00 );
  305. AUDIO_ZR385_OUT( 0x00 );
  306. AUDIO_ZR385_OUT( 0x02 );
  307. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 25 ) & 0xff ) );
  308. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 17 ) & 0xff ) );
  309. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 9 ) & 0xff ) );
  310. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 1 ) & 0xff ) );
  311. AUDIO_ZR385_OUT( 0x00 );
  312. AUDIO_ZR385_OUT( 0xfb );
  313. AUDIO_ZR385_OUT( 0xc8 );
  314. AUDIO_ZR385_OUT( 0x80 );
  315. AUDIO_ZR385_OUT( 0x00 );
  316. AUDIO_ZR385_OUT( 0x00 );
  317. AUDIO_ZR385_OUT( 0x00 );
  318. return STATUS_SUCCESS;
  319. }
  320. NTSTATUS ADecoder::AUDIO_ZR38521_AVSYNC_OFF( ULONG stc )
  321. {
  322. UCHAR val;
  323. pDack->PCIF_CHECK_SERIAL();
  324. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  325. if( val != 0x80 )
  326. return STATUS_UNSUCCESSFUL;
  327. AUDIO_ZR385_OUT( 0x93 );
  328. AUDIO_ZR385_OUT( 0x0d );
  329. AUDIO_ZR385_OUT( 0x03 );
  330. AUDIO_ZR385_OUT( 0xf4 );
  331. AUDIO_ZR385_OUT( 0x00 );
  332. AUDIO_ZR385_OUT( 0x00 );
  333. AUDIO_ZR385_OUT( 0x00 );
  334. AUDIO_ZR385_OUT( 0x02 );
  335. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 25 ) & 0xff ) );
  336. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 17 ) & 0xff ) );
  337. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 9 ) & 0xff ) );
  338. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 1 ) & 0xff ) );
  339. AUDIO_ZR385_OUT( 0x00 );
  340. AUDIO_ZR385_OUT( 0xfb );
  341. AUDIO_ZR385_OUT( 0xc8 );
  342. AUDIO_ZR385_OUT( 0xc0 );
  343. AUDIO_ZR385_OUT( 0x00 );
  344. AUDIO_ZR385_OUT( 0x00 );
  345. AUDIO_ZR385_OUT( 0x00 );
  346. return STATUS_SUCCESS;
  347. }
  348. NTSTATUS ADecoder::AUDIO_ZR38521_AVSYNC_ON( ULONG stc )
  349. {
  350. UCHAR val;
  351. pDack->PCIF_CHECK_SERIAL();
  352. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  353. if( val != 0x80 )
  354. return STATUS_UNSUCCESSFUL;
  355. AUDIO_ZR385_OUT( 0x93 );
  356. AUDIO_ZR385_OUT( 0x0d );
  357. AUDIO_ZR385_OUT( 0x03 );
  358. AUDIO_ZR385_OUT( 0xf4 );
  359. AUDIO_ZR385_OUT( 0x00 );
  360. AUDIO_ZR385_OUT( 0x00 );
  361. AUDIO_ZR385_OUT( 0x00 );
  362. AUDIO_ZR385_OUT( 0x02 );
  363. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 25 ) & 0xff ) );
  364. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 17 ) & 0xff ) );
  365. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 9 ) & 0xff ) );
  366. AUDIO_ZR385_OUT( (UCHAR)( ( stc >> 1 ) & 0xff ) );
  367. AUDIO_ZR385_OUT( 0x00 );
  368. AUDIO_ZR385_OUT( 0xfb );
  369. AUDIO_ZR385_OUT( 0xc8 );
  370. AUDIO_ZR385_OUT( 0x40 );
  371. AUDIO_ZR385_OUT( 0x00 );
  372. AUDIO_ZR385_OUT( 0x00 );
  373. AUDIO_ZR385_OUT( 0x00 );
  374. return STATUS_SUCCESS;
  375. }
  376. NTSTATUS ADecoder::AUDIO_ZR38521_STAT( PULONG pDiff )
  377. {
  378. UCHAR val;
  379. if( pDiff == NULL )
  380. return STATUS_UNSUCCESSFUL;
  381. pDack->PCIF_CHECK_SERIAL();
  382. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  383. if( val != 0x80 ) {
  384. *pDiff = 0x0908;
  385. return STATUS_UNSUCCESSFUL;
  386. }
  387. *pDiff = 0;
  388. AUDIO_ZR385_OUT( 0x8e );
  389. AUDIO_ZR385_OUT( 0x00 );
  390. AUDIO_ZR385_OUT( 0x00 );
  391. AUDIO_ZR385_OUT( 0x00 );
  392. AUDIO_ZR385_OUT( 0x00 );
  393. AUDIO_ZR385_OUT( 0x00 );
  394. AUDIO_ZR385_OUT( 0x00 );
  395. AUDIO_ZR385_OUT( 0x00 );
  396. // Check DIFTH
  397. pDack->PCIF_CHECK_SERIAL();
  398. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  399. *pDiff |= (ULONG)val << 8;
  400. AUDIO_ZR385_OUT( 0x00 );
  401. // Check DIFTL
  402. pDack->PCIF_CHECK_SERIAL();
  403. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  404. *pDiff |= val & 0xff;
  405. AUDIO_ZR385_OUT( 0x00 );
  406. AUDIO_ZR385_OUT( 0x00 );
  407. AUDIO_ZR385_OUT( 0x00 );
  408. AUDIO_ZR385_OUT( 0x00 );
  409. AUDIO_ZR385_OUT( 0x00 );
  410. AUDIO_ZR385_OUT( 0x00 );
  411. AUDIO_ZR385_OUT( 0x00 );
  412. AUDIO_ZR385_OUT( 0x00 );
  413. AUDIO_ZR385_OUT( 0x00 );
  414. AUDIO_ZR385_OUT( 0x00 );
  415. AUDIO_ZR385_OUT( 0x00 );
  416. return STATUS_SUCCESS;
  417. }
  418. NTSTATUS ADecoder::AUDIO_ZR38521_KCOEF()
  419. {
  420. UCHAR val;
  421. pDack->PCIF_CHECK_SERIAL();
  422. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  423. if( val != 0x80 )
  424. return STATUS_UNSUCCESSFUL;
  425. AUDIO_ZR385_OUT( 0x93 );
  426. AUDIO_ZR385_OUT( 0x0d );
  427. AUDIO_ZR385_OUT( 0x03 );
  428. AUDIO_ZR385_OUT( 0xf0 );
  429. AUDIO_ZR385_OUT( 0x00 );
  430. AUDIO_ZR385_OUT( 0x00 );
  431. AUDIO_ZR385_OUT( 0x00 );
  432. AUDIO_ZR385_OUT( 0x03 );
  433. AUDIO_ZR385_OUT( 0x7f );
  434. AUDIO_ZR385_OUT( 0x00 );
  435. AUDIO_ZR385_OUT( 0x00 );
  436. AUDIO_ZR385_OUT( 0x59 );
  437. AUDIO_ZR385_OUT( 0x00 );
  438. AUDIO_ZR385_OUT( 0x00 );
  439. AUDIO_ZR385_OUT( 0x00 );
  440. AUDIO_ZR385_OUT( 0x7f );
  441. AUDIO_ZR385_OUT( 0x00 );
  442. AUDIO_ZR385_OUT( 0x00 );
  443. AUDIO_ZR385_OUT( 0x59 );
  444. AUDIO_ZR385_OUT( 0x00 );
  445. AUDIO_ZR385_OUT( 0x00 );
  446. AUDIO_ZR385_OUT( 0x00 );
  447. AUDIO_ZR385_OUT( 0x00 );
  448. return STATUS_SUCCESS;
  449. }
  450. void ADecoder::AUDIO_ZR38521_REPEAT_02()
  451. {
  452. AUDIO_ZR385_OUT( 0x93 );
  453. AUDIO_ZR385_OUT( 0x0d );
  454. AUDIO_ZR385_OUT( 0x01 );
  455. AUDIO_ZR385_OUT( 0xc3 );
  456. AUDIO_ZR385_OUT( 0x00 );
  457. AUDIO_ZR385_OUT( 0x00 );
  458. AUDIO_ZR385_OUT( 0x00 );
  459. AUDIO_ZR385_OUT( 0x01 );
  460. AUDIO_ZR385_OUT( 0x13 );
  461. AUDIO_ZR385_OUT( 0xfb );
  462. AUDIO_ZR385_OUT( 0xd0 );
  463. AUDIO_ZR385_OUT( 0x44 );
  464. AUDIO_ZR385_OUT( 0x00 );
  465. AUDIO_ZR385_OUT( 0x00 );
  466. AUDIO_ZR385_OUT( 0x00 );
  467. }
  468. void ADecoder::AUDIO_ZR38521_REPEAT_16()
  469. {
  470. AUDIO_ZR385_OUT( 0x93 );
  471. AUDIO_ZR385_OUT( 0x0d );
  472. AUDIO_ZR385_OUT( 0x01 );
  473. AUDIO_ZR385_OUT( 0xc3 );
  474. AUDIO_ZR385_OUT( 0x00 );
  475. AUDIO_ZR385_OUT( 0x00 );
  476. AUDIO_ZR385_OUT( 0x00 );
  477. AUDIO_ZR385_OUT( 0x01 );
  478. AUDIO_ZR385_OUT( 0x13 );
  479. AUDIO_ZR385_OUT( 0xfb );
  480. AUDIO_ZR385_OUT( 0xd3 );
  481. AUDIO_ZR385_OUT( 0xc4 );
  482. AUDIO_ZR385_OUT( 0x00 );
  483. AUDIO_ZR385_OUT( 0x00 );
  484. AUDIO_ZR385_OUT( 0x00 );
  485. }
  486. NTSTATUS ADecoder::AUDIO_ZR38521_BFST( PULONG pErrCode )
  487. {
  488. UCHAR val;
  489. if( pErrCode == NULL )
  490. return STATUS_UNSUCCESSFUL;
  491. pDack->PCIF_CHECK_SERIAL();
  492. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  493. if( val != 0x80 ) {
  494. *pErrCode = 0x0908;
  495. return STATUS_UNSUCCESSFUL;
  496. }
  497. *pErrCode = 0;
  498. AUDIO_ZR385_OUT( 0x8e );
  499. AUDIO_ZR385_OUT( 0x00 );
  500. AUDIO_ZR385_OUT( 0x00 );
  501. AUDIO_ZR385_OUT( 0x00 );
  502. AUDIO_ZR385_OUT( 0x00 );
  503. // Check IST
  504. pDack->PCIF_CHECK_SERIAL();
  505. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  506. val &= 0x07;
  507. *pErrCode |= (ULONG)val << 8;
  508. AUDIO_ZR385_OUT( 0x00 );
  509. // Check BFST
  510. pDack->PCIF_CHECK_SERIAL();
  511. val = READ_PORT_UCHAR( ioBase + PCIF_SR );
  512. val &= 0x07;
  513. *pErrCode |= val;
  514. AUDIO_ZR385_OUT( 0x00 );
  515. AUDIO_ZR385_OUT( 0x00 );
  516. AUDIO_ZR385_OUT( 0x00 );
  517. AUDIO_ZR385_OUT( 0x00 );
  518. AUDIO_ZR385_OUT( 0x00 );
  519. AUDIO_ZR385_OUT( 0x00 );
  520. AUDIO_ZR385_OUT( 0x00 );
  521. AUDIO_ZR385_OUT( 0x00 );
  522. AUDIO_ZR385_OUT( 0x00 );
  523. AUDIO_ZR385_OUT( 0x00 );
  524. AUDIO_ZR385_OUT( 0x00 );
  525. AUDIO_ZR385_OUT( 0x00 );
  526. AUDIO_ZR385_OUT( 0x00 );
  527. AUDIO_ZR385_OUT( 0x00 );
  528. return STATUS_SUCCESS;
  529. }
  530. // ***************************************************************************
  531. // T C 9 4 2 5 F
  532. // ***************************************************************************
  533. void ADecoder::AUDIO_TC9425_INIT_DIGITAL()
  534. {
  535. UCHAR val;
  536. val = 0;
  537. if( AudioType != AUDIO_OUT_ANALOG )
  538. if( AudioMode == AUDIO_TYPE_AC3 )
  539. val |= 0x40;
  540. if( (AudioCgms & 0x02) == 0x00 ) {
  541. val |= 0x20; // Copying is permitted without restriction
  542. DebugPrint( ( DebugLevelTrace, "TOSDVD: AUDIO Copy OK\r\n" ) );
  543. }
  544. else {
  545. val &= 0xDF; // Basically no copying is permitted (depend on L-Bit below)
  546. DebugPrint( ( DebugLevelTrace, "TOSDVD: AUDIO Copy NG\r\n" ) );
  547. }
  548. // COPY, EMPH
  549. pDack->PCIF_CHECK_SERIAL();
  550. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  551. WRITE_PORT_UCHAR( ioBase + PCIF_SW, val );
  552. if( (AudioCgms & 0x01) == 0x00 ) {
  553. val = 0x98; // L-Bit==0; One generation of copies may be made
  554. DebugPrint( ( DebugLevelTrace, "TOSDVD: AUDIO 1 Time Copy OK\r\n" ) );
  555. }
  556. else {
  557. val = 0x99; // L-Bit==1; No copying is permitted
  558. DebugPrint( ( DebugLevelTrace, "TOSDVD: AUDIO 1 Time Copy NG\r\n" ) );
  559. }
  560. // Category Code, LBIT
  561. pDack->PCIF_CHECK_SERIAL();
  562. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  563. WRITE_PORT_UCHAR( ioBase + PCIF_SW, val );
  564. // Channel Num
  565. pDack->PCIF_CHECK_SERIAL();
  566. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  567. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  568. if( AudioFreq == AUDIO_FS_32 )
  569. val = 0xc0;
  570. else if( AudioFreq == AUDIO_FS_44 )
  571. val = 0x00;
  572. else if( AudioFreq == AUDIO_FS_48 )
  573. val = 0x40;
  574. else
  575. val = 0x40;
  576. // FS1, FS2, CKA1, CKA2
  577. pDack->PCIF_CHECK_SERIAL();
  578. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  579. WRITE_PORT_UCHAR( ioBase + PCIF_SW, val );
  580. pDack->PCIF_CHECK_SERIAL();
  581. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x72 );
  582. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  583. }
  584. void ADecoder::AUDIO_TC9425_INIT_ANALOG()
  585. {
  586. UCHAR val;
  587. pDack->PCIF_CHECK_SERIAL();
  588. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  589. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  590. pDack->PCIF_CHECK_SERIAL();
  591. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  592. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  593. pDack->PCIF_CHECK_SERIAL();
  594. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  595. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  596. // MONO, CHS, EM, EMP
  597. pDack->PCIF_CHECK_SERIAL();
  598. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  599. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  600. pDack->PCIF_CHECK_SERIAL();
  601. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x72 );
  602. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0xc0 );
  603. //
  604. pDack->PCIF_CHECK_SERIAL();
  605. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  606. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  607. pDack->PCIF_CHECK_SERIAL();
  608. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  609. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  610. pDack->PCIF_CHECK_SERIAL();
  611. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  612. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  613. if( AudioType == AUDIO_OUT_DIGITAL )
  614. val = 0x79;
  615. else
  616. val = 0x69;
  617. if( AudioFreq == AUDIO_FS_96 )
  618. val |= 0x04;
  619. else if( AudioFreq == AUDIO_FS_48 )
  620. val |= 0x04;
  621. // BIT, DOIN, DOSEL, IFSEL, RLS
  622. pDack->PCIF_CHECK_SERIAL();
  623. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  624. WRITE_PORT_UCHAR( ioBase + PCIF_SW, val );
  625. pDack->PCIF_CHECK_SERIAL();
  626. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x72 );
  627. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0xc0 );
  628. AUDIO_TC9425_SET_VOLUME( AudioVolume );
  629. }
  630. void ADecoder::AUDIO_TC9425_SET_VOLUME( ULONG vol )
  631. {
  632. UCHAR ucvol;
  633. AudioVolume = vol;
  634. pDack->PCIF_CHECK_SERIAL();
  635. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  636. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  637. pDack->PCIF_CHECK_SERIAL();
  638. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  639. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  640. pDack->PCIF_CHECK_SERIAL();
  641. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  642. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x00 );
  643. ucvol = (UCHAR)vol;
  644. ucvol = INVERSE_BYTE( ucvol );
  645. ucvol = (UCHAR)( ucvol >> 1 );
  646. pDack->PCIF_CHECK_SERIAL();
  647. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x38 );
  648. WRITE_PORT_UCHAR( ioBase + PCIF_SW, ucvol );
  649. pDack->PCIF_CHECK_SERIAL();
  650. WRITE_PORT_UCHAR( ioBase + PCIF_SCNT, 0x72 );
  651. WRITE_PORT_UCHAR( ioBase + PCIF_SW, 0x40 );
  652. }
  653. UCHAR ADecoder::INVERSE_BYTE( UCHAR uc )
  654. {
  655. ULONG i;
  656. UCHAR retch = 0;
  657. for( i = 0; i < 8; i++ )
  658. retch |= ( uc & 0x01 ) << ( 7 - i );
  659. return retch;
  660. }