123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616 |
-
- #ifndef _DSP_HAL_DEFS_H_
- #define _DSP_HAL_DEFS_H_
- #include <stdint.h>
- #include <drivers/dsp.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define RINGBUF_TYPE uint32_t
- #define DSP_SUPPORT_VOICE_EFFECT
- #define DSP_SUPPORT_DEBUG_PRINT
- #define DSP_SUPPORT_MULTI_BUFFER_NUM (2)
- #define DSP_SUPPORT_AEC_REFBUF_NUM (1)
- #define DSP_AEC_REF_DELAY (1)
- #ifdef DSP_SUPPORT_MUSIC_EFFECT
- #define DSP_SUPPORT_PLAYER
- #define DSP_SUPPORT_DECODER
- #define DSP_SUPPORT_DECODER_DAE
- #define DSP_SUPPORT_AAC_DECODER
- #define DSP_SUPPORT_OUTPUT_SUBWOOFER
- #endif
- #ifdef DSP_SUPPORT_VOICE_EFFECT
- #define DSP_SUPPORT_PLAYER
- #define DSP_SUPPORT_RECODER
- #define DSP_SUPPORT_DECODER
- #define DSP_SUPPORT_ENCODER
- #define DSP_SUPPORT_AGC
- #define DSP_SUPPORT_PEQ
- #define DSP_SUPPORT_DECODER_AGC
- #define DSP_SUPPORT_DECODER_PEQ
- #define DSP_SUPPORT_ENCODER_AGC
- #define DSP_SUPPORT_ENCODER_PEQ
- #define DSP_SUPPORT_MSBC_DECODER
- #define DSP_SUPPORT_MSBC_ENCODER
- #define DSP_SUPPORT_ENCODER_AEC
- #define DSP_SUPPORT_HARDWARE_AEC_SYNC
- #define DSP_SUPPORT_ENCODER_CNG
- #endif
- #if !defined(DSP_SUPPORT_MUSIC_EFFECT) && !defined(DSP_SUPPORT_VOICE_EFFECT)
- #define DSP_SUPPORT_RECODER
- #define DSP_SUPPORT_ENCODER
- #define DSP_SUPPORT_OPUS_ENCODER
- #endif
- #ifdef DSP_SUPPORT_DEBUG_PRINT
- #define DSP_PUTS(a) dsp_puts(a)
- #define DSP_PRINTHEX(a) dsp_printhex(a)
- #else
- #define DSP_PUTS(a)
- #define DSP_PRINTHEX(a)
- #endif
- enum {
- DSP_SESSION_DEFAULT = 0,
- DSP_SESSION_MEDIA,
- DSP_NUM_SESSIONS,
- };
- enum {
-
- DSP_FUNCTION_DECODER = 0,
- DSP_FUNCTION_ENCODER,
-
- DSP_FUNCTION_PLAYER,
- DSP_FUNCTION_RECORDER,
- DSP_FUNCTION_PREPROCESS,
- DSP_FUNCTION_POSTPROCESS,
- DSP_NUM_FUNCTIONS,
- };
- #define DSP_FUNC_BIT(func) BIT(func)
- #define DSP_FUNC_ALL BIT_MASK(DSP_NUM_FUNCTIONS)
- #if defined(DSP_SUPPORT_CVSD_DECODER) || defined(DSP_SUPPORT_CVSD_ENCODER)
- #define PCM_FRAMESZ (128)
- #else
- #define PCM_FRAMESZ (256)
- #endif
- enum {
-
- DSP_CMD_USER_DEFINED = 32,
- DSP_MIN_SESSION_CMD = DSP_CMD_USER_DEFINED,
-
- DSP_CMD_SESSION_INIT = DSP_MIN_SESSION_CMD,
-
- DSP_CMD_SESSION_BEGIN,
-
- DSP_CMD_SESSION_END,
-
- DSP_CMD_SESSION_USER_DEFINED,
- DSP_MAX_SESSION_CMD = DSP_MIN_SESSION_CMD + 0xFF,
-
- DSP_MIN_FUNCTION_CMD = DSP_MAX_SESSION_CMD + 0x1,
-
- DSP_CMD_FUNCTION_CONFIG = DSP_MIN_FUNCTION_CMD,
-
- DSP_CMD_FUNCTION_ENABLE,
-
- DSP_CMD_FUNCTION_DISABLE,
-
- DSP_CMD_FUNCTION_DEBUG,
-
- DSP_CMD_FUNCTION_PAUSE,
-
- DSP_CMD_FUNCTION_RESUME,
-
- DSP_CMD_FUNCTION_USER_DEFINED,
- DSP_MAX_FUNCTION_CMD = DSP_MIN_FUNCTION_CMD + 0xFF,
- };
- enum {
-
- DSP_CONFIG_DEFAULT = 0,
-
- DSP_CONFIG_DECODER,
-
- DSP_CONFIG_ENCODER,
-
- DSP_CONFIG_DAE,
-
- DSP_CONFIG_AEC_REF,
-
- DSP_CONFIG_AEC,
-
- DSP_CONFIG_MIX,
-
- DSP_CONFIG_OUTPUT,
-
- DSP_CONFIG_DECODER_EXT,
- DSP_CONFIG_ENERGY,
- DSP_CONFIG_MSIC,
- DSP_CONFIG_DAE_DRM,
- };
- enum {
-
- DSP_BAD_STREAM = 32,
- };
- enum {
- DSP_CODEC_FORMAT_MP3 = 1,
- DSP_CODEC_FORMAT_WMA = 2,
- DSP_CODEC_FORMAT_WAV = 3,
- DSP_CODEC_FORMAT_FLAC = 4,
- DSP_CODEC_FORMAT_APE = 5,
- DSP_CODEC_FORMAT_AAC = 6,
- DSP_CODEC_FORMAT_OGG = 7,
- DSP_CODEC_FORMAT_ACT = 8,
- DSP_CODEC_FORMAT_AMR = 9,
- DSP_CODEC_FORMAT_SBC = 10,
- DSP_CODEC_FORMAT_MSBC = 11,
- DSP_CODEC_FORMAT_OPUS = 12,
- DSP_CODEC_FORMAT_CVSD = 15,
- DSP_CODEC_FORMAT_SPEECH = 16,
- DSP_CODEC_FORMAT_PCM = 17,
- DSP_CODEC_FORMAT_LDAC = 18,
- DSP_CODEC_FORMAT_NAV = 19,
- DSP_CODEC_FORMAT_NAV_SEP = 20,
- DSP_CODEC_FORMAT_AAC_M4A = 21,
- };
- enum {
- RESAMPLE_SAMPLERATE_16 = 16000,
- RESAMPLE_SAMPLERATE_44_1 = 44100,
- RESAMPLE_SAMPLERATE_48 = 48000,
- };
- enum {
- RESAMPLE_FRAMESZ_44_1 = 441,
- RESAMPLE_FRAMESZ_48 = 480,
- RESAMPLE_FRAMESZ_16 = 160,
- };
- enum {
- REF_STREAM_NULL = 0,
- REF_STREAM_MONO,
- REF_STREAM_LEFT,
- REF_STREAM_RIGHT,
- };
- enum {
- MIX_MODE_NULL,
- MIX_MODE_LEFT_RIGHT,
- MIX_MODE_LEFT,
- MIX_MODE_RIGHT,
- MIX_MODE_L_R_SWITCH,
- MIX_MODE_L_R_MERGE,
- };
- enum {
- AEC_NOT_INIT = 0,
- AEC_CONFIGED,
- AEC_START,
- };
- struct media_dspssn_params {
- int16_t aec_en;
- } __packed;
- struct media_dspssn_info {
- struct media_dspssn_params params;
- } __packed;
- struct test_dspfunc_params {
- RINGBUF_TYPE inbuf;
- RINGBUF_TYPE refbuf;
- RINGBUF_TYPE outbuf;
- } __packed;
- struct test_dspfunc_runtime {
- uint32_t sample_count;
- } __packed;
- struct test_dspfunc_debug {
- RINGBUF_TYPE inbuf;
- RINGBUF_TYPE refbuf;
- RINGBUF_TYPE outbuf;
- } __packed;
- struct test_dspfunc_info {
- struct test_dspfunc_params params;
- struct test_dspfunc_runtime runtime;
- } __packed;
- struct decoder_resample_params{
- uint32_t input_sr;
- uint32_t output_sr;
- uint32_t input_sample_pairs;
- uint32_t output_sample_pairs;
- } __packed;
- struct decoder_dspfunc_params {
- uint16_t slot;
- uint16_t format;
- uint16_t channels;
- uint16_t sample_bits;
- uint32_t sample_rate;
- RINGBUF_TYPE inbuf;
- RINGBUF_TYPE resbuf;
- RINGBUF_TYPE outbuf;
- struct decoder_resample_params resample_param;
- } __packed;
- struct decoder_dspfunc_ext_params {
-
- uint32_t format_pbuf;
- uint32_t format_pbufsz;
-
- RINGBUF_TYPE evtbuf;
- } __packed;
- struct mix_channel_params{
-
- uint16_t channels:2;
- uint16_t vol:6;
- uint16_t is_mute:1;
- uint16_t mix_mode:3;
- uint16_t sample_bits:1;
- uint16_t running:1;
- uint16_t master_channel:1;
- uint16_t reserved:1;
- uint16_t input_sr:8;
- uint16_t output_sr:8;
- RINGBUF_TYPE chan_buf;
- RINGBUF_TYPE res_buf;
- } __packed;
- struct mix_dspfunc_params{
- uint32_t channel_num;
- struct mix_channel_params channel_params[DSP_SUPPORT_MULTI_BUFFER_NUM];
- } __packed;
- struct output_dspfunc_params{
- RINGBUF_TYPE outbuf;
- RINGBUF_TYPE outbuf_subwoofer;
- RINGBUF_TYPE hdrbuf;
- uint32_t sample_bits:1;
- uint32_t reserved:31;
- } __packed;
- struct energy_dspfunc_params{
- RINGBUF_TYPE energy_buf;
- } __packed;
- struct decoder_dspfunc_runtime {
- uint32_t frame_size;
- uint32_t channels;
- uint32_t sample_count;
- uint32_t datalost_count;
- uint32_t raw_count;
- } __packed;
- struct decoder_dspfunc_debug {
- RINGBUF_TYPE stream;
- RINGBUF_TYPE pcmbuf;
- RINGBUF_TYPE plcbuf;
- } __packed;
- struct decoder_dspfunc_info {
- struct decoder_dspfunc_params params;
- struct decoder_dspfunc_runtime runtime;
- struct decoder_dspfunc_debug debug;
- struct decoder_dspfunc_ext_params ext_params;
- } __packed;
- struct encoder_dspfunc_params {
- uint16_t slot;
- uint16_t format;
- uint16_t sub_format;
- uint16_t sample_bits;
- uint16_t sample_rate_orig;
- uint16_t sample_rate;
- uint32_t bit_rate;
- uint16_t complexity;
- uint16_t channels;
- uint32_t frame_size;
- RINGBUF_TYPE inbuf;
- RINGBUF_TYPE outbuf;
- } __packed;
- struct encoder_dspfunc_runtime {
- uint32_t frame_size;
- uint32_t channels;
- uint32_t compression_ratio;
- uint32_t sample_count;
- } __packed;
- struct encoder_dspfunc_debug {
- RINGBUF_TYPE pcmbuf;
- RINGBUF_TYPE stream;
- } __packed;
- struct encoder_dspfunc_info {
- struct encoder_dspfunc_params params;
- struct encoder_dspfunc_runtime runtime;
- struct encoder_dspfunc_debug debug;
- } __packed;
- struct preprocess_dspfunc_info {
- struct encoder_dspfunc_params params;
- struct encoder_dspfunc_runtime runtime;
- struct encoder_dspfunc_debug debug;
- } __packed;
- struct dae_dspfunc_params {
- uint32_t pbuf;
- uint32_t pbufsz;
- } __packed;
- struct aec_dspfunc_channel_params{
-
- int16_t stream_type;
-
- RINGBUF_TYPE srcbuf;
-
- RINGBUF_TYPE refbuf;
- } __packed;
- struct aec_dspfunc_ref_params{
-
- int16_t delay;
-
- int16_t channel_num;
-
- struct aec_dspfunc_channel_params channel[DSP_SUPPORT_AEC_REFBUF_NUM];
- } __packed;
- struct aec_dspfunc_params {
-
- int16_t enable;
-
- int16_t channel_num;
-
- int16_t block_size;
-
- int16_t dropped_samples;
-
- RINGBUF_TYPE inbuf;
-
- RINGBUF_TYPE refbuf[DSP_SUPPORT_AEC_REFBUF_NUM];
-
- RINGBUF_TYPE outbuf;
- } __packed;
- struct misc_dspfunc_parsms {
- int16_t auto_mute;
- int16_t auto_mute_threshold;
- int16_t reserved[2];
- }__packed;
- struct streamout_dspfunc_params {
- struct dae_dspfunc_params dae;
- struct aec_dspfunc_ref_params aec_ref;
- struct output_dspfunc_params output;
- struct mix_dspfunc_params mix;
- struct energy_dspfunc_params energy;
- struct misc_dspfunc_parsms misc;
- } __packed;
- struct streamout_dspfunc_runtime {
- } __packed;
- struct streamout_dspfunc_debug {
- } __packed;
- struct streamout_dspfunc_info {
- struct streamout_dspfunc_params params;
- struct streamout_dspfunc_runtime runtime;
- struct streamout_dspfunc_debug debug;
- } __packed;
- struct player_dspfunc_debug {
- RINGBUF_TYPE decode_stream;
- RINGBUF_TYPE decode_data;
- RINGBUF_TYPE plc_data;
- } __packed;
- struct player_dspfunc_info {
- struct dae_dspfunc_params dae;
- struct aec_dspfunc_ref_params aec_ref;
- struct output_dspfunc_params output;
- const struct decoder_dspfunc_info *decoder_info;
- struct mix_dspfunc_params mix;
- struct player_dspfunc_debug debug;
- struct energy_dspfunc_params energy;
- const struct streamout_dspfunc_info *streamout_info;
- } __packed;
- struct recorder_dspfunc_debug {
- RINGBUF_TYPE mic1_data;
- RINGBUF_TYPE mic2_data;
- RINGBUF_TYPE ref_data;
- RINGBUF_TYPE aec1_data;
- RINGBUF_TYPE aec2_data;
- RINGBUF_TYPE encode_data;
- RINGBUF_TYPE encode_stream;
- } __packed;
- struct recorder_dspfunc_info {
- struct dae_dspfunc_params dae;
- struct aec_dspfunc_params aec;
- const struct preprocess_dspfunc_info * preprocess_info;
- const struct encoder_dspfunc_info * encoder_info;
- struct recorder_dspfunc_debug debug;
- } __packed;
- #ifdef __cplusplus
- }
- #endif
- #endif
|