Nut/OS  4.10.3
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 2661 2009-09-01 18:10:54Z 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_VSAUTO)
00061 #define AUDIO0_VSAUTO
00062 #endif
00063 
00064 /*
00065 ** Include codec features.
00066 */
00067 #if defined(AUDIO0_VS1001K)
00068 #include <dev/vs1001.h>
00069 #elif defined(AUDIO0_VS1002D)
00070 #include <dev/vs1002.h>
00071 #elif defined(AUDIO0_VS1003B)
00072 #include <dev/vs1003.h>
00073 #elif defined(AUDIO0_VS1011E)
00074 #include <dev/vs1011.h>
00075 #elif defined(AUDIO0_VS1033C)
00076 #include <dev/vs1033.h>
00077 #elif defined(AUDIO0_VS1053B)
00078 #include <dev/vs1053.h>
00079 #elif !defined(AUDIO0_VSAUTO)
00080 #define AUDIO0_VSAUTO
00081 #endif
00082 
00092 
00093 /* DAC min/max gain in dB. */
00094 #ifndef AUDIO0_DAC_MIN_GAIN
00095 #define AUDIO0_DAC_MIN_GAIN      -127
00096 #endif
00097 #ifndef AUDIO0_DAC_MAX_GAIN
00098 #define AUDIO0_DAC_MAX_GAIN      0
00099 #endif
00100 
00101 /* Backward compatibility, still used. */
00102 #ifndef AUDIO_DAC_MIN_GAIN
00103 #define AUDIO_DAC_MIN_GAIN      AUDIO0_DAC_MIN_GAIN
00104 #endif
00105 #ifndef AUDIO_DAC_MAX_GAIN
00106 #define AUDIO_DAC_MAX_GAIN      AUDIO0_DAC_MAX_GAIN
00107 #endif
00108 
00109 /* Audio decoder treble anhancement limits */
00110 #ifndef AUDIO_DAC_MAX_TREB
00111 #define AUDIO_DAC_MAX_TREB       8      /* VLSI1053 limits */
00112 #endif
00113 
00114 #ifndef AUDIO_DAC_MAX_TFIN
00115 #define AUDIO_DAC_MAX_TFIN      15      /* VLSI1053 limits */
00116 #endif
00117 
00118 #ifndef AUDIO_DAC_MAX_BASS
00119 #define AUDIO_DAC_MAX_BASS      15      /* VLSI1053 limits */
00120 #endif
00121 
00122 #ifndef AUDIO_DAC_MAX_BFIN
00123 #define AUDIO_DAC_MAX_BFIN      15      /* VLSI1053 limits */
00124 #endif
00125 
00126 /*
00127  * I/O control codes.
00128  */
00129 #define AUDIO_SETWRITETIMEOUT   0x010d
00130 #define AUDIO_GETWRITETIMEOUT   0x010e
00131 
00133 #define AUDIO_PLAY          0x3001
00134 
00135 #define AUDIO_CANCEL        0x3002
00136 #define AUDIO_GET_STATUS    0x3003
00137 #define AUDIO_GET_PLAYGAIN  0x3004
00138 #define AUDIO_SET_PLAYGAIN  0x3005
00139 #define AUDIO_GET_PBSIZE    0x3006
00140 #define AUDIO_SET_PBSIZE    0x3007
00141 #define AUDIO_GET_PBLEVEL   0x3008
00142 #define AUDIO_GET_PBWLOW    0x3009
00143 #define AUDIO_SET_PBWLOW    0x300A
00144 #define AUDIO_GET_PBWHIGH   0x300B
00145 #define AUDIO_SET_PBWHIGH   0x300C
00146 #define AUDIO_BEEP          0x300F
00147 
00148 #define AUDIO_GET_DECINFO   0x3010
00149 
00150 #define AUDIO_GET_DECCAPS   0x3011
00151 
00152 #define AUDIO_GET_DECFMTS   0x3012
00153 #define AUDIO_FMT_PLUGIN        0x00000001
00154 #define AUDIO_FMT_WAV_PCM       0x00000002
00155 #define AUDIO_FMT_WAV_ADPCM     0x00000004
00156 #define AUDIO_FMT_WAV_IMA_ADPCM 0x00000008
00157 #define AUDIO_FMT_VORBIS        0x00000100
00158 #define AUDIO_FMT_MPEG1_L1      0x00001000
00159 #define AUDIO_FMT_MPEG1_L2      0x00002000
00160 #define AUDIO_FMT_MPEG1_L3      0x00004000
00161 #define AUDIO_FMT_MPEG2_AAC     0x00010000
00162 #define AUDIO_FMT_MPEG4_AAC     0x00020000
00163 #define AUDIO_FMT_WMA_V2        0x00100000
00164 #define AUDIO_FMT_WMA_V7        0x00200000
00165 #define AUDIO_FMT_WMA_V8        0x00400000
00166 #define AUDIO_FMT_WMA_V9        0x00800000
00167 
00169 #define AUDIO_SET_DECFMTS   0x3013
00170 
00171 #define AUDIO_GET_CODINFO   0x3014
00172 
00173 #define AUDIO_GET_CODCAPS   0x3015
00174 
00175 #define AUDIO_GET_CODFMTS   0x3016
00176 
00177 #define AUDIO_SET_CODFMTS   0x3017
00178 
00179 #define AUDIO_GET_MIDINFO   0x3018
00180 
00181 #define AUDIO_GET_MIDCAPS   0x3019
00182 #define AUDIO_FMT_GMIDI1        0x00000001
00183 #define AUDIO_FMT_GMIDI2        0x00000002
00184 #define AUDIO_FMT_SPMIDI0       0x00000004
00185 
00186 #define AUDIO_SET_TREB      0x301a
00187 
00188 #define AUDIO_GET_TREB      0x301b
00189 
00190 #define AUDIO_SET_TFIN      0x301c
00191 
00192 #define AUDIO_GET_TFIN      0x301d
00193 
00194 #define AUDIO_SET_BASS      0x301e
00195 
00196 #define AUDIO_GET_BASS      0x301f
00197 
00198 #define AUDIO_SET_BFIN      0x3020
00199 
00200 #define AUDIO_GET_BFIN      0x3021
00201 
00203 #define AUDIO_PLUGIN_UPLOAD 0x3030
00204 
00206 #define AUDIO_IRQ_ENABLE    0x3031
00207 
00209 #define AUDIO_SET_ICLOCK    0x3032
00210 
00211 typedef struct _VS_PLUGIN_INFO VS_PLUGIN_INFO;
00212 
00213 struct _VS_PLUGIN_INFO {
00214     size_t vsplg_size;
00215     CONST uint16_t *vsplg_data;
00216 };
00217 
00218 /*
00219  * Instruction opcodes.
00220  */
00221 #define VS_OPCODE_READ  3
00222 #define VS_OPCODE_WRITE 2
00223 
00227 /* ------------------------------------------------------------- */
00230 #define VS_MODE_REG         0
00231 
00232 #define VS_SM_DIFF          0x0001
00233 
00242 #if VS_HAS_SM_LAYER12
00243 #define VS_SM_LAYER12       0x0002
00244 #endif
00245 
00257 #if VS_HAS_SM_FFWD
00258 #define VS_SM_FFWD          0x0002
00259 #endif
00260 
00265 #define VS_SM_RESET         0x0004
00266 
00267 
00279 #if VS_HAS_SM_MP12
00280 #define VS_SM_MP12          0x0008
00281 #endif
00282 
00291 #if VS_HAS_SM_OUTOFWAV
00292 #define VS_SM_OUTOFWAV      0x0008
00293 #endif
00294 
00304 #if VS_HAS_SM_CANCEL
00305 #define VS_SM_CANCEL        0x0008
00306 #endif
00307 
00319 #if VS_HAS_SM_PDOWN
00320 #define VS_SM_PDOWN         0x0010
00321 #endif
00322 
00325 #if VS_HAS_SM_EARSPEAKER
00326 #define VS_SM_EARSPEAKER_LO     0x0010
00327 #define VS_SM_SPATIAL_OFF       0
00328 #define VS_SM_SPATIAL_MINIMAL   VS_SM_EARSPEAKER_LO
00329 #define VS_SM_SPATIAL_NORMAL    VS_SM_EARSPEAKER_HI
00330 #define VS_SM_SPATIAL_EXTREME   (VS_SM_EARSPEAKER_LO | VS_SM_EARSPEAKER_LO)
00331 #endif
00332 
00343 #if VS_HAS_SM_DAC
00344 #define VS_SM_DAC           0x0020
00345 #endif
00346 
00351 #if VS_HAS_SM_TESTS
00352 #define VS_SM_TESTS         0x0020
00353 #endif
00354 
00365 #if VS_HAS_SM_DACMONO
00366 #define VS_SM_DACMONO       0x0040
00367 #endif
00368 
00380 #if VS_HAS_SM_STREAM
00381 #define VS_SM_STREAM        0x0040
00382 #endif
00383 
00388 #if VS_HAS_SM_BASS
00389 #define VS_SM_BASS          0x0080
00390 #endif
00391 
00392 #if VS_HAS_SM_EARSPEAKER
00393 #define VS_SM_EARSPEAKER_HI 0x0080
00394 #endif
00395 
00401 #define VS_SM_DACT          0x0100
00402 
00408 #define VS_SM_BITORD        0x0200
00409 
00414 #define VS_SM_SDIORD        0x0200
00415 
00423 #if VS_HAS_SM_IBMODE
00424 #define VS_SM_IBMODE        0x0400
00425 #endif
00426 
00428 #if VS_HAS_SM_SDISHARE
00429 #define VS_SM_SDISHARE      0x0400
00430 #endif
00431 
00439 #if VS_HAS_SM_IBCLK
00440 #define VS_SM_IBCLK         0x0800
00441 #endif
00442 
00449 #if VS_HAS_SM_SDINEW
00450 #define VS_SM_SDINEW        0x0800
00451 #endif
00452 
00457 #if VS_HAS_SM_ADPCM
00458 #define VS_SM_ADPCM         0x1000
00459 #endif
00460 
00469 #if VS_HAS_SM_ADPCM_HP
00470 #define VS_SM_ADPCM_HP      0x2000
00471 #endif
00472 
00480 #if VS_HAS_SM_LINE_IN
00481 #define VS_SM_LINE_IN       0x4000
00482 #endif
00483 
00491 #if VS_HAS_SM_CLK_RANGE
00492 #define VS_SM_CLK_RANGE     0x8000
00493 #endif
00494 
00500 /* ------------------------------------------------------------- */
00503 #define VS_STATUS_REG       1
00504 
00513 #if VS_HAS_SS_AVOL
00514 #define VS_SS_AVOL          0x0003
00515 
00516 #define VS_SS_AVOL_LSB      0
00517 #endif
00518 
00527 #if VS_HAS_SS_VREF_1_65
00528 #define VS_SS_VREF_1_65     0x0001
00529 #endif
00530 
00547 #if VS_HAS_SS_AD_CLOCK
00548 #define VS_SS_AD_CLOCK      0x0002
00549 #endif
00550 
00555 #define VS_SS_APDOWM1       0x0004
00556 
00567 #define VS_SS_APDOWN2       0x0008
00568 
00579 #define VS_SS_VER           0x00F0
00580 
00581 #define VS_SS_VER_LSB       4
00582 
00583 #define VS1001_SS_VER       0
00584 #define VS1011_SS_VER       1
00585 #define VS1011E_SS_VER      2
00586 #define VS1002_SS_VER       2
00587 #define VS1003_SS_VER       3
00588 #define VS1053_SS_VER       4
00589 #define VS1033_SS_VER       5
00590 #define VS1103_SS_VER       7
00591 
00598 #if VS_HAS_SS_VCM_DISABLE
00599 #define VS_SS_VCM_DISABLE   0x0400
00600 #endif
00601 
00606 #if VS_HAS_SS_VCM_OVERLOAD
00607 #define VS_SS_VCM_OVERLOAD  0x0800
00608 #endif
00609 
00619 #if VS_HAS_SS_SWING
00620 #define VS_SS_SWING         0x7000
00621 #define VS_SS_SWING_LSB     12
00622 #define VS_SS_SWING_NORMAL  0
00623 #define VS_SS_SWING_MAX     2
00624 #endif
00625 
00631 #if VS_HAS_SS_DO_NOT_JUMP
00632 #define VS_SS_DO_NOT_JUMP   0x8000
00633 #endif
00634 
00640 /* ------------------------------------------------------------- */
00646 #if VS_HAS_INT_FCTLH_REG
00647 #define VS_INT_FCTLH_REG    2
00648 #endif
00649 
00655 /* ------------------------------------------------------------- */
00664 #if VS_HAS_BASS_REG
00665 #define VS_BASS_REG         2
00666 
00676 #define VS_SB_FREQLIMIT     0x000F
00677 
00678 #define VS_SB_FREQLIMIT_LSB 0
00679 
00684 #define VS_SB_AMPLITUDE     0x00F0
00685 
00686 #define VS_SB_AMPLITUDE_LSB 4
00687 
00692 #define VS_ST_FREQLIMIT     0x0F00
00693 
00694 #define VS_ST_FREQLIMIT_LSB 8
00695 
00700 #define VS_ST_AMPLITUDE     0xF000
00701 
00702 #define VS_ST_AMPLITUDE_LSB 12
00703 #endif
00704 
00709 /* ------------------------------------------------------------- */
00712 #define VS_CLOCKF_REG       3
00713 
00724 #if VS_HAS_SC_FREQ
00725 #define VS_SC_FREQ          0x7FFF
00726 
00727 #define VS_SC_FREQ_LSB      0
00728 #endif
00729 
00737 #if VS_HAS_SC_X3FREQ
00738 #define VS_SC_X3FREQ        0x07FF
00739 #endif
00740 
00747 #if VS_HAS_SC_ADD
00748 #define VS_SC_ADD           0x1800
00749 #define VS_SC_ADD_NONE      0x0000
00750 #if VS_HAS_SC_ADD2
00751 #define VS_SC_ADD_1_0       0x0800
00752 #define VS_SC_ADD_1_5       0x1000
00753 #define VS_SC_ADD_2_0       0x1800
00754 #else
00755 #define VS_SC_ADD_0_5       0x0800
00756 #define VS_SC_ADD_1_0       0x1000
00757 #define VS_SC_ADD_1_5       0x1800
00758 #endif
00759 #endif
00760 
00766 #if VS_HAS_SC_MULT
00767 #define VS_SC_MULT          0xE000
00768 #define VS_SC_MULT_1_0      0x0000
00769 #if VS_HAS_SC_MULT5
00770 #define VS_SC_MULT_2_0      0x2000
00771 #define VS_SC_MULT_2_5      0x4000
00772 #define VS_SC_MULT_3_0      0x6000
00773 #define VS_SC_MULT_3_5      0x8000
00774 #define VS_SC_MULT_4_0      0xA000
00775 #define VS_SC_MULT_4_5      0xC000
00776 #define VS_SC_MULT_5_0      0xE000
00777 #else
00778 #define VS_SC_MULT_1_5      0x2000
00779 #define VS_SC_MULT_2_0      0x4000
00780 #define VS_SC_MULT_2_5      0x6000
00781 #define VS_SC_MULT_3_0      0x8000
00782 #define VS_SC_MULT_3_5      0xA000
00783 #define VS_SC_MULT_4_0      0xC000
00784 #define VS_SC_MULT_4_5      0xE000
00785 #endif
00786 #endif
00787 
00792 #if VS_HAS_CF_DOUBLER
00793 #define VS_CF_DOUBLER       0x8000
00794 #endif
00795 
00801 /* ------------------------------------------------------------- */
00811 #define VS_DECODE_TIME_REG  4
00812 
00817 /* ------------------------------------------------------------- */
00823 #define VS_AUDATA_REG       5
00824 
00830 #if VS_HAS_AD_STEREO_BIT0
00831 #define VS_AD_STEREO        0x0001
00832 #else
00833 #define VS_AD_STEREO        0x8000
00834 #endif
00835 
00844 #if VS_HAS_AD_SAMRATE
00845 #if VS_HAS_AD_STEREO_BIT0
00846 #define VS_AD_SAMRATE       0xFFFE
00847 
00848 #define VS_AD_SAMRATE_LSB   1
00849 #else
00850 #define VS_AD_SAMRATE       0x7FFF
00851 #define VS_AD_SAMRATE_LSB   0
00852 #endif
00853 #endif
00854 
00857 #if VS_HAS_AD_BITRATE
00858 #define VS_AD_BITRATE       0x01FF
00859 #define VS_AD_BITRATE_LSB   0
00860 #endif
00861 
00864 #if VS_HAS_AD_SAMRATE_IDX
00865 #define VS_AD_SAMRATE_IDX       0x1E00
00866 #define VS_AD_SAMRATE_IDX_LSB   9
00867 
00868 #define VS_AD_SAMRATE_44100     1
00869 #define VS_AD_SAMRATE_48000     2
00870 #define VS_AD_SAMRATE_32000     3
00871 #define VS_AD_SAMRATE_22050     4
00872 #define VS_AD_SAMRATE_24000     5
00873 #define VS_AD_SAMRATE_16000     6
00874 #define VS_AD_SAMRATE_11025     7
00875 #define VS_AD_SAMRATE_12000     8
00876 #define VS_AD_SAMRATE_8000      9
00877 #endif
00878 
00884 /* ------------------------------------------------------------- */
00890 #define VS_WRAM_REG         6
00891 
00896 /* ------------------------------------------------------------- */
00902 #define VS_WRAMADDR_REG     7
00903 
00908 /* ------------------------------------------------------------- */
00919 #if VS_HAS_HDAT0_REG
00920 #define VS_HDAT0_REG            8
00921 
00922 #define VS_HDAT0_EMPHAS         0x0003
00923 #define VS_HDAT0_EMPHAS_LSB     0
00924 
00925 #define VS_HDAT0_EMPHAS_NONE    0
00926 #define VS_HDAT0_EMPHAS_5015    1
00927 #define VS_HDAT0_EMPHAS_J17     3
00928 
00929 #define VS_HDAT0_ORIGIN         0x0004
00930 
00931 #define VS_HDAT0_COPY           0x0008
00932 
00933 #define VS_HDAT0_EXT            0x0030
00934 
00935 #define VS_HDAT0_MODE           0x00C0
00936 #define VS_HDAT0_MODE_LSB       6
00937 
00938 #define VS_HDAT0_MODE_STEREO    0
00939 #define VS_HDAT0_MODE_JSTEREO   1
00940 #define VS_HDAT0_MODE_DUAL      2
00941 #define VS_HDAT0_MODE_MONO      3
00942 
00943 #define VS_HDAT0_PRIV           0x0100
00944 
00945 #define VS_HDAT0_PAD            0x0200
00946 
00947 #define VS_HDAT0_SAMRATE        0x0C00
00948 #define VS_HDAT0_SAMRATE_LSB    10
00949 
00950 #define VS_HDAT0_SAMRATE_11B    0
00951 #define VS_HDAT0_SAMRATE_12B    1
00952 #define VS_HDAT0_SAMRATE_8B     2
00953 
00954 #define VS_HDAT0_BITRATE        0xF000
00955 #endif
00956 
00961 /* ------------------------------------------------------------- */
00964 #if VS_HAS_IN0_REG
00965 #define VS_IN0_REG          8
00966 #endif
00967 
00972 /* ------------------------------------------------------------- */
00978 #if VS_HAS_HDAT1_REG
00979 #define VS_HDAT1_REG        9
00980 
00981 #define VS_HDAT1_PROT       0x0001
00982 #define VS_HDAT1_LAYER      0x0006
00983 #define VS_HDAT1_ID         0x0018
00984 
00985 #define VS_HDAT1_SYNC       0xFFE0
00986 #define VS_HDAT1_WAV        0x7665
00987 #define VS_HDAT1_AAC_ADTS   0x4154
00988 #define VS_HDAT1_AAC_ADIF   0x4144
00989 #define VS_HDAT1_AAC_MP4    0x4D34
00990 #define VS_HDAT1_WMA        0x574D
00991 #define VS_HDAT1_MIDI       0x4D54
00992 #define VS_HDAT1_OGG        0x4F67
00993 
00994 #endif
00995 
01000 /* ------------------------------------------------------------- */
01003 #if VS_HAS_IN1_REG
01004 #define VS_IN1_REG          9
01005 #endif
01006 
01013 /* ------------------------------------------------------------- */
01016 #define VS_AIADDR_REG      10
01017 
01022 /* ------------------------------------------------------------- */
01037 #define VS_VOL_REG         11
01038 
01043 #define VS_VOL_RIGHT        0x00FF
01044 
01046 #define VS_VOL_RIGHT_LSB    0
01047 
01052 #define VS_VOL_LEFT         0xFF00
01053 
01055 #define VS_VOL_LEFT_LSB     8
01056 
01057 #define VS_VOL_MAX          0x0000
01058 #define VS_VOL_MIN          0xFEFE
01059 #define VS_VOL_OFF          0xFFFF
01060 
01065 /* ------------------------------------------------------------- */
01070 #if VS_HAS_MIXERVOL_REG
01071 #define VS_MIXERVOL_REG     12
01072 #define VS_SMV_GAIN1        0x001F
01073 #define VS_SMV_GAIN2        0x03E0
01074 #define VS_SMV_GAIN3        0x7C00
01075 #define VS_SMV_ACTIVE       0x8000
01076 #endif
01077 
01082 /* ------------------------------------------------------------- */
01087 #if VS_HAS_ADPCMRECCTL_REG
01088 #define VS_ADPCMRECCTL_REG  13
01089 #define VS_SARC_GAIN4       0x003F
01090 #define VS_SARC_MANUALGAIN  0x0040
01091 #define VS_SARC_OUTOFADPCM  0x0080
01092 #endif
01093 
01098 /* ------------------------------------------------------------- */
01104 #if VS_HAS_AICTRL0_REG
01105 #define VS_AICTRL0_REG     12
01106 #endif
01107 
01112 #if VS_HAS_AICTRL_REG
01113 #define VS_AICTRL_REG      13
01114 #endif
01115 
01120 #if VS_HAS_AICTRL1_REG
01121 #define VS_AICTRL1_REG     13
01122 #endif
01123 
01127 #if VS_HAS_AICTRL2_REG
01128 #define VS_AICTRL2_REG     14
01129 #endif
01130 
01134 #if VS_HAS_AICTRL3_REG
01135 #define VS_AICTRL3_REG     15
01136 #endif
01137 
01140 /*
01141  * Bytes needed to flush internal VS buffer (size of VS internal buffer)
01142  */
01143 #ifndef VS_FLUSH_BYTES
01144 #define VS_FLUSH_BYTES 2048
01145 #endif
01146 
01147 /*
01148  * Status of the decoder
01149  */
01150 #define CODEC_STATUS_IDLE       0
01151 #define CODEC_STATUS_PLAYING    1
01152 #define CODEC_STATUS_RECORDING  2
01153 
01154 /*
01155  * Header info filled by VsGetHeaderInfo.
01156  */
01157 #ifdef __GNUC__
01158 typedef struct __attribute__((packed)) {
01159     uint16_t vshi_no_crc:1;
01160     uint16_t vshi_layer:2;
01161     uint16_t vshi_id:2;
01162     uint16_t vshi_syncword:11;
01163 
01164     uint16_t vshi_emphasis:2;
01165     uint16_t vshi_original:1;
01166     uint16_t vshi_copyright:1;
01167     uint16_t vshi_extension:2;
01168     uint16_t vshi_mode:2;
01169     uint16_t vshi_private_bit:1;
01170     uint16_t vshi_pad_bit:1;
01171     uint16_t vshi_sample_rate:2;
01172     uint16_t vshi_bitrate:4;
01173 } VS_HEADERINFO;
01174 #endif
01175 
01176 #ifndef VSCODEC_CMD_TIMEOUT
01177 
01178 #define VSCODEC_CMD_TIMEOUT         NUT_WAIT_INFINITE
01179 #endif
01180 
01184 typedef struct _VSDCB {
01185     int dcb_pbstat;         
01186     uint32_t dcb_scmd;      
01187     int dcb_rvol;           
01188     int dcb_lvol;           
01189     int dcb_treb;           
01190     int dcb_tfin;           
01191     int dcb_bass;           
01192     int dcb_bfin;           
01193     uint16_t dcb_sinefreq;  
01194     uint32_t dcb_pbwlo;     
01195     uint32_t dcb_pbwhi;     
01196     uint32_t dcb_wtmo;      
01197     uint32_t dcb_rtmo;      
01198     HANDLE dcb_bufque;      
01199     HANDLE dcb_feedme;      
01200     uint16_t dcb_codec_ver; 
01201     char dcb_codec_rev;     
01202     uint32_t dcb_dec_caps;  
01203     uint32_t dcb_cod_caps;  
01204     uint32_t dcb_midi_caps; 
01205     uint32_t dcb_cod_mode;  
01206     int (*dcb_isready)(void);
01207     int (*dcb_sendcmd)(void *, size_t);
01208     int (*dcb_senddata)(CONST uint8_t *, size_t);
01209     int (*dcb_control)(int req, void *conf);
01210 } VSDCB;
01211 
01212 #ifndef VSCODEC_DATA_CHUNK_SIZE
01213 
01214 #define VSCODEC_DATA_CHUNK_SIZE     32
01215 #endif
01216 
01217 extern uint8_t zero_chunk[VSCODEC_DATA_CHUNK_SIZE];
01218 
01219 extern NUTDEVICE devVsCodec;
01220 extern NUTDEVICE devSpiVsCodec0;
01221 
01224 __BEGIN_DECLS
01225 /* Function prototypes */
01226 extern int VsCodecWaitReady(NUTDEVICE *dev, uint32_t tmo);
01227 extern uint16_t VsCodecReg(NUTDEVICE *dev, uint_fast8_t op, uint_fast8_t reg, uint_fast16_t val);
01228 extern uint16_t VsCodecMode(NUTDEVICE *dev, uint_fast16_t flags, uint_fast16_t mask);
01229 extern int VsDecoderSetVolume(NUTDEVICE *dev, int left, int right);
01230 extern int VsDecoderSetBass(NUTDEVICE *dev, int treb, int tfin, int bass, int bfin);
01231 extern uint16_t VsCodecBeep(NUTDEVICE *dev, uint16_t fsin);
01232 extern int VsDecoderBufferInit(NUTDEVICE *dev, uint32_t size);
01233 extern int VsCodecIOCtl(NUTDEVICE * dev, int req, void *conf);
01234 extern int VsCodecRead(NUTFILE * nfp, void *data, int len);
01235 extern int VsCodecWrite(NUTFILE * nfp, CONST void *data, int len);
01236 NUTFILE *VsCodecOpen(NUTDEVICE * dev, CONST char *name, int mode, int acc);
01237 extern int VsCodecClose(NUTFILE * nfp);
01238 
01239 #ifdef __HARVARD_ARCH__
01240 extern int VsCodecWrite_P(NUTFILE * nfp, PGM_P buffer, int len);
01241 #endif
01242 
01243 extern void FeederThread(void *arg) __attribute__ ((noreturn));
01244 
01245 __END_DECLS
01246 /* End of prototypes */
01247 
01248 #endif