/*1* opl3_hw.h - Definitions of the OPL-3 registers2*3*4* Copyright (C) by Hannu Savolainen 1993-19975*6* OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)7* Version 2 (June 1991). See the "COPYING" file distributed with this software8* for more info.9*10*11* The OPL-3 mode is switched on by writing 0x01, to the offset 512* of the right side.13*14* Another special register at the right side is at offset 4. It contains15* a bit mask defining which voices are used as 4 OP voices.16*17* The percussive mode is implemented in the left side only.18*19* With the above exceptions the both sides can be operated independently.20*21* A 4 OP voice can be created by setting the corresponding22* bit at offset 4 of the right side.23*24* For example setting the rightmost bit (0x01) changes the25* first voice on the right side to the 4 OP mode. The fourth26* voice is made inaccessible.27*28* If a voice is set to the 2 OP mode, it works like 2 OP modes29* of the original YM3812 (AdLib). In addition the voice can30* be connected the left, right or both stereo channels. It can31* even be left unconnected. This works with 4 OP voices also.32*33* The stereo connection bits are located in the FEEDBACK_CONNECTION34* register of the voice (0xC0-0xC8). In 4 OP voices these bits are35* in the second half of the voice.36*/3738/*39* Register numbers for the global registers40*/4142#define TEST_REGISTER 0x0143#define ENABLE_WAVE_SELECT 0x204445#define TIMER1_REGISTER 0x0246#define TIMER2_REGISTER 0x0347#define TIMER_CONTROL_REGISTER 0x04 /* Left side */48#define IRQ_RESET 0x8049#define TIMER1_MASK 0x4050#define TIMER2_MASK 0x2051#define TIMER1_START 0x0152#define TIMER2_START 0x025354#define CONNECTION_SELECT_REGISTER 0x04 /* Right side */55#define RIGHT_4OP_0 0x0156#define RIGHT_4OP_1 0x0257#define RIGHT_4OP_2 0x0458#define LEFT_4OP_0 0x0859#define LEFT_4OP_1 0x1060#define LEFT_4OP_2 0x206162#define OPL3_MODE_REGISTER 0x05 /* Right side */63#define OPL3_ENABLE 0x0164#define OPL4_ENABLE 0x026566#define KBD_SPLIT_REGISTER 0x08 /* Left side */67#define COMPOSITE_SINE_WAVE_MODE 0x80 /* Don't use with OPL-3? */68#define KEYBOARD_SPLIT 0x406970#define PERCOSSION_REGISTER 0xbd /* Left side only */71#define TREMOLO_DEPTH 0x8072#define VIBRATO_DEPTH 0x4073#define PERCOSSION_ENABLE 0x2074#define BASSDRUM_ON 0x1075#define SNAREDRUM_ON 0x0876#define TOMTOM_ON 0x0477#define CYMBAL_ON 0x0278#define HIHAT_ON 0x017980/*81* Offsets to the register banks for operators. To get the82* register number just add the operator offset to the bank offset83*84* AM/VIB/EG/KSR/Multiple (0x20 to 0x35)85*/86#define AM_VIB 0x2087#define TREMOLO_ON 0x8088#define VIBRATO_ON 0x4089#define SUSTAIN_ON 0x2090#define KSR 0x10 /* Key scaling rate */91#define MULTIPLE_MASK 0x0f /* Frequency multiplier */9293/*94* KSL/Total level (0x40 to 0x55)95*/96#define KSL_LEVEL 0x4097#define KSL_MASK 0xc0 /* Envelope scaling bits */98#define TOTAL_LEVEL_MASK 0x3f /* Strength (volume) of OP */99100/*101* Attack / Decay rate (0x60 to 0x75)102*/103#define ATTACK_DECAY 0x60104#define ATTACK_MASK 0xf0105#define DECAY_MASK 0x0f106107/*108* Sustain level / Release rate (0x80 to 0x95)109*/110#define SUSTAIN_RELEASE 0x80111#define SUSTAIN_MASK 0xf0112#define RELEASE_MASK 0x0f113114/*115* Wave select (0xE0 to 0xF5)116*/117#define WAVE_SELECT 0xe0118119/*120* Offsets to the register banks for voices. Just add to the121* voice number to get the register number.122*123* F-Number low bits (0xA0 to 0xA8).124*/125#define FNUM_LOW 0xa0126127/*128* F-number high bits / Key on / Block (octave) (0xB0 to 0xB8)129*/130#define KEYON_BLOCK 0xb0131#define KEYON_BIT 0x20132#define BLOCKNUM_MASK 0x1c133#define FNUM_HIGH_MASK 0x03134135/*136* Feedback / Connection (0xc0 to 0xc8)137*138* These registers have two new bits when the OPL-3 mode139* is selected. These bits controls connecting the voice140* to the stereo channels. For 4 OP voices this bit is141* defined in the second half of the voice (add 3 to the142* register offset).143*144* For 4 OP voices the connection bit is used in the145* both halves (gives 4 ways to connect the operators).146*/147#define FEEDBACK_CONNECTION 0xc0148#define FEEDBACK_MASK 0x0e /* Valid just for 1st OP of a voice */149#define CONNECTION_BIT 0x01150/*151* In the 4 OP mode there is four possible configurations how the152* operators can be connected together (in 2 OP modes there is just153* AM or FM). The 4 OP connection mode is defined by the rightmost154* bit of the FEEDBACK_CONNECTION (0xC0-0xC8) on the both halves.155*156* First half Second half Mode157*158* +---+159* v |160* 0 0 >+-1-+--2--3--4-->161*162*163*164* +---+165* | |166* 0 1 >+-1-+--2-+167* |->168* >--3----4-+169*170* +---+171* | |172* 1 0 >+-1-+-----+173* |->174* >--2--3--4-+175*176* +---+177* | |178* 1 1 >+-1-+--+179* |180* >--2--3-+->181* |182* >--4----+183*/184#define STEREO_BITS 0x30 /* OPL-3 only */185#define VOICE_TO_LEFT 0x10186#define VOICE_TO_RIGHT 0x20187188/*189* Definition table for the physical voices190*/191192struct physical_voice_info {193unsigned char voice_num;194unsigned char voice_mode; /* 0=unavailable, 2=2 OP, 4=4 OP */195unsigned short ioaddr; /* I/O port (left or right side) */196unsigned char op[4]; /* Operator offsets */197};198199/*200* There is 18 possible 2 OP voices201* (9 in the left and 9 in the right).202* The first OP is the modulator and 2nd is the carrier.203*204* The first three voices in the both sides may be connected205* with another voice to a 4 OP voice. For example voice 0206* can be connected with voice 3. The operators of voice 3 are207* used as operators 3 and 4 of the new 4 OP voice.208* In this case the 2 OP voice number 0 is the 'first half' and209* voice 3 is the second.210*/211212#define USE_LEFT 0213#define USE_RIGHT 1214215static struct physical_voice_info pv_map[18] =216{217/* No Mode Side OP1 OP2 OP3 OP4 */218/* --------------------------------------------------- */219{ 0, 2, USE_LEFT, {0x00, 0x03, 0x08, 0x0b}},220{ 1, 2, USE_LEFT, {0x01, 0x04, 0x09, 0x0c}},221{ 2, 2, USE_LEFT, {0x02, 0x05, 0x0a, 0x0d}},222223{ 3, 2, USE_LEFT, {0x08, 0x0b, 0x00, 0x00}},224{ 4, 2, USE_LEFT, {0x09, 0x0c, 0x00, 0x00}},225{ 5, 2, USE_LEFT, {0x0a, 0x0d, 0x00, 0x00}},226227{ 6, 2, USE_LEFT, {0x10, 0x13, 0x00, 0x00}}, /* Used by percussive voices */228{ 7, 2, USE_LEFT, {0x11, 0x14, 0x00, 0x00}}, /* if the percussive mode */229{ 8, 2, USE_LEFT, {0x12, 0x15, 0x00, 0x00}}, /* is selected */230231{ 0, 2, USE_RIGHT, {0x00, 0x03, 0x08, 0x0b}},232{ 1, 2, USE_RIGHT, {0x01, 0x04, 0x09, 0x0c}},233{ 2, 2, USE_RIGHT, {0x02, 0x05, 0x0a, 0x0d}},234235{ 3, 2, USE_RIGHT, {0x08, 0x0b, 0x00, 0x00}},236{ 4, 2, USE_RIGHT, {0x09, 0x0c, 0x00, 0x00}},237{ 5, 2, USE_RIGHT, {0x0a, 0x0d, 0x00, 0x00}},238239{ 6, 2, USE_RIGHT, {0x10, 0x13, 0x00, 0x00}},240{ 7, 2, USE_RIGHT, {0x11, 0x14, 0x00, 0x00}},241{ 8, 2, USE_RIGHT, {0x12, 0x15, 0x00, 0x00}}242};243/*244* DMA buffer calls245*/246247248