/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 *
 * $Author: wenjin.peng $
 * $Date: 2017/05/18 $
 * $RCSfile: hdmi_earc_if.c,v $
 * $Revision:
 *
 *---------------------------------------------------------------------------*/
#include "x_typedef.h"
#include "x_assert.h"
#include "x_stl_lib.h"
#include "x_drv_cli.h"

#include "hdmi_debug.h"
#include "hdmi_earc_if.h"

typedef struct
{
    UINT8 u1Level;
    UINT8 u1EARCStatus[5];
    EARCEDIDInfo_t eEDIDInfo;
    EARCAudioStatus_t eAudStatus;
}EARCCLIObject_t;

static EARCCLIObject_t eARCCLIObj;

void vCLIDebugPrintf(char *str, UINT8 *pData, UINT32 u4Length)
{
    UINT32 i=0;

    if(eARCCLIObj.u1Level == 0)
        return;

    if(str!=NULL)
    {
        LOG(1, "%s", str);
    }
    for(i=0;i<u4Length;i++)
    {   
        if((i%16) == 0)
        {
            Printf("\n");
        }
        Printf("0x%02x,",pData[i]);
    }
    Printf("\n");
}

UINT8 u1CLISetChannelStatus(EARCChannelStatus_t *eStatus)
{
    vCLIDebugPrintf("[EARC]CLI Set Channel Status:\n", eStatus->u1Status, eStatus->u1Length);
    return 0;
}

UINT8 u1CLISetAudioInfoFrame(EARCAudioInfoFrame_t *eInfoFrame)
{
    vCLIDebugPrintf("[EARC]CLI Set Audio InfoFrame:\n", eInfoFrame->u1Info, eInfoFrame->u1Length);
    return 0;
}

UINT8 u1CLISetValidityBit(BOOL bValidity)
{
    LOG(1, "[EARC]CLI Set Validity Bit:0x%x\n", bValidity);
    return 0;
}

UINT8 u1CLISetHPDStatus(UINT8 u1HpdStatus)
{
    LOG(1, "[EARC]CLI Set HPD Status:0x%x\n", u1HpdStatus);
    return 0;
}

UINT8 u1CLISet5VStatus(UINT8 u15VStatus)
{
    LOG(1, "[EARC]CLI Set 5V Status:0x%x\n", u15VStatus);
    return 0;
}

UINT8 u1CLISetHBRAInputStatus(BOOL bHbr)
{
    LOG(1, "[EARC]CLI Set HBRA Input Status:0x%x\n", bHbr);
    return 0;
}

UINT8 u1CLISetLayoutBit(BOOL bLayout)
{
    LOG(1, "[EARC]CLI Set Layout Bit:0x%x\n", bLayout);
    return 0;
}

UINT8 u1CLISetArcStatus(BOOL bOnOff)
{
    LOG(1, "[EARC]CLI Set Arc Status:0x%x\n", bOnOff);
    return 0;
}

UINT8 u1CLISetAudioPath(BOOL bPath)
{
    LOG(1, "[EARC]CLI Set Audio Path:%s\n", bPath?"I2S":"SPDIF");
    return 0;
}

UINT8 u1CLISetAudioLatency(INT16 i2Ms)
{
    LOG(1, "[EARC]CLI Set Audio Latency:%dms\n", i2Ms);
    return 0;
}

UINT8 u1CLISetTVStatus(BOOL bTVStatus)
{
    LOG(1, "[EARC]CLI Set TV Status:0x%x\n", bTVStatus);
    return 0;
}

UINT8 u1CLISetBtHpStatus(BOOL bConnect)
{
    LOG(1, "[EARC]CLI Set BtHp Status:0x%x\n", bConnect);
    return 0;
}

UINT8 u1CLISetEnable(BOOL bEn)
{
    LOG(1, "[EARC]CLI Set Enable:0x%x\n", bEn);
    return 0;
}

UINT8 u1CLISetHdmiMute(BOOL bMute)
{
    LOG(1, "[EARC]CLI Set Hdmi Mute:0x%x\n", bMute);
    return 0;
}

UINT8 u1CLISetAudioMute(BOOL bMute)
{
    LOG(1, "[EARC]CLI Set Audio Mute:0x%x\n", bMute);
    return 0;
}

EARCStatus_t eCLIGetEARCStatus(UINT32 u4PortId)
{
    UINT8 u1Status = HDMI_EARC_NOT_ENABLED;

    if(u4PortId < 5)
    {
        u1Status = eARCCLIObj.u1EARCStatus[u4PortId];
    }
    LOG(1, "[EARC]CLI Get EARC Status, Port:0x%x, Status:0x%x\n", u4PortId, u1Status);

    return u1Status;
}

UINT8 u1CLISetEARCStatus(E_HDMI_SWITCH_NUM ePortId, UINT8 u1Status)
{
    LOG(1, "[EARC]CLI Set EARC Status, Port:0x%x, Status:0x%x\n", ePortId, u1Status);
    if(ePortId < 5)
    {
        eARCCLIObj.u1EARCStatus[ePortId] = u1Status;
    }
    return 0;
}

UINT8 u1CLIGetEARCAudioStatus(EARCAudioStatus_t* eStatus)
{
    eStatus->bEARCConnect = eARCCLIObj.eAudStatus.bEARCConnect;
    eStatus->u1Capability = eARCCLIObj.eAudStatus.u1Capability;
    LOG(1, "[EARC]CLI Get EARC Audio Status, bConnect:0x%x, u1Capability:0x%x\n", \
                    eStatus->bEARCConnect, eStatus->u1Capability);
    return 0;
}

UINT8 u1CLISetEARCAudioStatus(EARCAudioStatus_t eStatus)
{
    LOG(1, "[EARC]CLI Set EARC Audio Status, bConnect:0x%x, u1Capability:0x%x\n", \
                    eStatus.bEARCConnect, eStatus.u1Capability);
    eARCCLIObj.eAudStatus.bEARCConnect = eStatus.bEARCConnect;
    eARCCLIObj.eAudStatus.u1Capability = eStatus.u1Capability;
    return 0;
}

static EARCFuncTable_t eCLIFuncTable =
{
    u1CLISetChannelStatus,
    u1CLISetAudioInfoFrame,
    u1CLISetValidityBit,
    u1CLISetHPDStatus,
    u1CLISet5VStatus,
    u1CLISetHBRAInputStatus,
    u1CLISetLayoutBit,
    u1CLISetArcStatus,
    u1CLISetAudioPath,
    u1CLISetAudioLatency,
    u1CLISetTVStatus,
    u1CLISetBtHpStatus,
    u1CLISetEnable,
    u1CLISetHdmiMute,
    u1CLISetAudioMute,
    eCLIGetEARCStatus,
    u1CLIGetEARCAudioStatus
};

INT32 _u4HDMIDebugSetStatus(INT32 i4Argc, const CHAR** szArgv)
{
    UINT8 u1Type;

    if(i4Argc == 1)
    {
        LOG(0, "usage: type\n");
        Printf("type: \n"
            "0:Set eARC Status\n"
            "1:Change HPD Status\n"
            "2:Set Menu TV Status\n"
            "3:Set Menu DDP Out\n"
            "4:Set Menu DDP Capability\n"
            "5:Set Menu Enable\n"
            "6:Set Audio Mute\n"
            "7:Set Audio Path\n");
        Printf("8:Set Audio Status\n"
            "9:Test PQ/BE Interface\n"
            "\n");
        return 0;
    }
    u1Type = (UINT8)StrToInt(szArgv[1]);
    switch(u1Type)
    {
        case 0:
        {
            UINT8 u1Value;
            E_HDMI_SWITCH_NUM ePort = HDMI_SWITCH_1;
            if(i4Argc == 4)
            {
                ePort = (E_HDMI_SWITCH_NUM)StrToInt(szArgv[2]);
                u1Value = (UINT8)StrToInt(szArgv[3]);
                ePort = eHDMIGetVirtualPortId(ePort);
                u1CLISetEARCStatus(ePort, u1Value);
            }
            break;
        }
        case 1:
        {
            UINT8 u1HPDStatus;
            if(i4Argc == 3)
            {
                u1HPDStatus = (UINT8)StrToInt(szArgv[2]);
                u1HDMIEARCChgHPD(u1HPDStatus);
                LOG(0, "[EARC]CLI Change hpd:%d\n",u1HPDStatus);
            }
            return 0;
        }
        case 2:
        {
            BOOL bTVStatus;
            if(i4Argc == 3)
            {
                bTVStatus = (BOOL)StrToInt(szArgv[2]);
                u1HDMIEARCMenuSetTVStatus(bTVStatus);
                LOG(0, "[EARC]CLI Set TV Status:%d\n",bTVStatus);
            }
            return 0;
        }
        case 3:
        {
            UINT8 u1DDPOut;
            if(i4Argc == 3)
            {
                u1DDPOut = (UINT8)StrToInt(szArgv[2]);
                u1HDMIEARCMenuSetDDPOut(u1DDPOut);
                LOG(0, "[EARC]CLI Set DDP Out:%d\n",u1DDPOut);
            }
            return 0;
        }
        case 4:
        {
            UINT8 u1DDPCap;
            if(i4Argc == 3)
            {
                u1DDPCap = (UINT8)StrToInt(szArgv[2]);
                u1HDMIEARCMenuSetDDPCap(u1DDPCap);
                LOG(0, "[EARC]CLI Set DDP Capability:%d\n",u1DDPCap);
            }
            return 0;
        }
        case 5:
        {
            BOOL bEn;
            if(i4Argc == 3)
            {
                bEn = (BOOL)StrToInt(szArgv[2]);
                u1HDMIEARCSetEnable(bEn);
                LOG(0, "[EARC]CLI Set Menu Enable:%d\n",bEn);
            }
            return 0;
        }
        case 6:
        {
            BOOL bMute;
            if(i4Argc == 3)
            {
                bMute = (BOOL)StrToInt(szArgv[2]);
                u1HDMIEARCSetAudioMute(bMute);
                LOG(0, "[EARC]CLI Set Audio Mute:%d\n",bMute);
            }
            return 0;
        }
        case 7:
        {
            BOOL bPath;
            if(i4Argc == 3)
            {
                bPath = (BOOL)StrToInt(szArgv[2]);
                u1HDMIEARCSetAudioPath(bPath);
                LOG(0, "[EARC]CLI Set Audio Path:%d\n",bPath);
            }
            return 0;
        }
        case 8:
        {
            EARCAudioStatus_t eStatus;
            if(i4Argc == 4)
            {
                eStatus.bEARCConnect = (BOOL)StrToInt(szArgv[2]);
                eStatus.u1Capability = (UINT8)StrToInt(szArgv[3]);
                u1CLISetEARCAudioStatus(eStatus);
            }
            return 0;
        }
        case 9:
        {
            UINT8 u1Type;
            if(i4Argc == 3)
            {
                u1Type = (UINT8)StrToInt(szArgv[2]);
                if(u1Type == 1)
                    vHDMIEARCSetGenParam(u1Type, &u1Type, sizeof(UINT8));
                else if(u1Type == 2)
                    vHDMIEARCSetBEGenParam(u1Type, &u1Type, sizeof(UINT8));
                else if(u1Type == 3)
                    vHDMIEARCSetPQGenParam(u1Type, &u1Type, sizeof(UINT8));
            }
            return 0;
        }
        default:
            break;
    }

    return 0;
}

INT32 _u4HDMIDebugGetStatus(INT32 i4Argc, const CHAR** szArgv)
{
    UINT8 u1Type;

    if(i4Argc == 1)
    {
        LOG(0, "usage: type\n");
        Printf("type: \n"
            "0:Print All of eARC Status\n"
            "1:GetChannelStatus\n"
            "2:GetAudInfoFrame\n"
            "3:GetValidityBit\n"
            "4:GetHbraInput\n"
            "5:GetLayoutBit\n"
            "6:GetAudioFS\n"
            "7:GetHdmiInputStatus\n");
        Printf("8:GetDataForInit\n"
            "9:GetMWReady\n"
            "10:GetAudioLatency\n"
            "11:Get eARC State\n"
            "\n");
        return 0;
    }
    u1Type = (UINT8)StrToInt(szArgv[1]);
    switch(u1Type)
    {
        case 0:
        {
            vHDMIEARCPrintStatus();
            return 0;
        }
        case 1:
        {
            EARCChannelStatus_t eStatus;
            u1HDMIEARCGetChannelStatus(&eStatus);
            vCLIDebugPrintf("[EARC]CLI Get Channel Status:\n", eStatus.u1Status, eStatus.u1Length);
            return 0;
        }
        case 2:
        {
            EARCAudioInfoFrame_t eStatus;
            u1HDMIEARCGetAudInfoFrame(&eStatus);
            vCLIDebugPrintf("[EARC]CLI Get Audio InfoFrame:\n", eStatus.u1Info, eStatus.u1Length);
            return 0;
        }
        case 3:
        {
            UINT8 u1Validity;
            u1HDMIEARCGetValidityBit(&u1Validity);
            LOG(0, "[EARC]CLI Get Validity Bit:0x%x\n", u1Validity);
            return 0;
        }
        case 4:
        {
            UINT8 u1Hbr;
            u1HDMIEARCIsHBRInput(&u1Hbr);
            LOG(0, "[EARC]CLI Get Hbr Input Status:0x%x\n", u1Hbr);
            return 0;
        }
        case 5:
        {
            UINT8 u1Layout;
            u1HDMIEARCGetLayoutBit(&u1Layout);
            LOG(0, "[EARC]CLI Get Layout Bit:0x%x\n", u1Layout);
            return 0;
        }
        case 6:
        {
            UINT32 u4Fs;
            u1HDMIEARCGetAudioFs(&u4Fs);
            LOG(0, "[EARC]CLI Get Audio Fs:0x%x\n", u4Fs);
            return 0;
        }
        case 7:
        {
            BOOL bFlag;
            u1HDMIEARCIsHDMIInput(&bFlag);
            LOG(0, "[EARC]CLI Get HDMI Input Status:%d\n", bFlag);
            return 0;
        }
        case 8:
        {
            EARCInitInfo_t eInitInfo;
            u1HDMIEARCGetInitialStatus(&eInitInfo);
            LOG(0, "[EARC]CLI Get Init Status, HPD:0x%x, 5V:0x%x, En:%d, TV:%d, BT:%d\n",\
                     eInitInfo.u1HPDStatus, eInitInfo.u15VStatus, eInitInfo.bEnable,\
                     eInitInfo.bTVStatus, eInitInfo.bBtHpStatus);
            return 0;
        }
        case 9:
        {
            BOOL bReady;
            if (RET_SUCCESS != u1HDMIEARCGetMWReady(&bReady)) {
                LOG(0, "[EARC] u1HDMIEARCGetMWReady() is fail\n");
                return 0;
            }
            LOG(0, "[EARC]CLI Get MW Ready:%d\n",bReady);
            return 0;
        }
        case 10:
        {
            INT16 i2Latency;
            u1HDMIEARCGetAudioLatency(&i2Latency);
            LOG(0, "[EARC]CLI Get Aud Latency:%d\n",i2Latency);
            return 0;
        }
        case 11:
        {
            E_HDMI_SWITCH_NUM ePort;
            
            if(i4Argc == 3)
            {
                ePort = (E_HDMI_SWITCH_NUM)StrToInt(szArgv[2]);
                u1HDMIEARCGetStatus(ePort);
            }
            return 0;
        }
        default:
            break;
    }
    return 0;
}

INT32 _u4HDMIDebugNotifyCEC(INT32 i4Argc, const CHAR** szArgv)
{
    EARCPortStatus_t eTmpStatus;
    if(i4Argc != 3)
    {
        LOG(0, "Usage:PortID, Status\n");
        return 0;
    }

    eTmpStatus.u4PortId = (UINT8)StrToInt(szArgv[1]);
    eTmpStatus.eStatus = (UINT8)StrToInt(szArgv[2]);
    vHDMIEARCEventNotify(EARC_EVENT_CONNECT_CHG_TO_CEC, (void *)&eTmpStatus);
    return 0;
}

INT32 _u4HDMIDebugNotifyHbr(INT32 i4Argc, const CHAR** szArgv)
{
    BOOL bHbrMode;
    if(i4Argc != 2)
    {
        LOG(0, "Usage: HbrMode\n");
        return 0;
    }

    bHbrMode = ((UINT8)StrToInt(szArgv[1])) > 0?1:0;
    vHDMIEARCEventNotify(EARC_EVENT_HBRA_MODE, (void *)&bHbrMode);
    return 0;
}

INT32 _u4HDMIDebugNotifyAud(INT32 i4Argc, const CHAR** szArgv)
{
    EARCAudioStatus_t eStatus;
    if(i4Argc != 3)
    {
        LOG(0, "Usage: connect, capbility\n");
        return 0;
    }

    eStatus.bEARCConnect = ((UINT8)StrToInt(szArgv[1])) > 0?1:0;
    eStatus.u1Capability = (UINT8)StrToInt(szArgv[2]);

    vHDMIEARCEventNotify(EARC_EVENT_CONNECT_CHG_TO_APP, (void *)&eStatus);
    return 0;
}

INT32 _u4HDMIDebugRead(INT32 i4Argc, const CHAR** szArgv)
{
    UINT32 u4DevID;
    UINT16 u2RegAddr;
    UINT8 u1Length;
    UINT8 pData[256] = {0};
    if(i4Argc != 4)
    {
        LOG(0, "Usage:u4DevID, u2RegAddr, length\n");
         return 0;
    }
    u4DevID = (UINT32)StrToInt(szArgv[1]);//0
    u2RegAddr = (UINT16)StrToInt(szArgv[2]);
    u1Length = (UINT8)StrToInt(szArgv[3]);

    LOG(0,"DevId:0x%x, RegAddr:0x%x, Length:0x%x\n", u4DevID, u2RegAddr, u1Length);
    if(u4HDMIEARCHostBlockRead(u4DevID, u2RegAddr, pData, (UINT16)u1Length) == RET_FAIL)
    {
        LOG(0,"I2C Read FAIL\n");
        return 0;
    }
    vCLIDebugPrintf("I2C Read Data:\n", pData, u1Length);
    return 0;
}

INT32 _u4HDMIDebugWrite(INT32 i4Argc, const CHAR** szArgv)
{
    UINT32 u4DevID;
    UINT16 u2RegAddr;
    UINT8 i;
    UINT8 u1Length;
    UINT8 pData[20] = {0};
    if((i4Argc < 4)||(i4Argc>20))
    {
        LOG(0, "Usage:u4DevID, u2RegAddr, Data0,Data1...\n");
         return 0;
    }
    u4DevID = (UINT32)StrToInt(szArgv[1]);//0
    u2RegAddr = (UINT16)StrToInt(szArgv[2]);
    
    pData[0] = (UINT8)StrToInt(szArgv[3]);
    u1Length = i4Argc -3;
    if(u1Length > 1)
    {
        for(i=1; i <= (u1Length-1); i++)
        {
            pData[i] = (UINT8)StrToInt(szArgv[3+i]);
        }
    }

    LOG(0,"DevId:0x%x, RegAddr:0x%x, Length:0x%x\n", u4DevID, u2RegAddr, u1Length);

    if(u4HDMIEARCHostBlockWrite(u4DevID, u2RegAddr, pData, (UINT16)u1Length) == RET_FAIL)
    {
        LOG(0,"I2C Write FAIL\n");
        return 0;
    }
    vCLIDebugPrintf("I2C Write Data:\n", pData, u1Length);
    return 0;
}

INT32 _u4HDMIDebugRegFuncTable(INT32 i4Argc, const CHAR** szArgv)
{
    UINT8 u1Type = 0;
    if(i4Argc != 2)
    {
        LOG(0, "Usage:\n 0:unregister func table\n 1:register func table\n");
        return 0;
    }
    u1Type = (UINT8)StrToInt(szArgv[1]);

    if(u1Type)
    {
        u1HDMIEARCRegFuncTable(&eCLIFuncTable);
    }
    else
    {
    }
    return 0;
}

INT32 _u4HDMIDebugGetDataBlock(INT32 i4Argc, const CHAR** szArgv)
{
    EARCEDIDInfo_t *pEdidInfo;
    u1HDMIEARCGetEDIDInfo(&pEdidInfo);
    vCLIDebugPrintf(NULL, pEdidInfo->u1DataBlock, 256);
    return 0;
}

INT32 _u4HDMIDebugEdidWrite(INT32 i4Argc, const CHAR** szArgv)
{
    UINT8 u1Offset;
    UINT8 i;
    if(i4Argc != 18)
    {
        LOG(0, "Usage:offset(0x10, 0x20...), data(16 bytes)\n");
        return 0;
    }
    u1Offset = (UINT8)StrToInt(szArgv[1]);
    if((u1Offset%16) != 0)
    {
        LOG(0, "Usage:offset should be 0x10, 0x20...\n");
        return 0;
    }
    for(i = 0; i < 16; i++)
    {
        eARCCLIObj.eEDIDInfo.u1DataBlock[u1Offset+i] = (UINT8)StrToInt(szArgv[2 + i]);
    }
    LOG(0, "offset:0x%02x\n", u1Offset);
    vCLIDebugPrintf("update cli data:\n", eARCCLIObj.eEDIDInfo.u1DataBlock+u1Offset, 16);
    return 0;
}

INT32 _u4HDMIDebugEdidUpdate(INT32 i4Argc, const CHAR** szArgv)
{
    if(i4Argc != 2)
    {
        LOG(0, "Usage:connect_status\n");
        return 0;
    }
    eARCCLIObj.eEDIDInfo.bEARCConnect = (UINT8)StrToInt(szArgv[1])?1:0;
    u1HDMIEARCUpdateEdid(&eARCCLIObj.eEDIDInfo);
    LOG(0,"[EARC]Output DDP:0x%x, EAC3:0x%x, AAC_LC:0x%x, AAC_LC_Ch:0x%x, AAC_LC_22ch:0x%x\n", \
            eARCCLIObj.eEDIDInfo.u1DDP, eARCCLIObj.eEDIDInfo.u1EAC3, eARCCLIObj.eEDIDInfo.AAC_LC, \
            eARCCLIObj.eEDIDInfo.AAC_LC_Ch, eARCCLIObj.eEDIDInfo.AAC_LC_22ch);
    return 0;
}

INT32 _u4HDMIDebugLogCmd(INT32 i4Argc, const CHAR** szArgv)
{
    if(i4Argc != 2)
    {
        LOG(0, "usage: 0:disable log  1:enable log\n");
        return 0;
    }
    eARCCLIObj.u1Level = (UINT8)StrToInt(szArgv[1])?1:0;
    LOG(0, "set debug lvl:0x%x\n", eARCCLIObj.u1Level);
    CLI_Parser_Arg("sif.hdmi.cust.earc.d_l %d",eARCCLIObj.u1Level);
    return 0;
}

CLIMOD_DEBUG_FUNCTIONS(HDMI)
CLI_EXEC_T arHDMIEARCCmdTbl[] = {
    CLIMOD_DEBUG_CLIENTRY(HDMI),
    {"dl", NULL, _u4HDMIDebugLogCmd, NULL, "enable/disable log", CLI_GUEST},
    {"ss", NULL, _u4HDMIDebugSetStatus, NULL, "set some earc status", CLI_GUEST},
    {"gs", NULL, _u4HDMIDebugGetStatus, NULL, "get some earc status", CLI_GUEST},
    {"read", NULL, _u4HDMIDebugRead, NULL, "Read register through i2c ", CLI_GUEST},
    {"write", NULL, _u4HDMIDebugWrite, NULL, "Write register through i2c ", CLI_GUEST},
    {"reg", NULL, _u4HDMIDebugRegFuncTable, NULL, "register function table", CLI_GUEST},
    {"gdb", NULL, _u4HDMIDebugGetDataBlock, NULL, "get data block", CLI_GUEST},
    {"hbrnfy", NULL, _u4HDMIDebugNotifyHbr, NULL, "HBR Notify", CLI_GUEST},
    {"cecnfy", NULL, _u4HDMIDebugNotifyCEC, NULL, "CEC Notify", CLI_GUEST},
    {"audnfy", NULL, _u4HDMIDebugNotifyAud, NULL, "Aud Notify", CLI_GUEST},
    {"edidw", NULL, _u4HDMIDebugEdidWrite, NULL, "Write EDID Block", CLI_GUEST},
    {"edidu", NULL, _u4HDMIDebugEdidUpdate, NULL, "EDID Update", CLI_GUEST},
    {NULL, NULL, NULL, NULL, NULL, CLI_SUPERVISOR}
};

