/*
 * host9438_if.h
 *
 *  Created on: 2017/10/25
 *      Author: 0000105997
 */

#ifndef HOST9438_IF_H_
#define HOST9438_IF_H_

#include "x_os.h"
#include "hdmi_earc_if.h"

#ifdef __cplusplus
extern "C" {
#endif

#define THREAD_PRIORITY 60 /* 1(H)~255(L)*/
#define STACK_SIZE (1024*2)
#define QUEUE_MSG_COUNT_MAX 127
#define HDMI1_BIT	0x01	// Unused
#define HDMI2_BIT	0x02	// Unused
#define HDMI3_BIT	0x04
#define HDMI4_BIT	0x08	// Unused
#define HDMIALL_BIT	(HDMI1_BIT | HDMI2_BIT | HDMI3_BIT | HDMI4_BIT)
#define HDMI_PORT	3
#define SII_EDID_AUD_SIZE 256
#define NO_AC3_CAPABILITY 0
#define NO_MPEG4AACLC_CAPABILITY 0

typedef enum {
	SALZ_INIT_SET_ACON = 0,
	SALZ_INIT_SET_RESUME
} SALZ_INIT_SET_STATE;

typedef enum {
	SALZCTRL_STATE_SUSPEND = 0,
	SALZCTRL_STATE_INITIALIZE,
	SALZCTRL_STATE_IDLE1_EARC_ENABLE,
	SALZCTRL_STATE_DISC1DISC2_EARC_ENABLE,
	SALZCTRL_STATE_EARC_EARC_ENABLE,
	SALZCTRL_STATE_IDLE2_EARC_ENABLE,
	SALZCTRL_STATE_ARC_EARC_ENABLE,
	SALZCTRL_STATE_ARC_EARC_ENABLE2,
	SALZCTRL_STATE_IDLE1_EARC_DISABLE,
	SALZCTRL_STATE_EARC_EARC_DISABLE,
	SALZCTRL_STATE_IDLE2_EARC_DISABLE,
	SALZCTRL_STATE_ARC_EARC_DISABLE1,
	SALZCTRL_STATE_ARC_EARC_DISABLE2,
	SALZCTRL_STATE_MAX
} SALZCTRL_STATE;

typedef enum {
	SALZCTRL_MSG_SUSPEND = 0,
	SALZCTRL_MSG_CB_LOG_FIFO_CHNG,
	SALZCTRL_MSG_CB_EARC_HPD_CHNG,
	SALZCTRL_MSG_CB_EARC_LINK_CHNG,
	SALZCTRL_MSG_CB_SPDIF_CHAN_STAT_CHNG,
	SALZCTRL_MSG_CB_EDID_CHNG,
	SALZCTRL_MSG_CB_GPIO_CHNG,
	SALZCTRL_MSG_CB_ASSERT,
	SALZCTRL_MSG_CB_ERX_LATENCY_CHNG,
	SALZCTRL_MSG_CB_EARC_DISC_TIMEOUT,
	SALZCTRL_MSG_FUNC_SET_CHANNEL_STATUS,
	SALZCTRL_MSG_FUNC_SET_AUDIO_INFO_FRAME,
	SALZCTRL_MSG_FUNC_SET_VALIDITY_BIT,
	SALZCTRL_MSG_FUNC_SET_5V_STATUS,
	SALZCTRL_MSG_FUNC_SET_HBRA_INPUT_STATUS,
	SALZCTRL_MSG_FUNC_SET_ARC_STATUS,
	SALZCTRL_MSG_FUNC_SET_AUDIO_PATH,
	SALZCTRL_MSG_FUNC_SET_AUDIO_LATENCY,
	SALZCTRL_MSG_FUNC_SET_TV_STATUS,
	SALZCTRL_MSG_FUNC_SET_BT_HP_STATUS,
	SALZCTRL_MSG_FUNC_SET_ENABLE,
	SALZCTRL_MSG_FUNC_SET_HDMI_MUTE,
	SALZCTRL_MSG_FUNC_SET_AUDIO_MUTE,
	SALZCTRL_MSG_MAX
} SALZCTRL_MSG_ID;

typedef struct {
	EARCChannelStatus_t channelStatus;
} CHANNEL_STATUS_ST;

typedef struct {
	EARCAudioInfoFrame_t audioInfoFrame;
} AUDIO_INFO_FRAME_ST;

typedef struct {
	BOOL bValidity;
} VALIDITY_BIT_ST;

typedef struct {
	UINT8 u15VStatus;
} V_STATUS_ST;

typedef struct {
	BOOL bHbr;
} HBRA_INPUT_STATUS_ST;

typedef struct {
	BOOL bOnOff;
} ARC_STATUS_ST;

typedef struct {
	BOOL bPath;
} AUDIO_PATH_ST;

typedef struct {
	INT16 i2Ms;
} AUDIO_LATENCY_ST;

typedef struct {
	BOOL bTVStatus;
} TV_STATUS_ST;

typedef struct {
	BOOL bConnect;
} BT_HP_STATUS_ST;

typedef struct {
	BOOL bEn;
} ENABLE_ST;

typedef struct {
	BOOL bMute;
} HDMI_MUTE_ST;

typedef struct {
	BOOL bMute;
} AUDIO_MUTE_ST;

typedef union {
	UINT32 buff[64];
	CHANNEL_STATUS_ST setChannelStatus;
	AUDIO_INFO_FRAME_ST setAudioInfoFrame;
	VALIDITY_BIT_ST setValidityBit;
	V_STATUS_ST set5VStatus;
	HBRA_INPUT_STATUS_ST setHBRAInputStatus;
	ARC_STATUS_ST setArcStatus;
	AUDIO_PATH_ST setAudioPath;
	AUDIO_LATENCY_ST setAudioLatency;
	TV_STATUS_ST setTVStatus;
	BT_HP_STATUS_ST setBtHpStatus;
	ENABLE_ST setEnable;
	HDMI_MUTE_ST setHdmiMute;
	AUDIO_MUTE_ST setAudioMute;
} SALZCTRL_MSG_DATA;

typedef struct {
	SALZCTRL_MSG_ID id;
	SALZCTRL_MSG_DATA data;
} SALZCTRL_MSG;

#define FS_THRESHOLD	10	//1kHz
#define FS_HBR_ADJUST	4	//Quadruple Frequency value for HBRA
typedef struct {
	UINT32 min;
	UINT32 max;
	UINT8 bit;
} AUDIO_FS_TBL;

extern BOOL Sii9438Init(void);
extern BOOL Sii9438Resume(void);
extern void Sii9438Suspend(void);

#ifdef __cplusplus
}
#endif

#endif /* HOST9438_IF_H_ */
