ReactOS  0.4.13-dev-249-gcba1a2f
sndblst.h
Go to the documentation of this file.
1 /*
2  *
3  * COPYRIGHT: See COPYING in the top level directory
4  * PROJECT: ReactOS kernel
5  * FILE: drivers/dd/sndblst/sndblst.h
6  * PURPOSE: Sound Blaster driver header
7  * PROGRAMMER: Andrew Greenwood
8  * UPDATE HISTORY:
9  * Sept 28, 2003: Created
10  */
11 
12 #pragma once
13 
14 #include <ntddk.h>
15 
16 #define NDEBUG
17 #include <debug.h>
18 
19 #define DEFAULT_PORT 0x220
20 #define DEFAULT_IRQ 5
21 #define DEFAULT_DMA 1
22 #define DEFAULT_BUFSIZE 0x4000
23 #define DEFAULT_SAMPLERATE 11025
24 #define DEFAULT_BITDEPTH 8
25 #define DEFAULT_CHANNELS 1
26 
27 #define VALID_IRQS {5}
28 
29 #define MIN_BUFSIZE 0x1000
30 #define MAX_BUFSIZE 0x4000
31 
32 #define DEVICE_SUBKEY L"Devices"
33 #define PARMS_SUBKEY L"Parameters"
34 
35 #define REGISTRY_PORT L"Port"
36 
37 // At the moment, we just support a single device with fixed parameters:
38 #define SB_PORT DEFAULT_PORT
39 #define SB_IRQ DEFAULT_IRQ
40 #define SB_DMA DEFAULT_DMA
41 #define SB_BUFSIZE DEFAULT_BUFSIZE
42 
43 #define SB_TIMEOUT 1000000
44 
45 #define IOCTL_SOUND_BASE FILE_DEVICE_SOUND
46 #define IOCTL_WAVE_BASE 0x0000 // CORRECT?
47 
48 /* #define IOCTL_MIDI_PLAY CTL_CODE(IOCTL_SOUND_BASE, IOCTL_MIDI_BASE + 0x0006, \
49  * METHOD_BUFFERED, FILE_WRITE_ACCESS)
50  */
51 
52 // Some constants
53 
54 #define SB_DSP_READY 0xaa
55 
56 // Commands (only the ones we use)
57 
58 #define SB_SET_OUTPUT_RATE 0x41 // DSP v4.xx only
59 #define SB_SET_INPUT_RATE 0x42 // DSP v4.xx only
60 #define SB_SET_BLOCK_SIZE 0x48 // DSP v2.00 +
61 #define SB_ENABLE_SPEAKER 0xd1
62 #define SB_DISABLE_SPEAKER 0xd3
63 #define SB_GET_SPEAKER_STATUS 0xd8 // DSP v2.00 +
64 #define SB_GET_DSP_VERSION 0xe1
65 
66 
67 // Hmm... These are a weenie bit trickier than MPU401...
68 
69 #define SB_WRITE_RESET(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0x6, x)
70 #define SB_READ_DATA(bp) READ_PORT_UCHAR((PUCHAR) bp+0xa)
71 #define SB_WRITE_DATA(bp, x) WRITE_PORT_UCHAR((PUCHAR) bp+0xc, x)
72 #define SB_READ_WRITESTATUS(bp) READ_PORT_UCHAR((PUCHAR) bp+0xc)
73 #define SB_READ_READSTATUS(bp) READ_PORT_UCHAR((PUCHAR) bp+0xe)
74 
75 // Flow control
76 
77 #define SB_READY_TO_SEND(bp) \
78  SB_READ_WRITESTATUS(bp) & 0x80
79 
80 #define SB_READY_TO_RECEIVE(bp) \
81  SB_READ_READSTATUS(bp) & 0x80
82 
83 
84 #define SB_WRITE_BYTE(bp, x) \
85  if (WaitToSend(bp)) SB_WRITE_DATA(bp, x)
86 
87 //#define MPU401_READ(bp)
88 // if (WaitToRead(bp)) ... ???
89 
90 /*
91  DEVICE_EXTENSION contains the settings for each individual device
92 */
93 
94 typedef struct _DEVICE_EXTENSION
95 {
98  ULONG Port;
99  ULONG IRQ;
107 
108 /*
109  DEVICE_INSTANCE contains ???
110 */
111 
112 typedef struct _DEVICE_INSTANCE
113 {
114  // pPrevGDI
117 
118 /*
119  CONFIG contains device parameters (port/IRQ)
120  THIS STRUCTURE IS REDUNDANT
121 */
122 
123 //typedef struct _CONFIG
124 //{
125 // ULONG Port;
126 // ULONG IRQ;
127 //} CONFIG, *PCONFIG;
128 
129 /*
130  Some callback typedefs
131 */
132 
135 
136 
137 /*
138  Prototypes for functions in portio.c :
139 */
140 
141 BOOLEAN WaitToSend(ULONG BasePort);
142 BOOLEAN WaitToReceive(ULONG BasePort);
143 USHORT InitSoundCard(ULONG BasePort);
144 
145 /*
146  Prototypes for functions in settings.c :
147 */
148 
151  IN PWSTR SubKey,
153  IN PVOID Context);
154 
160  IN PVOID Context,
162 
163 
164 
165 
167 
168 
169 
170 VOID SetOutputSampleRate(ULONG BasePort, ULONG SampleRate);
171 VOID EnableSpeaker(ULONG BasePort, BOOLEAN SpeakerOn);
172 BOOLEAN IsSpeakerEnabled(ULONG BasePort);
173 VOID BeginPlayback(ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize);
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:38
BOOLEAN EnableSpeaker(PSOUND_BLASTER_PARAMETERS SBDevice)
Definition: control.c:158
PHYSICAL_ADDRESS Buffer
Definition: sndblst.h:105
uint16_t * PWSTR
Definition: typedefs.h:54
BOOLEAN WaitToSend(ULONG BasePort)
Definition: portio.c:16
_In_ PCWSTR _In_z_ PCWSTR _In_ ULONG ValueType
Definition: rtlfuncs.h:4000
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN IsSpeakerEnabled(ULONG BasePort)
Definition: card.c:36
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
BOOLEAN CreateDMA(PDEVICE_OBJECT DeviceObject)
Definition: dma.c:70
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PDRIVER_OBJECT DriverObject
Definition: mpu401.h:102
VOID BeginPlayback(ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize)
Definition: card.c:51
unsigned char BOOLEAN
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:3988
PADAPTER_OBJECT Adapter
Definition: sndblst.h:102
NTSTATUS NTAPI LoadSettings(IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Definition: settings.c:233
ULONG BufferSize
Definition: sndblst.h:101
REGISTRY_CALLBACK_ROUTINE * PREGISTRY_CALLBACK_ROUTINE
Definition: mpu401.h:121
PDRIVER_OBJECT DriverObject
Definition: mntmgr.h:16
NTSTATUS NTAPI EnumDeviceKeys(IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context)
Definition: settings.c:73
REGISTRY_CALLBACK_ROUTINE * PREGISTRY_CALLBACK_ROUTINE
Definition: sndblst.h:70
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
PWSTR RegistryPath
Definition: sndblst.h:96
struct _DEVICE_EXTENSION DEVICE_EXTENSION
_In_ GUID _In_ PVOID _In_ ULONG ValueLength
Definition: hubbusif.h:311
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
unsigned short USHORT
Definition: pedump.c:61
struct _DEVICE_INSTANCE * PDEVICE_INSTANCE
PCHAR VirtualBuffer
Definition: sndblst.h:104
USHORT InitSoundCard(ULONG BasePort)
Definition: portio.c:62
unsigned int ULONG
Definition: retypes.h:1
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
NTAPI NTSTATUS REGISTRY_CALLBACK_ROUTINE(PDRIVER_OBJECT DriverObject, PWSTR RegistryPath)
Definition: sndblst.h:69
LPFNPSPCALLBACK Callback
Definition: desk.c:111
BOOLEAN SetOutputSampleRate(PSOUND_BLASTER_PARAMETERS SBDevice, ULONG SampleRate)
Definition: control.c:143
struct _DEVICE_INSTANCE DEVICE_INSTANCE