Annotation of sys/dev/midivar.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: midivar.h,v 1.5 2005/11/21 18:16:38 millert Exp $ */
2:
3: /*
4: * Copyright (c) 2003, 2004 Alexandre Ratchov
5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: #ifndef _SYS_DEV_MIDIVAR_H_
20: #define _SYS_DEV_MIDIVAR_H_
21:
22: #include <dev/midi_if.h>
23: #include <sys/device.h>
24: #include <sys/selinfo.h>
25: #include <sys/proc.h>
26: #include <sys/timeout.h>
27:
28: #define MIDI_MAXWRITE 32 /* max bytes to give to the uart at once */
29: #define MIDI_RATE 3125 /* midi uart baud rate in bytes/second */
30: #define MIDI_UNIT(a) ((a) & 0xff)
31: #define MIDI_DEV2SC(a) (midi_cd.cd_devs[MIDI_UNIT(a)])
32:
33: #include "sequencer.h"
34:
35: #if NSEQUENCER > 0
36: struct midi_dev; /* defined in sequencervar.h */
37: #endif
38:
39: /*
40: * simple ring buffer
41: */
42: #define MIDIBUF_SIZE (1 << 10)
43: #define MIDIBUF_MASK (MIDIBUF_SIZE - 1)
44: struct midi_buffer {
45: unsigned char data[MIDIBUF_SIZE];
46: unsigned start, used;
47: };
48: #define MIDIBUF_START(buf) ((buf)->start)
49: #define MIDIBUF_END(buf) (((buf)->start + (buf)->used) & MIDIBUF_MASK)
50: #define MIDIBUF_USED(buf) ((buf)->used)
51: #define MIDIBUF_AVAIL(buf) (MIDIBUF_SIZE - (buf)->used)
52: #define MIDIBUF_ISFULL(buf) ((buf)->used >= MIDIBUF_SIZE)
53: #define MIDIBUF_ISEMPTY(buf) ((buf)->used == 0)
54: #define MIDIBUF_WRITE(buf, byte) \
55: do { \
56: (buf)->data[MIDIBUF_END(buf)] = (byte); \
57: (buf)->used++; \
58: } while(0)
59: #define MIDIBUF_READ(buf, byte) \
60: do { \
61: (byte) = (buf)->data[(buf)->start++]; \
62: (buf)->start &= MIDIBUF_MASK; \
63: (buf)->used--; \
64: } while(0)
65: #define MIDIBUF_REMOVE(buf, count) \
66: do { \
67: (buf)->start += (count); \
68: (buf)->start &= MIDIBUF_MASK; \
69: (buf)->used -= (count); \
70: } while(0)
71: #define MIDIBUF_INIT(buf) \
72: do { \
73: (buf)->start = (buf)->used = 0; \
74: } while(0)
75:
76:
77: struct midi_softc {
78: struct device dev;
79: struct midi_hw_if *hw_if;
80: void *hw_hdl;
81: int isopen;
82: int isbusy; /* concerns only the output */
83: int isdying;
84: int flags; /* open flags */
85: int props; /* midi hw proprieties */
86: int rchan;
87: int wchan;
88: unsigned wait; /* see midi_out_do */
89: struct selinfo rsel;
90: struct selinfo wsel;
91: struct proc *async;
92: struct timeout timeo;
93: struct midi_buffer inbuf;
94: struct midi_buffer outbuf;
95: #if NSEQUENCER > 0
96: int seqopen;
97: struct midi_dev *seq_md; /* structure that links us with the seq. */
98: int evindex;
99: unsigned char evstatus;
100: unsigned char evdata[2];
101: #endif /* NSEQUENCER > 0 */
102: };
103:
104: #endif /* _SYS_DEV_MIDIVAR_H_ */
CVSweb