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 "precomp.h"
17 
18 NTSTATUS
19 SbDspEnableSpeaker(
20     IN  PUCHAR BasePort,
21     IN  ULONG Timeout)
22 {
23     return SbDspWrite(BasePort, SB_DSP_SPEAKER_ON, Timeout);
24 }
25 
26 NTSTATUS
27 SbDspDisableSpeaker(
28     IN  PUCHAR BasePort,
29     IN  ULONG Timeout)
30 {
31     return SbDspWrite(BasePort, SB_DSP_SPEAKER_OFF, Timeout);
32 }
33 
34 /*
35     VirtualBox doesn't seem to support this.
36 */
37 NTSTATUS
38 SbDspIsSpeakerEnabled(
39     IN  PUCHAR BasePort,
40     OUT PBOOLEAN IsEnabled,
41     IN  ULONG Timeout)
42 {
43     NTSTATUS Status;
44     UCHAR SpeakerStatus = 0;
45 
46     if ( ! IsEnabled )
47         return STATUS_INVALID_PARAMETER_2;
48 
49     /* Request the speaker status */
50     Status = SbDspWrite(BasePort, SB_DSP_SPEAKER_STATUS, Timeout);
51     if ( Status != STATUS_SUCCESS )
52         return Status;
53 
54     /* Obtain the status */
55     Status = SbDspRead(BasePort, &SpeakerStatus, Timeout);
56     if ( Status != STATUS_SUCCESS )
57         return Status;
58 
59     DbgPrint("SBDSP - SpeakerStatus is %02x\n", SpeakerStatus);
60     *IsEnabled = (SpeakerStatus == 0xFF);
61 
62     return STATUS_SUCCESS;
63 }
64