sequencervar.h revision 1.2 1 /* $NetBSD: sequencervar.h,v 1.2 1998/08/08 11:00:33 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 1024
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 MAXCONTROLLER 128
65 struct channel_info {
66 int pgm_num;
67 int bender_value;
68 int bender_range;
69 u_char controllers[MAXCONTROLLER];
70 };
71
72 #define MAXCHAN 16
73 struct midi_dev {
74 char *name;
75 int subtype;
76 int capabilities;
77 int nr_voices;
78 int instr_bank_size;
79 struct channel_info chan_info[MAXCHAN];
80 int unit;
81 u_char last_cmd;
82 struct sequencer_softc *seq;
83 struct midi_softc *msc;
84 };
85
86 struct sequencer_softc {
87 struct device dev;
88 struct device *sc_dev; /* Hardware device struct */
89 int isopen; /* Open indicator */
90 int flags; /* Open flags */
91 int mode;
92 #define SEQ_OLD 0
93 #define SEQ_NEW 1
94 int rchan, wchan;
95 int pbus;
96 struct selinfo wsel; /* write selector */
97 struct selinfo rsel; /* read selector */
98 struct proc *async; /* process who wants audio SIGIO */
99
100 int nmidi; /* number of MIDI devices */
101 struct midi_dev **devs;
102 struct syn_timer timer;
103
104 struct sequencer_queue outq; /* output event queue */
105 u_int lowat; /* output queue low water mark */
106 char timeout; /* timeout has been set */
107
108 struct sequencer_queue inq; /* input event queue */
109 u_long input_stamp;
110 };
111
112 void seq_event_intr __P((void *, seq_event_rec *));
113
114 #define SEQUENCERUNIT(d) ((d) & 0x7f)
115 #define SEQ_IS_OLD(d) ((d) & 0x80)
116
117