[CMAKE]
[reactos.git] / lib / drivers / sound / soundblaster / speaker.c
1 /*
2 ReactOS Sound System
3 Sound Blaster DSP support
4 Speaker commands
5
6 Author:
7 Andrew Greenwood (silverblade@reactos.org)
8
9 History:
10 2 July 2008 - Created (split from sbdsp.c)
11
12 Notes:
13 Functions documented in sbdsp.h
14 */
15
16 #include <ntddk.h>
17 #include <debug.h>
18
19 #include <sbdsp.h>
20
21 NTSTATUS
22 SbDspEnableSpeaker(
23 IN PUCHAR BasePort,
24 IN ULONG Timeout)
25 {
26 return SbDspWrite(BasePort, SB_DSP_SPEAKER_ON, Timeout);
27 }
28
29 NTSTATUS
30 SbDspDisableSpeaker(
31 IN PUCHAR BasePort,
32 IN ULONG Timeout)
33 {
34 return SbDspWrite(BasePort, SB_DSP_SPEAKER_OFF, Timeout);
35 }
36
37 /*
38 VirtualBox doesn't seem to support this.
39 */
40 NTSTATUS
41 SbDspIsSpeakerEnabled(
42 IN PUCHAR BasePort,
43 OUT PBOOLEAN IsEnabled,
44 IN ULONG Timeout)
45 {
46 NTSTATUS Status;
47 UCHAR SpeakerStatus = 0;
48
49 if ( ! IsEnabled )
50 return STATUS_INVALID_PARAMETER_2;
51
52 /* Request the speaker status */
53 Status = SbDspWrite(BasePort, SB_DSP_SPEAKER_STATUS, Timeout);
54 if ( Status != STATUS_SUCCESS )
55 return Status;
56
57 /* Obtain the status */
58 Status = SbDspRead(BasePort, &SpeakerStatus, Timeout);
59 if ( Status != STATUS_SUCCESS )
60 return Status;
61
62 DbgPrint("SBDSP - SpeakerStatus is %02x\n", SpeakerStatus);
63 *IsEnabled = (SpeakerStatus == 0xFF);
64
65 return STATUS_SUCCESS;
66 }