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.

151 lines
3.3 KiB

  1. //
  2. // MODULE : CODEDMA.C
  3. // PURPOSE : Compressed Data DMA Transfer
  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 "i20reg.h"
  21. #include "memio.h"
  22. #include "codedma.h"
  23. #include "debug.h"
  24. #include "sti3520A.h"
  25. CODEDMA CodeDma;
  26. LPCODEDMA lpCodeDma;
  27. #define ALLOCATE_DMA_BUFFER 0x8107
  28. #define RELEASE_DMA_BUFFER 0x8108
  29. #define COPY_TO_DMA_BUFFER 0x8109
  30. BOOL NEARAPI InitCodeCtl(DWORD);
  31. void NEARAPI StartTransfer(void);
  32. void NEARAPI StopTransfer(void);
  33. void NEARAPI FlushTransfer(void);
  34. WORD NEARAPI GetTransferLocation(void);
  35. DWORD NEARAPI GetCodeMemBase(void);
  36. DWORD NEARAPI GetCodeControlReg(void);
  37. BOOL NEARAPI OpenCodeCtrl(void);
  38. BOOL FARAPI CodeDmaOpen(BYTE *pDmaBuf, DWORD PhysicalAddress)
  39. {
  40. lpCodeDma = &CodeDma;
  41. lpCodeDma->WritePtr = 0;
  42. lpCodeDma->TransferCompleted = TRUE;
  43. lpCodeDma->lpBuf = pDmaBuf;
  44. return InitCodeCtl(PhysicalAddress);
  45. }
  46. BOOL FARAPI CodeDmaFlush(void)
  47. {
  48. StopTransfer();
  49. FlushTransfer();
  50. lpCodeDma->WritePtr = 0;
  51. lpCodeDma->TransferCompleted = TRUE;
  52. return TRUE;
  53. }
  54. BOOL FARAPI CodeDmaClose(void)
  55. {
  56. return TRUE;
  57. }
  58. BOOL NEARAPI InitCodeCtl(DWORD PhysicalAddress)
  59. {
  60. lpCodeDma->CodeCtl = 0x10200002;
  61. memOutDword(I20_CODECTL, lpCodeDma->CodeCtl);
  62. lpCodeDma->CodeCtl = 0x00200002;
  63. memOutDword(I20_CODECTL, lpCodeDma->CodeCtl);
  64. memOutDword(I20_CODEMB, PhysicalAddress);
  65. return TRUE;
  66. }
  67. void NEARAPI StartTransfer(void)
  68. {
  69. lpCodeDma->CodeCtl |= 0x00000080;
  70. memOutDword(I20_CODECTL, lpCodeDma->CodeCtl);
  71. }
  72. void NEARAPI StopTransfer(void)
  73. {
  74. lpCodeDma->CodeCtl &= (~(0x00000080L));
  75. memOutDword(I20_CODECTL, lpCodeDma->CodeCtl);
  76. }
  77. void NEARAPI FlushTransfer(void)
  78. {
  79. lpCodeDma->CodeCtl |= 0x10000000;
  80. memOutDword(I20_CODECTL, lpCodeDma->CodeCtl);
  81. lpCodeDma->CodeCtl &= (~0x10000000);
  82. memOutDword(I20_CODECTL, lpCodeDma->CodeCtl);
  83. }
  84. WORD NEARAPI GetTransferLocation(void)
  85. {
  86. DWORD xx;
  87. xx = memInDword(I20_CODEMP);
  88. return (WORD)(xx&0xFFFF);
  89. }
  90. DWORD FARAPI CodeDmaSendData(BYTE *lpData, DWORD Size)
  91. {
  92. DWORD Remaining, Next;
  93. if(!lpCodeDma->TransferCompleted)
  94. return 0L;
  95. if(lpCodeDma->WritePtr + Size < DMA_BUFFER_SIZE)
  96. {
  97. RtlCopyMemory((BYTE *)(lpCodeDma->lpBuf+lpCodeDma->WritePtr), lpData, Size);
  98. lpCodeDma->WritePtr += Size;
  99. return Size;
  100. }
  101. else
  102. {
  103. if(!VideoIsEnoughPlace(DMA_BUFFER_SIZE*2))
  104. return 0;
  105. Next = DMA_BUFFER_SIZE - lpCodeDma->WritePtr;
  106. if(Next)
  107. RtlCopyMemory((BYTE *)(lpCodeDma->lpBuf+lpCodeDma->WritePtr), lpData, Next);
  108. memOutDword(I20_CODEMP, 0);
  109. lpCodeDma->TransferCompleted = FALSE;
  110. lpCodeDma->WritePtr=0;
  111. StartTransfer();
  112. return Next;
  113. }
  114. }
  115. void FARAPI CodeDmaStopTransfer(void)
  116. {
  117. }
  118. void FARAPI CodeDmaStartTransfer(void)
  119. {
  120. }
  121. void FARAPI CodeDmaInterrupt(void)
  122. {
  123. StopTransfer();
  124. lpCodeDma->TransferCompleted = TRUE;
  125. }