Commit | Line | Data |
---|---|---|
1da177e4 LT |
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 | ||
1da177e4 LT |
24 | #include <linux/time.h> |
25 | #include <linux/wait.h> | |
26 | #include <linux/slab.h> | |
27 | #include <linux/sched.h> | |
28 | #include <sound/core.h> | |
29 | #include <sound/seq_oss.h> | |
30 | #include <sound/rawmidi.h> | |
31 | #include <sound/seq_kernel.h> | |
32 | #include <sound/info.h> | |
33 | ||
1da177e4 LT |
34 | /* max. applications */ |
35 | #define SNDRV_SEQ_OSS_MAX_CLIENTS 16 | |
36 | #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS 16 | |
37 | #define SNDRV_SEQ_OSS_MAX_MIDI_DEVS 32 | |
38 | ||
39 | /* version */ | |
40 | #define SNDRV_SEQ_OSS_MAJOR_VERSION 0 | |
41 | #define SNDRV_SEQ_OSS_MINOR_VERSION 1 | |
42 | #define SNDRV_SEQ_OSS_TINY_VERSION 8 | |
43 | #define SNDRV_SEQ_OSS_VERSION_STR "0.1.8" | |
44 | ||
45 | /* device and proc interface name */ | |
1da177e4 LT |
46 | #define SNDRV_SEQ_OSS_PROCNAME "oss" |
47 | ||
48 | ||
49 | /* | |
50 | * type definitions | |
51 | */ | |
52 | ||
1da177e4 LT |
53 | typedef unsigned int reltime_t; |
54 | typedef unsigned int abstime_t; | |
1da177e4 LT |
55 | |
56 | ||
57 | /* | |
58 | * synthesizer channel information | |
59 | */ | |
080dece3 | 60 | struct seq_oss_chinfo { |
1da177e4 LT |
61 | int note, vel; |
62 | }; | |
63 | ||
64 | /* | |
65 | * synthesizer information | |
66 | */ | |
080dece3 TI |
67 | struct seq_oss_synthinfo { |
68 | struct snd_seq_oss_arg arg; | |
69 | struct seq_oss_chinfo *ch; | |
70 | struct seq_oss_synth_sysex *sysex; | |
1da177e4 LT |
71 | int nr_voices; |
72 | int opened; | |
73 | int is_midi; | |
74 | int midi_mapped; | |
75 | }; | |
76 | ||
77 | ||
78 | /* | |
79 | * sequencer client information | |
80 | */ | |
81 | ||
080dece3 | 82 | struct seq_oss_devinfo { |
1da177e4 LT |
83 | |
84 | int index; /* application index */ | |
85 | int cseq; /* sequencer client number */ | |
86 | int port; /* sequencer port number */ | |
87 | int queue; /* sequencer queue number */ | |
88 | ||
080dece3 | 89 | struct snd_seq_addr addr; /* address of this device */ |
1da177e4 LT |
90 | |
91 | int seq_mode; /* sequencer mode */ | |
92 | int file_mode; /* file access */ | |
93 | ||
94 | /* midi device table */ | |
95 | int max_mididev; | |
96 | ||
97 | /* synth device table */ | |
98 | int max_synthdev; | |
080dece3 | 99 | struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS]; |
1da177e4 LT |
100 | int synth_opened; |
101 | ||
102 | /* output queue */ | |
080dece3 | 103 | struct seq_oss_writeq *writeq; |
1da177e4 LT |
104 | |
105 | /* midi input queue */ | |
080dece3 | 106 | struct seq_oss_readq *readq; |
1da177e4 LT |
107 | |
108 | /* timer */ | |
080dece3 | 109 | struct seq_oss_timer *timer; |
1da177e4 LT |
110 | }; |
111 | ||
112 | ||
113 | /* | |
114 | * function prototypes | |
115 | */ | |
116 | ||
117 | /* create/delete OSS sequencer client */ | |
118 | int snd_seq_oss_create_client(void); | |
119 | int snd_seq_oss_delete_client(void); | |
120 | ||
121 | /* device file interface */ | |
122 | int snd_seq_oss_open(struct file *file, int level); | |
080dece3 TI |
123 | void snd_seq_oss_release(struct seq_oss_devinfo *dp); |
124 | int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg); | |
125 | int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count); | |
126 | int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt); | |
127 | unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait); | |
1da177e4 | 128 | |
080dece3 | 129 | void snd_seq_oss_reset(struct seq_oss_devinfo *dp); |
1da177e4 LT |
130 | |
131 | /* */ | |
080dece3 | 132 | void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time); |
1da177e4 LT |
133 | |
134 | ||
135 | /* proc interface */ | |
080dece3 TI |
136 | void snd_seq_oss_system_info_read(struct snd_info_buffer *buf); |
137 | void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf); | |
138 | void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf); | |
139 | void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf); | |
1da177e4 LT |
140 | |
141 | /* file mode macros */ | |
142 | #define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ) | |
143 | #define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE) | |
144 | #define is_nonblock_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK) | |
145 | ||
146 | /* dispatch event */ | |
77933d72 | 147 | static inline int |
080dece3 | 148 | snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop) |
1da177e4 LT |
149 | { |
150 | return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop); | |
151 | } | |
152 | ||
153 | /* ioctl */ | |
77933d72 | 154 | static inline int |
080dece3 | 155 | snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg) |
1da177e4 LT |
156 | { |
157 | return snd_seq_kernel_client_ctl(dp->cseq, type, arg); | |
158 | } | |
159 | ||
160 | /* fill the addresses in header */ | |
77933d72 | 161 | static inline void |
080dece3 | 162 | snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, |
1da177e4 LT |
163 | int dest_client, int dest_port) |
164 | { | |
165 | ev->queue = dp->queue; | |
166 | ev->source = dp->addr; | |
167 | ev->dest.client = dest_client; | |
168 | ev->dest.port = dest_port; | |
169 | } | |
170 | ||
171 | ||
172 | /* misc. functions for proc interface */ | |
173 | char *enabled_str(int bool); | |
174 | ||
1da177e4 | 175 | #endif /* __SEQ_OSS_DEVICE_H */ |