blob: e5f943045afa50acb2182f2cd86b125133c85a64 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _cs4218_h_
2/*
3 * Hacked version of linux/drivers/sound/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 _cs4218_h_
14
15#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
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 *)(arg)); \
47 if (error) return error; \
48 } while (0)
49#define IOCTL_OUT(arg, ret) ioctl_return((int *)(arg), ret)
50
51static inline int ioctl_return(int *addr, int value)
52{
53 return value < 0 ? value : put_user(value, addr);
54}
55
56#define HAS_RECORD
57
58 /*
59 * Initialization
60 */
61
62/* description of the set-up applies to either hard or soft settings */
63
64typedef struct {
65 int format; /* AFMT_* */
66 int stereo; /* 0 = mono, 1 = stereo */
67 int size; /* 8/16 bit*/
68 int speed; /* speed */
69} SETTINGS;
70
71 /*
72 * Machine definitions
73 */
74
75typedef struct {
76 const char *name;
77 const char *name2;
78 void (*open)(void);
79 void (*release)(void);
Al Viro1ef64e62005-10-21 03:22:18 -040080 void *(*dma_alloc)(unsigned int, gfp_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 void (*dma_free)(void *, unsigned int);
82 int (*irqinit)(void);
83#ifdef MODULE
84 void (*irqcleanup)(void);
85#endif
86 void (*init)(void);
87 void (*silence)(void);
88 int (*setFormat)(int);
89 int (*setVolume)(int);
90 int (*setBass)(int);
91 int (*setTreble)(int);
92 int (*setGain)(int);
93 void (*play)(void);
94 void (*record)(void); /* optional */
95 void (*mixer_init)(void); /* optional */
96 int (*mixer_ioctl)(u_int, u_long); /* optional */
97 int (*write_sq_setup)(void); /* optional */
98 int (*read_sq_setup)(void); /* optional */
99 int (*sq_open)(mode_t); /* optional */
100 int (*state_info)(char *, size_t); /* optional */
101 void (*abort_read)(void); /* optional */
102 int min_dsp_speed;
103 int max_dsp_speed;
104 int version ;
105 int hardware_afmts ; /* OSS says we only return h'ware info */
106 /* when queried via SNDCTL_DSP_GETFMTS */
107 int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */
108 SETTINGS default_hard ; /* open() or init() should set something valid */
109 SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */
110} MACHINE;
111
112 /*
113 * Low level stuff
114 */
115
116typedef struct {
117 ssize_t (*ct_ulaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
118 ssize_t (*ct_alaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
119 ssize_t (*ct_s8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
120 ssize_t (*ct_u8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
121 ssize_t (*ct_s16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
122 ssize_t (*ct_u16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
123 ssize_t (*ct_s16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
124 ssize_t (*ct_u16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
125} TRANS;
126
127
128 /*
129 * Sound queue stuff, the heart of the driver
130 */
131
132struct sound_queue {
133 /* buffers allocated for this queue */
134 int numBufs; /* real limits on what the user can have */
135 int bufSize; /* in bytes */
136 char **buffers;
137
138 /* current parameters */
139 int locked ; /* params cannot be modified when != 0 */
140 int user_frags ; /* user requests this many */
141 int user_frag_size ; /* of this size */
142 int max_count; /* actual # fragments <= numBufs */
143 int block_size; /* internal block size in bytes */
144 int max_active; /* in-use fragments <= max_count */
145
146 /* it shouldn't be necessary to declare any of these volatile */
147 int front, rear, count;
148 int rear_size;
149 /*
150 * The use of the playing field depends on the hardware
151 *
152 * Atari, PMac: The number of frames that are loaded/playing
153 *
154 * Amiga: Bit 0 is set: a frame is loaded
155 * Bit 1 is set: a frame is playing
156 */
157 int active;
158 wait_queue_head_t action_queue, open_queue, sync_queue;
159 int open_mode;
160 int busy, syncing, xruns, died;
161};
162
163#define SLEEP(queue) interruptible_sleep_on_timeout(&queue, HZ)
164#define WAKE_UP(queue) (wake_up_interruptible(&queue))
165
166#endif /* _cs4218_h_ */