1 /*********************************************************************
5 * Turtle Beach MultiSound Sound Card Driver for Linux
7 * Some parts of this header file were derived from the Turtle Beach
8 * MultiSound Driver Development Kit.
10 * Copyright (C) 1998 Andrew Veliath
11 * Copyright (C) 1993 Turtle Beach Systems, Inc.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 * $Id: msnd.h,v 1.33 1998/11/05 20:26:18 andrewtv Exp $
29 ********************************************************************/
33 #define VERSION "0.8.2.2"
35 #define DEFSAMPLERATE DSP_DEFAULT_SPEED
36 #define DEFSAMPLESIZE AFMT_U8
39 #define DEFFIFOSIZE 128
41 #define SNDCARD_MSND 38
43 #define SRAM_BANK_SIZE 0x8000
44 #define SRAM_CNTL_START 0x7F00
46 #define DSP_BASE_ADDR 0x4000
47 #define DSP_BANK_BASE 0x4000
62 #define HP_ICR_DEF 0x00
63 #define HP_CVR_DEF 0x12
64 #define HP_ISR_DEF 0x06
65 #define HP_IVR_DEF 0x0f
66 #define HP_NU_DEF 0x00
79 #define HPICR_INIT 0x80
80 #define HPICR_HM1 0x40
81 #define HPICR_HM0 0x20
82 #define HPICR_HF1 0x10
83 #define HPICR_HF0 0x08
84 #define HPICR_TREQ 0x02
85 #define HPICR_RREQ 0x01
89 #define HPISR_HREQ 0x80
90 #define HPISR_DMA 0x40
91 #define HPISR_HF3 0x10
92 #define HPISR_HF2 0x08
93 #define HPISR_TRDY 0x04
94 #define HPISR_TXDE 0x02
95 #define HPISR_RXDF 0x01
124 #define HIMT_PLAY_DONE 0x00
125 #define HIMT_RECORD_DONE 0x01
126 #define HIMT_MIDI_EOS 0x02
127 #define HIMT_MIDI_OUT 0x03
129 #define HIMT_MIDI_IN_UCHAR 0x0E
130 #define HIMT_DSP 0x0F
132 #define HDEX_BASE 0x92
133 #define HDEX_PLAY_START (0 + HDEX_BASE)
134 #define HDEX_PLAY_STOP (1 + HDEX_BASE)
135 #define HDEX_PLAY_PAUSE (2 + HDEX_BASE)
136 #define HDEX_PLAY_RESUME (3 + HDEX_BASE)
137 #define HDEX_RECORD_START (4 + HDEX_BASE)
138 #define HDEX_RECORD_STOP (5 + HDEX_BASE)
139 #define HDEX_MIDI_IN_START (6 + HDEX_BASE)
140 #define HDEX_MIDI_IN_STOP (7 + HDEX_BASE)
141 #define HDEX_MIDI_OUT_START (8 + HDEX_BASE)
142 #define HDEX_MIDI_OUT_STOP (9 + HDEX_BASE)
143 #define HDEX_AUX_REQ (10 + HDEX_BASE)
145 #define HIWORD(l) ((WORD)((((DWORD)(l)) >> 16) & 0xFFFF))
146 #define LOWORD(l) ((WORD)(DWORD)(l))
147 #define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF))
148 #define LOBYTE(w) ((BYTE)(w))
149 #define MAKELONG(low,hi) ((long)(((WORD)(low))|(((DWORD)((WORD)(hi)))<<16)))
150 #define MAKEWORD(low,hi) ((WORD)(((BYTE)(low))|(((WORD)((BYTE)(hi)))<<8)))
152 #define PCTODSP_OFFSET(w) (USHORT)((w)/2)
153 #define PCTODSP_BASED(w) (USHORT)(((w)/2) + DSP_BASE_ADDR)
154 #define DSPTOPC_BASED(w) (((w) - DSP_BASE_ADDR) * 2)
164 # define __initfunc(f) f
165 # define __initdata /* nothing */
166 # define spin_lock_irqsave(junk,flags) do { save_flags(flags); cli(); } while (0)
167 # define spin_unlock_irqrestore(junk,flags) do { restore_flags(flags); } while (0)
171 #define JQS_wStart 0x00
172 #define JQS_wSize 0x02
173 #define JQS_wHead 0x04
174 #define JQS_wTail 0x06
175 #define JQS__size 0x08
177 /* DAQueueDataStruct */
178 #define DAQDS_wStart 0x00
179 #define DAQDS_wSize 0x02
180 #define DAQDS_wFormat 0x04
181 #define DAQDS_wSampleSize 0x06
182 #define DAQDS_wChannels 0x08
183 #define DAQDS_wSampleRate 0x0A
184 #define DAQDS_wIntMsg 0x0C
185 #define DAQDS_wFlags 0x0E
186 #define DAQDS__size 0x10
192 typedef volatile BYTE
* LPDAQD
;
201 typedef struct multisound_dev
{
202 /* Linux device info */
204 int dsp_minor
, mixer_minor
;
206 /* Hardware resources */
213 /* Motorola 56k DSP SMA */
215 volatile BYTE
*DAPQ
, *DARQ
, *MODQ
, *MIDQ
, *DSPQ
;
216 volatile WORD
*pwDSPQData
, *pwMIDQData
, *pwMODQData
;
218 /* State variables */
219 enum { msndClassic
, msndPinnacle
} type
;
222 #define F_RESETTING 0
223 #define F_HAVEDIGITAL 1
224 #define F_AUDIO_WRITE_INUSE 2
226 #define F_WRITEBLOCK 4
227 #define F_WRITEFLUSH 5
228 #define F_AUDIO_READ_INUSE 6
230 #define F_READBLOCK 8
231 #define F_EXT_MIDI_INUSE 9
232 #define F_INT_MIDI_INUSE 10
233 #define F_DISABLE_WRITE_NDELAY 11
234 wait_queue_head_t writeblock
;
235 wait_queue_head_t readblock
;
236 wait_queue_head_t writeflush
;
241 unsigned long recsrc
;
243 int right_levels
[16];
245 int calibrate_signal
;
246 int play_sample_size
, play_sample_rate
, play_channels
;
248 int rec_sample_size
, rec_sample_rate
, rec_channels
;
250 BYTE bCurrentMidiPatch
;
251 void (*inc_ref
)(void);
252 void (*dec_ref
)(void);
254 /* Digital audio FIFOs */
255 msnd_fifo DAPF
, DARF
;
257 int last_playbank
, last_recbank
;
259 /* MIDI in callback */
260 void (*midi_in_interrupt
)(struct multisound_dev
*);
264 # define mdelay(a) udelay((a) * 1000)
267 int msnd_register(multisound_dev_t
*dev
);
268 void msnd_unregister(multisound_dev_t
*dev
);
269 int msnd_get_num_devs(void);
270 multisound_dev_t
* msnd_get_dev(int i
);
272 void msnd_fifo_init(msnd_fifo
*f
);
273 void msnd_fifo_free(msnd_fifo
*f
);
274 int msnd_fifo_alloc(msnd_fifo
*f
, size_t n
);
275 void msnd_fifo_make_empty(msnd_fifo
*f
);
276 int msnd_fifo_write(msnd_fifo
*f
, const char *buf
, size_t len
, int user
);
277 int msnd_fifo_read(msnd_fifo
*f
, char *buf
, size_t len
, int user
);
279 int msnd_wait_TXDE(multisound_dev_t
*dev
);
280 int msnd_wait_HC0(multisound_dev_t
*dev
);
281 int msnd_send_dsp_cmd(multisound_dev_t
*dev
, BYTE cmd
);
282 int msnd_send_word(multisound_dev_t
*dev
, unsigned char high
,
283 unsigned char mid
, unsigned char low
);
284 int msnd_upload_host(multisound_dev_t
*dev
, char *bin
, int len
);
285 int msnd_enable_irq(multisound_dev_t
*dev
);
286 int msnd_disable_irq(multisound_dev_t
*dev
);
288 #endif /* __MSND_H */