source: GPL/alsa-kernel/include/sound/rawmidi.old@ 18

Last change on this file since 18 was 18, checked in by vladest, 20 years ago

initial import

File size: 6.2 KB
Line 
1#ifndef __MIDI_H
2#define __MIDI_H
3
4/*
5 * Abstract layer for MIDI v1.0 stream
6 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifdef CONFIG_SND_SEQUENCER
26#include "seq_device.h"
27#endif
28
29/*
30 * Raw MIDI interface
31 */
32
33typedef enum sndrv_rawmidi_stream snd_rawmidi_stream_t;
34typedef struct sndrv_rawmidi_info snd_rawmidi_info_t;
35typedef struct sndrv_rawmidi_params snd_rawmidi_params_t;
36typedef struct sndrv_rawmidi_status snd_rawmidi_status_t;
37
38#define SNDRV_RAWMIDI_DEVICES 8
39
40#define SNDRV_RAWMIDI_LFLG_OUTPUT (1<<0)
41#define SNDRV_RAWMIDI_LFLG_INPUT (1<<1)
42#define SNDRV_RAWMIDI_LFLG_OPEN (3<<0)
43#define SNDRV_RAWMIDI_LFLG_APPEND (1<<2)
44#define SNDRV_RAWMIDI_LFLG_NOOPENLOCK (1<<3)
45
46typedef struct _snd_rawmidi_runtime snd_rawmidi_runtime_t;
47typedef struct _snd_rawmidi_substream snd_rawmidi_substream_t;
48typedef struct _snd_rawmidi_str snd_rawmidi_str_t;
49
50typedef struct _snd_rawmidi_ops {
51 int (*open) (snd_rawmidi_substream_t * substream);
52 int (*close) (snd_rawmidi_substream_t * substream);
53 void (*trigger) (snd_rawmidi_substream_t * substream, int up);
54 void (*drain) (snd_rawmidi_substream_t * substream);
55} snd_rawmidi_ops_t;
56
57typedef struct _snd_rawmidi_global_ops {
58 int (*dev_register) (snd_rawmidi_t * rmidi);
59 int (*dev_unregister) (snd_rawmidi_t * rmidi);
60} snd_rawmidi_global_ops_t;
61
62struct _snd_rawmidi_runtime {
63 unsigned int trigger: 1, /* transfer is running */
64 drain: 1, /* drain stage */
65 oss: 1; /* OSS compatible mode */
66 /* midi stream buffer */
67 unsigned char *buffer; /* buffer for MIDI data */
68 size_t buffer_size; /* size of buffer */
69 size_t appl_ptr; /* application pointer */
70 size_t hw_ptr; /* hardware pointer */
71 size_t avail_min; /* min avail for wakeup */
72 size_t avail; /* max used buffer for wakeup */
73 size_t xruns; /* over/underruns counter */
74 /* misc */
75 spinlock_t lock;
76 wait_queue_head_t sleep;
77 /* event handler (room [output] or new bytes [input]) */
78 void (*event)(snd_rawmidi_substream_t *substream);
79 /* private data */
80 void *private_data;
81 void (*private_free)(snd_rawmidi_substream_t *substream);
82};
83
84struct _snd_rawmidi_substream {
85 struct list_head list; /* list of all substream for given stream */
86 int stream; /* direction */
87 int number; /* substream number */
88 unsigned int opened: 1, /* open flag */
89 append: 1, /* append flag (merge more streams) */
90 active_sensing: 1; /* send active sensing when close */
91 int use_count; /* use counter (for output) */
92 size_t bytes;
93 snd_rawmidi_t *rmidi;
94 snd_rawmidi_str_t *pstr;
95 char name[32];
96 snd_rawmidi_runtime_t *runtime;
97 /* hardware layer */
98 snd_rawmidi_ops_t *ops;
99};
100
101typedef struct _snd_rawmidi_file {
102 snd_rawmidi_t *rmidi;
103 snd_rawmidi_substream_t *input;
104 snd_rawmidi_substream_t *output;
105} snd_rawmidi_file_t;
106
107struct _snd_rawmidi_str {
108 unsigned int substream_count;
109 unsigned int substream_opened;
110 struct list_head substreams;
111};
112
113struct _snd_rawmidi {
114 snd_card_t *card;
115
116 unsigned int device; /* device number */
117 unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */
118 char id[64];
119 char name[80];
120
121#ifdef CONFIG_SND_OSSEMUL
122 int ossreg;
123#endif
124
125 snd_rawmidi_global_ops_t *ops;
126
127 snd_rawmidi_str_t streams[2];
128
129 void *private_data;
130 void (*private_free) (snd_rawmidi_t *rmidi);
131
132 struct semaphore open_mutex;
133 wait_queue_head_t open_wait;
134
135 snd_info_entry_t *dev;
136 snd_info_entry_t *proc_entry;
137
138#ifdef CONFIG_SND_SEQUENCER
139 snd_seq_device_t *seq_dev;
140#endif
141};
142
143/* main rawmidi functions */
144
145int snd_rawmidi_new(snd_card_t * card, char *id, int device,
146 int output_count, int input_count,
147 snd_rawmidi_t ** rmidi);
148void snd_rawmidi_set_ops(snd_rawmidi_t * rmidi, int stream, snd_rawmidi_ops_t * ops);
149
150/* control functions */
151
152int snd_rawmidi_control_ioctl(snd_card_t * card,
153 snd_ctl_file_t * control,
154 unsigned int cmd,
155 unsigned long arg);
156
157/* callbacks */
158
159void snd_rawmidi_receive_reset(snd_rawmidi_substream_t * substream);
160int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char *buffer, int count);
161void snd_rawmidi_transmit_reset(snd_rawmidi_substream_t * substream);
162int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream);
163int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count);
164int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count);
165int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count);
166
167/* main midi functions */
168
169int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info);
170int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, int mode, snd_rawmidi_file_t * rfile);
171int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile);
172int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, snd_rawmidi_params_t * params);
173int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, snd_rawmidi_params_t * params);
174int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream);
175int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream);
176int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream);
177long snd_rawmidi_kernel_read(snd_rawmidi_substream_t * substream, unsigned char *buf, long count);
178long snd_rawmidi_kernel_write(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count);
179
180#endif /* __MIDI_H */
Note: See TracBrowser for help on using the repository browser.