ReactOS 0.4.15-dev-7659-ga55345b
dsp_io.c File Reference
#include "precomp.h"
Include dependency graph for dsp_io.c:

Go to the source code of this file.

Functions

NTSTATUS SbDspReset (IN PUCHAR BasePort, IN ULONG Timeout)
 
NTSTATUS SbDspWaitToWrite (IN PUCHAR BasePort, IN ULONG Timeout)
 
NTSTATUS SbDspWaitToRead (IN PUCHAR BasePort, IN ULONG Timeout)
 
NTSTATUS SbDspWrite (IN PUCHAR BasePort, IN UCHAR DataByte, IN ULONG Timeout)
 
NTSTATUS SbDspRead (IN PUCHAR BasePort, OUT PUCHAR DataByte, IN ULONG Timeout)
 

Function Documentation

◆ SbDspRead()

NTSTATUS SbDspRead ( IN PUCHAR  BasePort,
OUT PUCHAR  DataByte,
IN ULONG  Timeout 
)

Definition at line 120 of file dsp_io.c.

124{
126
127 if ( ! DataByte )
128 {
130 }
131
132 Status = SbDspWaitToRead(BasePort, Timeout);
133
134 if ( Status != STATUS_SUCCESS )
135 {
136 return Status;
137 }
138
139 *DataByte = READ_SB_DSP_DATA(BasePort);
140 DbgPrint("SBDSP - Read %02x\n", *DataByte);
141
142 return STATUS_SUCCESS;
143}
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS SbDspWaitToRead(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: dsp_io.c:81
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
static ULONG Timeout
Definition: ping.c:61
#define READ_SB_DSP_DATA(bp)
Definition: sbdsp.h:53
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by SbDspGetVersion(), and SbDspIsSpeakerEnabled().

◆ SbDspReset()

NTSTATUS SbDspReset ( IN PUCHAR  BasePort,
IN ULONG  Timeout 
)

Definition at line 19 of file dsp_io.c.

22{
23 ULONG Expiry;
24 BOOLEAN DataAvailable = FALSE;
25
26 /* Should be called from DriverEntry with this IRQL */
28
29 WRITE_SB_DSP_RESET(BasePort, 0x01);
30 SleepMs(50); /* Should be enough */
31 WRITE_SB_DSP_RESET(BasePort, 0x00);
32
33 Expiry = QuerySystemTimeMs() + Timeout;
34
35 /* Wait for data to be available */
36 while ( (QuerySystemTimeMs() < Expiry) || ( Timeout == 0) )
37 {
38 if ( SB_DSP_DATA_AVAILABLE(BasePort) )
39 {
40 DataAvailable = TRUE;
41 break;
42 }
43 }
44
45 if ( ! DataAvailable )
46 {
47 return STATUS_TIMEOUT;
48 }
49
50 /* Data is available - wait for the "DSP ready" code */
51 while ( (QuerySystemTimeMs() < Expiry) || ( Timeout == 0) )
52 {
53 if ( READ_SB_DSP_DATA(BasePort) == SB_DSP_READY )
54 {
55 return STATUS_SUCCESS;
56 }
57 }
58
59 return STATUS_TIMEOUT;
60}
unsigned char BOOLEAN
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define ASSERT(a)
Definition: mode.c:44
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define SB_DSP_READY
Definition: sndblst.h:19
#define WRITE_SB_DSP_RESET(bp, x)
Definition: sbdsp.h:47
#define SB_DSP_DATA_AVAILABLE(bp)
Definition: sbdsp.h:62
VOID SleepMs(ULONG Milliseconds)
Definition: time.c:28
ULONG QuerySystemTimeMs()
Definition: time.c:39
uint32_t ULONG
Definition: typedefs.h:59

◆ SbDspWaitToRead()

NTSTATUS SbDspWaitToRead ( IN PUCHAR  BasePort,
IN ULONG  Timeout 
)

Definition at line 81 of file dsp_io.c.

84{
85 ULONG Expiry = QuerySystemTimeMs() + Timeout;
86
87 while ( (QuerySystemTimeMs() < Expiry) || (Timeout == 0) )
88 {
89 if ( SB_DSP_DATA_AVAILABLE(BasePort) )
90 {
91 return STATUS_SUCCESS;
92 }
93 }
94
95 return STATUS_TIMEOUT;
96}

Referenced by SbDspRead().

◆ SbDspWaitToWrite()

NTSTATUS SbDspWaitToWrite ( IN PUCHAR  BasePort,
IN ULONG  Timeout 
)

Definition at line 63 of file dsp_io.c.

66{
67 ULONG Expiry = QuerySystemTimeMs() + Timeout;
68
69 while ( (QuerySystemTimeMs() < Expiry) || (Timeout == 0) )
70 {
71 if ( SB_DSP_CLEAR_TO_SEND(BasePort) )
72 {
73 return STATUS_SUCCESS;
74 }
75 }
76
77 return STATUS_TIMEOUT;
78}
#define SB_DSP_CLEAR_TO_SEND(bp)
Definition: sbdsp.h:58

Referenced by SbDspWrite().

◆ SbDspWrite()

NTSTATUS SbDspWrite ( IN PUCHAR  BasePort,
IN UCHAR  DataByte,
IN ULONG  Timeout 
)

Definition at line 99 of file dsp_io.c.

103{
105
106 Status = SbDspWaitToWrite(BasePort, Timeout);
107
108 if ( Status != STATUS_SUCCESS )
109 {
110 return Status;
111 }
112
113 DbgPrint("SBDSP - Writing %02x\n", DataByte);
114 WRITE_SB_DSP_DATA(BasePort, DataByte);
115
116 return STATUS_SUCCESS;
117}
NTSTATUS SbDspWaitToWrite(IN PUCHAR BasePort, IN ULONG Timeout)
Definition: dsp_io.c:63
#define WRITE_SB_DSP_DATA(bp, x)
Definition: sbdsp.h:54

Referenced by SbDsp4SetInputRate(), SbDsp4SetOutputRate(), SbDsp4WriteRate(), SbDspDisableSpeaker(), SbDspEnableSpeaker(), SbDspGetVersion(), and SbDspIsSpeakerEnabled().