Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * OSS compatible sequencer driver
0004  *
0005  * Copyright (C) 1998,99 Takashi Iwai <tiwai@suse.de>
0006  */
0007 
0008 #ifndef __SEQ_OSS_DEVICE_H
0009 #define __SEQ_OSS_DEVICE_H
0010 
0011 #include <linux/time.h>
0012 #include <linux/wait.h>
0013 #include <linux/slab.h>
0014 #include <linux/sched/signal.h>
0015 #include <sound/core.h>
0016 #include <sound/seq_oss.h>
0017 #include <sound/rawmidi.h>
0018 #include <sound/seq_kernel.h>
0019 #include <sound/info.h>
0020 #include "../seq_clientmgr.h"
0021 
0022 /* max. applications */
0023 #define SNDRV_SEQ_OSS_MAX_CLIENTS   16
0024 #define SNDRV_SEQ_OSS_MAX_SYNTH_DEVS    16
0025 #define SNDRV_SEQ_OSS_MAX_MIDI_DEVS 32
0026 
0027 /* version */
0028 #define SNDRV_SEQ_OSS_MAJOR_VERSION 0
0029 #define SNDRV_SEQ_OSS_MINOR_VERSION 1
0030 #define SNDRV_SEQ_OSS_TINY_VERSION  8
0031 #define SNDRV_SEQ_OSS_VERSION_STR   "0.1.8"
0032 
0033 /* device and proc interface name */
0034 #define SNDRV_SEQ_OSS_PROCNAME      "oss"
0035 
0036 
0037 /*
0038  * type definitions
0039  */
0040 
0041 typedef unsigned int reltime_t;
0042 typedef unsigned int abstime_t;
0043 
0044 
0045 /*
0046  * synthesizer channel information
0047  */
0048 struct seq_oss_chinfo {
0049     int note, vel;
0050 };
0051 
0052 /*
0053  * synthesizer information
0054  */
0055 struct seq_oss_synthinfo {
0056     struct snd_seq_oss_arg arg;
0057     struct seq_oss_chinfo *ch;
0058     struct seq_oss_synth_sysex *sysex;
0059     int nr_voices;
0060     int opened;
0061     int is_midi;
0062     int midi_mapped;
0063 };
0064 
0065 
0066 /*
0067  * sequencer client information
0068  */
0069 
0070 struct seq_oss_devinfo {
0071 
0072     int index;  /* application index */
0073     int cseq;   /* sequencer client number */
0074     int port;   /* sequencer port number */
0075     int queue;  /* sequencer queue number */
0076 
0077     struct snd_seq_addr addr;   /* address of this device */
0078 
0079     int seq_mode;   /* sequencer mode */
0080     int file_mode;  /* file access */
0081 
0082     /* midi device table */
0083     int max_mididev;
0084 
0085     /* synth device table */
0086     int max_synthdev;
0087     struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS];
0088     int synth_opened;
0089 
0090     /* output queue */
0091     struct seq_oss_writeq *writeq;
0092 
0093     /* midi input queue */
0094     struct seq_oss_readq *readq;
0095 
0096     /* timer */
0097     struct seq_oss_timer *timer;
0098 };
0099 
0100 
0101 /*
0102  * function prototypes
0103  */
0104 
0105 /* create/delete OSS sequencer client */
0106 int snd_seq_oss_create_client(void);
0107 int snd_seq_oss_delete_client(void);
0108 
0109 /* device file interface */
0110 int snd_seq_oss_open(struct file *file, int level);
0111 void snd_seq_oss_release(struct seq_oss_devinfo *dp);
0112 int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg);
0113 int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count);
0114 int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt);
0115 __poll_t snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
0116 
0117 void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
0118 
0119 /* */
0120 void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);
0121 
0122 
0123 /* proc interface */
0124 void snd_seq_oss_system_info_read(struct snd_info_buffer *buf);
0125 void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf);
0126 void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf);
0127 void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf);
0128 
0129 /* file mode macros */
0130 #define is_read_mode(mode)  ((mode) & SNDRV_SEQ_OSS_FILE_READ)
0131 #define is_write_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_WRITE)
0132 #define is_nonblock_mode(mode)  ((mode) & SNDRV_SEQ_OSS_FILE_NONBLOCK)
0133 
0134 /* dispatch event */
0135 static inline int
0136 snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop)
0137 {
0138     return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
0139 }
0140 
0141 /* ioctl for writeq */
0142 static inline int
0143 snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
0144 {
0145     int err;
0146 
0147     snd_seq_client_ioctl_lock(dp->cseq);
0148     err = snd_seq_kernel_client_ctl(dp->cseq, type, arg);
0149     snd_seq_client_ioctl_unlock(dp->cseq);
0150     return err;
0151 }
0152 
0153 /* fill the addresses in header */
0154 static inline void
0155 snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev,
0156              int dest_client, int dest_port)
0157 {
0158     ev->queue = dp->queue;
0159     ev->source = dp->addr;
0160     ev->dest.client = dest_client;
0161     ev->dest.port = dest_port;
0162 }
0163 
0164 
0165 /* misc. functions for proc interface */
0166 char *enabled_str(int bool);
0167 
0168 #endif /* __SEQ_OSS_DEVICE_H */