msb_macros.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  * AUTHOR:
00021  *
00022  *      W.D. Arbo, March 1994.  
00023  *
00024  * MODIFIED BY:
00025  *
00026  *      X-1     WDA             W.D.Arbo                8-Mar-1994
00027  *              Original version.
00028  *
00029  */
00030 
00031 #ifndef _MSB_MACROS_H
00032 #define _MSB_MACROS_H
00033 
00034 
00035 /* 
00036  * Macros for moving data into and out of the correct byte lanes 
00037  */
00038  
00039 #define put_lane(_data,_offset) {_data <<= ((_offset & 3) * 8);}
00040 #define get_lane(_data,_offset) {_data >>= ((_offset & 3) * 8); _data &= 0x000000ff;}
00041 
00042 /*
00043  * Normalize gain value into range allowed by specified channel.
00044  */
00045 
00046 #define gain_normalize( ucb_ptr, channel, value)                        \
00047     {                                                                   \
00048     if (value > ucb_ptr->msb_gain_limits[channel].max)                  \
00049       value = ucb_ptr->msb_gain_limits[channel].max;                    \
00050                                                                         \
00051     if (value < ucb_ptr->msb_gain_limits[channel].min)                  \
00052       value = ucb_ptr->msb_gain_limits[channel].min;                    \
00053     }
00054 
00055 /*
00056  * Write to an indirect register in the CODEC (AD1848).  This macro copies 
00057  * the input data into a temporary variable, and shifts it into
00058  * the correct byte lane.  The original data is not modified.
00059  * The value must be in bits 7:0 of _data.
00060  *
00061  * The first write to the address register selects the indirect register.  
00062  * The second write, to the data register, writes the data to 
00063  * the previously selected indirect register.
00064  *
00065  * Note:  A pointer to an MSB_UCB named ucb_ptr is an implicit input.
00066  */
00067 #define write_codec( _indirect_reg_offset, _data)                       \
00068 {                                                                       \
00069     int _reg, _status,__data;                                           \
00070     __data = _data;                                                     \
00071     _reg = _indirect_reg_offset;                                        \
00072     put_lane(_reg, MSB_REG_CODEC_ADDRESS);                              \
00073     _status = ioc$write_io ( ucb_ptr->ucb$r_ucb.ucb$ps_adp,             \
00074                             &ucb_ptr->msb_iohandle,                     \
00075                             MSB_REG_CODEC_ADDRESS,                      \
00076                             1,                                          \
00077                             &_reg );                                    \
00078     put_lane(__data, MSB_REG_CODEC_DATA);                               \
00079     _status = ioc$write_io ( ucb_ptr->ucb$r_ucb.ucb$ps_adp,             \
00080                             &ucb_ptr->msb_iohandle,                     \
00081                             MSB_REG_CODEC_DATA,                         \
00082                             1,                                          \
00083                             &__data );                                  \
00084 }
00085 
00086 /*
00087  * Read from an indirect register in the CODEC (AD1848). 
00088  * The first write to the address register selects the indirect register.  
00089  * The read captures data from the previously selected indirect register.
00090  * The data is then shifted into bits 7:0 of _data.  A mask is applied
00091  * by get_lane so that bits 31:8 are guaranteed to be zero.
00092  *
00093  * Note:  A pointer to an MSB_UCB named ucb_ptr is an implicit input.
00094  */
00095 #define read_codec( _indirect_reg_offset, _data )                       \
00096 {                                                                       \
00097     int _status, _reg;                                                  \
00098     _reg = _indirect_reg_offset;                                        \
00099     put_lane(_reg, MSB_REG_CODEC_ADDRESS);                              \
00100     _status = ioc$write_io ( ucb_ptr->ucb$r_ucb.ucb$ps_adp,             \
00101                             &ucb_ptr->msb_iohandle,                     \
00102                             MSB_REG_CODEC_ADDRESS,                      \
00103                             1,                                          \
00104                             &_reg );                                    \
00105     _status = ioc$read_io  ( ucb_ptr->ucb$r_ucb.ucb$ps_adp,             \
00106                             &ucb_ptr->msb_iohandle,                     \
00107                             MSB_REG_CODEC_DATA,                         \
00108                             1,                                          \
00109                             &_data );                                   \
00110     get_lane (_data, MSB_REG_CODEC_DATA);                               \
00111 }
00112 
00113 /*
00114  * Write to the DMA engine (Intel 82357 or 82378IB).  This macro copies 
00115  * the input data into a temporary variable, and shifts it into
00116  * the correct byte lane.  The original data is not modified.
00117  * The value must be in bits 7:0 of _data.
00118  *
00119  * Note:  A pointer to an MSB_UCB named ucb_ptr is an implicit input.
00120  */
00121 #define write_dma( _reg_offset, _data )                                 \
00122 {                                                                       \
00123     int _status,__data;                                                 \
00124     __data=_data;                                                       \
00125     put_lane(__data, _reg_offset);                                      \
00126     _status = ioc$write_io ( ucb_ptr->ucb$r_ucb.ucb$ps_adp,             \
00127                             &ucb_ptr->dma_iohandle,                     \
00128                             _reg_offset,                                \
00129                             1,                                          \
00130                             &__data );                                  \
00131 }
00132 
00133 /* 
00134  * Macros for driver debugging 
00135  */
00136  
00137 #ifdef MSB__DEBUG
00138 
00139  /* Temporary for pre-Zeta use with inner mode printf */
00140  int        printf      (const char *__format, ...);
00141  int        putchar     (int __c);
00142 
00143  /* The global cell containing the value of the USERD1 sysboot param */
00144  extern int SGN$GL_USERD1;
00145 
00146  void ini$brk();
00147 
00148  /* The following constants are used with debug_break */
00149 
00150  #define MSBDBG$$_TABLE         0x0000001
00151  #define MSBDBG$$_CTRLINIT      0x0000002
00152  #define MSBDBG$$_UNITINIT      0x0000004
00153  #define MSBDBG$$_UNITINITFORK  0x0000008
00154  #define MSBDBG$$_CHANNELASSIGN 0X0000010
00155  #define MSBDBG$$_CANCEL        0x0000020
00156  #define MSBDBG$$_INT           0x0000040
00157  #define MSBDBG$$_IOCTL         0x0000080
00158 
00159  #define debug_break(bit_mask)                              \
00160     { if ( (bit_mask) & SGN$GL_USERD1) ini$brk(); }
00161 
00162  #define debug_printf(_printf_args) printf _printf_args 
00163 
00164 #else
00165 
00166  #define debug_break(bit_num) {}
00167  #define debug_printf(_printf_args) {}
00168 
00169 #endif
00170 
00171 #endif                          /* !def _MSB_MACROS_H */

SourceForge.net Logo
Project space on SourceForge.net