Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _dmasound_h_
3/*
4 * linux/sound/oss/dmasound/dmasound.h
5 *
6 *
7 * Minor numbers for the sound driver.
8 *
9 * Unfortunately Creative called the codec chip of SB as a DSP. For this
10 * reason the /dev/dsp is reserved for digitized audio use. There is a
11 * device for true DSP processors but it will be called something else.
12 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
13 */
14#define _dmasound_h_
15
16#include <linux/types.h>
17
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
31
32/* switch on various prinks */
33#define DEBUG_DMASOUND 1
34
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
40
41#define MAX_CATCH_RADIUS 10
42
43#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
44#define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
45
46#define IOCTL_IN(arg, ret) \
47 do { int error = get_user(ret, (int __user *)(arg)); \
48 if (error) return error; \
49 } while (0)
50#define IOCTL_OUT(arg, ret) ioctl_return((int __user *)(arg), ret)
51
52static inline int ioctl_return(int __user *addr, int value)
53{
54 return value < 0 ? value : put_user(value, addr);
55}
56
57
58 /*
59 * Configuration
60 */
61
62#undef HAS_8BIT_TABLES
63
64#if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\
65 defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\
66 defined(CONFIG_DMASOUND_Q40) || defined(CONFIG_DMASOUND_Q40_MODULE)
67#define HAS_8BIT_TABLES
68#define MIN_BUFFERS 4
69#define MIN_BUFSIZE (1<<12) /* in bytes (- where does this come from ?) */
70#define MIN_FRAG_SIZE 8 /* not 100% sure about this */
71#define MAX_BUFSIZE (1<<17) /* Limit for Amiga is 128 kb */
72#define MAX_FRAG_SIZE 15 /* allow *4 for mono-8 => stereo-16 (for multi) */
73
74#else /* is pmac and multi is off */
75
76#define MIN_BUFFERS 2
77#define MIN_BUFSIZE (1<<8) /* in bytes */
78#define MIN_FRAG_SIZE 8
79#define MAX_BUFSIZE (1<<18) /* this is somewhat arbitrary for pmac */
80#define MAX_FRAG_SIZE 16 /* need to allow *4 for mono-8 => stereo-16 */
81#endif
82
83#define DEFAULT_N_BUFFERS 4
84#define DEFAULT_BUFF_SIZE (1<<15)
85
86 /*
87 * Initialization
88 */
89
90extern int dmasound_init(void);
91#ifdef MODULE
92extern void dmasound_deinit(void);
93#else
94#define dmasound_deinit() do { } while (0)
95#endif
96
97/* description of the set-up applies to either hard or soft settings */
98
99typedef struct {
100 int format; /* AFMT_* */
101 int stereo; /* 0 = mono, 1 = stereo */
102 int size; /* 8/16 bit*/
103 int speed; /* speed */
104} SETTINGS;
105
106 /*
107 * Machine definitions
108 */
109
110typedef struct {
111 const char *name;
112 const char *name2;
113 struct module *owner;
114 void *(*dma_alloc)(unsigned int, gfp_t);
115 void (*dma_free)(void *, unsigned int);
116 int (*irqinit)(void);
117#ifdef MODULE
118 void (*irqcleanup)(void);
119#endif
120 void (*init)(void);
121 void (*silence)(void);
122 int (*setFormat)(int);
123 int (*setVolume)(int);
124 int (*setBass)(int);
125 int (*setTreble)(int);
126 int (*setGain)(int);
127 void (*play)(void);
128 void (*record)(void); /* optional */
129 void (*mixer_init)(void); /* optional */
130 int (*mixer_ioctl)(u_int, u_long); /* optional */
131 int (*write_sq_setup)(void); /* optional */
132 int (*read_sq_setup)(void); /* optional */
133 int (*sq_open)(fmode_t); /* optional */
134 int (*state_info)(char *, size_t); /* optional */
135 void (*abort_read)(void); /* optional */
136 int min_dsp_speed;
137 int max_dsp_speed;
138 int version ;
139 int hardware_afmts ; /* OSS says we only return h'ware info */
140 /* when queried via SNDCTL_DSP_GETFMTS */
141 int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */
142 SETTINGS default_hard ; /* open() or init() should set something valid */
143 SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */
144} MACHINE;
145
146 /*
147 * Low level stuff
148 */
149
150typedef struct {
151 ssize_t (*ct_ulaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
152 ssize_t (*ct_alaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
153 ssize_t (*ct_s8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
154 ssize_t (*ct_u8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
155 ssize_t (*ct_s16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
156 ssize_t (*ct_u16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
157 ssize_t (*ct_s16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
158 ssize_t (*ct_u16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
159} TRANS;
160
161struct sound_settings {
162 MACHINE mach; /* machine dependent things */
163 SETTINGS hard; /* hardware settings */
164 SETTINGS soft; /* software settings */
165 SETTINGS dsp; /* /dev/dsp default settings */
166 TRANS *trans_write; /* supported translations */
167 int volume_left; /* volume (range is machine dependent) */
168 int volume_right;
169 int bass; /* tone (range is machine dependent) */
170 int treble;
171 int gain;
172 int minDev; /* minor device number currently open */
173 spinlock_t lock;
174};
175
176extern struct sound_settings dmasound;
177
178#ifdef HAS_8BIT_TABLES
179extern char dmasound_ulaw2dma8[];
180extern char dmasound_alaw2dma8[];
181#endif
182
183 /*
184 * Mid level stuff
185 */
186
187static inline int dmasound_set_volume(int volume)
188{
189 return dmasound.mach.setVolume(volume);
190}
191
192static inline int dmasound_set_bass(int bass)
193{
194 return dmasound.mach.setBass ? dmasound.mach.setBass(bass) : 50;
195}
196
197static inline int dmasound_set_treble(int treble)
198{
199 return dmasound.mach.setTreble ? dmasound.mach.setTreble(treble) : 50;
200}
201
202static inline int dmasound_set_gain(int gain)
203{
204 return dmasound.mach.setGain ? dmasound.mach.setGain(gain) : 100;
205}
206
207
208 /*
209 * Sound queue stuff, the heart of the driver
210 */
211
212struct sound_queue {
213 /* buffers allocated for this queue */
214 int numBufs; /* real limits on what the user can have */
215 int bufSize; /* in bytes */
216 char **buffers;
217
218 /* current parameters */
219 int locked ; /* params cannot be modified when != 0 */
220 int user_frags ; /* user requests this many */
221 int user_frag_size ; /* of this size */
222 int max_count; /* actual # fragments <= numBufs */
223 int block_size; /* internal block size in bytes */
224 int max_active; /* in-use fragments <= max_count */
225
226 /* it shouldn't be necessary to declare any of these volatile */
227 int front, rear, count;
228 int rear_size;
229 /*
230 * The use of the playing field depends on the hardware
231 *
232 * Atari, PMac: The number of frames that are loaded/playing
233 *
234 * Amiga: Bit 0 is set: a frame is loaded
235 * Bit 1 is set: a frame is playing
236 */
237 int active;
238 wait_queue_head_t action_queue, open_queue, sync_queue;
239 int non_blocking;
240 int busy, syncing, xruns, died;
241};
242
243#define WAKE_UP(queue) (wake_up_interruptible(&queue))
244
245extern struct sound_queue dmasound_write_sq;
246#define write_sq dmasound_write_sq
247
248extern int dmasound_catchRadius;
249#define catchRadius dmasound_catchRadius
250
251/* define the value to be put in the byte-swap reg in mac-io
252 when we want it to swap for us.
253*/
254#define BS_VAL 1
255
256#define SW_INPUT_VOLUME_SCALE 4
257#define SW_INPUT_VOLUME_DEFAULT (128 / SW_INPUT_VOLUME_SCALE)
258
259extern int expand_read_bal; /* Balance factor for reading */
260extern uint software_input_volume; /* software implemented recording volume! */
261
262#endif /* _dmasound_h_ */
1#ifndef _dmasound_h_
2/*
3 * linux/sound/oss/dmasound/dmasound.h
4 *
5 *
6 * Minor numbers for the sound driver.
7 *
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.
12 */
13#define _dmasound_h_
14
15#include <linux/types.h>
16
17#define SND_NDEVS 256 /* Number of supported devices */
18#define SND_DEV_CTL 0 /* Control port /dev/mixer */
19#define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM
20 synthesizer and MIDI output) */
21#define SND_DEV_MIDIN 2 /* Raw midi access */
22#define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
23#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
24#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
25#define SND_DEV_STATUS 6 /* /dev/sndstat */
26/* #7 not in use now. Was in 2.4. Free for use after v3.0. */
27#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
28#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
29#define SND_DEV_PSS SND_DEV_SNDPROC
30
31/* switch on various prinks */
32#define DEBUG_DMASOUND 1
33
34#define MAX_AUDIO_DEV 5
35#define MAX_MIXER_DEV 4
36#define MAX_SYNTH_DEV 3
37#define MAX_MIDI_DEV 6
38#define MAX_TIMER_DEV 3
39
40#define MAX_CATCH_RADIUS 10
41
42#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
43#define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
44
45#define IOCTL_IN(arg, ret) \
46 do { int error = get_user(ret, (int __user *)(arg)); \
47 if (error) return error; \
48 } while (0)
49#define IOCTL_OUT(arg, ret) ioctl_return((int __user *)(arg), ret)
50
51static inline int ioctl_return(int __user *addr, int value)
52{
53 return value < 0 ? value : put_user(value, addr);
54}
55
56
57 /*
58 * Configuration
59 */
60
61#undef HAS_8BIT_TABLES
62
63#if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\
64 defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\
65 defined(CONFIG_DMASOUND_Q40) || defined(CONFIG_DMASOUND_Q40_MODULE)
66#define HAS_8BIT_TABLES
67#define MIN_BUFFERS 4
68#define MIN_BUFSIZE (1<<12) /* in bytes (- where does this come from ?) */
69#define MIN_FRAG_SIZE 8 /* not 100% sure about this */
70#define MAX_BUFSIZE (1<<17) /* Limit for Amiga is 128 kb */
71#define MAX_FRAG_SIZE 15 /* allow *4 for mono-8 => stereo-16 (for multi) */
72
73#else /* is pmac and multi is off */
74
75#define MIN_BUFFERS 2
76#define MIN_BUFSIZE (1<<8) /* in bytes */
77#define MIN_FRAG_SIZE 8
78#define MAX_BUFSIZE (1<<18) /* this is somewhat arbitrary for pmac */
79#define MAX_FRAG_SIZE 16 /* need to allow *4 for mono-8 => stereo-16 */
80#endif
81
82#define DEFAULT_N_BUFFERS 4
83#define DEFAULT_BUFF_SIZE (1<<15)
84
85 /*
86 * Initialization
87 */
88
89extern int dmasound_init(void);
90#ifdef MODULE
91extern void dmasound_deinit(void);
92#else
93#define dmasound_deinit() do { } while (0)
94#endif
95
96/* description of the set-up applies to either hard or soft settings */
97
98typedef struct {
99 int format; /* AFMT_* */
100 int stereo; /* 0 = mono, 1 = stereo */
101 int size; /* 8/16 bit*/
102 int speed; /* speed */
103} SETTINGS;
104
105 /*
106 * Machine definitions
107 */
108
109typedef struct {
110 const char *name;
111 const char *name2;
112 struct module *owner;
113 void *(*dma_alloc)(unsigned int, gfp_t);
114 void (*dma_free)(void *, unsigned int);
115 int (*irqinit)(void);
116#ifdef MODULE
117 void (*irqcleanup)(void);
118#endif
119 void (*init)(void);
120 void (*silence)(void);
121 int (*setFormat)(int);
122 int (*setVolume)(int);
123 int (*setBass)(int);
124 int (*setTreble)(int);
125 int (*setGain)(int);
126 void (*play)(void);
127 void (*record)(void); /* optional */
128 void (*mixer_init)(void); /* optional */
129 int (*mixer_ioctl)(u_int, u_long); /* optional */
130 int (*write_sq_setup)(void); /* optional */
131 int (*read_sq_setup)(void); /* optional */
132 int (*sq_open)(fmode_t); /* optional */
133 int (*state_info)(char *, size_t); /* optional */
134 void (*abort_read)(void); /* optional */
135 int min_dsp_speed;
136 int max_dsp_speed;
137 int version ;
138 int hardware_afmts ; /* OSS says we only return h'ware info */
139 /* when queried via SNDCTL_DSP_GETFMTS */
140 int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */
141 SETTINGS default_hard ; /* open() or init() should set something valid */
142 SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */
143} MACHINE;
144
145 /*
146 * Low level stuff
147 */
148
149typedef struct {
150 ssize_t (*ct_ulaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
151 ssize_t (*ct_alaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
152 ssize_t (*ct_s8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
153 ssize_t (*ct_u8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
154 ssize_t (*ct_s16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
155 ssize_t (*ct_u16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
156 ssize_t (*ct_s16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
157 ssize_t (*ct_u16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
158} TRANS;
159
160struct sound_settings {
161 MACHINE mach; /* machine dependent things */
162 SETTINGS hard; /* hardware settings */
163 SETTINGS soft; /* software settings */
164 SETTINGS dsp; /* /dev/dsp default settings */
165 TRANS *trans_write; /* supported translations */
166 int volume_left; /* volume (range is machine dependent) */
167 int volume_right;
168 int bass; /* tone (range is machine dependent) */
169 int treble;
170 int gain;
171 int minDev; /* minor device number currently open */
172 spinlock_t lock;
173};
174
175extern struct sound_settings dmasound;
176
177#ifdef HAS_8BIT_TABLES
178extern char dmasound_ulaw2dma8[];
179extern char dmasound_alaw2dma8[];
180#endif
181
182 /*
183 * Mid level stuff
184 */
185
186static inline int dmasound_set_volume(int volume)
187{
188 return dmasound.mach.setVolume(volume);
189}
190
191static inline int dmasound_set_bass(int bass)
192{
193 return dmasound.mach.setBass ? dmasound.mach.setBass(bass) : 50;
194}
195
196static inline int dmasound_set_treble(int treble)
197{
198 return dmasound.mach.setTreble ? dmasound.mach.setTreble(treble) : 50;
199}
200
201static inline int dmasound_set_gain(int gain)
202{
203 return dmasound.mach.setGain ? dmasound.mach.setGain(gain) : 100;
204}
205
206
207 /*
208 * Sound queue stuff, the heart of the driver
209 */
210
211struct sound_queue {
212 /* buffers allocated for this queue */
213 int numBufs; /* real limits on what the user can have */
214 int bufSize; /* in bytes */
215 char **buffers;
216
217 /* current parameters */
218 int locked ; /* params cannot be modified when != 0 */
219 int user_frags ; /* user requests this many */
220 int user_frag_size ; /* of this size */
221 int max_count; /* actual # fragments <= numBufs */
222 int block_size; /* internal block size in bytes */
223 int max_active; /* in-use fragments <= max_count */
224
225 /* it shouldn't be necessary to declare any of these volatile */
226 int front, rear, count;
227 int rear_size;
228 /*
229 * The use of the playing field depends on the hardware
230 *
231 * Atari, PMac: The number of frames that are loaded/playing
232 *
233 * Amiga: Bit 0 is set: a frame is loaded
234 * Bit 1 is set: a frame is playing
235 */
236 int active;
237 wait_queue_head_t action_queue, open_queue, sync_queue;
238 int non_blocking;
239 int busy, syncing, xruns, died;
240};
241
242#define WAKE_UP(queue) (wake_up_interruptible(&queue))
243
244extern struct sound_queue dmasound_write_sq;
245#define write_sq dmasound_write_sq
246
247extern int dmasound_catchRadius;
248#define catchRadius dmasound_catchRadius
249
250/* define the value to be put in the byte-swap reg in mac-io
251 when we want it to swap for us.
252*/
253#define BS_VAL 1
254
255#define SW_INPUT_VOLUME_SCALE 4
256#define SW_INPUT_VOLUME_DEFAULT (128 / SW_INPUT_VOLUME_SCALE)
257
258extern int expand_read_bal; /* Balance factor for reading */
259extern uint software_input_volume; /* software implemented recording volume! */
260
261#endif /* _dmasound_h_ */