18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci#ifndef __SOUND_OPL3_H 38c2ecf20Sopenharmony_ci#define __SOUND_OPL3_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Definitions of the OPL-3 registers. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (c) by Jaroslav Kysela <perex@perex.cz>, 98c2ecf20Sopenharmony_ci * Hannu Savolainen 1993-1996 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The OPL-3 mode is switched on by writing 0x01, to the offset 5 128c2ecf20Sopenharmony_ci * of the right side. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * Another special register at the right side is at offset 4. It contains 158c2ecf20Sopenharmony_ci * a bit mask defining which voices are used as 4 OP voices. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * The percussive mode is implemented in the left side only. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * With the above exceptions the both sides can be operated independently. 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * A 4 OP voice can be created by setting the corresponding 228c2ecf20Sopenharmony_ci * bit at offset 4 of the right side. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * For example setting the rightmost bit (0x01) changes the 258c2ecf20Sopenharmony_ci * first voice on the right side to the 4 OP mode. The fourth 268c2ecf20Sopenharmony_ci * voice is made inaccessible. 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * If a voice is set to the 2 OP mode, it works like 2 OP modes 298c2ecf20Sopenharmony_ci * of the original YM3812 (AdLib). In addition the voice can 308c2ecf20Sopenharmony_ci * be connected the left, right or both stereo channels. It can 318c2ecf20Sopenharmony_ci * even be left unconnected. This works with 4 OP voices also. 328c2ecf20Sopenharmony_ci * 338c2ecf20Sopenharmony_ci * The stereo connection bits are located in the FEEDBACK_CONNECTION 348c2ecf20Sopenharmony_ci * register of the voice (0xC0-0xC8). In 4 OP voices these bits are 358c2ecf20Sopenharmony_ci * in the second half of the voice. 368c2ecf20Sopenharmony_ci */ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include <sound/core.h> 398c2ecf20Sopenharmony_ci#include <sound/hwdep.h> 408c2ecf20Sopenharmony_ci#include <sound/timer.h> 418c2ecf20Sopenharmony_ci#include <sound/seq_midi_emul.h> 428c2ecf20Sopenharmony_ci#include <sound/seq_oss.h> 438c2ecf20Sopenharmony_ci#include <sound/seq_oss_legacy.h> 448c2ecf20Sopenharmony_ci#include <sound/seq_device.h> 458c2ecf20Sopenharmony_ci#include <sound/asound_fm.h> 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* 488c2ecf20Sopenharmony_ci * Register numbers for the global registers 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define OPL3_REG_TEST 0x01 528c2ecf20Sopenharmony_ci#define OPL3_ENABLE_WAVE_SELECT 0x20 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define OPL3_REG_TIMER1 0x02 558c2ecf20Sopenharmony_ci#define OPL3_REG_TIMER2 0x03 568c2ecf20Sopenharmony_ci#define OPL3_REG_TIMER_CONTROL 0x04 /* Left side */ 578c2ecf20Sopenharmony_ci#define OPL3_IRQ_RESET 0x80 588c2ecf20Sopenharmony_ci#define OPL3_TIMER1_MASK 0x40 598c2ecf20Sopenharmony_ci#define OPL3_TIMER2_MASK 0x20 608c2ecf20Sopenharmony_ci#define OPL3_TIMER1_START 0x01 618c2ecf20Sopenharmony_ci#define OPL3_TIMER2_START 0x02 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define OPL3_REG_CONNECTION_SELECT 0x04 /* Right side */ 648c2ecf20Sopenharmony_ci#define OPL3_LEFT_4OP_0 0x01 658c2ecf20Sopenharmony_ci#define OPL3_LEFT_4OP_1 0x02 668c2ecf20Sopenharmony_ci#define OPL3_LEFT_4OP_2 0x04 678c2ecf20Sopenharmony_ci#define OPL3_RIGHT_4OP_0 0x08 688c2ecf20Sopenharmony_ci#define OPL3_RIGHT_4OP_1 0x10 698c2ecf20Sopenharmony_ci#define OPL3_RIGHT_4OP_2 0x20 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define OPL3_REG_MODE 0x05 /* Right side */ 728c2ecf20Sopenharmony_ci#define OPL3_OPL3_ENABLE 0x01 /* OPL3 mode */ 738c2ecf20Sopenharmony_ci#define OPL3_OPL4_ENABLE 0x02 /* OPL4 mode */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define OPL3_REG_KBD_SPLIT 0x08 /* Left side */ 768c2ecf20Sopenharmony_ci#define OPL3_COMPOSITE_SINE_WAVE_MODE 0x80 /* Don't use with OPL-3? */ 778c2ecf20Sopenharmony_ci#define OPL3_KEYBOARD_SPLIT 0x40 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#define OPL3_REG_PERCUSSION 0xbd /* Left side only */ 808c2ecf20Sopenharmony_ci#define OPL3_TREMOLO_DEPTH 0x80 818c2ecf20Sopenharmony_ci#define OPL3_VIBRATO_DEPTH 0x40 828c2ecf20Sopenharmony_ci#define OPL3_PERCUSSION_ENABLE 0x20 838c2ecf20Sopenharmony_ci#define OPL3_BASSDRUM_ON 0x10 848c2ecf20Sopenharmony_ci#define OPL3_SNAREDRUM_ON 0x08 858c2ecf20Sopenharmony_ci#define OPL3_TOMTOM_ON 0x04 868c2ecf20Sopenharmony_ci#define OPL3_CYMBAL_ON 0x02 878c2ecf20Sopenharmony_ci#define OPL3_HIHAT_ON 0x01 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* 908c2ecf20Sopenharmony_ci * Offsets to the register banks for operators. To get the 918c2ecf20Sopenharmony_ci * register number just add the operator offset to the bank offset 928c2ecf20Sopenharmony_ci * 938c2ecf20Sopenharmony_ci * AM/VIB/EG/KSR/Multiple (0x20 to 0x35) 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_ci#define OPL3_REG_AM_VIB 0x20 968c2ecf20Sopenharmony_ci#define OPL3_TREMOLO_ON 0x80 978c2ecf20Sopenharmony_ci#define OPL3_VIBRATO_ON 0x40 988c2ecf20Sopenharmony_ci#define OPL3_SUSTAIN_ON 0x20 998c2ecf20Sopenharmony_ci#define OPL3_KSR 0x10 /* Key scaling rate */ 1008c2ecf20Sopenharmony_ci#define OPL3_MULTIPLE_MASK 0x0f /* Frequency multiplier */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci /* 1038c2ecf20Sopenharmony_ci * KSL/Total level (0x40 to 0x55) 1048c2ecf20Sopenharmony_ci */ 1058c2ecf20Sopenharmony_ci#define OPL3_REG_KSL_LEVEL 0x40 1068c2ecf20Sopenharmony_ci#define OPL3_KSL_MASK 0xc0 /* Envelope scaling bits */ 1078c2ecf20Sopenharmony_ci#define OPL3_TOTAL_LEVEL_MASK 0x3f /* Strength (volume) of OP */ 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* 1108c2ecf20Sopenharmony_ci * Attack / Decay rate (0x60 to 0x75) 1118c2ecf20Sopenharmony_ci */ 1128c2ecf20Sopenharmony_ci#define OPL3_REG_ATTACK_DECAY 0x60 1138c2ecf20Sopenharmony_ci#define OPL3_ATTACK_MASK 0xf0 1148c2ecf20Sopenharmony_ci#define OPL3_DECAY_MASK 0x0f 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* 1178c2ecf20Sopenharmony_ci * Sustain level / Release rate (0x80 to 0x95) 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci#define OPL3_REG_SUSTAIN_RELEASE 0x80 1208c2ecf20Sopenharmony_ci#define OPL3_SUSTAIN_MASK 0xf0 1218c2ecf20Sopenharmony_ci#define OPL3_RELEASE_MASK 0x0f 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* 1248c2ecf20Sopenharmony_ci * Wave select (0xE0 to 0xF5) 1258c2ecf20Sopenharmony_ci */ 1268c2ecf20Sopenharmony_ci#define OPL3_REG_WAVE_SELECT 0xe0 1278c2ecf20Sopenharmony_ci#define OPL3_WAVE_SELECT_MASK 0x07 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci/* 1308c2ecf20Sopenharmony_ci * Offsets to the register banks for voices. Just add to the 1318c2ecf20Sopenharmony_ci * voice number to get the register number. 1328c2ecf20Sopenharmony_ci * 1338c2ecf20Sopenharmony_ci * F-Number low bits (0xA0 to 0xA8). 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_ci#define OPL3_REG_FNUM_LOW 0xa0 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * F-number high bits / Key on / Block (octave) (0xB0 to 0xB8) 1398c2ecf20Sopenharmony_ci */ 1408c2ecf20Sopenharmony_ci#define OPL3_REG_KEYON_BLOCK 0xb0 1418c2ecf20Sopenharmony_ci#define OPL3_KEYON_BIT 0x20 1428c2ecf20Sopenharmony_ci#define OPL3_BLOCKNUM_MASK 0x1c 1438c2ecf20Sopenharmony_ci#define OPL3_FNUM_HIGH_MASK 0x03 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci/* 1468c2ecf20Sopenharmony_ci * Feedback / Connection (0xc0 to 0xc8) 1478c2ecf20Sopenharmony_ci * 1488c2ecf20Sopenharmony_ci * These registers have two new bits when the OPL-3 mode 1498c2ecf20Sopenharmony_ci * is selected. These bits controls connecting the voice 1508c2ecf20Sopenharmony_ci * to the stereo channels. For 4 OP voices this bit is 1518c2ecf20Sopenharmony_ci * defined in the second half of the voice (add 3 to the 1528c2ecf20Sopenharmony_ci * register offset). 1538c2ecf20Sopenharmony_ci * 1548c2ecf20Sopenharmony_ci * For 4 OP voices the connection bit is used in the 1558c2ecf20Sopenharmony_ci * both halves (gives 4 ways to connect the operators). 1568c2ecf20Sopenharmony_ci */ 1578c2ecf20Sopenharmony_ci#define OPL3_REG_FEEDBACK_CONNECTION 0xc0 1588c2ecf20Sopenharmony_ci#define OPL3_FEEDBACK_MASK 0x0e /* Valid just for 1st OP of a voice */ 1598c2ecf20Sopenharmony_ci#define OPL3_CONNECTION_BIT 0x01 1608c2ecf20Sopenharmony_ci/* 1618c2ecf20Sopenharmony_ci * In the 4 OP mode there is four possible configurations how the 1628c2ecf20Sopenharmony_ci * operators can be connected together (in 2 OP modes there is just 1638c2ecf20Sopenharmony_ci * AM or FM). The 4 OP connection mode is defined by the rightmost 1648c2ecf20Sopenharmony_ci * bit of the FEEDBACK_CONNECTION (0xC0-0xC8) on the both halves. 1658c2ecf20Sopenharmony_ci * 1668c2ecf20Sopenharmony_ci * First half Second half Mode 1678c2ecf20Sopenharmony_ci * 1688c2ecf20Sopenharmony_ci * +---+ 1698c2ecf20Sopenharmony_ci * v | 1708c2ecf20Sopenharmony_ci * 0 0 >+-1-+--2--3--4--> 1718c2ecf20Sopenharmony_ci * 1728c2ecf20Sopenharmony_ci * 1738c2ecf20Sopenharmony_ci * 1748c2ecf20Sopenharmony_ci * +---+ 1758c2ecf20Sopenharmony_ci * | | 1768c2ecf20Sopenharmony_ci * 0 1 >+-1-+--2-+ 1778c2ecf20Sopenharmony_ci * |-> 1788c2ecf20Sopenharmony_ci * >--3----4-+ 1798c2ecf20Sopenharmony_ci * 1808c2ecf20Sopenharmony_ci * +---+ 1818c2ecf20Sopenharmony_ci * | | 1828c2ecf20Sopenharmony_ci * 1 0 >+-1-+-----+ 1838c2ecf20Sopenharmony_ci * |-> 1848c2ecf20Sopenharmony_ci * >--2--3--4-+ 1858c2ecf20Sopenharmony_ci * 1868c2ecf20Sopenharmony_ci * +---+ 1878c2ecf20Sopenharmony_ci * | | 1888c2ecf20Sopenharmony_ci * 1 1 >+-1-+--+ 1898c2ecf20Sopenharmony_ci * | 1908c2ecf20Sopenharmony_ci * >--2--3-+-> 1918c2ecf20Sopenharmony_ci * | 1928c2ecf20Sopenharmony_ci * >--4----+ 1938c2ecf20Sopenharmony_ci */ 1948c2ecf20Sopenharmony_ci#define OPL3_STEREO_BITS 0x30 /* OPL-3 only */ 1958c2ecf20Sopenharmony_ci#define OPL3_VOICE_TO_LEFT 0x10 1968c2ecf20Sopenharmony_ci#define OPL3_VOICE_TO_RIGHT 0x20 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci/* 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci */ 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci#define OPL3_LEFT 0x0000 2038c2ecf20Sopenharmony_ci#define OPL3_RIGHT 0x0100 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci#define OPL3_HW_AUTO 0x0000 2068c2ecf20Sopenharmony_ci#define OPL3_HW_OPL2 0x0200 2078c2ecf20Sopenharmony_ci#define OPL3_HW_OPL3 0x0300 2088c2ecf20Sopenharmony_ci#define OPL3_HW_OPL3_SV 0x0301 /* S3 SonicVibes */ 2098c2ecf20Sopenharmony_ci#define OPL3_HW_OPL3_CS 0x0302 /* CS4232/CS4236+ */ 2108c2ecf20Sopenharmony_ci#define OPL3_HW_OPL3_FM801 0x0303 /* FM801 */ 2118c2ecf20Sopenharmony_ci#define OPL3_HW_OPL3_CS4281 0x0304 /* CS4281 */ 2128c2ecf20Sopenharmony_ci#define OPL3_HW_OPL4 0x0400 /* YMF278B/YMF295 */ 2138c2ecf20Sopenharmony_ci#define OPL3_HW_OPL4_ML 0x0401 /* YMF704/YMF721 */ 2148c2ecf20Sopenharmony_ci#define OPL3_HW_MASK 0xff00 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define MAX_OPL2_VOICES 9 2178c2ecf20Sopenharmony_ci#define MAX_OPL3_VOICES 18 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_cistruct snd_opl3; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci/* 2228c2ecf20Sopenharmony_ci * Instrument record, aka "Patch" 2238c2ecf20Sopenharmony_ci */ 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci/* FM operator */ 2268c2ecf20Sopenharmony_cistruct fm_operator { 2278c2ecf20Sopenharmony_ci unsigned char am_vib; 2288c2ecf20Sopenharmony_ci unsigned char ksl_level; 2298c2ecf20Sopenharmony_ci unsigned char attack_decay; 2308c2ecf20Sopenharmony_ci unsigned char sustain_release; 2318c2ecf20Sopenharmony_ci unsigned char wave_select; 2328c2ecf20Sopenharmony_ci} __attribute__((packed)); 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci/* Instrument data */ 2358c2ecf20Sopenharmony_cistruct fm_instrument { 2368c2ecf20Sopenharmony_ci struct fm_operator op[4]; 2378c2ecf20Sopenharmony_ci unsigned char feedback_connection[2]; 2388c2ecf20Sopenharmony_ci unsigned char echo_delay; 2398c2ecf20Sopenharmony_ci unsigned char echo_atten; 2408c2ecf20Sopenharmony_ci unsigned char chorus_spread; 2418c2ecf20Sopenharmony_ci unsigned char trnsps; 2428c2ecf20Sopenharmony_ci unsigned char fix_dur; 2438c2ecf20Sopenharmony_ci unsigned char modes; 2448c2ecf20Sopenharmony_ci unsigned char fix_key; 2458c2ecf20Sopenharmony_ci}; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci/* type */ 2488c2ecf20Sopenharmony_ci#define FM_PATCH_OPL2 0x01 /* OPL2 2 operators FM instrument */ 2498c2ecf20Sopenharmony_ci#define FM_PATCH_OPL3 0x02 /* OPL3 4 operators FM instrument */ 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci/* Instrument record */ 2528c2ecf20Sopenharmony_cistruct fm_patch { 2538c2ecf20Sopenharmony_ci unsigned char prog; 2548c2ecf20Sopenharmony_ci unsigned char bank; 2558c2ecf20Sopenharmony_ci unsigned char type; 2568c2ecf20Sopenharmony_ci struct fm_instrument inst; 2578c2ecf20Sopenharmony_ci char name[24]; 2588c2ecf20Sopenharmony_ci struct fm_patch *next; 2598c2ecf20Sopenharmony_ci}; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci/* 2638c2ecf20Sopenharmony_ci * A structure to keep track of each hardware voice 2648c2ecf20Sopenharmony_ci */ 2658c2ecf20Sopenharmony_cistruct snd_opl3_voice { 2668c2ecf20Sopenharmony_ci int state; /* status */ 2678c2ecf20Sopenharmony_ci#define SNDRV_OPL3_ST_OFF 0 /* Not playing */ 2688c2ecf20Sopenharmony_ci#define SNDRV_OPL3_ST_ON_2OP 1 /* 2op voice is allocated */ 2698c2ecf20Sopenharmony_ci#define SNDRV_OPL3_ST_ON_4OP 2 /* 4op voice is allocated */ 2708c2ecf20Sopenharmony_ci#define SNDRV_OPL3_ST_NOT_AVAIL -1 /* voice is not available */ 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci unsigned int time; /* An allocation time */ 2738c2ecf20Sopenharmony_ci unsigned char note; /* Note currently assigned to this voice */ 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci unsigned long note_off; /* note-off time */ 2768c2ecf20Sopenharmony_ci int note_off_check; /* check note-off time */ 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci unsigned char keyon_reg; /* KON register shadow */ 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci struct snd_midi_channel *chan; /* Midi channel for this note */ 2818c2ecf20Sopenharmony_ci}; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_cistruct snd_opl3 { 2848c2ecf20Sopenharmony_ci unsigned long l_port; 2858c2ecf20Sopenharmony_ci unsigned long r_port; 2868c2ecf20Sopenharmony_ci struct resource *res_l_port; 2878c2ecf20Sopenharmony_ci struct resource *res_r_port; 2888c2ecf20Sopenharmony_ci unsigned short hardware; 2898c2ecf20Sopenharmony_ci /* hardware access */ 2908c2ecf20Sopenharmony_ci void (*command) (struct snd_opl3 * opl3, unsigned short cmd, unsigned char val); 2918c2ecf20Sopenharmony_ci unsigned short timer_enable; 2928c2ecf20Sopenharmony_ci int seq_dev_num; /* sequencer device number */ 2938c2ecf20Sopenharmony_ci struct snd_timer *timer1; 2948c2ecf20Sopenharmony_ci struct snd_timer *timer2; 2958c2ecf20Sopenharmony_ci spinlock_t timer_lock; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci void *private_data; 2988c2ecf20Sopenharmony_ci void (*private_free)(struct snd_opl3 *); 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci struct snd_hwdep *hwdep; 3018c2ecf20Sopenharmony_ci spinlock_t reg_lock; 3028c2ecf20Sopenharmony_ci struct snd_card *card; /* The card that this belongs to */ 3038c2ecf20Sopenharmony_ci unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */ 3048c2ecf20Sopenharmony_ci unsigned char rhythm; /* percussion mode flag */ 3058c2ecf20Sopenharmony_ci unsigned char max_voices; /* max number of voices */ 3068c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SEQUENCER) 3078c2ecf20Sopenharmony_ci#define SNDRV_OPL3_MODE_SYNTH 0 /* OSS - voices allocated by application */ 3088c2ecf20Sopenharmony_ci#define SNDRV_OPL3_MODE_SEQ 1 /* ALSA - driver handles voice allocation */ 3098c2ecf20Sopenharmony_ci int synth_mode; /* synth mode */ 3108c2ecf20Sopenharmony_ci int seq_client; 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci struct snd_seq_device *seq_dev; /* sequencer device */ 3138c2ecf20Sopenharmony_ci struct snd_midi_channel_set * chset; 3148c2ecf20Sopenharmony_ci 3158c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS) 3168c2ecf20Sopenharmony_ci struct snd_seq_device *oss_seq_dev; /* OSS sequencer device */ 3178c2ecf20Sopenharmony_ci struct snd_midi_channel_set * oss_chset; 3188c2ecf20Sopenharmony_ci#endif 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci#define OPL3_PATCH_HASH_SIZE 32 3218c2ecf20Sopenharmony_ci struct fm_patch *patch_table[OPL3_PATCH_HASH_SIZE]; 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci struct snd_opl3_voice voices[MAX_OPL3_VOICES]; /* Voices (OPL3 'channel') */ 3248c2ecf20Sopenharmony_ci int use_time; /* allocation counter */ 3258c2ecf20Sopenharmony_ci 3268c2ecf20Sopenharmony_ci unsigned short connection_reg; /* connection reg shadow */ 3278c2ecf20Sopenharmony_ci unsigned char drum_reg; /* percussion reg shadow */ 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci spinlock_t voice_lock; /* Lock for voice access */ 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci struct timer_list tlist; /* timer for note-offs and effects */ 3328c2ecf20Sopenharmony_ci int sys_timer_status; /* system timer run status */ 3338c2ecf20Sopenharmony_ci spinlock_t sys_timer_lock; /* Lock for system timer access */ 3348c2ecf20Sopenharmony_ci#endif 3358c2ecf20Sopenharmony_ci}; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci/* opl3.c */ 3388c2ecf20Sopenharmony_civoid snd_opl3_interrupt(struct snd_hwdep * hw); 3398c2ecf20Sopenharmony_ciint snd_opl3_new(struct snd_card *card, unsigned short hardware, 3408c2ecf20Sopenharmony_ci struct snd_opl3 **ropl3); 3418c2ecf20Sopenharmony_ciint snd_opl3_init(struct snd_opl3 *opl3); 3428c2ecf20Sopenharmony_ciint snd_opl3_create(struct snd_card *card, 3438c2ecf20Sopenharmony_ci unsigned long l_port, unsigned long r_port, 3448c2ecf20Sopenharmony_ci unsigned short hardware, 3458c2ecf20Sopenharmony_ci int integrated, 3468c2ecf20Sopenharmony_ci struct snd_opl3 ** opl3); 3478c2ecf20Sopenharmony_ciint snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev); 3488c2ecf20Sopenharmony_ciint snd_opl3_hwdep_new(struct snd_opl3 * opl3, int device, int seq_device, 3498c2ecf20Sopenharmony_ci struct snd_hwdep ** rhwdep); 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci/* opl3_synth */ 3528c2ecf20Sopenharmony_ciint snd_opl3_open(struct snd_hwdep * hw, struct file *file); 3538c2ecf20Sopenharmony_ciint snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file, 3548c2ecf20Sopenharmony_ci unsigned int cmd, unsigned long arg); 3558c2ecf20Sopenharmony_ciint snd_opl3_release(struct snd_hwdep * hw, struct file *file); 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_civoid snd_opl3_reset(struct snd_opl3 * opl3); 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SEQUENCER) 3608c2ecf20Sopenharmony_cilong snd_opl3_write(struct snd_hwdep *hw, const char __user *buf, long count, 3618c2ecf20Sopenharmony_ci loff_t *offset); 3628c2ecf20Sopenharmony_ciint snd_opl3_load_patch(struct snd_opl3 *opl3, 3638c2ecf20Sopenharmony_ci int prog, int bank, int type, 3648c2ecf20Sopenharmony_ci const char *name, 3658c2ecf20Sopenharmony_ci const unsigned char *ext, 3668c2ecf20Sopenharmony_ci const unsigned char *data); 3678c2ecf20Sopenharmony_cistruct fm_patch *snd_opl3_find_patch(struct snd_opl3 *opl3, int prog, int bank, 3688c2ecf20Sopenharmony_ci int create_patch); 3698c2ecf20Sopenharmony_civoid snd_opl3_clear_patches(struct snd_opl3 *opl3); 3708c2ecf20Sopenharmony_ci#else 3718c2ecf20Sopenharmony_ci#define snd_opl3_write NULL 3728c2ecf20Sopenharmony_cistatic inline void snd_opl3_clear_patches(struct snd_opl3 *opl3) {} 3738c2ecf20Sopenharmony_ci#endif 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci#endif /* __SOUND_OPL3_H */ 376