msb_data.h

Go to the documentation of this file.
00001 /*
00002  *  MSB_MACROS.H
00003  *
00004  *    Copyright © Digital Equipment Corporation, 1994 All Rights Reserved.
00005  *    Unpublished rights reserved under the copyright laws of the United States.
00006  * 
00007  *    The software contained on this media is proprietary to and embodies the
00008  *    confidential technology of Digital Equipment Corporation.  Possession, use,
00009  *    duplication or dissemination of the software and media is authorized only
00010  *    pursuant to a valid written license from Digital Equipment Corporation.
00011  * 
00012  *    RESTRICTED RIGHTS LEGEND   Use, duplication, or disclosure by the U.S.
00013  *    Government is subject to restrictions as set forth in Subparagraph
00014  *    (c)(1)(ii) of DFARS 252.227-7013, or in FAR 52.227-19, as applicable.
00015  * 
00016  *    -----------------------------------------------------------------------
00017  *
00018  * ABSTRACT:
00019  *
00020  *      Non-public data structure definitions and tables for the MSB driver.
00021  *
00022  * AUTHOR:
00023  *
00024  *      W.D. Arbo, March 1994.  
00025  *
00026  * MODIFIED BY:
00027  *
00028  *      X-1     WDA             W.D.Arbo                8-Mar-1994
00029  *              Original version, borrowed some from OSF/1.
00030  *
00031  */
00032 
00033 #ifndef _MSB_DATA_H
00034 #define _MSB_DATA_H
00035 
00036 #include "msb.h"
00037 #include "msb_reg.h"
00038 #include <ints.h>
00039 #include <ucbdef.h>
00040 
00041 /* 
00042  * Use OSF names for the DMA register offsets - they are clearer and more
00043  * consistent than the VMS names.  (SDL does not generate offset names for 
00044  * C at all, just a structure, and I've chosen to use the OSF/1 include file
00045  * rather than add symbols to the SDL file for the confusing names.)
00046  */
00047 
00048 /*----------------------------*/
00049 /* EISA data sizes and masks. */
00050 /*----------------------------*/
00051 #define EISA_B1         1
00052 #define EISA_B2         2
00053 #define EISA_B4         4
00054 #define EISA_B5         5
00055 #define EISA_B6         6
00056 #define EISA_B8         8
00057 #define EISA_BYTE       0x0     /*  8 bits */
00058 #define EISA_WORD       0x1     /* 16 bits */
00059 #define EISA_DWORD      0x2     /* 32 bits */
00060 
00061 #define EISA_B1_MASK    0x1
00062 #define EISA_B2_MASK    0x3
00063 #define EISA_B4_MASK    0xF
00064 #define EISA_B5_MASK    0x1F
00065 #define EISA_B6_MASK    0x3F
00066 #define EISA_BYTE_MASK  0xff
00067 #define EISA_WORD_MASK  0xffff
00068 #define EISA_DWORD_MASK 0xffffffff
00069 #define EISA_B16        16
00070 
00071 /*------------------------------------------------*/
00072 /* EISA DMA Registers. CT1 refers to channels 0-3 */
00073 /* and CT2 refers to channels 4-7.                */
00074 /*------------------------------------------------*/
00075 #define EISA_DMA_CT1_CMD        0x08
00076 #define EISA_DMA_CT2_CMD        0xD0
00077 #define EISA_DMA_CT1_MODE       0x0B
00078 #define EISA_DMA_CT2_MODE       0xD6
00079 #define EISA_DMA_CT1_EMODE      0x40B
00080 #define EISA_DMA_CT2_EMODE      0x4D6
00081 #define EISA_DMA_CT1_REQ        0x09
00082 #define EISA_DMA_CT2_REQ        0x0D2
00083 #define EISA_DMA_CT1_SMASK      0x0A
00084 #define EISA_DMA_CT2_SMASK      0xD4
00085 #define EISA_DMA_CT1_AMASK      0x0F
00086 #define EISA_DMA_CT2_AMASK      0xDE
00087 #define EISA_DMA_CT1_STATUS     0x08
00088 #define EISA_DMA_CT2_STATUS     0xD0
00089 #define EISA_DMA_CT1_CHAIN      0x40A
00090 #define EISA_DMA_CT2_CHAIN      0x4D4
00091 #define EISA_DMA_CHAIN_STAT     0x4D4
00092 #define EISA_DMA_INTR_STATUS    0x40A
00093 #define EISA_DMA_CHAIN_EXP      0x40C
00094 #define EISA_DMA_CT1_CLR_BYTE_P 0x0C
00095 #define EISA_DMA_CT2_CLR_BYTE_P 0x0D8
00096 #define EISA_DMA_CT1_MCLR       0x0D
00097 #define EISA_DMA_CT2_MCLR       0x0DA
00098 #define EISA_DMA_CT1_CLR_MASK   0x0E
00099 #define EISA_DMA_CT2_CLR_MASK   0x0DC
00100 #define EISA_DMA_CH0_BASE_CNT   0x01
00101 #define EISA_DMA_CH1_BASE_CNT   0x03
00102 #define EISA_DMA_CH2_BASE_CNT   0x05
00103 #define EISA_DMA_CH3_BASE_CNT   0x07
00104 #define EISA_DMA_CH5_BASE_CNT   0x0C6
00105 #define EISA_DMA_CH6_BASE_CNT   0x0CA
00106 #define EISA_DMA_CH7_BASE_CNT   0x0CE
00107 #define EISA_DMA_CH0_HIGH_CNT   0x0401
00108 #define EISA_DMA_CH1_HIGH_CNT   0x0403
00109 #define EISA_DMA_CH2_HIGH_CNT   0x0405
00110 #define EISA_DMA_CH3_HIGH_CNT   0x0407
00111 #define EISA_DMA_CH5_HIGH_CNT   0x04C6
00112 #define EISA_DMA_CH6_HIGH_CNT   0x04CA
00113 #define EISA_DMA_CH7_HIGH_CNT   0x04CE
00114 #define EISA_DMA_CH0_BASE_ADDR  0x000
00115 #define EISA_DMA_CH1_BASE_ADDR  0x002
00116 #define EISA_DMA_CH2_BASE_ADDR  0x004
00117 #define EISA_DMA_CH3_BASE_ADDR  0x006
00118 #define EISA_DMA_CH5_BASE_ADDR  0x0C4
00119 #define EISA_DMA_CH6_BASE_ADDR  0x0C8
00120 #define EISA_DMA_CH7_BASE_ADDR  0x0CC
00121 #define EISA_DMA_CH0_LOW_ADDR   0x087
00122 #define EISA_DMA_CH1_LOW_ADDR   0x083
00123 #define EISA_DMA_CH2_LOW_ADDR   0x081
00124 #define EISA_DMA_CH3_LOW_ADDR   0x082
00125 #define EISA_DMA_CH5_LOW_ADDR   0x08B
00126 #define EISA_DMA_CH6_LOW_ADDR   0x089
00127 #define EISA_DMA_CH7_LOW_ADDR   0x08A
00128 #define EISA_DMA_CH0_HIGH_ADDR  0x487
00129 #define EISA_DMA_CH1_HIGH_ADDR  0x483
00130 #define EISA_DMA_CH2_HIGH_ADDR  0x481
00131 #define EISA_DMA_CH3_HIGH_ADDR  0x482
00132 #define EISA_DMA_CH5_HIGH_ADDR  0x48B
00133 #define EISA_DMA_CH6_HIGH_ADDR  0x489
00134 #define EISA_DMA_CH7_HIGH_ADDR  0x48A
00135 
00136 /*
00137  * These constants are used instead of the OSF/1 macros, which
00138  * take a base address arg.  MSB_REG_CONFIG is equivalent
00139  * to MSB_CODEC_CONFIG(0).
00140  */
00141 #define MSB_REG_CONFIG              0       /* MSB_CONFIG (0)       */
00142 #define MSB_REG_STATUS              3       /* MSB_VERSION (0)      */
00143 #define MSB_REG_CODEC_ADDRESS       4       /* MSB_CODEC_ADDR (0)   */
00144 #define MSB_REG_CODEC_DATA          5       /* MSB_CODEC_DATA (0)   */
00145 #define MSB_REG_CODEC_STATUS        6       /* MSB_CODEC_STATUS (0) */
00146 #define MSB_REG_CODEC_PIO           7       /* MSB_CODEC_PIO (0)    */
00147 #define MSB_REG_MIDI_STATUS         0       /* 388h r/o */
00148 #define MSB_REG_MIDI_ADDRESS0       0       /* 388h w/o */
00149 #define MSB_REG_MIDI_DATA0          1       /* 389h w/o */
00150 #define MSB_REG_MIDI_ADDRESS1       0       /* 38ah w/o */
00151 #define MSB_REG_MIDI_DATA1          3       /* 38bh w/o */
00152 
00153 /* 
00154  * Identifiers which should be in STDIO - which we don't want to include
00155  * in order to avoid initialization routines 
00156  */
00157 
00158 #ifndef TRUE
00159 # define TRUE           1
00160 #endif
00161 #ifndef FALSE
00162 # define FALSE          0
00163 #endif
00164 
00165 /*
00166  * Define ringbuffer info
00167  */
00168 #define MSB_RINGBUFFER_SIZE     (1<<15)         /* 32KB */
00169 #define MSB_RINGBUFFER_SIZE_8KPAGES  4
00170 
00171 /*
00172  * Current gain settings for each channel
00173  */
00174 typedef struct {
00175     int                 value_left;      /* Left, Gain value (1/10 dB) */
00176     int                 value_right;     /* Right, Gain value (1/10 dB) */
00177     msb_enable_type     enable_left;     /* Left, mute on/off */
00178     msb_enable_type     enable_right;    /* Right, mute on/off */
00179 } msb_gain_info_t;
00180 
00181 /*
00182  * Codes for set_gain_* functions
00183  */
00184 typedef enum
00185 {
00186     MSB_GAIN_SAVE,                      /* Save new gain */
00187     MSB_GAIN_RESTORE,                   /* Restore previously saved gain */
00188     MSB_GAIN_NOSAVE                     /* Just set gain, don't save it */
00189 } msb_gain_save_t;
00190 
00191 /*
00192  * Number of ringbuffer loops to wait before expiring keepalive timer
00193  */
00194 #define KEEPALIVE_COUNT_MAX     2
00195 
00196 /*
00197  * Initialize the table of valid rate frequencies for use in setting the
00198  * Clock Source and Clock Frequency Divide Select registers.
00199  */
00200 
00201 uint32   msb_rate_clocks [MSB_RATE_TOTAL] = {   /*  Table offset            kHz value   */
00202                             5512,               /* MSB_RATE_5512_5          5.125       */
00203                             6615,               /* MSB_RATE_6615            6.615       */
00204                             8000,               /* MSB_RATE_8000            8.0         */
00205                             9600,               /* MSB_RATE_9600            9.6         */
00206                             11025,              /* MSB_RATE_11025           11.025      */
00207                             16000,              /* MSB_RATE_16000           16.0        */
00208                             18900,              /* MSB_RATE_18900           18.9        */
00209                             22050,              /* MSB_RATE_22050           22.05       */
00210                             27428,              /* MSB_RATE_27428_57        27.42857    */
00211                             32000,              /* MSB_RATE_32000           32.0        */
00212                             33075,              /* MSB_RATE_33075           33.075      */
00213                             37800,              /* MSB_RATE_37800           37.8        */
00214                             44100,              /* MSB_RATE_44100           44.1        */
00215                             48000,              /* MSB_RATE_48000           48.0        */
00216                             };
00217 
00218 /*
00219  * Define gain limits, in units of 1/10 dB.
00220  *
00221  * All input channels have the same gain limits.
00222  * The microphone input has an additional gain boost.
00223  * Aux channels have gains going into the final output stage.
00224  * All output channels have the same gain limits.
00225  * All channels use the same step value for gain increments or decrements.
00226  */
00227 #define GAIN_INPUT_MAX           225    /* max gain on input select */
00228 #define GAIN_INPUT_MIN             0    /* min gain on input select */
00229 #define GAIN_INPUT_MIC_BOOST     200    /* gain boost on mic input signal */
00230 #define GAIN_OUTPUT_AUX_MAX_J      0    /* max aux atten for J-grade */
00231 #define GAIN_OUTPUT_AUX_MIN_J  (-225)   /* min aux atten for J-grade */
00232 #define GAIN_OUTPUT_AUX_MAX_K    120    /* max aux atten for J-grade */
00233 #define GAIN_OUTPUT_AUX_MIN_K  (-345)   /* min aux atten for K-grade */
00234 #define GAIN_OUTPUT_MAX            0    /* max gain on output select */
00235 #define GAIN_OUTPUT_MIN         -945    /* minimum gain on output select */
00236 #define MSB_GAIN_STEP             15    /* step value for all channels */
00237 #define MSB_GAIN_DIVIDER          10    /* from specified to real dB value */
00238 
00239 #define MSB_CHANNEL_INPUT_FIRST     MSB_LINE_SRC
00240 #define MSB_CHANNEL_INPUT_LAST      MSB_PM_DAC_SRC
00241 #define MSB_CHANNEL_OUTPUT_FIRST    MSB_AUX1
00242 #define MSB_CHANNEL_OUTPUT_LAST     MSB_MIX_CTL
00243 
00244 #define MSB_RATE_DEFAULT                MSB_RATE_8000
00245 #define MSB_FORMAT_DEFAULT              MSB_FORMAT_PCM_16
00246 #define MSB_MODE_DEFAULT                MSB_MODE_MONO
00247 
00248 msb_gain_limits_t     msb_gain_limits_jgrade =   
00249             {   
00250               GAIN_INPUT_MIN, GAIN_INPUT_MAX, 15,                         /* MSB_LINE_SRC    */
00251               GAIN_INPUT_MIN, GAIN_INPUT_MAX, 15,                         /* MSB_AUX1_SRC    */
00252               GAIN_INPUT_MIN, GAIN_INPUT_MAX + GAIN_INPUT_MIC_BOOST, 15,  /* MSB_MIC_SRC     */
00253               GAIN_INPUT_MIN, GAIN_INPUT_MAX, 15,                         /* MSB_PM_DAC_SRC  */
00254               GAIN_OUTPUT_AUX_MIN_J, GAIN_OUTPUT_AUX_MAX_J, -15,          /* MSB_AUX1        */
00255               GAIN_OUTPUT_AUX_MIN_J, GAIN_OUTPUT_AUX_MAX_J, -15,          /* MSB_AUX2        */
00256               GAIN_OUTPUT_MIN, GAIN_OUTPUT_MAX, -15,                      /* MSB_DAC         */
00257               GAIN_OUTPUT_MIN, GAIN_OUTPUT_MAX, -15                       /* MSB_MIX_CTL     */
00258             };    
00259 
00260 /*  Table of gain limits for K - Grade cards */
00261 
00262 msb_gain_limits_t     msb_gain_limits_kgrade =   
00263             {   
00264               GAIN_INPUT_MIN, GAIN_INPUT_MAX, 15,                         /* MSB_LINE_SRC    */
00265               GAIN_INPUT_MIN, GAIN_INPUT_MAX, 15,                         /* MSB_AUX1_SRC    */
00266               GAIN_INPUT_MIN, GAIN_INPUT_MAX + GAIN_INPUT_MIC_BOOST, 15,  /* MSB_MIC_SRC     */
00267               GAIN_INPUT_MIN, GAIN_INPUT_MAX, 15,                         /* MSB_PM_DAC_SRC  */
00268               GAIN_OUTPUT_AUX_MIN_K, GAIN_OUTPUT_AUX_MAX_K, -15,          /* MSB_AUX1        */
00269               GAIN_OUTPUT_AUX_MIN_K, GAIN_OUTPUT_AUX_MAX_K, -15,          /* MSB_AUX2        */
00270               GAIN_OUTPUT_MIN, GAIN_OUTPUT_MAX, -15,                      /* MSB_DAC         */
00271               GAIN_OUTPUT_MIN, GAIN_OUTPUT_MAX, -15                       /* MSB_MIX_CTL     */
00272             };    
00273 
00274 /*
00275  * Create a table to access DMA registers. The index is the channel number.
00276  * Each entry in the table contains register offsets for all the registers
00277  * which are channel specific.  Entries are not needed for the Write Mode
00278  * register, the Extended Write Mode register, the Clear byte pointer Filp/Flop
00279  * register or the Write Single Mask Bit register, because these are the same
00280  * for channels 0-3.  (The MSB board can only use channels 0 thru 3).  The VMS
00281  * names for the register offsets are listed in the comments.  OSF names are used
00282  * because they are clearer.
00283  */
00284 struct {
00285     int     base_addr;      /* DMAx Base and Current Address   (EISA$B_DMA1_CHx_BASE_ADDR) */
00286     int     low_addr;       /* DMA Page Register               (EISA$B_DMA_PAGE_CHx)       */
00287     int     high_addr;      /* DMA High Page Register          (EISA$B_DMA_CHx_PAGE_HIGH)  */
00288     int     base_cnt;       /* DMAx Base and Current Count     (EISA$B_DMA_CHx_BASE_CNT)   */
00289     int     high_cnt;       /* DMAx Base/Current Count High    (EISA$B_DMA_CHx_CNT)        */
00290     } dmareg[4]        = { {EISA_DMA_CH0_BASE_ADDR,          /* Channel 0 */
00291                             EISA_DMA_CH0_LOW_ADDR,
00292                             EISA_DMA_CH0_HIGH_ADDR,
00293                             EISA_DMA_CH0_BASE_CNT,
00294                             EISA_DMA_CH0_HIGH_CNT
00295                            },
00296                            {EISA_DMA_CH1_BASE_ADDR,          /* Channel 1 */
00297                             EISA_DMA_CH1_LOW_ADDR,
00298                             EISA_DMA_CH1_HIGH_ADDR,
00299                             EISA_DMA_CH1_BASE_CNT,
00300                             EISA_DMA_CH1_HIGH_CNT
00301                            },
00302                            {0,0,0,0,0                        /* Channel 2 - never used by the MSB*/
00303                            },
00304                            {EISA_DMA_CH3_BASE_ADDR,          /* Channel 3 */
00305                             EISA_DMA_CH3_LOW_ADDR,
00306                             EISA_DMA_CH3_HIGH_ADDR,
00307                             EISA_DMA_CH3_BASE_CNT,
00308                             EISA_DMA_CH3_HIGH_CNT
00309                            }
00310                          };
00311 
00312 /* Structures which describe DMA registers */
00313 
00314     union               /* Mode Register (EISA_DMA_CT1_MODE) */
00315         {
00316         int atom;
00317         struct {
00318             uint32  chan      : 2;
00319             uint32  xfer      : 2;
00320             uint32  autoinit  : 1;
00321             uint32  decrement : 1;
00322             uint32  mode      : 2;
00323             } bits;
00324          } mode;
00325 
00326     union               /* Extended Mode Register (EISA_DMA_CT1_EMODE) */
00327         {
00328         int atom;
00329         struct {
00330             uint32  chan    : 2;
00331             uint32  xfer    : 2;
00332             uint32  timing  : 2;
00333             uint32  eop     : 1;
00334             uint32  stop    : 1;
00335             } bits;
00336          } emode;
00337 
00338 /* Codes to describe io mode, for use with DMA support routines */
00339 
00340 typedef enum { DMA_IO_READ, DMA_IO_WRITE } io_mode;
00341 
00342 /* UCB extensions */
00343 
00344 typedef struct  {                               
00345                 UCB                     ucb$r_ucb;                      /* Common UCB */
00346                 uint64                  msb_base;                       /* Starting IO port address assigend to MSB */
00347                 uint64                  dma_iohandle;                   /* IO Handle for DMA from ioc$map_io */
00348                 uint64                  msb_iohandle;                   /* IO Handle for MSB from ioc$map_io */
00349                 uint64                  midi_iohandle;                  /* IO Handle for MIDI from ioc$map_io */
00350                 __int64                 ringbuffer_read_phys;           /* Physical Address of read ring buffer */
00351                 __int64                 ringbuffer_write_phys;          /* Physical Address of read write buffer */
00352                 void                    *ringbuffer_read;               /* Pointer to read ring buffer  */
00353                 void                    *ringbuffer_write;              /* Pointer to write ring buffer */
00354                 uint32                  active_read;                    /* Read in Progress */
00355                 uint32                  active_write;                   /* Write in Progress */
00356                 uint32                  irq;                            /* IRQ for this unit */
00357                 uint32                  dma_read;                       /* DMA read channel */
00358                 uint32                  dma_write;                      /* DMA write channel */
00359                 msb_channel_types       input_right;                    /* Right Channel */
00360                 msb_channel_types       input_left;                     /* Left Channel */
00361                 msb_dev_info_t          msb_dev_info;                   /* Device data */
00362                 msb_io_info_t           msb_io_info;                    /* Buffer size and address data */
00363                 msb_gain_info_t         msb_gain_info[MSB_CHANNEL_TOTAL];      /* Gain data for save/restore */
00364                 msb_limits_t            *msb_gain_limits;               /* Gain limits table */
00365                 msb_sample_type_t       msb_sample_type;                /* Format, rate, mode */
00366 } MSB_UCB;
00367 
00368 #endif                          /* !def _MSB_DATA_H */

SourceForge.net Logo
Project space on SourceForge.net