Merge tag 'pci-v6.16-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci
[linux-block.git] / sound / core / seq / oss / seq_oss_device.h
CommitLineData
1a59d1b8 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4
LT
2/*
3 * OSS compatible sequencer driver
4 *
5 * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>
1da177e4
LT
6 */
7
8#ifndef __SEQ_OSS_DEVICE_H
9#define __SEQ_OSS_DEVICE_H
10
1da177e4
LT
11#include <linux/time.h>
12#include <linux/wait.h>
13#include <linux/slab.h>
174cd4b1 14#include <linux/sched/signal.h>
1da177e4
LT
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>
6b580f52 20#include "../seq_clientmgr.h"
1da177e4 21
1da177e4
LT
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
26
27/* version */
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"
32
33/* device and proc interface name */
1da177e4
LT
34#define SNDRV_SEQ_OSS_PROCNAME "oss"
35
36
37/*
38 * type definitions
39 */
40
1da177e4
LT
41typedef unsigned int reltime_t;
42typedef unsigned int abstime_t;
1da177e4
LT
43
44
45/*
46 * synthesizer channel information
47 */
080dece3 48struct seq_oss_chinfo {
1da177e4
LT
49 int note, vel;
50};
51
52/*
53 * synthesizer information
54 */
080dece3
TI
55struct seq_oss_synthinfo {
56 struct snd_seq_oss_arg arg;
57 struct seq_oss_chinfo *ch;
1da177e4
LT
58 int nr_voices;
59 int opened;
60 int is_midi;
61 int midi_mapped;
62};
63
64
65/*
66 * sequencer client information
67 */
68
080dece3 69struct seq_oss_devinfo {
1da177e4
LT
70
71 int index; /* application index */
72 int cseq; /* sequencer client number */
73 int port; /* sequencer port number */
74 int queue; /* sequencer queue number */
75
080dece3 76 struct snd_seq_addr addr; /* address of this device */
1da177e4
LT
77
78 int seq_mode; /* sequencer mode */
79 int file_mode; /* file access */
80
81 /* midi device table */
82 int max_mididev;
83
84 /* synth device table */
85 int max_synthdev;
080dece3 86 struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
1da177e4
LT
87 int synth_opened;
88
89 /* output queue */
080dece3 90 struct seq_oss_writeq *writeq;
1da177e4
LT
91
92 /* midi input queue */
080dece3 93 struct seq_oss_readq *readq;
1da177e4
LT
94
95 /* timer */
080dece3 96 struct seq_oss_timer *timer;
1da177e4
LT
97};
98
99
100/*
101 * function prototypes
102 */
103
104/* create/delete OSS sequencer client */
105int snd_seq_oss_create_client(void);
106int snd_seq_oss_delete_client(void);
107
108/* device file interface */
109int snd_seq_oss_open(struct file *file, int level);
080dece3
TI
110void snd_seq_oss_release(struct seq_oss_devinfo *dp);
111int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
112int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
113int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
680ef72a 114__poll_t snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
1da177e4 115
080dece3 116void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
1da177e4 117
1da177e4 118/* proc interface */
080dece3
TI
119void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
120void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
121void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
122void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
1da177e4
LT
123
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)
128
129/* dispatch event */
77933d72 130static inline int
080dece3 131snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
1da177e4
LT
132{
133 return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
134}
135
6b580f52 136/* ioctl for writeq */
77933d72 137static inline int
080dece3 138snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
1da177e4 139{
6b580f52
TI
140 int err;
141
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);
145 return err;
1da177e4
LT
146}
147
148/* fill the addresses in header */
77933d72 149static inline void
080dece3 150snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
1da177e4
LT
151 int dest_client, int dest_port)
152{
153 ev->queue = dp->queue;
154 ev->source = dp->addr;
155 ev->dest.client = dest_client;
156 ev->dest.port = dest_port;
157}
158
1da177e4 159#endif /* __SEQ_OSS_DEVICE_H */