xref: /openbmc/linux/include/uapi/sound/asequencer.h (revision 674e95ca)
1674e95caSDavid Howells /*
2674e95caSDavid Howells  *  Main header file for the ALSA sequencer
3674e95caSDavid Howells  *  Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
4674e95caSDavid Howells  *            (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
5674e95caSDavid Howells  *
6674e95caSDavid Howells  *
7674e95caSDavid Howells  *   This program is free software; you can redistribute it and/or modify
8674e95caSDavid Howells  *   it under the terms of the GNU General Public License as published by
9674e95caSDavid Howells  *   the Free Software Foundation; either version 2 of the License, or
10674e95caSDavid Howells  *   (at your option) any later version.
11674e95caSDavid Howells  *
12674e95caSDavid Howells  *   This program is distributed in the hope that it will be useful,
13674e95caSDavid Howells  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14674e95caSDavid Howells  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15674e95caSDavid Howells  *   GNU General Public License for more details.
16674e95caSDavid Howells  *
17674e95caSDavid Howells  *   You should have received a copy of the GNU General Public License
18674e95caSDavid Howells  *   along with this program; if not, write to the Free Software
19674e95caSDavid Howells  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20674e95caSDavid Howells  *
21674e95caSDavid Howells  */
22674e95caSDavid Howells #ifndef _UAPI__SOUND_ASEQUENCER_H
23674e95caSDavid Howells #define _UAPI__SOUND_ASEQUENCER_H
24674e95caSDavid Howells 
25674e95caSDavid Howells 
26674e95caSDavid Howells /** version of the sequencer */
27674e95caSDavid Howells #define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 1)
28674e95caSDavid Howells 
29674e95caSDavid Howells /**
30674e95caSDavid Howells  * definition of sequencer event types
31674e95caSDavid Howells  */
32674e95caSDavid Howells 
33674e95caSDavid Howells /** system messages
34674e95caSDavid Howells  * event data type = #snd_seq_result
35674e95caSDavid Howells  */
36674e95caSDavid Howells #define SNDRV_SEQ_EVENT_SYSTEM		0
37674e95caSDavid Howells #define SNDRV_SEQ_EVENT_RESULT		1
38674e95caSDavid Howells 
39674e95caSDavid Howells /** note messages (channel specific)
40674e95caSDavid Howells  * event data type = #snd_seq_ev_note
41674e95caSDavid Howells  */
42674e95caSDavid Howells #define SNDRV_SEQ_EVENT_NOTE		5
43674e95caSDavid Howells #define SNDRV_SEQ_EVENT_NOTEON		6
44674e95caSDavid Howells #define SNDRV_SEQ_EVENT_NOTEOFF		7
45674e95caSDavid Howells #define SNDRV_SEQ_EVENT_KEYPRESS	8
46674e95caSDavid Howells 
47674e95caSDavid Howells /** control messages (channel specific)
48674e95caSDavid Howells  * event data type = #snd_seq_ev_ctrl
49674e95caSDavid Howells  */
50674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CONTROLLER	10
51674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PGMCHANGE	11
52674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CHANPRESS	12
53674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PITCHBEND	13	/**< from -8192 to 8191 */
54674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CONTROL14	14	/**< 14 bit controller value */
55674e95caSDavid Howells #define SNDRV_SEQ_EVENT_NONREGPARAM	15	/**< 14 bit NRPN address + 14 bit unsigned value */
56674e95caSDavid Howells #define SNDRV_SEQ_EVENT_REGPARAM	16	/**< 14 bit RPN address + 14 bit unsigned value */
57674e95caSDavid Howells 
58674e95caSDavid Howells /** synchronisation messages
59674e95caSDavid Howells  * event data type = #snd_seq_ev_ctrl
60674e95caSDavid Howells  */
61674e95caSDavid Howells #define SNDRV_SEQ_EVENT_SONGPOS		20	/* Song Position Pointer with LSB and MSB values */
62674e95caSDavid Howells #define SNDRV_SEQ_EVENT_SONGSEL		21	/* Song Select with song ID number */
63674e95caSDavid Howells #define SNDRV_SEQ_EVENT_QFRAME		22	/* midi time code quarter frame */
64674e95caSDavid Howells #define SNDRV_SEQ_EVENT_TIMESIGN	23	/* SMF Time Signature event */
65674e95caSDavid Howells #define SNDRV_SEQ_EVENT_KEYSIGN		24	/* SMF Key Signature event */
66674e95caSDavid Howells 
67674e95caSDavid Howells /** timer messages
68674e95caSDavid Howells  * event data type = snd_seq_ev_queue_control
69674e95caSDavid Howells  */
70674e95caSDavid Howells #define SNDRV_SEQ_EVENT_START		30	/* midi Real Time Start message */
71674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CONTINUE	31	/* midi Real Time Continue message */
72674e95caSDavid Howells #define SNDRV_SEQ_EVENT_STOP		32	/* midi Real Time Stop message */
73674e95caSDavid Howells #define	SNDRV_SEQ_EVENT_SETPOS_TICK	33	/* set tick queue position */
74674e95caSDavid Howells #define SNDRV_SEQ_EVENT_SETPOS_TIME	34	/* set realtime queue position */
75674e95caSDavid Howells #define SNDRV_SEQ_EVENT_TEMPO		35	/* (SMF) Tempo event */
76674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CLOCK		36	/* midi Real Time Clock message */
77674e95caSDavid Howells #define SNDRV_SEQ_EVENT_TICK		37	/* midi Real Time Tick message */
78674e95caSDavid Howells #define SNDRV_SEQ_EVENT_QUEUE_SKEW	38	/* skew queue tempo */
79674e95caSDavid Howells 
80674e95caSDavid Howells /** others
81674e95caSDavid Howells  * event data type = none
82674e95caSDavid Howells  */
83674e95caSDavid Howells #define SNDRV_SEQ_EVENT_TUNE_REQUEST	40	/* tune request */
84674e95caSDavid Howells #define SNDRV_SEQ_EVENT_RESET		41	/* reset to power-on state */
85674e95caSDavid Howells #define SNDRV_SEQ_EVENT_SENSING		42	/* "active sensing" event */
86674e95caSDavid Howells 
87674e95caSDavid Howells /** echo back, kernel private messages
88674e95caSDavid Howells  * event data type = any type
89674e95caSDavid Howells  */
90674e95caSDavid Howells #define SNDRV_SEQ_EVENT_ECHO		50	/* echo event */
91674e95caSDavid Howells #define SNDRV_SEQ_EVENT_OSS		51	/* OSS raw event */
92674e95caSDavid Howells 
93674e95caSDavid Howells /** system status messages (broadcast for subscribers)
94674e95caSDavid Howells  * event data type = snd_seq_addr
95674e95caSDavid Howells  */
96674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CLIENT_START	60	/* new client has connected */
97674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CLIENT_EXIT	61	/* client has left the system */
98674e95caSDavid Howells #define SNDRV_SEQ_EVENT_CLIENT_CHANGE	62	/* client status/info has changed */
99674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PORT_START	63	/* new port was created */
100674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PORT_EXIT	64	/* port was deleted from system */
101674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PORT_CHANGE	65	/* port status/info has changed */
102674e95caSDavid Howells 
103674e95caSDavid Howells /** port connection changes
104674e95caSDavid Howells  * event data type = snd_seq_connect
105674e95caSDavid Howells  */
106674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED	66	/* ports connected */
107674e95caSDavid Howells #define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67	/* ports disconnected */
108674e95caSDavid Howells 
109674e95caSDavid Howells /* 70-89:  synthesizer events - obsoleted */
110674e95caSDavid Howells 
111674e95caSDavid Howells /** user-defined events with fixed length
112674e95caSDavid Howells  * event data type = any
113674e95caSDavid Howells  */
114674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR0		90
115674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR1		91
116674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR2		92
117674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR3		93
118674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR4		94
119674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR5		95
120674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR6		96
121674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR7		97
122674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR8		98
123674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR9		99
124674e95caSDavid Howells 
125674e95caSDavid Howells /* 100-118: instrument layer - obsoleted */
126674e95caSDavid Howells /* 119-129: reserved */
127674e95caSDavid Howells 
128674e95caSDavid Howells /* 130-139: variable length events
129674e95caSDavid Howells  * event data type = snd_seq_ev_ext
130674e95caSDavid Howells  * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set)
131674e95caSDavid Howells  */
132674e95caSDavid Howells #define SNDRV_SEQ_EVENT_SYSEX		130	/* system exclusive data (variable length) */
133674e95caSDavid Howells #define SNDRV_SEQ_EVENT_BOUNCE		131	/* error event */
134674e95caSDavid Howells /* 132-134: reserved */
135674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR_VAR0	135
136674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR_VAR1	136
137674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR_VAR2	137
138674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR_VAR3	138
139674e95caSDavid Howells #define SNDRV_SEQ_EVENT_USR_VAR4	139
140674e95caSDavid Howells 
141674e95caSDavid Howells /* 150-151: kernel events with quote - DO NOT use in user clients */
142674e95caSDavid Howells #define SNDRV_SEQ_EVENT_KERNEL_ERROR	150
143674e95caSDavid Howells #define SNDRV_SEQ_EVENT_KERNEL_QUOTE	151	/* obsolete */
144674e95caSDavid Howells 
145674e95caSDavid Howells /* 152-191: reserved */
146674e95caSDavid Howells 
147674e95caSDavid Howells /* 192-254: hardware specific events */
148674e95caSDavid Howells 
149674e95caSDavid Howells /* 255: special event */
150674e95caSDavid Howells #define SNDRV_SEQ_EVENT_NONE		255
151674e95caSDavid Howells 
152674e95caSDavid Howells 
153674e95caSDavid Howells typedef unsigned char snd_seq_event_type_t;
154674e95caSDavid Howells 
155674e95caSDavid Howells /** event address */
156674e95caSDavid Howells struct snd_seq_addr {
157674e95caSDavid Howells 	unsigned char client;	/**< Client number:         0..255, 255 = broadcast to all clients */
158674e95caSDavid Howells 	unsigned char port;	/**< Port within client:    0..255, 255 = broadcast to all ports */
159674e95caSDavid Howells };
160674e95caSDavid Howells 
161674e95caSDavid Howells /** port connection */
162674e95caSDavid Howells struct snd_seq_connect {
163674e95caSDavid Howells 	struct snd_seq_addr sender;
164674e95caSDavid Howells 	struct snd_seq_addr dest;
165674e95caSDavid Howells };
166674e95caSDavid Howells 
167674e95caSDavid Howells 
168674e95caSDavid Howells #define SNDRV_SEQ_ADDRESS_UNKNOWN	253	/* unknown source */
169674e95caSDavid Howells #define SNDRV_SEQ_ADDRESS_SUBSCRIBERS	254	/* send event to all subscribed ports */
170674e95caSDavid Howells #define SNDRV_SEQ_ADDRESS_BROADCAST	255	/* send event to all queues/clients/ports/channels */
171674e95caSDavid Howells #define SNDRV_SEQ_QUEUE_DIRECT		253	/* direct dispatch */
172674e95caSDavid Howells 
173674e95caSDavid Howells 	/* event mode flag - NOTE: only 8 bits available! */
174674e95caSDavid Howells #define SNDRV_SEQ_TIME_STAMP_TICK	(0<<0) /* timestamp in clock ticks */
175674e95caSDavid Howells #define SNDRV_SEQ_TIME_STAMP_REAL	(1<<0) /* timestamp in real time */
176674e95caSDavid Howells #define SNDRV_SEQ_TIME_STAMP_MASK	(1<<0)
177674e95caSDavid Howells 
178674e95caSDavid Howells #define SNDRV_SEQ_TIME_MODE_ABS		(0<<1)	/* absolute timestamp */
179674e95caSDavid Howells #define SNDRV_SEQ_TIME_MODE_REL		(1<<1)	/* relative to current time */
180674e95caSDavid Howells #define SNDRV_SEQ_TIME_MODE_MASK	(1<<1)
181674e95caSDavid Howells 
182674e95caSDavid Howells #define SNDRV_SEQ_EVENT_LENGTH_FIXED	(0<<2)	/* fixed event size */
183674e95caSDavid Howells #define SNDRV_SEQ_EVENT_LENGTH_VARIABLE	(1<<2)	/* variable event size */
184674e95caSDavid Howells #define SNDRV_SEQ_EVENT_LENGTH_VARUSR	(2<<2)	/* variable event size - user memory space */
185674e95caSDavid Howells #define SNDRV_SEQ_EVENT_LENGTH_MASK	(3<<2)
186674e95caSDavid Howells 
187674e95caSDavid Howells #define SNDRV_SEQ_PRIORITY_NORMAL	(0<<4)	/* normal priority */
188674e95caSDavid Howells #define SNDRV_SEQ_PRIORITY_HIGH		(1<<4)	/* event should be processed before others */
189674e95caSDavid Howells #define SNDRV_SEQ_PRIORITY_MASK		(1<<4)
190674e95caSDavid Howells 
191674e95caSDavid Howells 
192674e95caSDavid Howells 	/* note event */
193674e95caSDavid Howells struct snd_seq_ev_note {
194674e95caSDavid Howells 	unsigned char channel;
195674e95caSDavid Howells 	unsigned char note;
196674e95caSDavid Howells 	unsigned char velocity;
197674e95caSDavid Howells 	unsigned char off_velocity;	/* only for SNDRV_SEQ_EVENT_NOTE */
198674e95caSDavid Howells 	unsigned int duration;		/* only for SNDRV_SEQ_EVENT_NOTE */
199674e95caSDavid Howells };
200674e95caSDavid Howells 
201674e95caSDavid Howells 	/* controller event */
202674e95caSDavid Howells struct snd_seq_ev_ctrl {
203674e95caSDavid Howells 	unsigned char channel;
204674e95caSDavid Howells 	unsigned char unused1, unused2, unused3;	/* pad */
205674e95caSDavid Howells 	unsigned int param;
206674e95caSDavid Howells 	signed int value;
207674e95caSDavid Howells };
208674e95caSDavid Howells 
209674e95caSDavid Howells 	/* generic set of bytes (12x8 bit) */
210674e95caSDavid Howells struct snd_seq_ev_raw8 {
211674e95caSDavid Howells 	unsigned char d[12];	/* 8 bit value */
212674e95caSDavid Howells };
213674e95caSDavid Howells 
214674e95caSDavid Howells 	/* generic set of integers (3x32 bit) */
215674e95caSDavid Howells struct snd_seq_ev_raw32 {
216674e95caSDavid Howells 	unsigned int d[3];	/* 32 bit value */
217674e95caSDavid Howells };
218674e95caSDavid Howells 
219674e95caSDavid Howells 	/* external stored data */
220674e95caSDavid Howells struct snd_seq_ev_ext {
221674e95caSDavid Howells 	unsigned int len;	/* length of data */
222674e95caSDavid Howells 	void *ptr;		/* pointer to data (note: maybe 64-bit) */
223674e95caSDavid Howells } __attribute__((packed));
224674e95caSDavid Howells 
225674e95caSDavid Howells struct snd_seq_result {
226674e95caSDavid Howells 	int event;		/* processed event type */
227674e95caSDavid Howells 	int result;
228674e95caSDavid Howells };
229674e95caSDavid Howells 
230674e95caSDavid Howells 
231674e95caSDavid Howells struct snd_seq_real_time {
232674e95caSDavid Howells 	unsigned int tv_sec;	/* seconds */
233674e95caSDavid Howells 	unsigned int tv_nsec;	/* nanoseconds */
234674e95caSDavid Howells };
235674e95caSDavid Howells 
236674e95caSDavid Howells typedef unsigned int snd_seq_tick_time_t;	/* midi ticks */
237674e95caSDavid Howells 
238674e95caSDavid Howells union snd_seq_timestamp {
239674e95caSDavid Howells 	snd_seq_tick_time_t tick;
240674e95caSDavid Howells 	struct snd_seq_real_time time;
241674e95caSDavid Howells };
242674e95caSDavid Howells 
243674e95caSDavid Howells struct snd_seq_queue_skew {
244674e95caSDavid Howells 	unsigned int value;
245674e95caSDavid Howells 	unsigned int base;
246674e95caSDavid Howells };
247674e95caSDavid Howells 
248674e95caSDavid Howells 	/* queue timer control */
249674e95caSDavid Howells struct snd_seq_ev_queue_control {
250674e95caSDavid Howells 	unsigned char queue;			/* affected queue */
251674e95caSDavid Howells 	unsigned char pad[3];			/* reserved */
252674e95caSDavid Howells 	union {
253674e95caSDavid Howells 		signed int value;		/* affected value (e.g. tempo) */
254674e95caSDavid Howells 		union snd_seq_timestamp time;	/* time */
255674e95caSDavid Howells 		unsigned int position;		/* sync position */
256674e95caSDavid Howells 		struct snd_seq_queue_skew skew;
257674e95caSDavid Howells 		unsigned int d32[2];
258674e95caSDavid Howells 		unsigned char d8[8];
259674e95caSDavid Howells 	} param;
260674e95caSDavid Howells };
261674e95caSDavid Howells 
262674e95caSDavid Howells 	/* quoted event - inside the kernel only */
263674e95caSDavid Howells struct snd_seq_ev_quote {
264674e95caSDavid Howells 	struct snd_seq_addr origin;		/* original sender */
265674e95caSDavid Howells 	unsigned short value;		/* optional data */
266674e95caSDavid Howells 	struct snd_seq_event *event;		/* quoted event */
267674e95caSDavid Howells } __attribute__((packed));
268674e95caSDavid Howells 
269674e95caSDavid Howells 
270674e95caSDavid Howells 	/* sequencer event */
271674e95caSDavid Howells struct snd_seq_event {
272674e95caSDavid Howells 	snd_seq_event_type_t type;	/* event type */
273674e95caSDavid Howells 	unsigned char flags;		/* event flags */
274674e95caSDavid Howells 	char tag;
275674e95caSDavid Howells 
276674e95caSDavid Howells 	unsigned char queue;		/* schedule queue */
277674e95caSDavid Howells 	union snd_seq_timestamp time;	/* schedule time */
278674e95caSDavid Howells 
279674e95caSDavid Howells 
280674e95caSDavid Howells 	struct snd_seq_addr source;	/* source address */
281674e95caSDavid Howells 	struct snd_seq_addr dest;	/* destination address */
282674e95caSDavid Howells 
283674e95caSDavid Howells 	union {				/* event data... */
284674e95caSDavid Howells 		struct snd_seq_ev_note note;
285674e95caSDavid Howells 		struct snd_seq_ev_ctrl control;
286674e95caSDavid Howells 		struct snd_seq_ev_raw8 raw8;
287674e95caSDavid Howells 		struct snd_seq_ev_raw32 raw32;
288674e95caSDavid Howells 		struct snd_seq_ev_ext ext;
289674e95caSDavid Howells 		struct snd_seq_ev_queue_control queue;
290674e95caSDavid Howells 		union snd_seq_timestamp time;
291674e95caSDavid Howells 		struct snd_seq_addr addr;
292674e95caSDavid Howells 		struct snd_seq_connect connect;
293674e95caSDavid Howells 		struct snd_seq_result result;
294674e95caSDavid Howells 		struct snd_seq_ev_quote quote;
295674e95caSDavid Howells 	} data;
296674e95caSDavid Howells };
297674e95caSDavid Howells 
298674e95caSDavid Howells 
299674e95caSDavid Howells /*
300674e95caSDavid Howells  * bounce event - stored as variable size data
301674e95caSDavid Howells  */
302674e95caSDavid Howells struct snd_seq_event_bounce {
303674e95caSDavid Howells 	int err;
304674e95caSDavid Howells 	struct snd_seq_event event;
305674e95caSDavid Howells 	/* external data follows here. */
306674e95caSDavid Howells };
307674e95caSDavid Howells 
308674e95caSDavid Howells 
309674e95caSDavid Howells 	/* system information */
310674e95caSDavid Howells struct snd_seq_system_info {
311674e95caSDavid Howells 	int queues;			/* maximum queues count */
312674e95caSDavid Howells 	int clients;			/* maximum clients count */
313674e95caSDavid Howells 	int ports;			/* maximum ports per client */
314674e95caSDavid Howells 	int channels;			/* maximum channels per port */
315674e95caSDavid Howells 	int cur_clients;		/* current clients */
316674e95caSDavid Howells 	int cur_queues;			/* current queues */
317674e95caSDavid Howells 	char reserved[24];
318674e95caSDavid Howells };
319674e95caSDavid Howells 
320674e95caSDavid Howells 
321674e95caSDavid Howells 	/* system running information */
322674e95caSDavid Howells struct snd_seq_running_info {
323674e95caSDavid Howells 	unsigned char client;		/* client id */
324674e95caSDavid Howells 	unsigned char big_endian;	/* 1 = big-endian */
325674e95caSDavid Howells 	unsigned char cpu_mode;		/* 4 = 32bit, 8 = 64bit */
326674e95caSDavid Howells 	unsigned char pad;		/* reserved */
327674e95caSDavid Howells 	unsigned char reserved[12];
328674e95caSDavid Howells };
329674e95caSDavid Howells 
330674e95caSDavid Howells 
331674e95caSDavid Howells 	/* known client numbers */
332674e95caSDavid Howells #define SNDRV_SEQ_CLIENT_SYSTEM		0
333674e95caSDavid Howells 	/* internal client numbers */
334674e95caSDavid Howells #define SNDRV_SEQ_CLIENT_DUMMY		14	/* midi through */
335674e95caSDavid Howells #define SNDRV_SEQ_CLIENT_OSS		15	/* oss sequencer emulator */
336674e95caSDavid Howells 
337674e95caSDavid Howells 
338674e95caSDavid Howells 	/* client types */
339674e95caSDavid Howells typedef int __bitwise snd_seq_client_type_t;
340674e95caSDavid Howells #define	NO_CLIENT	((__force snd_seq_client_type_t) 0)
341674e95caSDavid Howells #define	USER_CLIENT	((__force snd_seq_client_type_t) 1)
342674e95caSDavid Howells #define	KERNEL_CLIENT	((__force snd_seq_client_type_t) 2)
343674e95caSDavid Howells 
344674e95caSDavid Howells 	/* event filter flags */
345674e95caSDavid Howells #define SNDRV_SEQ_FILTER_BROADCAST	(1<<0)	/* accept broadcast messages */
346674e95caSDavid Howells #define SNDRV_SEQ_FILTER_MULTICAST	(1<<1)	/* accept multicast messages */
347674e95caSDavid Howells #define SNDRV_SEQ_FILTER_BOUNCE		(1<<2)	/* accept bounce event in error */
348674e95caSDavid Howells #define SNDRV_SEQ_FILTER_USE_EVENT	(1<<31)	/* use event filter */
349674e95caSDavid Howells 
350674e95caSDavid Howells struct snd_seq_client_info {
351674e95caSDavid Howells 	int client;			/* client number to inquire */
352674e95caSDavid Howells 	snd_seq_client_type_t type;	/* client type */
353674e95caSDavid Howells 	char name[64];			/* client name */
354674e95caSDavid Howells 	unsigned int filter;		/* filter flags */
355674e95caSDavid Howells 	unsigned char multicast_filter[8]; /* multicast filter bitmap */
356674e95caSDavid Howells 	unsigned char event_filter[32];	/* event filter bitmap */
357674e95caSDavid Howells 	int num_ports;			/* RO: number of ports */
358674e95caSDavid Howells 	int event_lost;			/* number of lost events */
359674e95caSDavid Howells 	char reserved[64];		/* for future use */
360674e95caSDavid Howells };
361674e95caSDavid Howells 
362674e95caSDavid Howells 
363674e95caSDavid Howells /* client pool size */
364674e95caSDavid Howells struct snd_seq_client_pool {
365674e95caSDavid Howells 	int client;			/* client number to inquire */
366674e95caSDavid Howells 	int output_pool;		/* outgoing (write) pool size */
367674e95caSDavid Howells 	int input_pool;			/* incoming (read) pool size */
368674e95caSDavid Howells 	int output_room;		/* minimum free pool size for select/blocking mode */
369674e95caSDavid Howells 	int output_free;		/* unused size */
370674e95caSDavid Howells 	int input_free;			/* unused size */
371674e95caSDavid Howells 	char reserved[64];
372674e95caSDavid Howells };
373674e95caSDavid Howells 
374674e95caSDavid Howells 
375674e95caSDavid Howells /* Remove events by specified criteria */
376674e95caSDavid Howells 
377674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_INPUT		(1<<0)	/* Flush input queues */
378674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_OUTPUT		(1<<1)	/* Flush output queues */
379674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_DEST		(1<<2)	/* Restrict by destination q:client:port */
380674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_DEST_CHANNEL	(1<<3)	/* Restrict by channel */
381674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_TIME_BEFORE	(1<<4)	/* Restrict to before time */
382674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_TIME_AFTER	(1<<5)	/* Restrict to time or after */
383674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_TIME_TICK	(1<<6)	/* Time is in ticks */
384674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_EVENT_TYPE	(1<<7)	/* Restrict to event type */
385674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_IGNORE_OFF 	(1<<8)	/* Do not flush off events */
386674e95caSDavid Howells #define SNDRV_SEQ_REMOVE_TAG_MATCH 	(1<<9)	/* Restrict to events with given tag */
387674e95caSDavid Howells 
388674e95caSDavid Howells struct snd_seq_remove_events {
389674e95caSDavid Howells 	unsigned int  remove_mode;	/* Flags that determine what gets removed */
390674e95caSDavid Howells 
391674e95caSDavid Howells 	union snd_seq_timestamp time;
392674e95caSDavid Howells 
393674e95caSDavid Howells 	unsigned char queue;	/* Queue for REMOVE_DEST */
394674e95caSDavid Howells 	struct snd_seq_addr dest;	/* Address for REMOVE_DEST */
395674e95caSDavid Howells 	unsigned char channel;	/* Channel for REMOVE_DEST */
396674e95caSDavid Howells 
397674e95caSDavid Howells 	int  type;	/* For REMOVE_EVENT_TYPE */
398674e95caSDavid Howells 	char  tag;	/* Tag for REMOVE_TAG */
399674e95caSDavid Howells 
400674e95caSDavid Howells 	int  reserved[10];	/* To allow for future binary compatibility */
401674e95caSDavid Howells 
402674e95caSDavid Howells };
403674e95caSDavid Howells 
404674e95caSDavid Howells 
405674e95caSDavid Howells 	/* known port numbers */
406674e95caSDavid Howells #define SNDRV_SEQ_PORT_SYSTEM_TIMER	0
407674e95caSDavid Howells #define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE	1
408674e95caSDavid Howells 
409674e95caSDavid Howells 	/* port capabilities (32 bits) */
410674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_READ		(1<<0)	/* readable from this port */
411674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_WRITE	(1<<1)	/* writable to this port */
412674e95caSDavid Howells 
413674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_SYNC_READ	(1<<2)
414674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_SYNC_WRITE	(1<<3)
415674e95caSDavid Howells 
416674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_DUPLEX	(1<<4)
417674e95caSDavid Howells 
418674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_SUBS_READ	(1<<5)	/* allow read subscription */
419674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_SUBS_WRITE	(1<<6)	/* allow write subscription */
420674e95caSDavid Howells #define SNDRV_SEQ_PORT_CAP_NO_EXPORT	(1<<7)	/* routing not allowed */
421674e95caSDavid Howells 
422674e95caSDavid Howells 	/* port type */
423674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_SPECIFIC	(1<<0)	/* hardware specific */
424674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1)	/* generic MIDI device */
425674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_MIDI_GM	(1<<2)	/* General MIDI compatible device */
426674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_MIDI_GS	(1<<3)	/* GS compatible device */
427674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_MIDI_XG	(1<<4)	/* XG compatible device */
428674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_MIDI_MT32	(1<<5)	/* MT-32 compatible device */
429674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_MIDI_GM2	(1<<6)	/* General MIDI 2 compatible device */
430674e95caSDavid Howells 
431674e95caSDavid Howells /* other standards...*/
432674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_SYNTH	(1<<10)	/* Synth device (no MIDI compatible - direct wavetable) */
433674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11)	/* Sampling device (support sample download) */
434674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_SAMPLE	(1<<12)	/* Sampling device (sample can be downloaded at any time) */
435674e95caSDavid Howells /*...*/
436674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_HARDWARE	(1<<16)	/* driver for a hardware device */
437674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_SOFTWARE	(1<<17)	/* implemented in software */
438674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_SYNTHESIZER	(1<<18)	/* generates sound */
439674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_PORT	(1<<19)	/* connects to other device(s) */
440674e95caSDavid Howells #define SNDRV_SEQ_PORT_TYPE_APPLICATION	(1<<20)	/* application (sequencer/editor) */
441674e95caSDavid Howells 
442674e95caSDavid Howells /* misc. conditioning flags */
443674e95caSDavid Howells #define SNDRV_SEQ_PORT_FLG_GIVEN_PORT	(1<<0)
444674e95caSDavid Howells #define SNDRV_SEQ_PORT_FLG_TIMESTAMP	(1<<1)
445674e95caSDavid Howells #define SNDRV_SEQ_PORT_FLG_TIME_REAL	(1<<2)
446674e95caSDavid Howells 
447674e95caSDavid Howells struct snd_seq_port_info {
448674e95caSDavid Howells 	struct snd_seq_addr addr;	/* client/port numbers */
449674e95caSDavid Howells 	char name[64];			/* port name */
450674e95caSDavid Howells 
451674e95caSDavid Howells 	unsigned int capability;	/* port capability bits */
452674e95caSDavid Howells 	unsigned int type;		/* port type bits */
453674e95caSDavid Howells 	int midi_channels;		/* channels per MIDI port */
454674e95caSDavid Howells 	int midi_voices;		/* voices per MIDI port */
455674e95caSDavid Howells 	int synth_voices;		/* voices per SYNTH port */
456674e95caSDavid Howells 
457674e95caSDavid Howells 	int read_use;			/* R/O: subscribers for output (from this port) */
458674e95caSDavid Howells 	int write_use;			/* R/O: subscribers for input (to this port) */
459674e95caSDavid Howells 
460674e95caSDavid Howells 	void *kernel;			/* reserved for kernel use (must be NULL) */
461674e95caSDavid Howells 	unsigned int flags;		/* misc. conditioning */
462674e95caSDavid Howells 	unsigned char time_queue;	/* queue # for timestamping */
463674e95caSDavid Howells 	char reserved[59];		/* for future use */
464674e95caSDavid Howells };
465674e95caSDavid Howells 
466674e95caSDavid Howells 
467674e95caSDavid Howells /* queue flags */
468674e95caSDavid Howells #define SNDRV_SEQ_QUEUE_FLG_SYNC	(1<<0)	/* sync enabled */
469674e95caSDavid Howells 
470674e95caSDavid Howells /* queue information */
471674e95caSDavid Howells struct snd_seq_queue_info {
472674e95caSDavid Howells 	int queue;		/* queue id */
473674e95caSDavid Howells 
474674e95caSDavid Howells 	/*
475674e95caSDavid Howells 	 *  security settings, only owner of this queue can start/stop timer
476674e95caSDavid Howells 	 *  etc. if the queue is locked for other clients
477674e95caSDavid Howells 	 */
478674e95caSDavid Howells 	int owner;		/* client id for owner of the queue */
479674e95caSDavid Howells 	unsigned locked:1;	/* timing queue locked for other queues */
480674e95caSDavid Howells 	char name[64];		/* name of this queue */
481674e95caSDavid Howells 	unsigned int flags;	/* flags */
482674e95caSDavid Howells 	char reserved[60];	/* for future use */
483674e95caSDavid Howells 
484674e95caSDavid Howells };
485674e95caSDavid Howells 
486674e95caSDavid Howells /* queue info/status */
487674e95caSDavid Howells struct snd_seq_queue_status {
488674e95caSDavid Howells 	int queue;			/* queue id */
489674e95caSDavid Howells 	int events;			/* read-only - queue size */
490674e95caSDavid Howells 	snd_seq_tick_time_t tick;	/* current tick */
491674e95caSDavid Howells 	struct snd_seq_real_time time;	/* current time */
492674e95caSDavid Howells 	int running;			/* running state of queue */
493674e95caSDavid Howells 	int flags;			/* various flags */
494674e95caSDavid Howells 	char reserved[64];		/* for the future */
495674e95caSDavid Howells };
496674e95caSDavid Howells 
497674e95caSDavid Howells 
498674e95caSDavid Howells /* queue tempo */
499674e95caSDavid Howells struct snd_seq_queue_tempo {
500674e95caSDavid Howells 	int queue;			/* sequencer queue */
501674e95caSDavid Howells 	unsigned int tempo;		/* current tempo, us/tick */
502674e95caSDavid Howells 	int ppq;			/* time resolution, ticks/quarter */
503674e95caSDavid Howells 	unsigned int skew_value;	/* queue skew */
504674e95caSDavid Howells 	unsigned int skew_base;		/* queue skew base */
505674e95caSDavid Howells 	char reserved[24];		/* for the future */
506674e95caSDavid Howells };
507674e95caSDavid Howells 
508674e95caSDavid Howells 
509674e95caSDavid Howells /* sequencer timer sources */
510674e95caSDavid Howells #define SNDRV_SEQ_TIMER_ALSA		0	/* ALSA timer */
511674e95caSDavid Howells #define SNDRV_SEQ_TIMER_MIDI_CLOCK	1	/* Midi Clock (CLOCK event) */
512674e95caSDavid Howells #define SNDRV_SEQ_TIMER_MIDI_TICK	2	/* Midi Timer Tick (TICK event) */
513674e95caSDavid Howells 
514674e95caSDavid Howells /* queue timer info */
515674e95caSDavid Howells struct snd_seq_queue_timer {
516674e95caSDavid Howells 	int queue;			/* sequencer queue */
517674e95caSDavid Howells 	int type;			/* source timer type */
518674e95caSDavid Howells 	union {
519674e95caSDavid Howells 		struct {
520674e95caSDavid Howells 			struct snd_timer_id id;	/* ALSA's timer ID */
521674e95caSDavid Howells 			unsigned int resolution;	/* resolution in Hz */
522674e95caSDavid Howells 		} alsa;
523674e95caSDavid Howells 	} u;
524674e95caSDavid Howells 	char reserved[64];		/* for the future use */
525674e95caSDavid Howells };
526674e95caSDavid Howells 
527674e95caSDavid Howells 
528674e95caSDavid Howells struct snd_seq_queue_client {
529674e95caSDavid Howells 	int queue;		/* sequencer queue */
530674e95caSDavid Howells 	int client;		/* sequencer client */
531674e95caSDavid Howells 	int used;		/* queue is used with this client
532674e95caSDavid Howells 				   (must be set for accepting events) */
533674e95caSDavid Howells 	/* per client watermarks */
534674e95caSDavid Howells 	char reserved[64];	/* for future use */
535674e95caSDavid Howells };
536674e95caSDavid Howells 
537674e95caSDavid Howells 
538674e95caSDavid Howells #define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE	(1<<0)	/* exclusive connection */
539674e95caSDavid Howells #define SNDRV_SEQ_PORT_SUBS_TIMESTAMP	(1<<1)
540674e95caSDavid Howells #define SNDRV_SEQ_PORT_SUBS_TIME_REAL	(1<<2)
541674e95caSDavid Howells 
542674e95caSDavid Howells struct snd_seq_port_subscribe {
543674e95caSDavid Howells 	struct snd_seq_addr sender;	/* sender address */
544674e95caSDavid Howells 	struct snd_seq_addr dest;	/* destination address */
545674e95caSDavid Howells 	unsigned int voices;		/* number of voices to be allocated (0 = don't care) */
546674e95caSDavid Howells 	unsigned int flags;		/* modes */
547674e95caSDavid Howells 	unsigned char queue;		/* input time-stamp queue (optional) */
548674e95caSDavid Howells 	unsigned char pad[3];		/* reserved */
549674e95caSDavid Howells 	char reserved[64];
550674e95caSDavid Howells };
551674e95caSDavid Howells 
552674e95caSDavid Howells /* type of query subscription */
553674e95caSDavid Howells #define SNDRV_SEQ_QUERY_SUBS_READ	0
554674e95caSDavid Howells #define SNDRV_SEQ_QUERY_SUBS_WRITE	1
555674e95caSDavid Howells 
556674e95caSDavid Howells struct snd_seq_query_subs {
557674e95caSDavid Howells 	struct snd_seq_addr root;	/* client/port id to be searched */
558674e95caSDavid Howells 	int type;		/* READ or WRITE */
559674e95caSDavid Howells 	int index;		/* 0..N-1 */
560674e95caSDavid Howells 	int num_subs;		/* R/O: number of subscriptions on this port */
561674e95caSDavid Howells 	struct snd_seq_addr addr;	/* R/O: result */
562674e95caSDavid Howells 	unsigned char queue;	/* R/O: result */
563674e95caSDavid Howells 	unsigned int flags;	/* R/O: result */
564674e95caSDavid Howells 	char reserved[64];	/* for future use */
565674e95caSDavid Howells };
566674e95caSDavid Howells 
567674e95caSDavid Howells 
568674e95caSDavid Howells /*
569674e95caSDavid Howells  *  IOCTL commands
570674e95caSDavid Howells  */
571674e95caSDavid Howells 
572674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_PVERSION	_IOR ('S', 0x00, int)
573674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_CLIENT_ID	_IOR ('S', 0x01, int)
574674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SYSTEM_INFO	_IOWR('S', 0x02, struct snd_seq_system_info)
575674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_RUNNING_MODE	_IOWR('S', 0x03, struct snd_seq_running_info)
576674e95caSDavid Howells 
577674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO	_IOWR('S', 0x10, struct snd_seq_client_info)
578674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO	_IOW ('S', 0x11, struct snd_seq_client_info)
579674e95caSDavid Howells 
580674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_CREATE_PORT	_IOWR('S', 0x20, struct snd_seq_port_info)
581674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_DELETE_PORT	_IOW ('S', 0x21, struct snd_seq_port_info)
582674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_PORT_INFO	_IOWR('S', 0x22, struct snd_seq_port_info)
583674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_PORT_INFO	_IOW ('S', 0x23, struct snd_seq_port_info)
584674e95caSDavid Howells 
585674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT	_IOW ('S', 0x30, struct snd_seq_port_subscribe)
586674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct snd_seq_port_subscribe)
587674e95caSDavid Howells 
588674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_CREATE_QUEUE	_IOWR('S', 0x32, struct snd_seq_queue_info)
589674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_DELETE_QUEUE	_IOW ('S', 0x33, struct snd_seq_queue_info)
590674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO	_IOWR('S', 0x34, struct snd_seq_queue_info)
591674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO	_IOWR('S', 0x35, struct snd_seq_queue_info)
592674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE	_IOWR('S', 0x36, struct snd_seq_queue_info)
593674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status)
594674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO	_IOWR('S', 0x41, struct snd_seq_queue_tempo)
595674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO	_IOW ('S', 0x42, struct snd_seq_queue_tempo)
596674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER	_IOWR('S', 0x43, struct snd_seq_queue_owner)
597674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER	_IOW ('S', 0x44, struct snd_seq_queue_owner)
598674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER	_IOWR('S', 0x45, struct snd_seq_queue_timer)
599674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER	_IOW ('S', 0x46, struct snd_seq_queue_timer)
600674e95caSDavid Howells /* XXX
601674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC	_IOWR('S', 0x53, struct snd_seq_queue_sync)
602674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC	_IOW ('S', 0x54, struct snd_seq_queue_sync)
603674e95caSDavid Howells */
604674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT	_IOWR('S', 0x49, struct snd_seq_queue_client)
605674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT	_IOW ('S', 0x4a, struct snd_seq_queue_client)
606674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL	_IOWR('S', 0x4b, struct snd_seq_client_pool)
607674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL	_IOW ('S', 0x4c, struct snd_seq_client_pool)
608674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_REMOVE_EVENTS	_IOW ('S', 0x4e, struct snd_seq_remove_events)
609674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_QUERY_SUBS	_IOWR('S', 0x4f, struct snd_seq_query_subs)
610674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION	_IOWR('S', 0x50, struct snd_seq_port_subscribe)
611674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT	_IOWR('S', 0x51, struct snd_seq_client_info)
612674e95caSDavid Howells #define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT	_IOWR('S', 0x52, struct snd_seq_port_info)
613674e95caSDavid Howells 
614674e95caSDavid Howells #endif /* _UAPI__SOUND_ASEQUENCER_H */
615