blob: 07e3ea133b56fc05dc600379ca84630fa472094f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * OSS compatible sequencer driver
3 *
4 * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __SEQ_OSS_DEVICE_H
22#define __SEQ_OSS_DEVICE_H
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/time.h>
25#include <linux/wait.h>
26#include <linux/slab.h>
27#include <linux/sched.h>
28#include <sound/core.h>
29#include <sound/seq_oss.h>
30#include <sound/rawmidi.h>
31#include <sound/seq_kernel.h>
32#include <sound/info.h>
33
34/* enable debug print */
35#define SNDRV_SEQ_OSS_DEBUG
36
37/* max. applications */
38#define SNDRV_SEQ_OSS_MAX_CLIENTS 16
39#define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS 16
40#define SNDRV_SEQ_OSS_MAX_MIDI_DEVS 32
41
42/* version */
43#define SNDRV_SEQ_OSS_MAJOR_VERSION 0
44#define SNDRV_SEQ_OSS_MINOR_VERSION 1
45#define SNDRV_SEQ_OSS_TINY_VERSION 8
46#define SNDRV_SEQ_OSS_VERSION_STR "0.1.8"
47
48/* device and proc interface name */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define SNDRV_SEQ_OSS_PROCNAME "oss"
50
51
52/*
53 * type definitions
54 */
55
Linus Torvalds1da177e2005-04-16 15:20:36 -070056typedef unsigned int reltime_t;
57typedef unsigned int abstime_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59
60/*
61 * synthesizer channel information
62 */
Takashi Iwai080dece2005-11-17 14:05:16 +010063struct seq_oss_chinfo {
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 int note, vel;
65};
66
67/*
68 * synthesizer information
69 */
Takashi Iwai080dece2005-11-17 14:05:16 +010070struct seq_oss_synthinfo {
71 struct snd_seq_oss_arg arg;
72 struct seq_oss_chinfo *ch;
73 struct seq_oss_synth_sysex *sysex;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 int nr_voices;
75 int opened;
76 int is_midi;
77 int midi_mapped;
78};
79
80
81/*
82 * sequencer client information
83 */
84
Takashi Iwai080dece2005-11-17 14:05:16 +010085struct seq_oss_devinfo {
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87 int index; /* application index */
88 int cseq; /* sequencer client number */
89 int port; /* sequencer port number */
90 int queue; /* sequencer queue number */
91
Takashi Iwai080dece2005-11-17 14:05:16 +010092 struct snd_seq_addr addr; /* address of this device */
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94 int seq_mode; /* sequencer mode */
95 int file_mode; /* file access */
96
97 /* midi device table */
98 int max_mididev;
99
100 /* synth device table */
101 int max_synthdev;
Takashi Iwai080dece2005-11-17 14:05:16 +0100102 struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 int synth_opened;
104
105 /* output queue */
Takashi Iwai080dece2005-11-17 14:05:16 +0100106 struct seq_oss_writeq *writeq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108 /* midi input queue */
Takashi Iwai080dece2005-11-17 14:05:16 +0100109 struct seq_oss_readq *readq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111 /* timer */
Takashi Iwai080dece2005-11-17 14:05:16 +0100112 struct seq_oss_timer *timer;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113};
114
115
116/*
117 * function prototypes
118 */
119
120/* create/delete OSS sequencer client */
121int snd_seq_oss_create_client(void);
122int snd_seq_oss_delete_client(void);
123
124/* device file interface */
125int snd_seq_oss_open(struct file *file, int level);
Takashi Iwai080dece2005-11-17 14:05:16 +0100126void snd_seq_oss_release(struct seq_oss_devinfo *dp);
127int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
128int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
129int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
130unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
Takashi Iwai080dece2005-11-17 14:05:16 +0100132void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
133void snd_seq_oss_drain_write(struct seq_oss_devinfo *dp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
135/* */
Takashi Iwai080dece2005-11-17 14:05:16 +0100136void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138
139/* proc interface */
Takashi Iwai080dece2005-11-17 14:05:16 +0100140void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
141void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
142void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
143void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
145/* file mode macros */
146#define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ)
147#define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
148#define is_nonblock_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
149
150/* dispatch event */
Jesper Juhl77933d72005-07-27 11:46:09 -0700151static inline int
Takashi Iwai080dece2005-11-17 14:05:16 +0100152snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153{
154 return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
155}
156
157/* ioctl */
Jesper Juhl77933d72005-07-27 11:46:09 -0700158static inline int
Takashi Iwai080dece2005-11-17 14:05:16 +0100159snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
161 return snd_seq_kernel_client_ctl(dp->cseq, type, arg);
162}
163
164/* fill the addresses in header */
Jesper Juhl77933d72005-07-27 11:46:09 -0700165static inline void
Takashi Iwai080dece2005-11-17 14:05:16 +0100166snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 int dest_client, int dest_port)
168{
169 ev->queue = dp->queue;
170 ev->source = dp->addr;
171 ev->dest.client = dest_client;
172 ev->dest.port = dest_port;
173}
174
175
176/* misc. functions for proc interface */
177char *enabled_str(int bool);
178
179
180/* for debug */
181#ifdef SNDRV_SEQ_OSS_DEBUG
182extern int seq_oss_debug;
Takashi Iwai006de2672009-02-05 15:51:04 +0100183#define debug_printk(x) do { if (seq_oss_debug > 0) snd_printd x; } while (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184#else
185#define debug_printk(x) /**/
186#endif
187
188#endif /* __SEQ_OSS_DEVICE_H */