ReactOS 0.4.15-dev-8207-gd73a838
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
94typedef struct _DEVICE_EXTENSION
95{
98 ULONG Port;
99 ULONG IRQ;
107
108/*
109 DEVICE_INSTANCE contains ???
110*/
111
112typedef 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
141BOOLEAN WaitToSend(ULONG BasePort);
142BOOLEAN WaitToReceive(ULONG BasePort);
143USHORT InitSoundCard(ULONG BasePort);
144
145/*
146 Prototypes for functions in settings.c :
147*/
148
151 IN PWSTR SubKey,
154
162
163
164
165
167
168
169
170VOID SetOutputSampleRate(ULONG BasePort, ULONG SampleRate);
171VOID EnableSpeaker(ULONG BasePort, BOOLEAN SpeakerOn);
173VOID BeginPlayback(ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize);
unsigned char BOOLEAN
void LoadSettings(void)
Definition: settings.c:53
LONG NTSTATUS
Definition: precomp.h:26
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
REGISTRY_CALLBACK_ROUTINE * PREGISTRY_CALLBACK_ROUTINE
Definition: mpu401.h:121
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4207
unsigned short USHORT
Definition: pedump.c:61
NTAPI NTSTATUS REGISTRY_CALLBACK_ROUTINE(PDRIVER_OBJECT DriverObject, PWSTR RegistryPath)
Definition: sndblst.h:69
BOOLEAN SetOutputSampleRate(PSOUND_BLASTER_PARAMETERS SBDevice, ULONG SampleRate)
Definition: control.c:143
BOOLEAN EnableSpeaker(PSOUND_BLASTER_PARAMETERS SBDevice)
Definition: control.c:158
REGISTRY_CALLBACK_ROUTINE * PREGISTRY_CALLBACK_ROUTINE
Definition: sndblst.h:70
VOID BeginPlayback(ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize)
Definition: card.c:51
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
NTSTATUS NTAPI EnumDeviceKeys(IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context)
Definition: settings.c:73
struct _DEVICE_EXTENSION DEVICE_EXTENSION
BOOLEAN WaitToSend(ULONG BasePort)
Definition: portio.c:16
BOOLEAN CreateDMA(PDEVICE_OBJECT DeviceObject)
Definition: dma.c:70
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
struct _DEVICE_INSTANCE * PDEVICE_INSTANCE
BOOLEAN IsSpeakerEnabled(ULONG BasePort)
Definition: card.c:36
struct _DEVICE_INSTANCE DEVICE_INSTANCE
USHORT InitSoundCard(ULONG BasePort)
Definition: portio.c:62
PADAPTER_OBJECT Adapter
Definition: sndblst.h:102
PDRIVER_OBJECT DriverObject
Definition: mpu401.h:86
ULONG BufferSize
Definition: sndblst.h:101
PWSTR RegistryPath
Definition: sndblst.h:96
PHYSICAL_ADDRESS Buffer
Definition: sndblst.h:105
PCHAR VirtualBuffer
Definition: sndblst.h:104
PDRIVER_OBJECT DriverObject
Definition: mpu401.h:102
uint16_t * PWSTR
Definition: typedefs.h:56
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
Definition: wdfregistry.h:282
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275