brintos

brintos / linux-shallow public Read only

0
0
Text · 6.8 KiB · a16b467 Raw
236 lines · c
1/*2 * Local definitions for the OPL4 driver3 *4 * Copyright (c) 2003 by Clemens Ladisch <clemens@ladisch.de>5 * All rights reserved.6 *7 * Redistribution and use in source and binary forms, with or without8 * modification, are permitted provided that the following conditions9 * are met:10 * 1. Redistributions of source code must retain the above copyright11 *    notice, this list of conditions, and the following disclaimer,12 *    without modification.13 * 2. The name of the author may not be used to endorse or promote products14 *    derived from this software without specific prior written permission.15 *16 * Alternatively, this software may be distributed and/or modified under the17 * terms of the GNU General Public License as published by the Free Software18 * Foundation; either version 2 of the License, or (at your option) any later19 * version.20 *21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF31 * SUCH DAMAGE.32 */33 34#ifndef __OPL4_LOCAL_H35#define __OPL4_LOCAL_H36 37#include <sound/opl4.h>38 39/*40 * Register numbers41 */42 43#define OPL4_REG_TEST0			0x0044#define OPL4_REG_TEST1			0x0145 46#define OPL4_REG_MEMORY_CONFIGURATION	0x0247#define   OPL4_MODE_BIT			0x0148#define   OPL4_MTYPE_BIT		0x0249#define   OPL4_TONE_HEADER_MASK		0x1c50#define   OPL4_DEVICE_ID_MASK		0xe051 52#define OPL4_REG_MEMORY_ADDRESS_HIGH	0x0353#define OPL4_REG_MEMORY_ADDRESS_MID	0x0454#define OPL4_REG_MEMORY_ADDRESS_LOW	0x0555#define OPL4_REG_MEMORY_DATA		0x0656 57/*58 * Offsets to the register banks for voices. To get the59 * register number just add the voice number to the bank offset.60 *61 * Wave Table Number low bits (0x08 to 0x1F)62 */63#define OPL4_REG_TONE_NUMBER		0x0864 65/* Wave Table Number high bit, F-Number low bits (0x20 to 0x37) */66#define OPL4_REG_F_NUMBER		0x2067#define   OPL4_TONE_NUMBER_BIT8		0x0168#define   OPL4_F_NUMBER_LOW_MASK	0xfe69 70/* F-Number high bits, Octave, Pseudo-Reverb (0x38 to 0x4F) */71#define OPL4_REG_OCTAVE			0x3872#define   OPL4_F_NUMBER_HIGH_MASK	0x0773#define   OPL4_BLOCK_MASK		0xf074#define   OPL4_PSEUDO_REVERB_BIT	0x0875 76/* Total Level, Level Direct (0x50 to 0x67) */77#define OPL4_REG_LEVEL			0x5078#define   OPL4_TOTAL_LEVEL_MASK		0xfe79#define   OPL4_LEVEL_DIRECT_BIT		0x0180 81/* Key On, Damp, LFO RST, CH, Panpot (0x68 to 0x7F) */82#define OPL4_REG_MISC			0x6883#define   OPL4_KEY_ON_BIT		0x8084#define   OPL4_DAMP_BIT			0x4085#define   OPL4_LFO_RESET_BIT		0x2086#define   OPL4_OUTPUT_CHANNEL_BIT	0x1087#define   OPL4_PAN_POT_MASK		0x0f88 89/* LFO, VIB (0x80 to 0x97) */90#define OPL4_REG_LFO_VIBRATO		0x8091#define   OPL4_LFO_FREQUENCY_MASK	0x3892#define   OPL4_VIBRATO_DEPTH_MASK	0x0793#define   OPL4_CHORUS_SEND_MASK		0xc0 /* ML only */94 95/* Attack / Decay 1 rate (0x98 to 0xAF) */96#define OPL4_REG_ATTACK_DECAY1		0x9897#define   OPL4_ATTACK_RATE_MASK		0xf098#define   OPL4_DECAY1_RATE_MASK		0x0f99 100/* Decay level / 2 rate (0xB0 to 0xC7) */101#define OPL4_REG_LEVEL_DECAY2		0xb0102#define   OPL4_DECAY_LEVEL_MASK		0xf0103#define   OPL4_DECAY2_RATE_MASK		0x0f104 105/* Release rate / Rate correction (0xC8 to 0xDF) */106#define OPL4_REG_RELEASE_CORRECTION	0xc8107#define   OPL4_RELEASE_RATE_MASK	0x0f108#define   OPL4_RATE_INTERPOLATION_MASK	0xf0109 110/* AM (0xE0 to 0xF7) */111#define OPL4_REG_TREMOLO		0xe0112#define   OPL4_TREMOLO_DEPTH_MASK	0x07113#define   OPL4_REVERB_SEND_MASK		0xe0 /* ML only */114 115/* Mixer */116#define OPL4_REG_MIX_CONTROL_FM		0xf8117#define OPL4_REG_MIX_CONTROL_PCM	0xf9118#define   OPL4_MIX_LEFT_MASK		0x07119#define   OPL4_MIX_RIGHT_MASK		0x38120 121#define OPL4_REG_ATC			0xfa122#define   OPL4_ATC_BIT			0x01 /* ???, ML only */123 124/* bits in the OPL3 Status register */125#define OPL4_STATUS_BUSY		0x01126#define OPL4_STATUS_LOAD		0x02127 128 129#define OPL4_MAX_VOICES 24130 131#define SNDRV_SEQ_DEV_ID_OPL4 "opl4-synth"132 133 134struct opl4_sound {135	u16 tone;136	s16 pitch_offset;137	u8 key_scaling;138	s8 panpot;139	u8 vibrato;140	u8 tone_attenuate;141	u8 volume_factor;142	u8 reg_lfo_vibrato;143	u8 reg_attack_decay1;144	u8 reg_level_decay2;145	u8 reg_release_correction;146	u8 reg_tremolo;147};148 149struct opl4_region {150	u8 key_min, key_max;151	struct opl4_sound sound;152};153 154struct opl4_region_ptr {155	int count;156	const struct opl4_region *regions;157};158 159struct opl4_voice {160	struct list_head list;161	int number;162	struct snd_midi_channel *chan;163	int note;164	int velocity;165	const struct opl4_sound *sound;166	u8 level_direct;167	u8 reg_f_number;168	u8 reg_misc;169	u8 reg_lfo_vibrato;170};171 172struct snd_opl4 {173	unsigned long fm_port;174	unsigned long pcm_port;175	struct resource *res_fm_port;176	struct resource *res_pcm_port;177	unsigned short hardware;178	spinlock_t reg_lock;179	struct snd_card *card;180 181#ifdef CONFIG_SND_PROC_FS182	struct snd_info_entry *proc_entry;183	int memory_access;184#endif185	struct mutex access_mutex;186 187#if IS_ENABLED(CONFIG_SND_SEQUENCER)188	int used;189 190	int seq_dev_num;191	int seq_client;192	struct snd_seq_device *seq_dev;193 194	struct snd_midi_channel_set *chset;195	struct opl4_voice voices[OPL4_MAX_VOICES];196	struct list_head off_voices;197	struct list_head on_voices;198#endif199};200 201/* opl4_lib.c */202void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value);203u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg);204void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size);205void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size);206 207/* opl4_mixer.c */208int snd_opl4_create_mixer(struct snd_opl4 *opl4);209 210#ifdef CONFIG_SND_PROC_FS211/* opl4_proc.c */212int snd_opl4_create_proc(struct snd_opl4 *opl4);213void snd_opl4_free_proc(struct snd_opl4 *opl4);214#else215static inline int snd_opl4_create_proc(struct snd_opl4 *opl4) { return 0; }216static inline void snd_opl4_free_proc(struct snd_opl4 *opl4) {}217#endif218 219/* opl4_seq.c */220extern int volume_boost;221 222/* opl4_synth.c */223void snd_opl4_synth_reset(struct snd_opl4 *opl4);224void snd_opl4_synth_shutdown(struct snd_opl4 *opl4);225void snd_opl4_note_on(void *p, int note, int vel, struct snd_midi_channel *chan);226void snd_opl4_note_off(void *p, int note, int vel, struct snd_midi_channel *chan);227void snd_opl4_terminate_note(void *p, int note, struct snd_midi_channel *chan);228void snd_opl4_control(void *p, int type, struct snd_midi_channel *chan);229void snd_opl4_sysex(void *p, unsigned char *buf, int len, int parsed, struct snd_midi_channel_set *chset);230 231/* yrw801.c */232int snd_yrw801_detect(struct snd_opl4 *opl4);233extern const struct opl4_region_ptr snd_yrw801_regions[];234 235#endif /* __OPL4_LOCAL_H */236