Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / core / seq / oss / seq_oss_device.h
1 /*
2  * OSS compatible sequencer driver
3  *
4  * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19  */
20
21 #ifndef __SEQ_OSS_DEVICE_H
22 #define __SEQ_OSS_DEVICE_H
23
24 #include <sound/driver.h>
25 #include <linux/time.h>
26 #include <linux/wait.h>
27 #include <linux/slab.h>
28 #include <linux/sched.h>
29 #include <sound/core.h>
30 #include <sound/seq_oss.h>
31 #include <sound/rawmidi.h>
32 #include <sound/seq_kernel.h>
33 #include <sound/info.h>
34
35 /* enable debug print */
36 #define SNDRV_SEQ_OSS_DEBUG
37
38 /* max. applications */
39 #define SNDRV_SEQ_OSS_MAX_CLIENTS       16
40 #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS    16
41 #define SNDRV_SEQ_OSS_MAX_MIDI_DEVS     32
42
43 /* version */
44 #define SNDRV_SEQ_OSS_MAJOR_VERSION     0
45 #define SNDRV_SEQ_OSS_MINOR_VERSION     1
46 #define SNDRV_SEQ_OSS_TINY_VERSION      8
47 #define SNDRV_SEQ_OSS_VERSION_STR       "0.1.8"
48
49 /* device and proc interface name */
50 #define SNDRV_SEQ_OSS_DEVNAME           "seq_oss"
51 #define SNDRV_SEQ_OSS_PROCNAME          "oss"
52
53
54 /*
55  * type definitions
56  */
57
58 typedef unsigned int reltime_t;
59 typedef unsigned int abstime_t;
60
61
62 /*
63  * synthesizer channel information
64  */
65 struct seq_oss_chinfo {
66         int note, vel;
67 };
68
69 /*
70  * synthesizer information
71  */
72 struct seq_oss_synthinfo {
73         struct snd_seq_oss_arg arg;
74         struct seq_oss_chinfo *ch;
75         struct seq_oss_synth_sysex *sysex;
76         int nr_voices;
77         int opened;
78         int is_midi;
79         int midi_mapped;
80 };
81
82
83 /*
84  * sequencer client information
85  */
86
87 struct seq_oss_devinfo {
88
89         int index;      /* application index */
90         int cseq;       /* sequencer client number */
91         int port;       /* sequencer port number */
92         int queue;      /* sequencer queue number */
93
94         struct snd_seq_addr addr;       /* address of this device */
95
96         int seq_mode;   /* sequencer mode */
97         int file_mode;  /* file access */
98
99         /* midi device table */
100         int max_mididev;
101
102         /* synth device table */
103         int max_synthdev;
104         struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
105         int synth_opened;
106
107         /* output queue */
108         struct seq_oss_writeq *writeq;
109
110         /* midi input queue */
111         struct seq_oss_readq *readq;
112
113         /* timer */
114         struct seq_oss_timer *timer;
115 };
116
117
118 /*
119  * function prototypes
120  */
121
122 /* create/delete OSS sequencer client */
123 int snd_seq_oss_create_client(void);
124 int snd_seq_oss_delete_client(void);
125
126 /* device file interface */
127 int snd_seq_oss_open(struct file *file, int level);
128 void snd_seq_oss_release(struct seq_oss_devinfo *dp);
129 int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
130 int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
131 int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
132 unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
133
134 void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
135 void snd_seq_oss_drain_write(struct seq_oss_devinfo *dp);
136
137 /* */
138 void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);
139
140
141 /* proc interface */
142 void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
143 void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
144 void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
145 void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
146
147 /* file mode macros */
148 #define is_read_mode(mode)      ((mode) & SNDRV_SEQ_OSS_FILE_READ)
149 #define is_write_mode(mode)     ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
150 #define is_nonblock_mode(mode)  ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
151
152 /* dispatch event */
153 static inline int
154 snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
155 {
156         return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
157 }
158
159 /* ioctl */
160 static inline int
161 snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
162 {
163         return snd_seq_kernel_client_ctl(dp->cseq, type, arg);
164 }
165
166 /* fill the addresses in header */
167 static inline void
168 snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
169                      int dest_client, int dest_port)
170 {
171         ev->queue = dp->queue;
172         ev->source = dp->addr;
173         ev->dest.client = dest_client;
174         ev->dest.port = dest_port;
175 }
176
177
178 /* misc. functions for proc interface */
179 char *enabled_str(int bool);
180
181
182 /* for debug */
183 #ifdef SNDRV_SEQ_OSS_DEBUG
184 extern int seq_oss_debug;
185 #define debug_printk(x) do { if (seq_oss_debug > 0) snd_printk x; } while (0)
186 #else
187 #define debug_printk(x) /**/
188 #endif
189
190 #endif /* __SEQ_OSS_DEVICE_H */