source: trunk/minix/drivers/sb16/sb16.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 6.1 KB
RevLine 
[9]1#ifndef SB16_H
2#define SB16_H
3
4#include "../drivers.h"
5#include <sys/ioc_sound.h>
6#include <minix/sound.h>
7
8
9#define SB_TIMEOUT 32000 /* timeout count */
10
11/* IRQ, base address and DMA channels */
12#define SB_IRQ 7
13#define SB_BASE_ADDR 0x220 /* 0x210, 0x220, 0x230, 0x240,
14 * 0x250, 0x260, 0x280
15 */
16#define SB_DMA_8 1 /* 0, 1, 3 */
17#define SB_DMA_16 5 /* 5, 6, 7 */
18#if _WORD_SIZE == 2
19#define DMA_SIZE 8192 /* Dma buffer MUST BE MULTIPLE OF 2 */
20#else
21#define DMA_SIZE (64 * 1024) /* Dma buffer MUST BE MULTIPLE OF 2 */
22#endif
23
24/* Some defaults for the DSP */
25#define DEFAULT_SPEED 22050 /* Sample rate */
26#define DEFAULT_BITS 8 /* Nr. of bits */
27#define DEFAULT_SIGN 0 /* 0 = unsigned, 1 = signed */
28#define DEFAULT_STEREO 0 /* 0 = mono, 1 = stereo */
29
30/* DMA port addresses */
31#define DMA8_ADDR ((SB_DMA_8 & 3) << 1) + 0x00
32#define DMA8_COUNT ((SB_DMA_8 & 3) << 1) + 0x01
33#define DMA8_MASK 0x0A
34#define DMA8_MODE 0x0B
35#define DMA8_CLEAR 0x0C
36
37
38/* If after this preprocessing stuff DMA8_PAGE is not defined
39 * the 8-bit DMA channel specified is not valid
40 */
41#if SB_DMA_8 == 0
42# define DMA8_PAGE 0x87
43#else
44# if SB_DMA_8 == 1
45# define DMA8_PAGE 0x83
46# else
47# if SB_DMA_8 == 3
48# define DMA8_PAGE 0x82
49# endif
50# endif
51#endif
52
53
54#define DMA16_ADDR ((SB_DMA_16 & 3) << 2) + 0xC0
55#define DMA16_COUNT ((SB_DMA_16 & 3) << 2) + 0xC2
56#define DMA16_MASK 0xD4
57#define DMA16_MODE 0xD6
58#define DMA16_CLEAR 0xD8
59
60
61/* If after this preprocessing stuff DMA16_PAGE is not defined
62 * the 16-bit DMA channel specified is not valid
63 */
64#if SB_DMA_16 == 5
65# define DMA16_PAGE 0x8B
66#else
67# if SB_DMA_16 == 6
68# define DMA16_PAGE 0x89
69# else
70# if SB_DMA_16 == 7
71# define DMA16_PAGE 0x8A
72# endif
73# endif
74#endif
75
76
77/* DMA modes */
78#define DMA16_AUTO_PLAY 0x58 + (SB_DMA_16 & 3)
79#define DMA16_AUTO_REC 0x54 + (SB_DMA_16 & 3)
80#define DMA8_AUTO_PLAY 0x58 + SB_DMA_8
81#define DMA8_AUTO_REC 0x54 + SB_DMA_8
82
83
84/* IO ports for soundblaster */
85#define DSP_RESET 0x6 + SB_BASE_ADDR
86#define DSP_READ 0xA + SB_BASE_ADDR
87#define DSP_WRITE 0xC + SB_BASE_ADDR
88#define DSP_COMMAND 0xC + SB_BASE_ADDR
89#define DSP_STATUS 0xC + SB_BASE_ADDR
90#define DSP_DATA_AVL 0xE + SB_BASE_ADDR
91#define DSP_DATA16_AVL 0xF + SB_BASE_ADDR
92#define MIXER_REG 0x4 + SB_BASE_ADDR
93#define MIXER_DATA 0x5 + SB_BASE_ADDR
94#define OPL3_LEFT 0x0 + SB_BASE_ADDR
95#define OPL3_RIGHT 0x2 + SB_BASE_ADDR
96#define OPL3_BOTH 0x8 + SB_BASE_ADDR
97
98
99/* DSP Commands */
100#define DSP_INPUT_RATE 0x42 /* set input sample rate */
101#define DSP_OUTPUT_RATE 0x41 /* set output sample rate */
102#define DSP_CMD_SPKON 0xD1 /* set speaker on */
103#define DSP_CMD_SPKOFF 0xD3 /* set speaker off */
104#define DSP_CMD_DMA8HALT 0xD0 /* halt DMA 8-bit operation */
105#define DSP_CMD_DMA8CONT 0xD4 /* continue DMA 8-bit operation */
106#define DSP_CMD_DMA16HALT 0xD5 /* halt DMA 16-bit operation */
107#define DSP_CMD_DMA16CONT 0xD6 /* continue DMA 16-bit operation */
108#define DSP_GET_VERSION 0xE1 /* get version number of DSP */
109#define DSP_CMD_8BITAUTO_IN 0xCE /* 8 bit auto-initialized input */
110#define DSP_CMD_8BITAUTO_OUT 0xC6 /* 8 bit auto-initialized output */
111#define DSP_CMD_16BITAUTO_IN 0xBE /* 16 bit auto-initialized input */
112#define DSP_CMD_16BITAUTO_OUT 0xB6 /* 16 bit auto-initialized output */
113#define DSP_CMD_IRQREQ8 0xF2 /* Interrupt request 8 bit */
114#define DSP_CMD_IRQREQ16 0xF3 /* Interrupt request 16 bit */
115
116
117/* DSP Modes */
118#define DSP_MODE_MONO_US 0x00 /* Mono unsigned */
119#define DSP_MODE_MONO_S 0x10 /* Mono signed */
120#define DSP_MODE_STEREO_US 0x20 /* Stereo unsigned */
121#define DSP_MODE_STEREO_S 0x30 /* Stereo signed */
122
123
124/* MIXER commands */
125#define MIXER_RESET 0x00 /* Reset */
126#define MIXER_DAC_LEVEL 0x04 /* Used for detection only */
127#define MIXER_MASTER_LEFT 0x30 /* Master volume left */
128#define MIXER_MASTER_RIGHT 0x31 /* Master volume right */
129#define MIXER_DAC_LEFT 0x32 /* Dac level left */
130#define MIXER_DAC_RIGHT 0x33 /* Dac level right */
131#define MIXER_FM_LEFT 0x34 /* Fm level left */
132#define MIXER_FM_RIGHT 0x35 /* Fm level right */
133#define MIXER_CD_LEFT 0x36 /* Cd audio level left */
134#define MIXER_CD_RIGHT 0x37 /* Cd audio level right */
135#define MIXER_LINE_LEFT 0x38 /* Line in level left */
136#define MIXER_LINE_RIGHT 0x39 /* Line in level right */
137#define MIXER_MIC_LEVEL 0x3A /* Microphone level */
138#define MIXER_PC_LEVEL 0x3B /* Pc speaker level */
139#define MIXER_OUTPUT_CTRL 0x3C /* Output control */
140#define MIXER_IN_LEFT 0x3D /* Input control left */
141#define MIXER_IN_RIGHT 0x3E /* Input control right */
142#define MIXER_GAIN_IN_LEFT 0x3F /* Input gain control left */
143#define MIXER_GAIN_IN_RIGHT 0x40 /* Input gain control right */
144#define MIXER_GAIN_OUT_LEFT 0x41 /* Output gain control left */
145#define MIXER_GAIN_OUT_RIGHT 0x42 /* Output gain control rigth */
146#define MIXER_AGC 0x43 /* Automatic gain control */
147#define MIXER_TREBLE_LEFT 0x44 /* Treble left */
148#define MIXER_TREBLE_RIGHT 0x45 /* Treble right */
149#define MIXER_BASS_LEFT 0x46 /* Bass left */
150#define MIXER_BASS_RIGHT 0x47 /* Bass right */
151#define MIXER_SET_IRQ 0x80 /* Set irq number */
152#define MIXER_SET_DMA 0x81 /* Set DMA channels */
153#define MIXER_IRQ_STATUS 0x82 /* Irq status */
154
155/* Mixer constants */
156#define MIC 0x01 /* Microphone */
157#define CD_RIGHT 0x02
158#define CD_LEFT 0x04
159#define LINE_RIGHT 0x08
160#define LINE_LEFT 0x10
161#define FM_RIGHT 0x20
162#define FM_LEFT 0x40
163
164/* DSP constants */
165#define DMA_NR_OF_BUFFERS 2
166#define DSP_MAX_SPEED 44100 /* Max sample speed in KHz */
167#define DSP_MIN_SPEED 4000 /* Min sample speed in KHz */
168#define DSP_MAX_FRAGMENT_SIZE DMA_SIZE / DMA_NR_OF_BUFFERS /* Maximum fragment size */
169#define DSP_MIN_FRAGMENT_SIZE 1024 /* Minimum fragment size */
170#define DSP_NR_OF_BUFFERS 8
171
172
173/* Number of bytes you can DMA before hitting a 64K boundary: */
174#define dma_bytes_left(phys) \
175 ((unsigned) (sizeof(int) == 2 ? 0 : 0x10000) - (unsigned) ((phys) & 0xFFFF))
176
177
178_PROTOTYPE(int mixer_set, (int reg, int data));
179_PROTOTYPE( int sb16_inb, (int port) );
180_PROTOTYPE( void sb16_outb, (int port, int value) );
181
182
183#endif /* SB16_H */
Note: See TracBrowser for help on using the repository browser.