2007-03-04 08:59:00 +03:00
|
|
|
/* $NetBSD: midi_if.h,v 1.19 2007/03/04 06:01:42 christos Exp $ */
|
1998-08-18 01:16:09 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
1998-11-26 01:17:06 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2003-12-04 16:57:30 +03:00
|
|
|
* by Lennart Augustsson (augustss@NetBSD.org).
|
1998-08-18 01:16:09 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_DEV_MIDI_IF_H_
|
|
|
|
#define _SYS_DEV_MIDI_IF_H_
|
|
|
|
|
|
|
|
struct midi_info {
|
2005-05-30 02:18:25 +04:00
|
|
|
const char *name; /* Name of MIDI hardware */
|
1998-08-18 01:16:09 +04:00
|
|
|
int props;
|
|
|
|
};
|
|
|
|
#define MIDI_PROP_OUT_INTR 1
|
|
|
|
#define MIDI_PROP_CAN_INPUT 2
|
2006-06-30 17:56:25 +04:00
|
|
|
#define MIDI_PROP_NO_OUTPUT 4
|
1998-08-18 01:16:09 +04:00
|
|
|
|
|
|
|
struct midi_softc;
|
|
|
|
|
|
|
|
struct midi_hw_if {
|
2001-10-03 02:41:22 +04:00
|
|
|
int (*open)(void *, int, /* open hardware */
|
|
|
|
void (*)(void *, int), /* input callback */
|
|
|
|
void (*)(void *), /* output callback */
|
|
|
|
void *);
|
|
|
|
void (*close)(void *); /* close hardware */
|
|
|
|
int (*output)(void *, int); /* output a byte */
|
|
|
|
void (*getinfo)(void *, struct midi_info *);
|
2007-03-04 08:59:00 +03:00
|
|
|
int (*ioctl)(void *, u_long, void *, int, struct lwp *);
|
1998-08-18 01:16:09 +04:00
|
|
|
};
|
|
|
|
|
2006-06-30 17:56:25 +04:00
|
|
|
/*
|
|
|
|
* The extended hardware interface is for use by drivers that are better off
|
|
|
|
* getting messages whole to transmit, rather than byte-by-byte through
|
|
|
|
* output(). Two examples are midisyn (which interprets MIDI messages in
|
|
|
|
* software to drive synth chips) and umidi (which has to send messages in the
|
|
|
|
* packet-based USB MIDI protocol). It is silly for them to have to reassemble
|
|
|
|
* messages midi had to split up to poke through the single-byte interface.
|
|
|
|
*
|
|
|
|
* To register use of the extended interface, a driver will call back midi's
|
|
|
|
* midi_register_hw_if_ext() function during getinfo(); thereafter midi will
|
|
|
|
* deliver channel messages, system common messages other than sysex, and sysex
|
|
|
|
* messages, respectively, through these methods, and use the original output
|
|
|
|
* method only for system realtime messages (all of which are single byte).
|
|
|
|
* Other drivers that have no reason to change from the single-byte interface
|
|
|
|
* simply don't call the register function, and nothing changes for them.
|
|
|
|
*
|
|
|
|
* IMPORTANT: any code that provides a midi_hw_if_ext struct MUST initialize
|
|
|
|
* its members BY NAME (typically with a C99-style initializer with designators)
|
|
|
|
* and assure that any unused members contain zeroes (which is what C99
|
|
|
|
* initializers will do), and make no assumptions about the size or order of
|
|
|
|
* the struct, to allow for further extension of this interface as needed.
|
|
|
|
*/
|
|
|
|
struct midi_hw_if_ext {
|
|
|
|
int (*channel)(void *, int, int, u_char *, int);
|
|
|
|
int (*common)(void *, int, u_char *, int);
|
|
|
|
int (*sysex)(void *, u_char *, int);
|
|
|
|
int compress:1; /* if hw wants channel msgs in compressed form */
|
|
|
|
};
|
|
|
|
void midi_register_hw_if_ext(struct midi_hw_if_ext *);
|
|
|
|
|
2001-10-03 02:41:22 +04:00
|
|
|
void midi_attach(struct midi_softc *, struct device *);
|
2005-02-27 03:26:58 +03:00
|
|
|
struct device *midi_attach_mi(const struct midi_hw_if *, void *,
|
2001-10-03 02:41:22 +04:00
|
|
|
struct device *);
|
1998-08-18 01:16:09 +04:00
|
|
|
|
2001-10-03 02:41:22 +04:00
|
|
|
int midi_unit_count(void);
|
|
|
|
void midi_getinfo(dev_t, struct midi_info *);
|
|
|
|
int midi_writebytes(int, u_char *, int);
|
1998-08-18 01:16:09 +04:00
|
|
|
|
2000-07-07 05:11:12 +04:00
|
|
|
#if !defined(IPL_AUDIO)
|
1999-03-22 10:57:15 +03:00
|
|
|
#define splaudio splbio /* XXX */
|
|
|
|
#define IPL_AUDIO IPL_BIO /* XXX */
|
|
|
|
#endif
|
|
|
|
|
1998-08-18 01:16:09 +04:00
|
|
|
#endif /* _SYS_DEV_MIDI_IF_H_ */
|