aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/sb.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/sound/sb.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/sound/sb.h')
-rw-r--r--include/sound/sb.h360
1 files changed, 360 insertions, 0 deletions
diff --git a/include/sound/sb.h b/include/sound/sb.h
new file mode 100644
index 000000000000..7960452445e6
--- /dev/null
+++ b/include/sound/sb.h
@@ -0,0 +1,360 @@
1#ifndef __SOUND_SB_H
2#define __SOUND_SB_H
3
4/*
5 * Header file for SoundBlaster cards
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#include "pcm.h"
26#include "rawmidi.h"
27#include <linux/interrupt.h>
28#include <asm/io.h>
29
30enum sb_hw_type {
31 SB_HW_AUTO,
32 SB_HW_10,
33 SB_HW_20,
34 SB_HW_201,
35 SB_HW_PRO,
36 SB_HW_16,
37 SB_HW_16CSP, /* SB16 with CSP chip */
38 SB_HW_ALS100, /* Avance Logic ALS100 chip */
39 SB_HW_ALS4000, /* Avance Logic ALS4000 chip */
40 SB_HW_DT019X, /* Diamond Tech. DT-019X / Avance Logic ALS-007 */
41};
42
43#define SB_OPEN_PCM 0x01
44#define SB_OPEN_MIDI_INPUT 0x02
45#define SB_OPEN_MIDI_OUTPUT 0x04
46#define SB_OPEN_MIDI_INPUT_TRIGGER 0x08
47#define SB_OPEN_MIDI_OUTPUT_TRIGGER 0x10
48
49#define SB_MODE_HALT 0x00
50#define SB_MODE_PLAYBACK_8 0x01
51#define SB_MODE_PLAYBACK_16 0x02
52#define SB_MODE_PLAYBACK (SB_MODE_PLAYBACK_8 | SB_MODE_PLAYBACK_16)
53#define SB_MODE_CAPTURE_8 0x04
54#define SB_MODE_CAPTURE_16 0x08
55#define SB_MODE_CAPTURE (SB_MODE_CAPTURE_8 | SB_MODE_CAPTURE_16)
56
57#define SB_RATE_LOCK_PLAYBACK 0x10
58#define SB_RATE_LOCK_CAPTURE 0x20
59#define SB_RATE_LOCK (SB_RATE_LOCK_PLAYBACK | SB_RATE_LOCK_CAPTURE)
60
61#define SB_MPU_INPUT 1
62
63struct _snd_sb {
64 unsigned long port; /* base port of DSP chip */
65 struct resource *res_port;
66 unsigned long mpu_port; /* MPU port for SB DSP 4.0+ */
67 int irq; /* IRQ number of DSP chip */
68 int dma8; /* 8-bit DMA */
69 int dma16; /* 16-bit DMA */
70 unsigned short version; /* version of DSP chip */
71 enum sb_hw_type hardware; /* see to SB_HW_XXXX */
72
73 unsigned long alt_port; /* alternate port (ALS4000) */
74 struct pci_dev *pci; /* ALS4000 */
75
76 unsigned int open; /* see to SB_OPEN_XXXX for sb8 */
77 /* also SNDRV_SB_CSP_MODE_XXX for sb16_csp */
78 unsigned int mode; /* current mode of stream */
79 unsigned int force_mode16; /* force 16-bit mode of streams */
80 unsigned int locked_rate; /* sb16 duplex */
81 unsigned int playback_format;
82 unsigned int capture_format;
83 struct timer_list midi_timer;
84 unsigned int p_dma_size;
85 unsigned int p_period_size;
86 unsigned int c_dma_size;
87 unsigned int c_period_size;
88
89 spinlock_t mixer_lock;
90
91 char name[32];
92
93 void *csp; /* used only when CONFIG_SND_SB16_CSP is set */
94
95 snd_card_t *card;
96 snd_pcm_t *pcm;
97 snd_pcm_substream_t *playback_substream;
98 snd_pcm_substream_t *capture_substream;
99
100 snd_rawmidi_t *rmidi;
101 snd_rawmidi_substream_t *midi_substream_input;
102 snd_rawmidi_substream_t *midi_substream_output;
103 irqreturn_t (*rmidi_callback)(int irq, void *dev_id, struct pt_regs *regs);
104
105 spinlock_t reg_lock;
106 spinlock_t open_lock;
107 spinlock_t midi_input_lock;
108
109 snd_info_entry_t *proc_entry;
110};
111
112typedef struct _snd_sb sb_t;
113
114/* I/O ports */
115
116#define SBP(chip, x) ((chip)->port + s_b_SB_##x)
117#define SBP1(port, x) ((port) + s_b_SB_##x)
118
119#define s_b_SB_RESET 0x6
120#define s_b_SB_READ 0xa
121#define s_b_SB_WRITE 0xc
122#define s_b_SB_COMMAND 0xc
123#define s_b_SB_STATUS 0xc
124#define s_b_SB_DATA_AVAIL 0xe
125#define s_b_SB_DATA_AVAIL_16 0xf
126#define s_b_SB_MIXER_ADDR 0x4
127#define s_b_SB_MIXER_DATA 0x5
128#define s_b_SB_OPL3_LEFT 0x0
129#define s_b_SB_OPL3_RIGHT 0x2
130#define s_b_SB_OPL3_BOTH 0x8
131
132#define SB_DSP_OUTPUT 0x14
133#define SB_DSP_INPUT 0x24
134#define SB_DSP_BLOCK_SIZE 0x48
135#define SB_DSP_HI_OUTPUT 0x91
136#define SB_DSP_HI_INPUT 0x99
137#define SB_DSP_LO_OUTPUT_AUTO 0x1c
138#define SB_DSP_LO_INPUT_AUTO 0x2c
139#define SB_DSP_HI_OUTPUT_AUTO 0x90
140#define SB_DSP_HI_INPUT_AUTO 0x98
141#define SB_DSP_IMMED_INT 0xf2
142#define SB_DSP_GET_VERSION 0xe1
143#define SB_DSP_SPEAKER_ON 0xd1
144#define SB_DSP_SPEAKER_OFF 0xd3
145#define SB_DSP_DMA8_OFF 0xd0
146#define SB_DSP_DMA8_ON 0xd4
147#define SB_DSP_DMA8_EXIT 0xda
148#define SB_DSP_DMA16_OFF 0xd5
149#define SB_DSP_DMA16_ON 0xd6
150#define SB_DSP_DMA16_EXIT 0xd9
151#define SB_DSP_SAMPLE_RATE 0x40
152#define SB_DSP_SAMPLE_RATE_OUT 0x41
153#define SB_DSP_SAMPLE_RATE_IN 0x42
154#define SB_DSP_MONO_8BIT 0xa0
155#define SB_DSP_MONO_16BIT 0xa4
156#define SB_DSP_STEREO_8BIT 0xa8
157#define SB_DSP_STEREO_16BIT 0xac
158
159#define SB_DSP_MIDI_INPUT_IRQ 0x31
160#define SB_DSP_MIDI_UART_IRQ 0x35
161#define SB_DSP_MIDI_OUTPUT 0x38
162
163#define SB_DSP4_OUT8_AI 0xc6
164#define SB_DSP4_IN8_AI 0xce
165#define SB_DSP4_OUT16_AI 0xb6
166#define SB_DSP4_IN16_AI 0xbe
167#define SB_DSP4_MODE_UNS_MONO 0x00
168#define SB_DSP4_MODE_SIGN_MONO 0x10
169#define SB_DSP4_MODE_UNS_STEREO 0x20
170#define SB_DSP4_MODE_SIGN_STEREO 0x30
171
172#define SB_DSP4_OUTPUT 0x3c
173#define SB_DSP4_INPUT_LEFT 0x3d
174#define SB_DSP4_INPUT_RIGHT 0x3e
175
176/* registers for SB 2.0 mixer */
177#define SB_DSP20_MASTER_DEV 0x02
178#define SB_DSP20_PCM_DEV 0x0A
179#define SB_DSP20_CD_DEV 0x08
180#define SB_DSP20_FM_DEV 0x06
181
182/* registers for SB PRO mixer */
183#define SB_DSP_MASTER_DEV 0x22
184#define SB_DSP_PCM_DEV 0x04
185#define SB_DSP_LINE_DEV 0x2e
186#define SB_DSP_CD_DEV 0x28
187#define SB_DSP_FM_DEV 0x26
188#define SB_DSP_MIC_DEV 0x0a
189#define SB_DSP_CAPTURE_SOURCE 0x0c
190#define SB_DSP_CAPTURE_FILT 0x0c
191#define SB_DSP_PLAYBACK_FILT 0x0e
192#define SB_DSP_STEREO_SW 0x0e
193
194#define SB_DSP_MIXS_MIC0 0x00 /* same as MIC */
195#define SB_DSP_MIXS_CD 0x01
196#define SB_DSP_MIXS_MIC 0x02
197#define SB_DSP_MIXS_LINE 0x03
198
199/* registers (only for left channel) for SB 16 mixer */
200#define SB_DSP4_MASTER_DEV 0x30
201#define SB_DSP4_BASS_DEV 0x46
202#define SB_DSP4_TREBLE_DEV 0x44
203#define SB_DSP4_SYNTH_DEV 0x34
204#define SB_DSP4_PCM_DEV 0x32
205#define SB_DSP4_SPEAKER_DEV 0x3b
206#define SB_DSP4_LINE_DEV 0x38
207#define SB_DSP4_MIC_DEV 0x3a
208#define SB_DSP4_OUTPUT_SW 0x3c
209#define SB_DSP4_CD_DEV 0x36
210#define SB_DSP4_IGAIN_DEV 0x3f
211#define SB_DSP4_OGAIN_DEV 0x41
212#define SB_DSP4_MIC_AGC 0x43
213
214/* additional registers for SB 16 mixer */
215#define SB_DSP4_IRQSETUP 0x80
216#define SB_DSP4_DMASETUP 0x81
217#define SB_DSP4_IRQSTATUS 0x82
218#define SB_DSP4_MPUSETUP 0x84
219
220#define SB_DSP4_3DSE 0x90
221
222/* Registers for DT-019x / ALS-007 mixer */
223#define SB_DT019X_MASTER_DEV 0x62
224#define SB_DT019X_PCM_DEV 0x64
225#define SB_DT019X_SYNTH_DEV 0x66
226#define SB_DT019X_CD_DEV 0x68
227#define SB_DT019X_MIC_DEV 0x6a
228#define SB_DT019X_SPKR_DEV 0x6a
229#define SB_DT019X_LINE_DEV 0x6e
230#define SB_DT019X_OUTPUT_SW2 0x4c
231#define SB_DT019X_CAPTURE_SW 0x6c
232
233#define SB_DT019X_CAP_CD 0x02
234#define SB_DT019X_CAP_MIC 0x04
235#define SB_DT019X_CAP_LINE 0x06
236#define SB_DT019X_CAP_SYNTH 0x07
237#define SB_DT019X_CAP_MAIN 0x07
238
239#define SB_ALS4000_MONO_IO_CTRL 0x4b
240#define SB_ALS4000_MIC_IN_GAIN 0x4d
241#define SB_ALS4000_FMDAC 0x4f
242#define SB_ALS4000_3D_SND_FX 0x50
243#define SB_ALS4000_3D_TIME_DELAY 0x51
244#define SB_ALS4000_3D_AUTO_MUTE 0x52
245#define SB_ALS4000_QSOUND 0xdb
246
247/* IRQ setting bitmap */
248#define SB_IRQSETUP_IRQ9 0x01
249#define SB_IRQSETUP_IRQ5 0x02
250#define SB_IRQSETUP_IRQ7 0x04
251#define SB_IRQSETUP_IRQ10 0x08
252
253/* IRQ types */
254#define SB_IRQTYPE_8BIT 0x01
255#define SB_IRQTYPE_16BIT 0x02
256#define SB_IRQTYPE_MPUIN 0x04
257
258/* DMA setting bitmap */
259#define SB_DMASETUP_DMA0 0x01
260#define SB_DMASETUP_DMA1 0x02
261#define SB_DMASETUP_DMA3 0x08
262#define SB_DMASETUP_DMA5 0x20
263#define SB_DMASETUP_DMA6 0x40
264#define SB_DMASETUP_DMA7 0x80
265
266/*
267 *
268 */
269
270static inline void snd_sb_ack_8bit(sb_t *chip)
271{
272 inb(SBP(chip, DATA_AVAIL));
273}
274
275static inline void snd_sb_ack_16bit(sb_t *chip)
276{
277 inb(SBP(chip, DATA_AVAIL_16));
278}
279
280/* sb_common.c */
281int snd_sbdsp_command(sb_t *chip, unsigned char val);
282int snd_sbdsp_get_byte(sb_t *chip);
283int snd_sbdsp_reset(sb_t *chip);
284int snd_sbdsp_create(snd_card_t *card,
285 unsigned long port,
286 int irq,
287 irqreturn_t (*irq_handler)(int, void *, struct pt_regs *),
288 int dma8, int dma16,
289 unsigned short hardware,
290 sb_t **r_chip);
291/* sb_mixer.c */
292void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data);
293unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg);
294int snd_sbmixer_new(sb_t *chip);
295
296/* sb8_init.c */
297int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm);
298/* sb8.c */
299irqreturn_t snd_sb8dsp_interrupt(sb_t *chip);
300int snd_sb8_playback_open(snd_pcm_substream_t *substream);
301int snd_sb8_capture_open(snd_pcm_substream_t *substream);
302int snd_sb8_playback_close(snd_pcm_substream_t *substream);
303int snd_sb8_capture_close(snd_pcm_substream_t *substream);
304/* midi8.c */
305irqreturn_t snd_sb8dsp_midi_interrupt(sb_t *chip);
306int snd_sb8dsp_midi(sb_t *chip, int device, snd_rawmidi_t ** rrawmidi);
307
308/* sb16_init.c */
309int snd_sb16dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm);
310const snd_pcm_ops_t *snd_sb16dsp_get_pcm_ops(int direction);
311int snd_sb16dsp_configure(sb_t *chip);
312/* sb16.c */
313irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs);
314
315/* exported mixer stuffs */
316enum {
317 SB_MIX_SINGLE,
318 SB_MIX_DOUBLE,
319 SB_MIX_INPUT_SW,
320 SB_MIX_CAPTURE_PRO,
321 SB_MIX_CAPTURE_DT019X
322};
323
324#define SB_MIXVAL_DOUBLE(left_reg, right_reg, left_shift, right_shift, mask) \
325 ((left_reg) | ((right_reg) << 8) | ((left_shift) << 16) | ((right_shift) << 19) | ((mask) << 24))
326#define SB_MIXVAL_SINGLE(reg, shift, mask) \
327 ((reg) | ((shift) << 16) | ((mask) << 24))
328#define SB_MIXVAL_INPUT_SW(reg1, reg2, left_shift, right_shift) \
329 ((reg1) | ((reg2) << 8) | ((left_shift) << 16) | ((right_shift) << 24))
330
331int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsigned long value);
332
333/* for ease of use */
334struct sbmix_elem {
335 const char *name;
336 int type;
337 unsigned long private_value;
338};
339
340#define SB_SINGLE(xname, reg, shift, mask) \
341{ .name = xname, \
342 .type = SB_MIX_SINGLE, \
343 .private_value = SB_MIXVAL_SINGLE(reg, shift, mask) }
344
345#define SB_DOUBLE(xname, left_reg, right_reg, left_shift, right_shift, mask) \
346{ .name = xname, \
347 .type = SB_MIX_DOUBLE, \
348 .private_value = SB_MIXVAL_DOUBLE(left_reg, right_reg, left_shift, right_shift, mask) }
349
350#define SB16_INPUT_SW(xname, reg1, reg2, left_shift, right_shift) \
351{ .name = xname, \
352 .type = SB_MIX_INPUT_SW, \
353 .private_value = SB_MIXVAL_INPUT_SW(reg1, reg2, left_shift, right_shift) }
354
355static inline int snd_sbmixer_add_ctl_elem(sb_t *chip, const struct sbmix_elem *c)
356{
357 return snd_sbmixer_add_ctl(chip, c->name, 0, c->type, c->private_value);
358}
359
360#endif /* __SOUND_SB_H */