0001
0002 #ifndef _dmasound_h_
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #define _dmasound_h_
0015
0016 #include <linux/types.h>
0017
0018 #define SND_NDEVS 256
0019 #define SND_DEV_CTL 0
0020 #define SND_DEV_SEQ 1
0021
0022 #define SND_DEV_MIDIN 2
0023 #define SND_DEV_DSP 3
0024 #define SND_DEV_AUDIO 4
0025 #define SND_DEV_DSP16 5
0026 #define SND_DEV_STATUS 6
0027
0028 #define SND_DEV_SEQ2 8
0029 #define SND_DEV_SNDPROC 9
0030 #define SND_DEV_PSS SND_DEV_SNDPROC
0031
0032
0033 #define DEBUG_DMASOUND 1
0034
0035 #define MAX_AUDIO_DEV 5
0036 #define MAX_MIXER_DEV 4
0037 #define MAX_SYNTH_DEV 3
0038 #define MAX_MIDI_DEV 6
0039 #define MAX_TIMER_DEV 3
0040
0041 #define MAX_CATCH_RADIUS 10
0042
0043 #define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
0044 #define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
0045
0046 #define IOCTL_IN(arg, ret) \
0047 do { int error = get_user(ret, (int __user *)(arg)); \
0048 if (error) return error; \
0049 } while (0)
0050 #define IOCTL_OUT(arg, ret) ioctl_return((int __user *)(arg), ret)
0051
0052 static inline int ioctl_return(int __user *addr, int value)
0053 {
0054 return value < 0 ? value : put_user(value, addr);
0055 }
0056
0057
0058
0059
0060
0061
0062 #undef HAS_8BIT_TABLES
0063
0064 #if defined(CONFIG_DMASOUND_ATARI) || defined(CONFIG_DMASOUND_ATARI_MODULE) ||\
0065 defined(CONFIG_DMASOUND_PAULA) || defined(CONFIG_DMASOUND_PAULA_MODULE) ||\
0066 defined(CONFIG_DMASOUND_Q40) || defined(CONFIG_DMASOUND_Q40_MODULE)
0067 #define HAS_8BIT_TABLES
0068 #define MIN_BUFFERS 4
0069 #define MIN_BUFSIZE (1<<12)
0070 #define MIN_FRAG_SIZE 8
0071 #define MAX_BUFSIZE (1<<17)
0072 #define MAX_FRAG_SIZE 15
0073
0074 #else
0075
0076 #define MIN_BUFFERS 2
0077 #define MIN_BUFSIZE (1<<8)
0078 #define MIN_FRAG_SIZE 8
0079 #define MAX_BUFSIZE (1<<18)
0080 #define MAX_FRAG_SIZE 16
0081 #endif
0082
0083 #define DEFAULT_N_BUFFERS 4
0084 #define DEFAULT_BUFF_SIZE (1<<15)
0085
0086
0087
0088
0089
0090 extern int dmasound_init(void);
0091 extern void dmasound_deinit(void);
0092
0093
0094
0095 typedef struct {
0096 int format;
0097 int stereo;
0098 int size;
0099 int speed;
0100 } SETTINGS;
0101
0102
0103
0104
0105
0106 typedef struct {
0107 const char *name;
0108 const char *name2;
0109 struct module *owner;
0110 void *(*dma_alloc)(unsigned int, gfp_t);
0111 void (*dma_free)(void *, unsigned int);
0112 int (*irqinit)(void);
0113 void (*irqcleanup)(void);
0114 void (*init)(void);
0115 void (*silence)(void);
0116 int (*setFormat)(int);
0117 int (*setVolume)(int);
0118 int (*setBass)(int);
0119 int (*setTreble)(int);
0120 int (*setGain)(int);
0121 void (*play)(void);
0122 void (*record)(void);
0123 void (*mixer_init)(void);
0124 int (*mixer_ioctl)(u_int, u_long);
0125 int (*write_sq_setup)(void);
0126 int (*read_sq_setup)(void);
0127 int (*sq_open)(fmode_t);
0128 int (*state_info)(char *, size_t);
0129 void (*abort_read)(void);
0130 int min_dsp_speed;
0131 int max_dsp_speed;
0132 int version ;
0133 int hardware_afmts ;
0134
0135 int capabilities ;
0136 SETTINGS default_hard ;
0137 SETTINGS default_soft ;
0138 } MACHINE;
0139
0140
0141
0142
0143
0144 typedef struct {
0145 ssize_t (*ct_ulaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0146 ssize_t (*ct_alaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0147 ssize_t (*ct_s8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0148 ssize_t (*ct_u8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0149 ssize_t (*ct_s16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0150 ssize_t (*ct_u16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0151 ssize_t (*ct_s16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0152 ssize_t (*ct_u16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
0153 } TRANS;
0154
0155 struct sound_settings {
0156 MACHINE mach;
0157 SETTINGS hard;
0158 SETTINGS soft;
0159 SETTINGS dsp;
0160 TRANS *trans_write;
0161 int volume_left;
0162 int volume_right;
0163 int bass;
0164 int treble;
0165 int gain;
0166 int minDev;
0167 spinlock_t lock;
0168 };
0169
0170 extern struct sound_settings dmasound;
0171
0172 #ifdef HAS_8BIT_TABLES
0173 extern char dmasound_ulaw2dma8[];
0174 extern char dmasound_alaw2dma8[];
0175 #endif
0176
0177
0178
0179
0180
0181 static inline int dmasound_set_volume(int volume)
0182 {
0183 return dmasound.mach.setVolume(volume);
0184 }
0185
0186 static inline int dmasound_set_bass(int bass)
0187 {
0188 return dmasound.mach.setBass ? dmasound.mach.setBass(bass) : 50;
0189 }
0190
0191 static inline int dmasound_set_treble(int treble)
0192 {
0193 return dmasound.mach.setTreble ? dmasound.mach.setTreble(treble) : 50;
0194 }
0195
0196 static inline int dmasound_set_gain(int gain)
0197 {
0198 return dmasound.mach.setGain ? dmasound.mach.setGain(gain) : 100;
0199 }
0200
0201
0202
0203
0204
0205
0206 struct sound_queue {
0207
0208 int numBufs;
0209 int bufSize;
0210 char **buffers;
0211
0212
0213 int locked ;
0214 int user_frags ;
0215 int user_frag_size ;
0216 int max_count;
0217 int block_size;
0218 int max_active;
0219
0220
0221 int front, rear, count;
0222 int rear_size;
0223
0224
0225
0226
0227
0228
0229
0230
0231 int active;
0232 wait_queue_head_t action_queue, open_queue, sync_queue;
0233 int non_blocking;
0234 int busy, syncing, xruns, died;
0235 };
0236
0237 #define WAKE_UP(queue) (wake_up_interruptible(&queue))
0238
0239 extern struct sound_queue dmasound_write_sq;
0240 #define write_sq dmasound_write_sq
0241
0242 extern int dmasound_catchRadius;
0243 #define catchRadius dmasound_catchRadius
0244
0245
0246
0247
0248 #define BS_VAL 1
0249
0250 #define SW_INPUT_VOLUME_SCALE 4
0251 #define SW_INPUT_VOLUME_DEFAULT (128 / SW_INPUT_VOLUME_SCALE)
0252
0253 extern int expand_read_bal;
0254 extern uint software_input_volume;
0255
0256 #endif