/*
 * @file hv_drv_Bcon.h
 * @brief Header file of audio module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) 
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-18
 */


#ifndef __DRV_DIMMER__
#define __DRV_DIMMER__

#include "hv_vos_Comm.h"
#include "hv_comm_Assert.h"
typedef enum _BconProtoc
{
	BCON_PROT_TI,
	BCON_PROT_XX,
	BCON_PROT_S,
	BCON_PROT_HY,
	BCON_PROT_MAX
} BconProtoc;

typedef enum _BconSendMode
{
	BCON_CMD_MODE_RAM_ONLY,
	BCON_CMD_MODE_CMD_ONLY,
	BCON_CMD_MODE_CMD_BOTH,
	BCON_CMD_MODE_MAX
} BconSendMode;

typedef enum _BconCmdWidth
{
	BCON_CMD_WIDTH_8BIT,
	BCON_CMD_WIDTH_16BIT,
	BCON_CMD_WIDTH_MAX
} BconCmdWidth;

typedef struct _OSPB{
    USHORT16 usHead;
    USHORT16 usAddr;
    USHORT16 usSubAddr;
    USHORT16 usFeedback;
    USHORT16 usDataLen;
    USHORT16 *pusData;
    USHORT16 *pusOutData;
    USHORT16 usCrc;
}OSPB;

#define MAX_LANE_NUM_HY (6)
#define INIT_TIME_3 (1)


#define OSPB_CMD_TYPE_DIMMING   (0x71)
#define OSPB_CMD_TYPE_BROADCAST (0x72)
#define OSPB_CMD_TYPE_CONFIG    (0x73)
#define OSPB_CMD_TYPE_ADDRESS   (0x74)
#define OSPB_CMD_TYPE_READBACK  (0x75)


VOID Hv_Drv_Bcon_Init(UCHAR8 ucVendor, UINT32 uiClk);

Status Hv_Drv_Bcon_SetClk(UINT32 uiClk);

Status Hv_Drv_Bcon_SetVendor(BconProtoc eProt);

Status Hv_Drv_Bcon_SwitchSram(VOID);

VOID Hv_Drv_Bcon_SetPacketLength(UINT32 uiLength);

UCHAR8 Hv_Drv_Bcon_CheckBusy(UINT32 uiLane);

VOID Hv_Drv_Bcon_WriteData(UCHAR8 ucLaneIndex, USHORT16 *auiBuf, UINT32 uiLength);

VOID Hv_Drv_Bcon_WriteDataU32(UINT32 uiLane, UINT32 *auiBuf, UINT32 uiLength);

VOID Hv_Drv_Bcon_SetPinshare(BconProtoc eProt);

VOID Hv_Drv_Bcon_SetCmdMode(UCHAR8 ucLaneIndex, BconSendMode eMode);

VOID Hv_Drv_Bcon_SetDataLength(UCHAR8 ucLaneIndex, UINT32 uiLength);
VOID Hv_Drv_Bcon_Start(UINT32 uiSel);
VOID Hv_Drv_Bcon_Sram_SingleWriteData(UCHAR8 ucLaneIndex, UINT32 *auiBuf, UINT32 uiLength);
VOID Hv_Drv_Bcon_Set_SingleDataWidth(UCHAR8 ucLaneIndex, BconCmdWidth eWidth);
VOID Hv_Drv_Bcon_Set_SingleCmdWidth(UCHAR8 ucLaneIndex, BconCmdWidth eWidth);
VOID Hv_Drv_Bcon_Set_SingleCmdLength(UCHAR8 ucLaneIndex, UINT32 uiLength);

VOID Hv_Drv_Bcon_ReadData(UCHAR8 ucLane, USHORT16 usLen, USHORT16 *pusBuf);


VOID Hv_Drv_Bcon_HP9309_Send();
VOID Hv_Drv_Bcon_HP9309_Init(UINT32 uiLane);
VOID Hv_Drv_Bcon_HP9309_WriteData(UCHAR8 ucLane, USHORT16* pusData, UINT32 uiLen);


UINT32 Hv_Drv_Bcon_HP9309_DataPrepare(USHORT16 usHead, USHORT16 usAddr, USHORT16 usSubAddr, USHORT16 usFeedBack, USHORT16 *pusData, USHORT16 usDataLen, USHORT16* pusOut);

#endif
