- Merge the remaining portion of the wlan-bringup branch
[reactos.git] / reactos / drivers / multimedia / audio / sndblst.old / card.c
1 /*
2 Sound card operations
3
4 http://www.cae.wisc.edu/~brodskye/sb16doc/sb16doc.html
5 */
6
7 #include <ntddk.h>
8 #include "sndblst.h"
9
10 VOID SetOutputSampleRate(ULONG BasePort, ULONG SampleRate)
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
19 SB_WRITE_BYTE(BasePort, SB_SET_OUTPUT_RATE);
20 SB_WRITE_BYTE(BasePort, SampleRate / 256); // high
21 SB_WRITE_BYTE(BasePort, SampleRate % 256); // low
22 }
23
24
25 VOID EnableSpeaker(ULONG BasePort, BOOLEAN SpeakerOn)
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 }
34
35
36 BOOLEAN IsSpeakerEnabled(ULONG BasePort)
37 {
38 DPRINT("Obtaining speaker status\n");
39
40 // if (! WaitToSend(BasePort))
41 // return FALSE;
42
43 SB_WRITE_BYTE(BasePort, SB_GET_SPEAKER_STATUS);
44 if (! WaitToReceive(BasePort))
45 return FALSE;
46
47 return SB_READ_DATA(BasePort) == 0xff;
48 }
49
50
51 VOID BeginPlayback(ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize)
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 }