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