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.

442 lines
20 KiB

  1. //
  2. // MODULE : ZAC3.C
  3. // PURPOSE : Zoran AC3 specific code
  4. // AUTHOR : JBS Yadawa
  5. // CREATED : 7/20/96
  6. //
  7. //
  8. // Copyright (C) 1996 SGS-THOMSON Microelectronics
  9. //
  10. //
  11. // REVISION HISTORY :
  12. //
  13. // DATE :
  14. //
  15. // COMMENTS :
  16. //
  17. #include "common.h"
  18. #include "strmini.h"
  19. #include "stdefs.h"
  20. #include "board.h"
  21. #include "debug.h"
  22. #include "i20reg.h"
  23. #include "bt856.h"
  24. #include "memio.h"
  25. #include "zac3.h"
  26. #include "sti3520a.h" //ckw
  27. #define POSTOFFICEREG 0x200
  28. #define SPIDO 0x07 //ckw
  29. #define SPIDI 0x06 //ckw
  30. #define SPICLK 0x05
  31. #define SPIENA 0x04
  32. #define PARAMSIZE 9
  33. static void NEARAPI SPIStart(void);
  34. static void NEARAPI SPIStop(void);
  35. static BYTE NEARAPI SPISendByte(BYTE data);
  36. BYTE CfgParams[PARAMSIZE] = {AC3_CFG, 0xD0,0x08,0x89,0x09,0x14,0x02,0x02,0x06}; //ckw
  37. BYTE AC3Params[PARAMSIZE] = {AC3_AC3, 0x10,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF}; //ckw
  38. #define NUMCODE 2501
  39. BYTE AC3MCode[NUMCODE] = {
  40. 0x90, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x02, 0x56, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  41. 0xB8, 0x0C, 0x00, 0x00, 0xB0, 0x3C, 0x38, 0x0D, 0x00, 0x5D, 0x32, 0x10, 0x0F, 0xF5, 0x3B,
  42. 0x80, 0x00, 0x00, 0x34, 0x3D, 0x03, 0xFB, 0x00, 0x03, 0xCD, 0x82, 0x38, 0x8D, 0x00, 0x00,
  43. 0x3A, 0x80, 0x02, 0x52, 0x3A, 0xAD, 0x00, 0x0C, 0x00, 0x03, 0xF0, 0x85, 0x1B, 0x5B, 0xCD,
  44. 0x86, 0x1B, 0x93, 0xF0, 0x85, 0x3B, 0x80, 0x00, 0x01, 0x36, 0xDE, 0x00, 0x42, 0x00, 0x03,
  45. 0xC0, 0xB6, 0x30, 0x3D, 0x03, 0xFB, 0x34, 0x30, 0x0F, 0x8D, 0x2E, 0xCF, 0xFF, 0xFF, 0x3C,
  46. 0x3D, 0x00, 0x17, 0x30, 0x30, 0x0F, 0x8D, 0x00, 0x03, 0xEC, 0x32, 0x00, 0x00, 0xB0, 0x3C,
  47. 0x00, 0x03, 0xF0, 0x2B, 0x00, 0x03, 0xF0, 0x2D, 0x3B, 0x80, 0x00, 0x01, 0x34, 0x30, 0x0F,
  48. 0xCC, 0x34, 0x3D, 0x03, 0xF6, 0x2E, 0xCF, 0xFF, 0xFF, 0x3C, 0x3D, 0x00, 0x43, 0x30, 0x3D,
  49. 0x03, 0xF6, 0xB9, 0x20, 0x00, 0x00, 0x3A, 0xDD, 0x00, 0x43, 0x38, 0x3D, 0x00, 0x23, 0x30,
  50. 0x30, 0x0F, 0xF9, 0x38, 0x4F, 0x87, 0x20, 0x3A, 0xDD, 0x00, 0x43, 0x38, 0x3D, 0x00, 0x27,
  51. 0x30, 0x30, 0x0F, 0xF9, 0x38, 0x44, 0xE1, 0xF0, 0x3A, 0xDD, 0x00, 0x43, 0x38, 0x3D, 0x00,
  52. 0x2B, 0x30, 0x30, 0x0F, 0xF9, 0x34, 0x4D, 0x03, 0xDD, 0x3A, 0xDD, 0x00, 0x43, 0x38, 0x3D,
  53. 0x00, 0x2F, 0x30, 0x30, 0x0F, 0xF9, 0x00, 0x03, 0xEB, 0x01, 0x3B, 0x50, 0x00, 0x00, 0x34,
  54. 0x4D, 0x03, 0xDE, 0x30, 0x4D, 0x03, 0xF6, 0x2F, 0x30, 0x00, 0x08, 0x3A, 0xDD, 0x00, 0x45,
  55. 0x38, 0x3D, 0x00, 0x37, 0x30, 0x30, 0x0F, 0xF9, 0xB6, 0xDB, 0xE3, 0x81, 0x34, 0xED, 0x03,
  56. 0xF3, 0x34, 0x3D, 0x03, 0xF6, 0x14, 0xDB, 0xFC, 0x84, 0x30, 0xED, 0x03, 0xF3, 0x3C, 0x3D,
  57. 0x00, 0x43, 0x00, 0x03, 0xF0, 0x0E, 0x30, 0x3D, 0x03, 0xF6, 0x34, 0x3D, 0x03, 0xDF, 0x30,
  58. 0x3D, 0x03, 0xF6, 0x38, 0x3D, 0x00, 0x1B, 0x30, 0x30, 0x0F, 0xF9, 0x00, 0x03, 0xEB, 0x01,
  59. 0x3B, 0x50, 0x00, 0x00, 0x34, 0x30, 0x0F, 0xC8, 0x0C, 0xE3, 0xFE, 0xB2, 0x00, 0x03, 0xC1,
  60. 0x31, 0x00, 0x00, 0x1E, 0x38, 0x00, 0x03, 0xF0, 0x2C, 0x34, 0x40, 0x0F, 0xCD, 0x00, 0x03,
  61. 0xF0, 0x2B, 0x00, 0x03, 0xF0, 0x2D, 0x3B, 0x80, 0x00, 0x01, 0x34, 0x30, 0x0F, 0xCC, 0x00,
  62. 0x03, 0xEB, 0x01, 0x3B, 0x50, 0x00, 0x00, 0x34, 0x40, 0x0F, 0xC8, 0x00, 0x03, 0xFF, 0x03,
  63. 0x00, 0x03, 0xED, 0x7A, 0x0D, 0x1B, 0xF0, 0x2C, 0x00, 0x03, 0xC0, 0xF1, 0x00, 0x03, 0xC0,
  64. 0xF2, 0x00, 0x03, 0xC0, 0xF3, 0x34, 0x40, 0x0F, 0xCD, 0x00, 0x03, 0xF0, 0x2B, 0x00, 0x03,
  65. 0xF0, 0x2D, 0x3B, 0x80, 0x00, 0x01, 0x34, 0x30, 0x0F, 0xCC, 0x3B, 0x80, 0x00, 0x00, 0x34,
  66. 0x20, 0x0F, 0xFA, 0x00, 0x50, 0x00, 0x00, 0x3C, 0x1D, 0x00, 0x6C, 0x34, 0x00, 0x0F, 0xC5,
  67. 0x2C, 0xB0, 0x00, 0x01, 0x3C, 0x1D, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. 0x00, 0x3A, 0xDE, 0x16, 0x12, 0x3A, 0xFD, 0x00, 0x69, 0x00, 0x03, 0xEB, 0xC1, 0x3A, 0xDD,
  69. 0x01, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB2, 0xEC, 0x2C, 0x00, 0x08, 0x00, 0x3A,
  70. 0xDD, 0x00, 0x83, 0x3C, 0x1E, 0x16, 0x12, 0x3B, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  71. 0x3A, 0xDE, 0x16, 0x12, 0x3A, 0xFD, 0x00, 0x74, 0x00, 0x03, 0xEB, 0xC1, 0x34, 0x00, 0x0F,
  72. 0xC5, 0x2C, 0x00, 0x08, 0x00, 0x3C, 0x1D, 0x01, 0x91, 0x00, 0x00, 0x00, 0x00, 0x38, 0x0D,
  73. 0x00, 0x11, 0x32, 0x10, 0x0F, 0xF8, 0x00, 0x00, 0xB8, 0x0C, 0x38, 0x00, 0x03, 0x80, 0x30,
  74. 0x00, 0x0D, 0xCB, 0x2E, 0x15, 0x00, 0x00, 0x30, 0x00, 0x0F, 0x8D, 0x00, 0x00, 0xC0, 0x3C,
  75. 0x38, 0x00, 0x06, 0x00, 0x32, 0x10, 0x0F, 0x81, 0x3A, 0xDD, 0x01, 0x91, 0x34, 0x00, 0x0D,
  76. 0xC6, 0x2C, 0x30, 0x00, 0x07, 0x3C, 0x6D, 0x00, 0x89, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00,
  77. 0x00, 0x00, 0x32, 0x10, 0x0D, 0xCA, 0x34, 0x00, 0x0D, 0xCA, 0x00, 0x40, 0x00, 0x00, 0x3C,
  78. 0x6D, 0x00, 0xCD, 0x00, 0x00, 0xB4, 0x6C, 0x00, 0x00, 0xB4, 0x2C, 0x3A, 0xDD, 0x01, 0xB1,
  79. 0x3A, 0xFD, 0x00, 0x91, 0x00, 0x03, 0xEB, 0xC1, 0x34, 0x00, 0x0D, 0xC6, 0x2C, 0x30, 0x00,
  80. 0x07, 0x3C, 0x1D, 0x00, 0x9C, 0x34, 0x00, 0x0D, 0xCB, 0x2E, 0x3F, 0xFF, 0xFE, 0x34, 0x10,
  81. 0x0F, 0x8D, 0xA2, 0x00, 0x00, 0x00, 0x3C, 0x4D, 0x00, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x30,
  82. 0x00, 0x0F, 0x8D, 0x00, 0x00, 0xC0, 0x3C, 0x3A, 0xDE, 0x18, 0x4E, 0x3A, 0xFD, 0x00, 0x9F,
  83. 0x00, 0x03, 0xEB, 0xC1, 0x3A, 0xDE, 0x18, 0xAC, 0x3A, 0xFD, 0x00, 0xA2, 0x00, 0x03, 0xEB,
  84. 0xC1, 0x3A, 0xDD, 0x01, 0x94, 0x3A, 0xFD, 0x00, 0xA5, 0x00, 0x03, 0xEB, 0xC1, 0x34, 0x00,
  85. 0x0D, 0xC4, 0x00, 0x40, 0x00, 0x00, 0x3C, 0x6D, 0x00, 0xF3, 0x34, 0x10, 0x0D, 0xCB, 0x34,
  86. 0x00, 0x0D, 0xC9, 0x34, 0x80, 0x0D, 0xC1, 0x35, 0x00, 0x0D, 0xFD, 0x34, 0x70, 0x0D, 0xF5,
  87. 0x00, 0x78, 0x00, 0x00, 0x3C, 0x1D, 0x00, 0xB2, 0x32, 0x10, 0x0D, 0xDA, 0xB0, 0x50, 0x60,
  88. 0x00, 0xA0, 0x00, 0x60, 0x00, 0x30, 0x80, 0x0D, 0xD6, 0x14, 0x90, 0x00, 0x00, 0x00, 0x03,
  89. 0xC0, 0x18, 0x30, 0x20, 0x0D, 0xC9, 0x00, 0x00, 0x80, 0x00, 0x30, 0x80, 0x0D, 0xC8, 0x39,
  90. 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x06, 0x32, 0x10, 0x0D, 0xD5, 0x34, 0x00, 0x0F, 0x88,
  91. 0x32, 0x10, 0x0D, 0xD7, 0x34, 0x00, 0x0D, 0xFD, 0x32, 0x10, 0x0D, 0xD8, 0x34, 0x00, 0x0D,
  92. 0xF2, 0x32, 0x10, 0x0D, 0xD9, 0xB0, 0x03, 0xD0, 0x81, 0x38, 0x80, 0x0D, 0xD5, 0x36, 0xDE,
  93. 0x00, 0x41, 0x3A, 0xFD, 0x00, 0xC6, 0x00, 0x03, 0xEB, 0xC1, 0x00, 0x40, 0x00, 0x00, 0x3C,
  94. 0x1D, 0x00, 0xF3, 0x30, 0x00, 0x0D, 0xC7, 0x34, 0x20, 0x0D, 0xC4, 0x3A, 0xDD, 0x00, 0xF3,
  95. 0x00, 0x00, 0xB0, 0x82, 0x30, 0x20, 0x0D, 0xC4, 0x3A, 0xDE, 0x18, 0xAC, 0x3A, 0xFD, 0x00,
  96. 0xD0, 0x00, 0x03, 0xEB, 0xC1, 0x34, 0x00, 0x0D, 0xCA, 0x38, 0x10, 0x00, 0x02, 0x04, 0x40,
  97. 0x00, 0x00, 0x3C, 0x1D, 0x00, 0xE1, 0x34, 0x00, 0x0D, 0xCA, 0x38, 0x10, 0x00, 0x05, 0x04,
  98. 0x40, 0x00, 0x00, 0x3C, 0x1D, 0x00, 0xF3, 0x34, 0x00, 0x0D, 0xCB, 0x2E, 0x3F, 0xFF, 0xFE,
  99. 0x34, 0x10, 0x0F, 0x8D, 0xA2, 0x00, 0x00, 0x00, 0x3C, 0x4D, 0x00, 0xF3, 0x00, 0x00, 0x00,
  100. 0x00, 0x30, 0x00, 0x0F, 0x8D, 0x3A, 0xDD, 0x00, 0xF3, 0x00, 0x00, 0xC0, 0x3C, 0x34, 0x00,
  101. 0x0D, 0xC4, 0x00, 0x40, 0x00, 0x00, 0x3C, 0x6D, 0x00, 0xF3, 0x34, 0x00, 0x0D, 0xC8, 0x32,
  102. 0x10, 0x0D, 0xD6, 0x34, 0x00, 0x0D, 0xC9, 0x32, 0x10, 0x0D, 0xDA, 0x34, 0x00, 0x0D, 0xC7,
  103. 0x38, 0x10, 0x00, 0x02, 0x38, 0x80, 0x0D, 0xD5, 0x36, 0xDE, 0x00, 0x41, 0x3A, 0xFD, 0x00,
  104. 0xEE, 0x00, 0x03, 0xEB, 0xC1, 0x00, 0x40, 0x00, 0x00, 0x3C, 0x1D, 0x00, 0xF3, 0x34, 0x20,
  105. 0x0D, 0xC4, 0x00, 0x00, 0xB0, 0xC2, 0x30, 0x20, 0x0D, 0xC4, 0x38, 0x00, 0x00, 0x0F, 0x32,
  106. 0x10, 0x0D, 0xDB, 0x34, 0x00, 0x0D, 0xFD, 0x32, 0x10, 0x0D, 0xDE, 0x34, 0x00, 0x0D, 0xF2,
  107. 0x32, 0x10, 0x0D, 0xDF, 0x34, 0x00, 0x0D, 0xF3, 0x2C, 0x00, 0x00, 0x0F, 0x32, 0x10, 0x0D,
  108. 0xE8, 0x38, 0x00, 0x00, 0x00, 0x32, 0x10, 0x0D, 0xE9, 0x38, 0x00, 0x0D, 0xCF, 0x32, 0x10,
  109. 0x0D, 0xE0, 0x34, 0x00, 0x0D, 0xFE, 0x32, 0x10, 0x0D, 0xE1, 0x34, 0x00, 0x0D, 0xFF, 0x32,
  110. 0x10, 0x0D, 0xE2, 0x34, 0x00, 0x0D, 0xF1, 0x32, 0x10, 0x0D, 0xE3, 0x34, 0x00, 0x0F, 0x88,
  111. 0x32, 0x10, 0x0D, 0xDD, 0x34, 0x00, 0x0D, 0xC1, 0x32, 0x10, 0x0D, 0xDC, 0x34, 0x00, 0x0D,
  112. 0xF4, 0x32, 0x10, 0x0D, 0xE7, 0x34, 0x00, 0x0D, 0xCA, 0x32, 0x10, 0x0D, 0xE4, 0x34, 0x00,
  113. 0x0D, 0xCC, 0x32, 0x10, 0x0D, 0xE5, 0x34, 0x00, 0x0D, 0xCD, 0x32, 0x10, 0x0D, 0xE6, 0x34,
  114. 0x0D, 0x03, 0xD9, 0x38, 0x10, 0x00, 0x0C, 0x16, 0x43, 0xD1, 0x01, 0x18, 0x40, 0x00, 0x00,
  115. 0x34, 0x10, 0x0D, 0xCE, 0x16, 0x43, 0xD3, 0x02, 0x3C, 0x1D, 0x01, 0x2C, 0x16, 0x53, 0xD4,
  116. 0x03, 0x30, 0x20, 0x0D, 0xCE, 0x34, 0x0D, 0x03, 0xD8, 0x2C, 0x00, 0x00, 0x07, 0x2C, 0x30,
  117. 0x00, 0x02, 0x3C, 0x3D, 0x01, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x18, 0xD0, 0x00, 0x00, 0x30,
  118. 0x20, 0x0D, 0xCE, 0x38, 0x00, 0x00, 0x02, 0x32, 0x10, 0x0D, 0xE3, 0x38, 0x07, 0xFF, 0xFF,
  119. 0x32, 0x10, 0x0D, 0xE7, 0x38, 0x0E, 0x2B, 0xA9, 0x32, 0x10, 0x0D, 0xE0, 0x38, 0x0E, 0x2B,
  120. 0xAF, 0x32, 0x10, 0x0D, 0xE1, 0x38, 0x0E, 0x2B, 0xB5, 0x32, 0x10, 0x0D, 0xE2, 0x34, 0x00,
  121. 0x0D, 0xE8, 0x00, 0x40, 0x00, 0x00, 0x3C, 0x6D, 0x01, 0x32, 0x34, 0x00, 0x0D, 0xC4, 0x38,
  122. 0x80, 0x0D, 0xDB, 0x06, 0x00, 0x00, 0x00, 0x34, 0x10, 0x0F, 0xFC, 0x00, 0x48, 0x00, 0x00,
  123. 0x3C, 0x6D, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x38, 0x10, 0x00, 0x03, 0x38, 0x0F, 0xFF,
  124. 0xFF, 0x34, 0x90, 0x0D, 0xC1, 0x35, 0x10, 0x0D, 0xFD, 0x34, 0x20, 0x0D, 0xCA, 0x00, 0x52,
  125. 0x82, 0x0A, 0x3C, 0x6D, 0x01, 0x40, 0x39, 0x10, 0x00, 0x00, 0x2C, 0xA8, 0x00, 0x00, 0x00,
  126. 0x03, 0xE0, 0x8C, 0x36, 0xD0, 0x0F, 0x8B, 0x3A, 0xFD, 0x01, 0x43, 0x00, 0x03, 0xEB, 0xC1,
  127. 0x36, 0xDE, 0x00, 0x41, 0x3A, 0xFD, 0x01, 0x46, 0x00, 0x03, 0xEB, 0xC1, 0x30, 0x00, 0x0D,
  128. 0xC5, 0x34, 0x00, 0x0D, 0xCE, 0x2C, 0x00, 0x00, 0x10, 0x3C, 0x1D, 0x01, 0x6A, 0x38, 0x00,
  129. 0x00, 0x20, 0x32, 0x10, 0x0D, 0xE4, 0x38, 0x00, 0x00, 0x0B, 0x32, 0x10, 0x0D, 0xDB, 0x38,
  130. 0x0E, 0x2B, 0xA9, 0x32, 0x10, 0x0D, 0xDC, 0x38, 0x0E, 0x2B, 0xAF, 0x32, 0x10, 0x0D, 0xDD,
  131. 0x38, 0x0E, 0x2B, 0xB5, 0x32, 0x10, 0x0D, 0xDE, 0x38, 0x00, 0x00, 0x00, 0x32, 0x10, 0x0D,
  132. 0xDF, 0x38, 0x00, 0x0D, 0xCF, 0x32, 0x10, 0x0D, 0xE0, 0x34, 0x00, 0x0D, 0xFE, 0x32, 0x10,
  133. 0x0D, 0xE1, 0x34, 0x00, 0x0D, 0xFF, 0x32, 0x10, 0x0D, 0xE2, 0x34, 0x00, 0x0D, 0xF4, 0x32,
  134. 0x10, 0x0D, 0xE5, 0x34, 0x0D, 0x03, 0xD8, 0x2C, 0x00, 0xC0, 0x00, 0x2E, 0x3F, 0xFF, 0xFE,
  135. 0x34, 0x10, 0x0D, 0xF1, 0x2C, 0x41, 0xCF, 0xFF, 0x18, 0x08, 0x00, 0x00, 0x32, 0x50, 0x0D,
  136. 0xE3, 0xB0, 0x03, 0xD1, 0x41, 0x38, 0x80, 0x0D, 0xDB, 0x36, 0xDE, 0x00, 0x41, 0x3A, 0xFD,
  137. 0x01, 0x6A, 0x00, 0x03, 0xEB, 0xC1, 0x38, 0x00, 0x00, 0x01, 0x3A, 0xDE, 0x17, 0xC7, 0x3A,
  138. 0xFD, 0x01, 0x6E, 0x00, 0x03, 0xEB, 0xC1, 0x36, 0xD0, 0x0F, 0x8C, 0x3A, 0xFD, 0x01, 0x71,
  139. 0x00, 0x03, 0xEB, 0xC1, 0x3A, 0xDE, 0x18, 0xE5, 0x3A, 0xFD, 0x01, 0x74, 0x00, 0x03, 0xEB,
  140. 0xC1, 0x34, 0x00, 0x0D, 0xCA, 0x2C, 0x30, 0x00, 0x05, 0x3C, 0x5D, 0x01, 0x7A, 0x12, 0x03,
  141. 0xD0, 0x01, 0x30, 0x00, 0x0D, 0xCA, 0x30, 0x10, 0x0D, 0xCA, 0x38, 0x00, 0x00, 0x08, 0x32,
  142. 0x1D, 0x03, 0xD4, 0x34, 0x00, 0x0D, 0xC6, 0x2C, 0x10, 0x05, 0x00, 0x34, 0x20, 0x0D, 0xC5,
  143. 0x34, 0x10, 0x0D, 0xC4, 0x00, 0x4B, 0xD0, 0xC1, 0x3C, 0x1D, 0x01, 0x85, 0x0C, 0x50, 0x00,
  144. 0x00, 0x18, 0x80, 0x00, 0x00, 0x2C, 0x10, 0x40, 0x00, 0x32, 0x1D, 0x03, 0xD5, 0x38, 0x0D,
  145. 0x03, 0xD4, 0x32, 0x10, 0x0F, 0xFB, 0x34, 0x10, 0x0F, 0xC5, 0x2C, 0x40, 0x10, 0x00, 0x3C,
  146. 0x1D, 0x01, 0x91, 0x34, 0x00, 0x0D, 0xC4, 0x00, 0x40, 0x00, 0x00, 0x3C, 0x1D, 0x01, 0x91,
  147. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7C, 0x00, 0x00, 0xB0, 0x7C, 0x00, 0x03, 0xF0,
  148. 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x0F, 0xC5, 0x00, 0x00,
  149. 0xD1, 0x61, 0x3C, 0x1D, 0x01, 0xAE, 0x34, 0x0D, 0x03, 0xD9, 0x2C, 0x00, 0x07, 0x00, 0x2E,
  150. 0x30, 0x00, 0x04, 0x2C, 0x10, 0x00, 0x10, 0x32, 0x1D, 0x03, 0xDD, 0x34, 0x00, 0x0D, 0xC1,
  151. 0x32, 0x1D, 0x03, 0xF3, 0x34, 0x30, 0x0D, 0xCB, 0x30, 0x3D, 0x03, 0xDE, 0x38, 0x20, 0x0B,
  152. 0xFC, 0xB6, 0x90, 0x00, 0x00, 0x30, 0x2D, 0x03, 0xDF, 0x2E, 0xCF, 0xFA, 0x06, 0x2E, 0xDA,
  153. 0xAA, 0xAB, 0x3B, 0x80, 0x00, 0x00, 0x2C, 0xCF, 0xFF, 0xFE, 0x00, 0x00, 0xD0, 0x0F, 0x3C,
  154. 0x1D, 0x01, 0xAC, 0x38, 0x0D, 0x00, 0x1B, 0x32, 0x10, 0x0F, 0xF9, 0x14, 0xD8, 0x00, 0x00,
  155. 0x3B, 0x80, 0x00, 0x01, 0x30, 0x3D, 0x03, 0xF6, 0x00, 0x03, 0xF0, 0x2D, 0x00, 0x00, 0x00,
  156. 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x0F, 0x8D, 0x00, 0x43, 0xC3, 0xC0, 0x3C, 0x4D,
  157. 0x01, 0xBB, 0x34, 0x10, 0x0D, 0xC2, 0x04, 0x08, 0x00, 0x00, 0x3C, 0x6D, 0x01, 0xB1, 0x38,
  158. 0x00, 0x00, 0x07, 0x32, 0x10, 0x0D, 0xC6, 0x3A, 0xDD, 0x02, 0x16, 0x00, 0x00, 0x00, 0x00,
  159. 0x34, 0x00, 0x0D, 0xC0, 0x3A, 0xDD, 0x02, 0x1A, 0x3A, 0xFD, 0x01, 0xBF, 0x00, 0x03, 0xEB,
  160. 0xC1, 0x2E, 0x0F, 0xFF, 0xF6, 0x38, 0x10, 0x00, 0x01, 0x20, 0x40, 0x00, 0x00, 0x30, 0x00,
  161. 0x0D, 0xE1, 0x34, 0x00, 0x0D, 0xC0, 0x32, 0x10, 0x0D, 0xDC, 0x34, 0x00, 0x0F, 0x88, 0x32,
  162. 0x10, 0x0D, 0xDD, 0x31, 0x60, 0x0D, 0xDE, 0x34, 0x00, 0x0D, 0xF2, 0x32, 0x10, 0x0D, 0xDF,
  163. 0x38, 0x00, 0x00, 0x00, 0x32, 0x10, 0x0D, 0xE0, 0x38, 0x80, 0x0D, 0xDB, 0xB0, 0x03, 0xD2,
  164. 0x01, 0x3A, 0xDE, 0x19, 0x92, 0x3A, 0xFD, 0x01, 0xD1, 0x00, 0x03, 0xEB, 0xC1, 0x00, 0x43,
  165. 0xC5, 0x91, 0x34, 0x90, 0x0F, 0x87, 0x3C, 0x6D, 0x02, 0x13, 0x38, 0x00, 0x00, 0x01, 0x32,
  166. 0x10, 0x0D, 0xC6, 0xBD, 0xB0, 0x00, 0x00, 0x30, 0x90, 0x0D, 0xC1, 0x38, 0x00, 0x00, 0x05,
  167. 0x32, 0x10, 0x0D, 0xDB, 0x30, 0x90, 0x0D, 0xDC, 0x34, 0x00, 0x0F, 0x88, 0x32, 0x10, 0x0D,
  168. 0xDD, 0x31, 0x60, 0x0D, 0xDE, 0x34, 0x00, 0x0D, 0xF2, 0x32, 0x10, 0x0D, 0xDF, 0x38, 0x80,
  169. 0x0D, 0xDB, 0xB0, 0x03, 0xD0, 0x41, 0x36, 0xDE, 0x00, 0x41, 0x3A, 0xFD, 0x01, 0xE5, 0x00,
  170. 0x03, 0xEB, 0xC1, 0x39, 0x80, 0x00, 0x02, 0x30, 0x00, 0x0D, 0xC6, 0x00, 0x43, 0x60, 0x02,
  171. 0x3C, 0x6D, 0x02, 0x10, 0x39, 0x80, 0x00, 0x03, 0x34, 0x00, 0x0D, 0xF5, 0x30, 0x20, 0x0D,
  172. 0xCB, 0x00, 0x43, 0xD0, 0x06, 0x3C, 0x1D, 0x01, 0xF1, 0x00, 0x03, 0x60, 0x01, 0x30, 0x10,
  173. 0x0D, 0xC9, 0x13, 0xB0, 0x00, 0x00, 0x39, 0x10, 0x00, 0x00, 0x39, 0x80, 0x00, 0x04, 0x00,
  174. 0x02, 0xA0, 0x07, 0x30, 0x7D, 0x03, 0xD8, 0x00, 0x00, 0x80, 0x00, 0x38, 0x9D, 0x03, 0xD9,
  175. 0x3E, 0x00, 0x00, 0x04, 0x00, 0x06, 0x51, 0xCF, 0x34, 0x00, 0x0D, 0xFD, 0x22, 0x13, 0xC5,
  176. 0x91, 0x34, 0x90, 0x0D, 0xC1, 0x0D, 0x90, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x99, 0x38, 0x15,
  177. 0x00, 0x00, 0x34, 0x20, 0x0D, 0xCB, 0x42, 0x98, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x30,
  178. 0x90, 0x0D, 0xC0, 0x34, 0x00, 0x0D, 0xC1, 0x3A, 0xDD, 0x02, 0x1A, 0x3A, 0xFD, 0x02, 0x07,
  179. 0x00, 0x03, 0xEB, 0xC1, 0xB0, 0xC0, 0x00, 0x00, 0x3C, 0x4D, 0x02, 0x0C, 0x00, 0x00, 0x00,
  180. 0x00, 0x30, 0x00, 0x0F, 0x8D, 0x00, 0x00, 0xC0, 0x3C, 0x39, 0x10, 0x00, 0x00, 0x00, 0x03,
  181. 0xF0, 0x2D, 0x31, 0x10, 0x0D, 0xC4, 0x30, 0xF0, 0x0D, 0xC3, 0x3A, 0xDD, 0x02, 0x14, 0x34,
  182. 0x00, 0x0D, 0xC1, 0x32, 0x10, 0x0D, 0xC0, 0x30, 0x90, 0x0D, 0xC0, 0x38, 0x00, 0x03, 0x80,
  183. 0x32, 0x10, 0x0D, 0xCB, 0x39, 0x10, 0x00, 0x00, 0x00, 0x03, 0xF0, 0x2D, 0x38, 0x00, 0x00,
  184. 0x01, 0x32, 0x10, 0x0D, 0xC4, 0x00, 0x00, 0xC4, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
  185. 0xC3, 0x81, 0x34, 0x20, 0x0F, 0x8D, 0xB0, 0x40, 0xB4, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x3C,
  186. 0x2D, 0x02, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC5, 0x81, 0xA2, 0x00, 0x00, 0x00,
  187. 0x00, 0x03, 0xF0, 0x2D, 0xA0, 0x90, 0x00, 0x00, 0xB0, 0x48, 0x00, 0x00, 0x34, 0x3D, 0x03,
  188. 0xF2, 0x00, 0x00, 0xD0, 0x03, 0x3C, 0x6D, 0x02, 0x53, 0x38, 0x20, 0x0F, 0x3B, 0x30, 0x20,
  189. 0x0D, 0xE9, 0x00, 0x00, 0xB0, 0x03, 0x30, 0x3D, 0x03, 0xF2, 0x00, 0x03, 0xE0, 0x01, 0x00,
  190. 0x03, 0xE0, 0x41, 0x38, 0xB0, 0x0F, 0x3B, 0x3A, 0x80, 0x00, 0x12, 0x3A, 0xAD, 0x02, 0x35,
  191. 0x38, 0x30, 0x00, 0x00, 0x00, 0x03, 0xE0, 0xDA, 0x00, 0x03, 0xE0, 0xDA, 0x39, 0xA0, 0x00,
  192. 0x03, 0x38, 0xAD, 0x03, 0xF0, 0x38, 0xCD, 0x03, 0xE3, 0x3A, 0x80, 0x00, 0x03, 0x3A, 0xAD,
  193. 0x02, 0x4F, 0x38, 0xB0, 0x0F, 0x3B, 0x00, 0x03, 0xF8, 0x81, 0x2E, 0x6F, 0xFF, 0xEC, 0x00,
  194. 0x03, 0xCD, 0xA5, 0x00, 0x03, 0xF4, 0x80, 0x2E, 0x2F, 0xFF, 0xEC, 0x00, 0x03, 0xCD, 0xA1,
  195. 0x3A, 0x80, 0x00, 0x04, 0x3A, 0xAD, 0x02, 0x4E, 0x38, 0x4F, 0xF0, 0x00, 0x2E, 0x20, 0x00,
  196. 0x08, 0x00, 0x03, 0xC8, 0x43, 0x17, 0x18, 0x00, 0x00, 0x2E, 0x60, 0x00, 0x08, 0x00, 0x03,
  197. 0xC9, 0x45, 0x17, 0x28, 0x00, 0x00, 0x2F, 0x7F, 0xFF, 0xF4, 0x00, 0x03, 0xC1, 0x5B, 0x38,
  198. 0x50, 0x00, 0x00, 0x00, 0x01, 0xD6, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xD6, 0x1D,
  199. 0x00, 0x03, 0xF0, 0x01, 0x00, 0x03, 0xF0, 0x00, 0x00, 0x03, 0xF0, 0x2D, 0x00, 0x00, 0x00,
  200. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
  201. 0x00, 0x01, 0x2F, 0x2F, 0x00, 0x21, 0x00, 0x00, 0x00, 0x2F, 0x00, 0x2F, 0x21, 0x00, 0x00,
  202. 0x03, 0x04, 0x01, 0x09, 0x0A, 0x07, 0x0E, 0x0F, 0x10, 0x0D, 0x11, 0x00, 0x0D, 0x03, 0xF4,
  203. 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x91, 0xA2, 0xB3, 0xC5, 0x01, 0x45, 0x67,
  204. 0x00, 0x00, 0x0D, 0x03, 0xFB, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xE9, 0xEF,
  205. 0xC6, 0x30, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
  206. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  207. };
  208. static void NEARAPI SPIStart(void)
  209. {
  210. BoardWriteGPIOReg(SPICLK, FALSE);
  211. Delay(100);
  212. BoardWriteGPIOReg(SPIENA, FALSE);
  213. Delay(100);
  214. }
  215. static void NEARAPI SPIStop(void)
  216. {
  217. Delay(100);
  218. BoardWriteGPIOReg(SPIENA, TRUE);
  219. }
  220. static BYTE NEARAPI SPISendByte(BYTE data)
  221. {
  222. BYTE Val;
  223. int i;
  224. Val = data;
  225. for(i=0; i<8; i++)
  226. {
  227. BoardWriteGPIOReg(SPICLK, TRUE);
  228. Delay(100); //ckw
  229. BoardWriteGPIOReg(SPIDO, (Val & 0x80 ? TRUE : FALSE)); //ckw
  230. Delay(100);
  231. BoardWriteGPIOReg(SPICLK, FALSE);
  232. Delay(100);
  233. if(BoardReadGPIOReg(SPIDI))
  234. Val = (Val << 1) | 0x01;
  235. else
  236. Val = (Val << 1);
  237. }
  238. return Val;
  239. }
  240. //ckw start
  241. void FARAPI SPIReadBack(BYTE command, int numresult, BYTE *result)
  242. {
  243. int i;
  244. SPIStart();
  245. SPISendByte(0x00);
  246. SPISendByte(0x00);
  247. SPISendByte(0x00);
  248. SPISendByte(command);
  249. SPISendByte(0x00);
  250. SPISendByte(0x00);
  251. for (i=0;i<numresult-1;i++)
  252. result[i] = SPISendByte(0x00);
  253. result[i] = SPISendByte(0x80);
  254. SPISendByte(0x80);
  255. SPISendByte(0x80);
  256. SPIStop();
  257. return;
  258. }
  259. //ckw end
  260. BYTE FARAPI SPISendSeq(int Num, BYTE *Data)
  261. {
  262. int i;
  263. BYTE b; //ckw
  264. SPIStart();
  265. SPISendByte(0x00);
  266. SPISendByte(0x00);
  267. SPISendByte(0x00);
  268. SPISendByte(Data[0]); //ckw
  269. for(i=1; i<Num; i++) //ckw
  270. {
  271. //ckw start
  272. b = SPISendByte(Data[i]);
  273. if ((b != 0x80) && ((Num-i-1) + 3 != b))
  274. {
  275. Delay(100);
  276. BoardWriteGPIOReg(SPIENA, TRUE);
  277. DebugPrint((DebugLevelError, "AC3:Wrong number of args\n"));
  278. }
  279. //ckw end
  280. }
  281. SPISendByte(0x00);
  282. SPISendByte(0x80);
  283. b = SPISendByte(0x80); //ckw
  284. SPIStop();
  285. //ckw start
  286. switch (b & 3)
  287. {
  288. case 1:
  289. DebugPrint((DebugLevelError, "AC3:Invalid OPCODE!!\n"));
  290. break;
  291. case 2:
  292. DebugPrint((DebugLevelError, "AC3:Invalid Parameters!!\n"));
  293. break;
  294. DebugPrint((DebugLevelError, "AC3:Device not ready!!\n"));
  295. break;
  296. }
  297. //ckw end
  298. return TRUE;
  299. }
  300. BOOL FARAPI InitAC3Decoder(void)
  301. {
  302. //ckw start
  303. char dbgstr[80];
  304. BYTE ver[4];
  305. DWORD version;
  306. int i;
  307. BoardWriteAudio(AUD_BBE, 0x01);
  308. BoardWriteAudio(AUD_DEM, 0x00);
  309. BoardWriteAudio(AUD_DIF, 0x01);
  310. BoardWriteAudio(AUD_DIV, 0x02);
  311. BoardWriteAudio(AUD_EXT, 0x00);
  312. BoardWriteAudio(AUD_FOR, 0x00);
  313. BoardWriteAudio(AUD_ISS, 0x03);
  314. BoardWriteAudio(AUD_LCA, 0x00);
  315. BoardWriteAudio(AUD_RCA, 0x00);
  316. BoardWriteAudio(AUD_LRP, 0x00);
  317. BoardWriteAudio(AUD_ORD, 0x00);
  318. BoardWriteAudio(AUD_P18, 0x01);
  319. BoardWriteAudio(AUD_SCP, 0x00);
  320. BoardWriteAudio(AUD_SEM, 0x00);
  321. BoardWriteAudio(AUD_SFR, 0x00);
  322. BoardWriteAudio(AUD_RST, 0x01);
  323. BoardWriteEPLD(INCTL, 0x01);
  324. BoardWriteVideo(CTL, 0x02);
  325. Delay(200);
  326. BoardWriteVideo(CTL, 0x00);
  327. BoardWriteEPLD(AUXCTL, 0x08);
  328. Delay(200);
  329. i = 0;
  330. do
  331. {
  332. BoardWriteEPLD(AUXCTL, 0x00);
  333. Delay(200);
  334. BoardWriteEPLD(AUXCTL, 0x08);
  335. Delay(200);
  336. i++;
  337. if(i>10)
  338. {
  339. DebugPrint((DebugLevelError,"Can not Boot AC3!!!!!!!"));
  340. break;
  341. }
  342. } while (!BootAC3());
  343. BoardWriteEPLD(AUXCTL, 0x08);
  344. Delay(200);
  345. SPIReadBack(0x81, 4, ver);
  346. version = ((DWORD)(BYTE)(ver[0]) | ((DWORD)(BYTE)(ver[1]) << 8) | ((DWORD)(BYTE)(ver[2]) << 16) | ((DWORD)(BYTE)(ver[3]) << 24));
  347. DebugPrint((DebugLevelError, "AC3:Version = %lu!!\n",version));
  348. SPISendSeq(PARAMSIZE, CfgParams);
  349. SPISendSeq(PARAMSIZE, AC3Params);
  350. AC3Command(AC3_STOP); //ckw
  351. //ckw end
  352. return TRUE;
  353. }
  354. //ckw start
  355. void FARAPI AC3Command(BYTE command)
  356. {
  357. SPISendSeq(1, &command); //ckw
  358. }
  359. //ckw end
  360. void FARAPI SendAC3Data(BYTE *Data, DWORD Size)
  361. {
  362. DWORD i, PoReg;
  363. PoReg = 0x00B00000;
  364. for(i=0; i<Size; i++)
  365. {
  366. // HostDisableIT();
  367. memOutDword(POSTOFFICEREG, PoReg|Data[i]);
  368. // Delay(10);
  369. while(memInDword(POSTOFFICEREG)&02000000L);
  370. // HostEnableIT();
  371. }
  372. }
  373. BOOL FARAPI BootAC3(void)
  374. {
  375. int i,num=0; //ckw
  376. BYTE Val, b;
  377. BOOL fail = FALSE; //ckw
  378. SPIStart();
  379. b=SPISendByte(0);
  380. b=SPISendByte(0);
  381. b=SPISendByte(0);
  382. b=SPISendByte(0);
  383. num = 0;
  384. i = 0;
  385. while(i < NUMCODE)
  386. {
  387. Val = AC3MCode[i];
  388. Delay(100);
  389. b = SPISendByte(Val);
  390. if ((num == 2 ) && (b != 0x05))
  391. {
  392. fail = TRUE;
  393. }
  394. num++;
  395. i++;
  396. }
  397. SPIStop();
  398. if(fail)
  399. {
  400. DebugPrint((DebugLevelError,"AC3 : Error Loading MicroCode!!\n"));
  401. return FALSE;
  402. }
  403. return TRUE;
  404. }
  405. //ckw start
  406. void FARAPI AudioTransfer(BOOL flag)
  407. {
  408. BoardWriteAudio(0xAE, (BYTE) flag);
  409. return;
  410. }
  411. //ckw end