Linux Audio

Check our new training course

Loading...
v5.14.15
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2#ifndef __SOUND_EMUX_SYNTH_H
  3#define __SOUND_EMUX_SYNTH_H
  4
  5/*
  6 *  Defines for the Emu-series WaveTable chip
  7 *
  8 *  Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  9 */
 10
 11#include <sound/seq_kernel.h>
 12#include <sound/seq_device.h>
 13#include <sound/soundfont.h>
 14#include <sound/seq_midi_emul.h>
 
 15#include <sound/seq_oss.h>
 
 16#include <sound/emux_legacy.h>
 17#include <sound/seq_virmidi.h>
 18
 19/*
 20 * compile flags
 21 */
 22#define SNDRV_EMUX_USE_RAW_EFFECT
 23
 24struct snd_emux;
 25struct snd_emux_port;
 26struct snd_emux_voice;
 27struct snd_emux_effect_table;
 28
 29/*
 30 * operators
 31 */
 32struct snd_emux_operators {
 33	struct module *owner;
 34	struct snd_emux_voice *(*get_voice)(struct snd_emux *emu,
 35					    struct snd_emux_port *port);
 36	int (*prepare)(struct snd_emux_voice *vp);
 37	void (*trigger)(struct snd_emux_voice *vp);
 38	void (*release)(struct snd_emux_voice *vp);
 39	void (*update)(struct snd_emux_voice *vp, int update);
 40	void (*terminate)(struct snd_emux_voice *vp);
 41	void (*free_voice)(struct snd_emux_voice *vp);
 42	void (*reset)(struct snd_emux *emu, int ch);
 43	/* the first parameters are struct snd_emux */
 44	int (*sample_new)(struct snd_emux *emu, struct snd_sf_sample *sp,
 45			  struct snd_util_memhdr *hdr,
 46			  const void __user *data, long count);
 47	int (*sample_free)(struct snd_emux *emu, struct snd_sf_sample *sp,
 48			   struct snd_util_memhdr *hdr);
 49	void (*sample_reset)(struct snd_emux *emu);
 50	int (*load_fx)(struct snd_emux *emu, int type, int arg,
 51		       const void __user *data, long count);
 52	void (*sysex)(struct snd_emux *emu, char *buf, int len, int parsed,
 53		      struct snd_midi_channel_set *chset);
 54#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
 55	int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2);
 56#endif
 57};
 58
 59
 60/*
 61 * constant values
 62 */
 63#define SNDRV_EMUX_MAX_PORTS		32	/* max # of sequencer ports */
 64#define SNDRV_EMUX_MAX_VOICES		64	/* max # of voices */
 65#define SNDRV_EMUX_MAX_MULTI_VOICES	16	/* max # of playable voices
 66						 * simultineously
 67						 */
 68
 69/*
 70 * flags
 71 */
 72#define SNDRV_EMUX_ACCEPT_ROM		(1<<0)
 73
 74/*
 75 * emuX wavetable
 76 */
 77struct snd_emux {
 78
 79	struct snd_card *card;	/* assigned card */
 80
 81	/* following should be initialized before registration */
 82	int max_voices;		/* Number of voices */
 83	int mem_size;		/* memory size (in byte) */
 84	int num_ports;		/* number of ports to be created */
 85	int pitch_shift;	/* pitch shift value (for Emu10k1) */
 86	struct snd_emux_operators ops;	/* operators */
 87	void *hw;		/* hardware */
 88	unsigned long flags;	/* other conditions */
 89	int midi_ports;		/* number of virtual midi devices */
 90	int midi_devidx;	/* device offset of virtual midi */
 91	unsigned int linear_panning: 1; /* panning is linear (sbawe = 1, emu10k1 = 0) */
 92	int hwdep_idx;		/* hwdep device index */
 93	struct snd_hwdep *hwdep;	/* hwdep device */
 94
 95	/* private */
 96	int num_voices;		/* current number of voices */
 97	struct snd_sf_list *sflist;	/* root of SoundFont list */
 98	struct snd_emux_voice *voices;	/* Voices (EMU 'channel') */
 99	int use_time;	/* allocation counter */
100	spinlock_t voice_lock;	/* Lock for voice access */
101	struct mutex register_mutex;
102	int client;		/* For the sequencer client */
103	int ports[SNDRV_EMUX_MAX_PORTS];	/* The ports for this device */
104	struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS];
105	int used;	/* use counter */
106	char *name;	/* name of the device (internal) */
107	struct snd_rawmidi **vmidi;
108	struct timer_list tlist;	/* for pending note-offs */
109	int timer_active;
110
111	struct snd_util_memhdr *memhdr;	/* memory chunk information */
112
113#ifdef CONFIG_SND_PROC_FS
114	struct snd_info_entry *proc;
115#endif
116
117#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
118	struct snd_seq_device *oss_synth;
119#endif
120};
121
122
123/*
124 * sequencer port information
125 */
126struct snd_emux_port {
127
128	struct snd_midi_channel_set chset;
129	struct snd_emux *emu;
130
131	char port_mode;			/* operation mode */
132	int volume_atten;		/* emuX raw attenuation */
133	unsigned long drum_flags;	/* drum bitmaps */
134	int ctrls[EMUX_MD_END];		/* control parameters */
135#ifdef SNDRV_EMUX_USE_RAW_EFFECT
136	struct snd_emux_effect_table *effect;
137#endif
138#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS)
139	struct snd_seq_oss_arg *oss_arg;
140#endif
141};
142
143/* port_mode */
144#define SNDRV_EMUX_PORT_MODE_MIDI		0	/* normal MIDI port */
145#define SNDRV_EMUX_PORT_MODE_OSS_SYNTH	1	/* OSS synth port */
146#define SNDRV_EMUX_PORT_MODE_OSS_MIDI	2	/* OSS multi channel synth port */
147
148/*
149 * A structure to keep track of each hardware voice
150 */
151struct snd_emux_voice {
152	int  ch;		/* Hardware channel number */
153
154	int  state;		/* status */
155#define SNDRV_EMUX_ST_OFF		0x00	/* Not playing, and inactive */
156#define SNDRV_EMUX_ST_ON		0x01	/* Note on */
157#define SNDRV_EMUX_ST_RELEASED 	(0x02|SNDRV_EMUX_ST_ON)	/* Note released */
158#define SNDRV_EMUX_ST_SUSTAINED	(0x04|SNDRV_EMUX_ST_ON)	/* Note sustained */
159#define SNDRV_EMUX_ST_STANDBY	(0x08|SNDRV_EMUX_ST_ON)	/* Waiting to be triggered */
160#define SNDRV_EMUX_ST_PENDING 	(0x10|SNDRV_EMUX_ST_ON)	/* Note will be released */
161#define SNDRV_EMUX_ST_LOCKED		0x100	/* Not accessible */
162
163	unsigned int  time;	/* An allocation time */
164	unsigned char note;	/* Note currently assigned to this voice */
165	unsigned char key;
166	unsigned char velocity;	/* Velocity of current note */
167
168	struct snd_sf_zone *zone;	/* Zone assigned to this note */
169	void *block;		/* sample block pointer (optional) */
170	struct snd_midi_channel *chan;	/* Midi channel for this note */
171	struct snd_emux_port *port;	/* associated port */
172	struct snd_emux *emu;	/* assigned root info */
173	void *hw;		/* hardware pointer (emu8000 or emu10k1) */
174	unsigned long ontime;	/* jiffies at note triggered */
175	
176	/* Emu8k/Emu10k1 registers */
177	struct soundfont_voice_info reg;
178
179	/* additional registers */
180	int avol;		/* volume attenuation */
181	int acutoff;		/* cutoff target */
182	int apitch;		/* pitch offset */
183	int apan;		/* pan/aux pair */
184	int aaux;
185	int ptarget;		/* pitch target */
186	int vtarget;		/* volume target */
187	int ftarget;		/* filter target */
188
189};
190
191/*
192 * update flags (can be combined)
193 */
194#define SNDRV_EMUX_UPDATE_VOLUME		(1<<0)
195#define SNDRV_EMUX_UPDATE_PITCH		(1<<1)
196#define SNDRV_EMUX_UPDATE_PAN		(1<<2)
197#define SNDRV_EMUX_UPDATE_FMMOD		(1<<3)
198#define SNDRV_EMUX_UPDATE_TREMFREQ	(1<<4)
199#define SNDRV_EMUX_UPDATE_FM2FRQ2		(1<<5)
200#define SNDRV_EMUX_UPDATE_Q		(1<<6)
201
202
203#ifdef SNDRV_EMUX_USE_RAW_EFFECT
204/*
205 * effect table
206 */
207struct snd_emux_effect_table {
208	/* Emu8000 specific effects */
209	short val[EMUX_NUM_EFFECTS];
210	unsigned char flag[EMUX_NUM_EFFECTS];
211};
212#endif /* SNDRV_EMUX_USE_RAW_EFFECT */
213
214
215/*
216 * prototypes - interface to Emu10k1 and Emu8k routines
217 */
218int snd_emux_new(struct snd_emux **remu);
219int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name);
220int snd_emux_free(struct snd_emux *emu);
221
222/*
223 * exported functions
224 */
225void snd_emux_terminate_all(struct snd_emux *emu);
226void snd_emux_lock_voice(struct snd_emux *emu, int voice);
227void snd_emux_unlock_voice(struct snd_emux *emu, int voice);
228
229#endif /* __SOUND_EMUX_SYNTH_H */
v4.6
 
  1#ifndef __SOUND_EMUX_SYNTH_H
  2#define __SOUND_EMUX_SYNTH_H
  3
  4/*
  5 *  Defines for the Emu-series WaveTable chip
  6 *
  7 *  Copyright (C) 2000 Takashi Iwai <tiwai@suse.de>
  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#include <sound/seq_kernel.h>
 25#include <sound/seq_device.h>
 26#include <sound/soundfont.h>
 27#include <sound/seq_midi_emul.h>
 28#ifdef CONFIG_SND_SEQUENCER_OSS
 29#include <sound/seq_oss.h>
 30#endif
 31#include <sound/emux_legacy.h>
 32#include <sound/seq_virmidi.h>
 33
 34/*
 35 * compile flags
 36 */
 37#define SNDRV_EMUX_USE_RAW_EFFECT
 38
 39struct snd_emux;
 40struct snd_emux_port;
 41struct snd_emux_voice;
 42struct snd_emux_effect_table;
 43
 44/*
 45 * operators
 46 */
 47struct snd_emux_operators {
 48	struct module *owner;
 49	struct snd_emux_voice *(*get_voice)(struct snd_emux *emu,
 50					    struct snd_emux_port *port);
 51	int (*prepare)(struct snd_emux_voice *vp);
 52	void (*trigger)(struct snd_emux_voice *vp);
 53	void (*release)(struct snd_emux_voice *vp);
 54	void (*update)(struct snd_emux_voice *vp, int update);
 55	void (*terminate)(struct snd_emux_voice *vp);
 56	void (*free_voice)(struct snd_emux_voice *vp);
 57	void (*reset)(struct snd_emux *emu, int ch);
 58	/* the first parameters are struct snd_emux */
 59	int (*sample_new)(struct snd_emux *emu, struct snd_sf_sample *sp,
 60			  struct snd_util_memhdr *hdr,
 61			  const void __user *data, long count);
 62	int (*sample_free)(struct snd_emux *emu, struct snd_sf_sample *sp,
 63			   struct snd_util_memhdr *hdr);
 64	void (*sample_reset)(struct snd_emux *emu);
 65	int (*load_fx)(struct snd_emux *emu, int type, int arg,
 66		       const void __user *data, long count);
 67	void (*sysex)(struct snd_emux *emu, char *buf, int len, int parsed,
 68		      struct snd_midi_channel_set *chset);
 69#ifdef CONFIG_SND_SEQUENCER_OSS
 70	int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2);
 71#endif
 72};
 73
 74
 75/*
 76 * constant values
 77 */
 78#define SNDRV_EMUX_MAX_PORTS		32	/* max # of sequencer ports */
 79#define SNDRV_EMUX_MAX_VOICES		64	/* max # of voices */
 80#define SNDRV_EMUX_MAX_MULTI_VOICES	16	/* max # of playable voices
 81						 * simultineously
 82						 */
 83
 84/*
 85 * flags
 86 */
 87#define SNDRV_EMUX_ACCEPT_ROM		(1<<0)
 88
 89/*
 90 * emuX wavetable
 91 */
 92struct snd_emux {
 93
 94	struct snd_card *card;	/* assigned card */
 95
 96	/* following should be initialized before registration */
 97	int max_voices;		/* Number of voices */
 98	int mem_size;		/* memory size (in byte) */
 99	int num_ports;		/* number of ports to be created */
100	int pitch_shift;	/* pitch shift value (for Emu10k1) */
101	struct snd_emux_operators ops;	/* operators */
102	void *hw;		/* hardware */
103	unsigned long flags;	/* other conditions */
104	int midi_ports;		/* number of virtual midi devices */
105	int midi_devidx;	/* device offset of virtual midi */
106	unsigned int linear_panning: 1; /* panning is linear (sbawe = 1, emu10k1 = 0) */
107	int hwdep_idx;		/* hwdep device index */
108	struct snd_hwdep *hwdep;	/* hwdep device */
109
110	/* private */
111	int num_voices;		/* current number of voices */
112	struct snd_sf_list *sflist;	/* root of SoundFont list */
113	struct snd_emux_voice *voices;	/* Voices (EMU 'channel') */
114	int use_time;	/* allocation counter */
115	spinlock_t voice_lock;	/* Lock for voice access */
116	struct mutex register_mutex;
117	int client;		/* For the sequencer client */
118	int ports[SNDRV_EMUX_MAX_PORTS];	/* The ports for this device */
119	struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS];
120	int used;	/* use counter */
121	char *name;	/* name of the device (internal) */
122	struct snd_rawmidi **vmidi;
123	struct timer_list tlist;	/* for pending note-offs */
124	int timer_active;
125
126	struct snd_util_memhdr *memhdr;	/* memory chunk information */
127
128#ifdef CONFIG_SND_PROC_FS
129	struct snd_info_entry *proc;
130#endif
131
132#ifdef CONFIG_SND_SEQUENCER_OSS
133	struct snd_seq_device *oss_synth;
134#endif
135};
136
137
138/*
139 * sequencer port information
140 */
141struct snd_emux_port {
142
143	struct snd_midi_channel_set chset;
144	struct snd_emux *emu;
145
146	char port_mode;			/* operation mode */
147	int volume_atten;		/* emuX raw attenuation */
148	unsigned long drum_flags;	/* drum bitmaps */
149	int ctrls[EMUX_MD_END];		/* control parameters */
150#ifdef SNDRV_EMUX_USE_RAW_EFFECT
151	struct snd_emux_effect_table *effect;
152#endif
153#ifdef CONFIG_SND_SEQUENCER_OSS
154	struct snd_seq_oss_arg *oss_arg;
155#endif
156};
157
158/* port_mode */
159#define SNDRV_EMUX_PORT_MODE_MIDI		0	/* normal MIDI port */
160#define SNDRV_EMUX_PORT_MODE_OSS_SYNTH	1	/* OSS synth port */
161#define SNDRV_EMUX_PORT_MODE_OSS_MIDI	2	/* OSS multi channel synth port */
162
163/*
164 * A structure to keep track of each hardware voice
165 */
166struct snd_emux_voice {
167	int  ch;		/* Hardware channel number */
168
169	int  state;		/* status */
170#define SNDRV_EMUX_ST_OFF		0x00	/* Not playing, and inactive */
171#define SNDRV_EMUX_ST_ON		0x01	/* Note on */
172#define SNDRV_EMUX_ST_RELEASED 	(0x02|SNDRV_EMUX_ST_ON)	/* Note released */
173#define SNDRV_EMUX_ST_SUSTAINED	(0x04|SNDRV_EMUX_ST_ON)	/* Note sustained */
174#define SNDRV_EMUX_ST_STANDBY	(0x08|SNDRV_EMUX_ST_ON)	/* Waiting to be triggered */
175#define SNDRV_EMUX_ST_PENDING 	(0x10|SNDRV_EMUX_ST_ON)	/* Note will be released */
176#define SNDRV_EMUX_ST_LOCKED		0x100	/* Not accessible */
177
178	unsigned int  time;	/* An allocation time */
179	unsigned char note;	/* Note currently assigned to this voice */
180	unsigned char key;
181	unsigned char velocity;	/* Velocity of current note */
182
183	struct snd_sf_zone *zone;	/* Zone assigned to this note */
184	void *block;		/* sample block pointer (optional) */
185	struct snd_midi_channel *chan;	/* Midi channel for this note */
186	struct snd_emux_port *port;	/* associated port */
187	struct snd_emux *emu;	/* assigned root info */
188	void *hw;		/* hardware pointer (emu8000 or emu10k1) */
189	unsigned long ontime;	/* jiffies at note triggered */
190	
191	/* Emu8k/Emu10k1 registers */
192	struct soundfont_voice_info reg;
193
194	/* additional registers */
195	int avol;		/* volume attenuation */
196	int acutoff;		/* cutoff target */
197	int apitch;		/* pitch offset */
198	int apan;		/* pan/aux pair */
199	int aaux;
200	int ptarget;		/* pitch target */
201	int vtarget;		/* volume target */
202	int ftarget;		/* filter target */
203
204};
205
206/*
207 * update flags (can be combined)
208 */
209#define SNDRV_EMUX_UPDATE_VOLUME		(1<<0)
210#define SNDRV_EMUX_UPDATE_PITCH		(1<<1)
211#define SNDRV_EMUX_UPDATE_PAN		(1<<2)
212#define SNDRV_EMUX_UPDATE_FMMOD		(1<<3)
213#define SNDRV_EMUX_UPDATE_TREMFREQ	(1<<4)
214#define SNDRV_EMUX_UPDATE_FM2FRQ2		(1<<5)
215#define SNDRV_EMUX_UPDATE_Q		(1<<6)
216
217
218#ifdef SNDRV_EMUX_USE_RAW_EFFECT
219/*
220 * effect table
221 */
222struct snd_emux_effect_table {
223	/* Emu8000 specific effects */
224	short val[EMUX_NUM_EFFECTS];
225	unsigned char flag[EMUX_NUM_EFFECTS];
226};
227#endif /* SNDRV_EMUX_USE_RAW_EFFECT */
228
229
230/*
231 * prototypes - interface to Emu10k1 and Emu8k routines
232 */
233int snd_emux_new(struct snd_emux **remu);
234int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name);
235int snd_emux_free(struct snd_emux *emu);
236
237/*
238 * exported functions
239 */
240void snd_emux_terminate_all(struct snd_emux *emu);
241void snd_emux_lock_voice(struct snd_emux *emu, int voice);
242void snd_emux_unlock_voice(struct snd_emux *emu, int voice);
243
244#endif /* __SOUND_EMUX_SYNTH_H */