• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  *  Main header file for the ALSA sequencer
4  *  Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
5  *            (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
6  *
7  *
8  *   This program is free software; you can redistribute it and/or modify
9  *   it under the terms of the GNU General Public License as published by
10  *   the Free Software Foundation; either version 2 of the License, or
11  *   (at your option) any later version.
12  *
13  *   This program is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with this program; if not, write to the Free Software
20  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  *
22  */
23 #ifndef __SOUND_ASEQUENCER_H
24 #define __SOUND_ASEQUENCER_H
25 
26 #include <sound/asound.h>
27 
28 /** version of the sequencer */
29 #define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 3)
30 
31 /**
32  * definition of sequencer event types
33  */
34 
35 /** system messages
36  * event data type = #snd_seq_result
37  */
38 #define SNDRV_SEQ_EVENT_SYSTEM		0
39 #define SNDRV_SEQ_EVENT_RESULT		1
40 
41 /** note messages (channel specific)
42  * event data type = #snd_seq_ev_note
43  */
44 #define SNDRV_SEQ_EVENT_NOTE		5
45 #define SNDRV_SEQ_EVENT_NOTEON		6
46 #define SNDRV_SEQ_EVENT_NOTEOFF		7
47 #define SNDRV_SEQ_EVENT_KEYPRESS	8
48 
49 /** control messages (channel specific)
50  * event data type = #snd_seq_ev_ctrl
51  */
52 #define SNDRV_SEQ_EVENT_CONTROLLER	10
53 #define SNDRV_SEQ_EVENT_PGMCHANGE	11
54 #define SNDRV_SEQ_EVENT_CHANPRESS	12
55 #define SNDRV_SEQ_EVENT_PITCHBEND	13	/**< from -8192 to 8191 */
56 #define SNDRV_SEQ_EVENT_CONTROL14	14	/**< 14 bit controller value */
57 #define SNDRV_SEQ_EVENT_NONREGPARAM	15	/**< 14 bit NRPN address + 14 bit unsigned value */
58 #define SNDRV_SEQ_EVENT_REGPARAM	16	/**< 14 bit RPN address + 14 bit unsigned value */
59 
60 /** synchronisation messages
61  * event data type = #snd_seq_ev_ctrl
62  */
63 #define SNDRV_SEQ_EVENT_SONGPOS		20	/* Song Position Pointer with LSB and MSB values */
64 #define SNDRV_SEQ_EVENT_SONGSEL		21	/* Song Select with song ID number */
65 #define SNDRV_SEQ_EVENT_QFRAME		22	/* midi time code quarter frame */
66 #define SNDRV_SEQ_EVENT_TIMESIGN	23	/* SMF Time Signature event */
67 #define SNDRV_SEQ_EVENT_KEYSIGN		24	/* SMF Key Signature event */
68 
69 /** timer messages
70  * event data type = snd_seq_ev_queue_control
71  */
72 #define SNDRV_SEQ_EVENT_START		30	/* midi Real Time Start message */
73 #define SNDRV_SEQ_EVENT_CONTINUE	31	/* midi Real Time Continue message */
74 #define SNDRV_SEQ_EVENT_STOP		32	/* midi Real Time Stop message */
75 #define	SNDRV_SEQ_EVENT_SETPOS_TICK	33	/* set tick queue position */
76 #define SNDRV_SEQ_EVENT_SETPOS_TIME	34	/* set realtime queue position */
77 #define SNDRV_SEQ_EVENT_TEMPO		35	/* (SMF) Tempo event */
78 #define SNDRV_SEQ_EVENT_CLOCK		36	/* midi Real Time Clock message */
79 #define SNDRV_SEQ_EVENT_TICK		37	/* midi Real Time Tick message */
80 #define SNDRV_SEQ_EVENT_QUEUE_SKEW	38	/* skew queue tempo */
81 
82 /** others
83  * event data type = none
84  */
85 #define SNDRV_SEQ_EVENT_TUNE_REQUEST	40	/* tune request */
86 #define SNDRV_SEQ_EVENT_RESET		41	/* reset to power-on state */
87 #define SNDRV_SEQ_EVENT_SENSING		42	/* "active sensing" event */
88 
89 /** echo back, kernel private messages
90  * event data type = any type
91  */
92 #define SNDRV_SEQ_EVENT_ECHO		50	/* echo event */
93 #define SNDRV_SEQ_EVENT_OSS		51	/* OSS raw event */
94 
95 /** system status messages (broadcast for subscribers)
96  * event data type = snd_seq_addr
97  */
98 #define SNDRV_SEQ_EVENT_CLIENT_START	60	/* new client has connected */
99 #define SNDRV_SEQ_EVENT_CLIENT_EXIT	61	/* client has left the system */
100 #define SNDRV_SEQ_EVENT_CLIENT_CHANGE	62	/* client status/info has changed */
101 #define SNDRV_SEQ_EVENT_PORT_START	63	/* new port was created */
102 #define SNDRV_SEQ_EVENT_PORT_EXIT	64	/* port was deleted from system */
103 #define SNDRV_SEQ_EVENT_PORT_CHANGE	65	/* port status/info has changed */
104 
105 /** port connection changes
106  * event data type = snd_seq_connect
107  */
108 #define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED	66	/* ports connected */
109 #define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67	/* ports disconnected */
110 
111 /* 70-89:  synthesizer events - obsoleted */
112 
113 /** user-defined events with fixed length
114  * event data type = any
115  */
116 #define SNDRV_SEQ_EVENT_USR0		90
117 #define SNDRV_SEQ_EVENT_USR1		91
118 #define SNDRV_SEQ_EVENT_USR2		92
119 #define SNDRV_SEQ_EVENT_USR3		93
120 #define SNDRV_SEQ_EVENT_USR4		94
121 #define SNDRV_SEQ_EVENT_USR5		95
122 #define SNDRV_SEQ_EVENT_USR6		96
123 #define SNDRV_SEQ_EVENT_USR7		97
124 #define SNDRV_SEQ_EVENT_USR8		98
125 #define SNDRV_SEQ_EVENT_USR9		99
126 
127 /* 100-118: instrument layer - obsoleted */
128 /* 119-129: reserved */
129 
130 /* 130-139: variable length events
131  * event data type = snd_seq_ev_ext
132  * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set)
133  */
134 #define SNDRV_SEQ_EVENT_SYSEX		130	/* system exclusive data (variable length) */
135 #define SNDRV_SEQ_EVENT_BOUNCE		131	/* error event */
136 /* 132-134: reserved */
137 #define SNDRV_SEQ_EVENT_USR_VAR0	135
138 #define SNDRV_SEQ_EVENT_USR_VAR1	136
139 #define SNDRV_SEQ_EVENT_USR_VAR2	137
140 #define SNDRV_SEQ_EVENT_USR_VAR3	138
141 #define SNDRV_SEQ_EVENT_USR_VAR4	139
142 
143 /* 150-151: kernel events with quote - DO NOT use in user clients */
144 #define SNDRV_SEQ_EVENT_KERNEL_ERROR	150
145 #define SNDRV_SEQ_EVENT_KERNEL_QUOTE	151	/* obsolete */
146 
147 /* 152-191: reserved */
148 
149 /* 192-254: hardware specific events */
150 
151 /* 255: special event */
152 #define SNDRV_SEQ_EVENT_NONE		255
153 
154 
155 typedef unsigned char snd_seq_event_type_t;
156 
157 /** event address */
158 struct snd_seq_addr {
159 	unsigned char client;	/**< Client number:         0..255, 255 = broadcast to all clients */
160 	unsigned char port;	/**< Port within client:    0..255, 255 = broadcast to all ports */
161 };
162 
163 /** port connection */
164 struct snd_seq_connect {
165 	struct snd_seq_addr sender;
166 	struct snd_seq_addr dest;
167 };
168 
169 
170 #define SNDRV_SEQ_ADDRESS_UNKNOWN	253	/* unknown source */
171 #define SNDRV_SEQ_ADDRESS_SUBSCRIBERS	254	/* send event to all subscribed ports */
172 #define SNDRV_SEQ_ADDRESS_BROADCAST	255	/* send event to all queues/clients/ports/channels */
173 #define SNDRV_SEQ_QUEUE_DIRECT		253	/* direct dispatch */
174 
175 	/* event mode flag - NOTE: only 8 bits available! */
176 #define SNDRV_SEQ_TIME_STAMP_TICK	(0<<0) /* timestamp in clock ticks */
177 #define SNDRV_SEQ_TIME_STAMP_REAL	(1<<0) /* timestamp in real time */
178 #define SNDRV_SEQ_TIME_STAMP_MASK	(1<<0)
179 
180 #define SNDRV_SEQ_TIME_MODE_ABS		(0<<1)	/* absolute timestamp */
181 #define SNDRV_SEQ_TIME_MODE_REL		(1<<1)	/* relative to current time */
182 #define SNDRV_SEQ_TIME_MODE_MASK	(1<<1)
183 
184 #define SNDRV_SEQ_EVENT_LENGTH_FIXED	(0<<2)	/* fixed event size */
185 #define SNDRV_SEQ_EVENT_LENGTH_VARIABLE	(1<<2)	/* variable event size */
186 #define SNDRV_SEQ_EVENT_LENGTH_VARUSR	(2<<2)	/* variable event size - user memory space */
187 #define SNDRV_SEQ_EVENT_LENGTH_MASK	(3<<2)
188 
189 #define SNDRV_SEQ_PRIORITY_NORMAL	(0<<4)	/* normal priority */
190 #define SNDRV_SEQ_PRIORITY_HIGH		(1<<4)	/* event should be processed before others */
191 #define SNDRV_SEQ_PRIORITY_MASK		(1<<4)
192 
193 #define SNDRV_SEQ_EVENT_UMP		(1<<5)	/* event holds a UMP packet */
194 
195 	/* note event */
196 struct snd_seq_ev_note {
197 	unsigned char channel;
198 	unsigned char note;
199 	unsigned char velocity;
200 	unsigned char off_velocity;	/* only for SNDRV_SEQ_EVENT_NOTE */
201 	unsigned int duration;		/* only for SNDRV_SEQ_EVENT_NOTE */
202 };
203 
204 	/* controller event */
205 struct snd_seq_ev_ctrl {
206 	unsigned char channel;
207 	unsigned char unused1, unused2, unused3;	/* pad */
208 	unsigned int param;
209 	signed int value;
210 };
211 
212 	/* generic set of bytes (12x8 bit) */
213 struct snd_seq_ev_raw8 {
214 	unsigned char d[12];	/* 8 bit value */
215 };
216 
217 	/* generic set of integers (3x32 bit) */
218 struct snd_seq_ev_raw32 {
219 	unsigned int d[3];	/* 32 bit value */
220 };
221 
222 	/* external stored data */
223 struct snd_seq_ev_ext {
224 	unsigned int len;	/* length of data */
225 	void *ptr;		/* pointer to data (note: maybe 64-bit) */
226 } __attribute__((packed));
227 
228 struct snd_seq_result {
229 	int event;		/* processed event type */
230 	int result;
231 };
232 
233 
234 struct snd_seq_real_time {
235 	unsigned int tv_sec;	/* seconds */
236 	unsigned int tv_nsec;	/* nanoseconds */
237 };
238 
239 typedef unsigned int snd_seq_tick_time_t;	/* midi ticks */
240 
241 union snd_seq_timestamp {
242 	snd_seq_tick_time_t tick;
243 	struct snd_seq_real_time time;
244 };
245 
246 struct snd_seq_queue_skew {
247 	unsigned int value;
248 	unsigned int base;
249 };
250 
251 	/* queue timer control */
252 struct snd_seq_ev_queue_control {
253 	unsigned char queue;			/* affected queue */
254 	unsigned char pad[3];			/* reserved */
255 	union {
256 		signed int value;		/* affected value (e.g. tempo) */
257 		union snd_seq_timestamp time;	/* time */
258 		unsigned int position;		/* sync position */
259 		struct snd_seq_queue_skew skew;
260 		unsigned int d32[2];
261 		unsigned char d8[8];
262 	} param;
263 };
264 
265 	/* quoted event - inside the kernel only */
266 struct snd_seq_ev_quote {
267 	struct snd_seq_addr origin;		/* original sender */
268 	unsigned short value;		/* optional data */
269 	struct snd_seq_event *event;		/* quoted event */
270 } __attribute__((packed));
271 
272 union snd_seq_event_data { /* event data... */
273 	struct snd_seq_ev_note note;
274 	struct snd_seq_ev_ctrl control;
275 	struct snd_seq_ev_raw8 raw8;
276 	struct snd_seq_ev_raw32 raw32;
277 	struct snd_seq_ev_ext ext;
278 	struct snd_seq_ev_queue_control queue;
279 	union snd_seq_timestamp time;
280 	struct snd_seq_addr addr;
281 	struct snd_seq_connect connect;
282 	struct snd_seq_result result;
283 	struct snd_seq_ev_quote quote;
284 };
285 
286 	/* sequencer event */
287 struct snd_seq_event {
288 	snd_seq_event_type_t type;	/* event type */
289 	unsigned char flags;		/* event flags */
290 	char tag;
291 
292 	unsigned char queue;		/* schedule queue */
293 	union snd_seq_timestamp time;	/* schedule time */
294 
295 	struct snd_seq_addr source;	/* source address */
296 	struct snd_seq_addr dest;	/* destination address */
297 
298 	union snd_seq_event_data data;
299 };
300 
301 	/* (compatible) event for UMP-capable clients */
302 struct snd_seq_ump_event {
303 	snd_seq_event_type_t type;	/* event type */
304 	unsigned char flags;		/* event flags */
305 	char tag;
306 	unsigned char queue;		/* schedule queue */
307 	union snd_seq_timestamp time;	/* schedule time */
308 	struct snd_seq_addr source;	/* source address */
309 	struct snd_seq_addr dest;	/* destination address */
310 
311 	union {
312 		union snd_seq_event_data data;
313 		unsigned int ump[4];
314 	};
315 };
316 
317 /*
318  * bounce event - stored as variable size data
319  */
320 struct snd_seq_event_bounce {
321 	int err;
322 	struct snd_seq_event event;
323 	/* external data follows here. */
324 };
325 
326 
327 	/* system information */
328 struct snd_seq_system_info {
329 	int queues;			/* maximum queues count */
330 	int clients;			/* maximum clients count */
331 	int ports;			/* maximum ports per client */
332 	int channels;			/* maximum channels per port */
333 	int cur_clients;		/* current clients */
334 	int cur_queues;			/* current queues */
335 	char reserved[24];
336 };
337 
338 
339 	/* system running information */
340 struct snd_seq_running_info {
341 	unsigned char client;		/* client id */
342 	unsigned char big_endian;	/* 1 = big-endian */
343 	unsigned char cpu_mode;		/* 4 = 32bit, 8 = 64bit */
344 	unsigned char pad;		/* reserved */
345 	unsigned char reserved[12];
346 };
347 
348 
349 	/* known client numbers */
350 #define SNDRV_SEQ_CLIENT_SYSTEM		0
351 	/* internal client numbers */
352 #define SNDRV_SEQ_CLIENT_DUMMY		14	/* midi through */
353 #define SNDRV_SEQ_CLIENT_OSS		15	/* oss sequencer emulator */
354 
355 
356 	/* client types */
357 typedef int __bitwise snd_seq_client_type_t;
358 #define	NO_CLIENT	((snd_seq_client_type_t) 0)
359 #define	USER_CLIENT	((snd_seq_client_type_t) 1)
360 #define	KERNEL_CLIENT	((snd_seq_client_type_t) 2)
361 
362 	/* event filter flags */
363 #define SNDRV_SEQ_FILTER_BROADCAST	(1U<<0)	/* accept broadcast messages */
364 #define SNDRV_SEQ_FILTER_MULTICAST	(1U<<1)	/* accept multicast messages */
365 #define SNDRV_SEQ_FILTER_BOUNCE		(1U<<2)	/* accept bounce event in error */
366 #define SNDRV_SEQ_FILTER_NO_CONVERT	(1U<<30) /* don't convert UMP events */
367 #define SNDRV_SEQ_FILTER_USE_EVENT	(1U<<31)	/* use event filter */
368 
369 struct snd_seq_client_info {
370 	int client;			/* client number to inquire */
371 	snd_seq_client_type_t type;	/* client type */
372 	char name[64];			/* client name */
373 	unsigned int filter;		/* filter flags */
374 	unsigned char multicast_filter[8]; /* multicast filter bitmap */
375 	unsigned char event_filter[32];	/* event filter bitmap */
376 	int num_ports;			/* RO: number of ports */
377 	int event_lost;			/* number of lost events */
378 	int card;			/* RO: card number[kernel] */
379 	int pid;			/* RO: pid[user] */
380 	unsigned int midi_version;	/* MIDI version */
381 	unsigned int group_filter;	/* UMP group filter bitmap
382 					 * (bit 0 = groupless messages,
383 					 *  bit 1-16 = messages for groups 1-16)
384 					 */
385 	char reserved[48];		/* for future use */
386 };
387 
388 /* MIDI version numbers in client info */
389 #define SNDRV_SEQ_CLIENT_LEGACY_MIDI		0	/* Legacy client */
390 #define SNDRV_SEQ_CLIENT_UMP_MIDI_1_0		1	/* UMP MIDI 1.0 */
391 #define SNDRV_SEQ_CLIENT_UMP_MIDI_2_0		2	/* UMP MIDI 2.0 */
392 
393 /* client pool size */
394 struct snd_seq_client_pool {
395 	int client;			/* client number to inquire */
396 	int output_pool;		/* outgoing (write) pool size */
397 	int input_pool;			/* incoming (read) pool size */
398 	int output_room;		/* minimum free pool size for select/blocking mode */
399 	int output_free;		/* unused size */
400 	int input_free;			/* unused size */
401 	char reserved[64];
402 };
403 
404 
405 /* Remove events by specified criteria */
406 
407 #define SNDRV_SEQ_REMOVE_INPUT		(1<<0)	/* Flush input queues */
408 #define SNDRV_SEQ_REMOVE_OUTPUT		(1<<1)	/* Flush output queues */
409 #define SNDRV_SEQ_REMOVE_DEST		(1<<2)	/* Restrict by destination q:client:port */
410 #define SNDRV_SEQ_REMOVE_DEST_CHANNEL	(1<<3)	/* Restrict by channel */
411 #define SNDRV_SEQ_REMOVE_TIME_BEFORE	(1<<4)	/* Restrict to before time */
412 #define SNDRV_SEQ_REMOVE_TIME_AFTER	(1<<5)	/* Restrict to time or after */
413 #define SNDRV_SEQ_REMOVE_TIME_TICK	(1<<6)	/* Time is in ticks */
414 #define SNDRV_SEQ_REMOVE_EVENT_TYPE	(1<<7)	/* Restrict to event type */
415 #define SNDRV_SEQ_REMOVE_IGNORE_OFF 	(1<<8)	/* Do not flush off events */
416 #define SNDRV_SEQ_REMOVE_TAG_MATCH 	(1<<9)	/* Restrict to events with given tag */
417 
418 struct snd_seq_remove_events {
419 	unsigned int  remove_mode;	/* Flags that determine what gets removed */
420 
421 	union snd_seq_timestamp time;
422 
423 	unsigned char queue;	/* Queue for REMOVE_DEST */
424 	struct snd_seq_addr dest;	/* Address for REMOVE_DEST */
425 	unsigned char channel;	/* Channel for REMOVE_DEST */
426 
427 	int  type;	/* For REMOVE_EVENT_TYPE */
428 	char  tag;	/* Tag for REMOVE_TAG */
429 
430 	int  reserved[10];	/* To allow for future binary compatibility */
431 
432 };
433 
434 
435 	/* known port numbers */
436 #define SNDRV_SEQ_PORT_SYSTEM_TIMER	0
437 #define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE	1
438 
439 	/* port capabilities (32 bits) */
440 #define SNDRV_SEQ_PORT_CAP_READ		(1<<0)	/* readable from this port */
441 #define SNDRV_SEQ_PORT_CAP_WRITE	(1<<1)	/* writable to this port */
442 
443 #define SNDRV_SEQ_PORT_CAP_SYNC_READ	(1<<2)
444 #define SNDRV_SEQ_PORT_CAP_SYNC_WRITE	(1<<3)
445 
446 #define SNDRV_SEQ_PORT_CAP_DUPLEX	(1<<4)
447 
448 #define SNDRV_SEQ_PORT_CAP_SUBS_READ	(1<<5)	/* allow read subscription */
449 #define SNDRV_SEQ_PORT_CAP_SUBS_WRITE	(1<<6)	/* allow write subscription */
450 #define SNDRV_SEQ_PORT_CAP_NO_EXPORT	(1<<7)	/* routing not allowed */
451 #define SNDRV_SEQ_PORT_CAP_INACTIVE	(1<<8)	/* inactive port */
452 #define SNDRV_SEQ_PORT_CAP_UMP_ENDPOINT	(1<<9)	/* MIDI 2.0 UMP Endpoint port */
453 
454 	/* port type */
455 #define SNDRV_SEQ_PORT_TYPE_SPECIFIC	(1<<0)	/* hardware specific */
456 #define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1)	/* generic MIDI device */
457 #define SNDRV_SEQ_PORT_TYPE_MIDI_GM	(1<<2)	/* General MIDI compatible device */
458 #define SNDRV_SEQ_PORT_TYPE_MIDI_GS	(1<<3)	/* GS compatible device */
459 #define SNDRV_SEQ_PORT_TYPE_MIDI_XG	(1<<4)	/* XG compatible device */
460 #define SNDRV_SEQ_PORT_TYPE_MIDI_MT32	(1<<5)	/* MT-32 compatible device */
461 #define SNDRV_SEQ_PORT_TYPE_MIDI_GM2	(1<<6)	/* General MIDI 2 compatible device */
462 #define SNDRV_SEQ_PORT_TYPE_MIDI_UMP	(1<<7)	/* UMP */
463 
464 /* other standards...*/
465 #define SNDRV_SEQ_PORT_TYPE_SYNTH	(1<<10)	/* Synth device (no MIDI compatible - direct wavetable) */
466 #define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11)	/* Sampling device (support sample download) */
467 #define SNDRV_SEQ_PORT_TYPE_SAMPLE	(1<<12)	/* Sampling device (sample can be downloaded at any time) */
468 /*...*/
469 #define SNDRV_SEQ_PORT_TYPE_HARDWARE	(1<<16)	/* driver for a hardware device */
470 #define SNDRV_SEQ_PORT_TYPE_SOFTWARE	(1<<17)	/* implemented in software */
471 #define SNDRV_SEQ_PORT_TYPE_SYNTHESIZER	(1<<18)	/* generates sound */
472 #define SNDRV_SEQ_PORT_TYPE_PORT	(1<<19)	/* connects to other device(s) */
473 #define SNDRV_SEQ_PORT_TYPE_APPLICATION	(1<<20)	/* application (sequencer/editor) */
474 
475 /* misc. conditioning flags */
476 #define SNDRV_SEQ_PORT_FLG_GIVEN_PORT	(1<<0)
477 #define SNDRV_SEQ_PORT_FLG_TIMESTAMP	(1<<1)
478 #define SNDRV_SEQ_PORT_FLG_TIME_REAL	(1<<2)
479 
480 /* port direction */
481 #define SNDRV_SEQ_PORT_DIR_UNKNOWN	0
482 #define SNDRV_SEQ_PORT_DIR_INPUT	1
483 #define SNDRV_SEQ_PORT_DIR_OUTPUT	2
484 #define SNDRV_SEQ_PORT_DIR_BIDIRECTION	3
485 
486 struct snd_seq_port_info {
487 	struct snd_seq_addr addr;	/* client/port numbers */
488 	char name[64];			/* port name */
489 
490 	unsigned int capability;	/* port capability bits */
491 	unsigned int type;		/* port type bits */
492 	int midi_channels;		/* channels per MIDI port */
493 	int midi_voices;		/* voices per MIDI port */
494 	int synth_voices;		/* voices per SYNTH port */
495 
496 	int read_use;			/* R/O: subscribers for output (from this port) */
497 	int write_use;			/* R/O: subscribers for input (to this port) */
498 
499 	void *kernel;			/* reserved for kernel use (must be NULL) */
500 	unsigned int flags;		/* misc. conditioning */
501 	unsigned char time_queue;	/* queue # for timestamping */
502 	unsigned char direction;	/* port usage direction (r/w/bidir) */
503 	unsigned char ump_group;	/* 0 = UMP EP (no conversion), 1-16 = UMP group number */
504 	char reserved[57];		/* for future use */
505 };
506 
507 
508 /* queue flags */
509 #define SNDRV_SEQ_QUEUE_FLG_SYNC	(1<<0)	/* sync enabled */
510 
511 /* queue information */
512 struct snd_seq_queue_info {
513 	int queue;		/* queue id */
514 
515 	/*
516 	 *  security settings, only owner of this queue can start/stop timer
517 	 *  etc. if the queue is locked for other clients
518 	 */
519 	int owner;		/* client id for owner of the queue */
520 	unsigned locked:1;	/* timing queue locked for other queues */
521 	char name[64];		/* name of this queue */
522 	unsigned int flags;	/* flags */
523 	char reserved[60];	/* for future use */
524 
525 };
526 
527 /* queue info/status */
528 struct snd_seq_queue_status {
529 	int queue;			/* queue id */
530 	int events;			/* read-only - queue size */
531 	snd_seq_tick_time_t tick;	/* current tick */
532 	struct snd_seq_real_time time;	/* current time */
533 	int running;			/* running state of queue */
534 	int flags;			/* various flags */
535 	char reserved[64];		/* for the future */
536 };
537 
538 
539 /* queue tempo */
540 struct snd_seq_queue_tempo {
541 	int queue;			/* sequencer queue */
542 	unsigned int tempo;		/* current tempo, us/tick */
543 	int ppq;			/* time resolution, ticks/quarter */
544 	unsigned int skew_value;	/* queue skew */
545 	unsigned int skew_base;		/* queue skew base */
546 	char reserved[24];		/* for the future */
547 };
548 
549 
550 /* sequencer timer sources */
551 #define SNDRV_SEQ_TIMER_ALSA		0	/* ALSA timer */
552 #define SNDRV_SEQ_TIMER_MIDI_CLOCK	1	/* Midi Clock (CLOCK event) */
553 #define SNDRV_SEQ_TIMER_MIDI_TICK	2	/* Midi Timer Tick (TICK event) */
554 
555 /* queue timer info */
556 struct snd_seq_queue_timer {
557 	int queue;			/* sequencer queue */
558 	int type;			/* source timer type */
559 	union {
560 		struct {
561 			struct snd_timer_id id;	/* ALSA's timer ID */
562 			unsigned int resolution;	/* resolution in Hz */
563 		} alsa;
564 	} u;
565 	char reserved[64];		/* for the future use */
566 };
567 
568 
569 struct snd_seq_queue_client {
570 	int queue;		/* sequencer queue */
571 	int client;		/* sequencer client */
572 	int used;		/* queue is used with this client
573 				   (must be set for accepting events) */
574 	/* per client watermarks */
575 	char reserved[64];	/* for future use */
576 };
577 
578 
579 #define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE	(1<<0)	/* exclusive connection */
580 #define SNDRV_SEQ_PORT_SUBS_TIMESTAMP	(1<<1)
581 #define SNDRV_SEQ_PORT_SUBS_TIME_REAL	(1<<2)
582 
583 struct snd_seq_port_subscribe {
584 	struct snd_seq_addr sender;	/* sender address */
585 	struct snd_seq_addr dest;	/* destination address */
586 	unsigned int voices;		/* number of voices to be allocated (0 = don't care) */
587 	unsigned int flags;		/* modes */
588 	unsigned char queue;		/* input time-stamp queue (optional) */
589 	unsigned char pad[3];		/* reserved */
590 	char reserved[64];
591 };
592 
593 /* type of query subscription */
594 #define SNDRV_SEQ_QUERY_SUBS_READ	0
595 #define SNDRV_SEQ_QUERY_SUBS_WRITE	1
596 
597 struct snd_seq_query_subs {
598 	struct snd_seq_addr root;	/* client/port id to be searched */
599 	int type;		/* READ or WRITE */
600 	int index;		/* 0..N-1 */
601 	int num_subs;		/* R/O: number of subscriptions on this port */
602 	struct snd_seq_addr addr;	/* R/O: result */
603 	unsigned char queue;	/* R/O: result */
604 	unsigned int flags;	/* R/O: result */
605 	char reserved[64];	/* for future use */
606 };
607 
608 /*
609  * UMP-specific information
610  */
611 /* type of UMP info query */
612 #define SNDRV_SEQ_CLIENT_UMP_INFO_ENDPOINT	0
613 #define SNDRV_SEQ_CLIENT_UMP_INFO_BLOCK		1
614 
615 struct snd_seq_client_ump_info {
616 	int client;			/* client number to inquire/set */
617 	int type;			/* type to inquire/set */
618 	unsigned char info[512];	/* info (either UMP ep or block info) */
619 } __packed;
620 
621 /*
622  *  IOCTL commands
623  */
624 
625 #define SNDRV_SEQ_IOCTL_PVERSION	_IOR ('S', 0x00, int)
626 #define SNDRV_SEQ_IOCTL_CLIENT_ID	_IOR ('S', 0x01, int)
627 #define SNDRV_SEQ_IOCTL_SYSTEM_INFO	_IOWR('S', 0x02, struct snd_seq_system_info)
628 #define SNDRV_SEQ_IOCTL_RUNNING_MODE	_IOWR('S', 0x03, struct snd_seq_running_info)
629 #define SNDRV_SEQ_IOCTL_USER_PVERSION	_IOW('S', 0x04, int)
630 
631 #define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO	_IOWR('S', 0x10, struct snd_seq_client_info)
632 #define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO	_IOW ('S', 0x11, struct snd_seq_client_info)
633 #define SNDRV_SEQ_IOCTL_GET_CLIENT_UMP_INFO	_IOWR('S', 0x12, struct snd_seq_client_ump_info)
634 #define SNDRV_SEQ_IOCTL_SET_CLIENT_UMP_INFO	_IOWR('S', 0x13, struct snd_seq_client_ump_info)
635 
636 #define SNDRV_SEQ_IOCTL_CREATE_PORT	_IOWR('S', 0x20, struct snd_seq_port_info)
637 #define SNDRV_SEQ_IOCTL_DELETE_PORT	_IOW ('S', 0x21, struct snd_seq_port_info)
638 #define SNDRV_SEQ_IOCTL_GET_PORT_INFO	_IOWR('S', 0x22, struct snd_seq_port_info)
639 #define SNDRV_SEQ_IOCTL_SET_PORT_INFO	_IOW ('S', 0x23, struct snd_seq_port_info)
640 
641 #define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT	_IOW ('S', 0x30, struct snd_seq_port_subscribe)
642 #define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct snd_seq_port_subscribe)
643 
644 #define SNDRV_SEQ_IOCTL_CREATE_QUEUE	_IOWR('S', 0x32, struct snd_seq_queue_info)
645 #define SNDRV_SEQ_IOCTL_DELETE_QUEUE	_IOW ('S', 0x33, struct snd_seq_queue_info)
646 #define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO	_IOWR('S', 0x34, struct snd_seq_queue_info)
647 #define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO	_IOWR('S', 0x35, struct snd_seq_queue_info)
648 #define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE	_IOWR('S', 0x36, struct snd_seq_queue_info)
649 #define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status)
650 #define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO	_IOWR('S', 0x41, struct snd_seq_queue_tempo)
651 #define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO	_IOW ('S', 0x42, struct snd_seq_queue_tempo)
652 #define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER	_IOWR('S', 0x45, struct snd_seq_queue_timer)
653 #define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER	_IOW ('S', 0x46, struct snd_seq_queue_timer)
654 #define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT	_IOWR('S', 0x49, struct snd_seq_queue_client)
655 #define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT	_IOW ('S', 0x4a, struct snd_seq_queue_client)
656 #define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL	_IOWR('S', 0x4b, struct snd_seq_client_pool)
657 #define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL	_IOW ('S', 0x4c, struct snd_seq_client_pool)
658 #define SNDRV_SEQ_IOCTL_REMOVE_EVENTS	_IOW ('S', 0x4e, struct snd_seq_remove_events)
659 #define SNDRV_SEQ_IOCTL_QUERY_SUBS	_IOWR('S', 0x4f, struct snd_seq_query_subs)
660 #define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION	_IOWR('S', 0x50, struct snd_seq_port_subscribe)
661 #define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT	_IOWR('S', 0x51, struct snd_seq_client_info)
662 #define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT	_IOWR('S', 0x52, struct snd_seq_port_info)
663 
664 #endif /* __SOUND_ASEQUENCER_H */
665