Nut/OS  5.0.5
API Reference
vscodec.h
Go to the documentation of this file.
00001 #ifndef _DEV_VSCODEC_H_
00002 #define _DEV_VSCODEC_H_
00003 /*
00004  * Copyright (C) 2009 by egnite GmbH
00005  * Copyright (C) 2001-2007 by egnite Software GmbH
00006  *
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. Neither the name of the copyright holders nor the names of
00019  *    contributors may be used to endorse or promote products derived
00020  *    from this software without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
00029  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
00030  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00031  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
00032  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  *
00035  * For additional information see http://www.ethernut.de/
00036  */
00037 
00038 /*
00039  * $Id: vscodec.h 4473 2012-08-20 15:12:45Z haraldkipp $
00040  */
00041 
00042 #include <cfg/audio.h>
00043 #include <sys/device.h>
00044 
00045 #include <stdint.h>
00046 
00047 /* For backward compatibility. */
00048 #if defined(AUDIO_VS1001K)
00049 #define AUDIO0_VS1001K
00050 #elif defined(AUDIO_VS1011E)
00051 #define AUDIO0_VS1011E
00052 #elif defined(AUDIO_VS1002D)
00053 #define AUDIO0_VS1002D
00054 #elif defined(AUDIO_VS1003B)
00055 #define AUDIO0_VS1003B
00056 #elif defined(AUDIO_VS1033C)
00057 #define AUDIO0_VS1033C
00058 #elif defined(AUDIO_VS1053B)
00059 #define AUDIO0_VS1053B
00060 #elif defined(AUDIO_VS1063A)
00061 #define AUDIO0_VS1063A
00062 #elif defined(AUDIO_VSAUTO)
00063 #define AUDIO0_VSAUTO
00064 #endif
00065 
00066 /*
00067 ** Include codec features.
00068 */
00069 #if defined(AUDIO0_VS1001K)
00070 #include <dev/vs1001.h>
00071 #elif defined(AUDIO0_VS1002D)
00072 #include <dev/vs1002.h>
00073 #elif defined(AUDIO0_VS1003B)
00074 #include <dev/vs1003.h>
00075 #elif defined(AUDIO0_VS1011E)
00076 #include <dev/vs1011.h>
00077 #elif defined(AUDIO0_VS1033C)
00078 #include <dev/vs1033.h>
00079 #elif defined(AUDIO0_VS1053B)
00080 #include <dev/vs1053.h>
00081 #elif defined(AUDIO0_VS1063A)
00082 #include <dev/vs1063.h>
00083 #elif !defined(AUDIO0_VSAUTO)
00084 #define AUDIO0_VSAUTO
00085 #endif
00086 
00096 
00097 /* DAC min/max gain in dB. */
00098 #ifndef AUDIO0_DAC_MIN_GAIN
00099 #define AUDIO0_DAC_MIN_GAIN      -127
00100 #endif
00101 #ifndef AUDIO0_DAC_MAX_GAIN
00102 #define AUDIO0_DAC_MAX_GAIN      0
00103 #endif
00104 
00105 /* Backward compatibility, still used. */
00106 #ifndef AUDIO_DAC_MIN_GAIN
00107 #define AUDIO_DAC_MIN_GAIN      AUDIO0_DAC_MIN_GAIN
00108 #endif
00109 #ifndef AUDIO_DAC_MAX_GAIN
00110 #define AUDIO_DAC_MAX_GAIN      AUDIO0_DAC_MAX_GAIN
00111 #endif
00112 
00113 /* Audio decoder treble anhancement limits */
00114 #ifndef AUDIO_DAC_MAX_TREB
00115 #define AUDIO_DAC_MAX_TREB       8      /* VLSI1053 limits */
00116 #endif
00117 
00118 #ifndef AUDIO_DAC_MAX_TFIN
00119 #define AUDIO_DAC_MAX_TFIN      15      /* VLSI1053 limits */
00120 #endif
00121 
00122 #ifndef AUDIO_DAC_MAX_BASS
00123 #define AUDIO_DAC_MAX_BASS      15      /* VLSI1053 limits */
00124 #endif
00125 
00126 #ifndef AUDIO_DAC_MAX_BFIN
00127 #define AUDIO_DAC_MAX_BFIN      15      /* VLSI1053 limits */
00128 #endif
00129 
00130 /*
00131  * I/O control codes.
00132  */
00133 #define AUDIO_SETWRITETIMEOUT   0x010d
00134 #define AUDIO_GETWRITETIMEOUT   0x010e
00135 
00137 #define AUDIO_PLAY          0x3001
00138 
00139 #define AUDIO_CANCEL        0x3002
00140 #define AUDIO_GET_STATUS    0x3003
00141 #define AUDIO_GET_PLAYGAIN  0x3004
00142 #define AUDIO_SET_PLAYGAIN  0x3005
00143 #define AUDIO_GET_PBSIZE    0x3006
00144 #define AUDIO_SET_PBSIZE    0x3007
00145 #define AUDIO_GET_PBLEVEL   0x3008
00146 #define AUDIO_GET_PBWLOW    0x3009
00147 #define AUDIO_SET_PBWLOW    0x300A
00148 #define AUDIO_GET_PBWHIGH   0x300B
00149 #define AUDIO_SET_PBWHIGH   0x300C
00150 #define AUDIO_BEEP          0x300F
00151 
00152 #define AUDIO_GET_DECINFO   0x3010
00153 
00154 #define AUDIO_GET_DECCAPS   0x3011
00155 
00156 #define AUDIO_GET_DECFMTS   0x3012
00157 #define AUDIO_FMT_PLUGIN        0x00000001
00158 #define AUDIO_FMT_WAV_PCM       0x00000002
00159 #define AUDIO_FMT_WAV_ADPCM     0x00000004
00160 #define AUDIO_FMT_WAV_IMA_ADPCM 0x00000008
00161 #define AUDIO_FMT_VORBIS        0x00000100
00162 #define AUDIO_FMT_MPEG1_L1      0x00001000
00163 #define AUDIO_FMT_MPEG1_L2      0x00002000
00164 #define AUDIO_FMT_MPEG1_L3      0x00004000
00165 #define AUDIO_FMT_MPEG2_AAC     0x00010000
00166 #define AUDIO_FMT_MPEG4_AAC     0x00020000
00167 #define AUDIO_FMT_WMA_V2        0x00100000
00168 #define AUDIO_FMT_WMA_V7        0x00200000
00169 #define AUDIO_FMT_WMA_V8        0x00400000
00170 #define AUDIO_FMT_WMA_V9        0x00800000
00171 
00173 #define AUDIO_SET_DECFMTS   0x3013
00174 
00175 #define AUDIO_GET_CODINFO   0x3014
00176 
00177 #define AUDIO_GET_CODCAPS   0x3015
00178 
00179 #define AUDIO_GET_CODFMTS   0x3016
00180 
00181 #define AUDIO_SET_CODFMTS   0x3017
00182 
00183 #define AUDIO_GET_MIDINFO   0x3018
00184 
00185 #define AUDIO_GET_MIDCAPS   0x3019
00186 #define AUDIO_FMT_GMIDI1        0x00000001
00187 #define AUDIO_FMT_GMIDI2        0x00000002
00188 #define AUDIO_FMT_SPMIDI0       0x00000004
00189 
00190 #define AUDIO_SET_TREB      0x301a
00191 
00192 #define AUDIO_GET_TREB      0x301b
00193 
00194 #define AUDIO_SET_TFIN      0x301c
00195 
00196 #define AUDIO_GET_TFIN      0x301d
00197 
00198 #define AUDIO_SET_BASS      0x301e
00199 
00200 #define AUDIO_GET_BASS      0x301f
00201 
00202 #define AUDIO_SET_BFIN      0x3020
00203 
00204 #define AUDIO_GET_BFIN      0x3021
00205 
00207 #define AUDIO_PLUGIN_UPLOAD 0x3030
00208 
00210 #define AUDIO_IRQ_ENABLE    0x3031
00211 
00213 #define AUDIO_SET_ICLOCK    0x3032
00214 
00216 #define AUDIO_WRITE_CMEM    0x3038
00217 
00219 #define AUDIO_SET_PARAMX    0x3040
00220 
00222 #define AUDIO_GET_PARAMX    0x3041
00223 #define VSP4_CHIP_ID_OFF                    0x00
00224 #define VSP4_VERSION_OFF                    0x02
00225 #define VSP4_CONFIG1_OFF                    0x03
00226 #define VSP4_PLAY_SPEED_OFF                 0x04
00227 #define VSP4_BIT_RATE_PER_100_OFF           0x05
00228 #define VSP4_END_FILL_BYTE_OFF              0x06
00229 #define VSP4_RATE_TUNE_OFF                  0x07
00230 #define VSP4_PLAY_MODE_OFF                  0x09
00231 #define VSP4_SAMPLE_COUNTER_OFF             0x0a
00232 #define VSP4_VU_METER_OFF                   0x0c
00233 #define VSP4_AD_MIXER_GAIN_OFF              0x0d
00234 #define VSP4_AD_MIXER_CONFIG_OFF            0x0e
00235 #define VSP4_PCM_MIXER_RATE_OFF             0x0f
00236 #define VSP4_PCM_MIXER_FREE_OFF             0x10
00237 #define VSP4_PCM_MIXER_VOL_OFF              0x11
00238 #define VSP4_EQ5_PARAMS_OFF(i)              (0x12 + (i))
00239 #define VSP4_EQ5_UPDATED_OFF                0x1c
00240 #define VSP4_SPEED_SHIFTER_OFF              0x1d
00241 #define VSP4_EAR_SPEAKER_LEVEL_OFF          0x1e
00242 #define VSP4_SDI_FREE_OFF                   0x1f
00243 #define VSP4_AUDIO_FILL_OFF                 0x20
00244 #define VSP4_LATEST_SOF_OFF                 0x25
00245 #define VSP4_POSITION_MSEC_OFF              0x27
00246 #define VSP4_RESYNC_OFF                     0x29
00247 #define VSP4_ENC_TX_UART_DIV_OFF            0x2a
00248 #define VSP4_ENC_TX_UART_BYTE_SPEED_OFF     0x2b
00249 #define VSP4_ENC_TX_PAUSE_GPIO_OFF          0x2c
00250 #define VSP4_ENC_SEC_ADAPT_MULTIPLIER_OFF   0x2d
00251 #define VSP4_ENC_CHANNEL_MAX_OFF            0x3c
00252 #define VSP4_ENC_SERIAL_NUMBER_OFF          0x3e
00253 #define VSP4_WMA_CUR_PACKET_SIZE_OFF        0x2a
00254 #define VSP4_WMA_PACKET_SIZE_OFF            0x2c
00255 #define VSP4_AAC_SCE_FOUND_MASK_OFF         0x2a
00256 #define VSP4_AAC_CPE_FOUND_MASK_OFF         0x2b
00257 #define VSP4_AAC_LFE_FOUND_MASK_OFF         0x2c
00258 #define VSP4_AAC_PLAY_SELECT_OFF            0x2d
00259 #define VSP4_AAC_DYN_COMPRESS_OFF           0x2e
00260 #define VSP4_AAC_DYN_BOOST_OFF              0x2f
00261 #define VSP4_AAC_SBR_AND_PS_STATUS_OFF      0x30
00262 #define VSP4_AAC_SBR_PS_FLAGS_OFF           0x31
00263 #define VSP4_VORBIS_GAIN_OFF                0x2a
00264 
00265 #define VS_PLAYMODE_MONO_OUTPUT_ON  ox0001
00266 #define VS_PLAYMODE_PAUSE_ON        0x0002
00267 #define VS_PLAYMODE_VUMETER_ON      0x0004
00268 #define VS_PLAYMODE_ADMIXER_ON      0x0008
00269 #define VS_PLAYMODE_PCMMIXER_ON     0x0010
00270 #define VS_PLAYMODE_EQ5_ON          0x0020
00271 #define VS_PLAYMODE_SPEEDSHIFTER_ON 0x0040
00272 
00273 typedef struct _VS_PLUGIN_INFO VS_PLUGIN_INFO;
00274 
00275 struct _VS_PLUGIN_INFO {
00276     size_t vsplg_size;
00277     const uint16_t *vsplg_data;
00278 };
00279 
00280 typedef struct _VS_WRAM_DATA VS_WRAM_DATA;
00281 
00282 struct _VS_WRAM_DATA {
00283     uint16_t vswd_addr;
00284     uint16_t vswd_size;
00285     uint16_t *vswd_data;
00286 };
00287 
00288 typedef struct _VS_PARAMX_INFO VS_PARAMX_INFO;
00289 
00290 struct _VS_PARAMX_INFO {
00291     uint16_t vspx_offs;
00292     uint16_t vspx_data;
00293 };
00294 
00295 /*
00296  * Instruction opcodes.
00297  */
00298 #define VS_OPCODE_READ  3
00299 #define VS_OPCODE_WRITE 2
00300 
00304 /* ------------------------------------------------------------- */
00307 #define VS_MODE_REG         0
00308 
00309 #define VS_SM_DIFF          0x0001
00310 
00319 #if VS_HAS_SM_LAYER12
00320 #define VS_SM_LAYER12       0x0002
00321 #endif
00322 
00334 #if VS_HAS_SM_FFWD
00335 #define VS_SM_FFWD          0x0002
00336 #endif
00337 
00342 #define VS_SM_RESET         0x0004
00343 
00344 
00356 #if VS_HAS_SM_MP12
00357 #define VS_SM_MP12          0x0008
00358 #endif
00359 
00368 #if VS_HAS_SM_OUTOFWAV
00369 #define VS_SM_OUTOFWAV      0x0008
00370 #endif
00371 
00381 #if VS_HAS_SM_CANCEL
00382 #define VS_SM_CANCEL        0x0008
00383 #endif
00384 
00396 #if VS_HAS_SM_PDOWN
00397 #define VS_SM_PDOWN         0x0010
00398 #endif
00399 
00402 #if VS_HAS_SM_EARSPEAKER
00403 #define VS_SM_EARSPEAKER_LO     0x0010
00404 #define VS_SM_SPATIAL_OFF       0
00405 #define VS_SM_SPATIAL_MINIMAL   VS_SM_EARSPEAKER_LO
00406 #define VS_SM_SPATIAL_NORMAL    VS_SM_EARSPEAKER_HI
00407 #define VS_SM_SPATIAL_EXTREME   (VS_SM_EARSPEAKER_LO | VS_SM_EARSPEAKER_LO)
00408 #endif
00409 
00420 #if VS_HAS_SM_DAC
00421 #define VS_SM_DAC           0x0020
00422 #endif
00423 
00428 #if VS_HAS_SM_TESTS
00429 #define VS_SM_TESTS         0x0020
00430 #endif
00431 
00442 #if VS_HAS_SM_DACMONO
00443 #define VS_SM_DACMONO       0x0040
00444 #endif
00445 
00457 #if VS_HAS_SM_STREAM
00458 #define VS_SM_STREAM        0x0040
00459 #endif
00460 
00465 #if VS_HAS_SM_BASS
00466 #define VS_SM_BASS          0x0080
00467 #endif
00468 
00469 #if VS_HAS_SM_EARSPEAKER
00470 #define VS_SM_EARSPEAKER_HI 0x0080
00471 #endif
00472 
00478 #define VS_SM_DACT          0x0100
00479 
00485 #define VS_SM_BITORD        0x0200
00486 
00491 #define VS_SM_SDIORD        0x0200
00492 
00500 #if VS_HAS_SM_IBMODE
00501 #define VS_SM_IBMODE        0x0400
00502 #endif
00503 
00505 #if VS_HAS_SM_SDISHARE
00506 #define VS_SM_SDISHARE      0x0400
00507 #endif
00508 
00516 #if VS_HAS_SM_IBCLK
00517 #define VS_SM_IBCLK         0x0800
00518 #endif
00519 
00526 #if VS_HAS_SM_SDINEW
00527 #define VS_SM_SDINEW        0x0800
00528 #endif
00529 
00534 #if VS_HAS_SM_ADPCM
00535 #define VS_SM_ADPCM         0x1000
00536 #define VS_SM_ENCODE        0x1000
00537 #endif
00538 
00547 #if VS_HAS_SM_ADPCM_HP
00548 #define VS_SM_ADPCM_HP      0x2000
00549 #endif
00550 
00558 #if VS_HAS_SM_LINE_IN
00559 #define VS_SM_LINE_IN       0x4000
00560 #define VS_SM_LINE1         0x4000
00561 #endif
00562 
00570 #if VS_HAS_SM_CLK_RANGE
00571 #define VS_SM_CLK_RANGE     0x8000
00572 #endif
00573 
00579 /* ------------------------------------------------------------- */
00582 #define VS_STATUS_REG       1
00583 
00592 #if VS_HAS_SS_AVOL
00593 #define VS_SS_AVOL          0x0003
00594 
00595 #define VS_SS_AVOL_LSB      0
00596 #endif
00597 
00606 #if VS_HAS_SS_VREF_1_65
00607 #define VS_SS_VREF_1_65     0x0001
00608 #endif
00609 
00626 #if VS_HAS_SS_AD_CLOCK
00627 #define VS_SS_AD_CLOCK      0x0002
00628 #endif
00629 
00634 #define VS_SS_APDOWM1       0x0004
00635 
00646 #define VS_SS_APDOWN2       0x0008
00647 
00658 #define VS_SS_VER           0x00F0
00659 
00660 #define VS_SS_VER_LSB       4
00661 
00662 #define VS1001_SS_VER       0
00663 #define VS1011_SS_VER       1
00664 #define VS1011E_SS_VER      2
00665 #define VS1002_SS_VER       2
00666 #define VS1003_SS_VER       3
00667 #define VS1053_SS_VER       4
00668 #define VS1033_SS_VER       5
00669 #define VS1063_SS_VER       6
00670 #define VS1103_SS_VER       7
00671 
00678 #if VS_HAS_SS_VCM_DISABLE
00679 #define VS_SS_VCM_DISABLE   0x0400
00680 #endif
00681 
00686 #if VS_HAS_SS_VCM_OVERLOAD
00687 #define VS_SS_VCM_OVERLOAD  0x0800
00688 #endif
00689 
00699 #if VS_HAS_SS_SWING
00700 #define VS_SS_SWING         0x7000
00701 #define VS_SS_SWING_LSB     12
00702 #define VS_SS_SWING_NORMAL  0
00703 #define VS_SS_SWING_MAX     2
00704 #endif
00705 
00711 #if VS_HAS_SS_DO_NOT_JUMP
00712 #define VS_SS_DO_NOT_JUMP   0x8000
00713 #endif
00714 
00720 /* ------------------------------------------------------------- */
00726 #if VS_HAS_INT_FCTLH_REG
00727 #define VS_INT_FCTLH_REG    2
00728 #endif
00729 
00735 /* ------------------------------------------------------------- */
00744 #if VS_HAS_BASS_REG
00745 #define VS_BASS_REG         2
00746 
00756 #define VS_SB_FREQLIMIT     0x000F
00757 
00758 #define VS_SB_FREQLIMIT_LSB 0
00759 
00764 #define VS_SB_AMPLITUDE     0x00F0
00765 
00766 #define VS_SB_AMPLITUDE_LSB 4
00767 
00772 #define VS_ST_FREQLIMIT     0x0F00
00773 
00774 #define VS_ST_FREQLIMIT_LSB 8
00775 
00780 #define VS_ST_AMPLITUDE     0xF000
00781 
00782 #define VS_ST_AMPLITUDE_LSB 12
00783 #endif
00784 
00789 /* ------------------------------------------------------------- */
00792 #define VS_CLOCKF_REG       3
00793 
00804 #if VS_HAS_SC_FREQ
00805 #define VS_SC_FREQ          0x7FFF
00806 
00807 #define VS_SC_FREQ_LSB      0
00808 #endif
00809 
00817 #if VS_HAS_SC_X3FREQ
00818 #define VS_SC_X3FREQ        0x07FF
00819 #endif
00820 
00827 #if VS_HAS_SC_ADD
00828 #define VS_SC_ADD           0x1800
00829 #define VS_SC_ADD_NONE      0x0000
00830 #if VS_HAS_SC_ADD2
00831 #define VS_SC_ADD_1_0       0x0800
00832 #define VS_SC_ADD_1_5       0x1000
00833 #define VS_SC_ADD_2_0       0x1800
00834 #else
00835 #define VS_SC_ADD_0_5       0x0800
00836 #define VS_SC_ADD_1_0       0x1000
00837 #define VS_SC_ADD_1_5       0x1800
00838 #endif
00839 #endif
00840 
00846 #if VS_HAS_SC_MULT
00847 #define VS_SC_MULT          0xE000
00848 #define VS_SC_MULT_1_0      0x0000
00849 #if VS_HAS_SC_MULT5
00850 #define VS_SC_MULT_2_0      0x2000
00851 #define VS_SC_MULT_2_5      0x4000
00852 #define VS_SC_MULT_3_0      0x6000
00853 #define VS_SC_MULT_3_5      0x8000
00854 #define VS_SC_MULT_4_0      0xA000
00855 #define VS_SC_MULT_4_5      0xC000
00856 #define VS_SC_MULT_5_0      0xE000
00857 #else
00858 #define VS_SC_MULT_1_5      0x2000
00859 #define VS_SC_MULT_2_0      0x4000
00860 #define VS_SC_MULT_2_5      0x6000
00861 #define VS_SC_MULT_3_0      0x8000
00862 #define VS_SC_MULT_3_5      0xA000
00863 #define VS_SC_MULT_4_0      0xC000
00864 #define VS_SC_MULT_4_5      0xE000
00865 #endif
00866 #endif
00867 
00872 #if VS_HAS_CF_DOUBLER
00873 #define VS_CF_DOUBLER       0x8000
00874 #endif
00875 
00881 /* ------------------------------------------------------------- */
00891 #define VS_DECODE_TIME_REG  4
00892 
00897 /* ------------------------------------------------------------- */
00903 #define VS_AUDATA_REG       5
00904 
00910 #if VS_HAS_AD_STEREO_BIT0
00911 #define VS_AD_STEREO        0x0001
00912 #else
00913 #define VS_AD_STEREO        0x8000
00914 #endif
00915 
00924 #if VS_HAS_AD_SAMRATE
00925 #if VS_HAS_AD_STEREO_BIT0
00926 #define VS_AD_SAMRATE       0xFFFE
00927 
00928 #define VS_AD_SAMRATE_LSB   1
00929 #else
00930 #define VS_AD_SAMRATE       0x7FFF
00931 #define VS_AD_SAMRATE_LSB   0
00932 #endif
00933 #endif
00934 
00937 #if VS_HAS_AD_BITRATE
00938 #define VS_AD_BITRATE       0x01FF
00939 #define VS_AD_BITRATE_LSB   0
00940 #endif
00941 
00944 #if VS_HAS_AD_SAMRATE_IDX
00945 #define VS_AD_SAMRATE_IDX       0x1E00
00946 #define VS_AD_SAMRATE_IDX_LSB   9
00947 
00948 #define VS_AD_SAMRATE_44100     1
00949 #define VS_AD_SAMRATE_48000     2
00950 #define VS_AD_SAMRATE_32000     3
00951 #define VS_AD_SAMRATE_22050     4
00952 #define VS_AD_SAMRATE_24000     5
00953 #define VS_AD_SAMRATE_16000     6
00954 #define VS_AD_SAMRATE_11025     7
00955 #define VS_AD_SAMRATE_12000     8
00956 #define VS_AD_SAMRATE_8000      9
00957 #endif
00958 
00964 /* ------------------------------------------------------------- */
00970 #define VS_WRAM_REG         6
00971 
00976 /* ------------------------------------------------------------- */
00982 #define VS_WRAMADDR_REG     7
00983 
00988 /* ------------------------------------------------------------- */
00999 #if VS_HAS_HDAT0_REG
01000 #define VS_HDAT0_REG            8
01001 
01002 #define VS_HDAT0_EMPHAS         0x0003
01003 #define VS_HDAT0_EMPHAS_LSB     0
01004 
01005 #define VS_HDAT0_EMPHAS_NONE    0
01006 #define VS_HDAT0_EMPHAS_5015    1
01007 #define VS_HDAT0_EMPHAS_J17     3
01008 
01009 #define VS_HDAT0_ORIGIN         0x0004
01010 
01011 #define VS_HDAT0_COPY           0x0008
01012 
01013 #define VS_HDAT0_EXT            0x0030
01014 
01015 #define VS_HDAT0_MODE           0x00C0
01016 #define VS_HDAT0_MODE_LSB       6
01017 
01018 #define VS_HDAT0_MODE_STEREO    0
01019 #define VS_HDAT0_MODE_JSTEREO   1
01020 #define VS_HDAT0_MODE_DUAL      2
01021 #define VS_HDAT0_MODE_MONO      3
01022 
01023 #define VS_HDAT0_PRIV           0x0100
01024 
01025 #define VS_HDAT0_PAD            0x0200
01026 
01027 #define VS_HDAT0_SAMRATE        0x0C00
01028 #define VS_HDAT0_SAMRATE_LSB    10
01029 
01030 #define VS_HDAT0_SAMRATE_11B    0
01031 #define VS_HDAT0_SAMRATE_12B    1
01032 #define VS_HDAT0_SAMRATE_8B     2
01033 
01034 #define VS_HDAT0_BITRATE        0xF000
01035 #endif
01036 
01041 /* ------------------------------------------------------------- */
01044 #if VS_HAS_IN0_REG
01045 #define VS_IN0_REG          8
01046 #endif
01047 
01052 /* ------------------------------------------------------------- */
01058 #if VS_HAS_HDAT1_REG
01059 #define VS_HDAT1_REG        9
01060 
01061 #define VS_HDAT1_PROT       0x0001
01062 #define VS_HDAT1_LAYER      0x0006
01063 #define VS_HDAT1_ID         0x0018
01064 
01065 #define VS_HDAT1_SYNC       0xFFE0
01066 #define VS_HDAT1_WAV        0x7665
01067 #define VS_HDAT1_AAC_ADTS   0x4154
01068 #define VS_HDAT1_AAC_ADIF   0x4144
01069 #define VS_HDAT1_AAC_MP4    0x4D34
01070 #define VS_HDAT1_WMA        0x574D
01071 #define VS_HDAT1_MIDI       0x4D54
01072 #define VS_HDAT1_OGG        0x4F67
01073 
01074 #endif
01075 
01080 /* ------------------------------------------------------------- */
01083 #if VS_HAS_IN1_REG
01084 #define VS_IN1_REG          9
01085 #endif
01086 
01093 /* ------------------------------------------------------------- */
01096 #define VS_AIADDR_REG      10
01097 
01102 /* ------------------------------------------------------------- */
01117 #define VS_VOL_REG         11
01118 
01123 #define VS_VOL_RIGHT        0x00FF
01124 
01126 #define VS_VOL_RIGHT_LSB    0
01127 
01132 #define VS_VOL_LEFT         0xFF00
01133 
01135 #define VS_VOL_LEFT_LSB     8
01136 
01137 #define VS_VOL_MAX          0x0000
01138 #define VS_VOL_MIN          0xFEFE
01139 #define VS_VOL_OFF          0xFFFF
01140 
01145 /* ------------------------------------------------------------- */
01150 #if VS_HAS_MIXERVOL_REG
01151 #define VS_MIXERVOL_REG     12
01152 #define VS_SMV_GAIN1        0x001F
01153 #define VS_SMV_GAIN2        0x03E0
01154 #define VS_SMV_GAIN3        0x7C00
01155 #define VS_SMV_ACTIVE       0x8000
01156 #endif
01157 
01162 /* ------------------------------------------------------------- */
01167 #if VS_HAS_ADPCMRECCTL_REG
01168 #define VS_ADPCMRECCTL_REG  13
01169 #define VS_SARC_GAIN4       0x003F
01170 #define VS_SARC_MANUALGAIN  0x0040
01171 #define VS_SARC_OUTOFADPCM  0x0080
01172 #endif
01173 
01178 /* ------------------------------------------------------------- */
01184 #if VS_HAS_AICTRL0_REG
01185 #define VS_AICTRL0_REG     12
01186 #endif
01187 
01192 #if VS_HAS_AICTRL_REG
01193 #define VS_AICTRL_REG      13
01194 #endif
01195 
01200 #if VS_HAS_AICTRL1_REG
01201 #define VS_AICTRL1_REG     13
01202 #endif
01203 
01207 #if VS_HAS_AICTRL2_REG
01208 #define VS_AICTRL2_REG     14
01209 #endif
01210 
01214 #if VS_HAS_AICTRL3_REG
01215 #define VS_AICTRL3_REG     15
01216 #define VS_AICTRL3_STEREO      0
01217 #define VS_AICTRL3_DUALCHANNEL 1
01218 #define VS_AICTRL3_LEFT        2
01219 #define VS_AICTRL3_RIGHT       3
01220 #define VS_AICTRL3_MONOMIX     4
01221 #define VS_ENCMODE_ADPCM      0x0000
01222 #define VS_ENCMODE_LPCM       0x0010
01223 #define VS_ENCMODE_G711_ULAW  0x0020
01224 #define VS_ENCMODE_G711_ALAW  0x0030
01225 #define VS_ENCMODE_G722       0x0040
01226 #define VS_ENCMODE_OGGVORBIS  0x0050
01227 #define VS_ENCMODE_MP3        0x0060
01228 #define VS_AICTRL3_CODECMODE  0x8000
01229 #define VS_AICTRL3_ENABLEAEC  0x4000
01230 #define VS_AICTRL3_ENABLEUART 0x2000
01231 #endif
01232 
01235 /*
01236  * Bytes needed to flush internal VS buffer (size of VS internal buffer)
01237  */
01238 #ifndef VS_FLUSH_BYTES
01239 #define VS_FLUSH_BYTES 2048
01240 #endif
01241 
01242 /*
01243  * Status of the decoder
01244  */
01245 #define CODEC_STATUS_IDLE       0
01246 #define CODEC_STATUS_PLAYING    1
01247 #define CODEC_STATUS_RECORDING  2
01248 
01249 /*
01250  * Header info filled by VsGetHeaderInfo.
01251  */
01252 #ifdef __GNUC__
01253 typedef struct __attribute__((packed)) {
01254     uint16_t vshi_no_crc:1;
01255     uint16_t vshi_layer:2;
01256     uint16_t vshi_id:2;
01257     uint16_t vshi_syncword:11;
01258 
01259     uint16_t vshi_emphasis:2;
01260     uint16_t vshi_original:1;
01261     uint16_t vshi_copyright:1;
01262     uint16_t vshi_extension:2;
01263     uint16_t vshi_mode:2;
01264     uint16_t vshi_private_bit:1;
01265     uint16_t vshi_pad_bit:1;
01266     uint16_t vshi_sample_rate:2;
01267     uint16_t vshi_bitrate:4;
01268 } VS_HEADERINFO;
01269 #endif
01270 
01271 #ifndef VSCODEC_CMD_TIMEOUT
01272 
01273 #define VSCODEC_CMD_TIMEOUT         NUT_WAIT_INFINITE
01274 #endif
01275 
01279 typedef struct _VSDCB {
01280     int dcb_pbstat;         
01281     uint32_t dcb_scmd;      
01282     int dcb_rvol;           
01283     int dcb_lvol;           
01284     int dcb_treb;           
01285     int dcb_tfin;           
01286     int dcb_bass;           
01287     int dcb_bfin;           
01288     uint16_t dcb_sinefreq;  
01289     uint32_t dcb_pbwlo;     
01290     uint32_t dcb_pbwhi;     
01291     uint32_t dcb_wtmo;      
01292     uint32_t dcb_rtmo;      
01293     HANDLE dcb_bufque;      
01294     HANDLE dcb_feedme;      
01295     uint16_t dcb_codec_ver; 
01296     char dcb_codec_rev;     
01297     uint32_t dcb_dec_caps;  
01298     uint32_t dcb_cod_caps;  
01299     uint32_t dcb_midi_caps; 
01300     uint32_t dcb_cod_mode;  
01301     int (*dcb_isready)(void);
01302     int (*dcb_sendcmd)(void *, size_t);
01303     int (*dcb_senddata)(const uint8_t *, size_t);
01304     int (*dcb_control)(int req, void *conf);
01305     int (*dcb_recvdata)(void *, size_t);
01306 } VSDCB;
01307 
01308 #ifndef VSCODEC_DATA_CHUNK_SIZE
01309 
01310 #define VSCODEC_DATA_CHUNK_SIZE     32
01311 #endif
01312 
01313 extern uint8_t zero_chunk[VSCODEC_DATA_CHUNK_SIZE];
01314 
01315 extern NUTDEVICE devVsCodec;
01316 extern NUTDEVICE devSpiVsCodec0;
01317 
01320 extern int VsCodecWaitReady(NUTDEVICE *dev, uint32_t tmo);
01321 extern uint16_t VsCodecReg(NUTDEVICE *dev, uint_fast8_t op, uint_fast8_t reg, uint_fast16_t val);
01322 extern uint16_t VsCodecMode(NUTDEVICE *dev, uint_fast16_t flags, uint_fast16_t mask);
01323 extern int VsDecoderSetVolume(NUTDEVICE *dev, int left, int right);
01324 extern int VsDecoderSetBass(NUTDEVICE *dev, int treb, int tfin, int bass, int bfin);
01325 extern uint16_t VsCodecBeep(NUTDEVICE *dev, uint16_t fsin);
01326 extern int VsDecoderBufferInit(NUTDEVICE *dev, uint32_t size);
01327 extern int VsCodecIOCtl(NUTDEVICE * dev, int req, void *conf);
01328 extern int VsCodecRead(NUTFILE * nfp, void *data, int len);
01329 extern int VsCodecWrite(NUTFILE * nfp, const void *data, int len);
01330 NUTFILE *VsCodecOpen(NUTDEVICE * dev, const char *name, int mode, int acc);
01331 extern int VsCodecClose(NUTFILE * nfp);
01332 
01333 #ifdef __HARVARD_ARCH__
01334 extern int VsCodecWrite_P(NUTFILE * nfp, PGM_P buffer, int len);
01335 #endif
01336 
01337 extern void FeederThread(void *arg) __attribute__ ((noreturn));
01338 
01339 #endif