3 * linux/sound/oss/dmasound/dmasound.h
6 * Minor numbers for the sound driver.
8 * Unfortunately Creative called the codec chip of SB as a DSP. For this
9 * reason the /dev/dsp is reserved for digitized audio use. There is a
10 * device for true DSP processors but it will be called something else.
11 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
15 #include <linux/types.h>
16 #include <linux/config.h>
18 #define SND_NDEVS 256 /* Number of supported devices */
19 #define SND_DEV_CTL 0 /* Control port /dev/mixer */
20 #define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM
21 synthesizer and MIDI output) */
22 #define SND_DEV_MIDIN 2 /* Raw midi access */
23 #define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
24 #define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
25 #define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
26 #define SND_DEV_STATUS 6 /* /dev/sndstat */
27 /* #7 not in use now. Was in 2.4. Free for use after v3.0. */
28 #define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
29 #define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
30 #define SND_DEV_PSS SND_DEV_SNDPROC
32 /* switch on various prinks */
33 #define DEBUG_DMASOUND 1
35 #define MAX_AUDIO_DEV 5
36 #define MAX_MIXER_DEV 4
37 #define MAX_SYNTH_DEV 3
38 #define MAX_MIDI_DEV 6
39 #define MAX_TIMER_DEV 3
41 #define MAX_CATCH_RADIUS 10
43 #define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
44 #define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
46 #define IOCTL_IN(arg, ret) \
47 do { int error = get_user(ret, (int __user *)(arg)); \
48 if (error) return error; \
50 #define IOCTL_OUT(arg, ret) ioctl_return((int __user *)(arg), ret)
52 static inline int ioctl_return(int __user
*addr
, int value
)
54 return value
< 0 ? value
: put_user(value
, addr
);
62 #undef HAS_8BIT_TABLES
65 #if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\
66 defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\
67 defined(CONFIG_DMASOUND_Q40) || defined(CONFIG_DMASOUND_Q40_MODULE)
68 #define HAS_8BIT_TABLES
70 #define MIN_BUFSIZE (1<<12) /* in bytes (- where does this come from ?) */
71 #define MIN_FRAG_SIZE 8 /* not 100% sure about this */
72 #define MAX_BUFSIZE (1<<17) /* Limit for Amiga is 128 kb */
73 #define MAX_FRAG_SIZE 15 /* allow *4 for mono-8 => stereo-16 (for multi) */
75 #else /* is pmac and multi is off */
78 #define MIN_BUFSIZE (1<<8) /* in bytes */
79 #define MIN_FRAG_SIZE 8
80 #define MAX_BUFSIZE (1<<18) /* this is somewhat arbitrary for pmac */
81 #define MAX_FRAG_SIZE 16 /* need to allow *4 for mono-8 => stereo-16 */
84 #define DEFAULT_N_BUFFERS 4
85 #define DEFAULT_BUFF_SIZE (1<<15)
87 #if defined(CONFIG_DMASOUND_PMAC) || defined(CONFIG_DMASOUND_PMAC_MODULE)
95 extern int dmasound_init(void);
97 extern void dmasound_deinit(void);
99 #define dmasound_deinit() do { } while (0)
102 /* description of the set-up applies to either hard or soft settings */
105 int format
; /* AFMT_* */
106 int stereo
; /* 0 = mono, 1 = stereo */
107 int size
; /* 8/16 bit*/
108 int speed
; /* speed */
112 * Machine definitions
118 struct module
*owner
;
119 void *(*dma_alloc
)(unsigned int, int);
120 void (*dma_free
)(void *, unsigned int);
121 int (*irqinit
)(void);
123 void (*irqcleanup
)(void);
126 void (*silence
)(void);
127 int (*setFormat
)(int);
128 int (*setVolume
)(int);
130 int (*setTreble
)(int);
133 void (*record
)(void); /* optional */
134 void (*mixer_init
)(void); /* optional */
135 int (*mixer_ioctl
)(u_int
, u_long
); /* optional */
136 int (*write_sq_setup
)(void); /* optional */
137 int (*read_sq_setup
)(void); /* optional */
138 int (*sq_open
)(mode_t
); /* optional */
139 int (*state_info
)(char *, size_t); /* optional */
140 void (*abort_read
)(void); /* optional */
144 int hardware_afmts
; /* OSS says we only return h'ware info */
145 /* when queried via SNDCTL_DSP_GETFMTS */
146 int capabilities
; /* low-level reply to SNDCTL_DSP_GETCAPS */
147 SETTINGS default_hard
; /* open() or init() should set something valid */
148 SETTINGS default_soft
; /* you can make it look like old OSS, if you want to */
156 ssize_t (*ct_ulaw
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
157 ssize_t (*ct_alaw
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
158 ssize_t (*ct_s8
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
159 ssize_t (*ct_u8
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
160 ssize_t (*ct_s16be
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
161 ssize_t (*ct_u16be
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
162 ssize_t (*ct_s16le
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
163 ssize_t (*ct_u16le
)(const u_char __user
*, size_t, u_char
*, ssize_t
*, ssize_t
);
166 struct sound_settings
{
167 MACHINE mach
; /* machine dependent things */
168 SETTINGS hard
; /* hardware settings */
169 SETTINGS soft
; /* software settings */
170 SETTINGS dsp
; /* /dev/dsp default settings */
171 TRANS
*trans_write
; /* supported translations */
173 TRANS
*trans_read
; /* supported translations */
175 int volume_left
; /* volume (range is machine dependent) */
177 int bass
; /* tone (range is machine dependent) */
180 int minDev
; /* minor device number currently open */
184 extern struct sound_settings dmasound
;
186 #ifdef HAS_8BIT_TABLES
187 extern char dmasound_ulaw2dma8
[];
188 extern char dmasound_alaw2dma8
[];
195 static inline int dmasound_set_volume(int volume
)
197 return dmasound
.mach
.setVolume(volume
);
200 static inline int dmasound_set_bass(int bass
)
202 return dmasound
.mach
.setBass
? dmasound
.mach
.setBass(bass
) : 50;
205 static inline int dmasound_set_treble(int treble
)
207 return dmasound
.mach
.setTreble
? dmasound
.mach
.setTreble(treble
) : 50;
210 static inline int dmasound_set_gain(int gain
)
212 return dmasound
.mach
.setGain
? dmasound
.mach
.setGain(gain
) : 100;
217 * Sound queue stuff, the heart of the driver
221 /* buffers allocated for this queue */
222 int numBufs
; /* real limits on what the user can have */
223 int bufSize
; /* in bytes */
226 /* current parameters */
227 int locked
; /* params cannot be modified when != 0 */
228 int user_frags
; /* user requests this many */
229 int user_frag_size
; /* of this size */
230 int max_count
; /* actual # fragments <= numBufs */
231 int block_size
; /* internal block size in bytes */
232 int max_active
; /* in-use fragments <= max_count */
234 /* it shouldn't be necessary to declare any of these volatile */
235 int front
, rear
, count
;
238 * The use of the playing field depends on the hardware
240 * Atari, PMac: The number of frames that are loaded/playing
242 * Amiga: Bit 0 is set: a frame is loaded
243 * Bit 1 is set: a frame is playing
246 wait_queue_head_t action_queue
, open_queue
, sync_queue
;
248 int busy
, syncing
, xruns
, died
;
251 #define SLEEP(queue) interruptible_sleep_on_timeout(&queue, HZ)
252 #define WAKE_UP(queue) (wake_up_interruptible(&queue))
254 extern struct sound_queue dmasound_write_sq
;
255 #define write_sq dmasound_write_sq
258 extern struct sound_queue dmasound_read_sq
;
259 #define read_sq dmasound_read_sq
262 extern int dmasound_catchRadius
;
263 #define catchRadius dmasound_catchRadius
265 /* define the value to be put in the byte-swap reg in mac-io
266 when we want it to swap for us.
270 #define SW_INPUT_VOLUME_SCALE 4
271 #define SW_INPUT_VOLUME_DEFAULT (128 / SW_INPUT_VOLUME_SCALE)
273 extern int expand_bal
; /* Balance factor for expanding (not volume!) */
274 extern int expand_read_bal
; /* Balance factor for reading */
275 extern uint software_input_volume
; /* software implemented recording volume! */
277 #endif /* _dmasound_h_ */