1 /* $NetBSD: sequencervar.h,v 1.12 2007/02/09 21:55:26 ad Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (augustss@NetBSD.org).
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/callout.h>
37 struct timeval reftime
, stoptime
;
38 uint16_t tempo_beatpermin
, timebase_divperbeat
;
40 uint32_t divs_lastevent
;
41 uint32_t divs_lastchange
;
46 struct sequencer_queue
{
47 seq_event_t buf
[SEQ_MAXQ
];
48 u_int in
; /* input index in buf */
49 u_int out
; /* output index in buf */
50 u_int count
; /* filled slots in buf */
52 #define SEQ_QINIT(q) ((q)->in = (q)->out = (q)->count = 0)
53 #define SEQ_QEMPTY(q) ((q)->count == 0)
54 #define SEQ_QFULL(q) ((q)->count >= SEQ_MAXQ)
55 #define SEQ_QPUT(q, e) ((q)->buf[(q)->in++] = (e), (q)->in %= SEQ_MAXQ, (q)->count++)
56 #define SEQ_QGET(q, e) ((e) = (q)->buf[(q)->out++], (q)->out %= SEQ_MAXQ, (q)->count--)
57 #define SEQ_QLEN(q) ((q)->count)
59 struct sequencer_softc
;
69 struct sequencer_softc
*seq
;
70 struct midi_softc
*msc
;
71 char doingsysex
; /* doing a SEQ_SYSEX */
74 struct sequencer_softc
{
76 struct device
*sc_dev
; /* Hardware device struct */
77 struct callout sc_callout
;
78 int isopen
; /* Open indicator */
79 int flags
; /* Open flags */
85 struct selinfo wsel
; /* write selector */
86 struct selinfo rsel
; /* read selector */
87 struct proc
*async
; /* process who wants audio SIGIO */
90 int nmidi
; /* number of MIDI devices */
91 struct midi_dev
**devs
;
92 struct syn_timer timer
;
94 struct sequencer_queue outq
; /* output event queue */
95 u_int lowat
; /* output queue low water mark */
96 char timeout
; /* timeout has been set */
98 struct sequencer_queue inq
; /* input event queue */
102 void seq_event_intr(void *, seq_event_t
*);
104 #define SEQUENCERUNIT(d) ((d) & 0x7f)
105 #define SEQ_IS_OLD(d) ((d) & 0x80)