Home | History | Annotate | Line # | Download | only in isa
cmsreg.h revision 1.1
      1  1.1  augustss /* $NetBSD: cmsreg.h,v 1.1 2000/05/01 22:48:33 augustss Exp $ */
      2  1.1  augustss 
      3  1.1  augustss /*
      4  1.1  augustss  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  1.1  augustss  * All rights reserved.
      6  1.1  augustss  *
      7  1.1  augustss  * Redistribution and use in source and binary forms, with or without
      8  1.1  augustss  * modification, are permitted provided that the following conditions
      9  1.1  augustss  * are met:
     10  1.1  augustss  * 1. Redistributions of source code must retain the above copyright
     11  1.1  augustss  *    notice, this list of conditions and the following disclaimer.
     12  1.1  augustss  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  augustss  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  augustss  *    documentation and/or other materials provided with the distribution.
     15  1.1  augustss  * 3. All advertising materials mentioning features or use of this software
     16  1.1  augustss  *    must display the following acknowledgement:
     17  1.1  augustss  *        This product includes software developed by the NetBSD
     18  1.1  augustss  *        Foundation, Inc. and its contributors.
     19  1.1  augustss  * 4. Neither the name of The NetBSD Foundation nor the names of its
     20  1.1  augustss  *    contributors may be used to endorse or promote products derived
     21  1.1  augustss  *    from this software without specific prior written permission.
     22  1.1  augustss  *
     23  1.1  augustss  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     24  1.1  augustss  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     25  1.1  augustss  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     26  1.1  augustss  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     27  1.1  augustss  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28  1.1  augustss  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29  1.1  augustss  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     30  1.1  augustss  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     31  1.1  augustss  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     32  1.1  augustss  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     33  1.1  augustss  * POSSIBILITY OF SUCH DAMAGE.
     34  1.1  augustss  */
     35  1.1  augustss 
     36  1.1  augustss #define CMS_NVOICES 12
     37  1.1  augustss #define CMS_FIRST_NOTE 30
     38  1.1  augustss 
     39  1.1  augustss /* direct registers */
     40  1.1  augustss 
     41  1.1  augustss #define CMS_DATA0 0x00 /* for chip 0, voices 0-5 */
     42  1.1  augustss #define CMS_ADDR0 0x01
     43  1.1  augustss 
     44  1.1  augustss #define CMS_DATA1 0x02 /* for chip 1, voices 6-11 */
     45  1.1  augustss #define CMS_ADDR1 0x03
     46  1.1  augustss 
     47  1.1  augustss #define CMS_MREG  0x04 /* always returns 0x7f */
     48  1.1  augustss #define CMS_WREG  0x07 /* writable register */
     49  1.1  augustss #define CMS_RREG  0x0b /* readable register */
     50  1.1  augustss 
     51  1.1  augustss #define CMS_IOSIZE 16
     52  1.1  augustss 
     53  1.1  augustss /*
     54  1.1  augustss  * Note that for each register, if ports CMS_DATA1/CMS_ADDR1 are used
     55  1.1  augustss  * then the first voice is modified.  If ports CMS_DATA2/CMS_ADDR2 are
     56  1.1  augustss  * used then the second voice is modified.
     57  1.1  augustss  */
     58  1.1  augustss 
     59  1.1  augustss /*
     60  1.1  augustss  * Each voice can have a volume between 0 and 15 on both left and
     61  1.1  augustss  * right channels.  The high-order nibble is the right channel volume,
     62  1.1  augustss  * and the low-order nibble is the left channel volume.
     63  1.1  augustss  */
     64  1.1  augustss 
     65  1.1  augustss #define CMS_IREG_VOL0 0x00
     66  1.1  augustss #define CMS_IREG_VOL1 0x01
     67  1.1  augustss #define CMS_IREG_VOL2 0x02
     68  1.1  augustss #define CMS_IREG_VOL3 0x03
     69  1.1  augustss #define CMS_IREG_VOL4 0x04
     70  1.1  augustss #define CMS_IREG_VOL5 0x05
     71  1.1  augustss 
     72  1.1  augustss /* Frequency registers */
     73  1.1  augustss #define CMS_IREG_FREQ0 0x08
     74  1.1  augustss #define CMS_IREG_FREQ1 0x09
     75  1.1  augustss #define CMS_IREG_FREQ2 0x0a
     76  1.1  augustss #define CMS_IREG_FREQ3 0x0b
     77  1.1  augustss #define CMS_IREG_FREQ4 0x0c
     78  1.1  augustss #define CMS_IREG_FREQ5 0x0d
     79  1.1  augustss 
     80  1.1  augustss /*
     81  1.1  augustss  * Octave Registers: To get tones in higher octaves the octave
     82  1.1  augustss  * register for the voice must be set.  Each octave register stores
     83  1.1  augustss  * the octave number for two voices.  The high-order nibble is for
     84  1.1  augustss  * first voice and the low-order nibble is for the second voice.
     85  1.1  augustss  */
     86  1.1  augustss 
     87  1.1  augustss #define CMS_IREG_OCTAVE_1_0 0x10
     88  1.1  augustss #define CMS_IREG_OCTAVE_3_2 0x11
     89  1.1  augustss #define CMS_IREG_OCTAVE_5_4 0x12
     90  1.1  augustss 
     91  1.1  augustss #define CMS_IREG_FREQ_CTL 0x14 /* voice frequencies */
     92  1.1  augustss #define CMS_IREG_FREQ_ENBL0 0x01 /* setting the bit enables the voice */
     93  1.1  augustss #define CMS_IREG_FREQ_ENBL1 0x02 /* clearing the bit disables the voice */
     94  1.1  augustss #define CMS_IREG_FREQ_ENBL2 0x04
     95  1.1  augustss #define CMS_IREG_FREQ_ENBL3 0x08
     96  1.1  augustss #define CMS_IREG_FREQ_ENBL4 0x10
     97  1.1  augustss #define CMS_IREG_FREQ_ENBL5 0x20
     98  1.1  augustss 
     99  1.1  augustss /*
    100  1.1  augustss  * There are 4 noise generators, each noise generator can be connected
    101  1.1  augustss  * up to any of three voices:
    102  1.1  augustss  *
    103  1.1  augustss  * Noise generator 0: connected to voices 0,1,2
    104  1.1  augustss  *                 1: connected to voices 3,4,5
    105  1.1  augustss  *                 2: connected to voices 6,7,8
    106  1.1  augustss  *                 3: connected to voices 0,10,11
    107  1.1  augustss  *
    108  1.1  augustss  * CMS_DATA1/CMS_ADDR1 access noise generators 0 and 1.  Each noise
    109  1.1  augustss  * generator has two bits which control the noise generator rate.
    110  1.1  augustss  */
    111  1.1  augustss 
    112  1.1  augustss #define CMS_IREG_NOISE_CTL 0x15 /* noises */
    113  1.1  augustss #define CMS_IREG_NOISE_ENBL0 0x01
    114  1.1  augustss #define CMS_IREG_NOISE_ENBL1 0x02
    115  1.1  augustss #define CMS_IREG_NOISE_ENBL2 0x04
    116  1.1  augustss #define CMS_IREG_NOISE_ENBL3 0x08
    117  1.1  augustss #define CMS_IREG_NOISE_ENBL4 0x10
    118  1.1  augustss #define CMS_IREG_NOISE_ENBL5 0x20
    119  1.1  augustss 
    120  1.1  augustss #define CMS_IREG_NOISE_BW 0x16
    121  1.1  augustss #define CMS_IREG_NOISE_MASK0 0x03 /* bits for noise generator 0 */
    122  1.1  augustss #define CMS_IREG_NOISE_MASK1 0x30 /* bits for noise generator 1 */
    123  1.1  augustss /* the bits in the mask have the following meaning */
    124  1.1  augustss #define CMS_IREG_NOISE_MASK_28k 0 /* 28kHz */
    125  1.1  augustss #define CMS_IREG_NOISE_MASK_14k 1 /* 14kHz */
    126  1.1  augustss #define CMS_IREG_NOISE_MASK_7k  2 /* 6.8kHz */
    127  1.1  augustss 
    128  1.1  augustss #define CMS_IREG_SYS_CTL 0x1c
    129  1.1  augustss #define CMS_IREG_SYS_ENBL  0x01 /* enable all channels */
    130  1.1  augustss #define CMS_IREG_SYS_RESET 0x02 /* reset and synchronise generators */
    131  1.1  augustss 
    132  1.1  augustss 
    133  1.1  augustss /*
    134  1.1  augustss  * Some useful macros
    135  1.1  augustss  */
    136  1.1  augustss 
    137  1.1  augustss #define CMS_WRITE(sc, chip, reg, val)					\
    138  1.1  augustss do {									\
    139  1.1  augustss 	(sc)->sc_shadowregs[((chip)<<5) + (reg)] = val;			\
    140  1.1  augustss 	bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh,			\
    141  1.1  augustss 		CMS_ADDR0 + ((chip)<<1), (reg));			\
    142  1.1  augustss 	bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh,			\
    143  1.1  augustss 		CMS_DATA0 + ((chip)<<1), (val));			\
    144  1.1  augustss } while (0)
    145  1.1  augustss 
    146  1.1  augustss #define CMS_READ(sc, chip, reg) ((sc)->sc_shadowregs[((chip)<<5) + (reg)])
    147  1.1  augustss 
    148  1.1  augustss #define CHAN_TO_CHIP(chan) ((chan)>5)
    149  1.1  augustss #define CHAN_TO_VOICE(chan) ((chan)%6)
    150  1.1  augustss #define OCTAVE_OFFSET(voice) ((voice)>>1)
    151  1.1  augustss #define OCTAVE_SHIFT(voice) (((voice)&1)<<2)
    152