3 Sound Blaster DSP support
7 Andrew Greenwood (silverblade@reactos.org)
10 2 July 2008 - Created (split from sbdsp.c)
13 Functions documented in sbdsp.h
28 BOOLEAN DataAvailable
= FALSE
;
30 /* Should be called from DriverEntry with this IRQL */
31 ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL
);
33 WRITE_SB_DSP_RESET(BasePort
, 0x01);
34 SleepMs(50); /* Should be enough */
35 WRITE_SB_DSP_RESET(BasePort
, 0x00);
37 Expiry
= QuerySystemTimeMs() + Timeout
;
39 /* Wait for data to be available */
40 while ( (QuerySystemTimeMs() < Expiry
) || ( Timeout
== 0) )
42 if ( SB_DSP_DATA_AVAILABLE(BasePort
) )
49 if ( ! DataAvailable
)
51 return STATUS_TIMEOUT
;
54 /* Data is available - wait for the "DSP ready" code */
55 while ( (QuerySystemTimeMs() < Expiry
) || ( Timeout
== 0) )
57 if ( READ_SB_DSP_DATA(BasePort
) == SB_DSP_READY
)
59 return STATUS_SUCCESS
;
63 return STATUS_TIMEOUT
;
71 ULONG Expiry
= QuerySystemTimeMs() + Timeout
;
73 while ( (QuerySystemTimeMs() < Expiry
) || (Timeout
== 0) )
75 if ( SB_DSP_CLEAR_TO_SEND(BasePort
) )
77 return STATUS_SUCCESS
;
81 return STATUS_TIMEOUT
;
89 ULONG Expiry
= QuerySystemTimeMs() + Timeout
;
91 while ( (QuerySystemTimeMs() < Expiry
) || (Timeout
== 0) )
93 if ( SB_DSP_DATA_AVAILABLE(BasePort
) )
95 return STATUS_SUCCESS
;
99 return STATUS_TIMEOUT
;
110 Status
= SbDspWaitToWrite(BasePort
, Timeout
);
112 if ( Status
!= STATUS_SUCCESS
)
117 DbgPrint("SBDSP - Writing %02x\n", DataByte
);
118 WRITE_SB_DSP_DATA(BasePort
, DataByte
);
120 return STATUS_SUCCESS
;
133 return STATUS_INVALID_PARAMETER_2
;
136 Status
= SbDspWaitToRead(BasePort
, Timeout
);
138 if ( Status
!= STATUS_SUCCESS
)
143 *DataByte
= READ_SB_DSP_DATA(BasePort
);
144 DbgPrint("SBDSP - Read %02x\n", *DataByte
);
146 return STATUS_SUCCESS
;