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.

350 lines
10 KiB

  1. /*****************************************************************************
  2. * common.h - Common code used by all the sb16 miniports.
  3. *****************************************************************************
  4. * Copyright (c) 1997-2000 Microsoft Corporation. All Rights Reserved.
  5. *
  6. * A combination of random functions that are used by all the miniports.
  7. * This class also handles all the interrupts for the card.
  8. *
  9. */
  10. /*
  11. * THIS IS A BIT BROKEN FOR NOW. IT USES A SINGLETON OBJECT FOR WHICH THERE
  12. * IS ONLY ONE INSTANCE PER DRIVER. THIS MEANS THERE CAN ONLY ONE CARD
  13. * SUPPORTED IN ANY GIVEN MACHINE. THIS WILL BE FIXED.
  14. */
  15. #ifndef _COMMON_H_
  16. #define _COMMON_H_
  17. #include "stdunk.h"
  18. #include "portcls.h"
  19. #include "DMusicKS.h"
  20. #include "ksdebug.h"
  21. #include "kcom.h"
  22. /*****************************************************************************
  23. * Constants
  24. */
  25. //
  26. // Definitions for extended caps information.
  27. //
  28. #define STATIC_PID_MSSB16\
  29. 0x1c2dfaf4, 0xad9b, 0x45b7, 0xa9, 0x6f, 0xf5, 0xdf, 0x7b, 0x7e, 0x46, 0x20
  30. DEFINE_GUIDSTRUCT("1C2DFAF4-AD9B-45b7-A96F-F5DF7B7E4620", PID_MSSB16);
  31. #define PID_MSSB16 DEFINE_GUIDNAMED(PID_MSSB16)
  32. // This should match with the GUID in the inf. (ComponentId.GuidName)
  33. #define STATIC_NAME_MSSB16\
  34. 0x9a601f1c, 0x1b41, 0x4981, 0x99, 0x14, 0xac, 0x68, 0xa3, 0xa9, 0xb0, 0x7
  35. DEFINE_GUIDSTRUCT("9A601F1C-1B41-4981-9914-AC68A3A9B007", NAME_MSSB16);
  36. #define NAME_MSSB16 DEFINE_GUIDNAMED(NAME_MSSB16)
  37. #define MSSB16_VERSION 0x1
  38. #define MSSB16_REVISION 0x0
  39. //
  40. // DSP/DMA constants
  41. //
  42. #define MAXLEN_DMA_BUFFER 0x4000
  43. #define DSP_REG_CMSD0 0x00
  44. #define DSP_REG_CMSR0 0x01
  45. #define DSP_REG_CMSD1 0x02
  46. #define DSP_REG_CMSR1 0x03
  47. #define DSP_REG_MIXREG 0x04
  48. #define DSP_REG_MIXDATA 0x05
  49. #define DSP_REG_RESET 0x06
  50. #define DSP_REG_FMD0 0x08
  51. #define DSP_REG_FMR0 0x09
  52. #define DSP_REG_READ 0x0A
  53. #define DSP_REG_WRITE 0x0C
  54. #define DSP_REG_DATAAVAIL 0x0E
  55. #define DSP_REG_ACK8BIT 0x0E
  56. #define DSP_REG_ACK16BIT 0x0F
  57. //
  58. // controller commands
  59. //
  60. #define DSP_CMD_WAVEWRPIO 0x10 // wave output (programmed I/O)
  61. #define DSP_CMD_WAVEWR 0x14 // interrupt-driven 8 bit linear wave output
  62. #define DSP_CMD_WAVEWRA 0x1C // auto mode 8 bit out
  63. #define DSP_CMD_WAVERD 0x24 // interrupt-driven 8 bit linear wave input
  64. #define DSP_CMD_WAVERDA 0x2C // auto mode 8 bit in
  65. #define DSP_CMD_WAVEWRHS 0x90 // high speed mode write
  66. #define DSP_CMD_WAVERDHS 0x98 // high speed mode read
  67. #define DSP_CMD_SETSAMPRATE 0x40 // set sample rate
  68. #define DSP_CMD_SETBLCKSIZE 0x48 // set block size
  69. #define DSP_CMD_SPKRON 0xD1 // speaker on
  70. #define DSP_CMD_SPKROFF 0xD3 // speaker off
  71. #define DSP_CMD_SPKRSTATUS 0xD8 // speaker status (0=off, FF=on)
  72. #define DSP_CMD_PAUSEDMA 0xD0 // pause DMA
  73. #define DSP_CMD_CONTDMA 0xD4 // continue DMA
  74. #define DSP_CMD_HALTAUTODMA 0xDA // stop DMA autoinit mode
  75. #define DSP_CMD_INVERTER 0xE0 // byte inverter
  76. #define DSP_CMD_GETDSPVER 0xE1 // get dsp version
  77. #define DSP_CMD_GENERATEINT 0xF2 // cause sndblst to generate an interrupt.
  78. //
  79. // SB-16 support
  80. //
  81. #define DSP_CMD_SETDACRATE 0x41 // set SBPro-16 DAC rate
  82. #define DSP_CMD_SETADCRATE 0x42 // set SBPro-16 ADC rate
  83. #define DSP_CMD_STARTDAC16 0xB6 // start 16-bit DAC
  84. #define DSP_CMD_STARTADC16 0xBE // start 16-bit ADC
  85. #define DSP_CMD_STARTDAC8 0xC6 // start 8-bit DAC
  86. #define DSP_CMD_STARTADC8 0xCE // start 8-bit ADC
  87. #define DSP_CMD_PAUSEDMA16 0xD5 // pause 16-bit DMA
  88. #define DSP_CMD_CONTDMA16 0xD6 // continue 16-bit DMA
  89. #define DSP_CMD_HALTAUTODMA16 0xD9 // halt 16-bit DMA
  90. //
  91. // Indexed mixer registers
  92. //
  93. #define DSP_MIX_DATARESETIDX 0x00
  94. #define DSP_MIX_MASTERVOLIDX_L 0x00
  95. #define DSP_MIX_MASTERVOLIDX_R 0x01
  96. #define DSP_MIX_VOICEVOLIDX_L 0x02
  97. #define DSP_MIX_VOICEVOLIDX_R 0x03
  98. #define DSP_MIX_FMVOLIDX_L 0x04
  99. #define DSP_MIX_FMVOLIDX_R 0x05
  100. #define DSP_MIX_CDVOLIDX_L 0x06
  101. #define DSP_MIX_CDVOLIDX_R 0x07
  102. #define DSP_MIX_LINEVOLIDX_L 0x08
  103. #define DSP_MIX_LINEVOLIDX_R 0x09
  104. #define DSP_MIX_MICVOLIDX 0x0A
  105. #define DSP_MIX_SPKRVOLIDX 0x0B
  106. #define DSP_MIX_OUTMIXIDX 0x0C
  107. #define DSP_MIX_ADCMIXIDX_L 0x0D
  108. #define DSP_MIX_ADCMIXIDX_R 0x0E
  109. #define DSP_MIX_INGAINIDX_L 0x0F
  110. #define DSP_MIX_INGAINIDX_R 0x10
  111. #define DSP_MIX_OUTGAINIDX_L 0x11
  112. #define DSP_MIX_OUTGAINIDX_R 0x12
  113. #define DSP_MIX_AGCIDX 0x13
  114. #define DSP_MIX_TREBLEIDX_L 0x14
  115. #define DSP_MIX_TREBLEIDX_R 0x15
  116. #define DSP_MIX_BASSIDX_L 0x16
  117. #define DSP_MIX_BASSIDX_R 0x17
  118. #define DSP_MIX_BASEIDX 0x30
  119. #define DSP_MIX_MAXREGS (DSP_MIX_BASSIDX_R + 1)
  120. #define DSP_MIX_IRQCONFIG 0x80
  121. #define DSP_MIX_DMACONFIG 0x81
  122. //
  123. // Bit layout for DSP_MIX_OUTMIXIDX.
  124. //
  125. #define MIXBIT_MIC_LINEOUT 0
  126. #define MIXBIT_CD_LINEOUT_R 1
  127. #define MIXBIT_CD_LINEOUT_L 2
  128. #define MIXBIT_LINEIN_LINEOUT_R 3
  129. #define MIXBIT_LINEIN_LINEOUT_L 4
  130. //
  131. // Bit layout for DSP_MIX_ADCMIXIDX_L and DSP_MIX_ADCMIXIDX_R.
  132. //
  133. #define MIXBIT_MIC_WAVEIN 0
  134. #define MIXBIT_CD_WAVEIN_R 1
  135. #define MIXBIT_CD_WAVEIN_L 2
  136. #define MIXBIT_LINEIN_WAVEIN_R 3
  137. #define MIXBIT_LINEIN_WAVEIN_L 4
  138. #define MIXBIT_SYNTH_WAVEIN_R 5
  139. #define MIXBIT_SYNTH_WAVEIN_L 6
  140. //
  141. // Bit layout for MIXREG_MIC_AGC
  142. //
  143. #define MIXBIT_MIC_AGC 0
  144. //
  145. // MPU401 ports
  146. //
  147. #define MPU401_REG_STATUS 0x01 // Status register
  148. #define MPU401_DRR 0x40 // Output ready (for command or data)
  149. #define MPU401_DSR 0x80 // Input ready (for data)
  150. #define MPU401_REG_DATA 0x00 // Data in
  151. #define MPU401_REG_COMMAND 0x01 // Commands
  152. #define MPU401_CMD_RESET 0xFF // Reset command
  153. #define MPU401_CMD_UART 0x3F // Switch to UART mod
  154. typedef struct
  155. {
  156. PWCHAR KeyName;
  157. BYTE RegisterIndex;
  158. BYTE RegisterSetting;
  159. } MIXERSETTING,*PMIXERSETTING;
  160. // {9B564276-A9B8-49a9-8456-3341CF46F9FC}
  161. DEFINE_GUID(IID_IWaveMiniportSB16,
  162. 0x9b564276, 0xa9b8, 0x49a9, 0x84, 0x56, 0x33, 0x41, 0xcf, 0x46, 0xf9, 0xfc);
  163. /*****************************************************************************
  164. * IWaveMiniportSB16
  165. *****************************************************************************
  166. * Interface for wave miniport.
  167. */
  168. DECLARE_INTERFACE_(IWaveMiniportSB16, IUnknown)
  169. {
  170. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  171. STDMETHOD_(void,RestoreSampleRate)
  172. ( THIS
  173. ) PURE;
  174. STDMETHOD_(void,ServiceWaveISR)
  175. ( THIS
  176. ) PURE;
  177. };
  178. typedef IWaveMiniportSB16 *PWAVEMINIPORTSB16;
  179. #ifdef EVENT_SUPPORT
  180. // {885D00D1-E5E1-44c2-834B-64C4E1A79093}
  181. DEFINE_GUID(IID_ITopoMiniportSB16,
  182. 0x885d00d1, 0xe5e1, 0x44c2, 0x83, 0x4b, 0x64, 0xc4, 0xe1, 0xa7, 0x90, 0x93);
  183. /*****************************************************************************
  184. * ITopoMiniportSB16
  185. *****************************************************************************
  186. * Interface for topology miniport.
  187. */
  188. DECLARE_INTERFACE_(ITopoMiniportSB16, IUnknown)
  189. {
  190. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  191. STDMETHOD_(void,ServiceEvent)
  192. ( THIS
  193. ) PURE;
  194. };
  195. typedef ITopoMiniportSB16 *PTOPOMINIPORTSB16;
  196. #endif
  197. DEFINE_GUID(IID_IAdapterCommon,
  198. 0x7eda2950, 0xbf9f, 0x11d0, 0x87, 0x1f, 0x0, 0xa0, 0xc9, 0x11, 0xb5, 0x44);
  199. /*****************************************************************************
  200. * IAdapterCommon
  201. *****************************************************************************
  202. * Interface for adapter common object.
  203. */
  204. DECLARE_INTERFACE_(IAdapterCommon,IUnknown)
  205. {
  206. DEFINE_ABSTRACT_UNKNOWN() // For IUnknown
  207. STDMETHOD_(NTSTATUS,Init)
  208. ( THIS_
  209. IN PRESOURCELIST ResourceList,
  210. IN PDEVICE_OBJECT DeviceObject
  211. ) PURE;
  212. STDMETHOD_(PINTERRUPTSYNC,GetInterruptSync)
  213. ( THIS
  214. ) PURE;
  215. STDMETHOD_(void,SetWaveMiniport)
  216. ( THIS_
  217. IN PWAVEMINIPORTSB16 Miniport
  218. ) PURE;
  219. STDMETHOD_(BYTE,ReadController)
  220. ( THIS
  221. ) PURE;
  222. STDMETHOD_(BOOLEAN,WriteController)
  223. ( THIS_
  224. IN BYTE Value
  225. ) PURE;
  226. STDMETHOD_(NTSTATUS,ResetController)
  227. ( THIS
  228. ) PURE;
  229. STDMETHOD_(void,MixerRegWrite)
  230. ( THIS_
  231. IN BYTE Index,
  232. IN BYTE Value
  233. ) PURE;
  234. STDMETHOD_(BYTE,MixerRegRead)
  235. ( THIS_
  236. IN BYTE Index
  237. ) PURE;
  238. STDMETHOD_(void,MixerReset)
  239. ( THIS
  240. ) PURE;
  241. STDMETHOD_(NTSTATUS,RestoreMixerSettingsFromRegistry)
  242. ( THIS
  243. ) PURE;
  244. STDMETHOD_(NTSTATUS,SaveMixerSettingsToRegistry)
  245. ( THIS
  246. ) PURE;
  247. #ifdef EVENT_SUPPORT
  248. STDMETHOD_(void,SetTopologyMiniport)
  249. ( THIS_
  250. IN PTOPOMINIPORTSB16 Miniport
  251. ) PURE;
  252. #endif
  253. };
  254. typedef IAdapterCommon *PADAPTERCOMMON;
  255. /*****************************************************************************
  256. * NewAdapterCommon()
  257. *****************************************************************************
  258. * Create a new adapter common object.
  259. */
  260. NTSTATUS
  261. NewAdapterCommon
  262. (
  263. OUT PUNKNOWN * Unknown,
  264. IN REFCLSID,
  265. IN PUNKNOWN UnknownOuter OPTIONAL,
  266. IN POOL_TYPE PoolType
  267. );
  268. /*****************************************************************************
  269. * PropertyHandler_ComponentId
  270. *****************************************************************************
  271. * This is the propertyhandler for KSPROPERTY_GENERAL_COMPONENTID
  272. */
  273. NTSTATUS
  274. PropertyHandler_ComponentId
  275. (
  276. IN PPCPROPERTY_REQUEST PropertyRequest
  277. );
  278. /*****************************************************************************
  279. * AutomationFilter
  280. *****************************************************************************
  281. * This is the automation table for miniport filter.
  282. */
  283. static
  284. PCPROPERTY_ITEM PropertiesFilter[] =
  285. {
  286. {
  287. &KSPROPSETID_General,
  288. KSPROPERTY_GENERAL_COMPONENTID,
  289. KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_BASICSUPPORT,
  290. PropertyHandler_ComponentId
  291. },
  292. };
  293. DEFINE_PCAUTOMATION_TABLE_PROP(AutomationFilter, PropertiesFilter);
  294. #endif //_COMMON_H_