aboutsummaryrefslogtreecommitdiffstats
path: root/include/sound/asequencer.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/sound/asequencer.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/sound/asequencer.h')
-rw-r--r--include/sound/asequencer.h908
1 files changed, 908 insertions, 0 deletions
diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h
new file mode 100644
index 000000000000..728efd504262
--- /dev/null
+++ b/include/sound/asequencer.h
@@ -0,0 +1,908 @@
1/*
2 * Main header file for the ALSA sequencer
3 * Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
4 * (c) 1998-1999 by Jaroslav Kysela <perex@suse.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#ifndef __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/**
35 * definition of sequencer event types
36 */
37
38/** system messages
39 * event data type = #sndrv_seq_result_t
40 */
41#define SNDRV_SEQ_EVENT_SYSTEM 0
42#define SNDRV_SEQ_EVENT_RESULT 1
43
44/** note messages (channel specific)
45 * event data type = #sndrv_seq_ev_note
46 */
47#define SNDRV_SEQ_EVENT_NOTE 5
48#define SNDRV_SEQ_EVENT_NOTEON 6
49#define SNDRV_SEQ_EVENT_NOTEOFF 7
50#define SNDRV_SEQ_EVENT_KEYPRESS 8
51
52/** control messages (channel specific)
53 * event data type = #sndrv_seq_ev_ctrl
54 */
55#define SNDRV_SEQ_EVENT_CONTROLLER 10
56#define SNDRV_SEQ_EVENT_PGMCHANGE 11
57#define SNDRV_SEQ_EVENT_CHANPRESS 12
58#define SNDRV_SEQ_EVENT_PITCHBEND 13 /**< from -8192 to 8191 */
59#define SNDRV_SEQ_EVENT_CONTROL14 14 /**< 14 bit controller value */
60#define SNDRV_SEQ_EVENT_NONREGPARAM 15 /**< 14 bit NRPN address + 14 bit unsigned value */
61#define SNDRV_SEQ_EVENT_REGPARAM 16 /**< 14 bit RPN address + 14 bit unsigned value */
62
63/** synchronisation messages
64 * event data type = #sndrv_seq_ev_ctrl
65 */
66#define SNDRV_SEQ_EVENT_SONGPOS 20 /* Song Position Pointer with LSB and MSB values */
67#define SNDRV_SEQ_EVENT_SONGSEL 21 /* Song Select with song ID number */
68#define SNDRV_SEQ_EVENT_QFRAME 22 /* midi time code quarter frame */
69#define SNDRV_SEQ_EVENT_TIMESIGN 23 /* SMF Time Signature event */
70#define SNDRV_SEQ_EVENT_KEYSIGN 24 /* SMF Key Signature event */
71
72/** timer messages
73 * event data type = sndrv_seq_ev_queue_control_t
74 */
75#define SNDRV_SEQ_EVENT_START 30 /* midi Real Time Start message */
76#define SNDRV_SEQ_EVENT_CONTINUE 31 /* midi Real Time Continue message */
77#define SNDRV_SEQ_EVENT_STOP 32 /* midi Real Time Stop message */
78#define SNDRV_SEQ_EVENT_SETPOS_TICK 33 /* set tick queue position */
79#define SNDRV_SEQ_EVENT_SETPOS_TIME 34 /* set realtime queue position */
80#define SNDRV_SEQ_EVENT_TEMPO 35 /* (SMF) Tempo event */
81#define SNDRV_SEQ_EVENT_CLOCK 36 /* midi Real Time Clock message */
82#define SNDRV_SEQ_EVENT_TICK 37 /* midi Real Time Tick message */
83#define SNDRV_SEQ_EVENT_QUEUE_SKEW 38 /* skew queue tempo */
84
85/** others
86 * event data type = none
87 */
88#define SNDRV_SEQ_EVENT_TUNE_REQUEST 40 /* tune request */
89#define SNDRV_SEQ_EVENT_RESET 41 /* reset to power-on state */
90#define SNDRV_SEQ_EVENT_SENSING 42 /* "active sensing" event */
91
92/** echo back, kernel private messages
93 * event data type = any type
94 */
95#define SNDRV_SEQ_EVENT_ECHO 50 /* echo event */
96#define SNDRV_SEQ_EVENT_OSS 51 /* OSS raw event */
97
98/** system status messages (broadcast for subscribers)
99 * event data type = sndrv_seq_addr_t
100 */
101#define SNDRV_SEQ_EVENT_CLIENT_START 60 /* new client has connected */
102#define SNDRV_SEQ_EVENT_CLIENT_EXIT 61 /* client has left the system */
103#define SNDRV_SEQ_EVENT_CLIENT_CHANGE 62 /* client status/info has changed */
104#define SNDRV_SEQ_EVENT_PORT_START 63 /* new port was created */
105#define SNDRV_SEQ_EVENT_PORT_EXIT 64 /* port was deleted from system */
106#define SNDRV_SEQ_EVENT_PORT_CHANGE 65 /* port status/info has changed */
107
108/** port connection changes
109 * event data type = sndrv_seq_connect_t
110 */
111#define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */
112#define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */
113
114/** synthesizer events
115 * event data type = sndrv_seq_eve_sample_control_t
116 */
117#define SNDRV_SEQ_EVENT_SAMPLE 70 /* sample select */
118#define SNDRV_SEQ_EVENT_SAMPLE_CLUSTER 71 /* sample cluster select */
119#define SNDRV_SEQ_EVENT_SAMPLE_START 72 /* voice start */
120#define SNDRV_SEQ_EVENT_SAMPLE_STOP 73 /* voice stop */
121#define SNDRV_SEQ_EVENT_SAMPLE_FREQ 74 /* playback frequency */
122#define SNDRV_SEQ_EVENT_SAMPLE_VOLUME 75 /* volume and balance */
123#define SNDRV_SEQ_EVENT_SAMPLE_LOOP 76 /* sample loop */
124#define SNDRV_SEQ_EVENT_SAMPLE_POSITION 77 /* sample position */
125#define SNDRV_SEQ_EVENT_SAMPLE_PRIVATE1 78 /* private (hardware dependent) event */
126
127/** user-defined events with fixed length
128 * event data type = any
129 */
130#define SNDRV_SEQ_EVENT_USR0 90
131#define SNDRV_SEQ_EVENT_USR1 91
132#define SNDRV_SEQ_EVENT_USR2 92
133#define SNDRV_SEQ_EVENT_USR3 93
134#define SNDRV_SEQ_EVENT_USR4 94
135#define SNDRV_SEQ_EVENT_USR5 95
136#define SNDRV_SEQ_EVENT_USR6 96
137#define SNDRV_SEQ_EVENT_USR7 97
138#define SNDRV_SEQ_EVENT_USR8 98
139#define SNDRV_SEQ_EVENT_USR9 99
140
141/** instrument layer
142 * variable length data can be passed directly to the driver
143 */
144#define SNDRV_SEQ_EVENT_INSTR_BEGIN 100 /* begin of instrument management */
145#define SNDRV_SEQ_EVENT_INSTR_END 101 /* end of instrument management */
146#define SNDRV_SEQ_EVENT_INSTR_INFO 102 /* instrument interface info */
147#define SNDRV_SEQ_EVENT_INSTR_INFO_RESULT 103 /* result */
148#define SNDRV_SEQ_EVENT_INSTR_FINFO 104 /* get format info */
149#define SNDRV_SEQ_EVENT_INSTR_FINFO_RESULT 105 /* get format info */
150#define SNDRV_SEQ_EVENT_INSTR_RESET 106 /* reset instrument memory */
151#define SNDRV_SEQ_EVENT_INSTR_STATUS 107 /* instrument interface status */
152#define SNDRV_SEQ_EVENT_INSTR_STATUS_RESULT 108 /* result */
153#define SNDRV_SEQ_EVENT_INSTR_PUT 109 /* put instrument to port */
154#define SNDRV_SEQ_EVENT_INSTR_GET 110 /* get instrument from port */
155#define SNDRV_SEQ_EVENT_INSTR_GET_RESULT 111 /* result */
156#define SNDRV_SEQ_EVENT_INSTR_FREE 112 /* free instrument(s) */
157#define SNDRV_SEQ_EVENT_INSTR_LIST 113 /* instrument list */
158#define SNDRV_SEQ_EVENT_INSTR_LIST_RESULT 114 /* result */
159#define SNDRV_SEQ_EVENT_INSTR_CLUSTER 115 /* cluster parameters */
160#define SNDRV_SEQ_EVENT_INSTR_CLUSTER_GET 116 /* get cluster parameters */
161#define SNDRV_SEQ_EVENT_INSTR_CLUSTER_RESULT 117 /* result */
162#define SNDRV_SEQ_EVENT_INSTR_CHANGE 118 /* instrument change */
163/* 119-129: reserved */
164
165/* 130-139: variable length events
166 * event data type = sndrv_seq_ev_ext
167 * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set)
168 */
169#define SNDRV_SEQ_EVENT_SYSEX 130 /* system exclusive data (variable length) */
170#define SNDRV_SEQ_EVENT_BOUNCE 131 /* error event */
171/* 132-134: reserved */
172#define SNDRV_SEQ_EVENT_USR_VAR0 135
173#define SNDRV_SEQ_EVENT_USR_VAR1 136
174#define SNDRV_SEQ_EVENT_USR_VAR2 137
175#define SNDRV_SEQ_EVENT_USR_VAR3 138
176#define SNDRV_SEQ_EVENT_USR_VAR4 139
177
178/* 150-151: kernel events with quote - DO NOT use in user clients */
179#define SNDRV_SEQ_EVENT_KERNEL_ERROR 150
180#define SNDRV_SEQ_EVENT_KERNEL_QUOTE 151 /* obsolete */
181
182/* 152-191: reserved */
183
184/* 192-254: hardware specific events */
185
186/* 255: special event */
187#define SNDRV_SEQ_EVENT_NONE 255
188
189
190typedef unsigned char sndrv_seq_event_type_t;
191
192/** event address */
193struct sndrv_seq_addr {
194 unsigned char client; /**< Client number: 0..255, 255 = broadcast to all clients */
195 unsigned char port; /**< Port within client: 0..255, 255 = broadcast to all ports */
196};
197
198/** port connection */
199struct sndrv_seq_connect {
200 struct sndrv_seq_addr sender;
201 struct sndrv_seq_addr dest;
202};
203
204
205#define SNDRV_SEQ_ADDRESS_UNKNOWN 253 /* unknown source */
206#define SNDRV_SEQ_ADDRESS_SUBSCRIBERS 254 /* send event to all subscribed ports */
207#define SNDRV_SEQ_ADDRESS_BROADCAST 255 /* send event to all queues/clients/ports/channels */
208#define SNDRV_SEQ_QUEUE_DIRECT 253 /* direct dispatch */
209
210 /* event mode flag - NOTE: only 8 bits available! */
211#define SNDRV_SEQ_TIME_STAMP_TICK (0<<0) /* timestamp in clock ticks */
212#define SNDRV_SEQ_TIME_STAMP_REAL (1<<0) /* timestamp in real time */
213#define SNDRV_SEQ_TIME_STAMP_MASK (1<<0)
214
215#define SNDRV_SEQ_TIME_MODE_ABS (0<<1) /* absolute timestamp */
216#define SNDRV_SEQ_TIME_MODE_REL (1<<1) /* relative to current time */
217#define SNDRV_SEQ_TIME_MODE_MASK (1<<1)
218
219#define SNDRV_SEQ_EVENT_LENGTH_FIXED (0<<2) /* fixed event size */
220#define SNDRV_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /* variable event size */
221#define SNDRV_SEQ_EVENT_LENGTH_VARUSR (2<<2) /* variable event size - user memory space */
222#define SNDRV_SEQ_EVENT_LENGTH_MASK (3<<2)
223
224#define SNDRV_SEQ_PRIORITY_NORMAL (0<<4) /* normal priority */
225#define SNDRV_SEQ_PRIORITY_HIGH (1<<4) /* event should be processed before others */
226#define SNDRV_SEQ_PRIORITY_MASK (1<<4)
227
228
229 /* note event */
230struct sndrv_seq_ev_note {
231 unsigned char channel;
232 unsigned char note;
233 unsigned char velocity;
234 unsigned char off_velocity; /* only for SNDRV_SEQ_EVENT_NOTE */
235 unsigned int duration; /* only for SNDRV_SEQ_EVENT_NOTE */
236};
237
238 /* controller event */
239struct sndrv_seq_ev_ctrl {
240 unsigned char channel;
241 unsigned char unused1, unused2, unused3; /* pad */
242 unsigned int param;
243 signed int value;
244};
245
246 /* generic set of bytes (12x8 bit) */
247struct sndrv_seq_ev_raw8 {
248 unsigned char d[12]; /* 8 bit value */
249};
250
251 /* generic set of integers (3x32 bit) */
252struct sndrv_seq_ev_raw32 {
253 unsigned int d[3]; /* 32 bit value */
254};
255
256 /* external stored data */
257struct sndrv_seq_ev_ext {
258 unsigned int len; /* length of data */
259 void *ptr; /* pointer to data (note: maybe 64-bit) */
260} __attribute__((packed));
261
262/* Instrument cluster type */
263typedef unsigned int sndrv_seq_instr_cluster_t;
264
265/* Instrument type */
266struct sndrv_seq_instr {
267 sndrv_seq_instr_cluster_t cluster;
268 unsigned int std; /* the upper byte means a private instrument (owner - client #) */
269 unsigned short bank;
270 unsigned short prg;
271};
272
273 /* sample number */
274struct sndrv_seq_ev_sample {
275 unsigned int std;
276 unsigned short bank;
277 unsigned short prg;
278};
279
280 /* sample cluster */
281struct sndrv_seq_ev_cluster {
282 sndrv_seq_instr_cluster_t cluster;
283};
284
285 /* sample position */
286typedef unsigned int sndrv_seq_position_t; /* playback position (in samples) * 16 */
287
288 /* sample stop mode */
289enum sndrv_seq_stop_mode {
290 SAMPLE_STOP_IMMEDIATELY = 0, /* terminate playing immediately */
291 SAMPLE_STOP_VENVELOPE = 1, /* finish volume envelope */
292 SAMPLE_STOP_LOOP = 2 /* terminate loop and finish wave */
293};
294
295 /* sample frequency */
296typedef int sndrv_seq_frequency_t; /* playback frequency in HZ * 16 */
297
298 /* sample volume control; if any value is set to -1 == do not change */
299struct sndrv_seq_ev_volume {
300 signed short volume; /* range: 0-16383 */
301 signed short lr; /* left-right balance; range: 0-16383 */
302 signed short fr; /* front-rear balance; range: 0-16383 */
303 signed short du; /* down-up balance; range: 0-16383 */
304};
305
306 /* simple loop redefinition */
307struct sndrv_seq_ev_loop {
308 unsigned int start; /* loop start (in samples) * 16 */
309 unsigned int end; /* loop end (in samples) * 16 */
310};
311
312struct sndrv_seq_ev_sample_control {
313 unsigned char channel;
314 unsigned char unused1, unused2, unused3; /* pad */
315 union {
316 struct sndrv_seq_ev_sample sample;
317 struct sndrv_seq_ev_cluster cluster;
318 sndrv_seq_position_t position;
319 enum sndrv_seq_stop_mode stop_mode;
320 sndrv_seq_frequency_t frequency;
321 struct sndrv_seq_ev_volume volume;
322 struct sndrv_seq_ev_loop loop;
323 unsigned char raw8[8];
324 } param;
325};
326
327
328
329/* INSTR_BEGIN event */
330struct sndrv_seq_ev_instr_begin {
331 int timeout; /* zero = forever, otherwise timeout in ms */
332};
333
334struct sndrv_seq_result {
335 int event; /* processed event type */
336 int result;
337};
338
339
340struct sndrv_seq_real_time {
341 unsigned int tv_sec; /* seconds */
342 unsigned int tv_nsec; /* nanoseconds */
343};
344
345typedef unsigned int sndrv_seq_tick_time_t; /* midi ticks */
346
347union sndrv_seq_timestamp {
348 sndrv_seq_tick_time_t tick;
349 struct sndrv_seq_real_time time;
350};
351
352struct sndrv_seq_queue_skew {
353 unsigned int value;
354 unsigned int base;
355};
356
357 /* queue timer control */
358struct sndrv_seq_ev_queue_control {
359 unsigned char queue; /* affected queue */
360 unsigned char pad[3]; /* reserved */
361 union {
362 signed int value; /* affected value (e.g. tempo) */
363 union sndrv_seq_timestamp time; /* time */
364 unsigned int position; /* sync position */
365 struct sndrv_seq_queue_skew skew;
366 unsigned int d32[2];
367 unsigned char d8[8];
368 } param;
369};
370
371 /* quoted event - inside the kernel only */
372struct sndrv_seq_ev_quote {
373 struct sndrv_seq_addr origin; /* original sender */
374 unsigned short value; /* optional data */
375 struct sndrv_seq_event *event; /* quoted event */
376} __attribute__((packed));
377
378
379 /* sequencer event */
380struct sndrv_seq_event {
381 sndrv_seq_event_type_t type; /* event type */
382 unsigned char flags; /* event flags */
383 char tag;
384
385 unsigned char queue; /* schedule queue */
386 union sndrv_seq_timestamp time; /* schedule time */
387
388
389 struct sndrv_seq_addr source; /* source address */
390 struct sndrv_seq_addr dest; /* destination address */
391
392 union { /* event data... */
393 struct sndrv_seq_ev_note note;
394 struct sndrv_seq_ev_ctrl control;
395 struct sndrv_seq_ev_raw8 raw8;
396 struct sndrv_seq_ev_raw32 raw32;
397 struct sndrv_seq_ev_ext ext;
398 struct sndrv_seq_ev_queue_control queue;
399 union sndrv_seq_timestamp time;
400 struct sndrv_seq_addr addr;
401 struct sndrv_seq_connect connect;
402 struct sndrv_seq_result result;
403 struct sndrv_seq_ev_instr_begin instr_begin;
404 struct sndrv_seq_ev_sample_control sample;
405 struct sndrv_seq_ev_quote quote;
406 } data;
407};
408
409
410/*
411 * bounce event - stored as variable size data
412 */
413struct sndrv_seq_event_bounce {
414 int err;
415 struct sndrv_seq_event event;
416 /* external data follows here. */
417};
418
419#define sndrv_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(sndrv_seq_event_bounce_t)))
420
421/*
422 * type check macros
423 */
424/* result events: 0-4 */
425#define sndrv_seq_ev_is_result_type(ev) ((ev)->type < 5)
426/* channel specific events: 5-19 */
427#define sndrv_seq_ev_is_channel_type(ev) ((ev)->type >= 5 && (ev)->type < 20)
428/* note events: 5-9 */
429#define sndrv_seq_ev_is_note_type(ev) ((ev)->type >= 5 && (ev)->type < 10)
430/* control events: 10-19 */
431#define sndrv_seq_ev_is_control_type(ev) ((ev)->type >= 10 && (ev)->type < 20)
432/* queue control events: 30-39 */
433#define sndrv_seq_ev_is_queue_type(ev) ((ev)->type >= 30 && (ev)->type < 40)
434/* system status messages */
435#define sndrv_seq_ev_is_message_type(ev) ((ev)->type >= 60 && (ev)->type < 69)
436/* sample messages */
437#define sndrv_seq_ev_is_sample_type(ev) ((ev)->type >= 70 && (ev)->type < 79)
438/* user-defined messages */
439#define sndrv_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99)
440/* fixed length events: 0-99 */
441#define sndrv_seq_ev_is_fixed_type(ev) ((ev)->type < 100)
442/* instrument layer events: 100-129 */
443#define sndrv_seq_ev_is_instr_type(ev) ((ev)->type >= 100 && (ev)->type < 130)
444/* variable length events: 130-139 */
445#define sndrv_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140)
446/* reserved for kernel */
447#define sndrv_seq_ev_is_reserved(ev) ((ev)->type >= 150)
448
449/* direct dispatched events */
450#define sndrv_seq_ev_is_direct(ev) ((ev)->queue == SNDRV_SEQ_QUEUE_DIRECT)
451
452/*
453 * macros to check event flags
454 */
455/* prior events */
456#define sndrv_seq_ev_is_prior(ev) (((ev)->flags & SNDRV_SEQ_PRIORITY_MASK) == SNDRV_SEQ_PRIORITY_HIGH)
457
458/* event length type */
459#define sndrv_seq_ev_length_type(ev) ((ev)->flags & SNDRV_SEQ_EVENT_LENGTH_MASK)
460#define sndrv_seq_ev_is_fixed(ev) (sndrv_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_FIXED)
461#define sndrv_seq_ev_is_variable(ev) (sndrv_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE)
462#define sndrv_seq_ev_is_varusr(ev) (sndrv_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARUSR)
463
464/* time-stamp type */
465#define sndrv_seq_ev_timestamp_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_STAMP_MASK)
466#define sndrv_seq_ev_is_tick(ev) (sndrv_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_TICK)
467#define sndrv_seq_ev_is_real(ev) (sndrv_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_REAL)
468
469/* time-mode type */
470#define sndrv_seq_ev_timemode_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_MODE_MASK)
471#define sndrv_seq_ev_is_abstime(ev) (sndrv_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_ABS)
472#define sndrv_seq_ev_is_reltime(ev) (sndrv_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_REL)
473
474/* queue sync port */
475#define sndrv_seq_queue_sync_port(q) ((q) + 16)
476
477 /* system information */
478struct sndrv_seq_system_info {
479 int queues; /* maximum queues count */
480 int clients; /* maximum clients count */
481 int ports; /* maximum ports per client */
482 int channels; /* maximum channels per port */
483 int cur_clients; /* current clients */
484 int cur_queues; /* current queues */
485 char reserved[24];
486};
487
488
489 /* system running information */
490struct sndrv_seq_running_info {
491 unsigned char client; /* client id */
492 unsigned char big_endian; /* 1 = big-endian */
493 unsigned char cpu_mode; /* 4 = 32bit, 8 = 64bit */
494 unsigned char pad; /* reserved */
495 unsigned char reserved[12];
496};
497
498
499 /* known client numbers */
500#define SNDRV_SEQ_CLIENT_SYSTEM 0
501#define SNDRV_SEQ_CLIENT_DUMMY 62 /* dummy ports */
502#define SNDRV_SEQ_CLIENT_OSS 63 /* oss sequencer emulator */
503
504
505 /* client types */
506enum sndrv_seq_client_type {
507 NO_CLIENT = 0,
508 USER_CLIENT = 1,
509 KERNEL_CLIENT = 2
510};
511
512 /* event filter flags */
513#define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */
514#define SNDRV_SEQ_FILTER_MULTICAST (1<<1) /* accept multicast messages */
515#define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */
516#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */
517
518struct sndrv_seq_client_info {
519 int client; /* client number to inquire */
520 enum sndrv_seq_client_type type; /* client type */
521 char name[64]; /* client name */
522 unsigned int filter; /* filter flags */
523 unsigned char multicast_filter[8]; /* multicast filter bitmap */
524 unsigned char event_filter[32]; /* event filter bitmap */
525 int num_ports; /* RO: number of ports */
526 int event_lost; /* number of lost events */
527 char reserved[64]; /* for future use */
528};
529
530
531/* client pool size */
532struct sndrv_seq_client_pool {
533 int client; /* client number to inquire */
534 int output_pool; /* outgoing (write) pool size */
535 int input_pool; /* incoming (read) pool size */
536 int output_room; /* minimum free pool size for select/blocking mode */
537 int output_free; /* unused size */
538 int input_free; /* unused size */
539 char reserved[64];
540};
541
542
543/* Remove events by specified criteria */
544
545#define SNDRV_SEQ_REMOVE_INPUT (1<<0) /* Flush input queues */
546#define SNDRV_SEQ_REMOVE_OUTPUT (1<<1) /* Flush output queues */
547#define SNDRV_SEQ_REMOVE_DEST (1<<2) /* Restrict by destination q:client:port */
548#define SNDRV_SEQ_REMOVE_DEST_CHANNEL (1<<3) /* Restrict by channel */
549#define SNDRV_SEQ_REMOVE_TIME_BEFORE (1<<4) /* Restrict to before time */
550#define SNDRV_SEQ_REMOVE_TIME_AFTER (1<<5) /* Restrict to time or after */
551#define SNDRV_SEQ_REMOVE_TIME_TICK (1<<6) /* Time is in ticks */
552#define SNDRV_SEQ_REMOVE_EVENT_TYPE (1<<7) /* Restrict to event type */
553#define SNDRV_SEQ_REMOVE_IGNORE_OFF (1<<8) /* Do not flush off events */
554#define SNDRV_SEQ_REMOVE_TAG_MATCH (1<<9) /* Restrict to events with given tag */
555
556struct sndrv_seq_remove_events {
557 unsigned int remove_mode; /* Flags that determine what gets removed */
558
559 union sndrv_seq_timestamp time;
560
561 unsigned char queue; /* Queue for REMOVE_DEST */
562 struct sndrv_seq_addr dest; /* Address for REMOVE_DEST */
563 unsigned char channel; /* Channel for REMOVE_DEST */
564
565 int type; /* For REMOVE_EVENT_TYPE */
566 char tag; /* Tag for REMOVE_TAG */
567
568 int reserved[10]; /* To allow for future binary compatibility */
569
570};
571
572
573 /* known port numbers */
574#define SNDRV_SEQ_PORT_SYSTEM_TIMER 0
575#define SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE 1
576
577 /* port capabilities (32 bits) */
578#define SNDRV_SEQ_PORT_CAP_READ (1<<0) /* readable from this port */
579#define SNDRV_SEQ_PORT_CAP_WRITE (1<<1) /* writable to this port */
580
581#define SNDRV_SEQ_PORT_CAP_SYNC_READ (1<<2)
582#define SNDRV_SEQ_PORT_CAP_SYNC_WRITE (1<<3)
583
584#define SNDRV_SEQ_PORT_CAP_DUPLEX (1<<4)
585
586#define SNDRV_SEQ_PORT_CAP_SUBS_READ (1<<5) /* allow read subscription */
587#define SNDRV_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /* allow write subscription */
588#define SNDRV_SEQ_PORT_CAP_NO_EXPORT (1<<7) /* routing not allowed */
589
590 /* port type */
591#define SNDRV_SEQ_PORT_TYPE_SPECIFIC (1<<0) /* hardware specific */
592#define SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /* generic MIDI device */
593#define SNDRV_SEQ_PORT_TYPE_MIDI_GM (1<<2) /* General MIDI compatible device */
594#define SNDRV_SEQ_PORT_TYPE_MIDI_GS (1<<3) /* GS compatible device */
595#define SNDRV_SEQ_PORT_TYPE_MIDI_XG (1<<4) /* XG compatible device */
596#define SNDRV_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /* MT-32 compatible device */
597#define SNDRV_SEQ_PORT_TYPE_MIDI_GM2 (1<<6) /* General MIDI 2 compatible device */
598
599/* other standards...*/
600#define SNDRV_SEQ_PORT_TYPE_SYNTH (1<<10) /* Synth device (no MIDI compatible - direct wavetable) */
601#define SNDRV_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /* Sampling device (support sample download) */
602#define SNDRV_SEQ_PORT_TYPE_SAMPLE (1<<12) /* Sampling device (sample can be downloaded at any time) */
603/*...*/
604#define SNDRV_SEQ_PORT_TYPE_APPLICATION (1<<20) /* application (sequencer/editor) */
605
606/* misc. conditioning flags */
607#define SNDRV_SEQ_PORT_FLG_GIVEN_PORT (1<<0)
608#define SNDRV_SEQ_PORT_FLG_TIMESTAMP (1<<1)
609#define SNDRV_SEQ_PORT_FLG_TIME_REAL (1<<2)
610
611struct sndrv_seq_port_info {
612 struct sndrv_seq_addr addr; /* client/port numbers */
613 char name[64]; /* port name */
614
615 unsigned int capability; /* port capability bits */
616 unsigned int type; /* port type bits */
617 int midi_channels; /* channels per MIDI port */
618 int midi_voices; /* voices per MIDI port */
619 int synth_voices; /* voices per SYNTH port */
620
621 int read_use; /* R/O: subscribers for output (from this port) */
622 int write_use; /* R/O: subscribers for input (to this port) */
623
624 void *kernel; /* reserved for kernel use (must be NULL) */
625 unsigned int flags; /* misc. conditioning */
626 unsigned char time_queue; /* queue # for timestamping */
627 char reserved[59]; /* for future use */
628};
629
630
631/* queue flags */
632#define SNDRV_SEQ_QUEUE_FLG_SYNC (1<<0) /* sync enabled */
633
634/* queue information */
635struct sndrv_seq_queue_info {
636 int queue; /* queue id */
637
638 /*
639 * security settings, only owner of this queue can start/stop timer
640 * etc. if the queue is locked for other clients
641 */
642 int owner; /* client id for owner of the queue */
643 unsigned locked:1; /* timing queue locked for other queues */
644 char name[64]; /* name of this queue */
645 unsigned int flags; /* flags */
646 char reserved[60]; /* for future use */
647
648};
649
650/* queue info/status */
651struct sndrv_seq_queue_status {
652 int queue; /* queue id */
653 int events; /* read-only - queue size */
654 sndrv_seq_tick_time_t tick; /* current tick */
655 struct sndrv_seq_real_time time; /* current time */
656 int running; /* running state of queue */
657 int flags; /* various flags */
658 char reserved[64]; /* for the future */
659};
660
661
662/* queue tempo */
663struct sndrv_seq_queue_tempo {
664 int queue; /* sequencer queue */
665 unsigned int tempo; /* current tempo, us/tick */
666 int ppq; /* time resolution, ticks/quarter */
667 unsigned int skew_value; /* queue skew */
668 unsigned int skew_base; /* queue skew base */
669 char reserved[24]; /* for the future */
670};
671
672
673/* sequencer timer sources */
674#define SNDRV_SEQ_TIMER_ALSA 0 /* ALSA timer */
675#define SNDRV_SEQ_TIMER_MIDI_CLOCK 1 /* Midi Clock (CLOCK event) */
676#define SNDRV_SEQ_TIMER_MIDI_TICK 2 /* Midi Timer Tick (TICK event) */
677
678/* queue timer info */
679struct sndrv_seq_queue_timer {
680 int queue; /* sequencer queue */
681 int type; /* source timer type */
682 union {
683 struct {
684 struct sndrv_timer_id id; /* ALSA's timer ID */
685 unsigned int resolution; /* resolution in Hz */
686 } alsa;
687 } u;
688 char reserved[64]; /* for the future use */
689};
690
691
692struct sndrv_seq_queue_client {
693 int queue; /* sequencer queue */
694 int client; /* sequencer client */
695 int used; /* queue is used with this client
696 (must be set for accepting events) */
697 /* per client watermarks */
698 char reserved[64]; /* for future use */
699};
700
701
702#define SNDRV_SEQ_PORT_SUBS_EXCLUSIVE (1<<0) /* exclusive connection */
703#define SNDRV_SEQ_PORT_SUBS_TIMESTAMP (1<<1)
704#define SNDRV_SEQ_PORT_SUBS_TIME_REAL (1<<2)
705
706struct sndrv_seq_port_subscribe {
707 struct sndrv_seq_addr sender; /* sender address */
708 struct sndrv_seq_addr dest; /* destination address */
709 unsigned int voices; /* number of voices to be allocated (0 = don't care) */
710 unsigned int flags; /* modes */
711 unsigned char queue; /* input time-stamp queue (optional) */
712 unsigned char pad[3]; /* reserved */
713 char reserved[64];
714};
715
716/* type of query subscription */
717#define SNDRV_SEQ_QUERY_SUBS_READ 0
718#define SNDRV_SEQ_QUERY_SUBS_WRITE 1
719
720struct sndrv_seq_query_subs {
721 struct sndrv_seq_addr root; /* client/port id to be searched */
722 int type; /* READ or WRITE */
723 int index; /* 0..N-1 */
724 int num_subs; /* R/O: number of subscriptions on this port */
725 struct sndrv_seq_addr addr; /* R/O: result */
726 unsigned char queue; /* R/O: result */
727 unsigned int flags; /* R/O: result */
728 char reserved[64]; /* for future use */
729};
730
731
732/*
733 * Instrument abstraction layer
734 * - based on events
735 */
736
737/* instrument types */
738#define SNDRV_SEQ_INSTR_ATYPE_DATA 0 /* instrument data */
739#define SNDRV_SEQ_INSTR_ATYPE_ALIAS 1 /* instrument alias */
740
741/* instrument ASCII identifiers */
742#define SNDRV_SEQ_INSTR_ID_DLS1 "DLS1"
743#define SNDRV_SEQ_INSTR_ID_DLS2 "DLS2"
744#define SNDRV_SEQ_INSTR_ID_SIMPLE "Simple Wave"
745#define SNDRV_SEQ_INSTR_ID_SOUNDFONT "SoundFont"
746#define SNDRV_SEQ_INSTR_ID_GUS_PATCH "GUS Patch"
747#define SNDRV_SEQ_INSTR_ID_INTERWAVE "InterWave FFFF"
748#define SNDRV_SEQ_INSTR_ID_OPL2_3 "OPL2/3 FM"
749#define SNDRV_SEQ_INSTR_ID_OPL4 "OPL4"
750
751/* instrument types */
752#define SNDRV_SEQ_INSTR_TYPE0_DLS1 (1<<0) /* MIDI DLS v1 */
753#define SNDRV_SEQ_INSTR_TYPE0_DLS2 (1<<1) /* MIDI DLS v2 */
754#define SNDRV_SEQ_INSTR_TYPE1_SIMPLE (1<<0) /* Simple Wave */
755#define SNDRV_SEQ_INSTR_TYPE1_SOUNDFONT (1<<1) /* EMU SoundFont */
756#define SNDRV_SEQ_INSTR_TYPE1_GUS_PATCH (1<<2) /* Gravis UltraSound Patch */
757#define SNDRV_SEQ_INSTR_TYPE1_INTERWAVE (1<<3) /* InterWave FFFF */
758#define SNDRV_SEQ_INSTR_TYPE2_OPL2_3 (1<<0) /* Yamaha OPL2/3 FM */
759#define SNDRV_SEQ_INSTR_TYPE2_OPL4 (1<<1) /* Yamaha OPL4 */
760
761/* put commands */
762#define SNDRV_SEQ_INSTR_PUT_CMD_CREATE 0
763#define SNDRV_SEQ_INSTR_PUT_CMD_REPLACE 1
764#define SNDRV_SEQ_INSTR_PUT_CMD_MODIFY 2
765#define SNDRV_SEQ_INSTR_PUT_CMD_ADD 3
766#define SNDRV_SEQ_INSTR_PUT_CMD_REMOVE 4
767
768/* get commands */
769#define SNDRV_SEQ_INSTR_GET_CMD_FULL 0
770#define SNDRV_SEQ_INSTR_GET_CMD_PARTIAL 1
771
772/* query flags */
773#define SNDRV_SEQ_INSTR_QUERY_FOLLOW_ALIAS (1<<0)
774
775/* free commands */
776#define SNDRV_SEQ_INSTR_FREE_CMD_ALL 0
777#define SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE 1
778#define SNDRV_SEQ_INSTR_FREE_CMD_CLUSTER 2
779#define SNDRV_SEQ_INSTR_FREE_CMD_SINGLE 3
780
781/* size of ROM/RAM */
782typedef unsigned int sndrv_seq_instr_size_t;
783
784/* INSTR_INFO */
785
786struct sndrv_seq_instr_info {
787 int result; /* operation result */
788 unsigned int formats[8]; /* bitmap of supported formats */
789 int ram_count; /* count of RAM banks */
790 sndrv_seq_instr_size_t ram_sizes[16]; /* size of RAM banks */
791 int rom_count; /* count of ROM banks */
792 sndrv_seq_instr_size_t rom_sizes[8]; /* size of ROM banks */
793 char reserved[128];
794};
795
796/* INSTR_STATUS */
797
798struct sndrv_seq_instr_status {
799 int result; /* operation result */
800 sndrv_seq_instr_size_t free_ram[16]; /* free RAM in banks */
801 int instrument_count; /* count of downloaded instruments */
802 char reserved[128];
803};
804
805/* INSTR_FORMAT_INFO */
806
807struct sndrv_seq_instr_format_info {
808 char format[16]; /* format identifier - SNDRV_SEQ_INSTR_ID_* */
809 unsigned int len; /* max data length (without this structure) */
810};
811
812struct sndrv_seq_instr_format_info_result {
813 int result; /* operation result */
814 char format[16]; /* format identifier */
815 unsigned int len; /* filled data length (without this structure) */
816};
817
818/* instrument data */
819struct sndrv_seq_instr_data {
820 char name[32]; /* instrument name */
821 char reserved[16]; /* for the future use */
822 int type; /* instrument type */
823 union {
824 char format[16]; /* format identifier */
825 struct sndrv_seq_instr alias;
826 } data;
827};
828
829/* INSTR_PUT/GET, data are stored in one block (extended), header + data */
830
831struct sndrv_seq_instr_header {
832 union {
833 struct sndrv_seq_instr instr;
834 sndrv_seq_instr_cluster_t cluster;
835 } id; /* instrument identifier */
836 unsigned int cmd; /* get/put/free command */
837 unsigned int flags; /* query flags (only for get) */
838 unsigned int len; /* real instrument data length (without header) */
839 int result; /* operation result */
840 char reserved[16]; /* for the future */
841 struct sndrv_seq_instr_data data; /* instrument data (for put/get result) */
842};
843
844/* INSTR_CLUSTER_SET */
845
846struct sndrv_seq_instr_cluster_set {
847 sndrv_seq_instr_cluster_t cluster; /* cluster identifier */
848 char name[32]; /* cluster name */
849 int priority; /* cluster priority */
850 char reserved[64]; /* for the future use */
851};
852
853/* INSTR_CLUSTER_GET */
854
855struct sndrv_seq_instr_cluster_get {
856 sndrv_seq_instr_cluster_t cluster; /* cluster identifier */
857 char name[32]; /* cluster name */
858 int priority; /* cluster priority */
859 char reserved[64]; /* for the future use */
860};
861
862/*
863 * IOCTL commands
864 */
865
866#define SNDRV_SEQ_IOCTL_PVERSION _IOR ('S', 0x00, int)
867#define SNDRV_SEQ_IOCTL_CLIENT_ID _IOR ('S', 0x01, int)
868#define SNDRV_SEQ_IOCTL_SYSTEM_INFO _IOWR('S', 0x02, struct sndrv_seq_system_info)
869#define SNDRV_SEQ_IOCTL_RUNNING_MODE _IOWR('S', 0x03, struct sndrv_seq_running_info)
870
871#define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct sndrv_seq_client_info)
872#define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW ('S', 0x11, struct sndrv_seq_client_info)
873
874#define SNDRV_SEQ_IOCTL_CREATE_PORT _IOWR('S', 0x20, struct sndrv_seq_port_info)
875#define SNDRV_SEQ_IOCTL_DELETE_PORT _IOW ('S', 0x21, struct sndrv_seq_port_info)
876#define SNDRV_SEQ_IOCTL_GET_PORT_INFO _IOWR('S', 0x22, struct sndrv_seq_port_info)
877#define SNDRV_SEQ_IOCTL_SET_PORT_INFO _IOW ('S', 0x23, struct sndrv_seq_port_info)
878
879#define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT _IOW ('S', 0x30, struct sndrv_seq_port_subscribe)
880#define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct sndrv_seq_port_subscribe)
881
882#define SNDRV_SEQ_IOCTL_CREATE_QUEUE _IOWR('S', 0x32, struct sndrv_seq_queue_info)
883#define SNDRV_SEQ_IOCTL_DELETE_QUEUE _IOW ('S', 0x33, struct sndrv_seq_queue_info)
884#define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO _IOWR('S', 0x34, struct sndrv_seq_queue_info)
885#define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO _IOWR('S', 0x35, struct sndrv_seq_queue_info)
886#define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct sndrv_seq_queue_info)
887#define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct sndrv_seq_queue_status)
888#define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct sndrv_seq_queue_tempo)
889#define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW ('S', 0x42, struct sndrv_seq_queue_tempo)
890#define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct sndrv_seq_queue_owner)
891#define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW ('S', 0x44, struct sndrv_seq_queue_owner)
892#define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct sndrv_seq_queue_timer)
893#define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW ('S', 0x46, struct sndrv_seq_queue_timer)
894/* XXX
895#define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC _IOWR('S', 0x53, struct sndrv_seq_queue_sync)
896#define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC _IOW ('S', 0x54, struct sndrv_seq_queue_sync)
897*/
898#define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT _IOWR('S', 0x49, struct sndrv_seq_queue_client)
899#define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT _IOW ('S', 0x4a, struct sndrv_seq_queue_client)
900#define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL _IOWR('S', 0x4b, struct sndrv_seq_client_pool)
901#define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL _IOW ('S', 0x4c, struct sndrv_seq_client_pool)
902#define SNDRV_SEQ_IOCTL_REMOVE_EVENTS _IOW ('S', 0x4e, struct sndrv_seq_remove_events)
903#define SNDRV_SEQ_IOCTL_QUERY_SUBS _IOWR('S', 0x4f, struct sndrv_seq_query_subs)
904#define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION _IOWR('S', 0x50, struct sndrv_seq_port_subscribe)
905#define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT _IOWR('S', 0x51, struct sndrv_seq_client_info)
906#define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT _IOWR('S', 0x52, struct sndrv_seq_port_info)
907
908#endif /* __SOUND_ASEQUENCER_H */