diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/sound/rawmidi.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/sound/rawmidi.h')
-rw-r--r-- | include/sound/rawmidi.h | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h new file mode 100644 index 000000000000..3f9db510dee3 --- /dev/null +++ b/include/sound/rawmidi.h | |||
@@ -0,0 +1,180 @@ | |||
1 | #ifndef __SOUND_RAWMIDI_H | ||
2 | #define __SOUND_RAWMIDI_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 | #include <sound/asound.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/wait.h> | ||
29 | #include <asm/semaphore.h> | ||
30 | |||
31 | #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) | ||
32 | #include "seq_device.h" | ||
33 | #endif | ||
34 | |||
35 | /* | ||
36 | * Raw MIDI interface | ||
37 | */ | ||
38 | |||
39 | typedef enum sndrv_rawmidi_stream snd_rawmidi_stream_t; | ||
40 | typedef struct sndrv_rawmidi_info snd_rawmidi_info_t; | ||
41 | typedef struct sndrv_rawmidi_params snd_rawmidi_params_t; | ||
42 | typedef struct sndrv_rawmidi_status snd_rawmidi_status_t; | ||
43 | |||
44 | #define SNDRV_RAWMIDI_DEVICES 8 | ||
45 | |||
46 | #define SNDRV_RAWMIDI_LFLG_OUTPUT (1<<0) | ||
47 | #define SNDRV_RAWMIDI_LFLG_INPUT (1<<1) | ||
48 | #define SNDRV_RAWMIDI_LFLG_OPEN (3<<0) | ||
49 | #define SNDRV_RAWMIDI_LFLG_APPEND (1<<2) | ||
50 | #define SNDRV_RAWMIDI_LFLG_NOOPENLOCK (1<<3) | ||
51 | |||
52 | typedef struct _snd_rawmidi_runtime snd_rawmidi_runtime_t; | ||
53 | typedef struct _snd_rawmidi_substream snd_rawmidi_substream_t; | ||
54 | typedef struct _snd_rawmidi_str snd_rawmidi_str_t; | ||
55 | |||
56 | typedef struct _snd_rawmidi_ops { | ||
57 | int (*open) (snd_rawmidi_substream_t * substream); | ||
58 | int (*close) (snd_rawmidi_substream_t * substream); | ||
59 | void (*trigger) (snd_rawmidi_substream_t * substream, int up); | ||
60 | void (*drain) (snd_rawmidi_substream_t * substream); | ||
61 | } snd_rawmidi_ops_t; | ||
62 | |||
63 | typedef struct _snd_rawmidi_global_ops { | ||
64 | int (*dev_register) (snd_rawmidi_t * rmidi); | ||
65 | int (*dev_unregister) (snd_rawmidi_t * rmidi); | ||
66 | } snd_rawmidi_global_ops_t; | ||
67 | |||
68 | struct _snd_rawmidi_runtime { | ||
69 | unsigned int drain: 1, /* drain stage */ | ||
70 | oss: 1; /* OSS compatible mode */ | ||
71 | /* midi stream buffer */ | ||
72 | unsigned char *buffer; /* buffer for MIDI data */ | ||
73 | size_t buffer_size; /* size of buffer */ | ||
74 | size_t appl_ptr; /* application pointer */ | ||
75 | size_t hw_ptr; /* hardware pointer */ | ||
76 | size_t avail_min; /* min avail for wakeup */ | ||
77 | size_t avail; /* max used buffer for wakeup */ | ||
78 | size_t xruns; /* over/underruns counter */ | ||
79 | /* misc */ | ||
80 | spinlock_t lock; | ||
81 | wait_queue_head_t sleep; | ||
82 | /* event handler (new bytes, input only) */ | ||
83 | void (*event)(snd_rawmidi_substream_t *substream); | ||
84 | /* defers calls to event [input] or ops->trigger [output] */ | ||
85 | struct tasklet_struct tasklet; | ||
86 | /* private data */ | ||
87 | void *private_data; | ||
88 | void (*private_free)(snd_rawmidi_substream_t *substream); | ||
89 | }; | ||
90 | |||
91 | struct _snd_rawmidi_substream { | ||
92 | struct list_head list; /* list of all substream for given stream */ | ||
93 | int stream; /* direction */ | ||
94 | int number; /* substream number */ | ||
95 | unsigned int opened: 1, /* open flag */ | ||
96 | append: 1, /* append flag (merge more streams) */ | ||
97 | active_sensing: 1; /* send active sensing when close */ | ||
98 | int use_count; /* use counter (for output) */ | ||
99 | size_t bytes; | ||
100 | snd_rawmidi_t *rmidi; | ||
101 | snd_rawmidi_str_t *pstr; | ||
102 | char name[32]; | ||
103 | snd_rawmidi_runtime_t *runtime; | ||
104 | /* hardware layer */ | ||
105 | snd_rawmidi_ops_t *ops; | ||
106 | }; | ||
107 | |||
108 | typedef struct _snd_rawmidi_file { | ||
109 | snd_rawmidi_t *rmidi; | ||
110 | snd_rawmidi_substream_t *input; | ||
111 | snd_rawmidi_substream_t *output; | ||
112 | } snd_rawmidi_file_t; | ||
113 | |||
114 | struct _snd_rawmidi_str { | ||
115 | unsigned int substream_count; | ||
116 | unsigned int substream_opened; | ||
117 | struct list_head substreams; | ||
118 | }; | ||
119 | |||
120 | struct _snd_rawmidi { | ||
121 | snd_card_t *card; | ||
122 | |||
123 | unsigned int device; /* device number */ | ||
124 | unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */ | ||
125 | char id[64]; | ||
126 | char name[80]; | ||
127 | |||
128 | #ifdef CONFIG_SND_OSSEMUL | ||
129 | int ossreg; | ||
130 | #endif | ||
131 | |||
132 | snd_rawmidi_global_ops_t *ops; | ||
133 | |||
134 | snd_rawmidi_str_t streams[2]; | ||
135 | |||
136 | void *private_data; | ||
137 | void (*private_free) (snd_rawmidi_t *rmidi); | ||
138 | |||
139 | struct semaphore open_mutex; | ||
140 | wait_queue_head_t open_wait; | ||
141 | |||
142 | snd_info_entry_t *dev; | ||
143 | snd_info_entry_t *proc_entry; | ||
144 | |||
145 | #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) | ||
146 | snd_seq_device_t *seq_dev; | ||
147 | #endif | ||
148 | }; | ||
149 | |||
150 | /* main rawmidi functions */ | ||
151 | |||
152 | int snd_rawmidi_new(snd_card_t * card, char *id, int device, | ||
153 | int output_count, int input_count, | ||
154 | snd_rawmidi_t ** rmidi); | ||
155 | void snd_rawmidi_set_ops(snd_rawmidi_t * rmidi, int stream, snd_rawmidi_ops_t * ops); | ||
156 | |||
157 | /* callbacks */ | ||
158 | |||
159 | void snd_rawmidi_receive_reset(snd_rawmidi_substream_t * substream); | ||
160 | int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char *buffer, int count); | ||
161 | void snd_rawmidi_transmit_reset(snd_rawmidi_substream_t * substream); | ||
162 | int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream); | ||
163 | int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count); | ||
164 | int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count); | ||
165 | int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count); | ||
166 | |||
167 | /* main midi functions */ | ||
168 | |||
169 | int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info); | ||
170 | int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, int mode, snd_rawmidi_file_t * rfile); | ||
171 | int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile); | ||
172 | int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, snd_rawmidi_params_t * params); | ||
173 | int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, snd_rawmidi_params_t * params); | ||
174 | int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream); | ||
175 | int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream); | ||
176 | int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream); | ||
177 | long snd_rawmidi_kernel_read(snd_rawmidi_substream_t * substream, unsigned char *buf, long count); | ||
178 | long snd_rawmidi_kernel_write(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count); | ||
179 | |||
180 | #endif /* __SOUND_RAWMIDI_H */ | ||