ReactOS 0.4.15-dev-8135-g1bc6c90
sndblst.h File Reference
#include <ntddk.h>
#include <debug.h>
Include dependency graph for sndblst.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DEVICE_EXTENSION
 
struct  _DEVICE_INSTANCE
 

Macros

#define NDEBUG
 
#define DEFAULT_PORT   0x220
 
#define DEFAULT_IRQ   5
 
#define DEFAULT_DMA   1
 
#define DEFAULT_BUFSIZE   0x4000
 
#define DEFAULT_SAMPLERATE   11025
 
#define DEFAULT_BITDEPTH   8
 
#define DEFAULT_CHANNELS   1
 
#define VALID_IRQS   {5}
 
#define MIN_BUFSIZE   0x1000
 
#define MAX_BUFSIZE   0x4000
 
#define DEVICE_SUBKEY   L"Devices"
 
#define PARMS_SUBKEY   L"Parameters"
 
#define REGISTRY_PORT   L"Port"
 
#define SB_PORT   DEFAULT_PORT
 
#define SB_IRQ   DEFAULT_IRQ
 
#define SB_DMA   DEFAULT_DMA
 
#define SB_BUFSIZE   DEFAULT_BUFSIZE
 
#define SB_TIMEOUT   1000000
 
#define IOCTL_SOUND_BASE   FILE_DEVICE_SOUND
 
#define IOCTL_WAVE_BASE   0x0000
 
#define SB_DSP_READY   0xaa
 
#define SB_SET_OUTPUT_RATE   0x41
 
#define SB_SET_INPUT_RATE   0x42
 
#define SB_SET_BLOCK_SIZE   0x48
 
#define SB_ENABLE_SPEAKER   0xd1
 
#define SB_DISABLE_SPEAKER   0xd3
 
#define SB_GET_SPEAKER_STATUS   0xd8
 
#define SB_GET_DSP_VERSION   0xe1
 
#define SB_WRITE_RESET(bp, x)   WRITE_PORT_UCHAR((PUCHAR) bp+0x6, x)
 
#define SB_READ_DATA(bp)   READ_PORT_UCHAR((PUCHAR) bp+0xa)
 
#define SB_WRITE_DATA(bp, x)   WRITE_PORT_UCHAR((PUCHAR) bp+0xc, x)
 
#define SB_READ_WRITESTATUS(bp)   READ_PORT_UCHAR((PUCHAR) bp+0xc)
 
#define SB_READ_READSTATUS(bp)   READ_PORT_UCHAR((PUCHAR) bp+0xe)
 
#define SB_READY_TO_SEND(bp)    SB_READ_WRITESTATUS(bp) & 0x80
 
#define SB_READY_TO_RECEIVE(bp)    SB_READ_READSTATUS(bp) & 0x80
 
#define SB_WRITE_BYTE(bp, x)    if (WaitToSend(bp)) SB_WRITE_DATA(bp, x)
 

Typedefs

typedef struct _DEVICE_EXTENSION DEVICE_EXTENSION
 
typedef struct _DEVICE_EXTENSIONPDEVICE_EXTENSION
 
typedef struct _DEVICE_INSTANCE DEVICE_INSTANCE
 
typedef struct _DEVICE_INSTANCEPDEVICE_INSTANCE
 
typedef NTSTATUS REGISTRY_CALLBACK_ROUTINE(PWSTR RegistryPath, PVOID Context)
 
typedef REGISTRY_CALLBACK_ROUTINEPREGISTRY_CALLBACK_ROUTINE
 

Functions

BOOLEAN WaitToSend (ULONG BasePort)
 
BOOLEAN WaitToReceive (ULONG BasePort)
 
USHORT InitSoundCard (ULONG BasePort)
 
NTSTATUS NTAPI EnumDeviceKeys (IN PUNICODE_STRING RegistryPath, IN PWSTR SubKey, IN PREGISTRY_CALLBACK_ROUTINE Callback, IN PVOID Context)
 
NTSTATUS NTAPI LoadSettings (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
 
BOOLEAN CreateDMA (PDEVICE_OBJECT DeviceObject)
 
VOID SetOutputSampleRate (ULONG BasePort, ULONG SampleRate)
 
VOID EnableSpeaker (ULONG BasePort, BOOLEAN SpeakerOn)
 
BOOLEAN IsSpeakerEnabled (ULONG BasePort)
 
VOID BeginPlayback (ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize)
 

Macro Definition Documentation

◆ DEFAULT_BITDEPTH

#define DEFAULT_BITDEPTH   8

Definition at line 24 of file sndblst.h.

◆ DEFAULT_BUFSIZE

#define DEFAULT_BUFSIZE   0x4000

Definition at line 22 of file sndblst.h.

◆ DEFAULT_CHANNELS

#define DEFAULT_CHANNELS   1

Definition at line 25 of file sndblst.h.

◆ DEFAULT_DMA

#define DEFAULT_DMA   1

Definition at line 21 of file sndblst.h.

◆ DEFAULT_IRQ

#define DEFAULT_IRQ   5

Definition at line 20 of file sndblst.h.

◆ DEFAULT_PORT

#define DEFAULT_PORT   0x220

Definition at line 19 of file sndblst.h.

◆ DEFAULT_SAMPLERATE

#define DEFAULT_SAMPLERATE   11025

Definition at line 23 of file sndblst.h.

◆ DEVICE_SUBKEY

#define DEVICE_SUBKEY   L"Devices"

Definition at line 32 of file sndblst.h.

◆ IOCTL_SOUND_BASE

#define IOCTL_SOUND_BASE   FILE_DEVICE_SOUND

Definition at line 45 of file sndblst.h.

◆ IOCTL_WAVE_BASE

#define IOCTL_WAVE_BASE   0x0000

Definition at line 46 of file sndblst.h.

◆ MAX_BUFSIZE

#define MAX_BUFSIZE   0x4000

Definition at line 30 of file sndblst.h.

◆ MIN_BUFSIZE

#define MIN_BUFSIZE   0x1000

Definition at line 29 of file sndblst.h.

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file sndblst.h.

◆ PARMS_SUBKEY

#define PARMS_SUBKEY   L"Parameters"

Definition at line 33 of file sndblst.h.

◆ REGISTRY_PORT

#define REGISTRY_PORT   L"Port"

Definition at line 35 of file sndblst.h.

◆ SB_BUFSIZE

#define SB_BUFSIZE   DEFAULT_BUFSIZE

Definition at line 41 of file sndblst.h.

◆ SB_DISABLE_SPEAKER

#define SB_DISABLE_SPEAKER   0xd3

Definition at line 62 of file sndblst.h.

◆ SB_DMA

#define SB_DMA   DEFAULT_DMA

Definition at line 40 of file sndblst.h.

◆ SB_DSP_READY

#define SB_DSP_READY   0xaa

Definition at line 54 of file sndblst.h.

◆ SB_ENABLE_SPEAKER

#define SB_ENABLE_SPEAKER   0xd1

Definition at line 61 of file sndblst.h.

◆ SB_GET_DSP_VERSION

#define SB_GET_DSP_VERSION   0xe1

Definition at line 64 of file sndblst.h.

◆ SB_GET_SPEAKER_STATUS

#define SB_GET_SPEAKER_STATUS   0xd8

Definition at line 63 of file sndblst.h.

◆ SB_IRQ

#define SB_IRQ   DEFAULT_IRQ

Definition at line 39 of file sndblst.h.

◆ SB_PORT

#define SB_PORT   DEFAULT_PORT

Definition at line 38 of file sndblst.h.

◆ SB_READ_DATA

#define SB_READ_DATA (   bp)    READ_PORT_UCHAR((PUCHAR) bp+0xa)

Definition at line 70 of file sndblst.h.

◆ SB_READ_READSTATUS

#define SB_READ_READSTATUS (   bp)    READ_PORT_UCHAR((PUCHAR) bp+0xe)

Definition at line 73 of file sndblst.h.

◆ SB_READ_WRITESTATUS

#define SB_READ_WRITESTATUS (   bp)    READ_PORT_UCHAR((PUCHAR) bp+0xc)

Definition at line 72 of file sndblst.h.

◆ SB_READY_TO_RECEIVE

#define SB_READY_TO_RECEIVE (   bp)     SB_READ_READSTATUS(bp) & 0x80

Definition at line 80 of file sndblst.h.

◆ SB_READY_TO_SEND

#define SB_READY_TO_SEND (   bp)     SB_READ_WRITESTATUS(bp) & 0x80

Definition at line 77 of file sndblst.h.

◆ SB_SET_BLOCK_SIZE

#define SB_SET_BLOCK_SIZE   0x48

Definition at line 60 of file sndblst.h.

◆ SB_SET_INPUT_RATE

#define SB_SET_INPUT_RATE   0x42

Definition at line 59 of file sndblst.h.

◆ SB_SET_OUTPUT_RATE

#define SB_SET_OUTPUT_RATE   0x41

Definition at line 58 of file sndblst.h.

◆ SB_TIMEOUT

#define SB_TIMEOUT   1000000

Definition at line 43 of file sndblst.h.

◆ SB_WRITE_BYTE

#define SB_WRITE_BYTE (   bp,
  x 
)     if (WaitToSend(bp)) SB_WRITE_DATA(bp, x)

Definition at line 84 of file sndblst.h.

◆ SB_WRITE_DATA

#define SB_WRITE_DATA (   bp,
  x 
)    WRITE_PORT_UCHAR((PUCHAR) bp+0xc, x)

Definition at line 71 of file sndblst.h.

◆ SB_WRITE_RESET

#define SB_WRITE_RESET (   bp,
  x 
)    WRITE_PORT_UCHAR((PUCHAR) bp+0x6, x)

Definition at line 69 of file sndblst.h.

◆ VALID_IRQS

#define VALID_IRQS   {5}

Definition at line 27 of file sndblst.h.

Typedef Documentation

◆ DEVICE_EXTENSION

◆ DEVICE_INSTANCE

◆ PDEVICE_EXTENSION

◆ PDEVICE_INSTANCE

◆ PREGISTRY_CALLBACK_ROUTINE

Definition at line 134 of file sndblst.h.

◆ REGISTRY_CALLBACK_ROUTINE

typedef NTSTATUS REGISTRY_CALLBACK_ROUTINE(PWSTR RegistryPath, PVOID Context)

Definition at line 133 of file sndblst.h.

Function Documentation

◆ BeginPlayback()

VOID BeginPlayback ( ULONG  BasePort,
ULONG  BitDepth,
ULONG  Channels,
ULONG  BlockSize 
)

Definition at line 51 of file card.c.

52{
53 DPRINT("BeginPlayback(%d, %d, %d, %d)\n", BasePort, BitDepth, Channels, BlockSize);
54
55// switch(BitDepth)
56// {
57// case 8 : Command = 0xc0; break;
58// case 16 : Command = 0xb0; break; // Make sure we support it
59// default : Command = 0xc0;
60// }
61
62 DPRINT("Initiating playback\n");
63
64 // TEMPORARY:
65 SB_WRITE_BYTE(BasePort, 0xc6);
66 SB_WRITE_BYTE(BasePort, 0); // mode - TEMPORARY
67 SB_WRITE_BYTE(BasePort, BlockSize % 256);
68 SB_WRITE_BYTE(BasePort, BlockSize / 256);
69}
#define SB_WRITE_BYTE(bp, x)
Definition: sndblst.h:84
#define DPRINT
Definition: sndvol32.h:73

Referenced by InitDevice().

◆ CreateDMA()

BOOLEAN CreateDMA ( PDEVICE_OBJECT  DeviceObject)

Definition at line 70 of file dma.c.

71{
73 ULONG MappedRegs = 0;
74 PDEVICE_EXTENSION Device = DeviceObject->DeviceExtension;
75 KEVENT DMAEvent;
77
78 // Buffersize should already be set but it isn't yet !
79 Device->BufferSize = SB_BUFSIZE;
80 DPRINT("Bufsize == %u\n", Device->BufferSize);
81
82 RtlZeroMemory(&Desc, sizeof(DEVICE_DESCRIPTION));
83
84 // Init memory!
86 Desc.Master = FALSE; // Slave
87 Desc.ScatterGather = FALSE; // Don't think so anyway
88 Desc.DemandMode = FALSE; // == !SingleModeDMA
89 Desc.AutoInitialize = TRUE; // ?
90 Desc.Dma32BitAddresses = FALSE; // I don't think we can
91 Desc.IgnoreCount = FALSE; // Should be OK
92 Desc.Reserved1 = 0;
93// Desc.Reserved2 = 0;
94 Desc.BusNumber = 0;
95 Desc.DmaChannel = Device->DMA; // Our channel :)
96 Desc.InterfaceType = Isa; // (BusType == MicroChannel) ? MicroChannel : Isa;
97 Desc.DmaWidth = 0; // hmm... 8 bits?
98 Desc.DmaSpeed = 0; // double hmm (Compatible it should be)
99 Desc.MaximumLength = Device->BufferSize;
100// Desc.MinimumLength = 0;
101 Desc.DmaPort = 0;
102
103 DPRINT("Calling HalGetAdapter(), asking for %d mapped regs\n", MappedRegs);
104
105 Device->Adapter = HalGetAdapter(&Desc, &MappedRegs);
106
107 DPRINT("Called\n");
108
109 if (! Device->Adapter)
110 {
111 DPRINT("HalGetAdapter() FAILED\n");
112 return FALSE;
113 }
114
115 DPRINT("Bufsize == %u\n", Device->BufferSize);
116
117 if (MappedRegs < BYTES_TO_PAGES(Device->BufferSize))
118 {
119 DPRINT("Could only allocate %u mapping registers\n", MappedRegs);
120
121 if (MappedRegs == 0)
122 return FALSE;
123
124 Device->BufferSize = MappedRegs * PAGE_SIZE;
125 DPRINT("Bufsize == %u\n", Device->BufferSize);
126 }
127
128 DPRINT("Allocated %u mapping registers\n", MappedRegs);
129
130 // Check if we already have memory here...
131
132 // Check to make sure we're >= minimum
133
134 DPRINT("Allocating buffer\n");
135
136 DPRINT("Bufsize == %u\n", Device->BufferSize);
137
138 Device->VirtualBuffer = HalAllocateCommonBuffer(Device->Adapter, Device->BufferSize,
139 &Device->Buffer, FALSE);
140
141 // For some reason BufferSize == 0 here?!
142// DPRINT("Buffer == 0x%x Bufsize == %u\n", Device->Buffer, Device->BufferSize);
143 DPRINT("Bufsize == %u,", Device->BufferSize);
144 DPRINT("Buffer == 0x%x\n", Device->Buffer);
145
146 if (! Device->VirtualBuffer)
147 {
148 DPRINT("Could not allocate buffer :(\n");
149 // should try again with smaller buffer...
150 return FALSE;
151 }
152
153// DPRINT("Buffer == 0x%x Bufsize == %u\n", Device->Buffer, Device->BufferSize);
154 DPRINT("Bufsize == %u,", Device->BufferSize);
155 DPRINT("Buffer == 0x%x\n", Device->Buffer);
156
157 DPRINT("Calling IoAllocateMdl()\n");
158 Device->Mdl = IoAllocateMdl(Device->VirtualBuffer, Device->BufferSize, FALSE, FALSE, NULL);
159 DPRINT("Bufsize == %u\n", Device->BufferSize);
160
161 // IS THIS RIGHT:
162 if (! Device->Mdl)
163 {
164 DPRINT("IoAllocateMdl() FAILED\n");
165 // Free the HAL buffer
166 return FALSE;
167 }
168
169 DPRINT("VBuffer == 0x%x Mdl == %u Bufsize == %u\n", Device->VirtualBuffer, Device->Mdl, Device->BufferSize);
170
171 DPRINT("Calling MmBuildMdlForNonPagedPool\n");
173
174 DPRINT("Bufsize == %u\n", Device->BufferSize);
175
176 // part II:
178 // Raise IRQL
181 BYTES_TO_PAGES(Device->BufferSize),
182 SoundProgramDMA, &DMAEvent);
183 // Lower IRQL
185 DPRINT("VBuffer == 0x%x Bufsize == %u\n", Device->VirtualBuffer, Device->BufferSize);
187
188
189// if (MappedRegs == 0)
190// MappedRegs = 2;
191// else
192// MappedRegs ++;
193
194
195// Status = IoAllocateAdapterChannel(
196// Adapter,
197// DeviceObject,
198// MappedRegs,
199// CALLBACK,
200// DeviceObject); // Context
201 return TRUE;
202}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static IO_ALLOCATION_ACTION NTAPI SoundProgramDMA(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID MapRegisterBase, IN PVOID Context)
Definition: dma.c:37
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define IoAllocateMdl
Definition: fxmdl.h:88
PVOID NTAPI HalAllocateCommonBuffer(IN PADAPTER_OBJECT AdapterObject, IN ULONG Length, IN PPHYSICAL_ADDRESS LogicalAddress, IN BOOLEAN CacheEnabled)
Definition: dma.c:46
PADAPTER_OBJECT NTAPI HalGetAdapter(IN PDEVICE_DESCRIPTION DeviceDescription, OUT PULONG NumberOfMapRegisters)
Definition: dma.c:22
@ Isa
Definition: hwresource.cpp:138
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:424
#define KernelMode
Definition: asm.h:34
@ SynchronizationEvent
NTSTATUS NTAPI IoAllocateAdapterChannel(IN PADAPTER_OBJECT AdapterObject, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine, IN PVOID Context)
Definition: adapter.c:30
#define SB_BUFSIZE
Definition: sndblst.h:41
DMA_SPEED DmaSpeed
Definition: iotypes.h:2082
BOOLEAN IgnoreCount
Definition: iotypes.h:2075
BOOLEAN ScatterGather
Definition: iotypes.h:2071
BOOLEAN AutoInitialize
Definition: iotypes.h:2073
DMA_WIDTH DmaWidth
Definition: iotypes.h:2081
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2080
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2074
BOOLEAN DemandMode
Definition: iotypes.h:2072
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define DEVICE_DESCRIPTION_VERSION
Definition: iotypes.h:2063
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
@ Executive
Definition: ketypes.h:415
#define BYTES_TO_PAGES(Size)

Referenced by InitDevice().

◆ EnableSpeaker()

VOID EnableSpeaker ( ULONG  BasePort,
BOOLEAN  SpeakerOn 
)

Definition at line 25 of file card.c.

26{
27 DPRINT("Setting speaker status %d\n", SpeakerOn);
28
29// if (! WaitForWrite(BasePort))
30// return;
31
32 SB_WRITE_BYTE(BasePort, SpeakerOn ? SB_ENABLE_SPEAKER : SB_DISABLE_SPEAKER);
33}
#define SB_ENABLE_SPEAKER
Definition: sndblst.h:61
#define SB_DISABLE_SPEAKER
Definition: sndblst.h:62

◆ EnumDeviceKeys()

NTSTATUS NTAPI EnumDeviceKeys ( IN PUNICODE_STRING  RegistryPath,
IN PWSTR  SubKey,
IN PREGISTRY_CALLBACK_ROUTINE  Callback,
IN PVOID  Context 
)

Definition at line 73 of file settings.c.

92{
93 NTSTATUS s;
95 HANDLE hKey, hSubKey;
97 ULONG i;
98
99 // Attempt to open the key
100
103
104 s = ZwOpenKey(&hKey, KEY_READ, &oa);
105
106 TEST_STATUS(s); // debugging
107
108 if (! NT_SUCCESS(s))
109 return s; // Problem
110
112
113 DPRINT("Subkey: %wZ\n", &SubkeyName);
114
117
118 s = ZwOpenKey(&hSubKey, KEY_ENUMERATE_SUB_KEYS, &oa);
119
120 ZwClose(hKey);
121
122 TEST_STATUS(s); // debugging
123
124 if (! NT_SUCCESS(s))
125 return s;
126
127
128 // And now, the enumeration
129
130 for (i = 0;; i ++)
131 {
135 ULONG Size = 0;
136 PWSTR Pos;
137 PWSTR Name;
138
139 // Find the length of the subkey data
140
141// Info.NameLength = 0; // TEMPORARY!
142
143 s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, &Info,
144 sizeof(Info), &ResultLength);
145
147 break;
148
149 DPRINT("Found an entry, allocating memory...\n");
150
151// Size = Info.NameLength + FIELD_OFFSET(KEY_BASIC_INFORMATION, Name[0]);
153
154 DPRINT("Size is %d\n", Size);
155
157
158 if (pInfo == NULL)
159 {
160 DPRINT("INSUFFICIENT RESOURCES!\n");
162 break;
163 }
164
165 DPRINT("Re-enumerating...\n");
166
167 s = ZwEnumerateKey(hSubKey, i, KeyBasicInformation, pInfo, Size,
168 &ResultLength);
169
170// TEST_STATUS(s); // debugging
171
172 if (! NT_SUCCESS(s))
173 {
174 ExFreePool((PVOID) pInfo);
176 break;
177 }
178
179 DPRINT("Allocating memory for name...\n");
180
182 RegistryPath->Length + sizeof(WCHAR) +
183 SubkeyName.Length + sizeof(WCHAR) +
184 pInfo->NameLength + sizeof(UNICODE_NULL));
185
186 if (Name == NULL)
187 {
188 DPRINT("INSUFFICIENT RESOURCES!");
189 ExFreePool((PVOID) pInfo);
191 }
192
193 // Copy the key name
195 Pos = Name + (RegistryPath->Length / sizeof(WCHAR));
196 Pos[0] = '\\';
197 Pos++;
198
199 // Copy the parameters sub key name
200 RtlCopyMemory((PVOID)Pos, (PVOID)SubKey, SubkeyName.Length); //SubkeyName?
201 Pos += SubkeyName.Length / sizeof(WCHAR);
202 Pos[0] = '\\';
203 Pos ++;
204
205 // Copy the device sub key name
206 RtlCopyMemory((PVOID)Pos, (PVOID)pInfo->Name, pInfo->NameLength);
207 Pos += pInfo->NameLength / sizeof(WCHAR);
208 Pos[0] = UNICODE_NULL;
209
210 ExFreePool((PVOID)pInfo);
211
212 DPRINT("Calling callback...\n");
213
214 s = (*Callback)(Name, Context);
215
216 if (! NT_SUCCESS(s))
217 { DPRINT("Callback FAILED\n");
218 break;}
219 }
220
221 ZwClose(hSubKey);
222
223 DPRINT("%d device registry keys found\n", i);
224
225 if ((i == 0) && (s == STATUS_NO_MORE_ENTRIES))
227
229}
struct NameRec_ * Name
Definition: cdprocs.h:460
LONG NTSTATUS
Definition: precomp.h:26
_In_opt_ PWSTR SubkeyName
Definition: cdrom.h:960
ush Pos
Definition: deflate.h:92
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define PagedPool
Definition: env_spec_w32.h:308
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
FxAutoRegKey hKey
GLdouble s
Definition: gl.h:2039
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define TEST_STATUS(s)
Definition: sbdebug.h:2
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
@ KeyBasicInformation
Definition: nt_native.h:1131
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _KEY_BASIC_INFORMATION * PKEY_BASIC_INFORMATION
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define UNICODE_NULL
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:465
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:205
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
#define STATUS_SUCCESS
Definition: shellext.h:65
uint16_t * PWSTR
Definition: typedefs.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
Definition: wdfdevice.h:3776
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ InitSoundCard()

USHORT InitSoundCard ( ULONG  BasePort)

Definition at line 62 of file portio.c.

63{
64 ULONG TimeOut;
66 UCHAR DSP_Major, DSP_Minor;
67
68 DPRINT("InitSoundCard() called\n");
69
70 DPRINT("Resetting sound card\n");
71// if (!WaitToSend(BasePort))
72// return FALSE;
73
74 SB_WRITE_RESET(BasePort, 0x01);
75 for (TimeOut = 0; TimeOut < 30000; TimeOut ++); // Wait a while
76 SB_WRITE_RESET(BasePort, 0x00);
77
78 // Check if it's OK to receive (some cards will ignore the above reset
79 // command and so will not issue an ACK, so time out is NOT an error)
80 DPRINT("Waiting for an ACK\n");
81 if (WaitToReceive(BasePort))
82 {
83 // Check to make sure the reset was acknowledged:
84 for (TimeOut = SB_TIMEOUT;
85 (Status = (SB_READ_DATA(BasePort) != SB_DSP_READY) && (TimeOut > 0));
86 TimeOut --);
87 }
88
89 DPRINT("Querying DSP version\n");
90 if (! WaitToSend(BasePort))
91 return FALSE;
92
94
95 if (! WaitToReceive(BasePort))
96 return FALSE;
97
98 DSP_Major = SB_READ_DATA(BasePort);
99 DSP_Minor = SB_READ_DATA(BasePort);
100
101 DPRINT("DSP v%d.%d\n", DSP_Major, DSP_Minor);
102
103 // if audio is disabled,
104 // version tests return 0xFF everywhere
105 if (DSP_Major == 0xFF && DSP_Minor == 0xFF)
106 return FALSE;
107
108 DPRINT("Sound card initialized!\n");
109
110 return (DSP_Major * 256) + DSP_Minor;
111}
unsigned char BOOLEAN
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
BOOLEAN WaitToSend(ULONG BasePort)
Definition: portio.c:16
Status
Definition: gdiplustypes.h:25
#define SB_TIMEOUT
Definition: sndblst.h:17
#define SB_DSP_READY
Definition: sndblst.h:19
#define SB_GET_DSP_VERSION
Definition: sndblst.h:64
#define SB_WRITE_RESET(bp, x)
Definition: sndblst.h:69
#define SB_WRITE_DATA(bp, x)
Definition: sndblst.h:71
#define SB_READ_DATA(bp)
Definition: sndblst.h:70
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by InitDevice().

◆ IsSpeakerEnabled()

BOOLEAN IsSpeakerEnabled ( ULONG  BasePort)

Definition at line 36 of file card.c.

37{
38 DPRINT("Obtaining speaker status\n");
39
40// if (! WaitToSend(BasePort))
41// return FALSE;
42
44 if (! WaitToReceive(BasePort))
45 return FALSE;
46
47 return SB_READ_DATA(BasePort) == 0xff;
48}
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
#define SB_GET_SPEAKER_STATUS
Definition: sndblst.h:63

◆ LoadSettings()

NTSTATUS NTAPI LoadSettings ( IN PWSTR  ValueName,
IN ULONG  ValueType,
IN PVOID  ValueData,
IN ULONG  ValueLength,
IN PVOID  Context,
IN PVOID  EntryContext 
)

Definition at line 233 of file settings.c.

255{
257
258 if (ValueType == REG_DWORD)
259 {
261 {
262 DeviceInfo->Port = *(PULONG) ValueData;
263 DPRINT("Registry port = 0x%x\n", DeviceInfo->Port);
264 }
265
266 // More to come... (config.c)
267 }
268
269 else
270 {
271 // ?
272 }
273
274 return STATUS_SUCCESS;
275}
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
#define REGISTRY_PORT
Definition: mpu401.h:25
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
uint32_t * PULONG
Definition: typedefs.h:59
_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

◆ SetOutputSampleRate()

VOID SetOutputSampleRate ( ULONG  BasePort,
ULONG  SampleRate 
)

Definition at line 10 of file card.c.

11{
12 // This only works for DSP v4.xx ONLY - need a workaround!
13 DPRINT("Setting output sample rate\n");
14
15 // WAIT
16// if (! WaitToSend(BasePort))
17// return;
18
20 SB_WRITE_BYTE(BasePort, SampleRate / 256); // high
21 SB_WRITE_BYTE(BasePort, SampleRate % 256); // low
22}
#define SB_SET_OUTPUT_RATE
Definition: sndblst.h:58

◆ WaitToReceive()

BOOLEAN WaitToReceive ( ULONG  BasePort)

Definition at line 40 of file portio.c.

41{
42 int TimeOut;
43
44 DbgPrint("WaitToSend ");
45
46 // Check if it's OK to receive
47 for (TimeOut = MPU401_TIMEOUT;
48 ! MPU401_READY_TO_RECEIVE(BasePort) && TimeOut > 0;
49 TimeOut --);
50
51 // If a time-out occurs, we report failure
52 if (! TimeOut)
53 {
54 DbgPrint("FAILED\n");
55 return FALSE;
56 }
57
58 DbgPrint("SUCCEEDED\n");
59
60 return TRUE;
61}
#define DbgPrint
Definition: hal.h:12
#define MPU401_TIMEOUT
Definition: mpu401.h:31
#define MPU401_READY_TO_RECEIVE(bp)
Definition: mpu401.h:64

Referenced by InitSoundCard(), and InitUARTMode().

◆ WaitToSend()

BOOLEAN WaitToSend ( ULONG  BasePort)

Definition at line 16 of file portio.c.

17{
18 int TimeOut;
19
20 DbgPrint("WaitToSend ");
21
22 // Check if it's OK to send
23 for (TimeOut = MPU401_TIMEOUT;
24 ! MPU401_READY_TO_SEND(BasePort) && TimeOut > 0;
25 TimeOut --);
26
27 // If a time-out occurs, we report failure
28 if (! TimeOut)
29 {
30 DbgPrint("FAILED\n");
31 return FALSE;
32 }
33
34 DbgPrint("SUCCEEDED\n");
35
36 return TRUE;
37}
#define MPU401_READY_TO_SEND(bp)
Definition: mpu401.h:61

Referenced by InitSoundCard(), and InitUARTMode().