0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef __OPL4_LOCAL_H
0035 #define __OPL4_LOCAL_H
0036
0037 #include <sound/opl4.h>
0038
0039
0040
0041
0042
0043 #define OPL4_REG_TEST0 0x00
0044 #define OPL4_REG_TEST1 0x01
0045
0046 #define OPL4_REG_MEMORY_CONFIGURATION 0x02
0047 #define OPL4_MODE_BIT 0x01
0048 #define OPL4_MTYPE_BIT 0x02
0049 #define OPL4_TONE_HEADER_MASK 0x1c
0050 #define OPL4_DEVICE_ID_MASK 0xe0
0051
0052 #define OPL4_REG_MEMORY_ADDRESS_HIGH 0x03
0053 #define OPL4_REG_MEMORY_ADDRESS_MID 0x04
0054 #define OPL4_REG_MEMORY_ADDRESS_LOW 0x05
0055 #define OPL4_REG_MEMORY_DATA 0x06
0056
0057
0058
0059
0060
0061
0062
0063 #define OPL4_REG_TONE_NUMBER 0x08
0064
0065
0066 #define OPL4_REG_F_NUMBER 0x20
0067 #define OPL4_TONE_NUMBER_BIT8 0x01
0068 #define OPL4_F_NUMBER_LOW_MASK 0xfe
0069
0070
0071 #define OPL4_REG_OCTAVE 0x38
0072 #define OPL4_F_NUMBER_HIGH_MASK 0x07
0073 #define OPL4_BLOCK_MASK 0xf0
0074 #define OPL4_PSEUDO_REVERB_BIT 0x08
0075
0076
0077 #define OPL4_REG_LEVEL 0x50
0078 #define OPL4_TOTAL_LEVEL_MASK 0xfe
0079 #define OPL4_LEVEL_DIRECT_BIT 0x01
0080
0081
0082 #define OPL4_REG_MISC 0x68
0083 #define OPL4_KEY_ON_BIT 0x80
0084 #define OPL4_DAMP_BIT 0x40
0085 #define OPL4_LFO_RESET_BIT 0x20
0086 #define OPL4_OUTPUT_CHANNEL_BIT 0x10
0087 #define OPL4_PAN_POT_MASK 0x0f
0088
0089
0090 #define OPL4_REG_LFO_VIBRATO 0x80
0091 #define OPL4_LFO_FREQUENCY_MASK 0x38
0092 #define OPL4_VIBRATO_DEPTH_MASK 0x07
0093 #define OPL4_CHORUS_SEND_MASK 0xc0
0094
0095
0096 #define OPL4_REG_ATTACK_DECAY1 0x98
0097 #define OPL4_ATTACK_RATE_MASK 0xf0
0098 #define OPL4_DECAY1_RATE_MASK 0x0f
0099
0100
0101 #define OPL4_REG_LEVEL_DECAY2 0xb0
0102 #define OPL4_DECAY_LEVEL_MASK 0xf0
0103 #define OPL4_DECAY2_RATE_MASK 0x0f
0104
0105
0106 #define OPL4_REG_RELEASE_CORRECTION 0xc8
0107 #define OPL4_RELEASE_RATE_MASK 0x0f
0108 #define OPL4_RATE_INTERPOLATION_MASK 0xf0
0109
0110
0111 #define OPL4_REG_TREMOLO 0xe0
0112 #define OPL4_TREMOLO_DEPTH_MASK 0x07
0113 #define OPL4_REVERB_SEND_MASK 0xe0
0114
0115
0116 #define OPL4_REG_MIX_CONTROL_FM 0xf8
0117 #define OPL4_REG_MIX_CONTROL_PCM 0xf9
0118 #define OPL4_MIX_LEFT_MASK 0x07
0119 #define OPL4_MIX_RIGHT_MASK 0x38
0120
0121 #define OPL4_REG_ATC 0xfa
0122 #define OPL4_ATC_BIT 0x01
0123
0124
0125 #define OPL4_STATUS_BUSY 0x01
0126 #define OPL4_STATUS_LOAD 0x02
0127
0128
0129 #define OPL4_MAX_VOICES 24
0130
0131 #define SNDRV_SEQ_DEV_ID_OPL4 "opl4-synth"
0132
0133
0134 struct opl4_sound {
0135 u16 tone;
0136 s16 pitch_offset;
0137 u8 key_scaling;
0138 s8 panpot;
0139 u8 vibrato;
0140 u8 tone_attenuate;
0141 u8 volume_factor;
0142 u8 reg_lfo_vibrato;
0143 u8 reg_attack_decay1;
0144 u8 reg_level_decay2;
0145 u8 reg_release_correction;
0146 u8 reg_tremolo;
0147 };
0148
0149 struct opl4_region {
0150 u8 key_min, key_max;
0151 struct opl4_sound sound;
0152 };
0153
0154 struct opl4_region_ptr {
0155 int count;
0156 const struct opl4_region *regions;
0157 };
0158
0159 struct opl4_voice {
0160 struct list_head list;
0161 int number;
0162 struct snd_midi_channel *chan;
0163 int note;
0164 int velocity;
0165 const struct opl4_sound *sound;
0166 u8 level_direct;
0167 u8 reg_f_number;
0168 u8 reg_misc;
0169 u8 reg_lfo_vibrato;
0170 };
0171
0172 struct snd_opl4 {
0173 unsigned long fm_port;
0174 unsigned long pcm_port;
0175 struct resource *res_fm_port;
0176 struct resource *res_pcm_port;
0177 unsigned short hardware;
0178 spinlock_t reg_lock;
0179 struct snd_card *card;
0180
0181 #ifdef CONFIG_SND_PROC_FS
0182 struct snd_info_entry *proc_entry;
0183 int memory_access;
0184 #endif
0185 struct mutex access_mutex;
0186
0187 #if IS_ENABLED(CONFIG_SND_SEQUENCER)
0188 int used;
0189
0190 int seq_dev_num;
0191 int seq_client;
0192 struct snd_seq_device *seq_dev;
0193
0194 struct snd_midi_channel_set *chset;
0195 struct opl4_voice voices[OPL4_MAX_VOICES];
0196 struct list_head off_voices;
0197 struct list_head on_voices;
0198 #endif
0199 };
0200
0201
0202 void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value);
0203 u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg);
0204 void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size);
0205 void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size);
0206
0207
0208 int snd_opl4_create_mixer(struct snd_opl4 *opl4);
0209
0210 #ifdef CONFIG_SND_PROC_FS
0211
0212 int snd_opl4_create_proc(struct snd_opl4 *opl4);
0213 void snd_opl4_free_proc(struct snd_opl4 *opl4);
0214 #else
0215 static inline int snd_opl4_create_proc(struct snd_opl4 *opl4) { return 0; }
0216 static inline void snd_opl4_free_proc(struct snd_opl4 *opl4) {}
0217 #endif
0218
0219
0220 extern int volume_boost;
0221
0222
0223 void snd_opl4_synth_reset(struct snd_opl4 *opl4);
0224 void snd_opl4_synth_shutdown(struct snd_opl4 *opl4);
0225 void snd_opl4_note_on(void *p, int note, int vel, struct snd_midi_channel *chan);
0226 void snd_opl4_note_off(void *p, int note, int vel, struct snd_midi_channel *chan);
0227 void snd_opl4_terminate_note(void *p, int note, struct snd_midi_channel *chan);
0228 void snd_opl4_control(void *p, int type, struct snd_midi_channel *chan);
0229 void snd_opl4_sysex(void *p, unsigned char *buf, int len, int parsed, struct snd_midi_channel_set *chset);
0230
0231
0232 int snd_yrw801_detect(struct snd_opl4 *opl4);
0233 extern const struct opl4_region_ptr snd_yrw801_regions[];
0234
0235 #endif