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.

849 lines
18 KiB

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