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.

328 lines
6.2 KiB

  1. //
  2. // MODULE : BOARD.C
  3. // PURPOSE : Board specific code goes here
  4. // AUTHOR : JBS Yadawa
  5. // CREATED : 7/20/96
  6. //
  7. // Copyright (C) 1996 SGS-THOMSON Microelectronics
  8. //
  9. //
  10. // REVISION HISTORY :
  11. //
  12. // DATE :
  13. //
  14. // COMMENTS :
  15. //
  16. #include "common.h"
  17. #include "strmini.h"
  18. #include "stdefs.h"
  19. #include "board.h"
  20. #include "debug.h"
  21. #include "common.h"
  22. #include "i20reg.h"
  23. #include "bt856.h"
  24. #include "memio.h"
  25. #include "codedma.h"
  26. #define POSTOFFICEREG 0x200
  27. #define INCTL 0x01
  28. #define AUXCTL 0x02
  29. #define INTR_CTRL 0x40
  30. #define INTR_STATUS 0x3C
  31. static BYTE PrevVideoAdr = 0xFF;
  32. static BYTE GPIOReg;
  33. BYTE FARAPI BoardReadAudio(BYTE Reg)
  34. {
  35. BYTE NewVideoAdr = Reg & 0x7E;
  36. DWORD PoReg=0;
  37. HostDisableIT();
  38. if(NewVideoAdr != PrevVideoAdr)
  39. {
  40. PrevVideoAdr = NewVideoAdr;
  41. PoReg = NewVideoAdr | 0x00830000;
  42. memOutDword(POSTOFFICEREG, PoReg);
  43. while(memInDword(POSTOFFICEREG)&02000000L);
  44. }
  45. if(Reg&0x80)
  46. {
  47. if(Reg&0x01)
  48. PoReg = 0x00150000;
  49. else
  50. PoReg = 0x00140000;
  51. }
  52. else
  53. {
  54. if(Reg&0x01)
  55. PoReg = 0x00110000;
  56. else
  57. PoReg = 0x00100000;
  58. }
  59. memOutDword(POSTOFFICEREG, PoReg);
  60. while(memInDword(POSTOFFICEREG)&02000000L);
  61. PoReg = memInDword(POSTOFFICEREG);
  62. HostEnableIT();
  63. return ((BYTE)PoReg);
  64. }
  65. BYTE FARAPI BoardReadVideo(BYTE Reg)
  66. {
  67. BYTE NewVideoAdr = Reg & 0x7E;
  68. DWORD PoReg=0;
  69. HostDisableIT();
  70. if(NewVideoAdr != PrevVideoAdr)
  71. {
  72. PrevVideoAdr = NewVideoAdr;
  73. PoReg = NewVideoAdr | 0x00830000;
  74. memOutDword(POSTOFFICEREG, PoReg);
  75. while(memInDword(POSTOFFICEREG)&02000000L);
  76. }
  77. if(Reg&0x80)
  78. {
  79. if(Reg&0x01)
  80. PoReg = 0x00150000;
  81. else
  82. PoReg = 0x00140000;
  83. }
  84. else
  85. {
  86. if(Reg&0x01)
  87. PoReg = 0x00110000;
  88. else
  89. PoReg = 0x00100000;
  90. }
  91. memOutDword(POSTOFFICEREG, PoReg);
  92. while(memInDword(POSTOFFICEREG)&02000000L);
  93. PoReg = memInDword(POSTOFFICEREG);
  94. HostEnableIT();
  95. return ((BYTE)PoReg);
  96. }
  97. void FARAPI BoardWriteAudio(BYTE Reg, BYTE Data)
  98. {
  99. BYTE NewVideoAdr = Reg & 0x7E;
  100. DWORD PoReg=0;
  101. HostDisableIT();
  102. if(NewVideoAdr != PrevVideoAdr)
  103. {
  104. PrevVideoAdr = NewVideoAdr;
  105. PoReg = NewVideoAdr | 0x00830000;
  106. memOutDword(POSTOFFICEREG, PoReg);
  107. while(memInDword(POSTOFFICEREG)&02000000L);
  108. }
  109. if(Reg&0x80)
  110. {
  111. if(Reg&0x01)
  112. PoReg = Data | 0x00970000;
  113. else
  114. PoReg = Data | 0x00960000;
  115. }
  116. else
  117. {
  118. if(Reg&0x01)
  119. PoReg = Data | 0x00930000;
  120. else
  121. PoReg = Data | 0x00920000;
  122. }
  123. memOutDword(POSTOFFICEREG, PoReg);
  124. while(memInDword(POSTOFFICEREG)&02000000L);
  125. HostEnableIT();
  126. }
  127. void FARAPI BoardWriteVideo(BYTE Reg, BYTE Data)
  128. {
  129. BYTE NewVideoAdr = Reg & 0x7E;
  130. DWORD PoReg=0;
  131. HostDisableIT();
  132. if(NewVideoAdr != PrevVideoAdr)
  133. {
  134. PrevVideoAdr = NewVideoAdr;
  135. PoReg = NewVideoAdr | 0x00830000;
  136. memOutDword(POSTOFFICEREG, PoReg);
  137. while(memInDword(POSTOFFICEREG)&02000000L);
  138. }
  139. if(Reg&0x80)
  140. {
  141. if(Reg&0x01)
  142. PoReg = Data | 0x00970000;
  143. else
  144. PoReg = Data | 0x00960000;
  145. }
  146. else
  147. {
  148. if(Reg&0x01)
  149. PoReg = Data | 0x00930000;
  150. else
  151. PoReg = Data | 0x00920000;
  152. }
  153. memOutDword(POSTOFFICEREG, PoReg);
  154. while(memInDword(POSTOFFICEREG)&02000000L);
  155. HostEnableIT();
  156. }
  157. void FARAPI BoardSendAudio(LPBYTE lpBuffer, WORD size)
  158. {
  159. }
  160. void FARAPI BoardSendVideo(WORD * Buffer, WORD Size)
  161. {
  162. }
  163. void FARAPI BoardEnableIRQ(void)
  164. {
  165. memOutByte(INTR_CTRL+3,0x71);
  166. // DPF((Trace,"PCI Intr = %x", memInByte(INTR_CTRL+3)));
  167. }
  168. void FARAPI BoardDisableIRQ(void)
  169. {
  170. memOutByte(INTR_CTRL+3,0x00);
  171. // DPF((Trace,"PCI Intr = %x", memInByte(INTR_CTRL+3)));
  172. }
  173. void FARAPI BoardAudioSetSamplingFrequency(DWORD Frequency)
  174. {
  175. }
  176. void FARAPI BoardEnterInterrupt(void)
  177. {
  178. }
  179. void FARAPI BoardLeaveInterrupt(void)
  180. {
  181. // memOutByte(INTR_STATUS+3,0xFF);
  182. // DPF((Trace,"PCI Intr = %x", memInByte(INTR_STATUS+3)));
  183. }
  184. BOOL FARAPI BoardOpen(DWORD Base)
  185. {
  186. static char dbgstr[120];
  187. PrevVideoAdr = 0xFF;
  188. DPF((Trace,"Allocating Memory Base!!\n"));
  189. if(!AllocMemoryBase(Base, 0x1000))
  190. {
  191. DPF((Trace,"Can not covert Physical to Linear"));
  192. return FALSE;
  193. }
  194. DPF((Trace, "GPIO = %lx", memInDword(I20_GPREG)));
  195. memOutDword(I20_GPREG, 0x000000ff);
  196. Delay(100);
  197. memOutDword(I20_GPREG, 0x010000ff);
  198. Delay(100);
  199. memOutDword(I20_GPREG, 0x000000ff);
  200. Delay(100);
  201. memOutDword(I20_GPREG, 0x010000ff);
  202. Delay(4000);
  203. DPF((Trace, "GPIO = %lx", memInDword(I20_GPREG)));
  204. // Gen Purpose Directions
  205. // O I O O O O I I
  206. // SPIDO SPIDI SPICLK SPIEN SRESET STIRST STIREQ AXREQ
  207. memOutByte(I20_GPREG, 0x43);
  208. // 0 0 1 1 0 0 0 0
  209. // SPIDO SPIDI SPICLK SPIEN SRESET STIRST STIREQ AXREQ
  210. memOutByte(I20_GBREG+3, 0x30);
  211. Delay(100);
  212. // 0 0 0 1 0 0 0 0
  213. // SPIDO SPIDI SPICLK SPIEN SRESET STIRST STIREQ AXREQ
  214. memOutByte(I20_GBREG+3, 0x10);
  215. Delay(100);
  216. BoardWriteEPLD(INCTL, 0x01);
  217. Delay(100);
  218. BoardWriteEPLD(AUXCTL, 0x00);
  219. Delay(100);
  220. // 0 0 0 1 1 1 0 0
  221. // SPIDO SPIDI SPICLK SPIEN SRESET STIRST STIREQ AXREQ
  222. memOutByte(I20_GBREG+3, 0x1C);
  223. GPIOReg = 0x1C;
  224. Delay(100);
  225. memOutByte(I20_GBREG, 0x00);
  226. Delay(100);
  227. memOutByte(I20_GBREG+1, 0x00);
  228. Delay(100);
  229. BoardWriteEPLD(INCTL, 0x01);
  230. Delay(100);
  231. BoardWriteEPLD(AUXCTL, 0x00);
  232. Delay(100);
  233. BTInitEnc();
  234. BTSetVideoStandard(NTSC_PLAY);
  235. BTInitEnc();
  236. BTSetVideoStandard(NTSC_PLAY);
  237. return TRUE;
  238. }
  239. BOOL FARAPI BoardClose(void)
  240. {
  241. FreeMemoryBase();
  242. return TRUE;
  243. }
  244. void FARAPI Delay(DWORD Microseconds)
  245. {
  246. /*
  247. DWORD i, j;
  248. for (i = 0; i < Microseconds*20; i++)
  249. j = inp(0x0070)%2; // the action of reading takes about 1�s
  250. */
  251. KeStallExecutionProcessor(Microseconds);
  252. }
  253. void FARAPI BoardWriteEPLD(BYTE Reg, BYTE Data)
  254. {
  255. DWORD PoReg=0;
  256. HostDisableIT();
  257. PoReg = Data | 0x00800000 | ((DWORD)(Reg&0x07) << 16);
  258. memOutDword(POSTOFFICEREG, PoReg);
  259. while(memInDword(POSTOFFICEREG)&02000000L);
  260. HostEnableIT();
  261. }
  262. void FARAPI BoardWriteGPIOReg(BYTE Bit, BOOL Val)
  263. {
  264. BYTE x;
  265. if(Val)
  266. {
  267. x = 1 << Bit;
  268. GPIOReg |= x;
  269. memOutByte(I20_GBREG+3, GPIOReg);
  270. }
  271. else
  272. {
  273. x = 1 << Bit;
  274. x = ~x;
  275. GPIOReg &= x;
  276. memOutByte(I20_GBREG+3, GPIOReg);
  277. }
  278. }
  279. BOOL FARAPI BoardReadGPIOReg(BYTE Bit)
  280. {
  281. BYTE x;
  282. x = memInByte(I20_GBREG+3);
  283. return ((x>> Bit)&0x01);
  284. }