Windows NT 4.0 source code leak
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.

303 lines
7.9 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. findpas.c
  5. Abstract:
  6. This module contains code configuration code MediaVision's Pro audio
  7. spectrum. The card is run in Sound Blaster compatibiltiy mode.
  8. Support is provided for volume setting and line input and
  9. microphone mix level setting.
  10. The card is located by searching. No user configuration is supported.
  11. Author:
  12. Adapted from work by Robin Speed (RobinSp) 17-Oct-1992
  13. Environment:
  14. Kernel mode
  15. Revision History:
  16. --*/
  17. #include CARDTXXX_H
  18. #include "findpas.h"
  19. //--------------========================---------------------------
  20. //---------====< GLOBAL DATA SECTION >====-------------------------
  21. //--------------========================---------------------------
  22. // The board signature is the first value in the PAS 16 wakeup sequence
  23. // BC is the factory default. A board jumpered to recognize the BD signature
  24. // will not respond to a BC init command.
  25. UCHAR SignatureTable[4]={0xBC,0xBD,0xBE,0xBF};
  26. //
  27. // MPU stuff here until we work out what we want
  28. //
  29. #define MPU_ADDR 0x330
  30. #define MPU_IRQ 2
  31. #define MPU_EMUL_IRQ EMUL_IRQ_2
  32. //
  33. // Local routines
  34. //
  35. BOOLEAN
  36. VerifyProHardware(
  37. PFOUNDINFO pFI,
  38. ULONG port);
  39. BOOLEAN
  40. WakeUpAtAddress(
  41. PFOUNDINFO pFoundInfo,
  42. ULONG wPort);
  43. ; /*\
  44. ;---|*|------====< DWORD GetProTableRead() >====------
  45. ;---|*|
  46. ;---|*| Detects which version of the Pro AudioSpectrum is installed
  47. ;---|*|
  48. ;---|*| Entry Conditions:
  49. ;---|*| Pointer to Profile Structure. If the caller wants to specify
  50. ;---|*| the preferred base address for cards not yet init'd, they
  51. ;---|*| are passed in this structure. The NumFound field indicates
  52. ;---|*| the number of location requests and the board address elements
  53. ;---|*| indicate the locations.
  54. ;---|*|
  55. ;---|*| Also passed in pointer to port (the one we found in the registry
  56. ;---|*| if any
  57. ;---|*|
  58. ;---|*| Exit Conditions:
  59. ;---|*| Returns number of cards found
  60. ;---|*| ProFile structure has been updated.
  61. ;---|*|
  62. ; \*/
  63. int
  64. FindPasHardware(
  65. PFOUNDINFO pFoundInfo
  66. )
  67. // PSB_CONFIG_DATA ConfigData )
  68. {
  69. if (WakeUpAtAddress(pFoundInfo, pFoundInfo->ProPort)) {
  70. return 1;
  71. }
  72. return 0;
  73. }
  74. ; /*\
  75. ;---|*|------====< int VerifyProHardware() >====------
  76. ;---|*|
  77. ;---|*| Detects which version of the Pro AudioSpectrum is installed
  78. ;---|*|
  79. ;---|*| Entry Conditions:
  80. ;---|*| pFI - found info pointer -- has PROBase mapped I/O space.
  81. ;---|*| port - I/O port location to search -- not mapped.
  82. ;---|*|
  83. ;---|*| Exit Conditions:
  84. ;---|*| Returns TRUE if ProAudio found.
  85. ;---|*| Returns FALSE if not found.
  86. ;---|*|
  87. ; \*/
  88. BOOLEAN
  89. VerifyProHardware(
  90. PFOUNDINFO pFI,
  91. ULONG port)
  92. {
  93. UCHAR bData, bTemp;
  94. DebugPrint((DEBUG_LEVEL,"VerifyProHardware (proport %X,probase %X, port %X)\n",pFI->ProPort,pFI->PROBase,port));
  95. pFI->TranslateCode = port ^ DEFAULT_BASE;
  96. bData=PASX_IN (pFI, INTERRUPT_CTRL_REG);
  97. if (bData==0xFF) { // 0xFF usually means nothing there
  98. goto VerifyFailed;
  99. }
  100. pFI->wBoardRev= (bData >>5); // board rev is 3 topmost bits
  101. switch (pFI->wBoardRev) {
  102. #ifndef WINNT
  103. // winnt does not want support for old cards, this code recognizes
  104. // some sound blasters
  105. case PAS_VERSION_1:
  106. #endif
  107. //case PAS_PLUS: // same boardrev as PAS_SIXTEEN
  108. case PAS_STUDIO:
  109. case PAS_SIXTEEN:
  110. case PAS_CDPC:
  111. case 4: // Memphis
  112. break;
  113. default:
  114. goto VerifyFailed; // unknown hardware type
  115. }
  116. PASX_OUT(pFI, INTERRUPT_CTRL_REG, bData ^ 0xE0); // try changing version bits
  117. bTemp=PASX_IN (pFI, INTERRUPT_CTRL_REG); // they should be read only
  118. if ((bTemp & (D7+D6+D5)) != (bData & (D7+D6+D5))) {
  119. PASX_OUT(pFI, INTERRUPT_CTRL_REG, bData); // Excuse me, stranger.
  120. goto VerifyFailed;
  121. }
  122. if (pFI->wBoardRev==PAS_VERSION_1) {
  123. pFI->Caps.CapsBits.CDInterfaceType=SCSI_TYPE;
  124. //
  125. // test for Enhanced SCSI mod (U48)
  126. //
  127. PASX_OUT(pFI, ENHANCED_SCSI_DETECT_REG, 0 ); // write to try changing version bits
  128. ScsiPortStallExecution(10); // wait 10 us
  129. bTemp=PASX_IN ( pFI, ENHANCED_SCSI_DETECT_REG ); // they should be read only
  130. switch (bTemp & 1) { // bit0==1 means old SCSI PAL
  131. case 0:
  132. pFI->Caps.CapsBits.EnhancedSCSI=TRUE;
  133. // allow to fall thru
  134. case 1:
  135. goto ProVerified;
  136. }
  137. } else {
  138. // if PAS hardware installed, the reset bit can never be on
  139. bTemp=PASX_IN (pFI, SYSTEM_CONFIG_1); // get PAS config register
  140. if (bTemp & D7) { // D7 is reset bit
  141. goto VerifyFailed;
  142. }
  143. bTemp=PASX_IN (pFI, SLAVE_MODE_READ);
  144. if (bTemp & SLAVE_MODE_OPL3) {
  145. pFI->Caps.CapsBits.OPL_3=TRUE;
  146. }
  147. if (bTemp & SLAVE_MODE_16) {
  148. pFI->Caps.CapsBits.DAC16=TRUE;
  149. pFI->Caps.CapsBits.DualDAC=TRUE;
  150. // if 16-bit DAC, and not a CDPC, it has a 508 chip.
  151. // Note: PAS 16 w/ VGA will have Mixer 508 also.
  152. if (pFI->wBoardRev != PAS_CDPC) {
  153. pFI->Caps.CapsBits.Mixer_508=TRUE;
  154. }
  155. }
  156. pFI->Caps.CapsBits.CDInterfaceType=(bTemp & (D1+D0));
  157. if (pFI->Caps.CapsBits.CDInterfaceType==SCSI_TYPE) {
  158. pFI->Caps.CapsBits.SCSI_IO_16=TRUE;
  159. }
  160. pFI->Caps.CapsBits.Slot16=TRUE;
  161. pFI->Caps.CapsBits.SoundBlaster=TRUE;
  162. bTemp=PASX_IN (pFI, MASTER_MODE_READ); // get slave bits
  163. if ((bTemp & D0)==0) {
  164. pFI->Caps.CapsBits.MCA=TRUE;
  165. }
  166. if (bTemp & D2) {
  167. pFI->Caps.CapsBits.CDPC=TRUE;
  168. }
  169. pFI->wChipRev=PASX_IN (pFI, CHIP_REV);
  170. }
  171. ProVerified:
  172. DebugPrint((DEBUG_LEVEL,"\n\nFound PRO hardware at %X\n", port));
  173. pFI->ProPort=port; // found at this port
  174. return TRUE;
  175. ////////////////////////////////
  176. VerifyFailed:
  177. pFI->wBoardRev=0; // found at this port
  178. pFI->Caps.dwCaps=0; // No Board, No Caps
  179. return FALSE;
  180. }
  181. ; /*\
  182. ;---|*|------====< int WakeUpAtAddress(WORD wPort) >====------
  183. ;---|*|
  184. ;---|*| Tries to wake up sleeping relocatable hardware at a specified
  185. ;---|*| address. Does not check for hardware already in that location
  186. ;---|*| If it does wake up a card, it does the minimum amount of
  187. ;---|*| initialization to enable the hardware.
  188. ;---|*|
  189. ;---|*| Entry Conditions:
  190. ;---|*| wPort= Base I/O address to wake card up at.
  191. ;---|*|
  192. ;---|*| Exit Conditions:
  193. ;---|*| Returns TRUE if ProAudio hardware found.
  194. ;---|*| Returns FALSE if not.
  195. ;---|*|
  196. ; \*/
  197. BOOLEAN
  198. WakeUpAtAddress(
  199. PFOUNDINFO pFoundInfo,
  200. ULONG wPort)
  201. {
  202. int i,j;
  203. DebugPrint((DEBUG_LEVEL,"WakeUpAtAddress (proport %X,probase %X, port %X)\n",pFoundInfo->ProPort,pFoundInfo->PROBase,wPort));
  204. for (i = 0; i < sizeof(SignatureTable) / sizeof(SignatureTable[0]); i++) {
  205. for (j = 0; j < 20; j++) {
  206. WRITE_PORT_UCHAR(pFoundInfo->PROBase + PAS_2_WAKE_UP_REG, SignatureTable[i]);
  207. ScsiPortStallExecution(1);
  208. WRITE_PORT_UCHAR(pFoundInfo->PROBase + PAS_2_WAKE_UP_REG, (UCHAR)((wPort >> 2) & 0xFF));
  209. ScsiPortStallExecution(1);
  210. }
  211. if (VerifyProHardware(pFoundInfo, wPort)) {
  212. //
  213. // Found one - wTranslateCode translates to the board's
  214. // correct port.
  215. //
  216. pFoundInfo->Caps.CapsBits.Did_HW_Init=TRUE;
  217. if (pFoundInfo->wBoardRev > PAS_VERSION_1 ) {
  218. /* Only enable FM feature if we're going to sit at
  219. the right address */
  220. UCHAR Features = PCM_FEATURE_ENABLE | MIXER_FEATURE_ENABLE |
  221. SB_FEATURE_ENABLE | FM_FEATURE_ENABLE;
  222. PASX_OUT(pFoundInfo, FEATURE_ENABLE, Features);
  223. }
  224. return (TRUE);
  225. }
  226. }
  227. return (FALSE); // not found
  228. }