Back to home page

OSCL-LXR

 
 

    


0001 /****************************************************************************
0002 
0003    Copyright Echo Digital Audio Corporation (c) 1998 - 2004
0004    All rights reserved
0005    www.echoaudio.com
0006 
0007    This file is part of Echo Digital Audio's generic driver library.
0008 
0009    Echo Digital Audio's generic driver library is free software;
0010    you can redistribute it and/or modify it under the terms of
0011    the GNU General Public License as published by the Free Software
0012    Foundation.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017    GNU General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program; if not, write to the Free Software
0021    Foundation, Inc., 59 Temple Place - Suite 330, Boston,
0022    MA  02111-1307, USA.
0023 
0024    *************************************************************************
0025 
0026  Translation from C++ and adaptation for use in ALSA-Driver
0027  were made by Giuliano Pochini <pochini@shiny.it>
0028 
0029 ****************************************************************************/
0030 
0031 #ifndef _ECHO_DSP_
0032 #define _ECHO_DSP_
0033 
0034 
0035 /**** Echogals: Darla20, Gina20, Layla20, and Darla24 ****/
0036 #if defined(ECHOGALS_FAMILY)
0037 
0038 #define NUM_ASIC_TESTS      5
0039 #define READ_DSP_TIMEOUT    1000000L    /* one second */
0040 
0041 /**** Echo24: Gina24, Layla24, Mona, Mia, Mia-midi ****/
0042 #elif defined(ECHO24_FAMILY)
0043 
0044 #define DSP_56361           /* Some Echo24 cards use the 56361 DSP */
0045 #define READ_DSP_TIMEOUT    100000L     /* .1 second */
0046 
0047 /**** 3G: Gina3G, Layla3G ****/
0048 #elif defined(ECHO3G_FAMILY)
0049 
0050 #define DSP_56361
0051 #define READ_DSP_TIMEOUT    100000L     /* .1 second */
0052 #define MIN_MTC_1X_RATE     32000
0053 
0054 /**** Indigo: Indigo, Indigo IO, Indigo DJ ****/
0055 #elif defined(INDIGO_FAMILY)
0056 
0057 #define DSP_56361
0058 #define READ_DSP_TIMEOUT    100000L     /* .1 second */
0059 
0060 #else
0061 
0062 #error No family is defined
0063 
0064 #endif
0065 
0066 
0067 
0068 /*
0069  *
0070  *  Max inputs and outputs
0071  *
0072  */
0073 
0074 #define DSP_MAXAUDIOINPUTS      16  /* Max audio input channels */
0075 #define DSP_MAXAUDIOOUTPUTS     16  /* Max audio output channels */
0076 #define DSP_MAXPIPES            32  /* Max total pipes (input + output) */
0077 
0078 
0079 /*
0080  *
0081  * These are the offsets for the memory-mapped DSP registers; the DSP base
0082  * address is treated as the start of a u32 array.
0083  */
0084 
0085 #define CHI32_CONTROL_REG       4
0086 #define CHI32_STATUS_REG        5
0087 #define CHI32_VECTOR_REG        6
0088 #define CHI32_DATA_REG          7
0089 
0090 
0091 /*
0092  *
0093  * Interesting bits within the DSP registers
0094  *
0095  */
0096 
0097 #define CHI32_VECTOR_BUSY       0x00000001
0098 #define CHI32_STATUS_REG_HF3        0x00000008
0099 #define CHI32_STATUS_REG_HF4        0x00000010
0100 #define CHI32_STATUS_REG_HF5        0x00000020
0101 #define CHI32_STATUS_HOST_READ_FULL 0x00000004
0102 #define CHI32_STATUS_HOST_WRITE_EMPTY   0x00000002
0103 #define CHI32_STATUS_IRQ        0x00000040
0104 
0105 
0106 /* 
0107  *
0108  * DSP commands sent via slave mode; these are sent to the DSP by write_dsp()
0109  *
0110  */
0111 
0112 #define DSP_FNC_SET_COMMPAGE_ADDR       0x02
0113 #define DSP_FNC_LOAD_LAYLA_ASIC         0xa0
0114 #define DSP_FNC_LOAD_GINA24_ASIC        0xa0
0115 #define DSP_FNC_LOAD_MONA_PCI_CARD_ASIC     0xa0
0116 #define DSP_FNC_LOAD_LAYLA24_PCI_CARD_ASIC  0xa0
0117 #define DSP_FNC_LOAD_MONA_EXTERNAL_ASIC     0xa1
0118 #define DSP_FNC_LOAD_LAYLA24_EXTERNAL_ASIC  0xa1
0119 #define DSP_FNC_LOAD_3G_ASIC            0xa0
0120 
0121 
0122 /*
0123  *
0124  * Defines to handle the MIDI input state engine; these are used to properly
0125  * extract MIDI time code bytes and their timestamps from the MIDI input stream.
0126  *
0127  */
0128 
0129 #define MIDI_IN_STATE_NORMAL    0
0130 #define MIDI_IN_STATE_TS_HIGH   1
0131 #define MIDI_IN_STATE_TS_LOW    2
0132 #define MIDI_IN_STATE_F1_DATA   3
0133 #define MIDI_IN_SKIP_DATA   (-1)
0134 
0135 
0136 /*----------------------------------------------------------------------------
0137 
0138 Setting the sample rates on Layla24 is somewhat schizophrenic.
0139 
0140 For standard rates, it works exactly like Mona and Gina24.  That is, for
0141 8, 11.025, 16, 22.05, 32, 44.1, 48, 88.2, and 96 kHz, you just set the
0142 appropriate bits in the control register and write the control register.
0143 
0144 In order to support MIDI time code sync (and possibly SMPTE LTC sync in
0145 the future), Layla24 also has "continuous sample rate mode".  In this mode,
0146 Layla24 can generate any sample rate between 25 and 50 kHz inclusive, or
0147 50 to 100 kHz inclusive for double speed mode.
0148 
0149 To use continuous mode:
0150 
0151 -Set the clock select bits in the control register to 0xe (see the #define
0152  below)
0153 
0154 -Set double-speed mode if you want to use sample rates above 50 kHz
0155 
0156 -Write the control register as you would normally
0157 
0158 -Now, you need to set the frequency register. First, you need to determine the
0159  value for the frequency register.  This is given by the following formula:
0160 
0161 frequency_reg = (LAYLA24_MAGIC_NUMBER / sample_rate) - 2
0162 
0163 Note the #define below for the magic number
0164 
0165 -Wait for the DSP handshake
0166 -Write the frequency_reg value to the .SampleRate field of the comm page
0167 -Send the vector command SET_LAYLA24_FREQUENCY_REG (see vmonkey.h)
0168 
0169 Once you have set the control register up for continuous mode, you can just
0170 write the frequency register to change the sample rate.  This could be
0171 used for MIDI time code sync. For MTC sync, the control register is set for
0172 continuous mode.  The driver then just keeps writing the
0173 SET_LAYLA24_FREQUENCY_REG command.
0174 
0175 -----------------------------------------------------------------------------*/
0176 
0177 #define LAYLA24_MAGIC_NUMBER            677376000
0178 #define LAYLA24_CONTINUOUS_CLOCK        0x000e
0179 
0180 
0181 /*
0182  *
0183  * DSP vector commands
0184  *
0185  */
0186 
0187 #define DSP_VC_RESET                0x80ff
0188 
0189 #ifndef DSP_56361
0190 
0191 #define DSP_VC_ACK_INT              0x8073
0192 #define DSP_VC_SET_VMIXER_GAIN          0x0000  /* Not used, only for compile */
0193 #define DSP_VC_START_TRANSFER           0x0075  /* Handshke rqd. */
0194 #define DSP_VC_METERS_ON            0x0079
0195 #define DSP_VC_METERS_OFF           0x007b
0196 #define DSP_VC_UPDATE_OUTVOL            0x007d  /* Handshke rqd. */
0197 #define DSP_VC_UPDATE_INGAIN            0x007f  /* Handshke rqd. */
0198 #define DSP_VC_ADD_AUDIO_BUFFER         0x0081  /* Handshke rqd. */
0199 #define DSP_VC_TEST_ASIC            0x00eb
0200 #define DSP_VC_UPDATE_CLOCKS            0x00ef  /* Handshke rqd. */
0201 #define DSP_VC_SET_LAYLA_SAMPLE_RATE        0x00f1  /* Handshke rqd. */
0202 #define DSP_VC_SET_GD_AUDIO_STATE       0x00f1  /* Handshke rqd. */
0203 #define DSP_VC_WRITE_CONTROL_REG        0x00f1  /* Handshke rqd. */
0204 #define DSP_VC_MIDI_WRITE           0x00f5  /* Handshke rqd. */
0205 #define DSP_VC_STOP_TRANSFER            0x00f7  /* Handshke rqd. */
0206 #define DSP_VC_UPDATE_FLAGS         0x00fd  /* Handshke rqd. */
0207 #define DSP_VC_GO_COMATOSE          0x00f9
0208 
0209 #else /* !DSP_56361 */
0210 
0211 /* Vector commands for families that use either the 56301 or 56361 */
0212 #define DSP_VC_ACK_INT              0x80F5
0213 #define DSP_VC_SET_VMIXER_GAIN          0x00DB  /* Handshke rqd. */
0214 #define DSP_VC_START_TRANSFER           0x00DD  /* Handshke rqd. */
0215 #define DSP_VC_METERS_ON            0x00EF
0216 #define DSP_VC_METERS_OFF           0x00F1
0217 #define DSP_VC_UPDATE_OUTVOL            0x00E3  /* Handshke rqd. */
0218 #define DSP_VC_UPDATE_INGAIN            0x00E5  /* Handshke rqd. */
0219 #define DSP_VC_ADD_AUDIO_BUFFER         0x00E1  /* Handshke rqd. */
0220 #define DSP_VC_TEST_ASIC            0x00ED
0221 #define DSP_VC_UPDATE_CLOCKS            0x00E9  /* Handshke rqd. */
0222 #define DSP_VC_SET_LAYLA24_FREQUENCY_REG    0x00E9  /* Handshke rqd. */
0223 #define DSP_VC_SET_LAYLA_SAMPLE_RATE        0x00EB  /* Handshke rqd. */
0224 #define DSP_VC_SET_GD_AUDIO_STATE       0x00EB  /* Handshke rqd. */
0225 #define DSP_VC_WRITE_CONTROL_REG        0x00EB  /* Handshke rqd. */
0226 #define DSP_VC_MIDI_WRITE           0x00E7  /* Handshke rqd. */
0227 #define DSP_VC_STOP_TRANSFER            0x00DF  /* Handshke rqd. */
0228 #define DSP_VC_UPDATE_FLAGS         0x00FB  /* Handshke rqd. */
0229 #define DSP_VC_GO_COMATOSE          0x00d9
0230 
0231 #endif /* !DSP_56361 */
0232 
0233 
0234 /*
0235  *
0236  * Timeouts
0237  *
0238  */
0239 
0240 #define HANDSHAKE_TIMEOUT       20000   /* send_vector command timeout (20ms) */
0241 #define VECTOR_BUSY_TIMEOUT     100000  /* 100ms */
0242 #define MIDI_OUT_DELAY_USEC     2000    /* How long to wait after MIDI fills up */
0243 
0244 
0245 /*
0246  *
0247  * Flags for .Flags field in the comm page
0248  *
0249  */
0250 
0251 #define DSP_FLAG_MIDI_INPUT     0x0001  /* Enable MIDI input */
0252 #define DSP_FLAG_SPDIF_NONAUDIO     0x0002  /* Sets the "non-audio" bit
0253                          * in the S/PDIF out status
0254                          * bits.  Clear this flag for
0255                          * audio data;
0256                          * set it for AC3 or WMA or
0257                          * some such */
0258 #define DSP_FLAG_PROFESSIONAL_SPDIF 0x0008  /* 1 Professional, 0 Consumer */
0259 
0260 
0261 /*
0262  *
0263  * Clock detect bits reported by the DSP for Gina20, Layla20, Darla24, and Mia
0264  *
0265  */
0266 
0267 #define GLDM_CLOCK_DETECT_BIT_WORD  0x0002
0268 #define GLDM_CLOCK_DETECT_BIT_SUPER 0x0004
0269 #define GLDM_CLOCK_DETECT_BIT_SPDIF 0x0008
0270 #define GLDM_CLOCK_DETECT_BIT_ESYNC 0x0010
0271 
0272 
0273 /*
0274  *
0275  * Clock detect bits reported by the DSP for Gina24, Mona, and Layla24
0276  *
0277  */
0278 
0279 #define GML_CLOCK_DETECT_BIT_WORD96 0x0002
0280 #define GML_CLOCK_DETECT_BIT_WORD48 0x0004
0281 #define GML_CLOCK_DETECT_BIT_SPDIF48    0x0008
0282 #define GML_CLOCK_DETECT_BIT_SPDIF96    0x0010
0283 #define GML_CLOCK_DETECT_BIT_WORD   (GML_CLOCK_DETECT_BIT_WORD96 | GML_CLOCK_DETECT_BIT_WORD48)
0284 #define GML_CLOCK_DETECT_BIT_SPDIF  (GML_CLOCK_DETECT_BIT_SPDIF48 | GML_CLOCK_DETECT_BIT_SPDIF96)
0285 #define GML_CLOCK_DETECT_BIT_ESYNC  0x0020
0286 #define GML_CLOCK_DETECT_BIT_ADAT   0x0040
0287 
0288 
0289 /*
0290  *
0291  * Layla clock numbers to send to DSP
0292  *
0293  */
0294 
0295 #define LAYLA20_CLOCK_INTERNAL      0
0296 #define LAYLA20_CLOCK_SPDIF     1
0297 #define LAYLA20_CLOCK_WORD      2
0298 #define LAYLA20_CLOCK_SUPER     3
0299 
0300 
0301 /*
0302  *
0303  * Gina/Darla clock states
0304  *
0305  */
0306 
0307 #define GD_CLOCK_NOCHANGE       0
0308 #define GD_CLOCK_44         1
0309 #define GD_CLOCK_48         2
0310 #define GD_CLOCK_SPDIFIN        3
0311 #define GD_CLOCK_UNDEF          0xff
0312 
0313 
0314 /*
0315  *
0316  * Gina/Darla S/PDIF status bits
0317  *
0318  */
0319 
0320 #define GD_SPDIF_STATUS_NOCHANGE    0
0321 #define GD_SPDIF_STATUS_44      1
0322 #define GD_SPDIF_STATUS_48      2
0323 #define GD_SPDIF_STATUS_UNDEF       0xff
0324 
0325 
0326 /*
0327  *
0328  * Layla20 output clocks
0329  *
0330  */
0331 
0332 #define LAYLA20_OUTPUT_CLOCK_SUPER  0
0333 #define LAYLA20_OUTPUT_CLOCK_WORD   1
0334 
0335 
0336 /****************************************************************************
0337 
0338    Magic constants for the Darla24 hardware
0339 
0340  ****************************************************************************/
0341 
0342 #define GD24_96000  0x0
0343 #define GD24_48000  0x1
0344 #define GD24_44100  0x2
0345 #define GD24_32000  0x3
0346 #define GD24_22050  0x4
0347 #define GD24_16000  0x5
0348 #define GD24_11025  0x6
0349 #define GD24_8000   0x7
0350 #define GD24_88200  0x8
0351 #define GD24_EXT_SYNC   0x9
0352 
0353 
0354 /*
0355  *
0356  * Return values from the DSP when ASIC is loaded
0357  *
0358  */
0359 
0360 #define ASIC_ALREADY_LOADED 0x1
0361 #define ASIC_NOT_LOADED     0x0
0362 
0363 
0364 /*
0365  *
0366  * DSP Audio formats
0367  *
0368  * These are the audio formats that the DSP can transfer
0369  * via input and output pipes.  LE means little-endian,
0370  * BE means big-endian.
0371  *
0372  * DSP_AUDIOFORM_MS_8   
0373  *
0374  *    8-bit mono unsigned samples.  For playback,
0375  *    mono data is duplicated out the left and right channels
0376  *    of the output bus.  The "MS" part of the name
0377  *    means mono->stereo.
0378  *
0379  * DSP_AUDIOFORM_MS_16LE
0380  *
0381  *    16-bit signed little-endian mono samples.  Playback works
0382  *    like the previous code.
0383  *
0384  * DSP_AUDIOFORM_MS_24LE
0385  *
0386  *    24-bit signed little-endian mono samples.  Data is packed
0387  *    three bytes per sample; if you had two samples 0x112233 and 0x445566
0388  *    they would be stored in memory like this: 33 22 11 66 55 44.
0389  *
0390  * DSP_AUDIOFORM_MS_32LE
0391  * 
0392  *    24-bit signed little-endian mono samples in a 32-bit 
0393  *    container.  In other words, each sample is a 32-bit signed 
0394  *    integer, where the actual audio data is left-justified 
0395  *    in the 32 bits and only the 24 most significant bits are valid.
0396  *
0397  * DSP_AUDIOFORM_SS_8
0398  * DSP_AUDIOFORM_SS_16LE
0399  * DSP_AUDIOFORM_SS_24LE
0400  * DSP_AUDIOFORM_SS_32LE
0401  *
0402  *    Like the previous ones, except now with stereo interleaved
0403  *    data.  "SS" means stereo->stereo.
0404  *
0405  * DSP_AUDIOFORM_MM_32LE
0406  *
0407  *    Similar to DSP_AUDIOFORM_MS_32LE, except that the mono
0408  *    data is not duplicated out both the left and right outputs.
0409  *    This mode is used by the ASIO driver.  Here, "MM" means
0410  *    mono->mono.
0411  *
0412  * DSP_AUDIOFORM_MM_32BE
0413  *
0414  *    Just like DSP_AUDIOFORM_MM_32LE, but now the data is
0415  *    in big-endian format.
0416  *
0417  */
0418 
0419 #define DSP_AUDIOFORM_MS_8  0   /* 8 bit mono */
0420 #define DSP_AUDIOFORM_MS_16LE   1   /* 16 bit mono */
0421 #define DSP_AUDIOFORM_MS_24LE   2   /* 24 bit mono */
0422 #define DSP_AUDIOFORM_MS_32LE   3   /* 32 bit mono */
0423 #define DSP_AUDIOFORM_SS_8  4   /* 8 bit stereo */
0424 #define DSP_AUDIOFORM_SS_16LE   5   /* 16 bit stereo */
0425 #define DSP_AUDIOFORM_SS_24LE   6   /* 24 bit stereo */
0426 #define DSP_AUDIOFORM_SS_32LE   7   /* 32 bit stereo */
0427 #define DSP_AUDIOFORM_MM_32LE   8   /* 32 bit mono->mono little-endian */
0428 #define DSP_AUDIOFORM_MM_32BE   9   /* 32 bit mono->mono big-endian */
0429 #define DSP_AUDIOFORM_SS_32BE   10  /* 32 bit stereo big endian */
0430 #define DSP_AUDIOFORM_INVALID   0xFF    /* Invalid audio format */
0431 
0432 
0433 /*
0434  *
0435  * Super-interleave is defined as interleaving by 4 or more.  Darla20 and Gina20
0436  * do not support super interleave.
0437  *
0438  * 16 bit, 24 bit, and 32 bit little endian samples are supported for super 
0439  * interleave.  The interleave factor must be even.  16 - way interleave is the 
0440  * current maximum, so you can interleave by 4, 6, 8, 10, 12, 14, and 16.
0441  *
0442  * The actual format code is derived by taking the define below and or-ing with
0443  * the interleave factor.  So, 32 bit interleave by 6 is 0x86 and
0444  * 16 bit interleave by 16 is (0x40 | 0x10) = 0x50.
0445  *
0446  */
0447 
0448 #define DSP_AUDIOFORM_SUPER_INTERLEAVE_16LE 0x40
0449 #define DSP_AUDIOFORM_SUPER_INTERLEAVE_24LE 0xc0
0450 #define DSP_AUDIOFORM_SUPER_INTERLEAVE_32LE 0x80
0451 
0452 
0453 /*
0454  *
0455  * Gina24, Mona, and Layla24 control register defines
0456  *
0457  */
0458 
0459 #define GML_CONVERTER_ENABLE    0x0010
0460 #define GML_SPDIF_PRO_MODE  0x0020  /* Professional S/PDIF == 1,
0461                        consumer == 0 */
0462 #define GML_SPDIF_SAMPLE_RATE0  0x0040
0463 #define GML_SPDIF_SAMPLE_RATE1  0x0080
0464 #define GML_SPDIF_TWO_CHANNEL   0x0100  /* 1 == two channels,
0465                        0 == one channel */
0466 #define GML_SPDIF_NOT_AUDIO 0x0200
0467 #define GML_SPDIF_COPY_PERMIT   0x0400
0468 #define GML_SPDIF_24_BIT    0x0800  /* 1 == 24 bit, 0 == 20 bit */
0469 #define GML_ADAT_MODE       0x1000  /* 1 == ADAT mode, 0 == S/PDIF mode */
0470 #define GML_SPDIF_OPTICAL_MODE  0x2000  /* 1 == optical mode, 0 == RCA mode */
0471 #define GML_SPDIF_CDROM_MODE    0x3000  /* 1 == CDROM mode,
0472                      * 0 == RCA or optical mode */
0473 #define GML_DOUBLE_SPEED_MODE   0x4000  /* 1 == double speed,
0474                        0 == single speed */
0475 
0476 #define GML_DIGITAL_IN_AUTO_MUTE 0x800000
0477 
0478 #define GML_96KHZ       (0x0 | GML_DOUBLE_SPEED_MODE)
0479 #define GML_88KHZ       (0x1 | GML_DOUBLE_SPEED_MODE)
0480 #define GML_48KHZ       0x2
0481 #define GML_44KHZ       0x3
0482 #define GML_32KHZ       0x4
0483 #define GML_22KHZ       0x5
0484 #define GML_16KHZ       0x6
0485 #define GML_11KHZ       0x7
0486 #define GML_8KHZ        0x8
0487 #define GML_SPDIF_CLOCK     0x9
0488 #define GML_ADAT_CLOCK      0xA
0489 #define GML_WORD_CLOCK      0xB
0490 #define GML_ESYNC_CLOCK     0xC
0491 #define GML_ESYNCx2_CLOCK   0xD
0492 
0493 #define GML_CLOCK_CLEAR_MASK        0xffffbff0
0494 #define GML_SPDIF_RATE_CLEAR_MASK   (~(GML_SPDIF_SAMPLE_RATE0|GML_SPDIF_SAMPLE_RATE1))
0495 #define GML_DIGITAL_MODE_CLEAR_MASK 0xffffcfff
0496 #define GML_SPDIF_FORMAT_CLEAR_MASK 0xfffff01f
0497 
0498 
0499 /*
0500  *
0501  * Mia sample rate and clock setting constants
0502  *
0503  */
0504 
0505 #define MIA_32000   0x0040
0506 #define MIA_44100   0x0042
0507 #define MIA_48000   0x0041
0508 #define MIA_88200   0x0142
0509 #define MIA_96000   0x0141
0510 
0511 #define MIA_SPDIF   0x00000044
0512 #define MIA_SPDIF96 0x00000144
0513 
0514 #define MIA_MIDI_REV    1   /* Must be Mia rev 1 for MIDI support */
0515 
0516 
0517 /*
0518  *
0519  * 3G register bits
0520  *
0521  */
0522 
0523 #define E3G_CONVERTER_ENABLE    0x0010
0524 #define E3G_SPDIF_PRO_MODE  0x0020  /* Professional S/PDIF == 1,
0525                        consumer == 0 */
0526 #define E3G_SPDIF_SAMPLE_RATE0  0x0040
0527 #define E3G_SPDIF_SAMPLE_RATE1  0x0080
0528 #define E3G_SPDIF_TWO_CHANNEL   0x0100  /* 1 == two channels,
0529                        0 == one channel */
0530 #define E3G_SPDIF_NOT_AUDIO 0x0200
0531 #define E3G_SPDIF_COPY_PERMIT   0x0400
0532 #define E3G_SPDIF_24_BIT    0x0800  /* 1 == 24 bit, 0 == 20 bit */
0533 #define E3G_DOUBLE_SPEED_MODE   0x4000  /* 1 == double speed,
0534                        0 == single speed */
0535 #define E3G_PHANTOM_POWER   0x8000  /* 1 == phantom power on,
0536                        0 == phantom power off */
0537 
0538 #define E3G_96KHZ       (0x0 | E3G_DOUBLE_SPEED_MODE)
0539 #define E3G_88KHZ       (0x1 | E3G_DOUBLE_SPEED_MODE)
0540 #define E3G_48KHZ       0x2
0541 #define E3G_44KHZ       0x3
0542 #define E3G_32KHZ       0x4
0543 #define E3G_22KHZ       0x5
0544 #define E3G_16KHZ       0x6
0545 #define E3G_11KHZ       0x7
0546 #define E3G_8KHZ        0x8
0547 #define E3G_SPDIF_CLOCK     0x9
0548 #define E3G_ADAT_CLOCK      0xA
0549 #define E3G_WORD_CLOCK      0xB
0550 #define E3G_CONTINUOUS_CLOCK    0xE
0551 
0552 #define E3G_ADAT_MODE       0x1000
0553 #define E3G_SPDIF_OPTICAL_MODE  0x2000
0554 
0555 #define E3G_CLOCK_CLEAR_MASK        0xbfffbff0
0556 #define E3G_DIGITAL_MODE_CLEAR_MASK 0xffffcfff
0557 #define E3G_SPDIF_FORMAT_CLEAR_MASK 0xfffff01f
0558 
0559 /* Clock detect bits reported by the DSP */
0560 #define E3G_CLOCK_DETECT_BIT_WORD96 0x0001
0561 #define E3G_CLOCK_DETECT_BIT_WORD48 0x0002
0562 #define E3G_CLOCK_DETECT_BIT_SPDIF48    0x0004
0563 #define E3G_CLOCK_DETECT_BIT_ADAT   0x0004
0564 #define E3G_CLOCK_DETECT_BIT_SPDIF96    0x0008
0565 #define E3G_CLOCK_DETECT_BIT_WORD   (E3G_CLOCK_DETECT_BIT_WORD96|E3G_CLOCK_DETECT_BIT_WORD48)
0566 #define E3G_CLOCK_DETECT_BIT_SPDIF  (E3G_CLOCK_DETECT_BIT_SPDIF48|E3G_CLOCK_DETECT_BIT_SPDIF96)
0567 
0568 /* Frequency control register */
0569 #define E3G_MAGIC_NUMBER        677376000
0570 #define E3G_FREQ_REG_DEFAULT        (E3G_MAGIC_NUMBER / 48000 - 2)
0571 #define E3G_FREQ_REG_MAX        0xffff
0572 
0573 /* 3G external box types */
0574 #define E3G_GINA3G_BOX_TYPE     0x00
0575 #define E3G_LAYLA3G_BOX_TYPE        0x10
0576 #define E3G_ASIC_NOT_LOADED     0xffff
0577 #define E3G_BOX_TYPE_MASK       0xf0
0578 
0579 /* Indigo express control register values */
0580 #define INDIGO_EXPRESS_32000        0x02
0581 #define INDIGO_EXPRESS_44100        0x01
0582 #define INDIGO_EXPRESS_48000        0x00
0583 #define INDIGO_EXPRESS_DOUBLE_SPEED 0x10
0584 #define INDIGO_EXPRESS_QUAD_SPEED   0x04
0585 #define INDIGO_EXPRESS_CLOCK_MASK   0x17
0586 
0587 
0588 /*
0589  *
0590  * Gina20 & Layla20 have input gain controls for the analog inputs;
0591  * this is the magic number for the hardware that gives you 0 dB at -10.
0592  *
0593  */
0594 
0595 #define GL20_INPUT_GAIN_MAGIC_NUMBER    0xC8
0596 
0597 
0598 /*
0599  *
0600  * Defines how much time must pass between DSP load attempts
0601  *
0602  */
0603 
0604 #define DSP_LOAD_ATTEMPT_PERIOD     1000000L    /* One second */
0605 
0606 
0607 /*
0608  *
0609  * Size of arrays for the comm page.  MAX_PLAY_TAPS and MAX_REC_TAPS are
0610  * no longer used, but the sizes must still be right for the DSP to see
0611  * the comm page correctly.
0612  *
0613  */
0614 
0615 #define MONITOR_ARRAY_SIZE  0x180
0616 #define VMIXER_ARRAY_SIZE   0x40
0617 #define MIDI_OUT_BUFFER_SIZE    32
0618 #define MIDI_IN_BUFFER_SIZE 256
0619 #define MAX_PLAY_TAPS       168
0620 #define MAX_REC_TAPS        192
0621 #define DSP_MIDI_OUT_FIFO_SIZE  64
0622 
0623 
0624 /* sg_entry is a single entry for the scatter-gather list.  The array of struct
0625 sg_entry struct is read by the DSP, so all values must be little-endian. */
0626 
0627 #define MAX_SGLIST_ENTRIES 512
0628 
0629 struct sg_entry {
0630     __le32 addr;
0631     __le32 size;
0632 };
0633 
0634 
0635 /****************************************************************************
0636 
0637   The comm page.  This structure is read and written by the DSP; the
0638   DSP code is a firm believer in the byte offsets written in the comments
0639   at the end of each line.  This structure should not be changed.
0640 
0641   Any reads from or writes to this structure should be in little-endian format.
0642 
0643  ****************************************************************************/
0644 
0645 struct comm_page {      /*              Base    Length*/
0646     __le32 comm_size;   /* size of this object      0x000   4 */
0647     __le32 flags;       /* See Appendix A below     0x004   4 */
0648     __le32 unused;      /* Unused entry         0x008   4 */
0649     __le32 sample_rate; /* Card sample rate in Hz   0x00c   4 */
0650     __le32 handshake;   /* DSP command handshake    0x010   4 */
0651     __le32 cmd_start;   /* Chs. to start mask       0x014   4 */
0652     __le32 cmd_stop;    /* Chs. to stop mask        0x018   4 */
0653     __le32 cmd_reset;   /* Chs. to reset mask       0x01c   4 */
0654     __le16 audio_format[DSP_MAXPIPES];  /* Chs. audio format    0x020   32*2 */
0655     struct sg_entry sglist_addr[DSP_MAXPIPES];
0656                 /* Chs. Physical sglist addrs   0x060   32*8 */
0657     __le32 position[DSP_MAXPIPES];
0658                 /* Positions for ea. ch.    0x160   32*4 */
0659     s8 vu_meter[DSP_MAXPIPES];
0660                 /* VU meters            0x1e0   32*1 */
0661     s8 peak_meter[DSP_MAXPIPES];
0662                 /* Peak meters          0x200   32*1 */
0663     s8 line_out_level[DSP_MAXAUDIOOUTPUTS];
0664                 /* Output gain          0x220   16*1 */
0665     s8 line_in_level[DSP_MAXAUDIOINPUTS];
0666                 /* Input gain           0x230   16*1 */
0667     s8 monitors[MONITOR_ARRAY_SIZE];
0668                 /* Monitor map          0x240   0x180 */
0669     __le32 play_coeff[MAX_PLAY_TAPS];
0670             /* Gina/Darla play filters - obsolete   0x3c0   168*4 */
0671     __le32 rec_coeff[MAX_REC_TAPS];
0672             /* Gina/Darla record filters - obsolete 0x660   192*4 */
0673     __le16 midi_input[MIDI_IN_BUFFER_SIZE];
0674             /* MIDI input data transfer buffer  0x960   256*2 */
0675     u8 gd_clock_state;  /* Chg Gina/Darla clock state   0xb60   1 */
0676     u8 gd_spdif_status; /* Chg. Gina/Darla S/PDIF state 0xb61   1 */
0677     u8 gd_resampler_state;  /* Should always be 3       0xb62   1 */
0678     u8 filler2;     /*              0xb63   1 */
0679     __le32 nominal_level_mask;  /* -10 level enable mask    0xb64   4 */
0680     __le16 input_clock; /* Chg. Input clock state   0xb68   2 */
0681     __le16 output_clock;    /* Chg. Output clock state  0xb6a   2 */
0682     __le32 status_clocks;   /* Current Input clock state    0xb6c   4 */
0683     __le32 ext_box_status;  /* External box status      0xb70   4 */
0684     __le32 cmd_add_buffer;  /* Pipes to add (obsolete)  0xb74   4 */
0685     __le32 midi_out_free_count;
0686             /* # of bytes free in MIDI output FIFO  0xb78   4 */
0687     __le32 unused2;     /* Cyclic pipes         0xb7c   4 */
0688     __le32 control_register;
0689             /* Mona, Gina24, Layla24, 3G ctrl reg   0xb80   4 */
0690     __le32 e3g_frq_register;    /* 3G frequency register    0xb84   4 */
0691     u8 filler[24];      /* filler           0xb88   24*1 */
0692     s8 vmixer[VMIXER_ARRAY_SIZE];
0693                 /* Vmixer levels        0xba0   64*1 */
0694     u8 midi_output[MIDI_OUT_BUFFER_SIZE];
0695                 /* MIDI output data     0xbe0   32*1 */
0696 };
0697 
0698 #endif /* _ECHO_DSP_ */