//SPDX-License-Identifier:MediaTekProprietary
#ifndef AUD_COMP_DEC_INC_
#define AUD_COMP_DEC_INC_

/* Audio formats. */
typedef enum
{
    RISC_DEC_FMT_UNKNOWN = 0,
    RISC_DEC_FMT_MPEG,
    RISC_DEC_FMT_AC3,
    RISC_DEC_FMT_PCM,
    RISC_DEC_FMT_MP3,
    RISC_DEC_FMT_AAC,
    RISC_DEC_FMT_DTS,
    RISC_DEC_FMT_WMA,
    RISC_DEC_FMT_RA,
    RISC_DEC_FMT_HDCD,
    RISC_DEC_FMT_MLP,
    RISC_DEC_FMT_MTS,   /* remove */
    RISC_DEC_FMT_EU_CANAL_PLUS,
    RISC_DEC_FMT_TV_SYS,
    RISC_DEC_FMT_EAC3,
    RISC_DEC_FMT_EAC3_SEC,
    RISC_DEC_FMT_DTSHD_PRI_XLL,
    RISC_DEC_FMT_DTSHD_PRI_NO_XLL,
    RISC_DEC_FMT_DTSHD_SEC,
    RISC_DEC_FMT_DTSCD,
    RISC_DEC_FMT_TRUE_HD,
    RISC_DEC_FMT_LOSSLESS_AC3,
    RISC_DEC_FMT_CDDA,
    RISC_DEC_FMT_VORBIS = 24,
    RISC_DEC_FMT_DST,
    RISC_DEC_FMT_AAC_PURE,
    RISC_DEC_FMT_DTS_ES_6_1_MATRIX,
    RISC_DEC_FMT_DTS_ES_6_1_DISCRETE,
    RISC_DEC_FMT_DTS_ES_8_DISCRETE,
    RISC_DEC_FMT_DTS_96_24,
    RISC_DEC_FMT_DTS_96_24_ES_MATRIX,
    RISC_DEC_FMT_DVDA,
    RISC_DEC_FMT_DTSHD_ES_6_1_MATRIX,
    RISC_DEC_FMT_DTSHD_ES_6_1_DISCRETE,
    RISC_DEC_FMT_DTSHD_ES_8_DISCRETE,
    RISC_DEC_FMT_DTSHD_96_24,
    RISC_DEC_FMT_DTSHD_96_24_ES_MATRIX,
    RISC_DEC_FMT_RA_COOK,
    RISC_DEC_FMT_AACPLUS,
    RISC_DEC_FMT_PURE_AACPLUS,
    RISC_DEC_FMT_HEAAC_V1,
    RISC_DEC_FMT_HEAAC_V2,
    RISC_DEC_FMT_HDMI_IN_PCM,
    RISC_DEC_FMT_DRA,
    RISC_DEC_FMT_DRA_EXT,
    RISC_DEC_FMT_APE,    //mtk70169 mark
    RISC_DEC_FMT_FLAC,
    RISC_DEC_FMT_WMAPro,
    RISC_DEC_FMT_ALAC,
    RISC_DEC_FMT_AMR,
    RISC_DEC_FMT_AWB,
    RISC_DEC_FMT_DTSHD_LBR,
    RISC_DEC_FMT_LPCM_ALSA = 54,
#if 1 //CONFIG_MW_SUPPORT_RISC_AUD_DEC
    RISC_DEC_FMT_OPUS = 60, // Risc dec fmt start
    RISC_DEC_FMT_ATMOS    = 64,
    RISC_DEC_FMT_DTSX    = 65,
    RISC_DEC_FMT_MPEGH    = 66,
#endif
    RISC_DEC_FMT_END = 255
  } RISC_DEC_FMT_T;

/* Audio types. */
typedef enum
{
    RISC_DEC_TYPE_UNKNOWN = 0,
    RISC_DEC_TYPE_MONO,                 /* 1/0 */
    RISC_DEC_TYPE_MONO_SUB,             /* 1+sub-language */
    RISC_DEC_TYPE_DUAL_MONO,            /* 1+1 */
    RISC_DEC_TYPE_STEREO,               /* 2/0 */
    RISC_DEC_TYPE_STEREO_SUB,           /* 2+sub-language */
    RISC_DEC_TYPE_STEREO_DOLBY_SURROUND,/* 2/0, dolby surround */
    RISC_DEC_TYPE_SURROUND_2CH,         /* 2/1 */
    RISC_DEC_TYPE_SURROUND,             /* 3/1 */
    RISC_DEC_TYPE_3_0,                  /* 3/0 */
    RISC_DEC_TYPE_4_0,                  /* 2/2 */
    RISC_DEC_TYPE_4_1,
    RISC_DEC_TYPE_5_0,
    RISC_DEC_TYPE_5_1,                  /* 3/2 */
    RISC_DEC_TYPE_6_0,
    RISC_DEC_TYPE_6_1,
    RISC_DEC_TYPE_7_0,
    RISC_DEC_TYPE_7_1,                  /* 5/2 */
    RISC_DEC_TYPE_FM_MONO_NICAM_MONO,
    RISC_DEC_TYPE_FM_MONO_NICAM_STEREO,
    RISC_DEC_TYPE_FM_MONO_NICAM_DUAL,
    RISC_DEC_TYPE_MULTI_CH,
    RISC_DEC_TYPE_1_0_1,                /* 1/0/1 */
    RISC_DEC_TYPE_2_1_0,                /* 2/1/0 */
    RISC_DEC_TYPE_2_1_1,                /* 2/1/1 */
    RISC_DEC_TYPE_2_2_0,                /* 2/2/0 */
    RISC_DEC_TYPE_2_2_1,                /* 2/2/1 */
    RISC_DEC_TYPE_4_2_0,                /* 4/2/0 */
    RISC_DEC_TYPE_4_2_1,                /* 4/2/1 */
    RISC_DEC_TYPE_4_3_0,                /* 4/3/0 */
    RISC_DEC_TYPE_4_3_1,                /* 4/3/1 */
    RISC_DEC_TYPE_5_2_0,                /* 5/2/0 */
    RISC_DEC_TYPE_5_2_1,                /* 5/2/1 */
    RISC_DEC_TYPE_4_0_0,                /* 4/0/0 */
    RISC_DEC_TYPE_4_0_1,                /* 4/0/1 */
    RISC_DEC_TYPE_4_1_0,                /* 4/1/0 */
    RISC_DEC_TYPE_4_1_1,                /* 4/1/1 */
    RISC_DEC_TYPE_4_4_0,                /* 4/4/0 */
    RISC_DEC_TYPE_5_0_0,                /* 5/0/0 */
    RISC_DEC_TYPE_5_0_1,                /* 5/0/1 */
    RISC_DEC_TYPE_5_1_0,                /* 5/1/0 */
    RISC_DEC_TYPE_5_1_1,                /* 5/1/1 */
    RISC_DEC_TYPE_5_3_0,                /* 5/3/0 */
    RISC_DEC_TYPE_7_1_2,
    RISC_DEC_TYPE_7_1_4,
    RISC_DEC_TYPE_OTHERS
}  RISC_DEC_AUD_TYPE_T;

typedef enum
{
    RISC_DEC_FILE_TYPE_OTHER = 0,
    RISC_DEC_FILE_TYPE_TS = 1,
    RISC_DEC_FILE_TYPE_INVALID
} RISC_DEC_FILE_TYPE_INFO_T;

//channel assignment
typedef enum AUDIO_CHANNEL_ASSIGNMENT{
	NONE					= 0x0,

	//1channel
	C						= 0x1,

	//2channel
	L_R						= 0x10,

	//3channel
	L_R_C                   = 0x100,
	L_R_Bc                  = 0x101,
	C_L_R                   = 0x102,
	L_C_R                   = 0x103,
	L_R_Lfe                 = 0x104,

	//4channel
	L_R_C_Bc                = 0x1000,
	L_R_Bl_Br               = 0x1001,
	L_R_Sl_Sr               = 0x1002,
	C_L_R_Ls                = 0x1003,
	L_R_Ls_Rs               = 0x1004,
	L_R_Lfe_Bc              = 0x1005,
	L_R_C_Lfe               = 0x1006,
	L_R_C_Z                 = 0x1007,
	L_R_Bc_Z                = 0x1008,
	L_C_R_Bc                = 0x1009,

	//5channel
	L_R_C_Bl_Br             = 0x10000,
	L_R_C_Sl_Sr             = 0x10001,
	C_L_R_Ls_Rs             = 0x10002,
	L_C_R_Ls_Rs             = 0x10003,
	L_R_Lfe_Ls_Rs           = 0x10004,
	L_R_C_Ls_Rs             = 0x10005,
	L_R_C_Lfe_Bc            = 0x10006,
	L_R_Ls_Rs_Lfe           = 0x10007,
	L_R_Ls_Rs_C             = 0x10008,

	//6channel
	L_R_C_Lfe_Bl_Br         = 0x100000,
	L_R_C_Lfe_Sl_Sr         = 0x100001,
	L_R_C_Bl_Br_Bc          = 0x100002,
	L_R_C_Bc_Sl_Sr          = 0x100003,
	C_L_R_Ls_Rs_Lfe         = 0x100004,
	L_C_R_Ls_Rs_Lfe         = 0x100005,
	L_R_C_Lfe_Ls_Rs         = 0x100006,
	L_R_Ls_Rs_C_Lfe         = 0x100007,
	L_R_C_Ls_Rs_Z           = 0x100008,
	L_R_C_Ls_Rs_Lfe         = 0x100009,

	//7channel
	L_R_C_Bl_Br_Sl_Sr       = 0x1000000,

	//8channel
	L_R_C_Lfe_Bl_Br_Sl_Sr   = 0x10000000,
	C_L_R_Ls_Rs_Rls_Rrs_Lfe = 0x10000001,
	L_C_R_Ls_Rs_Rls_Rrs_Lfe = 0x10000002,
	L_R_C_Ls_Rls_Rrs_Rs_Z   = 0x10000003,
	L_R_C_Ls_Rls_Rrs_Rs_Lfe = 0x10000004
}AUDIO_CHANNEL_ASSIGNMENT;

typedef enum
{
   RISC_DEC_PCM_FMT_PCM_DVDV,  /* for DVD-Video*/
   RISC_DEC_PCM_FMT_WAVE,      /* for AVI etc.*/
   RISC_DEC_PCM_FMT_ADPCM,     /* for ADPCM IMA*/
   RISC_DEC_PCM_FMT_ADPCM_MS,  /* for ADPCM MS*/
   RISC_DEC_PCM_FMT_PCM_NORMAL,/* for ASF, AVI, MPS...etc */
   RISC_DEC_PCM_FMT_PCM_BD,     /* for Blue-ray*/
   RISC_DEC_PCM_FMT_PCM_DVDV_2CH, /* for DVD-Video strip 2ch*/
   RISC_DEC_PCM_FMT_A_LPCM,       /* for A Law PCM*/
   RISC_DEC_PCM_FMT_U_LPCM,        /* for U Law PCM*/
   RISC_DEC_PCM_FMT_IEEE_FLOAT,
   RISC_DEC_PCM_FMT_PCM_INV
}RISC_DEC_PCM_FMT_T;

typedef enum
{
   RISC_LPCM_DVD_CH_MONO = 0,
   RISC_LPCM_DVD_CH_STEREO = 1,
   RISC_LPCM_DVD_CH_LF_RF_S = 2,
   RISC_LPCM_DVD_CH_LF_RF_LS_RS = 3,
   RISC_LPCM_DVD_CH_LF_RF_C = 7,
   RISC_LPCM_DVD_CH_LF_RF_C_S = 8,
   RISC_LPCM_DVD_CH_LF_RF_LS_RS_C = 9,
   RISC_LPCM_DVD_CH_LF_RF_C_LFE = 0xF,
   RISC_LPCM_DVD_CH_LF_RF_LS_RS_C_LFE = 0xC,
   RISC_LPCM_DVD_CH_LF_RF_LS_RS_C_LFE_Ch7_Ch8 = 0x17,
   RISC_LPCM_DVD_CH_INVALID
}RISC_AUD_LPCM_DVD_CHANNEL_ASSIGN_T;

/*
typedef struct
{
    RISC_DEC_PCM_FMT_T ePCM_Format;
    UINT16 u2BlockAlign;        // block align, only necessary for ADPCM
    BOOL fgDeEmphasis;
    BOOL fgDlnaExist;
    BOOL fg8BitSigned;
    BOOL   b_audio_reset;
} RISC_DEC_PCM_INFO_T;
*/

typedef struct
{
    RISC_DEC_PCM_FMT_T ePCM_Format;
    UINT16 u2BlockAlign;        /* block align, only necessary for ADPCM*/
    BOOL   b_de_emphasis;       /*de-emphasis bit... 0 or 1*/
    BOOL   b_dlna_exist;		/*DLNA exist or not*/
    BOOL   b_8bit_signed;      /*8bit LPCM data signed or not*/
    BOOL   b_audio_reset;
} RISC_DEC_PCM_INFO_T;

typedef struct _RISC_DEC_OPUS_INFO_T   // Risc dec opus
{
    /* Opus header part */
    UINT8  ui1_versoin;
    UINT8  ui1_channel_count;         /* Number of channels: 1..255 */
    UINT16 ui2_pre_skip;
    UINT32 ui4_input_sample_rate;
    INT16  i2_output_gain;            /* in dB S7.8 should be zero whenever possible */
    UINT8  ui1_mapping_family;
    /* The below three parameters are only used if channel_mapping != 0 */
    UINT8  ui1_stream_count;
    UINT8  ui1_coupled_count;
    UINT8  ui1_channel_mapping[255];  /* 255 means opus max channel count */

    /* Opus specail info */
    UINT32 ui1_CodecDelay;
    UINT32 ui1_SeekPreRoll;
} RISC_DEC_OPUS_INFO_T;

typedef enum
{
    RISC_DEC_ATMOS_DD     = 0,   // 0: Dolby Digital
    RISC_DEC_ATMOS_DDP    = 1,   // 1: Dolby Digital Plus
    RISC_DEC_ATMOS_TRUEHD = 2,   // 2: TrueHD
    RISC_DEC_ATMOS_MAT    = 3    // 3: MAT
}RISC_DEC_ATMOS_DECODER_TYPE_T;

typedef enum
{
    RISC_DEC_DTSX_SD     = 0,   // 0: Dolby Digital
    RISC_DEC_DTSX_HD    = 1,   // 1: Dolby Digital Plus
    RISC_DEC_DTSX_XLL = 2,   // 2: TrueHD
    RISC_DEC_DTSX_EX    = 3    // 3: MAT
}RISC_DEC_DTSX_DECODER_TYPE_T;


typedef struct _RISC_DEC_ATMOS_INFO_T   // Risc dec Atmos
{
    RISC_DEC_ATMOS_DECODER_TYPE_T  eAtmosDecType;
    COMMON_DEC_PARAM_STR_T         *ptParamStr;
} RISC_DEC_ATMOS_INFO_T;

typedef struct _RISC_DEC_DTSX_INFO_T   // Risc dec Atmos
{
    RISC_DEC_DTSX_DECODER_TYPE_T  eAtmosDecType;
    COMMON_DEC_PARAM_STR_T         *ptParamStr;
} RISC_DEC_DTSX_INFO_T;


typedef struct _RISC_DEC_OPUS_PACKET_INFO_T   // Risc dec opus
{
    CHAR   ai1_HeaderID[4];        // set as "Opus"
    CHAR   ai1_ContainerID[4];     // set as "WebM" or "OggS" according to container
    UINT8  ui1_PacketFlag;         // bit0 is for BOS(begin of stream), True means begin of stream
                                   // bit1 is for EOS(end of stream), True means end of stream
                                   // bit2 is for packet error, True means packet lost or CRC error and so on
                                   // other bits not used now
    UINT32 ui4_PacketSize;         // bytes
    union{
        INT64 i8_GranulePos;      // for OggS
        INT32 i4_DiscardPadding;  // for WebM
    }u_info;

} RISC_DEC_OPUS_PACKET_INFO_T;

typedef struct
{
    RISC_DEC_PCM_INFO_T tPcmInfo;
    UINT8 u1BitResolution;
    UINT32 u4SamplingFreq;
    UINT8 u1ChannelAssign;
    UINT8 u1DecType;
    UINT8 u1IsBD;
    BOOL  fg8BitSigned;//false : unsigned, true:signed
} RISC_DEC_PCM_SETTING_T;

typedef enum
{
  RISC_FL_FR =0,
  RISC_LFE_FL_FR = 0x01,
  RISC_FC_FL_FR = 0x02,
  RISC_FC_LFE_FL_FR = 0x03,
  RISC_RC_FL_FR = 0x04,
  RISC_RC_LFE_FL_FR = 0x05,
  RISC_RC_FC_FL_FR = 0x06,
  RISC_RC_FC_LFE_FL_FR = 0x07,
  RISC_RR_RL_FL_FR = 0x08,
  RISC_RR_RL_LFE_FL_FR = 0x09,
  RISC_RR_RL_FC_FL_FR = 0x0A,
  RISC_RR_RL_FC_LFE_FL_FR = 0x0B,
  RISC_RC_RR_RL_FL_FR = 0x0C,
  RISC_RC_RR_RL_LFE_FL_FR = 0x0D,
  RISC_RC_RR_RL_FC_FL_FR = 0x0E,
  RISC_RC_RR_RL_FC_LFE_FL_FR = 0x0F,
  RISC_RRC_RLC_RR_RL_FL_FR = 0x10,
  RISC_RRC_RLC_RR_RL_LFE_FL_FR = 0x11,
  RISC_RRC_RLC_RR_RL_FC_FL_FR = 0x12,
  RISC_RRC_RLC_RR_RL_FC_LFE_FL_FR = 0x13,
  RISC_FRC_FLC_FL_FR = 0x14,
  RISC_FRC_FLC_LFE_FL_FR = 0x15,
  RISC_FRC_FLC_FC_FL_FR = 0x16,
  RISC_FRC_FLC_FC_LFE_FL_FR = 0x17,
  RISC_FRC_FLC_RC_FL_FR = 0x18,
  RISC_FRC_FLC_RC_LFE_FL_FR = 0x19,
  RISC_FRC_FLC_RC_FC_FL_FR = 0x1A,
  RISC_FRC_FLC_RC_FC_LFE_FL_FR = 0x1B,
  RISC_FRC_FLC_RR_RL_FL_FR = 0x1C,
  RISC_FRC_FLC_RR_RL_LFE_FL_FR = 0x1D,
  RISC_FRC_FLC_RR_RL_FC_FL_FR = 0x1E,
  RISC_FRC_FLC_RR_RL_FC_LFE_FL_FR = 0x1F,
  RISC_UNKNOWN = 0xFF

} RISC_HDMI_SPEAKER_ALLOCATE_T;

typedef struct
{
    RISC_DEC_FMT_T        e_aud_fmt;
    RISC_DEC_AUD_TYPE_T   e_aud_type;
    UINT32               ui4_sample_rate;
    UINT32               ui4_data_rate;
    UINT8                ui1_bit_depth;
    union
    {
        RISC_DEC_PCM_INFO_T*   __local_space__  pt_pcm_info;
        RISC_DEC_OPUS_INFO_T*  __local_space__  pt_opus_info;
        RISC_DEC_ATMOS_INFO_T* __local_space__  pt_atmos_info;
        RISC_DEC_DTSX_INFO_T* __local_space__  pt_dtsx_info;

        //TODO  Need codec owner to modify all your needed struct to RISC_DEC_*****
    } u_fmt_spec;
    UINT16               ui2_pid;               //Only use for BDMW currently
    UINT32               u4ChannelLayout;       //for detail channel layout
    RISC_DEC_FILE_TYPE_INFO_T e_aud_file_type;
    UINT8                u1DualMonoType;
} RISC_DEC_AUD_INFO_T;


#endif
