1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * OSS compatible sequencer driver
5 * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>
8 #ifndef __SEQ_OSS_DEVICE_H
9 #define __SEQ_OSS_DEVICE_H
11 #include <linux/time.h>
12 #include <linux/wait.h>
13 #include <linux/slab.h>
14 #include <linux/sched/signal.h>
15 #include <sound/core.h>
16 #include <sound/seq_oss.h>
17 #include <sound/rawmidi.h>
18 #include <sound/seq_kernel.h>
19 #include <sound/info.h>
20 #include "../seq_clientmgr.h"
22 /* max. applications */
23 #define SNDRV_SEQ_OSS_MAX_CLIENTS 16
24 #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS 16
25 #define SNDRV_SEQ_OSS_MAX_MIDI_DEVS 32
28 #define SNDRV_SEQ_OSS_MAJOR_VERSION 0
29 #define SNDRV_SEQ_OSS_MINOR_VERSION 1
30 #define SNDRV_SEQ_OSS_TINY_VERSION 8
31 #define SNDRV_SEQ_OSS_VERSION_STR "0.1.8"
33 /* device and proc interface name */
34 #define SNDRV_SEQ_OSS_PROCNAME "oss"
41 typedef unsigned int reltime_t;
42 typedef unsigned int abstime_t;
46 * synthesizer channel information
48 struct seq_oss_chinfo {
53 * synthesizer information
55 struct seq_oss_synthinfo {
56 struct snd_seq_oss_arg arg;
57 struct seq_oss_chinfo *ch;
66 * sequencer client information
69 struct seq_oss_devinfo {
71 int index; /* application index */
72 int cseq; /* sequencer client number */
73 int port; /* sequencer port number */
74 int queue; /* sequencer queue number */
76 struct snd_seq_addr addr; /* address of this device */
78 int seq_mode; /* sequencer mode */
79 int file_mode; /* file access */
81 /* midi device table */
84 /* synth device table */
86 struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
90 struct seq_oss_writeq *writeq;
92 /* midi input queue */
93 struct seq_oss_readq *readq;
96 struct seq_oss_timer *timer;
101 * function prototypes
104 /* create/delete OSS sequencer client */
105 int snd_seq_oss_create_client(void);
106 int snd_seq_oss_delete_client(void);
108 /* device file interface */
109 int snd_seq_oss_open(struct file *file, int level);
110 void snd_seq_oss_release(struct seq_oss_devinfo *dp);
111 int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
112 int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
113 int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
114 __poll_t snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
116 void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
119 void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
120 void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
121 void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
122 void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
124 /* file mode macros */
125 #define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ)
126 #define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
127 #define is_nonblock_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
131 snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
133 return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
136 /* ioctl for writeq */
138 snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
142 snd_seq_client_ioctl_lock(dp->cseq);
143 err = snd_seq_kernel_client_ctl(dp->cseq, type, arg);
144 snd_seq_client_ioctl_unlock(dp->cseq);
148 /* fill the addresses in header */
150 snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
151 int dest_client, int dest_port)
153 ev->queue = dp->queue;
154 ev->source = dp->addr;
155 ev->dest.client = dest_client;
156 ev->dest.port = dest_port;
159 #endif /* __SEQ_OSS_DEVICE_H */