2 * Acess2 SoundBlaster16 Driver
\r
9 #include <fs_devfs.h>
\r
10 #include <drv_pci.h>
\r
11 #include <api_drv_sound.h>
\r
16 typedef struct sSB16
\r
21 // === CONSTANTS ===
\r
23 SB16_PORT_RESET = 0x6,
\r
24 SB16_PORT_READ = 0xA,
\r
25 SB16_PORT_WRITE = 0xC,
\r
26 SB16_PORT_AVAIL = 0xE
\r
28 #define SB16_BASE_PORT 0x200
\r
30 SB16_CMD_RAW8 = 0x10, // 8-bit DAC value follows
\r
31 SB16_CMD_DMAFREQ = 0x40, // followed by TIME_CONSTANT = 256 - 1000000 / frequency
\r
32 SB16_CMD_DMASTOP = 0xD0,
\r
33 SB16_CMD_SPKRON = 0xD1,
\r
34 SB16_CMD_SPKROFF = 0xD3,
\r
35 SB16_CMD_DMACONT = 0xD4,
\r
37 // DMA Types (uses channel 1)
\r
38 // - Followed by 16-bit length (well, length - 1)
\r
39 SB16_CMD_DMA_8BIT = 0x14,
\r
43 // === PROTOTYPES ===
\r
45 int SB16_Install(char **Arguments);
\r
46 void SB16_Uninstall();
\r
48 Uint64 SB16_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
\r
49 int SB16_IOCtl(tVFS_Node *Node, int ID, void *Data);
\r
52 MODULE_DEFINE(0, 0x0032, SoundBlaster16, SB16_Install, SB16_Uninstall, "PCI", NULL);
\r
53 tDevFS_Driver gBGA_DriverStruct = {
\r
54 NULL, "SoundBlaster16",
\r
56 .Write = SB16_Write,
\r
62 int SB16_Install(char **Arguments)
\r
64 int jumper_port_setting = 1; // 1-6 incl
\r
67 outb(card->Base+SB16_PORT_RESET, 1);
\r
69 outb(card->Base+SB16_PORT_RESET, 0);
\r
73 return MODULE_ERR_OK;
\r
76 void SB16_Uninstall()
\r
81 * \fn Uint64 SB16_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
\r
82 * \brief Write to the framebuffer
\r
84 Uint64 SB16_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
\r
90 * \fn int SB16_IOCtl(tVFS_Node *Node, int ID, void *Data)
\r
91 * \brief Handle messages to the device
\r
93 int SB16_IOCtl(tVFS_Node *Node, int ID, void *Data)
\r
99 int SB16_WriteDSP(tSB16 *Card, Uint8 Value)
\r
101 // Wait for the card to be ready
\r
102 while( inb(Card->Base+SB16_PORT_WRITE) & 0x80 )
\r
105 outb(Card->Base+SB16_PORT_WRITE, Value);
\r
110 Uint8 SB16_ReadDSP(tSB16 *Card)
\r
112 // Wait for bit 7 of AVAIL
\r
113 while( !(inb(card->Base+SB16_PORT_AVAIL) & 0x80) )
\r
115 return inb(card->Base+SB16_PORT_READ);
\r