]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - sound/core/seq/oss/seq_oss_device.h
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.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 struct seq_oss_devinfo_t seq_oss_devinfo_t;
59 typedef struct seq_oss_writeq_t seq_oss_writeq_t;
60 typedef struct seq_oss_readq_t seq_oss_readq_t;
61 typedef struct seq_oss_timer_t seq_oss_timer_t;
62 typedef struct seq_oss_synthinfo_t seq_oss_synthinfo_t;
63 typedef struct seq_oss_synth_sysex_t seq_oss_synth_sysex_t;
64 typedef struct seq_oss_chinfo_t seq_oss_chinfo_t;
65 typedef unsigned int reltime_t;
66 typedef unsigned int abstime_t;
67 typedef union evrec_t evrec_t;
68
69
70 /*
71 * synthesizer channel information
72 */
73 struct seq_oss_chinfo_t {
74 int note, vel;
75 };
76
77 /*
78 * synthesizer information
79 */
80 struct seq_oss_synthinfo_t {
81 snd_seq_oss_arg_t arg;
82 seq_oss_chinfo_t *ch;
83 seq_oss_synth_sysex_t *sysex;
84 int nr_voices;
85 int opened;
86 int is_midi;
87 int midi_mapped;
88 };
89
90
91 /*
92 * sequencer client information
93 */
94
95 struct seq_oss_devinfo_t {
96
97 int index; /* application index */
98 int cseq; /* sequencer client number */
99 int port; /* sequencer port number */
100 int queue; /* sequencer queue number */
101
102 snd_seq_addr_t addr; /* address of this device */
103
104 int seq_mode; /* sequencer mode */
105 int file_mode; /* file access */
106
107 /* midi device table */
108 int max_mididev;
109
110 /* synth device table */
111 int max_synthdev;
112 seq_oss_synthinfo_t synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
113 int synth_opened;
114
115 /* output queue */
116 seq_oss_writeq_t *writeq;
117
118 /* midi input queue */
119 seq_oss_readq_t *readq;
120
121 /* timer */
122 seq_oss_timer_t *timer;
123 };
124
125
126 /*
127 * function prototypes
128 */
129
130 /* create/delete OSS sequencer client */
131 int snd_seq_oss_create_client(void);
132 int snd_seq_oss_delete_client(void);
133
134 /* device file interface */
135 int snd_seq_oss_open(struct file *file, int level);
136 void snd_seq_oss_release(seq_oss_devinfo_t *dp);
137 int snd_seq_oss_ioctl(seq_oss_devinfo_t *dp, unsigned int cmd, unsigned long arg);
138 int snd_seq_oss_read(seq_oss_devinfo_t *dev, char __user *buf, int count);
139 int snd_seq_oss_write(seq_oss_devinfo_t *dp, const char __user *buf, int count, struct file *opt);
140 unsigned int snd_seq_oss_poll(seq_oss_devinfo_t *dp, struct file *file, poll_table * wait);
141
142 void snd_seq_oss_reset(seq_oss_devinfo_t *dp);
143 void snd_seq_oss_drain_write(seq_oss_devinfo_t *dp);
144
145 /* */
146 void snd_seq_oss_process_queue(seq_oss_devinfo_t *dp, abstime_t time);
147
148
149 /* proc interface */
150 void snd_seq_oss_system_info_read(snd_info_buffer_t *buf);
151 void snd_seq_oss_midi_info_read(snd_info_buffer_t *buf);
152 void snd_seq_oss_synth_info_read(snd_info_buffer_t *buf);
153 void snd_seq_oss_readq_info_read(seq_oss_readq_t *q, snd_info_buffer_t *buf);
154
155 /* file mode macros */
156 #define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ)
157 #define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
158 #define is_nonblock_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
159
160 /* dispatch event */
161 inline static int
162 snd_seq_oss_dispatch(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, int atomic, int hop)
163 {
164 return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
165 }
166
167 /* ioctl */
168 inline static int
169 snd_seq_oss_control(seq_oss_devinfo_t *dp, unsigned int type, void *arg)
170 {
171 return snd_seq_kernel_client_ctl(dp->cseq, type, arg);
172 }
173
174 /* fill the addresses in header */
175 inline static void
176 snd_seq_oss_fill_addr(seq_oss_devinfo_t *dp, snd_seq_event_t *ev,
177 int dest_client, int dest_port)
178 {
179 ev->queue = dp->queue;
180 ev->source = dp->addr;
181 ev->dest.client = dest_client;
182 ev->dest.port = dest_port;
183 }
184
185
186 /* misc. functions for proc interface */
187 char *enabled_str(int bool);
188
189
190 /* for debug */
191 #ifdef SNDRV_SEQ_OSS_DEBUG
192 extern int seq_oss_debug;
193 #define debug_printk(x) do { if (seq_oss_debug > 0) snd_printk x; } while (0)
194 #else
195 #define debug_printk(x) /**/
196 #endif
197
198 #endif /* __SEQ_OSS_DEVICE_H */