ReactOS 0.4.15-dev-8235-gcd88a97
card.c
Go to the documentation of this file.
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
10VOID 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
20 SB_WRITE_BYTE(BasePort, SampleRate / 256); // high
21 SB_WRITE_BYTE(BasePort, SampleRate % 256); // low
22}
23
24
25VOID 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
37{
38 DPRINT("Obtaining speaker status\n");
39
40// if (! WaitToSend(BasePort))
41// return FALSE;
42
44 if (! WaitToReceive(BasePort))
45 return FALSE;
46
47 return SB_READ_DATA(BasePort) == 0xff;
48}
49
50
51VOID 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}
unsigned char BOOLEAN
VOID EnableSpeaker(ULONG BasePort, BOOLEAN SpeakerOn)
Definition: card.c:25
VOID BeginPlayback(ULONG BasePort, ULONG BitDepth, ULONG Channels, ULONG BlockSize)
Definition: card.c:51
VOID SetOutputSampleRate(ULONG BasePort, ULONG SampleRate)
Definition: card.c:10
BOOLEAN IsSpeakerEnabled(ULONG BasePort)
Definition: card.c:36
#define FALSE
Definition: types.h:117
BOOLEAN WaitToReceive(ULONG BasePort)
Definition: portio.c:40
#define SB_ENABLE_SPEAKER
Definition: sndblst.h:61
#define SB_DISABLE_SPEAKER
Definition: sndblst.h:62
#define SB_GET_SPEAKER_STATUS
Definition: sndblst.h:63
#define SB_SET_OUTPUT_RATE
Definition: sndblst.h:58
#define SB_READ_DATA(bp)
Definition: sndblst.h:70
#define SB_WRITE_BYTE(bp, x)
Definition: sndblst.h:84
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59