sequencervar.h revision 1.4 1 /* $NetBSD: sequencervar.h,v 1.4 1998/08/13 00:13:57 augustss Exp $ */
2
3 /*
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * Author: Lennart Augustsson
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the NetBSD
20 * Foundation, Inc. and its contributors.
21 * 4. Neither the name of The NetBSD Foundation nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 struct midi_softc;
39
40 struct syn_timer {
41 struct timeval start, stop;
42 int tempo, timebase;
43 u_long last;
44 u_long tick;
45 int running;
46 };
47
48 #define SEQ_MAXQ 256
49 struct sequencer_queue {
50 seq_event_rec buf[SEQ_MAXQ];
51 u_int in; /* input index in buf */
52 u_int out; /* output index in buf */
53 u_int count; /* filled slots in buf */
54 };
55 #define SEQ_QINIT(q) ((q)->in = (q)->out = (q)->count = 0)
56 #define SEQ_QEMPTY(q) ((q)->count == 0)
57 #define SEQ_QFULL(q) ((q)->count >= SEQ_MAXQ)
58 #define SEQ_QPUT(q, e) ((q)->buf[(q)->in++] = (e), (q)->in %= SEQ_MAXQ, (q)->count++)
59 #define SEQ_QGET(q, e) ((e) = (q)->buf[(q)->out++], (q)->out %= SEQ_MAXQ, (q)->count--)
60 #define SEQ_QLEN(q) ((q)->count)
61
62 struct sequencer_softc;
63
64 #define MAXCHAN 16
65 struct midi_dev {
66 char *name;
67 int subtype;
68 int capabilities;
69 int nr_voices;
70 int instr_bank_size;
71 int unit;
72 u_char last_cmd;
73 struct sequencer_softc *seq;
74 struct midi_softc *msc;
75 };
76
77 struct sequencer_softc {
78 struct device dev;
79 struct device *sc_dev; /* Hardware device struct */
80 int isopen; /* Open indicator */
81 int flags; /* Open flags */
82 int mode;
83 #define SEQ_OLD 0
84 #define SEQ_NEW 1
85 int rchan, wchan;
86 int pbus;
87 struct selinfo wsel; /* write selector */
88 struct selinfo rsel; /* read selector */
89 struct proc *async; /* process who wants audio SIGIO */
90
91 char doingsysex; /* doing a SEQ_SYSEX */
92
93 int nmidi; /* number of MIDI devices */
94 struct midi_dev **devs;
95 struct syn_timer timer;
96
97 struct sequencer_queue outq; /* output event queue */
98 u_int lowat; /* output queue low water mark */
99 char timeout; /* timeout has been set */
100
101 struct sequencer_queue inq; /* input event queue */
102 u_long input_stamp;
103 };
104
105 void seq_event_intr __P((void *, seq_event_rec *));
106
107 #define SEQUENCERUNIT(d) ((d) & 0x7f)
108 #define SEQ_IS_OLD(d) ((d) & 0x80)
109
110