root/drivers/sound/opl3.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  *      opl3.h  - Definitions of the OPL-3 registers
   3  *
   4  * Copyright by Hannu Savolainen 1993
   5  *
   6  * Redistribution and use in source and binary forms, with or without
   7  * modification, are permitted provided that the following conditions
   8  * are met:
   9  * 1. Redistributions of source code must retain the above copyright
  10  *    notice, this list of conditions and the following disclaimer.
  11  * 2. Redistributions in binary form must reproduce the above copyright
  12  *    notice, this list of conditions and the following disclaimer in the
  13  *    documentation and/or other materials provided with the distribution.
  14  *
  15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25  * SUCH DAMAGE.
  26  *
  27  */
  28 
  29 /*
  30  *      The OPL-3 mode is switched on by writing 0x01, to the offset 5
  31  *      of the right side.
  32  *
  33  *      Another special register at the right side is at offset 4. It contains
  34  *      a bit mask defining which voices are used as 4 OP voices.
  35  *
  36  *      The percussive mode is implemented in the left side only.
  37  *
  38  *      With the above exeptions the both sides can be operated independently.
  39  *      
  40  *      A 4 OP voice can be created by setting the corresponding
  41  *      bit at offset 4 of the right side.
  42  *
  43  *      For example setting the rightmost bit (0x01) changes the
  44  *      first voice on the right side to the 4 OP mode. The fourth
  45  *      voice is made inaccessible.
  46  *
  47  *      If a voice is set to the 2 OP mode, it works like 2 OP modes
  48  *      of the original YM3812 (AdLib). In addition the voice can 
  49  *      be connected the left, right or both stereo channels. It can
  50  *      even be left unconnected. This works with 4 OP voices also.
  51  *
  52  *      The stereo connection bits are located in the FEEDBACK_CONNECTION
  53  *      register of the voice (0xC0-0xC8). In 4 OP voices these bits are
  54  *      in the second half of the voice.
  55  */
  56 
  57 /*
  58  *      Register numbers for the global registers
  59  */
  60 
  61 #define TEST_REGISTER                           0x01
  62 #define   ENABLE_WAVE_SELECT            0x20
  63 
  64 #define TIMER1_REGISTER                         0x02
  65 #define TIMER2_REGISTER                         0x03
  66 #define TIMER_CONTROL_REGISTER                  0x04    /* Left side */
  67 #define   IRQ_RESET                     0x80
  68 #define   TIMER1_MASK                   0x40
  69 #define   TIMER2_MASK                   0x20
  70 #define   TIMER1_START                  0x01
  71 #define   TIMER2_START                  0x02
  72 
  73 #define CONNECTION_SELECT_REGISTER              0x04    /* Right side */
  74 #define   RIGHT_4OP_0                   0x01
  75 #define   RIGHT_4OP_1                   0x02
  76 #define   RIGHT_4OP_2                   0x04
  77 #define   LEFT_4OP_0                    0x08
  78 #define   LEFT_4OP_1                    0x10
  79 #define   LEFT_4OP_2                    0x20
  80 
  81 #define OPL3_MODE_REGISTER                      0x05    /* Right side */
  82 #define   OPL3_ENABLE                   0x01
  83 #define   OPL4_ENABLE                   0x02
  84 
  85 #define KBD_SPLIT_REGISTER                      0x08    /* Left side */
  86 #define   COMPOSITE_SINE_WAVE_MODE      0x80            /* Don't use with OPL-3? */
  87 #define   KEYBOARD_SPLIT                0x40
  88 
  89 #define PERCUSSION_REGISTER                     0xbd    /* Left side only */
  90 #define   TREMOLO_DEPTH                 0x80
  91 #define   VIBRATO_DEPTH                 0x40
  92 #define   PERCUSSION_ENABLE             0x20
  93 #define   BASSDRUM_ON                   0x10
  94 #define   SNAREDRUM_ON                  0x08
  95 #define   TOMTOM_ON                     0x04
  96 #define   CYMBAL_ON                     0x02
  97 #define   HIHAT_ON                      0x01
  98 
  99 /*
 100  *      Offsets to the register banks for operators. To get the
 101  *      register number just add the operator offset to the bank offset
 102  *
 103  *      AM/VIB/EG/KSR/Multiple (0x20 to 0x35)
 104  */
 105 #define AM_VIB                                  0x20
 106 #define   TREMOLO_ON                    0x80
 107 #define   VIBRATO_ON                    0x40
 108 #define   SUSTAIN_ON                    0x20
 109 #define   KSR                           0x10    /* Key scaling rate */
 110 #define   MULTIPLE_MASK         0x0f    /* Frequency multiplier */
 111 
 112  /*
 113   *     KSL/Total level (0x40 to 0x55)
 114   */
 115 #define KSL_LEVEL                               0x40
 116 #define   KSL_MASK                      0xc0    /* Envelope scaling bits */
 117 #define   TOTAL_LEVEL_MASK              0x3f    /* Strength (volume) of OP */
 118 
 119 /*
 120  *      Attack / Decay rate (0x60 to 0x75)
 121  */
 122 #define ATTACK_DECAY                            0x60
 123 #define   ATTACK_MASK                   0xf0
 124 #define   DECAY_MASK                    0x0f
 125 
 126 /*
 127  * Sustain level / Release rate (0x80 to 0x95)
 128  */
 129 #define SUSTAIN_RELEASE                         0x80
 130 #define   SUSTAIN_MASK                  0xf0
 131 #define   RELEASE_MASK                  0x0f
 132 
 133 /*
 134  * Wave select (0xE0 to 0xF5)
 135  */
 136 #define WAVE_SELECT                     0xe0
 137 
 138 /*
 139  *      Offsets to the register banks for voices. Just add to the
 140  *      voice number to get the register number.
 141  *
 142  *      F-Number low bits (0xA0 to 0xA8).
 143  */
 144 #define FNUM_LOW                                0xa0
 145 
 146 /*
 147  *      F-number high bits / Key on / Block (octave) (0xB0 to 0xB8)
 148  */
 149 #define KEYON_BLOCK                                     0xb0
 150 #define   KEYON_BIT                             0x20
 151 #define   BLOCKNUM_MASK                         0x1c
 152 #define   FNUM_HIGH_MASK                        0x03
 153 
 154 /*
 155  *      Feedback / Connection (0xc0 to 0xc8)
 156  *
 157  *      These registers have two new bits when the OPL-3 mode
 158  *      is selected. These bits controls connecting the voice
 159  *      to the stereo channels. For 4 OP voices this bit is
 160  *      defined in the second half of the voice (add 3 to the
 161  *      register offset).
 162  *
 163  *      For 4 OP voices the connection bit is used in the
 164  *      both halfs (gives 4 ways to connect the operators).
 165  */
 166 #define FEEDBACK_CONNECTION                             0xc0
 167 #define   FEEDBACK_MASK                         0x0e    /* Valid just for 1st OP of a voice */
 168 #define   CONNECTION_BIT                        0x01
 169 /*
 170  *      In the 4 OP mode there is four possible configurations how the
 171  *      operators can be connected together (in 2 OP modes there is just
 172  *      AM or FM). The 4 OP connection mode is defined by the rightmost
 173  *      bit of the FEEDBACK_CONNECTION (0xC0-0xC8) on the both halfs.
 174  *
 175  *      First half      Second half     Mode
 176  *
 177  *                                       +---+
 178  *                                       v   |
 179  *      0               0               >+-1-+--2--3--4-->
 180  *
 181  *
 182  *                                      
 183  *                                       +---+
 184  *                                       |   |
 185  *      0               1               >+-1-+--2-+
 186  *                                                |->
 187  *                                      >--3----4-+
 188  *                                      
 189  *                                       +---+
 190  *                                       |   |
 191  *      1               0               >+-1-+-----+
 192  *                                                 |->
 193  *                                      >--2--3--4-+
 194  *
 195  *                                       +---+
 196  *                                       |   |
 197  *      1               1               >+-1-+--+
 198  *                                              |
 199  *                                      >--2--3-+->
 200  *                                              |
 201  *                                      >--4----+
 202  */
 203 #define   STEREO_BITS                           0x30    /* OPL-3 only */
 204 #define     VOICE_TO_LEFT               0x10
 205 #define     VOICE_TO_RIGHT              0x20
 206 
 207 /*
 208  *      Definition table for the physical voices
 209  */
 210 
 211 struct physical_voice_info {
 212                 unsigned char voice_num;
 213                 unsigned char voice_mode; /* 0=unavailable, 2=2 OP, 4=4 OP */
 214                 unsigned short ioaddr; /* I/O port (left or right side) */
 215                 unsigned char op[4]; /* Operator offsets */
 216         };
 217 
 218 /*
 219  *      There is 18 possible 2 OP voices
 220  *      (9 in the left and 9 in the right).
 221  *      The first OP is the modulator and 2nd is the carrier.
 222  *
 223  *      The first three voices in the both sides may be connected
 224  *      with another voice to a 4 OP voice. For example voice 0
 225  *      can be connected with voice 3. The operators of voice 3 are
 226  *      used as operators 3 and 4 of the new 4 OP voice.
 227  *      In this case the 2 OP voice number 0 is the 'first half' and
 228  *      voice 3 is the second.
 229  */
 230 
 231 #define USE_LEFT        0
 232 #define USE_RIGHT       1
 233 
 234 static struct physical_voice_info pv_map[18] =
 235 {
 236 /*       No Mode Side           OP1     OP2     OP3   OP4       */
 237 /*      ---------------------------------------------------     */
 238         { 0,  2, USE_LEFT,      {0x00,  0x03,   0x08, 0x0b}},
 239         { 1,  2, USE_LEFT,      {0x01,  0x04,   0x09, 0x0c}},
 240         { 2,  2, USE_LEFT,      {0x02,  0x05,   0x0a, 0x0d}},
 241 
 242         { 3,  2, USE_LEFT,      {0x08,  0x0b,   0x00, 0x00}},
 243         { 4,  2, USE_LEFT,      {0x09,  0x0c,   0x00, 0x00}},
 244         { 5,  2, USE_LEFT,      {0x0a,  0x0d,   0x00, 0x00}},
 245 
 246         { 6,  2, USE_LEFT,      {0x10,  0x13,   0x00, 0x00}}, /* Used by percussive voices */
 247         { 7,  2, USE_LEFT,      {0x11,  0x14,   0x00, 0x00}}, /* if the percussive mode */
 248         { 8,  2, USE_LEFT,      {0x12,  0x15,   0x00, 0x00}}, /* is selected */
 249 
 250         { 0,  2, USE_RIGHT,     {0x00,  0x03,   0x08, 0x0b}},
 251         { 1,  2, USE_RIGHT,     {0x01,  0x04,   0x09, 0x0c}},
 252         { 2,  2, USE_RIGHT,     {0x02,  0x05,   0x0a, 0x0d}},
 253 
 254         { 3,  2, USE_RIGHT,     {0x08,  0x0b,   0x00, 0x00}},
 255         { 4,  2, USE_RIGHT,     {0x09,  0x0c,   0x00, 0x00}},
 256         { 5,  2, USE_RIGHT,     {0x0a,  0x0d,   0x00, 0x00}},
 257 
 258         { 6,  2, USE_RIGHT,     {0x10,  0x13,   0x00, 0x00}},
 259         { 7,  2, USE_RIGHT,     {0x11,  0x14,   0x00, 0x00}},
 260         { 8,  2, USE_RIGHT,     {0x12,  0x15,   0x00, 0x00}}
 261 };

/* [previous][next][first][last][top][bottom][index][help] */