123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619 |
- #ifndef __DRV_MP_DESP_H__
- #define __DRV_MP_DESP_H__
- #include "drv_types.h"
- /* ----- main buffer descriptor ---------------------------------------- */
- /* Note: Currently mpeg, mp3, aac, and cook
- use this basical buffer descriptor. */
- typedef struct __MPBUF_DESP
- {
- /* mp buffer descriptor flag */
- UINT8 mp_flag;
- #define MP_FLAG_MEDIAPLAYER 0
- #define MP_FLAG_DECODE_ONLY 1
- #define MP_FLAG_NEWMEDIAPLAYER 2
- #define MP_FLAG_GENERAL_INFO 3
- #define MP_FLAG_DDP_LICENSE 4
- #define MP_FLAG_ENCODE_ONLY 5
- /* Aync dec/enc path */
- #define MP_FLAG_AUDIODSP 0x10
- /* audio type, used only for flag = MP_FLAG_SISMEDIA_PLAYER */
- /* please see enum MP_DATA_TYPE_T */
- UINT8 audio_type;
- /* sample rate, used only for flag = MP_FLAG_SISMEDIA_PLAYER */
- /* please see enum MP_SFREQ_T */
- UINT8 sfreq;
- /* used only for flag = MP_FLAG_DECODE_ONLY */
- union
- {
- /*according to differnet source, do some special rules*/
- /*please see enum MP_SOURCE_T*/
- UINT8 input_source;
- #define MP_SOURCE_FFMPEG 0
- #define MP_SOURCE_FLASH 1
- #define MP_SOURCE_UNKNOWN 0xff
- UINT8 reserved01;
- struct
- {
- UINT8 bUseMultiPcmBuf : 1;
- UINT8 Buf_FrameNo: 6;
- UINT8 unused : 1;
- };
- };
- union
- {
- /* input audio buffer address/offset */
- UINT32 buf_offset;
- UINT32 pcm_desp_idx; //for MultiPcmBuf
- UINT32 buf_addr;
- };
- /* input audio buffer size */
- UINT32 buf_size;
- union
- {
- #define MP_PTSCNT_PER_SEC (45000)
- /* used only for flag = MP_FLAG_SISMEDIA_PLAYER */
- UINT32 pts; /* 45000 per second */
- /* used only for flag = MP_FLAG_DECODE_ONLY */
- UINT32 decbuf_offset;
- /*used only for flag = MP_FLAG_ENCODE_ONLY*/
- UINT32 enc_outbuf_offset;
- };
- union
- {
- /* used only for flag = MP_FLAG_SISMEDIA_PLAYER */
- UINT32 sample_nb;
- /* used only for flag = MP_FLAG_DECODE_ONLY */
- UINT32 decbuf_size;
- };
- union
- {
- UINT32 last_video_pts; //45k unit
- struct
- {
- UINT32 bAD_stream : 8;
- UINT32 AD_fade : 8;
- UINT32 AD_pan : 8;
- UINT32 reserved : 8;
- };
- };
- UINT32 private_data_size;
- UINT8 private_data[4];
- } MPBUF_DESP, *MPBUF_DESP_PTR;
- /* Fixed field size include all fields except private_data */
- #define MPBUF_DESP_FIX_FIELD_SIZE (sizeof(MPBUF_DESP)-4)
- /* This type enum should be sync to sisaudio_cmdq.h */
- enum MP_DATA_TYPE_T
- {
- MP_DATA_TYPE_PCM = 0x00,
- MP_DATA_TYPE_MPEG = 0x01,
- MP_DATA_TYPE_AC3 = 0x02,
- MP_DATA_TYPE_DTS = 0x03,
- MP_DATA_TYPE_AAC = 0x04,
- MP_DATA_TYPE_MP3 = 0x05,
- MP_DATA_TYPE_REAL = 0x06,
- MP_DATA_TYPE_EAC3 = 0x07,
- MP_DATA_TYPE_WMA = 0x08,
- MP_DATA_TYPE_COOK = 0x09,
- MP_DATA_TYPE_AMRNB = 0x0a,
- MP_DATA_TYPE_AMRWB = 0x0b,
- MP_DATA_TYPE_VORBIS = 0x0c,
- MP_DATA_TYPE_SILK = 0x0d,
- MP_DATA_TYPE_ISAC = 0x0e,
- MP_DATA_TYPE_DRA = 0x0f,
- MP_DATA_TYPE_FLAC = 0x10,
- MP_DATA_TYPE_UNKNOW = 0xff
- };
- /* This type enum should be sync to sisaudio_cmdq.h */
- enum MP_SFREQ_T
- {
- MP_SFREQ_24000,
- MP_SFREQ_48000,
- MP_SFREQ_96000,
- MP_SFREQ_192000,
- MP_SFREQ_22050,
- MP_SFREQ_44100,
- MP_SFREQ_88200,
- MP_SFREQ_176400,
- MP_SFREQ_32000,
- MP_SFREQ_8000,
- MP_SFREQ_11025,
- MP_SFREQ_12000,
- MP_SFREQ_16000,
- MP_SFREQ_64000
- };
- enum eAUDIO_BUFFER
- {
- eAUDIO_CMD_BUFFER,
- eAUDIO_PCM_BUFFER,
- eAUDIO_DEC_BUFFER,
- };
- /* ----- pcm buffer descriptor ----------------------------------------- */
- typedef struct __MPBUF_DESP_PCM
- {
- union
- {
- MPBUF_DESP main;
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- /* Serveral bytes private data for PCM case */
- UINT8 chmask;
- UINT8 chcnt;
- UINT8 sample_bits;
- UINT8 endian;
- #define MP_PCM_ENDIAN_LITTLE (0)
- #define MP_PCM_ENDIAN_BIG (1)
- UINT8 bfloat;
- UINT8 bdown_half_sample;
- };
- };
- } MPBUF_DESP_PCM, *MPBUF_DESP_PCM_PTR;
- #define MPBUF_DESP_PCM_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_PCM)-MPBUF_DESP_FIX_FIELD_SIZE)
- /* ----- aac buffer descriptor ----------------------------------------- */
- typedef struct __MPBUF_DESP_AAC
- {
- union
- {
- MPBUF_DESP main;
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- /* private data for AAC case*/
- UINT8 ObjType;
- UINT8 ext_ObjType;
- UINT8 sbr;
- UINT32 sampling_freq;
- UINT32 ext_sampling_freq;
- UINT8 aac_fmt;
- #if !defined(AAC_LATM) || !defined(AAC_ADTS) || !defined(AAC_ADIF) || !defined(AAC_RAW)
- #define AAC_LATM (0)
- #define AAC_ADTS (1)
- #define AAC_ADIF (2)
- #define AAC_RAW (3)
- #endif
- UINT8 profile; // AAC PROFILE 0: AAC MAIN, 1 : AAC LC
- #if !defined(AAC_MAIN_PROFILE)
- #endif
- };
- };
- } MPBUF_DESP_AAC, *MPBUF_DESP_AAC_PTR;
- #define MPBUF_DESP_AAC_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_AAC)-MPBUF_DESP_FIX_FIELD_SIZE)
- /* Private codec info for AAC */
- typedef struct __CODEC_INFO_AAC
- {
- UINT8 fmt;
- UINT8 extra_data_size;
- UINT8 extra_data[256];
- } CODEC_INFO_AAC, * CODEC_INFO_AAC_PTR;
- /* ----- wma buffer descriptor ----------------------------------------- */
- typedef struct __MPBUF_DESP_WMA
- {
- union
- {
- MPBUF_DESP main;
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- /* private data for WMA case*/
- struct
- {
- UINT32 bitspersample : 8;
- UINT32 channels : 4;
- UINT32 codec_id : 2;
- UINT32 wma_reserved: 18;
- };
- UINT32 samplerate;
- UINT32 bitrate;
- UINT32 blockalign;
- UINT32 datalen;
- UINT8 data[6];
- UINT16 wEncodeOptions;
- UINT32 dwChannelMask;
- };
- };
- } MPBUF_DESP_WMA, *MPBUF_DESP_WMA_PTR;
- #define MPBUF_DESP_WMA_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_WMA)-MPBUF_DESP_FIX_FIELD_SIZE)
- /* ----- cook buffer descriptor ---------------------------------------- */
- /* data type Real use basical buffer descriptor */
- /* Private codec info for COOK */
- typedef struct __CODEC_INFO_COOK
- {
- /* Serveral bytes private data for Cook case */
- UINT32 SampleRate;
- UINT32 BitsPerSample;
- UINT32 NumOfChannel;
- UINT32 AudioQuality;
- UINT32 BitsPerFrame;
- UINT32 Granularity;
- UINT32 OpaqueDataSize;
- /* According to RealFormatSDK, Max ppaque data size for cook is 20 bytes */
- #define REAL_COOK_MAX_OPAQUE_DATA_SIZE (20)
- UINT8 OpaqueData[REAL_COOK_MAX_OPAQUE_DATA_SIZE];
- } CODEC_INFO_COOK, *CODEC_INFO_COOK_PTR;
- typedef CODEC_INFO_COOK RA_FORMAT_INFO;
- typedef CODEC_INFO_COOK_PTR RA_FORMAT_INFO_PTR;
- /* ----- EAC3 buffer descriptor ---------------------------------------- */
- typedef struct __MPBUF_DESP_DDP
- {
- union
- {
- MPBUF_DESP main;
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- /* Serveral bytes private data for DDP case */
- UINT8 private_data[0x20];
- //DOLBY_DIGITAL_SETTINGS_CMDQ ddpinfo;
- };
- };
- } MPBUF_DESP_DDP, *MPBUF_DESP_DDP_PTR;
- #define MPBUF_DESP_DDP_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_DDP)-MPBUF_DESP_FIX_FIELD_SIZE)
- /*------SILK descriptor-----------------------------------------------*/
- typedef struct __MPBUF_DESP_SILK
- {
- union
- {
- MPBUF_DESP main;
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- UINT8 silk_fmt;
- #define SILK_NB_V3 0
- #define SILK_MB_V3 1
- #define SILK_WB_V3 2
- #define SILK_SW_V3 3
- };
- };
- } MPBUF_DESP_SILK, *MPBUF_DESP_SILK_PTR;
- #define MPBUF_DESP_SILK_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_SILK)-MPBUF_DESP_FIX_FIELD_SIZE)
- /* ----- General Control descriptor ------------------------------------ */
- typedef struct __MPBUF_DESP_GENERAL_INFO
- {
- union
- {
- MPBUF_DESP main;
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- /* private data for general info case*/
- UINT32 payload_offset;
- UINT32 flashPTS_for_init_stc; //for resume_init_waiting used
- struct
- {
- UINT32 clean_flag : 1;
- UINT32 pause_flag : 1;
- UINT32 resume_flag : 1;
- UINT32 payload_offset_flag : 1;
- UINT32 init_waiting_flag : 1;
- UINT32 resume_init_waiting_flag : 1;
- UINT32 fast_slow_play_flag : 1;
- UINT32 enable_audio: 1;
- UINT32 disable_audio: 1;
- UINT32 reserved : 23;
- };
- };
- };
- } MPBUF_DESP_GENERAL_INFO, *MPBUF_DESP_GENERAL_INFO_PTR;
- #define MPBUF_DESP_GENERAL_INFO_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_GENERAL_INFO)-MPBUF_DESP_FIX_FIELD_SIZE)
- typedef struct __MPBUF_DESP_DSP
- {
- union
- {
- MPBUF_DESP main;
- /* NOTICE: Please filled these main mp buf desp fields
- mp_flag: should be MP_FLAG_AUDIODSP
- audio_type: input audio type
- sfreq: input audio sample frequency
- buf_addr: input buffer ptr, no use in mp driver
- buf_size: input buffer size, no use in mp driver
- Other fields: left empty. */
- struct
- {
- UINT8 info[MPBUF_DESP_FIX_FIELD_SIZE];
- /* Private data for Audio dsp */
- union
- {
- UINT32 audio_dsp_info;
- struct
- {
- UINT32 operation: 8;
- #define MPDSP_OP_DECODE (0)
- #define MPDSP_OP_ENCODE (1)
- #define MPDSP_OP_POSTPROCESS (2)
- UINT32 outAudioType: 8; /* output audio type */
- UINT32 inbuf_type: 8;
- /* 0: inbuf contains normal data
- 1: inbuf contains codec config data */
- UINT32 desp_idx: 8; /* Filled by mpdsp */
- };
- };
- UINT32 desp_mgt_kbase; /* Filled by mpdsp */
- UINT32 outbuf_size;
- /* Expected output buffer size, no use in mp driver */
- };
- };
- } MPBUF_DESP_DSP, *MPBUF_DESP_DSP_PTR;
- #define MPBUF_DESP_DSP_PRIVATE_DATA_SIZE (sizeof(MPBUF_DESP_DSP)-MPBUF_DESP_FIX_FIELD_SIZE)
- /* ----- Union of all descriptors -------------------------------------- */
- typedef struct MPBUF_DESP_UNION
- {
- union
- {
- MPBUF_DESP main;
- MPBUF_DESP_PCM pcm;
- MPBUF_DESP_AAC aac;
- MPBUF_DESP_WMA wma;
- MPBUF_DESP_DDP ddp;
- MPBUF_DESP_SILK silk;
- MPBUF_DESP_GENERAL_INFO gi;
- MPBUF_DESP_DSP dsp;
- };
- } MPBUF_DESP_UNION, *MPBUF_DESP_UNION_PTR;
- /* ----- Definitions for mp dsp module ---------------------------------*/
- typedef enum
- {
- MPDSP_BUFTYPE_NORMAL = 0,
- MPDSP_BUFTYPE_CONFIG,
- MPDSP_BUFTYPE_MOREDATA = 0x80,
- MPDSP_BUFTYPE_NUM
- } MPDSP_BUFTYPE;
- typedef volatile struct __MPDSP_DESP
- {
- #define MPDSP_DESP_MAJOR_VERSION (0x01)
- #define MPDSP_DESP_UPDATE_VERSION (0x00)
- union
- {
- UINT32 union_dw_00;
- struct
- {
- UINT32 state: 8;
- #define MPDSP_ST_INIT (0)
- #define MPDSP_ST_DESP_FILLED (1)
- #define MPDSP_ST_DSP_READY (2)
- #define MPDSP_ST_DSP_ERROR (3)
- UINT32 frame_cnt: 8; /* NO USE NOW */
- /* Input/output data type. Please check enum MPDSP_BUFTYPE */
- UINT32 inbuf_type: 8;
- UINT32 outbuf_type: 8;
- };
- };
- /* dword 01 02 */
- UINT32 reserved_dw[2];
- /* dword 03 */
- union
- {
- UINT32 union_dw_03;
- struct
- {
- UINT32 dsp_extra_info: 8;
- UINT32 reserved_d3_b13: 24;
- };
- };
- /* Input buffer offset and size */
- /* dword 04 05 */
- UINT32 inbuf_offset;
- UINT32 inbuf_size;
- /* Output buffer offset and size */
- /* dword 06 07 */
- UINT32 outbuf_offset;
- /* max size for output buffer,
- audio dsp may update this size to smaller size. */
- UINT32 outbuf_size;
- /* TODO: Outbuf may not be feed to requester at once
- and should be sperated copied, we need to handle
- this situation.
- Current solution: Get buffer at once.
- */
- } MPDSP_DESP, *pMPDSP_DESP;
- typedef volatile struct __MPDSP_DESP_MGT
- {
- #define MPDSP_MGT_MAJOR_VERSION (0x01)
- #define MPDSP_MGT_UPDATE_VERSION (0x00)
- /* Set to magic number 0xade5b3a6 */
- UINT32 syncword;
- #define MPDSP_DESP_MGT_SYNCWORD (0xade5b3a6)
- union
- {
- UINT32 version;
- #define MPDSP_VERSION \
- ((MPDSP_MGT_MAJOR_VERSION<<24)|(MPDSP_MGT_UPDATE_VERSION<<16)|\
- (MPDSP_DESP_MAJOR_VERSION<<8)|(MPDSP_DESP_UPDATE_VERSION))
- struct
- {
- UINT32 desp_update_ver: 8;
- UINT32 desp_major_ver: 8;
- UINT32 mgt_update_ver: 8;
- UINT32 mgt_major_ver: 8;
- };
- };
- union
- {
- UINT32 union_dw_02;
- struct
- {
- UINT32 inAudioType: 8;
- UINT32 outAudioType: 8;
- UINT32 reserved_dw2_00: 8;
- UINT32 operation: 8;
- #define MPDSP_OP_DECODE (0)
- #define MPDSP_OP_ENCODE (1)
- };
- };
- union
- {
- UINT32 union_dw_03;
- struct
- {
- UINT32 desp_num: 8; /* number of dsp desps */
- UINT32 desp_sz: 8; /* size of one dsp desp */
- UINT32 wp: 8; /* desp is empty and can be filled now */
- UINT32 rp: 8; /* desp is filled and ready for dsp */
- /* queue status:
- empty if (wp == rp),
- full if ((wp+1)%desp_num == rp) */
- };
- };
- /* Total buffer size: including desp mgt, desps, and used buffer */
- UINT32 dsp_buf_size;
- union
- {
- UINT32 union_dw_05;
- struct
- {
- UINT32 bInit: 1; /* 1: dsp initialized */
- UINT32 reserved_dw5_00: 7;
- UINT32 bCancelAll: 1; /* 1: Cancel all */
- UINT32 reserved_dw5_01: 23;
- };
- };
- /* MPDEV allocates buffer for audio codecs */
- UINT32 libbuf_offset;
- UINT32 libbuf_size;
- MPDSP_DESP desp[0];
- } MPDSP_DESP_MGT, *pMPDSP_DESP_MGT;
- typedef struct __MP_STATUS
- {
- UINT8 status;
- #define MPST_STOP (0)
- #define MPST_PLAYING (1)
- #define MPST_PAUSE (2)
- UINT32 lastpts;
- /* 45K stc clock */
- UINT32 cur_stc;
- } MP_STATUS, *pMP_STATUS;
- typedef enum __MPDEV_STATUS
- {
- MPDEV_ST_OK,
- MPDEV_ST_NOT_INIT,
- MPDEV_ST_INIT_FAIL,
- MPDEV_ST_INVALID_PARAM,
- MPDEV_ST_WRITE_FAIL,
- MPDEV_ST_READ_FAIL,
- MPDEV_ST_IOCTL_FAIL,
- MPDEV_ST_PLEASE_WAIT,
- MPDEV_ST_NO_MORE_BUFFER,
- MPDEV_ST_INBUF_TOO_SMALL,
- MPDEV_ST_UNKNOW_ERROR,
- MPDEV_ST_END /* DON'T USE IT */
- } MPDEV_STATUS;
- #endif /* __DRV_MP_DESP_H__ */
|